diff --git a/.changes/scoped-resources-table.md b/.changes/scoped-resources-table.md new file mode 100644 index 00000000..2ab47c29 --- /dev/null +++ b/.changes/scoped-resources-table.md @@ -0,0 +1,8 @@ +--- +"fs": "patch" +"http": "patch" +"updater": "patch" +"clipboard-manager": "patch" +--- + +Internally use the webview scoped resources table instead of the app one, so other webviews can't access other webviews resources. diff --git a/.changes/tauri-beta-15.md b/.changes/tauri-beta-15.md new file mode 100644 index 00000000..58145373 --- /dev/null +++ b/.changes/tauri-beta-15.md @@ -0,0 +1,8 @@ +--- +"fs": patch +"http": patch +"updater": patch +"clipboard-manager": patch +--- + +Update for tauri 2.0.0-beta.15. diff --git a/Cargo.lock b/Cargo.lock index be9f4aec..18dc6c11 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5992,14 +5992,15 @@ checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" [[package]] name = "tauri" -version = "2.0.0-beta.14" +version = "2.0.0-beta.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a50fb0bdb687486415224f8be47c78993e9f3ea575ee0d5177c90d0c71842f4a" +checksum = "cd0aba659957a3f1f1666acbf17723e8d41dcc177539bf1adbe55305f5d7118a" dependencies = [ "anyhow", "bytes", "cocoa 0.25.0", "dirs-next", + "dunce", "embed_plist", "futures-util", "getrandom 0.2.12", @@ -6043,9 +6044,9 @@ dependencies = [ [[package]] name = "tauri-build" -version = "2.0.0-beta.11" +version = "2.0.0-beta.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82a46303cc4bce0b17ad95965cbd8326e3511b9d2cb6fb13a4a4c98a11b0dcaf" +checksum = "33de24aabe2b9c340d67005800cb6dd40aac5283126a42896fc8eec0b87cbe45" dependencies = [ "anyhow", "cargo_toml", @@ -6067,9 +6068,9 @@ dependencies = [ [[package]] name = "tauri-codegen" -version = "2.0.0-beta.11" +version = "2.0.0-beta.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1665f6a986842061a67cb9dcbe2fa27076c1a616f6525fc06de9d6d52838d63" +checksum = "9d1d211268a9590bbf75cc85b47208f59b447626c76396256e12479ac7df6c8b" dependencies = [ "base64 0.22.0", "brotli", @@ -6094,9 +6095,9 @@ dependencies = [ [[package]] name = "tauri-macros" -version = "2.0.0-beta.11" +version = "2.0.0-beta.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0c1558fc42cc2a1735cfd5edb2954c735d4516f8ba31c58b7180ba8a2bc18de" +checksum = "b096f63f2724a1280ae0f5a34d0731de18ca18305e2ef6e5e9a39bb2710e8a85" dependencies = [ "heck", "proc-macro2", @@ -6571,9 +6572,9 @@ dependencies = [ [[package]] name = "tauri-runtime" -version = "2.0.0-beta.11" +version = "2.0.0-beta.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "612e05de1382575b32b5220b546861256f630f37ac64c29cab252592861b9bd4" +checksum = "96c957749c40db7999959f379f799db095f2248a80bdbb13d8c078f6c299240e" dependencies = [ "dpi", "gtk", @@ -6590,9 +6591,9 @@ dependencies = [ [[package]] name = "tauri-runtime-wry" -version = "2.0.0-beta.11" +version = "2.0.0-beta.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f73672897b5396cb05c2f21b12b66ecfd4b51fae619dd35387467660d6c00fb" +checksum = "6b937adb1cf3fa0457928ace959ca3fc1a85ddd69f56b124682d40f3e5683e60" dependencies = [ "cocoa 0.25.0", "gtk", @@ -6614,9 +6615,9 @@ dependencies = [ [[package]] name = "tauri-utils" -version = "2.0.0-beta.11" +version = "2.0.0-beta.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a148adf8077e1891c8b7d1c2be90c1c8eb8c7a071c35bb8edbdfe7cd9d8e23c" +checksum = "760ac613d7f0de95067bcbcbcea175fe1df88fc4ab59c7f0b2cc2d01dc16a199" dependencies = [ "aes-gcm 0.10.3", "brotli", diff --git a/examples/api/src-tauri/gen/schemas/desktop-schema.json b/examples/api/src-tauri/gen/schemas/desktop-schema.json index e5aaf342..fe227861 100644 --- a/examples/api/src-tauri/gen/schemas/desktop-schema.json +++ b/examples/api/src-tauri/gen/schemas/desktop-schema.json @@ -5983,6 +5983,13 @@ "webview:allow-set-webview-size" ] }, + { + "description": "webview:allow-set-webview-zoom -> Enables the set_webview_zoom command without any pre-configured scope.", + "type": "string", + "enum": [ + "webview:allow-set-webview-zoom" + ] + }, { "description": "webview:allow-webview-close -> Enables the webview_close command without any pre-configured scope.", "type": "string", @@ -6060,6 +6067,13 @@ "webview:deny-set-webview-size" ] }, + { + "description": "webview:deny-set-webview-zoom -> Denies the set_webview_zoom command without any pre-configured scope.", + "type": "string", + "enum": [ + "webview:deny-set-webview-zoom" + ] + }, { "description": "webview:deny-webview-close -> Denies the webview_close command without any pre-configured scope.", "type": "string", diff --git a/plugins/clipboard-manager/src/commands.rs b/plugins/clipboard-manager/src/commands.rs index e9a630d4..263eb0da 100644 --- a/plugins/clipboard-manager/src/commands.rs +++ b/plugins/clipboard-manager/src/commands.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use tauri::{command, AppHandle, Manager, ResourceId, Runtime, State}; +use tauri::{command, AppHandle, Manager, ResourceId, Runtime, State, Webview}; use crate::{ClipKind, Clipboard, ClipboardContents, Result}; @@ -17,11 +17,12 @@ pub(crate) async fn write_text( #[command] pub(crate) async fn write_image( - _app: AppHandle, + webview: Webview, clipboard: State<'_, Clipboard>, data: ClipKind, ) -> Result<()> { - clipboard.write_image(data) + let resources_table = webview.resources_table(); + clipboard.write_image_inner(data, &resources_table) } #[command] @@ -34,11 +35,11 @@ pub(crate) async fn read_text( #[command] pub(crate) async fn read_image( - app: AppHandle, + webview: Webview, clipboard: State<'_, Clipboard>, ) -> Result { let image = clipboard.read_image()?.to_owned(); - let mut resources_table = app.resources_table(); + let mut resources_table = webview.resources_table(); let rid = resources_table.add(image); Ok(rid) } diff --git a/plugins/clipboard-manager/src/desktop.rs b/plugins/clipboard-manager/src/desktop.rs index bcd15027..5a92f452 100644 --- a/plugins/clipboard-manager/src/desktop.rs +++ b/plugins/clipboard-manager/src/desktop.rs @@ -5,7 +5,7 @@ use arboard::ImageData; use image::ImageEncoder; use serde::de::DeserializeOwned; -use tauri::{image::Image, plugin::PluginApi, AppHandle, Runtime}; +use tauri::{image::Image, plugin::PluginApi, AppHandle, Manager, ResourceTable, Runtime}; use crate::models::*; @@ -39,11 +39,15 @@ impl Clipboard { } } - pub fn write_image(&self, kind: ClipKind) -> crate::Result<()> { + pub(crate) fn write_image_inner( + &self, + kind: ClipKind, + resources_table: &ResourceTable, + ) -> crate::Result<()> { match kind { ClipKind::Image { image, .. } => match &self.clipboard { Ok(clipboard) => { - let image = image.into_img(&self.app)?; + let image = image.into_img(resources_table)?; clipboard .lock() .unwrap() @@ -60,6 +64,11 @@ impl Clipboard { } } + pub fn write_image(&self, kind: ClipKind) -> crate::Result<()> { + let resources_table = self.app.resources_table(); + self.write_image_inner(kind, &resources_table) + } + pub fn read_text(&self) -> crate::Result { match &self.clipboard { Ok(clipboard) => { diff --git a/plugins/clipboard-manager/src/mobile.rs b/plugins/clipboard-manager/src/mobile.rs index cb4ea682..4df242af 100644 --- a/plugins/clipboard-manager/src/mobile.rs +++ b/plugins/clipboard-manager/src/mobile.rs @@ -37,6 +37,16 @@ impl Clipboard { self.0.run_mobile_plugin("write", kind).map_err(Into::into) } + pub(crate) fn write_image_inner( + &self, + kind: ClipKind, + resources_table: &tauri::ResourceTable, + ) -> crate::Result<()> { + Err(crate::Error::Clipboard( + "Unsupported on this platform".to_string(), + )) + } + pub fn write_image(&self, kind: ClipKind) -> crate::Result<()> { Err(crate::Error::Clipboard( "Unsupported on this platform".to_string(), diff --git a/plugins/deep-link/examples/app/.gitignore b/plugins/deep-link/examples/app/.gitignore index a547bf36..251ce6d2 100644 --- a/plugins/deep-link/examples/app/.gitignore +++ b/plugins/deep-link/examples/app/.gitignore @@ -8,7 +8,6 @@ pnpm-debug.log* lerna-debug.log* node_modules -dist dist-ssr *.local diff --git a/plugins/fs/src/commands.rs b/plugins/fs/src/commands.rs index e9e747fc..10f8b126 100644 --- a/plugins/fs/src/commands.rs +++ b/plugins/fs/src/commands.rs @@ -9,7 +9,7 @@ use tauri::{ ipc::{CommandScope, GlobalScope}, path::{BaseDirectory, SafePathBuf}, utils::config::FsScope, - AppHandle, Manager, Resource, ResourceId, Runtime, + Manager, Resource, ResourceId, Runtime, Webview, }; use std::{ @@ -72,14 +72,14 @@ pub struct BaseOptions { #[tauri::command] pub fn create( - app: AppHandle, + webview: Webview, global_scope: GlobalScope, command_scope: CommandScope, path: SafePathBuf, options: Option, ) -> CommandResult { let resolved_path = resolve_path( - &app, + &webview, &global_scope, &command_scope, path, @@ -91,7 +91,7 @@ pub fn create( resolved_path.display() ) })?; - let rid = app.resources_table().add(StdFileResource::new(file)); + let rid = webview.resources_table().add(StdFileResource::new(file)); Ok(rid) } @@ -122,14 +122,14 @@ fn default_true() -> bool { #[tauri::command] pub fn open( - app: AppHandle, + webview: Webview, global_scope: GlobalScope, command_scope: CommandScope, path: SafePathBuf, options: Option, ) -> CommandResult { let resolved_path = resolve_path( - &app, + &webview, &global_scope, &command_scope, path, @@ -164,14 +164,14 @@ pub fn open( ) })?; - let rid = app.resources_table().add(StdFileResource::new(file)); + let rid = webview.resources_table().add(StdFileResource::new(file)); Ok(rid) } #[tauri::command] -pub fn close(app: AppHandle, rid: ResourceId) -> CommandResult<()> { - app.resources_table().close(rid).map_err(Into::into) +pub fn close(webview: Webview, rid: ResourceId) -> CommandResult<()> { + webview.resources_table().close(rid).map_err(Into::into) } #[derive(Debug, Clone, Deserialize)] @@ -183,7 +183,7 @@ pub struct CopyFileOptions { #[tauri::command] pub fn copy_file( - app: AppHandle, + webview: Webview, global_scope: GlobalScope, command_scope: CommandScope, from_path: SafePathBuf, @@ -191,14 +191,14 @@ pub fn copy_file( options: Option, ) -> CommandResult<()> { let resolved_from_path = resolve_path( - &app, + &webview, &global_scope, &command_scope, from_path, options.as_ref().and_then(|o| o.from_path_base_dir), )?; let resolved_to_path = resolve_path( - &app, + &webview, &global_scope, &command_scope, to_path, @@ -225,14 +225,14 @@ pub struct MkdirOptions { #[tauri::command] pub fn mkdir( - app: AppHandle, + webview: Webview, global_scope: GlobalScope, command_scope: CommandScope, path: SafePathBuf, options: Option, ) -> CommandResult<()> { let resolved_path = resolve_path( - &app, + &webview, &global_scope, &command_scope, path, @@ -292,14 +292,14 @@ fn read_dir_inner>(path: P) -> crate::Result> { #[tauri::command] pub fn read_dir( - app: AppHandle, + webview: Webview, global_scope: GlobalScope, command_scope: CommandScope, path: SafePathBuf, options: Option, ) -> CommandResult> { let resolved_path = resolve_path( - &app, + &webview, &global_scope, &command_scope, path, @@ -318,12 +318,12 @@ pub fn read_dir( #[tauri::command] pub fn read( - app: AppHandle, + webview: Webview, rid: ResourceId, len: u32, ) -> CommandResult<(Vec, usize)> { let mut data = vec![0; len as usize]; - let file = app.resources_table().get::(rid)?; + let file = webview.resources_table().get::(rid)?; let nread = StdFileResource::with_lock(&file, |mut file| file.read(&mut data)) .map_err(|e| format!("faied to read bytes from file with error: {e}"))?; Ok((data, nread)) @@ -331,14 +331,14 @@ pub fn read( #[tauri::command] pub fn read_file( - app: AppHandle, + webview: Webview, global_scope: GlobalScope, command_scope: CommandScope, path: SafePathBuf, options: Option, ) -> CommandResult> { let resolved_path = resolve_path( - &app, + &webview, &global_scope, &command_scope, path, @@ -356,14 +356,14 @@ pub fn read_file( #[tauri::command] pub fn read_text_file( - app: AppHandle, + webview: Webview, global_scope: GlobalScope, command_scope: CommandScope, path: SafePathBuf, options: Option, ) -> CommandResult { let resolved_path = resolve_path( - &app, + &webview, &global_scope, &command_scope, path, @@ -381,7 +381,7 @@ pub fn read_text_file( #[tauri::command] pub fn read_text_file_lines( - app: AppHandle, + webview: Webview, global_scope: GlobalScope, command_scope: CommandScope, path: SafePathBuf, @@ -390,7 +390,7 @@ pub fn read_text_file_lines( use std::io::BufRead; let resolved_path = resolve_path( - &app, + &webview, &global_scope, &command_scope, path, @@ -405,17 +405,17 @@ pub fn read_text_file_lines( })?; let lines = BufReader::new(file).lines(); - let rid = app.resources_table().add(StdLinesResource::new(lines)); + let rid = webview.resources_table().add(StdLinesResource::new(lines)); Ok(rid) } #[tauri::command] pub fn read_text_file_lines_next( - app: AppHandle, + webview: Webview, rid: ResourceId, ) -> CommandResult<(Option, bool)> { - let mut resource_table = app.resources_table(); + let mut resource_table = webview.resources_table(); let lines = resource_table.get::(rid)?; let ret = StdLinesResource::with_lock(&lines, |lines| { @@ -437,14 +437,14 @@ pub struct RemoveOptions { #[tauri::command] pub fn remove( - app: AppHandle, + webview: Webview, global_scope: GlobalScope, command_scope: CommandScope, path: SafePathBuf, options: Option, ) -> CommandResult<()> { let resolved_path = resolve_path( - &app, + &webview, &global_scope, &command_scope, path, @@ -505,7 +505,7 @@ pub struct RenameOptions { #[tauri::command] pub fn rename( - app: AppHandle, + webview: Webview, global_scope: GlobalScope, command_scope: CommandScope, old_path: SafePathBuf, @@ -513,14 +513,14 @@ pub fn rename( options: Option, ) -> CommandResult<()> { let resolved_old_path = resolve_path( - &app, + &webview, &global_scope, &command_scope, old_path, options.as_ref().and_then(|o| o.old_path_base_dir), )?; let resolved_new_path = resolve_path( - &app, + &webview, &global_scope, &command_scope, new_path, @@ -547,13 +547,13 @@ pub enum SeekMode { #[tauri::command] pub fn seek( - app: AppHandle, + webview: Webview, rid: ResourceId, offset: i64, whence: SeekMode, ) -> CommandResult { use std::io::{Seek, SeekFrom}; - let file = app.resources_table().get::(rid)?; + let file = webview.resources_table().get::(rid)?; StdFileResource::with_lock(&file, |mut file| { file.seek(match whence { SeekMode::Start => SeekFrom::Start(offset as u64), @@ -567,14 +567,14 @@ pub fn seek( #[tauri::command] pub fn stat( - app: AppHandle, + webview: Webview, global_scope: GlobalScope, command_scope: CommandScope, path: SafePathBuf, options: Option, ) -> CommandResult { let resolved_path = resolve_path( - &app, + &webview, &global_scope, &command_scope, path, @@ -591,14 +591,14 @@ pub fn stat( #[tauri::command] pub fn lstat( - app: AppHandle, + webview: Webview, global_scope: GlobalScope, command_scope: CommandScope, path: SafePathBuf, options: Option, ) -> CommandResult { let resolved_path = resolve_path( - &app, + &webview, &global_scope, &command_scope, path, @@ -614,8 +614,8 @@ pub fn lstat( } #[tauri::command] -pub fn fstat(app: AppHandle, rid: ResourceId) -> CommandResult { - let file = app.resources_table().get::(rid)?; +pub fn fstat(webview: Webview, rid: ResourceId) -> CommandResult { + let file = webview.resources_table().get::(rid)?; let metadata = StdFileResource::with_lock(&file, |file| file.metadata()) .map_err(|e| format!("failed to get metadata of file with error: {e}"))?; Ok(get_stat(metadata)) @@ -623,7 +623,7 @@ pub fn fstat(app: AppHandle, rid: ResourceId) -> CommandResult( - app: AppHandle, + webview: Webview, global_scope: GlobalScope, command_scope: CommandScope, path: SafePathBuf, @@ -631,7 +631,7 @@ pub fn truncate( options: Option, ) -> CommandResult<()> { let resolved_path = resolve_path( - &app, + &webview, &global_scope, &command_scope, path, @@ -658,11 +658,11 @@ pub fn truncate( #[tauri::command] pub fn ftruncate( - app: AppHandle, + webview: Webview, rid: ResourceId, len: Option, ) -> CommandResult<()> { - let file = app.resources_table().get::(rid)?; + let file = webview.resources_table().get::(rid)?; StdFileResource::with_lock(&file, |file| file.set_len(len.unwrap_or(0))) .map_err(|e| format!("failed to truncate file with error: {e}")) .map_err(Into::into) @@ -670,11 +670,11 @@ pub fn ftruncate( #[tauri::command] pub fn write( - app: AppHandle, + webview: Webview, rid: ResourceId, data: Vec, ) -> CommandResult { - let file = app.resources_table().get::(rid)?; + let file = webview.resources_table().get::(rid)?; StdFileResource::with_lock(&file, |mut file| file.write(&data)) .map_err(|e| format!("failed to write bytes to file with error: {e}")) .map_err(Into::into) @@ -700,7 +700,7 @@ fn default_create_value() -> bool { } fn write_file_inner( - app: AppHandle, + webview: Webview, global_scope: &GlobalScope, command_scope: &CommandScope, path: SafePathBuf, @@ -708,7 +708,7 @@ fn write_file_inner( options: Option, ) -> CommandResult<()> { let resolved_path = resolve_path( - &app, + &webview, global_scope, command_scope, path, @@ -753,19 +753,19 @@ fn write_file_inner( #[tauri::command] pub fn write_file( - app: AppHandle, + webview: Webview, global_scope: GlobalScope, command_scope: CommandScope, path: SafePathBuf, data: Vec, options: Option, ) -> CommandResult<()> { - write_file_inner(app, &global_scope, &command_scope, path, &data, options) + write_file_inner(webview, &global_scope, &command_scope, path, &data, options) } #[tauri::command] pub fn write_text_file( - app: AppHandle, + webview: Webview, global_scope: GlobalScope, command_scope: CommandScope, path: SafePathBuf, @@ -773,7 +773,7 @@ pub fn write_text_file( options: Option, ) -> CommandResult<()> { write_file_inner( - app, + webview, &global_scope, &command_scope, path, @@ -784,14 +784,14 @@ pub fn write_text_file( #[tauri::command] pub fn exists( - app: AppHandle, + webview: Webview, global_scope: GlobalScope, command_scope: CommandScope, path: SafePathBuf, options: Option, ) -> CommandResult { let resolved_path = resolve_path( - &app, + &webview, &global_scope, &command_scope, path, @@ -801,7 +801,7 @@ pub fn exists( } pub fn resolve_path( - app: &AppHandle, + app: &Webview, global_scope: &GlobalScope, command_scope: &CommandScope, path: SafePathBuf, diff --git a/plugins/fs/src/watcher.rs b/plugins/fs/src/watcher.rs index 0795aa49..920b86e0 100644 --- a/plugins/fs/src/watcher.rs +++ b/plugins/fs/src/watcher.rs @@ -8,7 +8,7 @@ use serde::Deserialize; use tauri::{ ipc::{Channel, CommandScope, GlobalScope}, path::{BaseDirectory, SafePathBuf}, - AppHandle, Manager, Resource, ResourceId, Runtime, + Manager, Resource, ResourceId, Runtime, Webview, }; use std::{ @@ -82,7 +82,7 @@ pub struct WatchOptions { #[tauri::command] pub async fn watch( - app: AppHandle, + webview: Webview, paths: Vec, options: WatchOptions, on_event: Channel, @@ -92,7 +92,7 @@ pub async fn watch( let mut resolved_paths = Vec::with_capacity(paths.capacity()); for path in paths { resolved_paths.push(resolve_path( - &app, + &webview, &global_scope, &command_scope, path, @@ -124,7 +124,7 @@ pub async fn watch( WatcherKind::Watcher(watcher) }; - let rid = app + let rid = webview .resources_table() .add(WatcherResource::new(kind, resolved_paths)); @@ -132,8 +132,8 @@ pub async fn watch( } #[tauri::command] -pub async fn unwatch(app: AppHandle, rid: ResourceId) -> CommandResult<()> { - let watcher = app.resources_table().take::(rid)?; +pub async fn unwatch(webview: Webview, rid: ResourceId) -> CommandResult<()> { + let watcher = webview.resources_table().take::(rid)?; WatcherResource::with_lock(&watcher, |watcher| { match &mut watcher.kind { WatcherKind::Debouncer(ref mut debouncer) => { diff --git a/plugins/http/src/commands.rs b/plugins/http/src/commands.rs index e88608f6..4f93461c 100644 --- a/plugins/http/src/commands.rs +++ b/plugins/http/src/commands.rs @@ -11,7 +11,7 @@ use tauri::{ async_runtime::Mutex, command, ipc::{CommandScope, GlobalScope}, - AppHandle, Manager, ResourceId, Runtime, + Manager, ResourceId, Runtime, Webview, }; use crate::{ @@ -137,7 +137,7 @@ fn attach_proxy( #[command] pub async fn fetch( - app: AppHandle, + webview: Webview, client_config: ClientConfig, command_scope: CommandScope, global_scope: GlobalScope, @@ -249,7 +249,7 @@ pub async fn fetch( } let fut = async move { Ok(request.send().await.map_err(Into::into)) }; - let mut resources_table = app.resources_table(); + let mut resources_table = webview.resources_table(); let rid = resources_table.add(FetchRequest::new(Box::pin(fut))); Ok(rid) @@ -270,7 +270,7 @@ pub async fn fetch( .body(reqwest::Body::from(body))?; let fut = async move { Ok(Ok(reqwest::Response::from(response))) }; - let mut resources_table = app.resources_table(); + let mut resources_table = webview.resources_table(); let rid = resources_table.add(FetchRequest::new(Box::pin(fut))); Ok(rid) } @@ -279,9 +279,9 @@ pub async fn fetch( } #[command] -pub async fn fetch_cancel(app: AppHandle, rid: ResourceId) -> crate::Result<()> { +pub async fn fetch_cancel(webview: Webview, rid: ResourceId) -> crate::Result<()> { let req = { - let resources_table = app.resources_table(); + let resources_table = webview.resources_table(); resources_table.get::(rid)? }; let mut req = req.0.lock().await; @@ -292,11 +292,11 @@ pub async fn fetch_cancel(app: AppHandle, rid: ResourceId) -> cra #[tauri::command] pub async fn fetch_send( - app: AppHandle, + webview: Webview, rid: ResourceId, ) -> crate::Result { let req = { - let mut resources_table = app.resources_table(); + let mut resources_table = webview.resources_table(); resources_table.take::(rid)? }; @@ -315,7 +315,7 @@ pub async fn fetch_send( )); } - let mut resources_table = app.resources_table(); + let mut resources_table = webview.resources_table(); let rid = resources_table.add(ReqwestResponse(res)); Ok(FetchResponse { @@ -329,11 +329,11 @@ pub async fn fetch_send( #[tauri::command] pub(crate) async fn fetch_read_body( - app: AppHandle, + webview: Webview, rid: ResourceId, ) -> crate::Result { let res = { - let mut resources_table = app.resources_table(); + let mut resources_table = webview.resources_table(); resources_table.take::(rid)? }; let res = Arc::into_inner(res).unwrap().0; diff --git a/plugins/updater/src/commands.rs b/plugins/updater/src/commands.rs index 6d2668f2..db0f87db 100644 --- a/plugins/updater/src/commands.rs +++ b/plugins/updater/src/commands.rs @@ -5,7 +5,7 @@ use crate::{Result, Update, UpdaterExt}; use serde::Serialize; -use tauri::{ipc::Channel, AppHandle, Manager, ResourceId, Runtime}; +use tauri::{ipc::Channel, Manager, ResourceId, Runtime, Webview}; use std::time::Duration; use url::Url; @@ -37,13 +37,13 @@ pub(crate) struct Metadata { #[tauri::command] pub(crate) async fn check( - app: AppHandle, + webview: Webview, headers: Option>, timeout: Option, proxy: Option, target: Option, ) -> Result { - let mut builder = app.updater_builder(); + let mut builder = webview.updater_builder(); if let Some(headers) = headers { for (k, v) in headers { builder = builder.header(k, v)?; @@ -69,7 +69,7 @@ pub(crate) async fn check( metadata.version = update.version.clone(); metadata.date = update.date.map(|d| d.to_string()); metadata.body = update.body.clone(); - metadata.rid = Some(app.resources_table().add(update)); + metadata.rid = Some(webview.resources_table().add(update)); } Ok(metadata) @@ -77,11 +77,11 @@ pub(crate) async fn check( #[tauri::command] pub(crate) async fn download_and_install( - app: AppHandle, + webview: Webview, rid: ResourceId, on_event: Channel, ) -> Result<()> { - let update = app.resources_table().get::(rid)?; + let update = webview.resources_table().get::(rid)?; let mut first_chunk = true; diff --git a/plugins/websocket/examples/tauri-app/src-tauri/tauri.conf.json b/plugins/websocket/examples/tauri-app/src-tauri/tauri.conf.json index c4fe3f7f..6647b5e6 100644 --- a/plugins/websocket/examples/tauri-app/src-tauri/tauri.conf.json +++ b/plugins/websocket/examples/tauri-app/src-tauri/tauri.conf.json @@ -2,7 +2,7 @@ "identifier": "com.tauri.dev", "build": { "devUrl": "http://localhost:5173/", - "frontendDist": "../build", + "frontendDist": "../dist", "beforeDevCommand": "pnpm dev", "beforeBuildCommand": "pnpm build" },