From 84a6e44fa6f6432edfb92d0dcd7583a8378ca5ee Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Mon, 14 Aug 2023 10:54:24 -0300 Subject: [PATCH 1/6] feat: update to alpha.11 --- .changes/fix-docs-build.md | 1 - .changes/positioner-tray-flag.md | 5 + .changes/tauri-alpha.11.md | 53 +++ Cargo.lock | 325 ++++++++++++------ Cargo.toml | 4 +- examples/api/package.json | 6 +- examples/api/src-tauri/Cargo.toml | 2 +- examples/api/src-tauri/src/lib.rs | 2 +- examples/api/src-tauri/src/tray.rs | 223 ++++++------ examples/api/src-tauri/tauri.conf.json | 6 +- plugins/app/package.json | 4 +- plugins/authenticator/package.json | 4 +- plugins/autostart/package.json | 4 +- plugins/cli/package.json | 4 +- plugins/clipboard-manager/package.json | 4 +- plugins/dialog/package.json | 4 +- plugins/fs/package.json | 4 +- plugins/fs/src/api-iife.js | 2 +- plugins/fs/src/watcher.rs | 2 +- plugins/global-shortcut/guest-js/index.ts | 29 +- plugins/global-shortcut/package.json | 4 +- plugins/global-shortcut/src/api-iife.js | 2 +- plugins/global-shortcut/src/lib.rs | 49 +-- plugins/http/package.json | 4 +- plugins/log/package.json | 4 +- plugins/log/src/api-iife.js | 2 +- plugins/notification/package.json | 4 +- plugins/notification/src/api-iife.js | 2 +- plugins/os/package.json | 4 +- plugins/persisted-scope/src/lib.rs | 4 +- plugins/positioner/Cargo.toml | 2 +- plugins/positioner/package.json | 4 +- plugins/positioner/src/ext.rs | 30 +- plugins/positioner/src/lib.rs | 51 ++- plugins/process/package.json | 4 +- plugins/shell/guest-js/index.ts | 26 +- plugins/shell/package.json | 4 +- plugins/shell/src/api-iife.js | 2 +- plugins/shell/src/commands.rs | 9 +- .../examples/vanilla/package.json | 2 +- plugins/sql/package.json | 4 +- plugins/store/package.json | 4 +- plugins/store/src/api-iife.js | 2 +- plugins/stronghold/package.json | 4 +- plugins/updater/package.json | 4 +- plugins/updater/src/api-iife.js | 2 +- plugins/updater/src/commands.rs | 8 +- plugins/updater/tests/app-updater/src/main.rs | 2 +- plugins/upload/package.json | 4 +- plugins/upload/src/api-iife.js | 2 +- plugins/upload/src/lib.rs | 14 +- .../examples/svelte-app/package.json | 2 +- plugins/websocket/guest-js/index.ts | 27 +- plugins/websocket/package.json | 4 +- plugins/websocket/src/api-iife.js | 2 +- plugins/websocket/src/lib.rs | 10 +- plugins/window-state/package.json | 4 +- plugins/window-state/src/lib.rs | 4 +- plugins/window/package.json | 4 +- plugins/window/src/api-iife.js | 2 +- plugins/window/src/lib.rs | 2 +- pnpm-lock.yaml | 176 +++++----- shared/template/package.json | 4 +- 63 files changed, 641 insertions(+), 551 deletions(-) create mode 100644 .changes/positioner-tray-flag.md create mode 100644 .changes/tauri-alpha.11.md diff --git a/.changes/fix-docs-build.md b/.changes/fix-docs-build.md index 1e6c0b1a7..880c5935c 100644 --- a/.changes/fix-docs-build.md +++ b/.changes/fix-docs-build.md @@ -28,4 +28,3 @@ --- Fixes docs.rs build by enabling the `tauri/dox` feature flag. - diff --git a/.changes/positioner-tray-flag.md b/.changes/positioner-tray-flag.md new file mode 100644 index 000000000..4cf24118d --- /dev/null +++ b/.changes/positioner-tray-flag.md @@ -0,0 +1,5 @@ +--- +"positioner": patch +--- + +Change `system-tray` feature flag to `tray-icon`. diff --git a/.changes/tauri-alpha.11.md b/.changes/tauri-alpha.11.md new file mode 100644 index 000000000..0f5a7a0c3 --- /dev/null +++ b/.changes/tauri-alpha.11.md @@ -0,0 +1,53 @@ +--- +"app": patch +"app-js": patch +"authenticator": patch +"authenticator-js": patch +"autostart": patch +"autostart-js": patch +"cli": patch +"cli-js": patch +"clipboard-manager": patch +"clipboard-manager-js": patch +"dialog": patch +"dialog-js": patch +"fs": patch +"fs-js": patch +"global-shortcut": patch +"global-shortcut-js": patch +"http": patch +"http-js": patch +"localhost": patch +"log-plugin": patch +"log-js": patch +"notification": patch +"notification-js": patch +"os": patch +"os-js": patch +"persisted-scope": patch +"positioner": patch +"positioner-js": patch +"process": patch +"process-js": patch +"shell": patch +"shell-js": patch +"single-instance": patch +"sql": patch +"sql-js": patch +"store": patch +"store-js": patch +"stronghold": patch +"stronghold-js": patch +"updater": patch +"updater-js": patch +"upload": patch +"upload-js": patch +"websocket": patch +"websocket-js": patch +"window": patch +"window-js": patch +"window-state": patch +"window-state-js": patch +--- + +Update to alpha.11. diff --git a/Cargo.lock b/Cargo.lock index 457bbe4de..e0eb8d25a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -275,7 +275,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6041616acea41d67c4a984709ddab1587fd0b10efe5cc563fee954d2f011854" dependencies = [ "clipboard-win", - "core-graphics", + "core-graphics 0.22.3", "image", "log", "objc", @@ -927,8 +927,24 @@ dependencies = [ "block", "cocoa-foundation", "core-foundation", - "core-graphics", - "foreign-types", + "core-graphics 0.22.3", + "foreign-types 0.3.2", + "libc", + "objc", +] + +[[package]] +name = "cocoa" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6140449f97a6e97f9511815c5632d84c8aacf8ac271ad77c559218161a1373c" +dependencies = [ + "bitflags 1.3.2", + "block", + "cocoa-foundation", + "core-foundation", + "core-graphics 0.23.1", + "foreign-types 0.5.0", "libc", "objc", ] @@ -943,7 +959,7 @@ dependencies = [ "block", "core-foundation", "core-graphics-types", - "foreign-types", + "foreign-types 0.3.2", "libc", "objc", ] @@ -1078,7 +1094,20 @@ dependencies = [ "bitflags 1.3.2", "core-foundation", "core-graphics-types", - "foreign-types", + "foreign-types 0.3.2", + "libc", +] + +[[package]] +name = "core-graphics" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "970a29baf4110c26fedbc7f82107d42c23f7e88e404c4577ed73fe99ff85a212" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "core-graphics-types", + "foreign-types 0.5.0", "libc", ] @@ -1668,7 +1697,28 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" dependencies = [ - "foreign-types-shared", + "foreign-types-shared 0.1.1", +] + +[[package]] +name = "foreign-types" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965" +dependencies = [ + "foreign-types-macros", + "foreign-types-shared 0.3.1", +] + +[[package]] +name = "foreign-types-macros" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.28", ] [[package]] @@ -1677,6 +1727,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" +[[package]] +name = "foreign-types-shared" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" + [[package]] name = "form_urlencoded" version = "1.2.0" @@ -2310,9 +2366,9 @@ dependencies = [ [[package]] name = "html5ever" -version = "0.25.2" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5c13fb08e5d4dfc151ee5e88bae63f7773d61852f3bdc73c9f4b9e1bde03148" +checksum = "bea68cab48b8459f17cf1c944c67ddc572d272d9f2b274140f223ecb1da4a3b7" dependencies = [ "log", "mac", @@ -2436,16 +2492,6 @@ dependencies = [ "cc", ] -[[package]] -name = "ico" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "031530fe562d8c8d71c0635013d6d155bbfe8ba0aa4b4d2d24ce8af6b71047bd" -dependencies = [ - "byteorder", - "png", -] - [[package]] name = "ico" version = "0.3.0" @@ -2531,18 +2577,18 @@ dependencies = [ [[package]] name = "infer" -version = "0.9.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f178e61cdbfe084aa75a2f4f7a25a5bb09701a47ae1753608f194b15783c937a" +checksum = "a898e4b7951673fce96614ce5751d13c40fc5674bc2d759288e46c3ab62598b3" dependencies = [ "cfb", ] [[package]] name = "infer" -version = "0.12.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a898e4b7951673fce96614ce5751d13c40fc5674bc2d759288e46c3ab62598b3" +checksum = "cb33622da908807a06f9513c19b3c1ad50fab3e4137d82a78107d502075aa199" dependencies = [ "cfb", ] @@ -2729,9 +2775,9 @@ checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "javascriptcore-rs" -version = "0.17.0" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "110b9902c80c12bf113c432d0b71c7a94490b294a8234f326fd0abca2fac0b00" +checksum = "4cfcc681b896b083864a4a3c3b3ea196f14ff66b8641a68fde209c6d84434056" dependencies = [ "bitflags 1.3.2", "glib", @@ -2740,9 +2786,9 @@ dependencies = [ [[package]] name = "javascriptcore-rs-sys" -version = "0.5.1" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98a216519a52cd941a733a0ad3f1023cfdb1cd47f3955e8e863ed56f558f916c" +checksum = "b0983ba5b3ab9a0c0918de02c42dc71f795d6de08092f88a98ce9fdfdee4ba91" dependencies = [ "glib-sys", "gobject-sys", @@ -2752,16 +2798,18 @@ dependencies = [ [[package]] name = "jni" -version = "0.20.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "039022cdf4d7b1cf548d31f60ae783138e5fd42013f6271049d7df7afadef96c" +checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97" dependencies = [ "cesu8", + "cfg-if", "combine", "jni-sys", "log", "thiserror", "walkdir", + "windows-sys 0.45.0", ] [[package]] @@ -2838,13 +2886,14 @@ dependencies = [ ] [[package]] -name = "kuchiki" -version = "0.8.1" +name = "kuchikiki" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ea8e9c6e031377cff82ee3001dc8026cdf431ed4e2e6b51f98ab8c73484a358" +checksum = "f29e4755b7b995046f510a7520c42b2fed58b77bd94d5a87a8eb43d2fd126da8" dependencies = [ "cssparser", "html5ever", + "indexmap 1.9.3", "matches", "selectors", ] @@ -3047,13 +3096,13 @@ dependencies = [ [[package]] name = "markup5ever" -version = "0.10.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a24f40fb03852d1cdd84330cddcaf98e9ec08a7b7768e952fad3b4cf048ec8fd" +checksum = "7a2629bb1404f3d34c2e921f21fd34ba00b206124c81f65c50b43b6aaefeb016" dependencies = [ "log", - "phf 0.8.0", - "phf_codegen", + "phf 0.10.1", + "phf_codegen 0.10.0", "string_cache", "string_cache_codegen", "tendril", @@ -3190,6 +3239,25 @@ dependencies = [ "similar", ] +[[package]] +name = "muda" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47e33f46fb20f85553edb85e30a6a5231567f4103276ccdb5a2050613d253b1d" +dependencies = [ + "cocoa 0.25.0", + "crossbeam-channel", + "gdk", + "gdk-pixbuf", + "gtk", + "keyboard-types", + "objc", + "once_cell", + "png", + "thiserror", + "windows-sys 0.48.0", +] + [[package]] name = "native-tls" version = "0.2.11" @@ -3210,14 +3278,15 @@ dependencies = [ [[package]] name = "ndk" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2032c77e030ddee34a6787a64166008da93f6a352b629261d0fee232b8742dd4" +checksum = "451422b7e4718271c8b5b3aadf5adedba43dc76312454b387e98fae0fc951aa0" dependencies = [ "bitflags 1.3.2", "jni-sys", "ndk-sys", "num_enum", + "raw-window-handle", "thiserror", ] @@ -3229,9 +3298,9 @@ checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" [[package]] name = "ndk-sys" -version = "0.3.0" +version = "0.4.1+23.1.7779620" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e5a6ae77c8ee183dcbbba6150e2e6b9f3f4196a7666c02a715a95692ec1fa97" +checksum = "3cf2aae958bd232cac5069850591667ad422d263686d75b52a065f9badeee5a3" dependencies = [ "jni-sys", ] @@ -3514,7 +3583,7 @@ checksum = "345df152bc43501c5eb9e4654ff05f794effb78d4efe3d53abc158baddc0703d" dependencies = [ "bitflags 1.3.2", "cfg-if", - "foreign-types", + "foreign-types 0.3.2", "libc", "once_cell", "openssl-macros", @@ -3734,6 +3803,16 @@ dependencies = [ "phf_shared 0.8.0", ] +[[package]] +name = "phf_codegen" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb1c3a8bc4dd4e5cfce29b44ffc14bedd2ee294559a294e2a4d4c9e9a6a13cd" +dependencies = [ + "phf_generator 0.10.0", + "phf_shared 0.10.0", +] + [[package]] name = "phf_generator" version = "0.8.0" @@ -4617,7 +4696,7 @@ dependencies = [ "log", "matches", "phf 0.8.0", - "phf_codegen", + "phf_codegen 0.8.0", "precomputed-hash", "servo_arc", "smallvec", @@ -5166,9 +5245,9 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "state" -version = "0.5.3" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbe866e1e51e8260c9eed836a042a5e7f6726bb2b411dffeaa712e19c388f23b" +checksum = "2b8c4a4445d81357df8b1a650d0d0d6fbbbfe99d064aa5e02f3e4022061476d8" dependencies = [ "loom", ] @@ -5293,9 +5372,9 @@ checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "swift-rs" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05e51d6f2b5fff4808614f429f8a7655ac8bcfe218185413f3a60c508482c2d6" +checksum = "1bbdb58577b6301f8d17ae2561f32002a5bae056d444e0f69e611e504a276204" dependencies = [ "base64 0.21.2", "serde", @@ -5349,18 +5428,17 @@ dependencies = [ [[package]] name = "tao" -version = "0.19.1" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "746ae5d0ca57ae275a792f109f6e992e0b41a443abdf3f5c6eff179ef5b3443a" +checksum = "60279ecb16c33a6cef45cd37a9602455c190942d20e360bd8499bff49f2a48f3" dependencies = [ "bitflags 1.3.2", "cairo-rs", "cc", - "cocoa", + "cocoa 0.24.1", "core-foundation", - "core-graphics", + "core-graphics 0.22.3", "crossbeam-channel", - "dirs-next", "dispatch", "gdk", "gdk-pixbuf", @@ -5375,7 +5453,6 @@ dependencies = [ "instant", "jni", "lazy_static", - "libappindicator", "libc", "log", "ndk", @@ -5390,10 +5467,12 @@ dependencies = [ "serde", "tao-macros", "unicode-segmentation", + "url", "uuid", - "windows 0.44.0", + "windows 0.48.0", "windows-implement", "x11-dl", + "zbus", ] [[package]] @@ -5426,13 +5505,13 @@ checksum = "1d2faeef5759ab89935255b1a4cd98e0baf99d1085e37d36599c625dac49ae8e" [[package]] name = "tauri" -version = "2.0.0-alpha.10" +version = "2.0.0-alpha.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e18377a75e314aa1d476896af881ed63f57a78ca84889fe63e69067f0de158d" +checksum = "fad0a5c32ce9e3e9862fb8cd433abf63e65ffea9b80dcc44d3d991e6794ea9a6" dependencies = [ "anyhow", "bytes 1.4.0", - "cocoa", + "cocoa 0.25.0", "dirs-next", "embed_plist", "futures-util", @@ -5441,11 +5520,13 @@ dependencies = [ "gtk", "heck", "http", - "ico 0.2.0", - "infer 0.9.0", + "ico", + "infer 0.15.0", "jni", "libc", "log", + "mime", + "muda", "objc", "once_cell", "percent-encoding", @@ -5453,7 +5534,6 @@ dependencies = [ "rand 0.8.5", "raw-window-handle", "reqwest", - "semver", "serde", "serde_json", "serde_repr", @@ -5465,26 +5545,27 @@ dependencies = [ "tauri-runtime", "tauri-runtime-wry", "tauri-utils", - "tempfile", "thiserror", "tokio", + "tray-icon", "url", "uuid", "webkit2gtk", "webview2-com", - "windows 0.44.0", + "windows 0.48.0", ] [[package]] name = "tauri-build" -version = "2.0.0-alpha.6" +version = "2.0.0-alpha.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a52990870fd043f1d3bd6719ae713ef2e0c50431334d7249f6ae8509d1b8c326" +checksum = "dc47d3c84f4aeac397cd956267f3b8060c5a2dba78288a5ccf9a8b7a8c1e7025" dependencies = [ "anyhow", "cargo_toml", "heck", "json-patch", + "plist", "quote", "semver", "serde", @@ -5498,13 +5579,13 @@ dependencies = [ [[package]] name = "tauri-codegen" -version = "2.0.0-alpha.6" +version = "2.0.0-alpha.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c1f1611ab0896f2693163ba4e8f3e39c02a1b70cdca4314286b5e365a5e08c6" +checksum = "7f98a67c7ef3cb3c25de91fe1fa16cc3681997f6ec99da0a7496d6feae2ea91e" dependencies = [ "base64 0.21.2", "brotli", - "ico 0.3.0", + "ico", "json-patch", "plist", "png", @@ -5524,9 +5605,9 @@ dependencies = [ [[package]] name = "tauri-macros" -version = "2.0.0-alpha.6" +version = "2.0.0-alpha.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22752425c6dd6f3a058f376db7371f1d5bac250e340d40ba6c97ecf7182eef29" +checksum = "b01cb5f945c71e040c5d191c32598565ae26cc266a9d5d4f7dd2dc324c5cfdd0" dependencies = [ "heck", "proc-macro2", @@ -5676,7 +5757,7 @@ version = "2.0.0-alpha.0" dependencies = [ "android_logger", "byte-unit", - "cocoa", + "cocoa 0.24.1", "fern", "log", "objc", @@ -5907,9 +5988,9 @@ dependencies = [ [[package]] name = "tauri-runtime" -version = "0.13.0-alpha.6" +version = "1.0.0-alpha.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7ce19f1309299bbc38ee9236307fad4943bd8fb09dd3fea5e9dd93c1d0898d6" +checksum = "f5ba2ea1c0b7a2c3e53259edc3c78527e9f40fa7b45f73c52ab5165e42f9d18a" dependencies = [ "gtk", "http", @@ -5923,16 +6004,16 @@ dependencies = [ "thiserror", "url", "uuid", - "windows 0.44.0", + "windows 0.48.0", ] [[package]] name = "tauri-runtime-wry" -version = "0.13.0-alpha.6" +version = "1.0.0-alpha.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1231be42085f3a8b150e615601f8a070bd16bf579771a5dafe2931970a05b518" +checksum = "095d8a6cb312211bd0ed6b51f078be2e5bba4e3244b5fdbe39fce2ebfc0d7a15" dependencies = [ - "cocoa", + "cocoa 0.24.1", "gtk", "jni", "percent-encoding", @@ -5943,15 +6024,15 @@ dependencies = [ "uuid", "webkit2gtk", "webview2-com", - "windows 0.44.0", + "windows 0.48.0", "wry", ] [[package]] name = "tauri-utils" -version = "2.0.0-alpha.6" +version = "2.0.0-alpha.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e2812e0cdfffb892c654555b2f1b8c84a035b4c56eb1646cb3eb5a9d8164d8e" +checksum = "06bcd7c6f67fd6371dcc22da7d7f26ec12c4eae26ad7bc54943bb9f35b5db302" dependencies = [ "aes-gcm 0.10.2", "brotli", @@ -5963,7 +6044,7 @@ dependencies = [ "html5ever", "infer 0.12.0", "json-patch", - "kuchiki", + "kuchikiki", "memchr", "phf 0.10.1", "proc-macro2", @@ -5976,7 +6057,7 @@ dependencies = [ "thiserror", "url", "walkdir", - "windows 0.44.0", + "windows 0.48.0", ] [[package]] @@ -6345,6 +6426,25 @@ dependencies = [ "tracing-log", ] +[[package]] +name = "tray-icon" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b0e5bec13da15e62330e9bcf8b9fd42489b5acfe29ac8fec7ed659dbee21d9" +dependencies = [ + "cocoa 0.25.0", + "core-graphics 0.23.1", + "crossbeam-channel", + "dirs-next", + "libappindicator", + "muda", + "objc", + "once_cell", + "png", + "thiserror", + "windows-sys 0.48.0", +] + [[package]] name = "treediff" version = "4.0.2" @@ -6760,9 +6860,9 @@ dependencies = [ [[package]] name = "webkit2gtk" -version = "0.19.2" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8eea819afe15eb8dcdff4f19d8bfda540bae84d874c10e6f4b8faf2d6704bd1" +checksum = "3ba4cce9085e0fb02575cfd45c328740dde78253cba516b1e8be2ca0f57bd8bf" dependencies = [ "bitflags 1.3.2", "cairo-rs", @@ -6784,9 +6884,9 @@ dependencies = [ [[package]] name = "webkit2gtk-sys" -version = "0.19.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0ac7a95ddd3fdfcaf83d8e513b4b1ad101b95b413b6aa6662ed95f284fc3d5b" +checksum = "f4489eb24e8cf0a3d0555fd3a8f7adec2a5ece34c1e7b7c9a62da7822fd40a59" dependencies = [ "bitflags 1.3.2", "cairo-sys-rs", @@ -6841,38 +6941,39 @@ dependencies = [ [[package]] name = "webview2-com" -version = "0.22.1" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11296e5daf3a653b79bf47d66c380e4143d5b9c975818871179a3bda79499562" +checksum = "79e563ffe8e84d42e43ffacbace8780c0244fc8910346f334613559d92e203ad" dependencies = [ "webview2-com-macros", "webview2-com-sys", - "windows 0.44.0", + "windows 0.48.0", "windows-implement", + "windows-interface", ] [[package]] name = "webview2-com-macros" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaebe196c01691db62e9e4ca52c5ef1e4fd837dcae27dae3ada599b5a8fd05ac" +checksum = "ac1345798ecd8122468840bcdf1b95e5dc6d2206c5e4b0eafa078d061f59c9bc" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.28", ] [[package]] name = "webview2-com-sys" -version = "0.22.1" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde542bed28058a5b028d459689ee57f1d06685bb6c266da3b91b1be6703952f" +checksum = "19d39576804304cf9ead192467ef47f7859a1a12fec3bd459d5ba34b8cd65ed5" dependencies = [ "regex", "serde", "serde_json", "thiserror", - "windows 0.44.0", + "windows 0.48.0", "windows-bindgen", "windows-metadata", ] @@ -6951,7 +7052,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29d30320647cfc3dc45554c8ad825b84831def81f967a2f7589931328ff9b16d" dependencies = [ - "cocoa", + "cocoa 0.24.1", "objc", "raw-window-handle", "windows-sys 0.42.0", @@ -6989,8 +7090,6 @@ version = "0.44.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e745dab35a0c4c77aa3ce42d595e13d2003d6902d6b08c9ef5fc326d08da12b" dependencies = [ - "windows-implement", - "windows-interface", "windows-targets 0.42.2", ] @@ -7000,14 +7099,16 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ + "windows-implement", + "windows-interface", "windows-targets 0.48.1", ] [[package]] name = "windows-bindgen" -version = "0.44.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222204ecf46521382a4d88b4a1bbefca9f8855697b4ab7d20803901425e061a3" +checksum = "1fe21a77bc54b7312dbd66f041605e098990c98be48cd52967b85b5e60e75ae6" dependencies = [ "windows-metadata", "windows-tokens", @@ -7015,9 +7116,9 @@ dependencies = [ [[package]] name = "windows-implement" -version = "0.44.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce87ca8e3417b02dc2a8a22769306658670ec92d78f1bd420d6310a67c245c6" +checksum = "5e2ee588991b9e7e6c8338edf3333fbe4da35dc72092643958ebb43f0ab2c49c" dependencies = [ "proc-macro2", "quote", @@ -7026,9 +7127,9 @@ dependencies = [ [[package]] name = "windows-interface" -version = "0.44.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "853f69a591ecd4f810d29f17e902d40e349fb05b0b11fff63b08b826bfe39c7f" +checksum = "e6fb8df20c9bcaa8ad6ab513f7b40104840c8867d5751126e4df3b08388d0cc7" dependencies = [ "proc-macro2", "quote", @@ -7037,9 +7138,9 @@ dependencies = [ [[package]] name = "windows-metadata" -version = "0.44.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee78911e3f4ce32c1ad9d3c7b0bd95389662ad8d8f1a3155688fed70bd96e2b6" +checksum = "422ee0e5f0e2cc372bb6addbfff9a8add712155cd743df9c15f6ab000f31432d" [[package]] name = "windows-sys" @@ -7119,9 +7220,9 @@ dependencies = [ [[package]] name = "windows-tokens" -version = "0.44.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4251900975a0d10841c5d4bde79c56681543367ef811f3fabb8d1803b0959b" +checksum = "b34c9a3b28cb41db7385546f7f9a8179348dffc89923dde66857b1ba5312f6b4" [[package]] name = "windows_aarch64_gnullvm" @@ -7307,14 +7408,14 @@ dependencies = [ [[package]] name = "wry" -version = "0.28.3" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d15f9f827d537cefe6d047be3930f5d89b238dfb85e08ba6a319153217635aa" +checksum = "4c6289018fa3cbc051c13f4ae1a102d80c3f35a527456c75567eb2cad6989020" dependencies = [ - "base64 0.13.1", + "base64 0.21.2", "block", - "cocoa", - "core-graphics", + "cocoa 0.24.1", + "core-graphics 0.22.3", "crossbeam-channel", "dunce", "gdk", @@ -7324,7 +7425,7 @@ dependencies = [ "html5ever", "http", "javascriptcore-rs", - "kuchiki", + "kuchikiki", "libc", "log", "objc", @@ -7340,7 +7441,7 @@ dependencies = [ "webkit2gtk", "webkit2gtk-sys", "webview2-com", - "windows 0.44.0", + "windows 0.48.0", "windows-implement", ] diff --git a/Cargo.toml b/Cargo.toml index fce722552..163cc4dfd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,8 +5,8 @@ resolver = "2" [workspace.dependencies] serde = { version = "1", features = ["derive"] } log = "0.4" -tauri = "2.0.0-alpha.10" -tauri-build = "2.0.0-alpha.6" +tauri = "2.0.0-alpha.11" +tauri-build = "2.0.0-alpha.8" serde_json = "1" thiserror = "1" diff --git a/examples/api/package.json b/examples/api/package.json index d6cc383d1..b546fedd5 100644 --- a/examples/api/package.json +++ b/examples/api/package.json @@ -9,7 +9,7 @@ "serve": "vite preview" }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.5", + "@tauri-apps/api": "2.0.0-alpha.6", "@tauri-apps/plugin-app": "2.0.0-alpha.0", "@tauri-apps/plugin-cli": "2.0.0-alpha.0", "@tauri-apps/plugin-clipboard-manager": "2.0.0-alpha.0", @@ -29,11 +29,11 @@ "@iconify-json/codicon": "^1.1.26", "@iconify-json/ph": "^1.1.5", "@sveltejs/vite-plugin-svelte": "^2.4.1", - "@tauri-apps/cli": "2.0.0-alpha.10", + "@tauri-apps/cli": "2.0.0-alpha.11", "@unocss/extractor-svelte": "^0.53.1", "internal-ip": "^8.0.0", "svelte": "^3.59.1", "unocss": "^0.53.1", "vite": "^4.3.9" } -} +} \ No newline at end of file diff --git a/examples/api/src-tauri/Cargo.toml b/examples/api/src-tauri/Cargo.toml index b1f1b09dd..2fd7fe6b1 100644 --- a/examples/api/src-tauri/Cargo.toml +++ b/examples/api/src-tauri/Cargo.toml @@ -37,7 +37,7 @@ tauri-plugin-window = { path = "../../../plugins/window", version = "2.0.0-alpha "icon-png", "isolation", "macos-private-api", - "system-tray", + "tray-icon", "protocol-asset" ] diff --git a/examples/api/src-tauri/src/lib.rs b/examples/api/src-tauri/src/lib.rs index 00da3ebcd..79405a10d 100644 --- a/examples/api/src-tauri/src/lib.rs +++ b/examples/api/src-tauri/src/lib.rs @@ -44,7 +44,7 @@ pub fn run() { .setup(move |app| { #[cfg(desktop)] { - tray::create_tray(app)?; + tray::create_tray(app.handle())?; app.handle().plugin(tauri_plugin_cli::init())?; app.handle() .plugin(tauri_plugin_global_shortcut::Builder::new().build())?; diff --git a/examples/api/src-tauri/src/tray.rs b/examples/api/src-tauri/src/tray.rs index fdd815d09..cff7ebb73 100644 --- a/examples/api/src-tauri/src/tray.rs +++ b/examples/api/src-tauri/src/tray.rs @@ -4,140 +4,113 @@ use std::sync::atomic::{AtomicBool, Ordering}; use tauri::{ - CustomMenuItem, Manager, SystemTray, SystemTrayEvent, SystemTrayMenu, WindowBuilder, WindowUrl, + menu::{Menu, MenuItem}, + tray::{ClickType, TrayIconBuilder}, + Manager, Runtime, WindowBuilder, WindowUrl, }; -use tauri_plugin_dialog::DialogExt; -use tauri_plugin_shell::ShellExt; - -pub fn create_tray(app: &tauri::App) -> tauri::Result<()> { - let mut tray_menu1 = SystemTrayMenu::new() - .add_item(CustomMenuItem::new("toggle", "Toggle")) - .add_item(CustomMenuItem::new("new", "New window")) - .add_item(CustomMenuItem::new("icon_1", "Tray Icon 1")) - .add_item(CustomMenuItem::new("icon_2", "Tray Icon 2")); +pub fn create_tray(app: &tauri::AppHandle) -> tauri::Result<()> { + let toggle_i = MenuItem::with_id(app, "toggle", "Toggle", true, None); + let new_window_i = MenuItem::with_id(app, "new-window", "New window", true, None); + let icon_i_1 = MenuItem::with_id(app, "icon-1", "Icon 1", true, None); + let icon_i_2 = MenuItem::with_id(app, "icon-2", "Icon 2", true, None); #[cfg(target_os = "macos")] - { - tray_menu1 = tray_menu1.add_item(CustomMenuItem::new("set_title", "Set Title")); - } - - tray_menu1 = tray_menu1 - .add_item(CustomMenuItem::new("switch_menu", "Switch Menu")) - .add_item(CustomMenuItem::new("about", "About")) - .add_item(CustomMenuItem::new("exit_app", "Quit")) - .add_item(CustomMenuItem::new("destroy", "Destroy")); + let set_title_i = MenuItem::with_id(app, "set-title", "Set Title", true, None); + let switch_i = MenuItem::with_id(app, "switch-menu", "Switch Menu", true, None); + let quit_i = MenuItem::with_id(app, "quit", "Quit", true, None); + let remove_tray_i = MenuItem::with_id(app, "remove-tray", "Remove Tray icon", true, None); + let menu1 = Menu::with_items( + app, + &[ + &toggle_i, + &new_window_i, + &icon_i_1, + &icon_i_2, + #[cfg(target_os = "macos")] + &set_title_i, + &switch_i, + &quit_i, + &remove_tray_i, + ], + )?; + let menu2 = Menu::with_items( + app, + &[&toggle_i, &new_window_i, &switch_i, &quit_i, &remove_tray_i], + )?; - let tray_menu2 = SystemTrayMenu::new() - .add_item(CustomMenuItem::new("toggle", "Toggle")) - .add_item(CustomMenuItem::new("new", "New window")) - .add_item(CustomMenuItem::new("switch_menu", "Switch Menu")) - .add_item(CustomMenuItem::new("about", "About")) - .add_item(CustomMenuItem::new("exit_app", "Quit")) - .add_item(CustomMenuItem::new("destroy", "Destroy")); let is_menu1 = AtomicBool::new(true); - let handle = app.handle(); - let tray_id = "my-tray".to_string(); - SystemTray::new() - .with_id(&tray_id) - .with_menu(tray_menu1.clone()) - .with_tooltip("Tauri") - .on_event(move |event| { - let tray_handle = handle.tray_handle_by_id(&tray_id).unwrap(); - match event { - SystemTrayEvent::LeftClick { - position: _, - size: _, - .. - } => { - let window = handle.get_window("main").unwrap(); - window.show().unwrap(); - window.set_focus().unwrap(); + let _ = TrayIconBuilder::with_id("tray-1") + .tooltip("Tauri") + .icon(app.default_window_icon().unwrap().clone()) + .menu(&menu1) + .menu_on_left_click(false) + .on_menu_event(move |app, event| match event.id.as_ref() { + "quit" => { + app.exit(0); + } + "remove-tray" => { + app.remove_tray_by_id("tray-1"); + } + "toggle" => { + if let Some(window) = app.get_window("main") { + let new_title = if window.is_visible().unwrap_or_default() { + let _ = window.hide(); + "Show" + } else { + let _ = window.show(); + let _ = window.set_focus(); + "Hide" + }; + toggle_i.set_text(new_title).unwrap(); } - SystemTrayEvent::MenuItemClick { id, .. } => { - let item_handle = tray_handle.get_item(&id); - match id.as_str() { - "exit_app" => { - // exit the app - handle.exit(0); - } - "destroy" => { - tray_handle.destroy().unwrap(); - } - "toggle" => { - let window = handle.get_window("main").unwrap(); - let new_title = if window.is_visible().unwrap() { - window.hide().unwrap(); - "Show" - } else { - window.show().unwrap(); - "Hide" - }; - item_handle.set_title(new_title).unwrap(); - } - "new" => { - WindowBuilder::new(&handle, "new", WindowUrl::App("index.html".into())) - .title("Tauri") - .build() - .unwrap(); - } - "set_title" => { - #[cfg(target_os = "macos")] - tray_handle.set_title("Tauri").unwrap(); - } - "icon_1" => { - #[cfg(target_os = "macos")] - tray_handle.set_icon_as_template(true).unwrap(); - - tray_handle - .set_icon(tauri::Icon::Raw( - include_bytes!("../icons/tray_icon_with_transparency.png") - .to_vec(), - )) - .unwrap(); - } - "icon_2" => { - #[cfg(target_os = "macos")] - tray_handle.set_icon_as_template(true).unwrap(); + } + "new-window" => { + let _ = WindowBuilder::new(app, "new", WindowUrl::App("index.html".into())) + .title("Tauri") + .build(); + } + #[cfg(target_os = "macos")] + "set-title" => { + if let Some(tray) = app.tray_by_id("tray-1") { + let _ = tray.set_title(Some("Tauri")); + } + } + i @ "icon-1" | i @ "icon-2" => { + if let Some(tray) = app.tray_by_id("tray-1") { + let _ = tray.set_icon(Some(tauri::Icon::Raw(if i == "icon-1" { + include_bytes!("../icons/icon.ico").to_vec() + } else { + include_bytes!("../icons/tray_icon_with_transparency.png").to_vec() + }))); + } + } + "switch-menu" => { + let flag = is_menu1.load(Ordering::Relaxed); + let (menu, tooltip) = if flag { + (menu2.clone(), "Menu 2") + } else { + (menu1.clone(), "Tauri") + }; + if let Some(tray) = app.tray_by_id("tray-1") { + let _ = tray.set_menu(Some(menu)); + let _ = tray.set_tooltip(Some(tooltip)); + } + is_menu1.store(!flag, Ordering::Relaxed); + } - tray_handle - .set_icon(tauri::Icon::Raw( - include_bytes!("../icons/icon.ico").to_vec(), - )) - .unwrap(); - } - "switch_menu" => { - let flag = is_menu1.load(Ordering::Relaxed); - let (menu, tooltip) = if flag { - (tray_menu2.clone(), "Menu 2") - } else { - (tray_menu1.clone(), "Tauri") - }; - tray_handle.set_menu(menu).unwrap(); - tray_handle.set_tooltip(tooltip).unwrap(); - is_menu1.store(!flag, Ordering::Relaxed); - } - "about" => { - let window = handle.get_window("main").unwrap(); - window - .dialog() - .message("Tauri demo app") - .title("About app") - .parent(&window) - .ok_button_label("Homepage") - .cancel_button_label("Cancel") - .show(move |ok| { - if ok { - window.shell().open("https://tauri.app/", None).unwrap(); - } - }); - } - _ => {} - } + _ => {} + }) + .on_tray_event(|tray, event| { + if event.click_type == ClickType::Left { + let app = tray.app_handle(); + if let Some(window) = app.get_window("main") { + let _ = window.show(); + let _ = window.set_focus(); } - _ => {} } }) - .build(app) - .map(|_| ()) + .build(app); + + Ok(()) } diff --git a/examples/api/src-tauri/tauri.conf.json b/examples/api/src-tauri/tauri.conf.json index 6f5f422d9..147c3ba03 100644 --- a/examples/api/src-tauri/tauri.conf.json +++ b/examples/api/src-tauri/tauri.conf.json @@ -124,6 +124,7 @@ "security": { "csp": { "default-src": "'self' customprotocol: asset:", + "connect-src": "ipc: https://ipc.localhost", "font-src": ["https://fonts.gstatic.com"], "img-src": "'self' asset: https://asset.localhost blob: data:", "style-src": "'unsafe-inline' 'self' https://fonts.googleapis.com" @@ -136,11 +137,6 @@ "deny": ["$APPDATA/db/*.stronghold"] } } - }, - "systemTray": { - "iconPath": "icons/tray_icon_with_transparency.png", - "iconAsTemplate": true, - "menuOnLeftClick": false } } } diff --git a/plugins/app/package.json b/plugins/app/package.json index eabb80de1..b92a8c698 100644 --- a/plugins/app/package.json +++ b/plugins/app/package.json @@ -27,6 +27,6 @@ "tslib": "^2.5.0" }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.5" + "@tauri-apps/api": "2.0.0-alpha.6" } -} +} \ No newline at end of file diff --git a/plugins/authenticator/package.json b/plugins/authenticator/package.json index ff3531894..6d03ac37a 100644 --- a/plugins/authenticator/package.json +++ b/plugins/authenticator/package.json @@ -28,6 +28,6 @@ "tslib": "2.6.0" }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.5" + "@tauri-apps/api": "2.0.0-alpha.6" } -} +} \ No newline at end of file diff --git a/plugins/autostart/package.json b/plugins/autostart/package.json index 96ee80301..ee0d461a8 100644 --- a/plugins/autostart/package.json +++ b/plugins/autostart/package.json @@ -27,6 +27,6 @@ "tslib": "2.6.0" }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.5" + "@tauri-apps/api": "2.0.0-alpha.6" } -} +} \ No newline at end of file diff --git a/plugins/cli/package.json b/plugins/cli/package.json index 27531d7be..074f2026a 100644 --- a/plugins/cli/package.json +++ b/plugins/cli/package.json @@ -27,6 +27,6 @@ "tslib": "^2.4.1" }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.5" + "@tauri-apps/api": "2.0.0-alpha.6" } -} +} \ No newline at end of file diff --git a/plugins/clipboard-manager/package.json b/plugins/clipboard-manager/package.json index a241b0dbb..49e898f45 100644 --- a/plugins/clipboard-manager/package.json +++ b/plugins/clipboard-manager/package.json @@ -27,6 +27,6 @@ "tslib": "^2.4.1" }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.5" + "@tauri-apps/api": "2.0.0-alpha.6" } -} +} \ No newline at end of file diff --git a/plugins/dialog/package.json b/plugins/dialog/package.json index 39d1950f6..6395658ff 100644 --- a/plugins/dialog/package.json +++ b/plugins/dialog/package.json @@ -27,6 +27,6 @@ "tslib": "^2.4.1" }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.5" + "@tauri-apps/api": "2.0.0-alpha.6" } -} +} \ No newline at end of file diff --git a/plugins/fs/package.json b/plugins/fs/package.json index 2943c5681..6cae43845 100644 --- a/plugins/fs/package.json +++ b/plugins/fs/package.json @@ -28,6 +28,6 @@ "tslib": "^2.4.1" }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.5" + "@tauri-apps/api": "2.0.0-alpha.6" } -} +} \ No newline at end of file diff --git a/plugins/fs/src/api-iife.js b/plugins/fs/src/api-iife.js index 6bc304427..1de2933ae 100644 --- a/plugins/fs/src/api-iife.js +++ b/plugins/fs/src/api-iife.js @@ -1 +1 @@ -if("__TAURI__"in window){var __TAURI_FS__=function(e){"use strict";var t=Object.defineProperty,n=(e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})},r=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},i=(e,t,n)=>(r(e,t,"read from private field"),n?n.call(e):t.get(e)),o=(e,t,n,i)=>(r(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n);function a(e,t=!1){let n=window.crypto.getRandomValues(new Uint32Array(1))[0],r=`_${n}`;return Object.defineProperty(window,r,{value:n=>(t&&Reflect.deleteProperty(window,r),e?.(n)),writable:!1,configurable:!0}),n}n({},{Channel:()=>s,PluginListener:()=>u,addPluginListener:()=>p,convertFileSrc:()=>_,invoke:()=>l,transformCallback:()=>a});var c,s=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,((e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)})(this,c,(()=>{})),this.id=a((e=>{i(this,c).call(this,e)}))}set onmessage(e){o(this,c,e)}get onmessage(){return i(this,c)}toJSON(){return`__CHANNEL__:${this.id}`}};c=new WeakMap;var u=class{constructor(e,t,n){this.plugin=e,this.event=t,this.channelId=n}async unregister(){return l(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function p(e,t,n){let r=new s;return r.onmessage=n,l(`plugin:${e}|register_listener`,{event:t,handler:r}).then((()=>new u(e,t,r.id)))}async function l(e,t={}){return new Promise(((n,r)=>{let i=a((e=>{n(e),Reflect.deleteProperty(window,`_${o}`)}),!0),o=a((e=>{r(e),Reflect.deleteProperty(window,`_${i}`)}),!0);window.__TAURI_IPC__({cmd:e,callback:i,error:o,...t})}))}function _(e,t="asset"){let n=encodeURIComponent(e);return navigator.userAgent.includes("Windows")?`https://${t}.localhost/${n}`:`${t}://localhost/${n}`}n({},{BaseDirectory:()=>y,appCacheDir:()=>g,appConfigDir:()=>f,appDataDir:()=>h,appLocalDataDir:()=>w,appLogDir:()=>x,audioDir:()=>m,basename:()=>W,cacheDir:()=>v,configDir:()=>A,dataDir:()=>D,delimiter:()=>k,desktopDir:()=>I,dirname:()=>S,documentDir:()=>R,downloadDir:()=>T,executableDir:()=>b,extname:()=>H,fontDir:()=>U,homeDir:()=>E,isAbsolute:()=>J,join:()=>M,localDataDir:()=>O,normalize:()=>B,pictureDir:()=>C,publicDir:()=>N,resolve:()=>z,resolveResource:()=>V,resourceDir:()=>P,runtimeDir:()=>j,sep:()=>$,tempDir:()=>L,templateDir:()=>F,videoDir:()=>K});var d,y=((d=y||{})[d.Audio=1]="Audio",d[d.Cache=2]="Cache",d[d.Config=3]="Config",d[d.Data=4]="Data",d[d.LocalData=5]="LocalData",d[d.Document=6]="Document",d[d.Download=7]="Download",d[d.Picture=8]="Picture",d[d.Public=9]="Public",d[d.Video=10]="Video",d[d.Resource=11]="Resource",d[d.Temp=12]="Temp",d[d.AppConfig=13]="AppConfig",d[d.AppData=14]="AppData",d[d.AppLocalData=15]="AppLocalData",d[d.AppCache=16]="AppCache",d[d.AppLog=17]="AppLog",d[d.Desktop=18]="Desktop",d[d.Executable=19]="Executable",d[d.Font=20]="Font",d[d.Home=21]="Home",d[d.Runtime=22]="Runtime",d[d.Template=23]="Template",d);async function f(){return l("plugin:path|resolve_directory",{directory:13})}async function h(){return l("plugin:path|resolve_directory",{directory:14})}async function w(){return l("plugin:path|resolve_directory",{directory:15})}async function g(){return l("plugin:path|resolve_directory",{directory:16})}async function m(){return l("plugin:path|resolve_directory",{directory:1})}async function v(){return l("plugin:path|resolve_directory",{directory:2})}async function A(){return l("plugin:path|resolve_directory",{directory:3})}async function D(){return l("plugin:path|resolve_directory",{directory:4})}async function I(){return l("plugin:path|resolve_directory",{directory:18})}async function R(){return l("plugin:path|resolve_directory",{directory:6})}async function T(){return l("plugin:path|resolve_directory",{directory:7})}async function b(){return l("plugin:path|resolve_directory",{directory:19})}async function U(){return l("plugin:path|resolve_directory",{directory:20})}async function E(){return l("plugin:path|resolve_directory",{directory:21})}async function O(){return l("plugin:path|resolve_directory",{directory:5})}async function C(){return l("plugin:path|resolve_directory",{directory:8})}async function N(){return l("plugin:path|resolve_directory",{directory:9})}async function P(){return l("plugin:path|resolve_directory",{directory:11})}async function V(e){return l("plugin:path|resolve_directory",{directory:11,path:e})}async function j(){return l("plugin:path|resolve_directory",{directory:22})}async function F(){return l("plugin:path|resolve_directory",{directory:23})}async function K(){return l("plugin:path|resolve_directory",{directory:10})}async function x(){return l("plugin:path|resolve_directory",{directory:17})}async function L(e){return l("plugin:path|resolve_directory",{directory:12})}function $(){return window.__TAURI__.path.__sep}function k(){return window.__TAURI__.path.__delimiter}async function z(...e){return l("plugin:path|resolve",{paths:e})}async function B(e){return l("plugin:path|normalize",{path:e})}async function M(...e){return l("plugin:path|join",{paths:e})}async function S(e){return l("plugin:path|dirname",{path:e})}async function H(e){return l("plugin:path|extname",{path:e})}async function W(e,t){return l("plugin:path|basename",{path:e,ext:t})}async function J(e){return l("plugin:path|isAbsolute",{path:e})}async function q(e,t,n){"object"==typeof n&&Object.freeze(n),"object"==typeof e&&Object.freeze(e);const r={path:"",contents:""};let i=n;return"string"==typeof e?r.path=e:(r.path=e.path,r.contents=e.contents),"string"==typeof t?r.contents=null!=t?t:"":i=t,await window.__TAURI_INVOKE__("plugin:fs|write_file",{path:r.path,contents:Array.from((new TextEncoder).encode(r.contents)),options:i})}return e.BaseDirectory=y,e.Dir=y,e.copyFile=async function(e,t,n={}){return await window.__TAURI_INVOKE__("plugin:fs|copy_file",{source:e,destination:t,options:n})},e.createDir=async function(e,t={}){return await window.__TAURI_INVOKE__("plugin:fs|create_dir",{path:e,options:t})},e.exists=async function(e){return await window.__TAURI_INVOKE__("plugin:fs|exists",{path:e})},e.metadata=async function(e){return await window.__TAURI_INVOKE__("plugin:fs|metadata",{path:e}).then((e=>{const{accessedAtMs:t,createdAtMs:n,modifiedAtMs:r,...i}=e;return{accessedAt:new Date(t),createdAt:new Date(n),modifiedAt:new Date(r),...i}}))},e.readBinaryFile=async function(e,t={}){const n=await window.__TAURI_INVOKE__("plugin:fs|read_file",{path:e,options:t});return Uint8Array.from(n)},e.readDir=async function(e,t={}){return await window.__TAURI_INVOKE__("plugin:fs|read_dir",{path:e,options:t})},e.readTextFile=async function(e,t={}){return await window.__TAURI_INVOKE__("plugin:fs|read_text_file",{path:e,options:t})},e.removeDir=async function(e,t={}){return await window.__TAURI_INVOKE__("plugin:fs|remove_dir",{path:e,options:t})},e.removeFile=async function(e,t={}){return await window.__TAURI_INVOKE__("plugin:fs|remove_file",{path:e,options:t})},e.renameFile=async function(e,t,n={}){return await window.__TAURI_INVOKE__("plugin:fs|rename_file",{oldPath:e,newPath:t,options:n})},e.writeBinaryFile=async function(e,t,n){"object"==typeof n&&Object.freeze(n),"object"==typeof e&&Object.freeze(e);const r={path:"",contents:[]};let i=n;return"string"==typeof e?r.path=e:(r.path=e.path,r.contents=e.contents),t&&"dir"in t?i=t:"string"==typeof e&&(r.contents=null!=t?t:[]),await window.__TAURI_INVOKE__("plugin:fs|write_file",{path:r.path,contents:Array.from(r.contents instanceof ArrayBuffer?new Uint8Array(r.contents):r.contents),options:i})},e.writeFile=q,e.writeTextFile=q,e}({});Object.defineProperty(window.__TAURI__,"fs",{value:__TAURI_FS__})} +if("__TAURI__"in window){var __TAURI_FS__=function(e){"use strict";var t=Object.defineProperty,n=(e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})},r=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},i=(e,t,n)=>(r(e,t,"read from private field"),n?n.call(e):t.get(e)),o=(e,t,n,i)=>(r(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n);function a(e,t=!1){let n=window.crypto.getRandomValues(new Uint32Array(1))[0],r=`_${n}`;return Object.defineProperty(window,r,{value:n=>(t&&Reflect.deleteProperty(window,r),e?.(n)),writable:!1,configurable:!0}),n}n({},{Channel:()=>s,PluginListener:()=>u,addPluginListener:()=>p,convertFileSrc:()=>_,invoke:()=>l,transformCallback:()=>a});var c,s=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,((e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)})(this,c,(()=>{})),this.id=a((e=>{i(this,c).call(this,e)}))}set onmessage(e){o(this,c,e)}get onmessage(){return i(this,c)}toJSON(){return`__CHANNEL__:${this.id}`}};c=new WeakMap;var u=class{constructor(e,t,n){this.plugin=e,this.event=t,this.channelId=n}async unregister(){return l(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function p(e,t,n){let r=new s;return r.onmessage=n,l(`plugin:${e}|register_listener`,{event:t,handler:r}).then((()=>new u(e,t,r.id)))}async function l(e,t={},n){return new Promise(((r,i)=>{let o=a((e=>{r(e),Reflect.deleteProperty(window,`_${c}`)}),!0),c=a((e=>{i(e),Reflect.deleteProperty(window,`_${o}`)}),!0);window.__TAURI_IPC__({cmd:e,callback:o,error:c,payload:t,options:n})}))}function _(e,t="asset"){return window.__TAURI__.convertFileSrc(e,t)}n({},{BaseDirectory:()=>y,appCacheDir:()=>g,appConfigDir:()=>f,appDataDir:()=>h,appLocalDataDir:()=>w,appLogDir:()=>x,audioDir:()=>m,basename:()=>W,cacheDir:()=>v,configDir:()=>A,dataDir:()=>D,delimiter:()=>z,desktopDir:()=>I,dirname:()=>M,documentDir:()=>R,downloadDir:()=>T,executableDir:()=>b,extname:()=>H,fontDir:()=>U,homeDir:()=>E,isAbsolute:()=>J,join:()=>B,localDataDir:()=>O,normalize:()=>$,pictureDir:()=>C,publicDir:()=>N,resolve:()=>S,resolveResource:()=>V,resourceDir:()=>P,runtimeDir:()=>F,sep:()=>k,tempDir:()=>L,templateDir:()=>j,videoDir:()=>K});var d,y=((d=y||{})[d.Audio=1]="Audio",d[d.Cache=2]="Cache",d[d.Config=3]="Config",d[d.Data=4]="Data",d[d.LocalData=5]="LocalData",d[d.Document=6]="Document",d[d.Download=7]="Download",d[d.Picture=8]="Picture",d[d.Public=9]="Public",d[d.Video=10]="Video",d[d.Resource=11]="Resource",d[d.Temp=12]="Temp",d[d.AppConfig=13]="AppConfig",d[d.AppData=14]="AppData",d[d.AppLocalData=15]="AppLocalData",d[d.AppCache=16]="AppCache",d[d.AppLog=17]="AppLog",d[d.Desktop=18]="Desktop",d[d.Executable=19]="Executable",d[d.Font=20]="Font",d[d.Home=21]="Home",d[d.Runtime=22]="Runtime",d[d.Template=23]="Template",d);async function f(){return l("plugin:path|resolve_directory",{directory:13})}async function h(){return l("plugin:path|resolve_directory",{directory:14})}async function w(){return l("plugin:path|resolve_directory",{directory:15})}async function g(){return l("plugin:path|resolve_directory",{directory:16})}async function m(){return l("plugin:path|resolve_directory",{directory:1})}async function v(){return l("plugin:path|resolve_directory",{directory:2})}async function A(){return l("plugin:path|resolve_directory",{directory:3})}async function D(){return l("plugin:path|resolve_directory",{directory:4})}async function I(){return l("plugin:path|resolve_directory",{directory:18})}async function R(){return l("plugin:path|resolve_directory",{directory:6})}async function T(){return l("plugin:path|resolve_directory",{directory:7})}async function b(){return l("plugin:path|resolve_directory",{directory:19})}async function U(){return l("plugin:path|resolve_directory",{directory:20})}async function E(){return l("plugin:path|resolve_directory",{directory:21})}async function O(){return l("plugin:path|resolve_directory",{directory:5})}async function C(){return l("plugin:path|resolve_directory",{directory:8})}async function N(){return l("plugin:path|resolve_directory",{directory:9})}async function P(){return l("plugin:path|resolve_directory",{directory:11})}async function V(e){return l("plugin:path|resolve_directory",{directory:11,path:e})}async function F(){return l("plugin:path|resolve_directory",{directory:22})}async function j(){return l("plugin:path|resolve_directory",{directory:23})}async function K(){return l("plugin:path|resolve_directory",{directory:10})}async function x(){return l("plugin:path|resolve_directory",{directory:17})}async function L(e){return l("plugin:path|resolve_directory",{directory:12})}function k(){return window.__TAURI__.path.__sep}function z(){return window.__TAURI__.path.__delimiter}async function S(...e){return l("plugin:path|resolve",{paths:e})}async function $(e){return l("plugin:path|normalize",{path:e})}async function B(...e){return l("plugin:path|join",{paths:e})}async function M(e){return l("plugin:path|dirname",{path:e})}async function H(e){return l("plugin:path|extname",{path:e})}async function W(e,t){return l("plugin:path|basename",{path:e,ext:t})}async function J(e){return l("plugin:path|isAbsolute",{path:e})}async function q(e,t,n){"object"==typeof n&&Object.freeze(n),"object"==typeof e&&Object.freeze(e);const r={path:"",contents:""};let i=n;return"string"==typeof e?r.path=e:(r.path=e.path,r.contents=e.contents),"string"==typeof t?r.contents=null!=t?t:"":i=t,await window.__TAURI_INVOKE__("plugin:fs|write_file",{path:r.path,contents:Array.from((new TextEncoder).encode(r.contents)),options:i})}return e.BaseDirectory=y,e.Dir=y,e.copyFile=async function(e,t,n={}){return await window.__TAURI_INVOKE__("plugin:fs|copy_file",{source:e,destination:t,options:n})},e.createDir=async function(e,t={}){return await window.__TAURI_INVOKE__("plugin:fs|create_dir",{path:e,options:t})},e.exists=async function(e){return await window.__TAURI_INVOKE__("plugin:fs|exists",{path:e})},e.metadata=async function(e){return await window.__TAURI_INVOKE__("plugin:fs|metadata",{path:e}).then((e=>{const{accessedAtMs:t,createdAtMs:n,modifiedAtMs:r,...i}=e;return{accessedAt:new Date(t),createdAt:new Date(n),modifiedAt:new Date(r),...i}}))},e.readBinaryFile=async function(e,t={}){const n=await window.__TAURI_INVOKE__("plugin:fs|read_file",{path:e,options:t});return Uint8Array.from(n)},e.readDir=async function(e,t={}){return await window.__TAURI_INVOKE__("plugin:fs|read_dir",{path:e,options:t})},e.readTextFile=async function(e,t={}){return await window.__TAURI_INVOKE__("plugin:fs|read_text_file",{path:e,options:t})},e.removeDir=async function(e,t={}){return await window.__TAURI_INVOKE__("plugin:fs|remove_dir",{path:e,options:t})},e.removeFile=async function(e,t={}){return await window.__TAURI_INVOKE__("plugin:fs|remove_file",{path:e,options:t})},e.renameFile=async function(e,t,n={}){return await window.__TAURI_INVOKE__("plugin:fs|rename_file",{oldPath:e,newPath:t,options:n})},e.writeBinaryFile=async function(e,t,n){"object"==typeof n&&Object.freeze(n),"object"==typeof e&&Object.freeze(e);const r={path:"",contents:[]};let i=n;return"string"==typeof e?r.path=e:(r.path=e.path,r.contents=e.contents),t&&"dir"in t?i=t:"string"==typeof e&&(r.contents=null!=t?t:[]),await window.__TAURI_INVOKE__("plugin:fs|write_file",{path:r.path,contents:Array.from(r.contents instanceof ArrayBuffer?new Uint8Array(r.contents):r.contents),options:i})},e.writeFile=q,e.writeTextFile=q,e}({});Object.defineProperty(window.__TAURI__,"fs",{value:__TAURI_FS__})} diff --git a/plugins/fs/src/watcher.rs b/plugins/fs/src/watcher.rs index 647342c73..108698a21 100644 --- a/plugins/fs/src/watcher.rs +++ b/plugins/fs/src/watcher.rs @@ -5,7 +5,7 @@ use notify::{Config, Event, RecommendedWatcher, RecursiveMode, Watcher}; use notify_debouncer_mini::{new_debouncer, DebounceEventResult, Debouncer}; use serde::Deserialize; -use tauri::{api::ipc::Channel, command, Runtime, State}; +use tauri::{command, ipc::Channel, Runtime, State}; use crate::Result; diff --git a/plugins/global-shortcut/guest-js/index.ts b/plugins/global-shortcut/guest-js/index.ts index 541530c48..aa5667026 100644 --- a/plugins/global-shortcut/guest-js/index.ts +++ b/plugins/global-shortcut/guest-js/index.ts @@ -8,14 +8,7 @@ * @module */ -declare global { - interface Window { - __TAURI_INVOKE__: (cmd: string, args?: unknown) => Promise; - __TAURI__: { - transformCallback: (cb: (payload: T) => void) => number; - }; - } -} +import { invoke, Channel } from "@tauri-apps/api/tauri"; export type ShortcutHandler = (shortcut: string) => void; @@ -38,9 +31,12 @@ async function register( shortcut: string, handler: ShortcutHandler, ): Promise { - return await window.__TAURI_INVOKE__("plugin:globalShortcut|register", { + const h = new Channel(); + h.onmessage = handler; + + return await invoke("plugin:globalShortcut|register", { shortcut, - handler: window.__TAURI__.transformCallback(handler), + handler: h, }); } @@ -63,9 +59,12 @@ async function registerAll( shortcuts: string[], handler: ShortcutHandler, ): Promise { - return await window.__TAURI_INVOKE__("plugin:globalShortcut|register_all", { + const h = new Channel(); + h.onmessage = handler; + + return await invoke("plugin:globalShortcut|register_all", { shortcuts, - handler: window.__TAURI__.transformCallback(handler), + handler: h, }); } @@ -85,7 +84,7 @@ async function registerAll( * @since 2.0.0 */ async function isRegistered(shortcut: string): Promise { - return await window.__TAURI_INVOKE__("plugin:globalShortcut|is_registered", { + return await invoke("plugin:globalShortcut|is_registered", { shortcut, }); } @@ -103,7 +102,7 @@ async function isRegistered(shortcut: string): Promise { * @since 2.0.0 */ async function unregister(shortcut: string): Promise { - return await window.__TAURI_INVOKE__("plugin:globalShortcut|unregister", { + return await invoke("plugin:globalShortcut|unregister", { shortcut, }); } @@ -119,7 +118,7 @@ async function unregister(shortcut: string): Promise { * @since 2.0.0 */ async function unregisterAll(): Promise { - return await window.__TAURI_INVOKE__("plugin:globalShortcut|unregister_all"); + return await invoke("plugin:globalShortcut|unregister_all"); } export { register, registerAll, isRegistered, unregister, unregisterAll }; diff --git a/plugins/global-shortcut/package.json b/plugins/global-shortcut/package.json index 5d198350a..25b555b25 100644 --- a/plugins/global-shortcut/package.json +++ b/plugins/global-shortcut/package.json @@ -27,6 +27,6 @@ "tslib": "^2.4.1" }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.5" + "@tauri-apps/api": "2.0.0-alpha.6" } -} +} \ No newline at end of file diff --git a/plugins/global-shortcut/src/api-iife.js b/plugins/global-shortcut/src/api-iife.js index 542aa04ff..a685b11e4 100644 --- a/plugins/global-shortcut/src/api-iife.js +++ b/plugins/global-shortcut/src/api-iife.js @@ -1 +1 @@ -if("__TAURI__"in window){var __TAURI_GLOBALSHORTCUT__=function(_){"use strict";return _.isRegistered=async function(_){return await window.__TAURI_INVOKE__("plugin:globalShortcut|is_registered",{shortcut:_})},_.register=async function(_,t){return await window.__TAURI_INVOKE__("plugin:globalShortcut|register",{shortcut:_,handler:window.__TAURI__.transformCallback(t)})},_.registerAll=async function(_,t){return await window.__TAURI_INVOKE__("plugin:globalShortcut|register_all",{shortcuts:_,handler:window.__TAURI__.transformCallback(t)})},_.unregister=async function(_){return await window.__TAURI_INVOKE__("plugin:globalShortcut|unregister",{shortcut:_})},_.unregisterAll=async function(){return await window.__TAURI_INVOKE__("plugin:globalShortcut|unregister_all")},_}({});Object.defineProperty(window.__TAURI__,"globalShortcut",{value:__TAURI_GLOBALSHORTCUT__})} +if("__TAURI__"in window){var __TAURI_GLOBALSHORTCUT__=function(e){"use strict";var t=Object.defineProperty,n=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},r=(e,t,r)=>(n(e,t,"read from private field"),r?r.call(e):t.get(e)),i=(e,t,r,i)=>(n(e,t,"write to private field"),i?i.call(e,r):t.set(e,r),r);function a(e,t=!1){let n=window.crypto.getRandomValues(new Uint32Array(1))[0],r=`_${n}`;return Object.defineProperty(window,r,{value:n=>(t&&Reflect.deleteProperty(window,r),e?.(n)),writable:!1,configurable:!0}),n}((e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})})({},{Channel:()=>s,PluginListener:()=>l,addPluginListener:()=>c,convertFileSrc:()=>_,invoke:()=>u,transformCallback:()=>a});var o,s=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,((e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)})(this,o,(()=>{})),this.id=a((e=>{r(this,o).call(this,e)}))}set onmessage(e){i(this,o,e)}get onmessage(){return r(this,o)}toJSON(){return`__CHANNEL__:${this.id}`}};o=new WeakMap;var l=class{constructor(e,t,n){this.plugin=e,this.event=t,this.channelId=n}async unregister(){return u(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function c(e,t,n){let r=new s;return r.onmessage=n,u(`plugin:${e}|register_listener`,{event:t,handler:r}).then((()=>new l(e,t,r.id)))}async function u(e,t={},n){return new Promise(((r,i)=>{let o=a((e=>{r(e),Reflect.deleteProperty(window,`_${s}`)}),!0),s=a((e=>{i(e),Reflect.deleteProperty(window,`_${o}`)}),!0);window.__TAURI_IPC__({cmd:e,callback:o,error:s,payload:t,options:n})}))}function _(e,t="asset"){return window.__TAURI__.convertFileSrc(e,t)}return e.isRegistered=async function(e){return await u("plugin:globalShortcut|is_registered",{shortcut:e})},e.register=async function(e,t){const n=new s;return n.onmessage=t,await u("plugin:globalShortcut|register",{shortcut:e,handler:n})},e.registerAll=async function(e,t){const n=new s;return n.onmessage=t,await u("plugin:globalShortcut|register_all",{shortcuts:e,handler:n})},e.unregister=async function(e){return await u("plugin:globalShortcut|unregister",{shortcut:e})},e.unregisterAll=async function(){return await u("plugin:globalShortcut|unregister_all")},e}({});Object.defineProperty(window.__TAURI__,"globalShortcut",{value:__TAURI_GLOBALSHORTCUT__})} diff --git a/plugins/global-shortcut/src/lib.rs b/plugins/global-shortcut/src/lib.rs index 96fab9d83..85e0910a5 100644 --- a/plugins/global-shortcut/src/lib.rs +++ b/plugins/global-shortcut/src/lib.rs @@ -23,7 +23,7 @@ use std::{ pub use global_hotkey::hotkey::{Code, HotKey as Shortcut, Modifiers}; use global_hotkey::{GlobalHotKeyEvent, GlobalHotKeyManager}; use tauri::{ - api::ipc::CallbackFn, + ipc::Channel, plugin::{Builder as PluginBuilder, TauriPlugin}, AppHandle, Manager, Runtime, State, Window, }; @@ -35,21 +35,15 @@ type Result = std::result::Result; type HotKeyId = u32; type HandlerFn = Box; -enum ShortcutSource { - Ipc { - window: Window, - handler: CallbackFn, - }, +enum ShortcutSource { + Ipc(Channel), Rust, } -impl Clone for ShortcutSource { +impl Clone for ShortcutSource { fn clone(&self) -> Self { match self { - Self::Ipc { window, handler } => Self::Ipc { - window: window.clone(), - handler: *handler, - }, + Self::Ipc(channel) => Self::Ipc(channel.clone()), Self::Rust => Self::Rust, } } @@ -70,8 +64,8 @@ impl TryFrom<&str> for ShortcutWrapper { } } -struct RegisteredShortcut { - source: ShortcutSource, +struct RegisteredShortcut { + source: ShortcutSource, shortcut: (Shortcut, Option), } @@ -79,14 +73,14 @@ pub struct GlobalShortcut { #[allow(dead_code)] app: AppHandle, manager: std::result::Result, - shortcuts: Arc>>>, + shortcuts: Arc>>, } impl GlobalShortcut { fn register_internal( &self, shortcut: (Shortcut, Option), - source: ShortcutSource, + source: ShortcutSource, ) -> Result<()> { let id = shortcut.0.id(); acquire_manager(&self.manager)?.register(shortcut.0)?; @@ -100,7 +94,7 @@ impl GlobalShortcut { fn register_all_internal)>>( &self, shortcuts: S, - source: ShortcutSource, + source: ShortcutSource, ) -> Result<()> { let hotkeys = shortcuts .into_iter() @@ -218,29 +212,29 @@ where #[tauri::command] fn register( - window: Window, + _window: Window, global_shortcut: State<'_, GlobalShortcut>, shortcut: String, - handler: CallbackFn, + handler: Channel, ) -> Result<()> { global_shortcut.register_internal( (parse_shortcut(&shortcut)?, Some(shortcut)), - ShortcutSource::Ipc { window, handler }, + ShortcutSource::Ipc(handler), ) } #[tauri::command] fn register_all( - window: Window, + _window: Window, global_shortcut: State<'_, GlobalShortcut>, shortcuts: Vec, - handler: CallbackFn, + handler: Channel, ) -> Result<()> { let mut hotkeys = Vec::new(); for shortcut in shortcuts { hotkeys.push((parse_shortcut(&shortcut)?, Some(shortcut))); } - global_shortcut.register_all_internal(hotkeys, ShortcutSource::Ipc { window, handler }) + global_shortcut.register_all_internal(hotkeys, ShortcutSource::Ipc(handler)) } #[tauri::command] @@ -303,19 +297,14 @@ impl Builder { ]) .setup(move |app, _api| { let shortcuts = - Arc::new(Mutex::new(HashMap::>::new())); + Arc::new(Mutex::new(HashMap::::new())); let shortcuts_ = shortcuts.clone(); GlobalHotKeyEvent::set_event_handler(Some(move |e: GlobalHotKeyEvent| { if let Some(shortcut) = shortcuts_.lock().unwrap().get(&e.id) { match &shortcut.source { - ShortcutSource::Ipc { window, handler } => { - let callback_string = tauri::api::ipc::format_callback( - *handler, - &shortcut.shortcut.1, - ) - .expect("unable to serialize shortcut string to json"); - let _ = window.eval(callback_string.as_str()); + ShortcutSource::Ipc(channel) => { + let _ = channel.send(&shortcut.shortcut.1); } ShortcutSource::Rust => { if let Some(handler) = &handler { diff --git a/plugins/http/package.json b/plugins/http/package.json index 81d3bc408..2dc34aa25 100644 --- a/plugins/http/package.json +++ b/plugins/http/package.json @@ -27,6 +27,6 @@ "tslib": "^2.5.0" }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.5" + "@tauri-apps/api": "2.0.0-alpha.6" } -} +} \ No newline at end of file diff --git a/plugins/log/package.json b/plugins/log/package.json index 4370fa1a6..79867ceaf 100644 --- a/plugins/log/package.json +++ b/plugins/log/package.json @@ -28,6 +28,6 @@ "tslib": "2.6.0" }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.5" + "@tauri-apps/api": "2.0.0-alpha.6" } -} +} \ No newline at end of file diff --git a/plugins/log/src/api-iife.js b/plugins/log/src/api-iife.js index e733187fc..ca318f25b 100644 --- a/plugins/log/src/api-iife.js +++ b/plugins/log/src/api-iife.js @@ -1 +1 @@ -if("__TAURI__"in window){var __TAURI_LOG__=function(e){"use strict";var n=Object.defineProperty,t=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},r=(e,n,t)=>{if(!n.has(e))throw TypeError("Cannot "+t)},a=(e,n,t)=>(r(e,n,"read from private field"),t?t.call(e):n.get(e)),i=(e,n,t,a)=>(r(e,n,"write to private field"),a?a.call(e,t):n.set(e,t),t);function o(e,n=!1){let t=window.crypto.getRandomValues(new Uint32Array(1))[0],r=`_${t}`;return Object.defineProperty(window,r,{value:t=>(n&&Reflect.deleteProperty(window,r),e?.(t)),writable:!1,configurable:!0}),t}t({},{Channel:()=>c,PluginListener:()=>s,addPluginListener:()=>u,convertFileSrc:()=>d,invoke:()=>_,transformCallback:()=>o});var l,c=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,((e,n,t)=>{if(n.has(e))throw TypeError("Cannot add the same private member more than once");n instanceof WeakSet?n.add(e):n.set(e,t)})(this,l,(()=>{})),this.id=o((e=>{a(this,l).call(this,e)}))}set onmessage(e){i(this,l,e)}get onmessage(){return a(this,l)}toJSON(){return`__CHANNEL__:${this.id}`}};l=new WeakMap;var s=class{constructor(e,n,t){this.plugin=e,this.event=n,this.channelId=t}async unregister(){return _(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function u(e,n,t){let r=new c;return r.onmessage=t,_(`plugin:${e}|register_listener`,{event:n,handler:r}).then((()=>new s(e,n,r.id)))}async function _(e,n={}){return new Promise(((t,r)=>{let a=o((e=>{t(e),Reflect.deleteProperty(window,`_${i}`)}),!0),i=o((e=>{r(e),Reflect.deleteProperty(window,`_${a}`)}),!0);window.__TAURI_IPC__({cmd:e,callback:a,error:i,...n})}))}function d(e,n="asset"){let t=encodeURIComponent(e);return navigator.userAgent.includes("Windows")?`https://${n}.localhost/${t}`:`${n}://localhost/${t}`}t({},{TauriEvent:()=>f,emit:()=>E,listen:()=>v,once:()=>h});var w,f=(e=>(e.WINDOW_RESIZED="tauri://resize",e.WINDOW_MOVED="tauri://move",e.WINDOW_CLOSE_REQUESTED="tauri://close-requested",e.WINDOW_CREATED="tauri://window-created",e.WINDOW_DESTROYED="tauri://destroyed",e.WINDOW_FOCUS="tauri://focus",e.WINDOW_BLUR="tauri://blur",e.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",e.WINDOW_THEME_CHANGED="tauri://theme-changed",e.WINDOW_FILE_DROP="tauri://file-drop",e.WINDOW_FILE_DROP_HOVER="tauri://file-drop-hover",e.WINDOW_FILE_DROP_CANCELLED="tauri://file-drop-cancelled",e.MENU="tauri://menu",e))(f||{});async function g(e,n){await _("plugin:event|unlisten",{event:e,eventId:n})}async function v(e,n,t){return _("plugin:event|listen",{event:e,windowLabel:t?.target,handler:o(n)}).then((n=>async()=>g(e,n)))}async function h(e,n,t){return v(e,(t=>{n(t),g(e,t.id).catch((()=>{}))}),t)}async function E(e,n,t){await _("plugin:event|emit",{event:e,windowLabel:t?.target,payload:n})}async function I(e,n,t){var r,a;const i=null===(r=(new Error).stack)||void 0===r?void 0:r.split("\n").map((e=>e.split("@"))),o=null==i?void 0:i.filter((([e,n])=>e.length>0&&"[native code]"!==n)),{file:l,line:c,keyValues:s}=null!=t?t:{};let u=null===(a=null==o?void 0:o[0])||void 0===a?void 0:a.filter((e=>e.length>0)).join("@");"Error"===u&&(u="webview::unknown"),await window.__TAURI_INVOKE__("plugin:log|log",{level:e,message:n,location:u,file:l,line:c,keyValues:s})}return function(e){e[e.Trace=1]="Trace",e[e.Debug=2]="Debug",e[e.Info=3]="Info",e[e.Warn=4]="Warn",e[e.Error=5]="Error"}(w||(w={})),e.attachConsole=async function(){return await v("log://log",(e=>{const n=e.payload,t=n.message.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,"");switch(n.level){case w.Trace:console.log(t);break;case w.Debug:console.debug(t);break;case w.Info:console.info(t);break;case w.Warn:console.warn(t);break;case w.Error:console.error(t);break;default:throw new Error(`unknown log level ${n.level}`)}}))},e.debug=async function(e,n){await I(w.Debug,e,n)},e.error=async function(e,n){await I(w.Error,e,n)},e.info=async function(e,n){await I(w.Info,e,n)},e.trace=async function(e,n){await I(w.Trace,e,n)},e.warn=async function(e,n){await I(w.Warn,e,n)},e}({});Object.defineProperty(window.__TAURI__,"log",{value:__TAURI_LOG__})} +if("__TAURI__"in window){var __TAURI_LOG__=function(e){"use strict";var n=Object.defineProperty,t=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},r=(e,n,t)=>{if(!n.has(e))throw TypeError("Cannot "+t)},a=(e,n,t)=>(r(e,n,"read from private field"),t?t.call(e):n.get(e)),i=(e,n,t,a)=>(r(e,n,"write to private field"),a?a.call(e,t):n.set(e,t),t);function o(e,n=!1){let t=window.crypto.getRandomValues(new Uint32Array(1))[0],r=`_${t}`;return Object.defineProperty(window,r,{value:t=>(n&&Reflect.deleteProperty(window,r),e?.(t)),writable:!1,configurable:!0}),t}t({},{Channel:()=>c,PluginListener:()=>s,addPluginListener:()=>u,convertFileSrc:()=>d,invoke:()=>_,transformCallback:()=>o});var l,c=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,((e,n,t)=>{if(n.has(e))throw TypeError("Cannot add the same private member more than once");n instanceof WeakSet?n.add(e):n.set(e,t)})(this,l,(()=>{})),this.id=o((e=>{a(this,l).call(this,e)}))}set onmessage(e){i(this,l,e)}get onmessage(){return a(this,l)}toJSON(){return`__CHANNEL__:${this.id}`}};l=new WeakMap;var s=class{constructor(e,n,t){this.plugin=e,this.event=n,this.channelId=t}async unregister(){return _(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function u(e,n,t){let r=new c;return r.onmessage=t,_(`plugin:${e}|register_listener`,{event:n,handler:r}).then((()=>new s(e,n,r.id)))}async function _(e,n={},t){return new Promise(((r,a)=>{let i=o((e=>{r(e),Reflect.deleteProperty(window,`_${l}`)}),!0),l=o((e=>{a(e),Reflect.deleteProperty(window,`_${i}`)}),!0);window.__TAURI_IPC__({cmd:e,callback:i,error:l,payload:n,options:t})}))}function d(e,n="asset"){return window.__TAURI__.convertFileSrc(e,n)}t({},{TauriEvent:()=>f,emit:()=>E,listen:()=>v,once:()=>h});var w,f=(e=>(e.WINDOW_RESIZED="tauri://resize",e.WINDOW_MOVED="tauri://move",e.WINDOW_CLOSE_REQUESTED="tauri://close-requested",e.WINDOW_CREATED="tauri://window-created",e.WINDOW_DESTROYED="tauri://destroyed",e.WINDOW_FOCUS="tauri://focus",e.WINDOW_BLUR="tauri://blur",e.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",e.WINDOW_THEME_CHANGED="tauri://theme-changed",e.WINDOW_FILE_DROP="tauri://file-drop",e.WINDOW_FILE_DROP_HOVER="tauri://file-drop-hover",e.WINDOW_FILE_DROP_CANCELLED="tauri://file-drop-cancelled",e.MENU="tauri://menu",e))(f||{});async function g(e,n){await _("plugin:event|unlisten",{event:e,eventId:n})}async function v(e,n,t){return _("plugin:event|listen",{event:e,windowLabel:t?.target,handler:o(n)}).then((n=>async()=>g(e,n)))}async function h(e,n,t){return v(e,(t=>{n(t),g(e,t.id).catch((()=>{}))}),t)}async function E(e,n,t){await _("plugin:event|emit",{event:e,windowLabel:t?.target,payload:n})}async function I(e,n,t){var r,a;const i=null===(r=(new Error).stack)||void 0===r?void 0:r.split("\n").map((e=>e.split("@"))),o=null==i?void 0:i.filter((([e,n])=>e.length>0&&"[native code]"!==n)),{file:l,line:c,keyValues:s}=null!=t?t:{};let u=null===(a=null==o?void 0:o[0])||void 0===a?void 0:a.filter((e=>e.length>0)).join("@");"Error"===u&&(u="webview::unknown"),await window.__TAURI_INVOKE__("plugin:log|log",{level:e,message:n,location:u,file:l,line:c,keyValues:s})}return function(e){e[e.Trace=1]="Trace",e[e.Debug=2]="Debug",e[e.Info=3]="Info",e[e.Warn=4]="Warn",e[e.Error=5]="Error"}(w||(w={})),e.attachConsole=async function(){return await v("log://log",(e=>{const n=e.payload,t=n.message.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,"");switch(n.level){case w.Trace:console.log(t);break;case w.Debug:console.debug(t);break;case w.Info:console.info(t);break;case w.Warn:console.warn(t);break;case w.Error:console.error(t);break;default:throw new Error(`unknown log level ${n.level}`)}}))},e.debug=async function(e,n){await I(w.Debug,e,n)},e.error=async function(e,n){await I(w.Error,e,n)},e.info=async function(e,n){await I(w.Info,e,n)},e.trace=async function(e,n){await I(w.Trace,e,n)},e.warn=async function(e,n){await I(w.Warn,e,n)},e}({});Object.defineProperty(window.__TAURI__,"log",{value:__TAURI_LOG__})} diff --git a/plugins/notification/package.json b/plugins/notification/package.json index cc74a6768..c41c1b27c 100644 --- a/plugins/notification/package.json +++ b/plugins/notification/package.json @@ -27,6 +27,6 @@ "tslib": "^2.4.1" }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.5" + "@tauri-apps/api": "2.0.0-alpha.6" } -} +} \ No newline at end of file diff --git a/plugins/notification/src/api-iife.js b/plugins/notification/src/api-iife.js index 4ef6d877b..68ef23d35 100644 --- a/plugins/notification/src/api-iife.js +++ b/plugins/notification/src/api-iife.js @@ -1 +1 @@ -if("__TAURI__"in window){var __TAURI_NOTIFICATION__=function(n){"use strict";var e=Object.defineProperty,i=(n,e,i)=>{if(!e.has(n))throw TypeError("Cannot "+i)},t=(n,e,t)=>(i(n,e,"read from private field"),t?t.call(n):e.get(n)),o=(n,e,t,o)=>(i(n,e,"write to private field"),o?o.call(n,t):e.set(n,t),t);function r(n,e=!1){let i=window.crypto.getRandomValues(new Uint32Array(1))[0],t=`_${i}`;return Object.defineProperty(window,t,{value:i=>(e&&Reflect.deleteProperty(window,t),n?.(i)),writable:!1,configurable:!0}),i}((n,i)=>{for(var t in i)e(n,t,{get:i[t],enumerable:!0})})({},{Channel:()=>a,PluginListener:()=>f,addPluginListener:()=>d,convertFileSrc:()=>p,invoke:()=>_,transformCallback:()=>r});var c,a=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,((n,e,i)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,i)})(this,c,(()=>{})),this.id=r((n=>{t(this,c).call(this,n)}))}set onmessage(n){o(this,c,n)}get onmessage(){return t(this,c)}toJSON(){return`__CHANNEL__:${this.id}`}};c=new WeakMap;var s,l,u,f=class{constructor(n,e,i){this.plugin=n,this.event=e,this.channelId=i}async unregister(){return _(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function d(n,e,i){let t=new a;return t.onmessage=i,_(`plugin:${n}|register_listener`,{event:e,handler:t}).then((()=>new f(n,e,t.id)))}async function _(n,e={}){return new Promise(((i,t)=>{let o=r((n=>{i(n),Reflect.deleteProperty(window,`_${c}`)}),!0),c=r((n=>{t(n),Reflect.deleteProperty(window,`_${o}`)}),!0);window.__TAURI_IPC__({cmd:n,callback:o,error:c,...e})}))}function p(n,e="asset"){let i=encodeURIComponent(n);return navigator.userAgent.includes("Windows")?`https://${e}.localhost/${i}`:`${e}://localhost/${i}`}return function(n){n.Year="Year",n.Month="Month",n.TwoWeeks="TwoWeeks",n.Week="Week",n.Day="Day",n.Hour="Hour",n.Minute="Minute",n.Second="Second"}(s||(s={})),n.Importance=void 0,(l=n.Importance||(n.Importance={}))[l.None=0]="None",l[l.Min=1]="Min",l[l.Low=2]="Low",l[l.Default=3]="Default",l[l.High=4]="High",n.Visibility=void 0,(u=n.Visibility||(n.Visibility={}))[u.Secret=-1]="Secret",u[u.Private=0]="Private",u[u.Public=1]="Public",n.active=async function(){return _("plugin:notification|get_active")},n.cancel=async function(n){return _("plugin:notification|cancel",{notifications:n})},n.cancelAll=async function(){return _("plugin:notification|cancel")},n.channels=async function(){return _("plugin:notification|getActive")},n.createChannel=async function(n){return _("plugin:notification|create_channel",{...n})},n.isPermissionGranted=async function(){return"default"!==window.Notification.permission?Promise.resolve("granted"===window.Notification.permission):_("plugin:notification|is_permission_granted")},n.onAction=async function(n){return d("notification","actionPerformed",n)},n.onNotificationReceived=async function(n){return d("notification","notification",n)},n.pending=async function(){return _("plugin:notification|get_pending")},n.registerActionTypes=async function(n){return _("plugin:notification|register_action_types",{types:n})},n.removeActive=async function(n){return _("plugin:notification|remove_active",{notifications:n})},n.removeAllActive=async function(){return _("plugin:notification|remove_active")},n.removeChannel=async function(n){return _("plugin:notification|delete_channel",{id:n})},n.requestPermission=async function(){return window.Notification.requestPermission()},n.sendNotification=function(n){"string"==typeof n?new window.Notification(n):new window.Notification(n.title,n)},n}({});Object.defineProperty(window.__TAURI__,"notification",{value:__TAURI_NOTIFICATION__})} +if("__TAURI__"in window){var __TAURI_NOTIFICATION__=function(n){"use strict";var e=Object.defineProperty,i=(n,e,i)=>{if(!e.has(n))throw TypeError("Cannot "+i)},t=(n,e,t)=>(i(n,e,"read from private field"),t?t.call(n):e.get(n)),o=(n,e,t,o)=>(i(n,e,"write to private field"),o?o.call(n,t):e.set(n,t),t);function r(n,e=!1){let i=window.crypto.getRandomValues(new Uint32Array(1))[0],t=`_${i}`;return Object.defineProperty(window,t,{value:i=>(e&&Reflect.deleteProperty(window,t),n?.(i)),writable:!1,configurable:!0}),i}((n,i)=>{for(var t in i)e(n,t,{get:i[t],enumerable:!0})})({},{Channel:()=>a,PluginListener:()=>f,addPluginListener:()=>d,convertFileSrc:()=>w,invoke:()=>_,transformCallback:()=>r});var c,a=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,((n,e,i)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,i)})(this,c,(()=>{})),this.id=r((n=>{t(this,c).call(this,n)}))}set onmessage(n){o(this,c,n)}get onmessage(){return t(this,c)}toJSON(){return`__CHANNEL__:${this.id}`}};c=new WeakMap;var s,l,u,f=class{constructor(n,e,i){this.plugin=n,this.event=e,this.channelId=i}async unregister(){return _(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function d(n,e,i){let t=new a;return t.onmessage=i,_(`plugin:${n}|register_listener`,{event:e,handler:t}).then((()=>new f(n,e,t.id)))}async function _(n,e={},i){return new Promise(((t,o)=>{let c=r((n=>{t(n),Reflect.deleteProperty(window,`_${a}`)}),!0),a=r((n=>{o(n),Reflect.deleteProperty(window,`_${c}`)}),!0);window.__TAURI_IPC__({cmd:n,callback:c,error:a,payload:e,options:i})}))}function w(n,e="asset"){return window.__TAURI__.convertFileSrc(n,e)}return function(n){n.Year="Year",n.Month="Month",n.TwoWeeks="TwoWeeks",n.Week="Week",n.Day="Day",n.Hour="Hour",n.Minute="Minute",n.Second="Second"}(s||(s={})),n.Importance=void 0,(l=n.Importance||(n.Importance={}))[l.None=0]="None",l[l.Min=1]="Min",l[l.Low=2]="Low",l[l.Default=3]="Default",l[l.High=4]="High",n.Visibility=void 0,(u=n.Visibility||(n.Visibility={}))[u.Secret=-1]="Secret",u[u.Private=0]="Private",u[u.Public=1]="Public",n.active=async function(){return _("plugin:notification|get_active")},n.cancel=async function(n){return _("plugin:notification|cancel",{notifications:n})},n.cancelAll=async function(){return _("plugin:notification|cancel")},n.channels=async function(){return _("plugin:notification|getActive")},n.createChannel=async function(n){return _("plugin:notification|create_channel",{...n})},n.isPermissionGranted=async function(){return"default"!==window.Notification.permission?Promise.resolve("granted"===window.Notification.permission):_("plugin:notification|is_permission_granted")},n.onAction=async function(n){return d("notification","actionPerformed",n)},n.onNotificationReceived=async function(n){return d("notification","notification",n)},n.pending=async function(){return _("plugin:notification|get_pending")},n.registerActionTypes=async function(n){return _("plugin:notification|register_action_types",{types:n})},n.removeActive=async function(n){return _("plugin:notification|remove_active",{notifications:n})},n.removeAllActive=async function(){return _("plugin:notification|remove_active")},n.removeChannel=async function(n){return _("plugin:notification|delete_channel",{id:n})},n.requestPermission=async function(){return window.Notification.requestPermission()},n.sendNotification=function(n){"string"==typeof n?new window.Notification(n):new window.Notification(n.title,n)},n}({});Object.defineProperty(window.__TAURI__,"notification",{value:__TAURI_NOTIFICATION__})} diff --git a/plugins/os/package.json b/plugins/os/package.json index 93a51096a..90407659a 100644 --- a/plugins/os/package.json +++ b/plugins/os/package.json @@ -27,6 +27,6 @@ "tslib": "2.6.0" }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.5" + "@tauri-apps/api": "2.0.0-alpha.6" } -} +} \ No newline at end of file diff --git a/plugins/persisted-scope/src/lib.rs b/plugins/persisted-scope/src/lib.rs index b4803dc99..a1e447cab 100644 --- a/plugins/persisted-scope/src/lib.rs +++ b/plugins/persisted-scope/src/lib.rs @@ -254,7 +254,7 @@ pub fn init() -> TauriPlugin { if let Some(fs_scope) = fs_scope { if fs_scope_state_path.exists() { - let scope: Scope = tauri::api::file::read_binary(&fs_scope_state_path) + let scope: Scope = std::fs::read(&fs_scope_state_path) .map_err(Error::from) .and_then(|scope| bincode::deserialize(&scope).map_err(Into::into)) .unwrap_or_default(); @@ -276,7 +276,7 @@ pub fn init() -> TauriPlugin { #[cfg(feature = "protocol-asset")] if asset_scope_state_path.exists() { - let scope: Scope = tauri::api::file::read_binary(&asset_scope_state_path) + let scope: Scope = std::fs::read(&asset_scope_state_path) .map_err(Error::from) .and_then(|scope| bincode::deserialize(&scope).map_err(Into::into)) .unwrap_or_default(); diff --git a/plugins/positioner/Cargo.toml b/plugins/positioner/Cargo.toml index 25189be5f..7d962f96e 100644 --- a/plugins/positioner/Cargo.toml +++ b/plugins/positioner/Cargo.toml @@ -19,4 +19,4 @@ thiserror = { workspace = true } serde_repr = "0.1" [features] -system-tray = [ "tauri/system-tray" ] +tray-icon = [ "tauri/tray-icon" ] diff --git a/plugins/positioner/package.json b/plugins/positioner/package.json index 0593b4a04..fc1975f30 100644 --- a/plugins/positioner/package.json +++ b/plugins/positioner/package.json @@ -28,6 +28,6 @@ "tslib": "2.6.0" }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.5" + "@tauri-apps/api": "2.0.0-alpha.6" } -} +} \ No newline at end of file diff --git a/plugins/positioner/src/ext.rs b/plugins/positioner/src/ext.rs index 196209ada..11a725dca 100644 --- a/plugins/positioner/src/ext.rs +++ b/plugins/positioner/src/ext.rs @@ -3,10 +3,10 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -#[cfg(feature = "system-tray")] +#[cfg(feature = "tray-icon")] use crate::Tray; use serde_repr::Deserialize_repr; -#[cfg(feature = "system-tray")] +#[cfg(feature = "tray-icon")] use tauri::Manager; use tauri::{PhysicalPosition, PhysicalSize, Result, Runtime, Window}; @@ -23,17 +23,17 @@ pub enum Position { LeftCenter, RightCenter, Center, - #[cfg(feature = "system-tray")] + #[cfg(feature = "tray-icon")] TrayLeft, - #[cfg(feature = "system-tray")] + #[cfg(feature = "tray-icon")] TrayBottomLeft, - #[cfg(feature = "system-tray")] + #[cfg(feature = "tray-icon")] TrayRight, - #[cfg(feature = "system-tray")] + #[cfg(feature = "tray-icon")] TrayBottomRight, - #[cfg(feature = "system-tray")] + #[cfg(feature = "tray-icon")] TrayCenter, - #[cfg(feature = "system-tray")] + #[cfg(feature = "tray-icon")] TrayBottomCenter, } @@ -59,7 +59,7 @@ impl WindowExt for Window { width: self.outer_size()?.width as i32, height: self.outer_size()?.height as i32, }; - #[cfg(feature = "system-tray")] + #[cfg(feature = "tray-icon")] let (tray_position, tray_size) = self .state::() .0 @@ -107,7 +107,7 @@ impl WindowExt for Window { x: screen_position.x + ((screen_size.width / 2) - (window_size.width / 2)), y: screen_position.y + (screen_size.height / 2) - (window_size.height / 2), }, - #[cfg(feature = "system-tray")] + #[cfg(feature = "tray-icon")] TrayLeft => { if let Some((tray_x, tray_y)) = tray_position { PhysicalPosition { @@ -118,7 +118,7 @@ impl WindowExt for Window { panic!("tray position not set"); } } - #[cfg(feature = "system-tray")] + #[cfg(feature = "tray-icon")] TrayBottomLeft => { if let Some((tray_x, tray_y)) = tray_position { PhysicalPosition { @@ -129,7 +129,7 @@ impl WindowExt for Window { panic!("Tray position not set"); } } - #[cfg(feature = "system-tray")] + #[cfg(feature = "tray-icon")] TrayRight => { if let (Some((tray_x, tray_y)), Some((tray_width, _))) = (tray_position, tray_size) { @@ -141,7 +141,7 @@ impl WindowExt for Window { panic!("Tray position not set"); } } - #[cfg(feature = "system-tray")] + #[cfg(feature = "tray-icon")] TrayBottomRight => { if let (Some((tray_x, tray_y)), Some((tray_width, _))) = (tray_position, tray_size) { @@ -153,7 +153,7 @@ impl WindowExt for Window { panic!("Tray position not set"); } } - #[cfg(feature = "system-tray")] + #[cfg(feature = "tray-icon")] TrayCenter => { if let (Some((tray_x, tray_y)), Some((tray_width, _))) = (tray_position, tray_size) { @@ -165,7 +165,7 @@ impl WindowExt for Window { panic!("Tray position not set"); } } - #[cfg(feature = "system-tray")] + #[cfg(feature = "tray-icon")] TrayBottomCenter => { if let (Some((tray_x, tray_y)), Some((tray_width, _))) = (tray_position, tray_size) { diff --git a/plugins/positioner/src/lib.rs b/plugins/positioner/src/lib.rs index 0a412d9a0..6c5b735e7 100644 --- a/plugins/positioner/src/lib.rs +++ b/plugins/positioner/src/lib.rs @@ -9,7 +9,7 @@ //! //! # Cargo features //! -//! - **system-tray**: Enables system-tray-relative positions. +//! - **tray-icon**: Enables tray-icon-relative positions. //! //! Note: This requires attaching the Tauri plugin, *even* when using the trait extension only. @@ -27,38 +27,27 @@ use tauri::{ Result, Runtime, }; -#[cfg(feature = "system-tray")] -use tauri::{AppHandle, Manager, PhysicalPosition, PhysicalSize, SystemTrayEvent}; +#[cfg(feature = "tray-icon")] +use tauri::{tray::TrayIconEvent, AppHandle, Manager, PhysicalPosition, PhysicalSize}; -#[cfg(feature = "system-tray")] +#[cfg(feature = "tray-icon")] struct Tray(std::sync::Mutex, PhysicalSize)>>); -#[cfg(feature = "system-tray")] -pub fn on_tray_event(app: &AppHandle, event: &SystemTrayEvent) { - match event { - SystemTrayEvent::LeftClick { position, size, .. } => { - app.state::() - .0 - .lock() - .unwrap() - .replace((*position, *size)); - } - SystemTrayEvent::RightClick { position, size, .. } => { - app.state::() - .0 - .lock() - .unwrap() - .replace((*position, *size)); - } - SystemTrayEvent::DoubleClick { position, size, .. } => { - app.state::() - .0 - .lock() - .unwrap() - .replace((*position, *size)); - } - _ => (), - } +#[cfg(feature = "tray-icon")] +pub fn on_tray_event(app: &AppHandle, event: &TrayIconEvent) { + let position = PhysicalPosition { + x: event.x, + y: event.y, + }; + let size = PhysicalSize { + width: event.icon_rect.right - event.icon_rect.left, + height: event.icon_rect.bottom - event.icon_rect.top, + }; + app.state::() + .0 + .lock() + .unwrap() + .replace((position, size)); } #[tauri::command] @@ -72,7 +61,7 @@ pub fn init() -> TauriPlugin { .js_init_script(include_str!("api-iife.js").to_string()) .invoke_handler(tauri::generate_handler![move_window]); - #[cfg(feature = "system-tray")] + #[cfg(feature = "tray-icon")] let plugin = plugin.setup(|app_handle, _api| { app_handle.manage(Tray(std::sync::Mutex::new(None))); Ok(()) diff --git a/plugins/process/package.json b/plugins/process/package.json index 92490d553..c86aa07c7 100644 --- a/plugins/process/package.json +++ b/plugins/process/package.json @@ -27,6 +27,6 @@ "tslib": "2.6.0" }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.5" + "@tauri-apps/api": "2.0.0-alpha.6" } -} +} \ No newline at end of file diff --git a/plugins/shell/guest-js/index.ts b/plugins/shell/guest-js/index.ts index 6c567c21b..0496849bf 100644 --- a/plugins/shell/guest-js/index.ts +++ b/plugins/shell/guest-js/index.ts @@ -62,14 +62,7 @@ * @module */ -declare global { - interface Window { - __TAURI_INVOKE__: (cmd: string, args?: unknown) => Promise; - __TAURI__: { - transformCallback: (cb: (payload: T) => void) => number; - }; - } -} +import { invoke, Channel } from "@tauri-apps/api/tauri"; /** * @since 2.0.0 @@ -111,7 +104,7 @@ interface ChildProcess { * * @ignore * @param program The name of the scoped command. - * @param onEvent Event handler. + * @param onEventHandler Event handler. * @param args Program arguments. * @param options Configuration for the process spawn. * @returns A promise resolving to the process id. @@ -119,7 +112,7 @@ interface ChildProcess { * @since 2.0.0 */ async function execute( - onEvent: (event: CommandEvent) => void, + onEventHandler: (event: CommandEvent) => void, program: string, args: string | string[] = [], options?: InternalSpawnOptions, @@ -128,11 +121,14 @@ async function execute( Object.freeze(args); } - return window.__TAURI_INVOKE__("plugin:shell|execute", { + const onEvent = new Channel>(); + onEvent.onmessage = onEventHandler; + + return invoke("plugin:shell|execute", { program, args, options, - onEventFn: window.__TAURI__.transformCallback(onEvent), + onEvent, }); } @@ -358,7 +354,7 @@ class Child { * @since 2.0.0 */ async write(data: IOPayload): Promise { - return window.__TAURI_INVOKE__("plugin:shell|stdin_write", { + return invoke("plugin:shell|stdin_write", { pid: this.pid, // correctly serialize Uint8Arrays buffer: typeof data === "string" ? data : Array.from(data), @@ -373,7 +369,7 @@ class Child { * @since 2.0.0 */ async kill(): Promise { - return window.__TAURI_INVOKE__("plugin:shell|kill", { + return invoke("plugin:shell|kill", { cmd: "killChild", pid: this.pid, }); @@ -648,7 +644,7 @@ type CommandEvent = * @since 2.0.0 */ async function open(path: string, openWith?: string): Promise { - return window.__TAURI_INVOKE__("plugin:shell|open", { + return invoke("plugin:shell|open", { path, with: openWith, }); diff --git a/plugins/shell/package.json b/plugins/shell/package.json index 5b2cae099..c79961f98 100644 --- a/plugins/shell/package.json +++ b/plugins/shell/package.json @@ -27,6 +27,6 @@ "tslib": "^2.4.1" }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.5" + "@tauri-apps/api": "2.0.0-alpha.6" } -} +} \ No newline at end of file diff --git a/plugins/shell/src/api-iife.js b/plugins/shell/src/api-iife.js index cb6b28ac9..8125c2e19 100644 --- a/plugins/shell/src/api-iife.js +++ b/plugins/shell/src/api-iife.js @@ -1 +1 @@ -if("__TAURI__"in window){var __TAURI_SHELL__=function(e){"use strict";class t{constructor(){this.eventListeners=Object.create(null)}addListener(e,t){return this.on(e,t)}removeListener(e,t){return this.off(e,t)}on(e,t){return e in this.eventListeners?this.eventListeners[e].push(t):this.eventListeners[e]=[t],this}once(e,t){const s=n=>{this.removeListener(e,s),t(n)};return this.addListener(e,s)}off(e,t){return e in this.eventListeners&&(this.eventListeners[e]=this.eventListeners[e].filter((e=>e!==t))),this}removeAllListeners(e){return e?delete this.eventListeners[e]:this.eventListeners=Object.create(null),this}emit(e,t){if(e in this.eventListeners){const s=this.eventListeners[e];for(const e of s)e(t);return!0}return!1}listenerCount(e){return e in this.eventListeners?this.eventListeners[e].length:0}prependListener(e,t){return e in this.eventListeners?this.eventListeners[e].unshift(t):this.eventListeners[e]=[t],this}prependOnceListener(e,t){const s=n=>{this.removeListener(e,s),t(n)};return this.prependListener(e,s)}}class s{constructor(e){this.pid=e}async write(e){return window.__TAURI_INVOKE__("plugin:shell|stdin_write",{pid:this.pid,buffer:"string"==typeof e?e:Array.from(e)})}async kill(){return window.__TAURI_INVOKE__("plugin:shell|kill",{cmd:"killChild",pid:this.pid})}}class n extends t{constructor(e,s=[],n){super(),this.stdout=new t,this.stderr=new t,this.program=e,this.args="string"==typeof s?[s]:s,this.options=null!=n?n:{}}static create(e,t=[],s){return new n(e,t,s)}static sidecar(e,t=[],s){const r=new n(e,t,s);return r.options.sidecar=!0,r}async spawn(){return async function(e,t,s=[],n){return"object"==typeof s&&Object.freeze(s),window.__TAURI_INVOKE__("plugin:shell|execute",{program:t,args:s,options:n,onEventFn:window.__TAURI__.transformCallback(e)})}((e=>{switch(e.event){case"Error":this.emit("error",e.payload);break;case"Terminated":this.emit("close",e.payload);break;case"Stdout":this.stdout.emit("data",e.payload);break;case"Stderr":this.stderr.emit("data",e.payload)}}),this.program,this.args,this.options).then((e=>new s(e)))}async execute(){return new Promise(((e,t)=>{this.on("error",t);const s=[],n=[];this.stdout.on("data",(e=>{s.push(e)})),this.stderr.on("data",(e=>{n.push(e)})),this.on("close",(t=>{e({code:t.code,signal:t.signal,stdout:this.collectOutput(s),stderr:this.collectOutput(n)})})),this.spawn().catch(t)}))}collectOutput(e){return"raw"===this.options.encoding?e.reduce(((e,t)=>new Uint8Array([...e,...t,10])),new Uint8Array):e.join("\n")}}return e.Child=s,e.Command=n,e.EventEmitter=t,e.open=async function(e,t){return window.__TAURI_INVOKE__("plugin:shell|open",{path:e,with:t})},e}({});Object.defineProperty(window.__TAURI__,"shell",{value:__TAURI_SHELL__})} +if("__TAURI__"in window){var __TAURI_SHELL__=function(e){"use strict";var t=Object.defineProperty,n=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},r=(e,t,r)=>(n(e,t,"read from private field"),r?r.call(e):t.get(e)),s=(e,t,r,s)=>(n(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r);function i(e,t=!1){let n=window.crypto.getRandomValues(new Uint32Array(1))[0],r=`_${n}`;return Object.defineProperty(window,r,{value:n=>(t&&Reflect.deleteProperty(window,r),e?.(n)),writable:!1,configurable:!0}),n}((e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})})({},{Channel:()=>a,PluginListener:()=>c,addPluginListener:()=>l,convertFileSrc:()=>u,invoke:()=>h,transformCallback:()=>i});var o,a=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,((e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)})(this,o,(()=>{})),this.id=i((e=>{r(this,o).call(this,e)}))}set onmessage(e){s(this,o,e)}get onmessage(){return r(this,o)}toJSON(){return`__CHANNEL__:${this.id}`}};o=new WeakMap;var c=class{constructor(e,t,n){this.plugin=e,this.event=t,this.channelId=n}async unregister(){return h(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function l(e,t,n){let r=new a;return r.onmessage=n,h(`plugin:${e}|register_listener`,{event:t,handler:r}).then((()=>new c(e,t,r.id)))}async function h(e,t={},n){return new Promise(((r,s)=>{let o=i((e=>{r(e),Reflect.deleteProperty(window,`_${a}`)}),!0),a=i((e=>{s(e),Reflect.deleteProperty(window,`_${o}`)}),!0);window.__TAURI_IPC__({cmd:e,callback:o,error:a,payload:t,options:n})}))}function u(e,t="asset"){return window.__TAURI__.convertFileSrc(e,t)}class d{constructor(){this.eventListeners=Object.create(null)}addListener(e,t){return this.on(e,t)}removeListener(e,t){return this.off(e,t)}on(e,t){return e in this.eventListeners?this.eventListeners[e].push(t):this.eventListeners[e]=[t],this}once(e,t){const n=r=>{this.removeListener(e,n),t(r)};return this.addListener(e,n)}off(e,t){return e in this.eventListeners&&(this.eventListeners[e]=this.eventListeners[e].filter((e=>e!==t))),this}removeAllListeners(e){return e?delete this.eventListeners[e]:this.eventListeners=Object.create(null),this}emit(e,t){if(e in this.eventListeners){const n=this.eventListeners[e];for(const e of n)e(t);return!0}return!1}listenerCount(e){return e in this.eventListeners?this.eventListeners[e].length:0}prependListener(e,t){return e in this.eventListeners?this.eventListeners[e].unshift(t):this.eventListeners[e]=[t],this}prependOnceListener(e,t){const n=r=>{this.removeListener(e,n),t(r)};return this.prependListener(e,n)}}class p{constructor(e){this.pid=e}async write(e){return h("plugin:shell|stdin_write",{pid:this.pid,buffer:"string"==typeof e?e:Array.from(e)})}async kill(){return h("plugin:shell|kill",{cmd:"killChild",pid:this.pid})}}class w extends d{constructor(e,t=[],n){super(),this.stdout=new d,this.stderr=new d,this.program=e,this.args="string"==typeof t?[t]:t,this.options=null!=n?n:{}}static create(e,t=[],n){return new w(e,t,n)}static sidecar(e,t=[],n){const r=new w(e,t,n);return r.options.sidecar=!0,r}async spawn(){return async function(e,t,n=[],r){"object"==typeof n&&Object.freeze(n);const s=new a;return s.onmessage=e,h("plugin:shell|execute",{program:t,args:n,options:r,onEvent:s})}((e=>{switch(e.event){case"Error":this.emit("error",e.payload);break;case"Terminated":this.emit("close",e.payload);break;case"Stdout":this.stdout.emit("data",e.payload);break;case"Stderr":this.stderr.emit("data",e.payload)}}),this.program,this.args,this.options).then((e=>new p(e)))}async execute(){return new Promise(((e,t)=>{this.on("error",t);const n=[],r=[];this.stdout.on("data",(e=>{n.push(e)})),this.stderr.on("data",(e=>{r.push(e)})),this.on("close",(t=>{e({code:t.code,signal:t.signal,stdout:this.collectOutput(n),stderr:this.collectOutput(r)})})),this.spawn().catch(t)}))}collectOutput(e){return"raw"===this.options.encoding?e.reduce(((e,t)=>new Uint8Array([...e,...t,10])),new Uint8Array):e.join("\n")}}return e.Child=p,e.Command=w,e.EventEmitter=d,e.open=async function(e,t){return h("plugin:shell|open",{path:e,with:t})},e}({});Object.defineProperty(window.__TAURI__,"shell",{value:__TAURI_SHELL__})} diff --git a/plugins/shell/src/commands.rs b/plugins/shell/src/commands.rs index e4b63e245..fd1e5058a 100644 --- a/plugins/shell/src/commands.rs +++ b/plugins/shell/src/commands.rs @@ -6,7 +6,7 @@ use std::{collections::HashMap, path::PathBuf, string::FromUtf8Error}; use encoding_rs::Encoding; use serde::{Deserialize, Serialize}; -use tauri::{api::ipc::CallbackFn, Manager, Runtime, State, Window}; +use tauri::{ipc::Channel, Manager, Runtime, State, Window}; use crate::{ open::Program, @@ -97,7 +97,7 @@ pub fn execute( shell: State<'_, Shell>, program: String, args: ExecuteArgs, - on_event_fn: CallbackFn, + on_event: Channel, options: CommandOptions, ) -> crate::Result { let mut command = if options.sidecar { @@ -166,10 +166,7 @@ pub fn execute( children.lock().unwrap().remove(&pid); }; let js_event = JSCommandEvent::new(event, encoding); - let js = tauri::api::ipc::format_callback(on_event_fn, &js_event) - .expect("unable to serialize CommandEvent"); - - let _ = window.eval(js.as_str()); + let _ = on_event.send(&js_event); } }); diff --git a/plugins/single-instance/examples/vanilla/package.json b/plugins/single-instance/examples/vanilla/package.json index f3d8f88e4..1578d03e7 100644 --- a/plugins/single-instance/examples/vanilla/package.json +++ b/plugins/single-instance/examples/vanilla/package.json @@ -9,6 +9,6 @@ "author": "", "license": "MIT", "devDependencies": { - "@tauri-apps/cli": "2.0.0-alpha.10" + "@tauri-apps/cli": "2.0.0-alpha.11" } } diff --git a/plugins/sql/package.json b/plugins/sql/package.json index 28ad04e85..a2ae06bbf 100644 --- a/plugins/sql/package.json +++ b/plugins/sql/package.json @@ -28,6 +28,6 @@ "tslib": "2.6.0" }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.5" + "@tauri-apps/api": "2.0.0-alpha.6" } -} +} \ No newline at end of file diff --git a/plugins/store/package.json b/plugins/store/package.json index 63f61ac26..74ff42779 100644 --- a/plugins/store/package.json +++ b/plugins/store/package.json @@ -28,6 +28,6 @@ "tslib": "2.6.0" }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.5" + "@tauri-apps/api": "2.0.0-alpha.6" } -} +} \ No newline at end of file diff --git a/plugins/store/src/api-iife.js b/plugins/store/src/api-iife.js index 9e7f497b0..3f074050a 100644 --- a/plugins/store/src/api-iife.js +++ b/plugins/store/src/api-iife.js @@ -1 +1 @@ -if("__TAURI__"in window){var __TAURI_STORE__=function(e){"use strict";var t=Object.defineProperty,a=(e,a)=>{for(var n in a)t(e,n,{get:a[n],enumerable:!0})},n=(e,t,a)=>{if(!t.has(e))throw TypeError("Cannot "+a)},r=(e,t,a)=>(n(e,t,"read from private field"),a?a.call(e):t.get(e)),i=(e,t,a,r)=>(n(e,t,"write to private field"),r?r.call(e,a):t.set(e,a),a);function s(e,t=!1){let a=window.crypto.getRandomValues(new Uint32Array(1))[0],n=`_${a}`;return Object.defineProperty(window,n,{value:a=>(t&&Reflect.deleteProperty(window,n),e?.(a)),writable:!1,configurable:!0}),a}a({},{Channel:()=>o,PluginListener:()=>l,addPluginListener:()=>u,convertFileSrc:()=>c,invoke:()=>h,transformCallback:()=>s});var _,o=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,((e,t,a)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,a)})(this,_,(()=>{})),this.id=s((e=>{r(this,_).call(this,e)}))}set onmessage(e){i(this,_,e)}get onmessage(){return r(this,_)}toJSON(){return`__CHANNEL__:${this.id}`}};_=new WeakMap;var l=class{constructor(e,t,a){this.plugin=e,this.event=t,this.channelId=a}async unregister(){return h(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function u(e,t,a){let n=new o;return n.onmessage=a,h(`plugin:${e}|register_listener`,{event:t,handler:n}).then((()=>new l(e,t,n.id)))}async function h(e,t={}){return new Promise(((a,n)=>{let r=s((e=>{a(e),Reflect.deleteProperty(window,`_${i}`)}),!0),i=s((e=>{n(e),Reflect.deleteProperty(window,`_${r}`)}),!0);window.__TAURI_IPC__({cmd:e,callback:r,error:i,...t})}))}function c(e,t="asset"){let a=encodeURIComponent(e);return navigator.userAgent.includes("Windows")?`https://${t}.localhost/${a}`:`${t}://localhost/${a}`}a({},{TauriEvent:()=>d,emit:()=>y,listen:()=>w,once:()=>I});var d=(e=>(e.WINDOW_RESIZED="tauri://resize",e.WINDOW_MOVED="tauri://move",e.WINDOW_CLOSE_REQUESTED="tauri://close-requested",e.WINDOW_CREATED="tauri://window-created",e.WINDOW_DESTROYED="tauri://destroyed",e.WINDOW_FOCUS="tauri://focus",e.WINDOW_BLUR="tauri://blur",e.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",e.WINDOW_THEME_CHANGED="tauri://theme-changed",e.WINDOW_FILE_DROP="tauri://file-drop",e.WINDOW_FILE_DROP_HOVER="tauri://file-drop-hover",e.WINDOW_FILE_DROP_CANCELLED="tauri://file-drop-cancelled",e.MENU="tauri://menu",e))(d||{});async function p(e,t){await h("plugin:event|unlisten",{event:e,eventId:t})}async function w(e,t,a){return h("plugin:event|listen",{event:e,windowLabel:a?.target,handler:s(t)}).then((t=>async()=>p(e,t)))}async function I(e,t,a){return w(e,(a=>{t(a),p(e,a.id).catch((()=>{}))}),a)}async function y(e,t,a){await h("plugin:event|emit",{event:e,windowLabel:a?.target,payload:t})}return e.Store=class{constructor(e){this.path=e}async set(e,t){return await window.__TAURI_INVOKE__("plugin:store|set",{path:this.path,key:e,value:t})}async get(e){return await window.__TAURI_INVOKE__("plugin:store|get",{path:this.path,key:e})}async has(e){return await window.__TAURI_INVOKE__("plugin:store|has",{path:this.path,key:e})}async delete(e){return await window.__TAURI_INVOKE__("plugin:store|delete",{path:this.path,key:e})}async clear(){return await window.__TAURI_INVOKE__("plugin:store|clear",{path:this.path})}async reset(){return await window.__TAURI_INVOKE__("plugin:store|reset",{path:this.path})}async keys(){return await window.__TAURI_INVOKE__("plugin:store|keys",{path:this.path})}async values(){return await window.__TAURI_INVOKE__("plugin:store|values",{path:this.path})}async entries(){return await window.__TAURI_INVOKE__("plugin:store|entries",{path:this.path})}async length(){return await window.__TAURI_INVOKE__("plugin:store|length",{path:this.path})}async load(){return await window.__TAURI_INVOKE__("plugin:store|load",{path:this.path})}async save(){return await window.__TAURI_INVOKE__("plugin:store|save",{path:this.path})}async onKeyChange(e,t){return await w("store://change",(a=>{a.payload.path===this.path&&a.payload.key===e&&t(a.payload.value)}))}async onChange(e){return await w("store://change",(t=>{t.payload.path===this.path&&e(t.payload.key,t.payload.value)}))}},e}({});Object.defineProperty(window.__TAURI__,"store",{value:__TAURI_STORE__})} +if("__TAURI__"in window){var __TAURI_STORE__=function(e){"use strict";var t=Object.defineProperty,a=(e,a)=>{for(var n in a)t(e,n,{get:a[n],enumerable:!0})},n=(e,t,a)=>{if(!t.has(e))throw TypeError("Cannot "+a)},r=(e,t,a)=>(n(e,t,"read from private field"),a?a.call(e):t.get(e)),i=(e,t,a,r)=>(n(e,t,"write to private field"),r?r.call(e,a):t.set(e,a),a);function s(e,t=!1){let a=window.crypto.getRandomValues(new Uint32Array(1))[0],n=`_${a}`;return Object.defineProperty(window,n,{value:a=>(t&&Reflect.deleteProperty(window,n),e?.(a)),writable:!1,configurable:!0}),a}a({},{Channel:()=>o,PluginListener:()=>l,addPluginListener:()=>u,convertFileSrc:()=>c,invoke:()=>h,transformCallback:()=>s});var _,o=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,((e,t,a)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,a)})(this,_,(()=>{})),this.id=s((e=>{r(this,_).call(this,e)}))}set onmessage(e){i(this,_,e)}get onmessage(){return r(this,_)}toJSON(){return`__CHANNEL__:${this.id}`}};_=new WeakMap;var l=class{constructor(e,t,a){this.plugin=e,this.event=t,this.channelId=a}async unregister(){return h(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function u(e,t,a){let n=new o;return n.onmessage=a,h(`plugin:${e}|register_listener`,{event:t,handler:n}).then((()=>new l(e,t,n.id)))}async function h(e,t={},a){return new Promise(((n,r)=>{let i=s((e=>{n(e),Reflect.deleteProperty(window,`_${_}`)}),!0),_=s((e=>{r(e),Reflect.deleteProperty(window,`_${i}`)}),!0);window.__TAURI_IPC__({cmd:e,callback:i,error:_,payload:t,options:a})}))}function c(e,t="asset"){return window.__TAURI__.convertFileSrc(e,t)}a({},{TauriEvent:()=>p,emit:()=>y,listen:()=>d,once:()=>I});var p=(e=>(e.WINDOW_RESIZED="tauri://resize",e.WINDOW_MOVED="tauri://move",e.WINDOW_CLOSE_REQUESTED="tauri://close-requested",e.WINDOW_CREATED="tauri://window-created",e.WINDOW_DESTROYED="tauri://destroyed",e.WINDOW_FOCUS="tauri://focus",e.WINDOW_BLUR="tauri://blur",e.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",e.WINDOW_THEME_CHANGED="tauri://theme-changed",e.WINDOW_FILE_DROP="tauri://file-drop",e.WINDOW_FILE_DROP_HOVER="tauri://file-drop-hover",e.WINDOW_FILE_DROP_CANCELLED="tauri://file-drop-cancelled",e.MENU="tauri://menu",e))(p||{});async function w(e,t){await h("plugin:event|unlisten",{event:e,eventId:t})}async function d(e,t,a){return h("plugin:event|listen",{event:e,windowLabel:a?.target,handler:s(t)}).then((t=>async()=>w(e,t)))}async function I(e,t,a){return d(e,(a=>{t(a),w(e,a.id).catch((()=>{}))}),a)}async function y(e,t,a){await h("plugin:event|emit",{event:e,windowLabel:a?.target,payload:t})}return e.Store=class{constructor(e){this.path=e}async set(e,t){return await window.__TAURI_INVOKE__("plugin:store|set",{path:this.path,key:e,value:t})}async get(e){return await window.__TAURI_INVOKE__("plugin:store|get",{path:this.path,key:e})}async has(e){return await window.__TAURI_INVOKE__("plugin:store|has",{path:this.path,key:e})}async delete(e){return await window.__TAURI_INVOKE__("plugin:store|delete",{path:this.path,key:e})}async clear(){return await window.__TAURI_INVOKE__("plugin:store|clear",{path:this.path})}async reset(){return await window.__TAURI_INVOKE__("plugin:store|reset",{path:this.path})}async keys(){return await window.__TAURI_INVOKE__("plugin:store|keys",{path:this.path})}async values(){return await window.__TAURI_INVOKE__("plugin:store|values",{path:this.path})}async entries(){return await window.__TAURI_INVOKE__("plugin:store|entries",{path:this.path})}async length(){return await window.__TAURI_INVOKE__("plugin:store|length",{path:this.path})}async load(){return await window.__TAURI_INVOKE__("plugin:store|load",{path:this.path})}async save(){return await window.__TAURI_INVOKE__("plugin:store|save",{path:this.path})}async onKeyChange(e,t){return await d("store://change",(a=>{a.payload.path===this.path&&a.payload.key===e&&t(a.payload.value)}))}async onChange(e){return await d("store://change",(t=>{t.payload.path===this.path&&e(t.payload.key,t.payload.value)}))}},e}({});Object.defineProperty(window.__TAURI__,"store",{value:__TAURI_STORE__})} diff --git a/plugins/stronghold/package.json b/plugins/stronghold/package.json index 8d3ed06bf..3a09383e6 100644 --- a/plugins/stronghold/package.json +++ b/plugins/stronghold/package.json @@ -28,6 +28,6 @@ "tslib": "2.6.0" }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.5" + "@tauri-apps/api": "2.0.0-alpha.6" } -} +} \ No newline at end of file diff --git a/plugins/updater/package.json b/plugins/updater/package.json index ef19ccab3..d80408926 100644 --- a/plugins/updater/package.json +++ b/plugins/updater/package.json @@ -27,6 +27,6 @@ "tslib": "^2.5.0" }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.5" + "@tauri-apps/api": "2.0.0-alpha.6" } -} +} \ No newline at end of file diff --git a/plugins/updater/src/api-iife.js b/plugins/updater/src/api-iife.js index 4574b7dd4..287417b69 100644 --- a/plugins/updater/src/api-iife.js +++ b/plugins/updater/src/api-iife.js @@ -1 +1 @@ -if("__TAURI__"in window){var __TAURI_UPDATER__=function(e){"use strict";var n=Object.defineProperty,t=(e,n,t)=>{if(!n.has(e))throw TypeError("Cannot "+t)},r=(e,n,r)=>(t(e,n,"read from private field"),r?r.call(e):n.get(e)),i=(e,n,r,i)=>(t(e,n,"write to private field"),i?i.call(e,r):n.set(e,r),r);function a(e,n=!1){let t=window.crypto.getRandomValues(new Uint32Array(1))[0],r=`_${t}`;return Object.defineProperty(window,r,{value:t=>(n&&Reflect.deleteProperty(window,r),e?.(t)),writable:!1,configurable:!0}),t}((e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})})({},{Channel:()=>o,PluginListener:()=>l,addPluginListener:()=>c,convertFileSrc:()=>u,invoke:()=>d,transformCallback:()=>a});var s,o=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,((e,n,t)=>{if(n.has(e))throw TypeError("Cannot add the same private member more than once");n instanceof WeakSet?n.add(e):n.set(e,t)})(this,s,(()=>{})),this.id=a((e=>{r(this,s).call(this,e)}))}set onmessage(e){i(this,s,e)}get onmessage(){return r(this,s)}toJSON(){return`__CHANNEL__:${this.id}`}};s=new WeakMap;var l=class{constructor(e,n,t){this.plugin=e,this.event=n,this.channelId=t}async unregister(){return d(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function c(e,n,t){let r=new o;return r.onmessage=t,d(`plugin:${e}|register_listener`,{event:n,handler:r}).then((()=>new l(e,n,r.id)))}async function d(e,n={}){return new Promise(((t,r)=>{let i=a((e=>{t(e),Reflect.deleteProperty(window,`_${s}`)}),!0),s=a((e=>{r(e),Reflect.deleteProperty(window,`_${i}`)}),!0);window.__TAURI_IPC__({cmd:e,callback:i,error:s,...n})}))}function u(e,n="asset"){let t=encodeURIComponent(e);return navigator.userAgent.includes("Windows")?`https://${n}.localhost/${t}`:`${n}://localhost/${t}`}class _{constructor(e){this.currentVersion=e.currentVersion,this.version=e.version,this.date=e.date,this.body=e.body}async downloadAndInstall(e){const n=new o;return null!=e&&(n.onmessage=e),d("plugin:updater|download_and_install",{onEvent:n})}}return e.Update=_,e.check=async function(e){return(null==e?void 0:e.headers)&&(e.headers=Array.from(new Headers(e.headers).entries())),d("plugin:updater|check",{...e}).then((e=>e.available?new _(e):null))},e}({});Object.defineProperty(window.__TAURI__,"updater",{value:__TAURI_UPDATER__})} +if("__TAURI__"in window){var __TAURI_UPDATER__=function(e){"use strict";var n=Object.defineProperty,t=(e,n,t)=>{if(!n.has(e))throw TypeError("Cannot "+t)},r=(e,n,r)=>(t(e,n,"read from private field"),r?r.call(e):n.get(e)),i=(e,n,r,i)=>(t(e,n,"write to private field"),i?i.call(e,r):n.set(e,r),r);function a(e,n=!1){let t=window.crypto.getRandomValues(new Uint32Array(1))[0],r=`_${t}`;return Object.defineProperty(window,r,{value:t=>(n&&Reflect.deleteProperty(window,r),e?.(t)),writable:!1,configurable:!0}),t}((e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})})({},{Channel:()=>o,PluginListener:()=>l,addPluginListener:()=>d,convertFileSrc:()=>_,invoke:()=>c,transformCallback:()=>a});var s,o=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,((e,n,t)=>{if(n.has(e))throw TypeError("Cannot add the same private member more than once");n instanceof WeakSet?n.add(e):n.set(e,t)})(this,s,(()=>{})),this.id=a((e=>{r(this,s).call(this,e)}))}set onmessage(e){i(this,s,e)}get onmessage(){return r(this,s)}toJSON(){return`__CHANNEL__:${this.id}`}};s=new WeakMap;var l=class{constructor(e,n,t){this.plugin=e,this.event=n,this.channelId=t}async unregister(){return c(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function d(e,n,t){let r=new o;return r.onmessage=t,c(`plugin:${e}|register_listener`,{event:n,handler:r}).then((()=>new l(e,n,r.id)))}async function c(e,n={},t){return new Promise(((r,i)=>{let s=a((e=>{r(e),Reflect.deleteProperty(window,`_${o}`)}),!0),o=a((e=>{i(e),Reflect.deleteProperty(window,`_${s}`)}),!0);window.__TAURI_IPC__({cmd:e,callback:s,error:o,payload:n,options:t})}))}function _(e,n="asset"){return window.__TAURI__.convertFileSrc(e,n)}class u{constructor(e){this.currentVersion=e.currentVersion,this.version=e.version,this.date=e.date,this.body=e.body}async downloadAndInstall(e){const n=new o;return null!=e&&(n.onmessage=e),c("plugin:updater|download_and_install",{onEvent:n})}}return e.Update=u,e.check=async function(e){return(null==e?void 0:e.headers)&&(e.headers=Array.from(new Headers(e.headers).entries())),c("plugin:updater|check",{...e}).then((e=>e.available?new u(e):null))},e}({});Object.defineProperty(window.__TAURI__,"updater",{value:__TAURI_UPDATER__})} diff --git a/plugins/updater/src/commands.rs b/plugins/updater/src/commands.rs index cd621dc92..4e8fcdc81 100644 --- a/plugins/updater/src/commands.rs +++ b/plugins/updater/src/commands.rs @@ -5,7 +5,7 @@ use crate::{PendingUpdate, Result, UpdaterExt}; use serde::Serialize; -use tauri::{api::ipc::Channel, AppHandle, Runtime, State}; +use tauri::{ipc::Channel, AppHandle, Runtime, State}; use std::{ sync::atomic::{AtomicBool, Ordering}, @@ -76,7 +76,7 @@ pub(crate) async fn check( pub(crate) async fn download_and_install( _app: AppHandle, pending: State<'_, PendingUpdate>, - on_event: Channel, + on_event: Channel, ) -> Result<()> { if let Some(pending) = &*pending.0.lock().await { let first_chunk = AtomicBool::new(false); @@ -86,11 +86,11 @@ pub(crate) async fn download_and_install( move |chunk_length, content_length| { if first_chunk.swap(false, Ordering::Acquire) { on_event - .send(&DownloadEvent::Started { content_length }) + .send(DownloadEvent::Started { content_length }) .unwrap(); } on_event - .send(&DownloadEvent::Progress { chunk_length }) + .send(DownloadEvent::Progress { chunk_length }) .unwrap(); }, move || { diff --git a/plugins/updater/tests/app-updater/src/main.rs b/plugins/updater/tests/app-updater/src/main.rs index b16926cf5..ad145c499 100644 --- a/plugins/updater/tests/app-updater/src/main.rs +++ b/plugins/updater/tests/app-updater/src/main.rs @@ -13,7 +13,7 @@ fn main() { tauri::Builder::default() .plugin(tauri_plugin_updater::Builder::new().build()) .setup(|app| { - let handle = app.handle(); + let handle = app.handle().clone(); tauri::async_runtime::spawn(async move { let mut builder = handle.updater_builder(); if std::env::var("TARGET").unwrap_or_default() == "nsis" { diff --git a/plugins/upload/package.json b/plugins/upload/package.json index db31acf1b..b7a6f249e 100644 --- a/plugins/upload/package.json +++ b/plugins/upload/package.json @@ -28,6 +28,6 @@ "tslib": "2.6.0" }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.5" + "@tauri-apps/api": "2.0.0-alpha.6" } -} +} \ No newline at end of file diff --git a/plugins/upload/src/api-iife.js b/plugins/upload/src/api-iife.js index 210ee0d95..567fe0db1 100644 --- a/plugins/upload/src/api-iife.js +++ b/plugins/upload/src/api-iife.js @@ -1 +1 @@ -if("__TAURI__"in window){var __TAURI_UPLOAD__=function(e){"use strict";var n=Object.defineProperty,t=(e,n,t)=>{if(!n.has(e))throw TypeError("Cannot "+t)},r=(e,n,r)=>(t(e,n,"read from private field"),r?r.call(e):n.get(e)),o=(e,n,r,o)=>(t(e,n,"write to private field"),o?o.call(e,r):n.set(e,r),r);function a(e,n=!1){let t=window.crypto.getRandomValues(new Uint32Array(1))[0],r=`_${t}`;return Object.defineProperty(window,r,{value:t=>(n&&Reflect.deleteProperty(window,r),e?.(t)),writable:!1,configurable:!0}),t}((e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})})({},{Channel:()=>s,PluginListener:()=>l,addPluginListener:()=>d,convertFileSrc:()=>u,invoke:()=>c,transformCallback:()=>a});var i,s=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,((e,n,t)=>{if(n.has(e))throw TypeError("Cannot add the same private member more than once");n instanceof WeakSet?n.add(e):n.set(e,t)})(this,i,(()=>{})),this.id=a((e=>{r(this,i).call(this,e)}))}set onmessage(e){o(this,i,e)}get onmessage(){return r(this,i)}toJSON(){return`__CHANNEL__:${this.id}`}};i=new WeakMap;var l=class{constructor(e,n,t){this.plugin=e,this.event=n,this.channelId=t}async unregister(){return c(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function d(e,n,t){let r=new s;return r.onmessage=t,c(`plugin:${e}|register_listener`,{event:n,handler:r}).then((()=>new l(e,n,r.id)))}async function c(e,n={}){return new Promise(((t,r)=>{let o=a((e=>{t(e),Reflect.deleteProperty(window,`_${i}`)}),!0),i=a((e=>{r(e),Reflect.deleteProperty(window,`_${o}`)}),!0);window.__TAURI_IPC__({cmd:e,callback:o,error:i,...n})}))}function u(e,n="asset"){let t=encodeURIComponent(e);return navigator.userAgent.includes("Windows")?`https://${n}.localhost/${t}`:`${n}://localhost/${t}`}return e.download=async function(e,n,t,r){const o=new Uint32Array(1);window.crypto.getRandomValues(o);const a=o[0],i=new s;null!=t&&(i.onmessage=t),await c("plugin:upload|download",{id:a,url:e,filePath:n,headers:null!=r?r:{},onProgress:i})},e.upload=async function(e,n,t,r){const o=new Uint32Array(1);window.crypto.getRandomValues(o);const a=o[0],i=new s;null!=t&&(i.onmessage=t),await c("plugin:upload|upload",{id:a,url:e,filePath:n,headers:null!=r?r:{},onProgress:i})},e}({});Object.defineProperty(window.__TAURI__,"upload",{value:__TAURI_UPLOAD__})} +if("__TAURI__"in window){var __TAURI_UPLOAD__=function(e){"use strict";var n=Object.defineProperty,t=(e,n,t)=>{if(!n.has(e))throw TypeError("Cannot "+t)},r=(e,n,r)=>(t(e,n,"read from private field"),r?r.call(e):n.get(e)),i=(e,n,r,i)=>(t(e,n,"write to private field"),i?i.call(e,r):n.set(e,r),r);function o(e,n=!1){let t=window.crypto.getRandomValues(new Uint32Array(1))[0],r=`_${t}`;return Object.defineProperty(window,r,{value:t=>(n&&Reflect.deleteProperty(window,r),e?.(t)),writable:!1,configurable:!0}),t}((e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})})({},{Channel:()=>l,PluginListener:()=>s,addPluginListener:()=>d,convertFileSrc:()=>u,invoke:()=>c,transformCallback:()=>o});var a,l=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,((e,n,t)=>{if(n.has(e))throw TypeError("Cannot add the same private member more than once");n instanceof WeakSet?n.add(e):n.set(e,t)})(this,a,(()=>{})),this.id=o((e=>{r(this,a).call(this,e)}))}set onmessage(e){i(this,a,e)}get onmessage(){return r(this,a)}toJSON(){return`__CHANNEL__:${this.id}`}};a=new WeakMap;var s=class{constructor(e,n,t){this.plugin=e,this.event=n,this.channelId=t}async unregister(){return c(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function d(e,n,t){let r=new l;return r.onmessage=t,c(`plugin:${e}|register_listener`,{event:n,handler:r}).then((()=>new s(e,n,r.id)))}async function c(e,n={},t){return new Promise(((r,i)=>{let a=o((e=>{r(e),Reflect.deleteProperty(window,`_${l}`)}),!0),l=o((e=>{i(e),Reflect.deleteProperty(window,`_${a}`)}),!0);window.__TAURI_IPC__({cmd:e,callback:a,error:l,payload:n,options:t})}))}function u(e,n="asset"){return window.__TAURI__.convertFileSrc(e,n)}return e.download=async function(e,n,t,r){const i=new Uint32Array(1);window.crypto.getRandomValues(i);const o=i[0],a=new l;null!=t&&(a.onmessage=t),await c("plugin:upload|download",{id:o,url:e,filePath:n,headers:null!=r?r:{},onProgress:a})},e.upload=async function(e,n,t,r){const i=new Uint32Array(1);window.crypto.getRandomValues(i);const o=i[0],a=new l;null!=t&&(a.onmessage=t),await c("plugin:upload|upload",{id:o,url:e,filePath:n,headers:null!=r?r:{},onProgress:a})},e}({});Object.defineProperty(window.__TAURI__,"upload",{value:__TAURI_UPLOAD__})} diff --git a/plugins/upload/src/lib.rs b/plugins/upload/src/lib.rs index fb139a3e2..83f2d4793 100644 --- a/plugins/upload/src/lib.rs +++ b/plugins/upload/src/lib.rs @@ -16,8 +16,8 @@ use futures_util::TryStreamExt; use serde::{ser::Serializer, Serialize}; use tauri::{ - api::ipc::Channel, command, + ipc::Channel, plugin::{Builder as PluginBuilder, TauriPlugin}, Runtime, }; @@ -56,11 +56,11 @@ struct ProgressPayload { } #[command] -async fn download( +async fn download( url: &str, file_path: &str, headers: HashMap, - on_progress: Channel, + on_progress: Channel, ) -> Result<()> { let client = reqwest::Client::new(); @@ -89,11 +89,11 @@ async fn download( } #[command] -async fn upload( +async fn upload( url: &str, file_path: &str, headers: HashMap, - on_progress: Channel, + on_progress: Channel, ) -> Result { // Read the file let file = File::open(file_path).await?; @@ -113,13 +113,13 @@ async fn upload( response.json().await.map_err(Into::into) } -fn file_to_body(channel: Channel, file: File) -> reqwest::Body { +fn file_to_body(channel: Channel, file: File) -> reqwest::Body { let stream = FramedRead::new(file, BytesCodec::new()).map_ok(|r| r.freeze()); reqwest::Body::wrap_stream(ReadProgressStream::new( stream, Box::new(move |progress, total| { - let _ = channel.send(&ProgressPayload { progress, total }); + let _ = channel.send(ProgressPayload { progress, total }); }), )) } diff --git a/plugins/websocket/examples/svelte-app/package.json b/plugins/websocket/examples/svelte-app/package.json index 98b526697..8e13e4039 100644 --- a/plugins/websocket/examples/svelte-app/package.json +++ b/plugins/websocket/examples/svelte-app/package.json @@ -13,7 +13,7 @@ "devDependencies": { "@sveltejs/adapter-auto": "2.1.0", "@sveltejs/kit": "1.22.3", - "@tauri-apps/cli": "2.0.0-alpha.10", + "@tauri-apps/cli": "2.0.0-alpha.11", "svelte": "4.0.5", "svelte-check": "3.4.6", "tslib": "2.6.0", diff --git a/plugins/websocket/guest-js/index.ts b/plugins/websocket/guest-js/index.ts index bd6ca7522..c72fd7760 100644 --- a/plugins/websocket/guest-js/index.ts +++ b/plugins/websocket/guest-js/index.ts @@ -2,14 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -declare global { - interface Window { - __TAURI_INVOKE__: (cmd: string, args?: unknown) => Promise; - __TAURI__: { - transformCallback: (cb: (payload: T) => void) => number; - }; - } -} +import { invoke, Channel } from "@tauri-apps/api/tauri"; export interface MessageKind { type: T; @@ -39,17 +32,17 @@ export default class WebSocket { static async connect(url: string, options?: unknown): Promise { const listeners: Array<(arg: Message) => void> = []; - const handler = (message: Message): void => { + + const onMessage = new Channel(); + onMessage.onmessage = (message: Message): void => { listeners.forEach((l) => l(message)); }; - return await window - .__TAURI_INVOKE__("plugin:websocket|connect", { - url, - callbackFunction: window.__TAURI__.transformCallback(handler), - options, - }) - .then((id) => new WebSocket(id, listeners)); + return await invoke("plugin:websocket|connect", { + url, + onMessage, + options, + }).then((id) => new WebSocket(id, listeners)); } addListener(cb: (arg: Message) => void): void { @@ -69,7 +62,7 @@ export default class WebSocket { "invalid `message` type, expected a `{ type: string, data: any }` object, a string or a numeric array", ); } - return await window.__TAURI_INVOKE__("plugin:websocket|send", { + return await invoke("plugin:websocket|send", { id: this.id, message: m, }); diff --git a/plugins/websocket/package.json b/plugins/websocket/package.json index 0ae8849b1..39f434ce7 100644 --- a/plugins/websocket/package.json +++ b/plugins/websocket/package.json @@ -27,6 +27,6 @@ "tslib": "2.6.0" }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.5" + "@tauri-apps/api": "2.0.0-alpha.6" } -} +} \ No newline at end of file diff --git a/plugins/websocket/src/api-iife.js b/plugins/websocket/src/api-iife.js index cea3c830c..7774527e2 100644 --- a/plugins/websocket/src/api-iife.js +++ b/plugins/websocket/src/api-iife.js @@ -1 +1 @@ -if("__TAURI__"in window){var __TAURI_WEBSOCKET__=function(){"use strict";class e{constructor(e,t){this.id=e,this.listeners=t}static async connect(t,n){const i=[];return await window.__TAURI_INVOKE__("plugin:websocket|connect",{url:t,callbackFunction:window.__TAURI__.transformCallback((e=>{i.forEach((t=>t(e)))})),options:n}).then((t=>new e(t,i)))}addListener(e){this.listeners.push(e)}async send(e){let t;if("string"==typeof e)t={type:"Text",data:e};else if("object"==typeof e&&"type"in e)t=e;else{if(!Array.isArray(e))throw new Error("invalid `message` type, expected a `{ type: string, data: any }` object, a string or a numeric array");t={type:"Binary",data:e}}return await window.__TAURI_INVOKE__("plugin:websocket|send",{id:this.id,message:t})}async disconnect(){return await this.send({type:"Close",data:{code:1e3,reason:"Disconnected by client"}})}}return e}();Object.defineProperty(window.__TAURI__,"websocket",{value:__TAURI_WEBSOCKET__})} +if("__TAURI__"in window){var __TAURI_WEBSOCKET__=function(){"use strict";var e=Object.defineProperty,t=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},n=(e,n,r)=>(t(e,n,"read from private field"),r?r.call(e):n.get(e)),r=(e,n,r,i)=>(t(e,n,"write to private field"),i?i.call(e,r):n.set(e,r),r);function i(e,t=!1){let n=window.crypto.getRandomValues(new Uint32Array(1))[0],r=`_${n}`;return Object.defineProperty(window,r,{value:n=>(t&&Reflect.deleteProperty(window,r),e?.(n)),writable:!1,configurable:!0}),n}((t,n)=>{for(var r in n)e(t,r,{get:n[r],enumerable:!0})})({},{Channel:()=>a,PluginListener:()=>o,addPluginListener:()=>c,convertFileSrc:()=>d,invoke:()=>l,transformCallback:()=>i});var s,a=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,((e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)})(this,s,(()=>{})),this.id=i((e=>{n(this,s).call(this,e)}))}set onmessage(e){r(this,s,e)}get onmessage(){return n(this,s)}toJSON(){return`__CHANNEL__:${this.id}`}};s=new WeakMap;var o=class{constructor(e,t,n){this.plugin=e,this.event=t,this.channelId=n}async unregister(){return l(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function c(e,t,n){let r=new a;return r.onmessage=n,l(`plugin:${e}|register_listener`,{event:t,handler:r}).then((()=>new o(e,t,r.id)))}async function l(e,t={},n){return new Promise(((r,s)=>{let a=i((e=>{r(e),Reflect.deleteProperty(window,`_${o}`)}),!0),o=i((e=>{s(e),Reflect.deleteProperty(window,`_${a}`)}),!0);window.__TAURI_IPC__({cmd:e,callback:a,error:o,payload:t,options:n})}))}function d(e,t="asset"){return window.__TAURI__.convertFileSrc(e,t)}class _{constructor(e,t){this.id=e,this.listeners=t}static async connect(e,t){const n=[],r=new a;return r.onmessage=e=>{n.forEach((t=>t(e)))},await l("plugin:websocket|connect",{url:e,onMessage:r,options:t}).then((e=>new _(e,n)))}addListener(e){this.listeners.push(e)}async send(e){let t;if("string"==typeof e)t={type:"Text",data:e};else if("object"==typeof e&&"type"in e)t=e;else{if(!Array.isArray(e))throw new Error("invalid `message` type, expected a `{ type: string, data: any }` object, a string or a numeric array");t={type:"Binary",data:e}}return await l("plugin:websocket|send",{id:this.id,message:t})}async disconnect(){return await this.send({type:"Close",data:{code:1e3,reason:"Disconnected by client"}})}}return _}();Object.defineProperty(window.__TAURI__,"websocket",{value:__TAURI_WEBSOCKET__})} diff --git a/plugins/websocket/src/lib.rs b/plugins/websocket/src/lib.rs index 31d744c38..164a0a090 100644 --- a/plugins/websocket/src/lib.rs +++ b/plugins/websocket/src/lib.rs @@ -14,7 +14,7 @@ use futures_util::{stream::SplitSink, SinkExt, StreamExt}; use serde::{ser::Serializer, Deserialize, Serialize}; use tauri::{ - api::ipc::{format_callback, CallbackFn}, + ipc::Channel, plugin::{Builder as PluginBuilder, TauriPlugin}, Manager, Runtime, State, Window, }; @@ -95,7 +95,7 @@ enum WebSocketMessage { async fn connect( window: Window, url: String, - callback_function: CallbackFn, + on_message: Channel, config: Option, ) -> Result { let id = rand::random(); @@ -107,6 +107,7 @@ async fn connect( manager.0.lock().await.insert(id, write); read.for_each(move |message| { let window_ = window.clone(); + let on_message_ = on_message.clone(); async move { if let Ok(Message::Close(_)) = message { let manager = window_.state::(); @@ -136,9 +137,8 @@ async fn connect( Ok(Message::Frame(_)) => serde_json::Value::Null, // This value can't be recieved. Err(e) => serde_json::to_value(Error::from(e)).unwrap(), }; - let js = format_callback(callback_function, &response) - .expect("unable to serialize websocket message"); - let _ = window_.eval(js.as_str()); + + let _ = on_message_.send(response); } }) .await; diff --git a/plugins/window-state/package.json b/plugins/window-state/package.json index ad169f175..4942a7b8a 100644 --- a/plugins/window-state/package.json +++ b/plugins/window-state/package.json @@ -28,6 +28,6 @@ "tslib": "2.6.0" }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.5" + "@tauri-apps/api": "2.0.0-alpha.6" } -} +} \ No newline at end of file diff --git a/plugins/window-state/src/lib.rs b/plugins/window-state/src/lib.rs index 98d58a9f7..0bd79a891 100644 --- a/plugins/window-state/src/lib.rs +++ b/plugins/window-state/src/lib.rs @@ -317,8 +317,8 @@ impl Builder { let state_path = app_dir.join(STATE_FILENAME); if state_path.exists() { Arc::new(Mutex::new( - tauri::api::file::read_binary(state_path) - .map_err(Error::TauriApi) + std::fs::read(state_path) + .map_err(Error::from) .and_then(|state| bincode::deserialize(&state).map_err(Into::into)) .unwrap_or_default(), )) diff --git a/plugins/window/package.json b/plugins/window/package.json index 2efeb0e89..053524103 100644 --- a/plugins/window/package.json +++ b/plugins/window/package.json @@ -27,6 +27,6 @@ "tslib": "^2.5.0" }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.5" + "@tauri-apps/api": "2.0.0-alpha.6" } -} +} \ No newline at end of file diff --git a/plugins/window/src/api-iife.js b/plugins/window/src/api-iife.js index 80e7bf302..eaa20f408 100644 --- a/plugins/window/src/api-iife.js +++ b/plugins/window/src/api-iife.js @@ -1 +1 @@ -if("__TAURI__"in window){var __TAURI_WINDOW__=function(e){"use strict";var i=Object.defineProperty,n=(e,n)=>{for(var t in n)i(e,t,{get:n[t],enumerable:!0})},t=(e,i,n)=>{if(!i.has(e))throw TypeError("Cannot "+n)},l=(e,i,n)=>(t(e,i,"read from private field"),n?n.call(e):i.get(e)),a=(e,i,n,l)=>(t(e,i,"write to private field"),l?l.call(e,n):i.set(e,n),n);function s(e,i=!1){let n=window.crypto.getRandomValues(new Uint32Array(1))[0],t=`_${n}`;return Object.defineProperty(window,t,{value:n=>(i&&Reflect.deleteProperty(window,t),e?.(n)),writable:!1,configurable:!0}),n}n({},{Channel:()=>o,PluginListener:()=>_,addPluginListener:()=>w,convertFileSrc:()=>c,invoke:()=>u,transformCallback:()=>s});var r,o=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,((e,i,n)=>{if(i.has(e))throw TypeError("Cannot add the same private member more than once");i instanceof WeakSet?i.add(e):i.set(e,n)})(this,r,(()=>{})),this.id=s((e=>{l(this,r).call(this,e)}))}set onmessage(e){a(this,r,e)}get onmessage(){return l(this,r)}toJSON(){return`__CHANNEL__:${this.id}`}};r=new WeakMap;var _=class{constructor(e,i,n){this.plugin=e,this.event=i,this.channelId=n}async unregister(){return u(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function w(e,i,n){let t=new o;return t.onmessage=n,u(`plugin:${e}|register_listener`,{event:i,handler:t}).then((()=>new _(e,i,t.id)))}async function u(e,i={}){return new Promise(((n,t)=>{let l=s((e=>{n(e),Reflect.deleteProperty(window,`_${a}`)}),!0),a=s((e=>{t(e),Reflect.deleteProperty(window,`_${l}`)}),!0);window.__TAURI_IPC__({cmd:e,callback:l,error:a,...i})}))}function c(e,i="asset"){let n=encodeURIComponent(e);return navigator.userAgent.includes("Windows")?`https://${i}.localhost/${n}`:`${i}://localhost/${n}`}n({},{TauriEvent:()=>h,emit:()=>b,listen:()=>y,once:()=>I});var d,h=(e=>(e.WINDOW_RESIZED="tauri://resize",e.WINDOW_MOVED="tauri://move",e.WINDOW_CLOSE_REQUESTED="tauri://close-requested",e.WINDOW_CREATED="tauri://window-created",e.WINDOW_DESTROYED="tauri://destroyed",e.WINDOW_FOCUS="tauri://focus",e.WINDOW_BLUR="tauri://blur",e.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",e.WINDOW_THEME_CHANGED="tauri://theme-changed",e.WINDOW_FILE_DROP="tauri://file-drop",e.WINDOW_FILE_DROP_HOVER="tauri://file-drop-hover",e.WINDOW_FILE_DROP_CANCELLED="tauri://file-drop-cancelled",e.MENU="tauri://menu",e))(h||{});async function p(e,i){await u("plugin:event|unlisten",{event:e,eventId:i})}async function y(e,i,n){return u("plugin:event|listen",{event:e,windowLabel:n?.target,handler:s(i)}).then((i=>async()=>p(e,i)))}async function I(e,i,n){return y(e,(n=>{i(n),p(e,n.id).catch((()=>{}))}),n)}async function b(e,i,n){await u("plugin:event|emit",{event:e,windowLabel:n?.target,payload:i})}class g{constructor(e,i){this.type="Logical",this.width=e,this.height=i}}class E{constructor(e,i){this.type="Physical",this.width=e,this.height=i}toLogical(e){return new g(this.width/e,this.height/e)}}class O{constructor(e,i){this.type="Logical",this.x=e,this.y=i}}class A{constructor(e,i){this.type="Physical",this.x=e,this.y=i}toLogical(e){return new O(this.x/e,this.y/e)}}e.UserAttentionType=void 0,(d=e.UserAttentionType||(e.UserAttentionType={}))[d.Critical=1]="Critical",d[d.Informational=2]="Informational";class m{constructor(e){this._preventDefault=!1,this.event=e.event,this.windowLabel=e.windowLabel,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}}function R(){return new T(window.__TAURI_METADATA__.__currentWindow.label,{skip:!0})}function N(){return window.__TAURI_METADATA__.__windows.map((e=>new T(e.label,{skip:!0})))}const v=["tauri://created","tauri://error"];class T{constructor(e,i={}){this.label=e,this.listeners=Object.create(null),(null==i?void 0:i.skip)||window.__TAURI_INVOKE__("plugin:window|create",{options:{...i,label:e}}).then((async()=>this.emit("tauri://created"))).catch((async e=>this.emit("tauri://error",e)))}static getByLabel(e){return N().some((i=>i.label===e))?new T(e,{skip:!0}):null}static getCurrent(){return R()}static getAll(){return N()}static async getFocusedWindow(){for(const e of N())if(await e.isFocused())return e;return null}async listen(e,i){return this._handleTauriEvent(e,i)?Promise.resolve((()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)})):y(e,i,{target:this.label})}async once(e,i){return this._handleTauriEvent(e,i)?Promise.resolve((()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)})):I(e,i,{target:this.label})}async emit(e,i){if(v.includes(e)){for(const n of this.listeners[e]||[])n({event:e,id:-1,windowLabel:this.label,payload:i});return Promise.resolve()}return b(e,i,{target:this.label})}_handleTauriEvent(e,i){return!!v.includes(e)&&(e in this.listeners?this.listeners[e].push(i):this.listeners[e]=[i],!0)}async scaleFactor(){return window.__TAURI_INVOKE__("plugin:window|scale_factor",{label:this.label})}async innerPosition(){return window.__TAURI_INVOKE__("plugin:window|inner_position",{label:this.label}).then((({x:e,y:i})=>new A(e,i)))}async outerPosition(){return window.__TAURI_INVOKE__("plugin:window|outer_position",{label:this.label}).then((({x:e,y:i})=>new A(e,i)))}async innerSize(){return window.__TAURI_INVOKE__("plugin:window|inner_size",{label:this.label}).then((({width:e,height:i})=>new E(e,i)))}async outerSize(){return window.__TAURI_INVOKE__("plugin:window|outer_size",{label:this.label}).then((({width:e,height:i})=>new E(e,i)))}async isFullscreen(){return window.__TAURI_INVOKE__("plugin:window|is_fullscreen",{label:this.label})}async isMinimized(){return window.__TAURI_INVOKE__("plugin:window|is_minimized",{label:this.label})}async isMaximized(){return window.__TAURI_INVOKE__("plugin:window|is_maximized",{label:this.label})}async isFocused(){return window.__TAURI_INVOKE__("plugin:window|is_focused",{label:this.label})}async isDecorated(){return window.__TAURI_INVOKE__("plugin:window|is_decorated",{label:this.label})}async isResizable(){return window.__TAURI_INVOKE__("plugin:window|is_resizable",{label:this.label})}async isMaximizable(){return window.__TAURI_INVOKE__("plugin:window|is_maximizable",{label:this.label})}async isMinimizable(){return window.__TAURI_INVOKE__("plugin:window|is_minimizable",{label:this.label})}async isClosable(){return window.__TAURI_INVOKE__("plugin:window|is_closable",{label:this.label})}async isVisible(){return window.__TAURI_INVOKE__("plugin:window|is_visible",{label:this.label})}async title(){return window.__TAURI_INVOKE__("plugin:window|title",{label:this.label})}async theme(){return window.__TAURI_INVOKE__("plugin:window|theme",{label:this.label})}async center(){return window.__TAURI_INVOKE__("plugin:window|center",{label:this.label})}async requestUserAttention(i){let n=null;return i&&(n=i===e.UserAttentionType.Critical?{type:"Critical"}:{type:"Informational"}),window.__TAURI_INVOKE__("plugin:window|request_user_attention",{label:this.label,value:n})}async setResizable(e){return window.__TAURI_INVOKE__("plugin:window|set_resizable",{label:this.label,value:e})}async setMaximizable(e){return window.__TAURI_INVOKE__("plugin:window|set_maximizable",{label:this.label,value:e})}async setMinimizable(e){return window.__TAURI_INVOKE__("plugin:window|set_minimizable",{label:this.label,value:e})}async setClosable(e){return window.__TAURI_INVOKE__("plugin:window|set_closable",{label:this.label,value:e})}async setTitle(e){return window.__TAURI_INVOKE__("plugin:window|set_title",{label:this.label,value:e})}async maximize(){return window.__TAURI_INVOKE__("plugin:window|maximize",{label:this.label})}async unmaximize(){return window.__TAURI_INVOKE__("plugin:window|unmaximize",{label:this.label})}async toggleMaximize(){return window.__TAURI_INVOKE__("plugin:window|toggle_maximize",{label:this.label})}async minimize(){return window.__TAURI_INVOKE__("plugin:window|minimize",{label:this.label})}async unminimize(){return window.__TAURI_INVOKE__("plugin:window|unminimize",{label:this.label})}async show(){return window.__TAURI_INVOKE__("plugin:window|show",{label:this.label})}async hide(){return window.__TAURI_INVOKE__("plugin:window|hide",{label:this.label})}async close(){return window.__TAURI_INVOKE__("plugin:window|close",{label:this.label})}async setDecorations(e){return window.__TAURI_INVOKE__("plugin:window|set_decorations",{label:this.label,value:e})}async setShadow(e){return window.__TAURI_INVOKE__("plugin:window|set_shadow",{label:this.label,value:e})}async setEffects(e){return window.__TAURI_INVOKE__("plugin:window|set_effects",{label:this.label,value:e})}async clearEffects(){return window.__TAURI_INVOKE__("plugin:window|set_effects",{label:this.label,value:null})}async setAlwaysOnTop(e){return window.__TAURI_INVOKE__("plugin:window|set_always_on_top",{label:this.label,value:e})}async setContentProtected(e){return window.__TAURI_INVOKE__("plugin:window|set_content_protected",{label:this.label,value:e})}async setSize(e){if(!e||"Logical"!==e.type&&"Physical"!==e.type)throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");return window.__TAURI_INVOKE__("plugin:window|set_size",{label:this.label,value:{type:e.type,data:{width:e.width,height:e.height}}})}async setMinSize(e){if(e&&"Logical"!==e.type&&"Physical"!==e.type)throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");return window.__TAURI_INVOKE__("plugin:window|set_min_size",{label:this.label,value:e?{type:e.type,data:{width:e.width,height:e.height}}:null})}async setMaxSize(e){if(e&&"Logical"!==e.type&&"Physical"!==e.type)throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");return window.__TAURI_INVOKE__("plugin:window|set_max_size",{label:this.label,value:e?{type:e.type,data:{width:e.width,height:e.height}}:null})}async setPosition(e){if(!e||"Logical"!==e.type&&"Physical"!==e.type)throw new Error("the `position` argument must be either a LogicalPosition or a PhysicalPosition instance");return window.__TAURI_INVOKE__("plugin:window|set_position",{label:this.label,value:{type:e.type,data:{x:e.x,y:e.y}}})}async setFullscreen(e){return window.__TAURI_INVOKE__("plugin:window|set_fullscreen",{label:this.label,value:e})}async setFocus(){return window.__TAURI_INVOKE__("plugin:window|set_focus",{label:this.label})}async setIcon(e){return window.__TAURI_INVOKE__("plugin:window|set_icon",{label:this.label,value:"string"==typeof e?e:Array.from(e)})}async setSkipTaskbar(e){return window.__TAURI_INVOKE__("plugin:window|set_skip_taskbar",{label:this.label,value:e})}async setCursorGrab(e){return window.__TAURI_INVOKE__("plugin:window|set_cursor_grab",{label:this.label,value:e})}async setCursorVisible(e){return window.__TAURI_INVOKE__("plugin:window|set_cursor_visible",{label:this.label,value:e})}async setCursorIcon(e){return window.__TAURI_INVOKE__("plugin:window|set_cursor_icon",{label:this.label,value:e})}async setCursorPosition(e){if(!e||"Logical"!==e.type&&"Physical"!==e.type)throw new Error("the `position` argument must be either a LogicalPosition or a PhysicalPosition instance");return window.__TAURI_INVOKE__("plugin:window|set_cursor_position",{label:this.label,value:{type:e.type,data:{x:e.x,y:e.y}}})}async setIgnoreCursorEvents(e){return window.__TAURI_INVOKE__("plugin:window|set_ignore_cursor_events",{label:this.label,value:e})}async startDragging(){return window.__TAURI_INVOKE__("plugin:window|start_dragging",{label:this.label})}async onResized(e){return this.listen(h.WINDOW_RESIZED,(i=>{i.payload=D(i.payload),e(i)}))}async onMoved(e){return this.listen(h.WINDOW_MOVED,(i=>{i.payload=W(i.payload),e(i)}))}async onCloseRequested(e){return this.listen(h.WINDOW_CLOSE_REQUESTED,(i=>{const n=new m(i);Promise.resolve(e(n)).then((()=>{if(!n.isPreventDefault())return this.close()}))}))}async onFocusChanged(e){const i=await this.listen(h.WINDOW_FOCUS,(i=>{e({...i,payload:!0})})),n=await this.listen(h.WINDOW_BLUR,(i=>{e({...i,payload:!1})}));return()=>{i(),n()}}async onScaleChanged(e){return this.listen(h.WINDOW_SCALE_FACTOR_CHANGED,e)}async onMenuClicked(e){return this.listen(h.MENU,e)}async onFileDropEvent(e){const i=await this.listen(h.WINDOW_FILE_DROP,(i=>{e({...i,payload:{type:"drop",paths:i.payload}})})),n=await this.listen(h.WINDOW_FILE_DROP_HOVER,(i=>{e({...i,payload:{type:"hover",paths:i.payload}})})),t=await this.listen(h.WINDOW_FILE_DROP_CANCELLED,(i=>{e({...i,payload:{type:"cancel"}})}));return()=>{i(),n(),t()}}async onThemeChanged(e){return this.listen(h.WINDOW_THEME_CHANGED,e)}}var f,U;function V(e){return null===e?null:{name:e.name,scaleFactor:e.scaleFactor,position:W(e.position),size:D(e.size)}}function W(e){return new A(e.x,e.y)}function D(e){return new E(e.width,e.height)}return e.Effect=void 0,(f=e.Effect||(e.Effect={})).AppearanceBased="appearanceBased",f.Light="light",f.Dark="dark",f.MediumLight="mediumLight",f.UltraDark="ultraDark",f.Titlebar="titlebar",f.Selection="selection",f.Menu="menu",f.Popover="popover",f.Sidebar="sidebar",f.HeaderView="headerView",f.Sheet="sheet",f.WindowBackground="windowBackground",f.HudWindow="hudWindow",f.FullScreenUI="fullScreenUI",f.Tooltip="tooltip",f.ContentBackground="contentBackground",f.UnderWindowBackground="underWindowBackground",f.UnderPageBackground="underPageBackground",f.Mica="mica",f.Blur="blur",f.Acrylic="acrylic",e.EffectState=void 0,(U=e.EffectState||(e.EffectState={})).FollowsWindowActiveState="followsWindowActiveState",U.Active="active",U.Inactive="inactive",e.CloseRequestedEvent=m,e.LogicalPosition=O,e.LogicalSize=g,e.PhysicalPosition=A,e.PhysicalSize=E,e.Window=T,e.availableMonitors=async function(){return window.__TAURI_INVOKE__("plugin:window|available_monitors").then((e=>e.map(V)))},e.currentMonitor=async function(){return window.__TAURI_INVOKE__("plugin:window|current_monitor").then(V)},e.getAll=N,e.getCurrent=R,e.primaryMonitor=async function(){return window.__TAURI_INVOKE__("plugin:window|primary_monitor").then(V)},e}({});Object.defineProperty(window.__TAURI__,"window",{value:__TAURI_WINDOW__})} +if("__TAURI__"in window){var __TAURI_WINDOW__=function(e){"use strict";var i=Object.defineProperty,n=(e,n)=>{for(var t in n)i(e,t,{get:n[t],enumerable:!0})},t=(e,i,n)=>{if(!i.has(e))throw TypeError("Cannot "+n)},l=(e,i,n)=>(t(e,i,"read from private field"),n?n.call(e):i.get(e)),a=(e,i,n,l)=>(t(e,i,"write to private field"),l?l.call(e,n):i.set(e,n),n);function s(e,i=!1){let n=window.crypto.getRandomValues(new Uint32Array(1))[0],t=`_${n}`;return Object.defineProperty(window,t,{value:n=>(i&&Reflect.deleteProperty(window,t),e?.(n)),writable:!1,configurable:!0}),n}n({},{Channel:()=>o,PluginListener:()=>_,addPluginListener:()=>w,convertFileSrc:()=>c,invoke:()=>u,transformCallback:()=>s});var r,o=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,((e,i,n)=>{if(i.has(e))throw TypeError("Cannot add the same private member more than once");i instanceof WeakSet?i.add(e):i.set(e,n)})(this,r,(()=>{})),this.id=s((e=>{l(this,r).call(this,e)}))}set onmessage(e){a(this,r,e)}get onmessage(){return l(this,r)}toJSON(){return`__CHANNEL__:${this.id}`}};r=new WeakMap;var _=class{constructor(e,i,n){this.plugin=e,this.event=i,this.channelId=n}async unregister(){return u(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function w(e,i,n){let t=new o;return t.onmessage=n,u(`plugin:${e}|register_listener`,{event:i,handler:t}).then((()=>new _(e,i,t.id)))}async function u(e,i={},n){return new Promise(((t,l)=>{let a=s((e=>{t(e),Reflect.deleteProperty(window,`_${r}`)}),!0),r=s((e=>{l(e),Reflect.deleteProperty(window,`_${a}`)}),!0);window.__TAURI_IPC__({cmd:e,callback:a,error:r,payload:i,options:n})}))}function c(e,i="asset"){return window.__TAURI__.convertFileSrc(e,i)}n({},{TauriEvent:()=>h,emit:()=>b,listen:()=>y,once:()=>I});var d,h=(e=>(e.WINDOW_RESIZED="tauri://resize",e.WINDOW_MOVED="tauri://move",e.WINDOW_CLOSE_REQUESTED="tauri://close-requested",e.WINDOW_CREATED="tauri://window-created",e.WINDOW_DESTROYED="tauri://destroyed",e.WINDOW_FOCUS="tauri://focus",e.WINDOW_BLUR="tauri://blur",e.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",e.WINDOW_THEME_CHANGED="tauri://theme-changed",e.WINDOW_FILE_DROP="tauri://file-drop",e.WINDOW_FILE_DROP_HOVER="tauri://file-drop-hover",e.WINDOW_FILE_DROP_CANCELLED="tauri://file-drop-cancelled",e.MENU="tauri://menu",e))(h||{});async function p(e,i){await u("plugin:event|unlisten",{event:e,eventId:i})}async function y(e,i,n){return u("plugin:event|listen",{event:e,windowLabel:n?.target,handler:s(i)}).then((i=>async()=>p(e,i)))}async function I(e,i,n){return y(e,(n=>{i(n),p(e,n.id).catch((()=>{}))}),n)}async function b(e,i,n){await u("plugin:event|emit",{event:e,windowLabel:n?.target,payload:i})}class g{constructor(e,i){this.type="Logical",this.width=e,this.height=i}}class E{constructor(e,i){this.type="Physical",this.width=e,this.height=i}toLogical(e){return new g(this.width/e,this.height/e)}}class O{constructor(e,i){this.type="Logical",this.x=e,this.y=i}}class A{constructor(e,i){this.type="Physical",this.x=e,this.y=i}toLogical(e){return new O(this.x/e,this.y/e)}}e.UserAttentionType=void 0,(d=e.UserAttentionType||(e.UserAttentionType={}))[d.Critical=1]="Critical",d[d.Informational=2]="Informational";class m{constructor(e){this._preventDefault=!1,this.event=e.event,this.windowLabel=e.windowLabel,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}}function R(){return new v(window.__TAURI_METADATA__.__currentWindow.label,{skip:!0})}function N(){return window.__TAURI_METADATA__.__windows.map((e=>new v(e.label,{skip:!0})))}const T=["tauri://created","tauri://error"];class v{constructor(e,i={}){this.label=e,this.listeners=Object.create(null),(null==i?void 0:i.skip)||window.__TAURI_INVOKE__("plugin:window|create",{options:{...i,label:e}}).then((async()=>this.emit("tauri://created"))).catch((async e=>this.emit("tauri://error",e)))}static getByLabel(e){return N().some((i=>i.label===e))?new v(e,{skip:!0}):null}static getCurrent(){return R()}static getAll(){return N()}static async getFocusedWindow(){for(const e of N())if(await e.isFocused())return e;return null}async listen(e,i){return this._handleTauriEvent(e,i)?Promise.resolve((()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)})):y(e,i,{target:this.label})}async once(e,i){return this._handleTauriEvent(e,i)?Promise.resolve((()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)})):I(e,i,{target:this.label})}async emit(e,i){if(T.includes(e)){for(const n of this.listeners[e]||[])n({event:e,id:-1,windowLabel:this.label,payload:i});return Promise.resolve()}return b(e,i,{target:this.label})}_handleTauriEvent(e,i){return!!T.includes(e)&&(e in this.listeners?this.listeners[e].push(i):this.listeners[e]=[i],!0)}async scaleFactor(){return window.__TAURI_INVOKE__("plugin:window|scale_factor",{label:this.label})}async innerPosition(){return window.__TAURI_INVOKE__("plugin:window|inner_position",{label:this.label}).then((({x:e,y:i})=>new A(e,i)))}async outerPosition(){return window.__TAURI_INVOKE__("plugin:window|outer_position",{label:this.label}).then((({x:e,y:i})=>new A(e,i)))}async innerSize(){return window.__TAURI_INVOKE__("plugin:window|inner_size",{label:this.label}).then((({width:e,height:i})=>new E(e,i)))}async outerSize(){return window.__TAURI_INVOKE__("plugin:window|outer_size",{label:this.label}).then((({width:e,height:i})=>new E(e,i)))}async isFullscreen(){return window.__TAURI_INVOKE__("plugin:window|is_fullscreen",{label:this.label})}async isMinimized(){return window.__TAURI_INVOKE__("plugin:window|is_minimized",{label:this.label})}async isMaximized(){return window.__TAURI_INVOKE__("plugin:window|is_maximized",{label:this.label})}async isFocused(){return window.__TAURI_INVOKE__("plugin:window|is_focused",{label:this.label})}async isDecorated(){return window.__TAURI_INVOKE__("plugin:window|is_decorated",{label:this.label})}async isResizable(){return window.__TAURI_INVOKE__("plugin:window|is_resizable",{label:this.label})}async isMaximizable(){return window.__TAURI_INVOKE__("plugin:window|is_maximizable",{label:this.label})}async isMinimizable(){return window.__TAURI_INVOKE__("plugin:window|is_minimizable",{label:this.label})}async isClosable(){return window.__TAURI_INVOKE__("plugin:window|is_closable",{label:this.label})}async isVisible(){return window.__TAURI_INVOKE__("plugin:window|is_visible",{label:this.label})}async title(){return window.__TAURI_INVOKE__("plugin:window|title",{label:this.label})}async theme(){return window.__TAURI_INVOKE__("plugin:window|theme",{label:this.label})}async center(){return window.__TAURI_INVOKE__("plugin:window|center",{label:this.label})}async requestUserAttention(i){let n=null;return i&&(n=i===e.UserAttentionType.Critical?{type:"Critical"}:{type:"Informational"}),window.__TAURI_INVOKE__("plugin:window|request_user_attention",{label:this.label,value:n})}async setResizable(e){return window.__TAURI_INVOKE__("plugin:window|set_resizable",{label:this.label,value:e})}async setMaximizable(e){return window.__TAURI_INVOKE__("plugin:window|set_maximizable",{label:this.label,value:e})}async setMinimizable(e){return window.__TAURI_INVOKE__("plugin:window|set_minimizable",{label:this.label,value:e})}async setClosable(e){return window.__TAURI_INVOKE__("plugin:window|set_closable",{label:this.label,value:e})}async setTitle(e){return window.__TAURI_INVOKE__("plugin:window|set_title",{label:this.label,value:e})}async maximize(){return window.__TAURI_INVOKE__("plugin:window|maximize",{label:this.label})}async unmaximize(){return window.__TAURI_INVOKE__("plugin:window|unmaximize",{label:this.label})}async toggleMaximize(){return window.__TAURI_INVOKE__("plugin:window|toggle_maximize",{label:this.label})}async minimize(){return window.__TAURI_INVOKE__("plugin:window|minimize",{label:this.label})}async unminimize(){return window.__TAURI_INVOKE__("plugin:window|unminimize",{label:this.label})}async show(){return window.__TAURI_INVOKE__("plugin:window|show",{label:this.label})}async hide(){return window.__TAURI_INVOKE__("plugin:window|hide",{label:this.label})}async close(){return window.__TAURI_INVOKE__("plugin:window|close",{label:this.label})}async setDecorations(e){return window.__TAURI_INVOKE__("plugin:window|set_decorations",{label:this.label,value:e})}async setShadow(e){return window.__TAURI_INVOKE__("plugin:window|set_shadow",{label:this.label,value:e})}async setEffects(e){return window.__TAURI_INVOKE__("plugin:window|set_effects",{label:this.label,value:e})}async clearEffects(){return window.__TAURI_INVOKE__("plugin:window|set_effects",{label:this.label,value:null})}async setAlwaysOnTop(e){return window.__TAURI_INVOKE__("plugin:window|set_always_on_top",{label:this.label,value:e})}async setContentProtected(e){return window.__TAURI_INVOKE__("plugin:window|set_content_protected",{label:this.label,value:e})}async setSize(e){if(!e||"Logical"!==e.type&&"Physical"!==e.type)throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");return window.__TAURI_INVOKE__("plugin:window|set_size",{label:this.label,value:{type:e.type,data:{width:e.width,height:e.height}}})}async setMinSize(e){if(e&&"Logical"!==e.type&&"Physical"!==e.type)throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");return window.__TAURI_INVOKE__("plugin:window|set_min_size",{label:this.label,value:e?{type:e.type,data:{width:e.width,height:e.height}}:null})}async setMaxSize(e){if(e&&"Logical"!==e.type&&"Physical"!==e.type)throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");return window.__TAURI_INVOKE__("plugin:window|set_max_size",{label:this.label,value:e?{type:e.type,data:{width:e.width,height:e.height}}:null})}async setPosition(e){if(!e||"Logical"!==e.type&&"Physical"!==e.type)throw new Error("the `position` argument must be either a LogicalPosition or a PhysicalPosition instance");return window.__TAURI_INVOKE__("plugin:window|set_position",{label:this.label,value:{type:e.type,data:{x:e.x,y:e.y}}})}async setFullscreen(e){return window.__TAURI_INVOKE__("plugin:window|set_fullscreen",{label:this.label,value:e})}async setFocus(){return window.__TAURI_INVOKE__("plugin:window|set_focus",{label:this.label})}async setIcon(e){return window.__TAURI_INVOKE__("plugin:window|set_icon",{label:this.label,value:"string"==typeof e?e:Array.from(e)})}async setSkipTaskbar(e){return window.__TAURI_INVOKE__("plugin:window|set_skip_taskbar",{label:this.label,value:e})}async setCursorGrab(e){return window.__TAURI_INVOKE__("plugin:window|set_cursor_grab",{label:this.label,value:e})}async setCursorVisible(e){return window.__TAURI_INVOKE__("plugin:window|set_cursor_visible",{label:this.label,value:e})}async setCursorIcon(e){return window.__TAURI_INVOKE__("plugin:window|set_cursor_icon",{label:this.label,value:e})}async setCursorPosition(e){if(!e||"Logical"!==e.type&&"Physical"!==e.type)throw new Error("the `position` argument must be either a LogicalPosition or a PhysicalPosition instance");return window.__TAURI_INVOKE__("plugin:window|set_cursor_position",{label:this.label,value:{type:e.type,data:{x:e.x,y:e.y}}})}async setIgnoreCursorEvents(e){return window.__TAURI_INVOKE__("plugin:window|set_ignore_cursor_events",{label:this.label,value:e})}async startDragging(){return window.__TAURI_INVOKE__("plugin:window|start_dragging",{label:this.label})}async onResized(e){return this.listen(h.WINDOW_RESIZED,(i=>{i.payload=W(i.payload),e(i)}))}async onMoved(e){return this.listen(h.WINDOW_MOVED,(i=>{i.payload=D(i.payload),e(i)}))}async onCloseRequested(e){return this.listen(h.WINDOW_CLOSE_REQUESTED,(i=>{const n=new m(i);Promise.resolve(e(n)).then((()=>{if(!n.isPreventDefault())return this.close()}))}))}async onFocusChanged(e){const i=await this.listen(h.WINDOW_FOCUS,(i=>{e({...i,payload:!0})})),n=await this.listen(h.WINDOW_BLUR,(i=>{e({...i,payload:!1})}));return()=>{i(),n()}}async onScaleChanged(e){return this.listen(h.WINDOW_SCALE_FACTOR_CHANGED,e)}async onMenuClicked(e){return this.listen(h.MENU,e)}async onFileDropEvent(e){const i=await this.listen(h.WINDOW_FILE_DROP,(i=>{e({...i,payload:{type:"drop",paths:i.payload}})})),n=await this.listen(h.WINDOW_FILE_DROP_HOVER,(i=>{e({...i,payload:{type:"hover",paths:i.payload}})})),t=await this.listen(h.WINDOW_FILE_DROP_CANCELLED,(i=>{e({...i,payload:{type:"cancel"}})}));return()=>{i(),n(),t()}}async onThemeChanged(e){return this.listen(h.WINDOW_THEME_CHANGED,e)}}var f,U;function V(e){return null===e?null:{name:e.name,scaleFactor:e.scaleFactor,position:D(e.position),size:W(e.size)}}function D(e){return new A(e.x,e.y)}function W(e){return new E(e.width,e.height)}return e.Effect=void 0,(f=e.Effect||(e.Effect={})).AppearanceBased="appearanceBased",f.Light="light",f.Dark="dark",f.MediumLight="mediumLight",f.UltraDark="ultraDark",f.Titlebar="titlebar",f.Selection="selection",f.Menu="menu",f.Popover="popover",f.Sidebar="sidebar",f.HeaderView="headerView",f.Sheet="sheet",f.WindowBackground="windowBackground",f.HudWindow="hudWindow",f.FullScreenUI="fullScreenUI",f.Tooltip="tooltip",f.ContentBackground="contentBackground",f.UnderWindowBackground="underWindowBackground",f.UnderPageBackground="underPageBackground",f.Mica="mica",f.Blur="blur",f.Acrylic="acrylic",e.EffectState=void 0,(U=e.EffectState||(e.EffectState={})).FollowsWindowActiveState="followsWindowActiveState",U.Active="active",U.Inactive="inactive",e.CloseRequestedEvent=m,e.LogicalPosition=O,e.LogicalSize=g,e.PhysicalPosition=A,e.PhysicalSize=E,e.Window=v,e.availableMonitors=async function(){return window.__TAURI_INVOKE__("plugin:window|available_monitors").then((e=>e.map(V)))},e.currentMonitor=async function(){return window.__TAURI_INVOKE__("plugin:window|current_monitor").then(V)},e.getAll=N,e.getCurrent=R,e.primaryMonitor=async function(){return window.__TAURI_INVOKE__("plugin:window|primary_monitor").then(V)},e}({});Object.defineProperty(window.__TAURI__,"window",{value:__TAURI_WINDOW__})} diff --git a/plugins/window/src/lib.rs b/plugins/window/src/lib.rs index be545b88c..90dbd710b 100644 --- a/plugins/window/src/lib.rs +++ b/plugins/window/src/lib.rs @@ -37,7 +37,7 @@ pub fn init() -> TauriPlugin { .invoke_handler(|invoke| { #[cfg(desktop)] { - let handler: Box) -> bool> = + let handler: Box) -> bool> = Box::new(tauri::generate_handler![ desktop_commands::create, // getters diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 062ad1add..d99858dd1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -64,8 +64,8 @@ importers: examples/api: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.5 - version: 2.0.0-alpha.5 + specifier: 2.0.0-alpha.6 + version: 2.0.0-alpha.6 '@tauri-apps/plugin-app': specifier: 2.0.0-alpha.0 version: link:../../plugins/app @@ -119,8 +119,8 @@ importers: specifier: ^2.4.1 version: 2.4.1(svelte@3.59.1)(vite@4.4.4) '@tauri-apps/cli': - specifier: 2.0.0-alpha.10 - version: 2.0.0-alpha.10 + specifier: 2.0.0-alpha.11 + version: 2.0.0-alpha.11 '@unocss/extractor-svelte': specifier: ^0.53.1 version: 0.53.1 @@ -140,8 +140,8 @@ importers: plugins/app: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.5 - version: 2.0.0-alpha.5 + specifier: 2.0.0-alpha.6 + version: 2.0.0-alpha.6 devDependencies: tslib: specifier: ^2.5.0 @@ -150,8 +150,8 @@ importers: plugins/authenticator: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.5 - version: 2.0.0-alpha.5 + specifier: 2.0.0-alpha.6 + version: 2.0.0-alpha.6 devDependencies: tslib: specifier: 2.6.0 @@ -160,8 +160,8 @@ importers: plugins/autostart: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.5 - version: 2.0.0-alpha.5 + specifier: 2.0.0-alpha.6 + version: 2.0.0-alpha.6 devDependencies: tslib: specifier: 2.6.0 @@ -170,8 +170,8 @@ importers: plugins/cli: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.5 - version: 2.0.0-alpha.5 + specifier: 2.0.0-alpha.6 + version: 2.0.0-alpha.6 devDependencies: tslib: specifier: ^2.4.1 @@ -180,8 +180,8 @@ importers: plugins/clipboard-manager: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.5 - version: 2.0.0-alpha.5 + specifier: 2.0.0-alpha.6 + version: 2.0.0-alpha.6 devDependencies: tslib: specifier: ^2.4.1 @@ -190,8 +190,8 @@ importers: plugins/dialog: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.5 - version: 2.0.0-alpha.5 + specifier: 2.0.0-alpha.6 + version: 2.0.0-alpha.6 devDependencies: tslib: specifier: ^2.4.1 @@ -200,8 +200,8 @@ importers: plugins/fs: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.5 - version: 2.0.0-alpha.5 + specifier: 2.0.0-alpha.6 + version: 2.0.0-alpha.6 devDependencies: tslib: specifier: ^2.4.1 @@ -210,8 +210,8 @@ importers: plugins/global-shortcut: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.5 - version: 2.0.0-alpha.5 + specifier: 2.0.0-alpha.6 + version: 2.0.0-alpha.6 devDependencies: tslib: specifier: ^2.4.1 @@ -220,8 +220,8 @@ importers: plugins/http: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.5 - version: 2.0.0-alpha.5 + specifier: 2.0.0-alpha.6 + version: 2.0.0-alpha.6 devDependencies: tslib: specifier: ^2.5.0 @@ -230,8 +230,8 @@ importers: plugins/log: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.5 - version: 2.0.0-alpha.5 + specifier: 2.0.0-alpha.6 + version: 2.0.0-alpha.6 devDependencies: tslib: specifier: 2.6.0 @@ -240,8 +240,8 @@ importers: plugins/notification: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.5 - version: 2.0.0-alpha.5 + specifier: 2.0.0-alpha.6 + version: 2.0.0-alpha.6 devDependencies: tslib: specifier: ^2.4.1 @@ -250,8 +250,8 @@ importers: plugins/os: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.5 - version: 2.0.0-alpha.5 + specifier: 2.0.0-alpha.6 + version: 2.0.0-alpha.6 devDependencies: tslib: specifier: 2.6.0 @@ -260,8 +260,8 @@ importers: plugins/positioner: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.5 - version: 2.0.0-alpha.5 + specifier: 2.0.0-alpha.6 + version: 2.0.0-alpha.6 devDependencies: tslib: specifier: 2.6.0 @@ -270,8 +270,8 @@ importers: plugins/process: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.5 - version: 2.0.0-alpha.5 + specifier: 2.0.0-alpha.6 + version: 2.0.0-alpha.6 devDependencies: tslib: specifier: 2.6.0 @@ -280,8 +280,8 @@ importers: plugins/shell: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.5 - version: 2.0.0-alpha.5 + specifier: 2.0.0-alpha.6 + version: 2.0.0-alpha.6 devDependencies: tslib: specifier: ^2.4.1 @@ -290,14 +290,14 @@ importers: plugins/single-instance/examples/vanilla: devDependencies: '@tauri-apps/cli': - specifier: 2.0.0-alpha.10 - version: 2.0.0-alpha.10 + specifier: 2.0.0-alpha.11 + version: 2.0.0-alpha.11 plugins/sql: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.5 - version: 2.0.0-alpha.5 + specifier: 2.0.0-alpha.6 + version: 2.0.0-alpha.6 devDependencies: tslib: specifier: 2.6.0 @@ -306,8 +306,8 @@ importers: plugins/store: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.5 - version: 2.0.0-alpha.5 + specifier: 2.0.0-alpha.6 + version: 2.0.0-alpha.6 devDependencies: tslib: specifier: 2.6.0 @@ -316,8 +316,8 @@ importers: plugins/stronghold: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.5 - version: 2.0.0-alpha.5 + specifier: 2.0.0-alpha.6 + version: 2.0.0-alpha.6 devDependencies: tslib: specifier: 2.6.0 @@ -326,8 +326,8 @@ importers: plugins/updater: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.5 - version: 2.0.0-alpha.5 + specifier: 2.0.0-alpha.6 + version: 2.0.0-alpha.6 devDependencies: tslib: specifier: ^2.5.0 @@ -336,8 +336,8 @@ importers: plugins/upload: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.5 - version: 2.0.0-alpha.5 + specifier: 2.0.0-alpha.6 + version: 2.0.0-alpha.6 devDependencies: tslib: specifier: 2.6.0 @@ -346,8 +346,8 @@ importers: plugins/websocket: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.5 - version: 2.0.0-alpha.5 + specifier: 2.0.0-alpha.6 + version: 2.0.0-alpha.6 devDependencies: tslib: specifier: 2.6.0 @@ -366,8 +366,8 @@ importers: specifier: 1.22.3 version: 1.22.3(svelte@4.0.5)(vite@4.4.4) '@tauri-apps/cli': - specifier: 2.0.0-alpha.10 - version: 2.0.0-alpha.10 + specifier: 2.0.0-alpha.11 + version: 2.0.0-alpha.11 svelte: specifier: 4.0.5 version: 4.0.5 @@ -387,8 +387,8 @@ importers: plugins/window: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.5 - version: 2.0.0-alpha.5 + specifier: 2.0.0-alpha.6 + version: 2.0.0-alpha.6 devDependencies: tslib: specifier: ^2.5.0 @@ -397,8 +397,8 @@ importers: plugins/window-state: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.5 - version: 2.0.0-alpha.5 + specifier: 2.0.0-alpha.6 + version: 2.0.0-alpha.6 devDependencies: tslib: specifier: 2.6.0 @@ -1106,13 +1106,13 @@ packages: - supports-color dev: true - /@tauri-apps/api@2.0.0-alpha.5: - resolution: {integrity: sha512-OqysC4c819itGxic50RoDMrmd+ofX+MMNkXKeRS0BV2rkKqrnuV17o3TrQXFI1xs/kXRmmPC+3Y42P9Y5uNvRg==} + /@tauri-apps/api@2.0.0-alpha.6: + resolution: {integrity: sha512-ZMOc3eu9amwvkC6M69h3hWt4/EsFaAXmtkiw4xd2LN59/lTb4ZQiVfq2QKlRcu1rj3n/Tcr7U30ZopvHwXBGIg==} engines: {node: '>= 14.6.0', npm: '>= 6.6.0', yarn: '>= 1.19.1'} dev: false - /@tauri-apps/cli-darwin-arm64@2.0.0-alpha.10: - resolution: {integrity: sha512-z6DoKRUm1Yygu2Tpatu7Fej0eZejZQcsDKsHWc3b5yoIsrodxvKbko2SvYczUx4ecXWplJBTIfTZNo6ciIRRmw==} + /@tauri-apps/cli-darwin-arm64@2.0.0-alpha.11: + resolution: {integrity: sha512-SXm5vCO/Rt5JoY9se35jA4zz8iqgA0bgbcM/qVOrTnd1DUFWUP9Tss0g+UExhqEcvUxo/QPfuwk8qVYDH3A7gg==} engines: {node: '>= 10'} cpu: [arm64] os: [darwin] @@ -1120,8 +1120,8 @@ packages: dev: true optional: true - /@tauri-apps/cli-darwin-x64@2.0.0-alpha.10: - resolution: {integrity: sha512-xqPUC5uI6zo5+1IXSwZLj1uyRWCeZgQgpyaExGDOYBjcC8HUc2NRdFGsGVtGhFWE+HftppD9p8elJLQM90B02w==} + /@tauri-apps/cli-darwin-x64@2.0.0-alpha.11: + resolution: {integrity: sha512-usboHzRGITRcT4YM6CC7M11EpgO1pormVhOb2OzhkUmt7m0HTwKDswZL7YER5Kx82RaMqXmt8MKF5q14HZqzkg==} engines: {node: '>= 10'} cpu: [x64] os: [darwin] @@ -1129,8 +1129,8 @@ packages: dev: true optional: true - /@tauri-apps/cli-linux-arm-gnueabihf@2.0.0-alpha.10: - resolution: {integrity: sha512-UpjG9qpF/7fkfrBoM6N+Lo08HRAKR9k7LENAFU+zd81JestxOCs0hxuX2/lGkVydtOuSXfVvMn1W5YpGKkgp3A==} + /@tauri-apps/cli-linux-arm-gnueabihf@2.0.0-alpha.11: + resolution: {integrity: sha512-yAcJOpTnijxSmvxwkbRmHNBmFGo0UyA9qunboDaSppQQqlEozGMwQe6yASUpBdjzRaECbygoiiNez9dHOnQfOg==} engines: {node: '>= 10'} cpu: [arm] os: [linux] @@ -1138,8 +1138,8 @@ packages: dev: true optional: true - /@tauri-apps/cli-linux-arm64-gnu@2.0.0-alpha.10: - resolution: {integrity: sha512-Pc8seZINcbHDgOC0ThZ5EPUqOYbL94wEUecKkiaKn7gCl3/ZyIlRte5gizBeLwmnG4fkSLZc0UMvRilu4hGK3g==} + /@tauri-apps/cli-linux-arm64-gnu@2.0.0-alpha.11: + resolution: {integrity: sha512-tPYRhxZjAKaBcpN5WerHO39PEru9Uql8milTgp+rD+uu5C0cqUTR524YoffuIox38zB4skq7y8sQCT+oivDLkQ==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] @@ -1147,8 +1147,8 @@ packages: dev: true optional: true - /@tauri-apps/cli-linux-arm64-musl@2.0.0-alpha.10: - resolution: {integrity: sha512-ZlaBbJq5yXP6VmNOrUGgSDnM1JcDsYf7XfVOm/kLVVrZ3iEzYA18v4SZH2kR18bU7h5+YVCPwwnfD+B8ROGidA==} + /@tauri-apps/cli-linux-arm64-musl@2.0.0-alpha.11: + resolution: {integrity: sha512-E+FJ9nnaYcsmm88u8GZOmmiHG/3qG4guF/k7r7Y3v5N9I1NFyiEr8hg5WeHBNBZoepHSrtBRQ0Ov2Bq58hqOzg==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] @@ -1156,8 +1156,8 @@ packages: dev: true optional: true - /@tauri-apps/cli-linux-x64-gnu@2.0.0-alpha.10: - resolution: {integrity: sha512-7fo0u56URSFZwJpwPMeNiYypbgYcT8i5KPMe1CQgWW19sJLHBMK1Kd0L8SeAZDlCPpY2coNifAdEm3C7Ca7xMQ==} + /@tauri-apps/cli-linux-x64-gnu@2.0.0-alpha.11: + resolution: {integrity: sha512-Rvy/r0HI2RmE+D+0EUAs5xlIa4zMxQ421PTrOY0WmyTHrjxx/M4TX3D4oJnZsKrLjQ3L8OFvV6A632BJnxpAuA==} engines: {node: '>= 10'} cpu: [x64] os: [linux] @@ -1165,8 +1165,8 @@ packages: dev: true optional: true - /@tauri-apps/cli-linux-x64-musl@2.0.0-alpha.10: - resolution: {integrity: sha512-9lY7YJmsm7SndlIxKzj/faX/bYX1q0dib88kpxT2xW4qNt9RihTI6PST1PDce5DmEoheLU9Xp9ere8SfoHgE2A==} + /@tauri-apps/cli-linux-x64-musl@2.0.0-alpha.11: + resolution: {integrity: sha512-QT1TH+QieJKDT8YOyUKRIdcnMZgeH/vGdkzkmXbKaGURcYEjsh8qHelYzE+2oyWt8VBIJJXV7DcbNX6g4Q+fMA==} engines: {node: '>= 10'} cpu: [x64] os: [linux] @@ -1174,8 +1174,8 @@ packages: dev: true optional: true - /@tauri-apps/cli-win32-arm64-msvc@2.0.0-alpha.10: - resolution: {integrity: sha512-tJOHIy13vjYRkfw7++aRDQEb5CVzVQKDiJ35Zg4I8YcaPExgj6LKCpDo8N8AD4RXy4SnYKzqYTt8K9xcyIonzA==} + /@tauri-apps/cli-win32-arm64-msvc@2.0.0-alpha.11: + resolution: {integrity: sha512-ggGRBzdND1lEYlZ31ujeYvVAKZh/vHjnx7Q5Gsi4Bu3e9pSt3sId0G5G2OXH7WyxftaDUzfsLfKknE3cQwX9rA==} engines: {node: '>= 10'} cpu: [arm64] os: [win32] @@ -1183,8 +1183,8 @@ packages: dev: true optional: true - /@tauri-apps/cli-win32-ia32-msvc@2.0.0-alpha.10: - resolution: {integrity: sha512-DN4TlOU8e6cRRVXAnldHhfDDr0ER000fojJ/Vb33fgGvaXury3jBtNyKQuoscvg6T8fLUBc72O6+4tDnXlIBwQ==} + /@tauri-apps/cli-win32-ia32-msvc@2.0.0-alpha.11: + resolution: {integrity: sha512-P32D6CvyzVB+5pPDxcKSoIClGB0el5rzaDne8jVS/VR+IidYp1oCP5wAsF9h+ldEsdesAbsbtWaMKS36kxgA2g==} engines: {node: '>= 10'} cpu: [ia32] os: [win32] @@ -1192,8 +1192,8 @@ packages: dev: true optional: true - /@tauri-apps/cli-win32-x64-msvc@2.0.0-alpha.10: - resolution: {integrity: sha512-H5Y+L7H24n9EVB/Dw5HHGo+wQZHTLVgWrkOwsxqssDhTPiM5CbEuyjEf/B1y8uqp4YoIlw5t7Db+GBg12KejAA==} + /@tauri-apps/cli-win32-x64-msvc@2.0.0-alpha.11: + resolution: {integrity: sha512-a3geg/sWR7+qfTuoQGFK13YlHlip47XYnMXtoaC+SAXJ7Pur+/m48PZgxYy5mwvI2ApNUTgkMO5ZwdeeK2sh5g==} engines: {node: '>= 10'} cpu: [x64] os: [win32] @@ -1201,21 +1201,21 @@ packages: dev: true optional: true - /@tauri-apps/cli@2.0.0-alpha.10: - resolution: {integrity: sha512-8SkTAxg5J06f7BWgJjNt1NEBPRsffmj4X+PckHX3ZguZd8xqpGtACufUg0zVqaFZPmd+9OCvoEJSP5veO4utDQ==} + /@tauri-apps/cli@2.0.0-alpha.11: + resolution: {integrity: sha512-akkxK6lkPyo27F7+GHJuZTEUWwaX5yKRXrDhir+DAzEH4Gt/EZ+GsPFPgSV1EBQzDZGdMGpRovuftIky7m0TZw==} engines: {node: '>= 10'} hasBin: true optionalDependencies: - '@tauri-apps/cli-darwin-arm64': 2.0.0-alpha.10 - '@tauri-apps/cli-darwin-x64': 2.0.0-alpha.10 - '@tauri-apps/cli-linux-arm-gnueabihf': 2.0.0-alpha.10 - '@tauri-apps/cli-linux-arm64-gnu': 2.0.0-alpha.10 - '@tauri-apps/cli-linux-arm64-musl': 2.0.0-alpha.10 - '@tauri-apps/cli-linux-x64-gnu': 2.0.0-alpha.10 - '@tauri-apps/cli-linux-x64-musl': 2.0.0-alpha.10 - '@tauri-apps/cli-win32-arm64-msvc': 2.0.0-alpha.10 - '@tauri-apps/cli-win32-ia32-msvc': 2.0.0-alpha.10 - '@tauri-apps/cli-win32-x64-msvc': 2.0.0-alpha.10 + '@tauri-apps/cli-darwin-arm64': 2.0.0-alpha.11 + '@tauri-apps/cli-darwin-x64': 2.0.0-alpha.11 + '@tauri-apps/cli-linux-arm-gnueabihf': 2.0.0-alpha.11 + '@tauri-apps/cli-linux-arm64-gnu': 2.0.0-alpha.11 + '@tauri-apps/cli-linux-arm64-musl': 2.0.0-alpha.11 + '@tauri-apps/cli-linux-x64-gnu': 2.0.0-alpha.11 + '@tauri-apps/cli-linux-x64-musl': 2.0.0-alpha.11 + '@tauri-apps/cli-win32-arm64-msvc': 2.0.0-alpha.11 + '@tauri-apps/cli-win32-ia32-msvc': 2.0.0-alpha.11 + '@tauri-apps/cli-win32-x64-msvc': 2.0.0-alpha.11 dev: true /@tauri-apps/toml@2.2.4: diff --git a/shared/template/package.json b/shared/template/package.json index 58309e19b..5a6598645 100644 --- a/shared/template/package.json +++ b/shared/template/package.json @@ -27,6 +27,6 @@ "tslib": "2.6.0" }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.5" + "@tauri-apps/api": "2.0.0-alpha.6" } -} +} \ No newline at end of file From f19260cbb2f9719c41fbdc460a8a1c91b65debe6 Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Mon, 14 Aug 2023 13:24:31 -0300 Subject: [PATCH 2/6] fmt [skip ci] --- examples/api/package.json | 2 +- plugins/app/package.json | 2 +- plugins/authenticator/package.json | 2 +- plugins/autostart/package.json | 2 +- plugins/cli/package.json | 2 +- plugins/clipboard-manager/package.json | 2 +- plugins/dialog/package.json | 2 +- plugins/fs/package.json | 2 +- plugins/global-shortcut/package.json | 2 +- plugins/http/package.json | 2 +- plugins/log/package.json | 2 +- plugins/notification/package.json | 2 +- plugins/os/package.json | 2 +- plugins/positioner/package.json | 2 +- plugins/process/package.json | 2 +- plugins/shell/package.json | 2 +- plugins/sql/package.json | 2 +- plugins/store/package.json | 2 +- plugins/stronghold/package.json | 2 +- plugins/updater/package.json | 2 +- plugins/upload/package.json | 2 +- plugins/websocket/package.json | 2 +- plugins/window-state/package.json | 2 +- plugins/window/package.json | 2 +- shared/template/package.json | 2 +- 25 files changed, 25 insertions(+), 25 deletions(-) diff --git a/examples/api/package.json b/examples/api/package.json index b546fedd5..1394283e7 100644 --- a/examples/api/package.json +++ b/examples/api/package.json @@ -36,4 +36,4 @@ "unocss": "^0.53.1", "vite": "^4.3.9" } -} \ No newline at end of file +} diff --git a/plugins/app/package.json b/plugins/app/package.json index b92a8c698..7180f88dd 100644 --- a/plugins/app/package.json +++ b/plugins/app/package.json @@ -29,4 +29,4 @@ "dependencies": { "@tauri-apps/api": "2.0.0-alpha.6" } -} \ No newline at end of file +} diff --git a/plugins/authenticator/package.json b/plugins/authenticator/package.json index 6d03ac37a..012db39a4 100644 --- a/plugins/authenticator/package.json +++ b/plugins/authenticator/package.json @@ -30,4 +30,4 @@ "dependencies": { "@tauri-apps/api": "2.0.0-alpha.6" } -} \ No newline at end of file +} diff --git a/plugins/autostart/package.json b/plugins/autostart/package.json index ee0d461a8..6509e2c07 100644 --- a/plugins/autostart/package.json +++ b/plugins/autostart/package.json @@ -29,4 +29,4 @@ "dependencies": { "@tauri-apps/api": "2.0.0-alpha.6" } -} \ No newline at end of file +} diff --git a/plugins/cli/package.json b/plugins/cli/package.json index 074f2026a..2c64a4597 100644 --- a/plugins/cli/package.json +++ b/plugins/cli/package.json @@ -29,4 +29,4 @@ "dependencies": { "@tauri-apps/api": "2.0.0-alpha.6" } -} \ No newline at end of file +} diff --git a/plugins/clipboard-manager/package.json b/plugins/clipboard-manager/package.json index 49e898f45..b042dfea5 100644 --- a/plugins/clipboard-manager/package.json +++ b/plugins/clipboard-manager/package.json @@ -29,4 +29,4 @@ "dependencies": { "@tauri-apps/api": "2.0.0-alpha.6" } -} \ No newline at end of file +} diff --git a/plugins/dialog/package.json b/plugins/dialog/package.json index 6395658ff..30ba44101 100644 --- a/plugins/dialog/package.json +++ b/plugins/dialog/package.json @@ -29,4 +29,4 @@ "dependencies": { "@tauri-apps/api": "2.0.0-alpha.6" } -} \ No newline at end of file +} diff --git a/plugins/fs/package.json b/plugins/fs/package.json index 6cae43845..08edde604 100644 --- a/plugins/fs/package.json +++ b/plugins/fs/package.json @@ -30,4 +30,4 @@ "dependencies": { "@tauri-apps/api": "2.0.0-alpha.6" } -} \ No newline at end of file +} diff --git a/plugins/global-shortcut/package.json b/plugins/global-shortcut/package.json index 25b555b25..809cf4993 100644 --- a/plugins/global-shortcut/package.json +++ b/plugins/global-shortcut/package.json @@ -29,4 +29,4 @@ "dependencies": { "@tauri-apps/api": "2.0.0-alpha.6" } -} \ No newline at end of file +} diff --git a/plugins/http/package.json b/plugins/http/package.json index 2dc34aa25..56f4bda7c 100644 --- a/plugins/http/package.json +++ b/plugins/http/package.json @@ -29,4 +29,4 @@ "dependencies": { "@tauri-apps/api": "2.0.0-alpha.6" } -} \ No newline at end of file +} diff --git a/plugins/log/package.json b/plugins/log/package.json index 79867ceaf..45935f1fc 100644 --- a/plugins/log/package.json +++ b/plugins/log/package.json @@ -30,4 +30,4 @@ "dependencies": { "@tauri-apps/api": "2.0.0-alpha.6" } -} \ No newline at end of file +} diff --git a/plugins/notification/package.json b/plugins/notification/package.json index c41c1b27c..ef88be2ed 100644 --- a/plugins/notification/package.json +++ b/plugins/notification/package.json @@ -29,4 +29,4 @@ "dependencies": { "@tauri-apps/api": "2.0.0-alpha.6" } -} \ No newline at end of file +} diff --git a/plugins/os/package.json b/plugins/os/package.json index 90407659a..b4fb60762 100644 --- a/plugins/os/package.json +++ b/plugins/os/package.json @@ -29,4 +29,4 @@ "dependencies": { "@tauri-apps/api": "2.0.0-alpha.6" } -} \ No newline at end of file +} diff --git a/plugins/positioner/package.json b/plugins/positioner/package.json index fc1975f30..21866a1ef 100644 --- a/plugins/positioner/package.json +++ b/plugins/positioner/package.json @@ -30,4 +30,4 @@ "dependencies": { "@tauri-apps/api": "2.0.0-alpha.6" } -} \ No newline at end of file +} diff --git a/plugins/process/package.json b/plugins/process/package.json index c86aa07c7..343ec59c1 100644 --- a/plugins/process/package.json +++ b/plugins/process/package.json @@ -29,4 +29,4 @@ "dependencies": { "@tauri-apps/api": "2.0.0-alpha.6" } -} \ No newline at end of file +} diff --git a/plugins/shell/package.json b/plugins/shell/package.json index c79961f98..64e4e56c2 100644 --- a/plugins/shell/package.json +++ b/plugins/shell/package.json @@ -29,4 +29,4 @@ "dependencies": { "@tauri-apps/api": "2.0.0-alpha.6" } -} \ No newline at end of file +} diff --git a/plugins/sql/package.json b/plugins/sql/package.json index a2ae06bbf..e60c2701b 100644 --- a/plugins/sql/package.json +++ b/plugins/sql/package.json @@ -30,4 +30,4 @@ "dependencies": { "@tauri-apps/api": "2.0.0-alpha.6" } -} \ No newline at end of file +} diff --git a/plugins/store/package.json b/plugins/store/package.json index 74ff42779..139f94fde 100644 --- a/plugins/store/package.json +++ b/plugins/store/package.json @@ -30,4 +30,4 @@ "dependencies": { "@tauri-apps/api": "2.0.0-alpha.6" } -} \ No newline at end of file +} diff --git a/plugins/stronghold/package.json b/plugins/stronghold/package.json index 3a09383e6..7aed19443 100644 --- a/plugins/stronghold/package.json +++ b/plugins/stronghold/package.json @@ -30,4 +30,4 @@ "dependencies": { "@tauri-apps/api": "2.0.0-alpha.6" } -} \ No newline at end of file +} diff --git a/plugins/updater/package.json b/plugins/updater/package.json index d80408926..dd71827d1 100644 --- a/plugins/updater/package.json +++ b/plugins/updater/package.json @@ -29,4 +29,4 @@ "dependencies": { "@tauri-apps/api": "2.0.0-alpha.6" } -} \ No newline at end of file +} diff --git a/plugins/upload/package.json b/plugins/upload/package.json index b7a6f249e..b8f5e1e7a 100644 --- a/plugins/upload/package.json +++ b/plugins/upload/package.json @@ -30,4 +30,4 @@ "dependencies": { "@tauri-apps/api": "2.0.0-alpha.6" } -} \ No newline at end of file +} diff --git a/plugins/websocket/package.json b/plugins/websocket/package.json index 39f434ce7..de70c46a8 100644 --- a/plugins/websocket/package.json +++ b/plugins/websocket/package.json @@ -29,4 +29,4 @@ "dependencies": { "@tauri-apps/api": "2.0.0-alpha.6" } -} \ No newline at end of file +} diff --git a/plugins/window-state/package.json b/plugins/window-state/package.json index 4942a7b8a..e1e2906a1 100644 --- a/plugins/window-state/package.json +++ b/plugins/window-state/package.json @@ -30,4 +30,4 @@ "dependencies": { "@tauri-apps/api": "2.0.0-alpha.6" } -} \ No newline at end of file +} diff --git a/plugins/window/package.json b/plugins/window/package.json index 053524103..f7cea27b5 100644 --- a/plugins/window/package.json +++ b/plugins/window/package.json @@ -29,4 +29,4 @@ "dependencies": { "@tauri-apps/api": "2.0.0-alpha.6" } -} \ No newline at end of file +} diff --git a/shared/template/package.json b/shared/template/package.json index 5a6598645..ae1542577 100644 --- a/shared/template/package.json +++ b/shared/template/package.json @@ -29,4 +29,4 @@ "dependencies": { "@tauri-apps/api": "2.0.0-alpha.6" } -} \ No newline at end of file +} From 8c2d6b796531620f330750e375171450903428fd Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Mon, 14 Aug 2023 13:29:29 -0300 Subject: [PATCH 3/6] fix fs [skip ci] --- plugins/fs/src/watcher.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/fs/src/watcher.rs b/plugins/fs/src/watcher.rs index 108698a21..8c2a36fb5 100644 --- a/plugins/fs/src/watcher.rs +++ b/plugins/fs/src/watcher.rs @@ -5,7 +5,7 @@ use notify::{Config, Event, RecommendedWatcher, RecursiveMode, Watcher}; use notify_debouncer_mini::{new_debouncer, DebounceEventResult, Debouncer}; use serde::Deserialize; -use tauri::{command, ipc::Channel, Runtime, State}; +use tauri::{command, ipc::Channel, State}; use crate::Result; @@ -30,7 +30,7 @@ enum WatcherKind { Watcher(RecommendedWatcher), } -fn watch_raw(on_event: Channel, rx: Receiver>) { +fn watch_raw(on_event: Channel, rx: Receiver>) { spawn(move || { while let Ok(event) = rx.recv() { if let Ok(event) = event { @@ -41,7 +41,7 @@ fn watch_raw(on_event: Channel, rx: Receiver(on_event: Channel, rx: Receiver) { +fn watch_debounced(on_event: Channel, rx: Receiver) { spawn(move || { while let Ok(event) = rx.recv() { if let Ok(event) = event { @@ -60,12 +60,12 @@ pub struct WatchOptions { } #[command] -pub async fn watch( +pub async fn watch( watchers: State<'_, WatcherCollection>, id: Id, paths: Vec, options: WatchOptions, - on_event: Channel, + on_event: Channel, ) -> Result<()> { let mode = if options.recursive { RecursiveMode::Recursive From 01fc3fa593d79544ebb8c252d35fdd32af8bc710 Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Mon, 14 Aug 2023 14:07:52 -0300 Subject: [PATCH 4/6] fix doctest [skip ci] --- plugins/shell/src/process/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/shell/src/process/mod.rs b/plugins/shell/src/process/mod.rs index 11a3154e1..29f40e337 100644 --- a/plugins/shell/src/process/mod.rs +++ b/plugins/shell/src/process/mod.rs @@ -206,7 +206,7 @@ impl Command { /// use tauri_plugin_shell::{process::CommandEvent, ShellExt}; /// tauri::Builder::default() /// .setup(|app| { - /// let handle = app.handle(); + /// let handle = app.handle().clone(); /// tauri::async_runtime::spawn(async move { /// let (mut rx, mut child) = handle.shell().command("cargo") /// .args(["tauri", "dev"]) From b63cb003cc0527747281cf5a893e39b82ed7a845 Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Mon, 14 Aug 2023 14:10:04 -0300 Subject: [PATCH 5/6] fix store tests [skip ci] --- plugins/store/src/lib.rs | 8 ++++---- plugins/store/src/store.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/store/src/lib.rs b/plugins/store/src/lib.rs index 3569f2736..45a0c8263 100644 --- a/plugins/store/src/lib.rs +++ b/plugins/store/src/lib.rs @@ -218,7 +218,7 @@ impl Builder { /// /// tauri::Builder::default() /// .setup(|app| { - /// let store = StoreBuilder::new("store.bin").build(app.handle()); + /// let store = StoreBuilder::new("store.bin").build(app.handle().clone()); /// let builder = Builder::default().store(store); /// Ok(()) /// }); @@ -237,7 +237,7 @@ impl Builder { /// /// tauri::Builder::default() /// .setup(|app| { - /// let store = StoreBuilder::new("store.bin").build(app.handle()); + /// let store = StoreBuilder::new("store.bin").build(app.handle().clone()); /// let builder = Builder::default().stores([store]); /// Ok(()) /// }); @@ -261,7 +261,7 @@ impl Builder { /// /// tauri::Builder::default() /// .setup(|app| { - /// let store = StoreBuilder::new("store.bin").build(app.handle()); + /// let store = StoreBuilder::new("store.bin").build(app.handle().clone()); /// app.handle().plugin(Builder::default().freeze().build()); /// Ok(()) /// }); @@ -280,7 +280,7 @@ impl Builder { /// /// tauri::Builder::default() /// .setup(|app| { - /// let store = StoreBuilder::new("store.bin").build(app.handle()); + /// let store = StoreBuilder::new("store.bin").build(app.handle().clone()); /// app.handle().plugin(Builder::default().build()); /// Ok(()) /// }); diff --git a/plugins/store/src/store.rs b/plugins/store/src/store.rs index 41e9ff54c..cea0eb17f 100644 --- a/plugins/store/src/store.rs +++ b/plugins/store/src/store.rs @@ -144,7 +144,7 @@ impl StoreBuilder { /// ``` /// tauri::Builder::default() /// .setup(|app| { - /// let store = tauri_plugin_store::StoreBuilder::new("store.json").build(app.handle()); + /// let store = tauri_plugin_store::StoreBuilder::new("store.json").build(app.handle().clone()); /// Ok(()) /// }); /// ``` From 6511e47b3e191291ce64279631b84a705f7ae827 Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Mon, 14 Aug 2023 14:10:50 -0300 Subject: [PATCH 6/6] fix updater doctests [skip ci] --- plugins/updater/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/updater/src/lib.rs b/plugins/updater/src/lib.rs index cb2391027..0475620de 100644 --- a/plugins/updater/src/lib.rs +++ b/plugins/updater/src/lib.rs @@ -41,7 +41,7 @@ pub trait UpdaterExt { /// use tauri_plugin_updater::UpdaterExt; /// tauri::Builder::default() /// .setup(|app| { - /// let handle = app.handle(); + /// let handle = app.handle().clone(); /// tauri::async_runtime::spawn(async move { /// let response = handle.updater_builder().build().unwrap().check().await; /// }); @@ -58,7 +58,7 @@ pub trait UpdaterExt { /// use tauri_plugin_updater::UpdaterExt; /// tauri::Builder::default() /// .setup(|app| { - /// let handle = app.handle(); + /// let handle = app.handle().clone(); /// tauri::async_runtime::spawn(async move { /// let response = handle.updater().unwrap().check().await; /// });