diff --git a/plugin-runtime/src/gen/plugins/runtime.ts b/plugin-runtime/src/gen/plugins/runtime.ts index a3dad4fb..31f5f13a 100644 --- a/plugin-runtime/src/gen/plugins/runtime.ts +++ b/plugin-runtime/src/gen/plugins/runtime.ts @@ -382,17 +382,17 @@ export const PluginRuntimeDefinition = { responseStream: false, options: {}, }, - hookResponseFilter: { - name: "hookResponseFilter", - requestType: HookResponseFilterRequest, + hookExport: { + name: "hookExport", + requestType: HookExportRequest, requestStream: false, responseType: HookResponse, responseStream: false, options: {}, }, - hookExport: { - name: "hookExport", - requestType: HookExportRequest, + hookResponseFilter: { + name: "hookResponseFilter", + requestType: HookResponseFilterRequest, requestStream: false, responseType: HookResponse, responseStream: false, @@ -403,20 +403,20 @@ export const PluginRuntimeDefinition = { export interface PluginRuntimeServiceImplementation { hookImport(request: HookImportRequest, context: CallContext & CallContextExt): Promise>; + hookExport(request: HookExportRequest, context: CallContext & CallContextExt): Promise>; hookResponseFilter( request: HookResponseFilterRequest, context: CallContext & CallContextExt, ): Promise>; - hookExport(request: HookExportRequest, context: CallContext & CallContextExt): Promise>; } export interface PluginRuntimeClient { hookImport(request: DeepPartial, options?: CallOptions & CallOptionsExt): Promise; + hookExport(request: DeepPartial, options?: CallOptions & CallOptionsExt): Promise; hookResponseFilter( request: DeepPartial, options?: CallOptions & CallOptionsExt, ): Promise; - hookExport(request: DeepPartial, options?: CallOptions & CallOptionsExt): Promise; } type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 1b2a8d3d..0cff9bc1 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -2033,6 +2033,7 @@ name = "grpc" version = "0.1.0" dependencies = [ "anyhow", + "dunce", "hyper 0.14.29", "hyper-rustls 0.24.2", "log", @@ -3874,6 +3875,7 @@ version = "0.1.0" dependencies = [ "anyhow", "command-group", + "dunce", "log", "prost 0.13.1", "rand 0.8.5", diff --git a/src-tauri/grpc/Cargo.toml b/src-tauri/grpc/Cargo.toml index 688c5abe..5a6c351f 100644 --- a/src-tauri/grpc/Cargo.toml +++ b/src-tauri/grpc/Cargo.toml @@ -21,3 +21,4 @@ uuid = { version = "1.7.0", features = ["v4"] } tauri = { version = "2.0.0-beta" } tauri-plugin-shell = "2.0.0-beta" md5 = "0.7.0" +dunce = "1.0.4" diff --git a/src-tauri/grpc/src/proto.rs b/src-tauri/grpc/src/proto.rs index 2f8edfee..1a16c362 100644 --- a/src-tauri/grpc/src/proto.rs +++ b/src-tauri/grpc/src/proto.rs @@ -1,6 +1,6 @@ use std::env::temp_dir; use std::ops::Deref; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::str::FromStr; use anyhow::anyhow; @@ -35,12 +35,15 @@ pub async fn fill_pool_from_files( let global_import_dir = app_handle .path() .resolve("protoc-include", BaseDirectory::Resource) - .expect("failed to resolve protoc include directory") - .to_string_lossy() - .to_string(); + .expect("failed to resolve protoc include directory"); // HACK: Remove UNC prefix for Windows paths - let global_import_dir = global_import_dir.replace("\\\\?\\", ""); + let global_import_dir = dunce::simplified(&Path::from(global_import_dir)) + .to_string_lossy() + .to_string(); + let desc_path = dunce::simplified(&Path::from(desc_path)) + .to_string_lossy() + .to_string(); let mut args = vec![ "--include_imports".to_string(), @@ -48,7 +51,7 @@ pub async fn fill_pool_from_files( "-I".to_string(), global_import_dir, "-o".to_string(), - desc_path.to_string_lossy().to_string(), + desc_path, ]; for p in paths { diff --git a/src-tauri/tauri-plugin-plugin-runtime/Cargo.toml b/src-tauri/tauri-plugin-plugin-runtime/Cargo.toml index ad1ea02d..7f8b7942 100644 --- a/src-tauri/tauri-plugin-plugin-runtime/Cargo.toml +++ b/src-tauri/tauri-plugin-plugin-runtime/Cargo.toml @@ -6,6 +6,7 @@ edition = "2021" [dependencies] anyhow = "1.0.86" command-group = "5.0.1" +dunce = "1.0.4" log = "0.4.21" prost = "0.13.1" rand = "0.8.5" diff --git a/src-tauri/tauri-plugin-plugin-runtime/src/nodejs.rs b/src-tauri/tauri-plugin-plugin-runtime/src/nodejs.rs index 02bde511..d6ae135d 100644 --- a/src-tauri/tauri-plugin-plugin-runtime/src/nodejs.rs +++ b/src-tauri/tauri-plugin-plugin-runtime/src/nodejs.rs @@ -1,4 +1,4 @@ -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::process::Command; use std::time::Duration; @@ -7,8 +7,8 @@ use log::{debug, info}; use rand::distributions::{Alphanumeric, DistString}; use serde; use serde::Deserialize; -use tauri::{AppHandle, Manager, Runtime}; use tauri::path::BaseDirectory; +use tauri::{AppHandle, Manager, Runtime}; use tauri_plugin_shell::ShellExt; use tokio::fs; @@ -29,23 +29,28 @@ pub async fn node_start(app: &AppHandle, temp_dir: &PathBuf) -> S let plugins_dir = app .path() .resolve("plugins", BaseDirectory::Resource) - .expect("failed to resolve plugin directory resource") - .to_string_lossy() - .to_string(); + .expect("failed to resolve plugin directory resource"); - let plugin_runtime_dir = app + let plugin_runtime_main = app .path() .resolve("plugin-runtime", BaseDirectory::Resource) - .expect("failed to resolve plugin runtime resource"); + .expect("failed to resolve plugin runtime resource") + .join("index.cjs"); - // HACK: Remove UNC prefix for Windows paths - let plugins_dir = plugins_dir.replace("\\\\?\\", ""); + // HACK: Remove UNC prefix for Windows paths to pass to sidecar + + let plugins_dir = dunce::simplified(&Path::from(plugins_dir)) + .to_string_lossy() + .to_string(); + let plugin_runtime_main = dunce::simplified(&Path::from(plugin_runtime_main)) + .to_string_lossy() + .to_string(); info!( "Starting plugin runtime\n port_file={}\n plugins_dir={}\n runtime_dir={}", port_file_path.to_string_lossy(), plugins_dir, - plugin_runtime_dir.to_string_lossy(), + plugin_runtime_main, ); let cmd = app @@ -54,7 +59,7 @@ pub async fn node_start(app: &AppHandle, temp_dir: &PathBuf) -> S .expect("yaaknode not found") .env("YAAK_GRPC_PORT_FILE_PATH", port_file_path.clone()) .env("YAAK_PLUGINS_DIR", plugins_dir) - .args(&[plugin_runtime_dir.join("index.cjs")]); + .args(&[plugin_runtime_main]); let child = Command::from(cmd) .group_spawn()