diff --git a/.changes/alpha.17.md b/.changes/alpha.17.md new file mode 100644 index 000000000..ea686a26d --- /dev/null +++ b/.changes/alpha.17.md @@ -0,0 +1,30 @@ +--- +"authenticator": patch +"autostart": patch +"barcode-scanner": patch +"cli": patch +"clipboard-manager": patch +"deep-link": patch +"dialog": patch +"fs": patch +"global-shortcut": patch +"http": patch +"localhost": patch +"log-plugin": patch +"notification": patch +"os": patch +"persisted-scope": patch +"positioner": patch +"process": patch +"shell": patch +"single-instance": patch +"sql": patch +"store": patch +"stronghold": patch +"updater": patch +"upload": patch +"websocket": patch +"window-state": patch +--- + +Update to tauri@alpha.17. diff --git a/.changes/api-alpha.11.md b/.changes/api-alpha.11.md new file mode 100644 index 000000000..fc5e1ba58 --- /dev/null +++ b/.changes/api-alpha.11.md @@ -0,0 +1,27 @@ +--- +"authenticator-js": patch +"autostart-js": patch +"barcode-scanner-js": patch +"cli-js": patch +"clipboard-manager-js": patch +"deep-link-js": patch +"dialog-js": patch +"fs-js": patch +"global-shortcut-js": patch +"http-js": patch +"log-js": patch +"notification-js": patch +"os-js": patch +"positioner-js": patch +"process-js": patch +"shell-js": patch +"sql-js": patch +"store-js": patch +"stronghold-js": patch +"updater-js": patch +"upload-js": patch +"websocket-js": patch +"window-state-js": patch +--- + +Update to @tauri-apps/api v2.0.0-alpha.11. diff --git a/.changes/api-alpha.9.md b/.changes/api-alpha.9.md index b042bcf5b..e0267b08b 100644 --- a/.changes/api-alpha.9.md +++ b/.changes/api-alpha.9.md @@ -24,4 +24,4 @@ "window-state-js": patch --- -Update to @tauri-apps/api v2.0.0-alpha.16. +Update to @tauri-apps/api v2.0.0-alpha.9. diff --git a/.changes/fix-emit-all-usage.md b/.changes/fix-emit-all-usage.md new file mode 100644 index 000000000..30782cdf7 --- /dev/null +++ b/.changes/fix-emit-all-usage.md @@ -0,0 +1,7 @@ +--- +"log-plugin": patch +"deep-link": patch +"store": patch +--- + +Update to breaking changes from tauri@alpha.17. diff --git a/Cargo.lock b/Cargo.lock index 7760c7234..c79a2d502 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -453,24 +453,23 @@ dependencies = [ [[package]] name = "atk" -version = "0.16.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39991bc421ddf72f70159011b323ff49b0f783cc676a7287c59453da2e2531cf" +checksum = "b4af014b17dd80e8af9fa689b2d4a211ddba6eb583c1622f35d0cb543f6b17e4" dependencies = [ "atk-sys", - "bitflags 1.3.2", - "glib", + "glib 0.18.2", "libc", ] [[package]] name = "atk-sys" -version = "0.16.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11ad703eb64dc058024f0e57ccfa069e15a413b98dbd50a1a950e743b7f11148" +checksum = "251e0b7d90e33e0ba930891a505a9a35ece37b2dd37a14f3ffc306c13b980009" dependencies = [ - "glib-sys", - "gobject-sys", + "glib-sys 0.18.1", + "gobject-sys 0.18.0", "libc", "system-deps", ] @@ -737,14 +736,13 @@ dependencies = [ [[package]] name = "cairo-rs" -version = "0.16.7" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3125b15ec28b84c238f6f476c6034016a5f6cc0221cb514ca46c532139fc97d" +checksum = "1c0466dfa8c0ee78deef390c274ad756801e0a6dbb86c5ef0924a298c5761c4d" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.3.3", "cairo-sys-rs", - "freetype-rs", - "glib", + "glib 0.18.2", "libc", "once_cell", "thiserror", @@ -752,24 +750,23 @@ dependencies = [ [[package]] name = "cairo-sys-rs" -version = "0.16.3" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c48f4af05fabdcfa9658178e1326efa061853f040ce7d72e33af6885196f421" +checksum = "685c9fa8e590b8b3d678873528d83411db17242a73fccaed827770ea0fedda51" dependencies = [ - "glib-sys", + "glib-sys 0.18.1", "libc", "system-deps", - "x11", ] [[package]] name = "cargo_toml" -version = "0.15.3" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "599aa35200ffff8f04c1925aa1acc92fa2e08874379ef42e210a80e527e60838" +checksum = "e3f9629bc6c4388ea699781dc988c2b99766d7679b151c81990b4fa1208fafd3" dependencies = [ "serde", - "toml", + "toml 0.8.6", ] [[package]] @@ -918,15 +915,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "cmake" -version = "0.1.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" -dependencies = [ - "cc", -] - [[package]] name = "cocoa" version = "0.24.1" @@ -1511,7 +1499,7 @@ checksum = "f7f1e82a60222fc67bfd50d752a9c89da5cce4c39ed39decc84a443b07bbd69a" dependencies = [ "cc", "rustc_version", - "toml", + "toml 0.7.6", "vswhom", "winreg 0.11.0", ] @@ -1763,28 +1751,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "freetype-rs" -version = "0.31.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4200d5c6da26d4b5acff9098c1747f9f86da5e0f23bd7d63fed4c4a07e0b60ba" -dependencies = [ - "bitflags 1.3.2", - "freetype-sys", - "libc", -] - -[[package]] -name = "freetype-sys" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17c696ead7d51c6c585f3513eee3b604a73c4e8345b16d450843eb0a59591b2" -dependencies = [ - "cmake", - "libc", - "pkg-config", -] - [[package]] name = "fsevent-sys" version = "4.1.0" @@ -1930,57 +1896,56 @@ dependencies = [ [[package]] name = "gdk" -version = "0.16.2" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa9cb33da481c6c040404a11f8212d193889e9b435db2c14fd86987f630d3ce1" +checksum = "f5ba081bdef3b75ebcdbfc953699ed2d7417d6bd853347a42a37d76406a33646" dependencies = [ - "bitflags 1.3.2", "cairo-rs", "gdk-pixbuf", "gdk-sys", "gio", - "glib", + "glib 0.18.2", "libc", "pango", ] [[package]] name = "gdk-pixbuf" -version = "0.16.7" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3578c60dee9d029ad86593ed88cb40f35c1b83360e12498d055022385dd9a05" +checksum = "bbc9c2ed73a81d556b65d08879ba4ee58808a6b1927ce915262185d6d547c6f3" dependencies = [ - "bitflags 1.3.2", "gdk-pixbuf-sys", "gio", - "glib", + "glib 0.18.2", "libc", + "once_cell", ] [[package]] name = "gdk-pixbuf-sys" -version = "0.16.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3092cf797a5f1210479ea38070d9ae8a5b8e9f8f1be9f32f4643c529c7d70016" +checksum = "3f9839ea644ed9c97a34d129ad56d38a25e6756f99f3a88e15cd39c20629caf7" dependencies = [ - "gio-sys", - "glib-sys", - "gobject-sys", + "gio-sys 0.18.1", + "glib-sys 0.18.1", + "gobject-sys 0.18.0", "libc", "system-deps", ] [[package]] name = "gdk-sys" -version = "0.16.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d76354f97a913e55b984759a997b693aa7dc71068c9e98bcce51aa167a0a5c5a" +checksum = "31ff856cb3386dae1703a920f803abafcc580e9b5f711ca62ed1620c25b51ff2" dependencies = [ "cairo-sys-rs", "gdk-pixbuf-sys", - "gio-sys", - "glib-sys", - "gobject-sys", + "gio-sys 0.18.1", + "glib-sys 0.18.1", + "gobject-sys 0.18.0", "libc", "pango-sys", "pkg-config", @@ -1989,13 +1954,13 @@ dependencies = [ [[package]] name = "gdkwayland-sys" -version = "0.16.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4511710212ed3020b61a8622a37aa6f0dd2a84516575da92e9b96928dcbe83ba" +checksum = "a90fbf5c033c65d93792192a49a8efb5bb1e640c419682a58bb96f5ae77f3d4a" dependencies = [ "gdk-sys", - "glib-sys", - "gobject-sys", + "glib-sys 0.18.1", + "gobject-sys 0.18.0", "libc", "pkg-config", "system-deps", @@ -2003,12 +1968,12 @@ dependencies = [ [[package]] name = "gdkx11-sys" -version = "0.16.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fa2bf8b5b8c414bc5d05e48b271896d0fd3ddb57464a3108438082da61de6af" +checksum = "fee8f00f4ee46cad2939b8990f5c70c94ff882c3028f3cc5abf950fa4ab53043" dependencies = [ "gdk-sys", - "glib-sys", + "glib-sys 0.18.1", "libc", "system-deps", "x11", @@ -2109,17 +2074,16 @@ checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" [[package]] name = "gio" -version = "0.16.7" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a1c84b4534a290a29160ef5c6eff2a9c95833111472e824fc5cb78b513dd092" +checksum = "57052f84e8e5999b258e8adf8f5f2af0ac69033864936b8b6838321db2f759b1" dependencies = [ - "bitflags 1.3.2", "futures-channel", "futures-core", "futures-io", "futures-util", - "gio-sys", - "glib", + "gio-sys 0.18.1", + "glib 0.18.2", "libc", "once_cell", "pin-project-lite", @@ -2133,8 +2097,21 @@ version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e9b693b8e39d042a95547fc258a7b07349b1f0b48f4b2fa3108ba3c51c0b5229" dependencies = [ - "glib-sys", - "gobject-sys", + "glib-sys 0.16.3", + "gobject-sys 0.16.3", + "libc", + "system-deps", + "winapi", +] + +[[package]] +name = "gio-sys" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37566df850baf5e4cb0dfb78af2e4b9898d817ed9263d1090a2df958c64737d2" +dependencies = [ + "glib-sys 0.18.1", + "gobject-sys 0.18.0", "libc", "system-deps", "winapi", @@ -2152,12 +2129,34 @@ dependencies = [ "futures-executor", "futures-task", "futures-util", - "gio-sys", - "glib-macros", - "glib-sys", - "gobject-sys", + "gio-sys 0.16.3", + "glib-macros 0.16.8", + "glib-sys 0.16.3", + "gobject-sys 0.16.3", "libc", - "log", + "once_cell", + "smallvec", + "thiserror", +] + +[[package]] +name = "glib" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c316afb01ce8067c5eaab1fc4f2cd47dc21ce7b6296358605e2ffab23ccbd19" +dependencies = [ + "bitflags 2.3.3", + "futures-channel", + "futures-core", + "futures-executor", + "futures-task", + "futures-util", + "gio-sys 0.18.1", + "glib-macros 0.18.2", + "glib-sys 0.18.1", + "gobject-sys 0.18.0", + "libc", + "memchr", "once_cell", "smallvec", "thiserror", @@ -2178,6 +2177,20 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "glib-macros" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8da903822b136d42360518653fcf154455defc437d3e7a81475bf9a95ff1e47" +dependencies = [ + "heck", + "proc-macro-crate", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.28", +] + [[package]] name = "glib-sys" version = "0.16.3" @@ -2188,6 +2201,16 @@ dependencies = [ "system-deps", ] +[[package]] +name = "glib-sys" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "063ce2eb6a8d0ea93d2bf8ba1957e78dbab6be1c2220dd3daca57d5a9d869898" +dependencies = [ + "libc", + "system-deps", +] + [[package]] name = "glob" version = "0.3.1" @@ -2201,7 +2224,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "997c3cad8588ba1079e7747961d27515e85989be4680d88f3a194b576a4f1d58" dependencies = [ "crossbeam-channel", - "keyboard-types", + "keyboard-types 0.6.2", "once_cell", "thiserror", "windows-sys 0.48.0", @@ -2214,47 +2237,56 @@ version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3520bb9c07ae2a12c7f2fbb24d4efc11231c8146a86956413fb1a79bb760a0f1" dependencies = [ - "glib-sys", + "glib-sys 0.16.3", + "libc", + "system-deps", +] + +[[package]] +name = "gobject-sys" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0850127b514d1c4a4654ead6dedadb18198999985908e6ffe4436f53c785ce44" +dependencies = [ + "glib-sys 0.18.1", "libc", "system-deps", ] [[package]] name = "gtk" -version = "0.16.2" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4d3507d43908c866c805f74c9dd593c0ce7ba5c38e576e41846639cdcd4bee6" +checksum = "93c4f5e0e20b60e10631a5f06da7fe3dda744b05ad0ea71fee2f47adf865890c" dependencies = [ "atk", - "bitflags 1.3.2", "cairo-rs", "field-offset", "futures-channel", "gdk", "gdk-pixbuf", "gio", - "glib", + "glib 0.18.2", "gtk-sys", "gtk3-macros", "libc", - "once_cell", "pango", "pkg-config", ] [[package]] name = "gtk-sys" -version = "0.16.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b5f8946685d5fe44497007786600c2f368ff6b1e61a16251c89f72a97520a3" +checksum = "771437bf1de2c1c0b496c11505bdf748e26066bbe942dfc8f614c9460f6d7722" dependencies = [ "atk-sys", "cairo-sys-rs", "gdk-pixbuf-sys", "gdk-sys", - "gio-sys", - "glib-sys", - "gobject-sys", + "gio-sys 0.18.1", + "glib-sys 0.18.1", + "gobject-sys 0.18.0", "libc", "pango-sys", "system-deps", @@ -2262,16 +2294,15 @@ dependencies = [ [[package]] name = "gtk3-macros" -version = "0.16.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "096eb63c6fedf03bafe65e5924595785eaf1bcb7200dac0f2cbe9c9738f05ad8" +checksum = "c6063efb63db582968fb7df72e1ae68aa6360dcfb0a75143f34fc7d616bad75e" dependencies = [ - "anyhow", "proc-macro-crate", "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.28", ] [[package]] @@ -2810,23 +2841,23 @@ checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "javascriptcore-rs" -version = "1.0.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cfcc681b896b083864a4a3c3b3ea196f14ff66b8641a68fde209c6d84434056" +checksum = "ca5671e9ffce8ffba57afc24070e906da7fc4b1ba66f2cabebf61bf2ea257fcc" dependencies = [ "bitflags 1.3.2", - "glib", + "glib 0.18.2", "javascriptcore-rs-sys", ] [[package]] name = "javascriptcore-rs-sys" -version = "1.0.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0983ba5b3ab9a0c0918de02c42dc71f795d6de08092f88a98ce9fdfdee4ba91" +checksum = "af1be78d14ffa4b75b66df31840478fef72b51f8c2465d4ca7c194da9f7a5124" dependencies = [ - "glib-sys", - "gobject-sys", + "glib-sys 0.18.1", + "gobject-sys 0.18.0", "libc", "system-deps", ] @@ -2879,9 +2910,9 @@ dependencies = [ [[package]] name = "json-patch" -version = "1.0.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f54898088ccb91df1b492cc80029a6fdf1c48ca0db7c6822a8babad69c94658" +checksum = "55ff1e1486799e3f64129f8ccad108b38290df9cd7015cd31bed17239f0789d6" dependencies = [ "serde", "serde_json", @@ -2900,6 +2931,17 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "keyboard-types" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b750dcadc39a09dbadd74e118f6dd6598df77fa01df0cfcdc52c28dece74528a" +dependencies = [ + "bitflags 2.3.3", + "serde", + "unicode-segmentation", +] + [[package]] name = "kqueue" version = "1.0.7" @@ -2944,11 +2986,11 @@ dependencies = [ [[package]] name = "libappindicator" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89e1edfdc9b0853358306c6dfb4b77c79c779174256fe93d80c0b5ebca451a2f" +checksum = "03589b9607c868cc7ae54c0b2a22c8dc03dd41692d48f2d7df73615c6a95dc0a" dependencies = [ - "glib", + "glib 0.18.2", "gtk", "gtk-sys", "libappindicator-sys", @@ -2957,9 +2999,9 @@ dependencies = [ [[package]] name = "libappindicator-sys" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08fcb2bea89cee9613982501ec83eaa2d09256b24540ae463c52a28906163918" +checksum = "6e9ec52138abedcc58dc17a7c6c0c00a2bdb4f3427c7f63fa97fd0d859155caf" dependencies = [ "gtk-sys", "libloading", @@ -3276,16 +3318,14 @@ dependencies = [ [[package]] name = "muda" -version = "0.8.7" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41fe753ec4d3e8137a1d3ecb1aee1192b8f7661fe1247641968f5bf5f2e6ebbe" +checksum = "9767ce3b12d2928f17ff4f91b29e7e872a8594033d82bf00e56017cc23bb8410" dependencies = [ "cocoa 0.25.0", "crossbeam-channel", - "gdk", - "gdk-pixbuf", "gtk", - "keyboard-types", + "keyboard-types 0.7.0", "objc", "once_cell", "png", @@ -3703,13 +3743,12 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "pango" -version = "0.16.5" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdff66b271861037b89d028656184059e03b0b6ccb36003820be19f7200b1e94" +checksum = "06a9e54b831d033206160096b825f2070cf5fda7e35167b1c01e9e774f9202d1" dependencies = [ - "bitflags 1.3.2", "gio", - "glib", + "glib 0.18.2", "libc", "once_cell", "pango-sys", @@ -3717,12 +3756,12 @@ dependencies = [ [[package]] name = "pango-sys" -version = "0.16.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e134909a9a293e04d2cc31928aa95679c5e4df954d0b85483159bd20d8f047f" +checksum = "436737e391a843e5933d6d9aa102cb126d501e815b83601365a948a518555dc5" dependencies = [ - "glib-sys", - "gobject-sys", + "glib-sys 0.18.1", + "gobject-sys 0.18.0", "libc", "system-deps", ] @@ -4096,7 +4135,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell", - "toml_edit", + "toml_edit 0.19.14", ] [[package]] @@ -4472,16 +4511,14 @@ dependencies = [ [[package]] name = "rfd" -version = "0.11.4" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fe664af397d2b6a13a8ba1d172a2b5c87c6c5149039edbf8fa122b98c9ed96f" +checksum = "3c9e7b57df6e8472152674607f6cc68aa14a748a3157a857a94f516e11aeacc2" dependencies = [ - "async-io", "block", "dispatch", - "futures-util", - "glib-sys", - "gobject-sys", + "glib-sys 0.18.1", + "gobject-sys 0.18.0", "gtk-sys", "js-sys", "log", @@ -4492,7 +4529,7 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "windows 0.44.0", + "windows-sys 0.48.0", ] [[package]] @@ -4821,9 +4858,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" +checksum = "12022b835073e5b11e90a14f86838ceb1c8fb0325b72416845c487ac0fa95e80" dependencies = [ "serde", ] @@ -5049,28 +5086,26 @@ dependencies = [ [[package]] name = "soup3" -version = "0.3.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82bc46048125fefd69d30b32b9d263d6556c9ffe82a7a7df181a86d912da5616" +checksum = "471f924a40f31251afc77450e781cb26d55c0b650842efafc9c6cbd2f7cc4f9f" dependencies = [ - "bitflags 1.3.2", "futures-channel", "gio", - "glib", + "glib 0.18.2", "libc", - "once_cell", "soup3-sys", ] [[package]] name = "soup3-sys" -version = "0.3.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "014bbeb1c4cdb30739dc181e8d98b7908f124d9555843afa89b5570aaf4ec62b" +checksum = "7ebe8950a680a12f24f15ebe1bf70db7af98ad242d9db43596ad3108aab86c27" dependencies = [ - "gio-sys", - "glib-sys", - "gobject-sys", + "gio-sys 0.18.1", + "glib-sys 0.18.1", + "gobject-sys 0.18.0", "libc", "system-deps", ] @@ -5498,15 +5533,15 @@ dependencies = [ "cfg-expr", "heck", "pkg-config", - "toml", + "toml 0.7.6", "version-compare", ] [[package]] name = "tao" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60279ecb16c33a6cef45cd37a9602455c190942d20e360bd8499bff49f2a48f3" +checksum = "f130523fee9820ad78141d443e6cef75043acade79107bc483872bc183928c0f" dependencies = [ "bitflags 1.3.2", "cairo-rs", @@ -5522,8 +5557,8 @@ dependencies = [ "gdkwayland-sys", "gdkx11-sys", "gio", - "glib", - "glib-sys", + "glib 0.18.2", + "glib-sys 0.18.1", "gtk", "image", "instant", @@ -5545,8 +5580,8 @@ dependencies = [ "unicode-segmentation", "url", "uuid", - "windows 0.48.0", - "windows-implement 0.48.0", + "windows 0.51.1", + "windows-implement", "x11-dl", "zbus", ] @@ -5581,9 +5616,9 @@ checksum = "1d2faeef5759ab89935255b1a4cd98e0baf99d1085e37d36599c625dac49ae8e" [[package]] name = "tauri" -version = "2.0.0-alpha.16" +version = "2.0.0-alpha.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "350fce27e96fda5a5741ae200ebf775cc3423c682154224cfbd78066db777fc6" +checksum = "892f45e7f10c9481488633f506496eeb3c69034c17fc71d5562d1e87b5442f78" dependencies = [ "anyhow", "bytes 1.4.0", @@ -5592,7 +5627,6 @@ dependencies = [ "embed_plist", "futures-util", "getrandom 0.2.10", - "glib", "glob", "gtk", "heck", @@ -5630,17 +5664,18 @@ dependencies = [ "webkit2gtk", "webview2-com", "window-vibrancy", - "windows 0.48.0", + "windows 0.51.1", ] [[package]] name = "tauri-build" -version = "2.0.0-alpha.10" +version = "2.0.0-alpha.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55e3fe1435d7bcf64d15182815f5e1b0b05ec71cd365ed5055204efb5436ebc4" +checksum = "9d5f06f1cbb5507f4de803f8e1fab01c71cb9515297a90d3adba4fa6c06a194c" dependencies = [ "anyhow", "cargo_toml", + "dirs-next", "heck", "json-patch", "plist", @@ -5657,9 +5692,9 @@ dependencies = [ [[package]] name = "tauri-codegen" -version = "2.0.0-alpha.9" +version = "2.0.0-alpha.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff206ba5a7de8f20068f36d5fa49756a9fd375a156a2332278273b6d0dc57033" +checksum = "28094b389b0981aba46eeba7dcda6216c23fdf7288b2e0414e69fbc55aa55676" dependencies = [ "base64 0.21.2", "brotli", @@ -5683,9 +5718,9 @@ dependencies = [ [[package]] name = "tauri-macros" -version = "2.0.0-alpha.9" +version = "2.0.0-alpha.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29a29d42cca831a9d9c8be91412ef6416813e7307e8dcfd1df38f3b13f3cc73" +checksum = "c1df582259285a81324d4d38846433bfd3c0440c7a268f730acb7c29350f25cf" dependencies = [ "heck", "proc-macro2", @@ -5780,7 +5815,7 @@ dependencies = [ name = "tauri-plugin-dialog" version = "2.0.0-alpha.3" dependencies = [ - "glib", + "glib 0.16.9", "log", "raw-window-handle", "rfd", @@ -6076,9 +6111,9 @@ dependencies = [ [[package]] name = "tauri-runtime" -version = "1.0.0-alpha.3" +version = "1.0.0-alpha.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c373492a8e2d369c638bff48fc07abbe7292f8ddb867bc3b992fb7ea10006212" +checksum = "f46889d91efc090ac4031c7c423c30c5280d6984cb071b729b748d643aa3df40" dependencies = [ "gtk", "http", @@ -6089,14 +6124,14 @@ dependencies = [ "tauri-utils", "thiserror", "url", - "windows 0.48.0", + "windows 0.51.1", ] [[package]] name = "tauri-runtime-wry" -version = "1.0.0-alpha.4" +version = "1.0.0-alpha.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef7b8a49504f67c65a55188013439edf815356a6f8e2a9d2ed005120a201c98f" +checksum = "b083797e147019c318db883a51868014751b578ba0d1ef3aadd34199a3bbcf61" dependencies = [ "cocoa 0.24.1", "gtk", @@ -6108,15 +6143,15 @@ dependencies = [ "tauri-utils", "webkit2gtk", "webview2-com", - "windows 0.48.0", + "windows 0.51.1", "wry", ] [[package]] name = "tauri-utils" -version = "2.0.0-alpha.9" +version = "2.0.0-alpha.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b821e0e6b5b94c6bde3c95568f5161eb70939a7b0d511f79c0cf85fed3b29c9" +checksum = "68e138783ca404416a4afe34f22f804d533c28fb73f87870f365c6ecdcee6c23" dependencies = [ "aes-gcm 0.10.2", "brotli", @@ -6152,7 +6187,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5993dc129e544393574288923d1ec447c857f3f644187f4fbf7d9a875fbfc4fb" dependencies = [ "embed-resource", - "toml", + "toml 0.7.6", ] [[package]] @@ -6417,14 +6452,26 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit", + "toml_edit 0.19.14", +] + +[[package]] +name = "toml" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ff9e3abce27ee2c9a37f9ad37238c1bdd4e789c84ba37df76aa4d528f5072cc" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit 0.20.7", ] [[package]] name = "toml_datetime" -version = "0.6.3" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" dependencies = [ "serde", ] @@ -6442,6 +6489,19 @@ dependencies = [ "winnow", ] +[[package]] +name = "toml_edit" +version = "0.20.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81" +dependencies = [ + "indexmap 2.0.0", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + [[package]] name = "tower-service" version = "0.3.2" @@ -6513,9 +6573,9 @@ dependencies = [ [[package]] name = "tray-icon" -version = "0.8.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b0e5bec13da15e62330e9bcf8b9fd42489b5acfe29ac8fec7ed659dbee21d9" +checksum = "1a7dce8a4b6d7a566ca78fa43f37efc7a3ec427480828d35fe3474c4f0c75396" dependencies = [ "cocoa 0.25.0", "core-graphics 0.23.1", @@ -6950,19 +7010,19 @@ dependencies = [ [[package]] name = "webkit2gtk" -version = "1.1.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ba4cce9085e0fb02575cfd45c328740dde78253cba516b1e8be2ca0f57bd8bf" +checksum = "76b1bc1e54c581da1e9f179d0b38512ba358fb1af2d634a1affe42e37172361a" dependencies = [ "bitflags 1.3.2", "cairo-rs", "gdk", "gdk-sys", "gio", - "gio-sys", - "glib", - "glib-sys", - "gobject-sys", + "gio-sys 0.18.1", + "glib 0.18.2", + "glib-sys 0.18.1", + "gobject-sys 0.18.0", "gtk", "gtk-sys", "javascriptcore-rs", @@ -6974,16 +7034,16 @@ dependencies = [ [[package]] name = "webkit2gtk-sys" -version = "1.1.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4489eb24e8cf0a3d0555fd3a8f7adec2a5ece34c1e7b7c9a62da7822fd40a59" +checksum = "62daa38afc514d1f8f12b8693d30d5993ff77ced33ce30cd04deebc267a6d57c" dependencies = [ "bitflags 1.3.2", "cairo-sys-rs", "gdk-sys", - "gio-sys", - "glib-sys", - "gobject-sys", + "gio-sys 0.18.1", + "glib-sys 0.18.1", + "gobject-sys 0.18.0", "gtk-sys", "javascriptcore-rs-sys", "libc", @@ -7042,15 +7102,16 @@ dependencies = [ [[package]] name = "webview2-com" -version = "0.25.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79e563ffe8e84d42e43ffacbace8780c0244fc8910346f334613559d92e203ad" +checksum = "cd15556ff1d1d6bc850dbb362762bae86069773dd30177c90d3bfa917080dc73" dependencies = [ "webview2-com-macros", "webview2-com-sys", - "windows 0.48.0", - "windows-implement 0.48.0", - "windows-interface 0.48.0", + "windows 0.51.1", + "windows-core", + "windows-implement", + "windows-interface", ] [[package]] @@ -7066,17 +7127,13 @@ dependencies = [ [[package]] name = "webview2-com-sys" -version = "0.25.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19d39576804304cf9ead192467ef47f7859a1a12fec3bd459d5ba34b8cd65ed5" +checksum = "3775bb005c3170497ec411b36005708b57ad486bfa3d23864c92f5973858ce8d" dependencies = [ - "regex", - "serde", - "serde_json", "thiserror", - "windows 0.48.0", - "windows-bindgen", - "windows-metadata", + "windows 0.51.1", + "windows-core", ] [[package]] @@ -7197,23 +7254,12 @@ dependencies = [ "windows_x86_64_msvc 0.39.0", ] -[[package]] -name = "windows" -version = "0.44.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e745dab35a0c4c77aa3ce42d595e13d2003d6902d6b08c9ef5fc326d08da12b" -dependencies = [ - "windows-targets 0.42.2", -] - [[package]] name = "windows" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ - "windows-implement 0.48.0", - "windows-interface 0.48.0", "windows-targets 0.48.5", ] @@ -7224,21 +7270,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca229916c5ee38c2f2bc1e9d8f04df975b4bd93f9955dc69fabb5d91270045c9" dependencies = [ "windows-core", - "windows-implement 0.51.1", - "windows-interface 0.51.1", + "windows-implement", + "windows-interface", "windows-targets 0.48.5", ] -[[package]] -name = "windows-bindgen" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fe21a77bc54b7312dbd66f041605e098990c98be48cd52967b85b5e60e75ae6" -dependencies = [ - "windows-metadata", - "windows-tokens", -] - [[package]] name = "windows-core" version = "0.51.1" @@ -7248,17 +7284,6 @@ dependencies = [ "windows-targets 0.48.5", ] -[[package]] -name = "windows-implement" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e2ee588991b9e7e6c8338edf3333fbe4da35dc72092643958ebb43f0ab2c49c" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "windows-implement" version = "0.51.1" @@ -7270,17 +7295,6 @@ dependencies = [ "syn 2.0.28", ] -[[package]] -name = "windows-interface" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6fb8df20c9bcaa8ad6ab513f7b40104840c8867d5751126e4df3b08388d0cc7" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "windows-interface" version = "0.51.1" @@ -7292,12 +7306,6 @@ dependencies = [ "syn 2.0.28", ] -[[package]] -name = "windows-metadata" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "422ee0e5f0e2cc372bb6addbfff9a8add712155cd743df9c15f6ab000f31432d" - [[package]] name = "windows-sys" version = "0.36.1" @@ -7374,12 +7382,6 @@ dependencies = [ "windows_x86_64_msvc 0.48.5", ] -[[package]] -name = "windows-tokens" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b34c9a3b28cb41db7385546f7f9a8179348dffc89923dde66857b1ba5312f6b4" - [[package]] name = "windows_aarch64_gnullvm" version = "0.42.2" @@ -7564,19 +7566,16 @@ dependencies = [ [[package]] name = "wry" -version = "0.33.0" +version = "0.34.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf906b43b8042615c85a978dceb4d4b72214d27b850b54abc3edeb7c5a67abab" +checksum = "3f1e29660f22d8eec141f41f59b7fef231e4113c370c89b90ae3a0db8dec1927" dependencies = [ "base64 0.21.2", "block", - "cocoa 0.24.1", - "core-graphics 0.22.3", + "cocoa 0.25.0", + "core-graphics 0.23.1", "crossbeam-channel", "dunce", - "gdk", - "gio", - "glib", "gtk", "html5ever", "http", @@ -7597,8 +7596,8 @@ dependencies = [ "webkit2gtk", "webkit2gtk-sys", "webview2-com", - "windows 0.48.0", - "windows-implement 0.48.0", + "windows 0.51.1", + "windows-implement", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 5dbff89b4..6aba67f8b 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.16" -tauri-build = "2.0.0-alpha.10" +tauri = "2.0.0-alpha.17" +tauri-build = "2.0.0-alpha.11" serde_json = "1" thiserror = "1" diff --git a/examples/api/package.json b/examples/api/package.json index 49b7c1722..cf2931f5a 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.9", + "@tauri-apps/api": "2.0.0-alpha.11", "@tauri-apps/plugin-barcode-scanner": "2.0.0-alpha.1", "@tauri-apps/plugin-cli": "2.0.0-alpha.2", "@tauri-apps/plugin-clipboard-manager": "2.0.0-alpha.2", @@ -28,7 +28,7 @@ "@iconify-json/codicon": "^1.1.31", "@iconify-json/ph": "^1.1.6", "@sveltejs/vite-plugin-svelte": "^2.4.6", - "@tauri-apps/cli": "2.0.0-alpha.16", + "@tauri-apps/cli": "2.0.0-alpha.17", "@unocss/extractor-svelte": "^0.56.5", "internal-ip": "^8.0.0", "svelte": "^4.2.2", diff --git a/examples/api/src-tauri/gen/android/app/src/main/AndroidManifest.xml b/examples/api/src-tauri/gen/android/app/src/main/AndroidManifest.xml index 6ad2d2105..c9ef9e7fc 100644 --- a/examples/api/src-tauri/gen/android/app/src/main/AndroidManifest.xml +++ b/examples/api/src-tauri/gen/android/app/src/main/AndroidManifest.xml @@ -1,6 +1,7 @@ + + NSCameraUsageDescription + Request camera access for barcode scanner CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleExecutable diff --git a/examples/api/src-tauri/src/lib.rs b/examples/api/src-tauri/src/lib.rs index f9d345678..5bb818519 100644 --- a/examples/api/src-tauri/src/lib.rs +++ b/examples/api/src-tauri/src/lib.rs @@ -12,7 +12,7 @@ mod cmd; mod tray; use serde::Serialize; -use tauri::{window::WindowBuilder, App, AppHandle, RunEvent, WindowUrl}; +use tauri::{window::WindowBuilder, App, AppHandle, Manager, RunEvent, WindowUrl}; #[derive(Clone, Serialize)] struct Reply { diff --git a/examples/api/src/App.svelte b/examples/api/src/App.svelte index 6c24851eb..040d1939b 100644 --- a/examples/api/src/App.svelte +++ b/examples/api/src/App.svelte @@ -72,7 +72,7 @@ component: Http, icon: "i-ph-globe-hemisphere-west", }, - !isMobile && { + { label: "Notifications", component: Notifications, icon: "i-codicon-bell-dot", @@ -92,7 +92,7 @@ component: Updater, icon: "i-codicon-cloud-download", }, - !isMobile && { + { label: "Clipboard", component: Clipboard, icon: "i-codicon-clippy", diff --git a/examples/api/src/views/Notifications.svelte b/examples/api/src/views/Notifications.svelte index 624561dfa..e01d57fcd 100644 --- a/examples/api/src/views/Notifications.svelte +++ b/examples/api/src/views/Notifications.svelte @@ -29,6 +29,6 @@ } - diff --git a/plugins/authenticator/CHANGELOG.md b/plugins/authenticator/CHANGELOG.md index 35880572d..03ac852c1 100644 --- a/plugins/authenticator/CHANGELOG.md +++ b/plugins/authenticator/CHANGELOG.md @@ -2,7 +2,7 @@ ## \[2.0.0-alpha.2] -- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.16. +- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.9. ## \[2.0.0-alpha.2] diff --git a/plugins/authenticator/Cargo.toml b/plugins/authenticator/Cargo.toml index 641cb39f9..0a1237a9d 100644 --- a/plugins/authenticator/Cargo.toml +++ b/plugins/authenticator/Cargo.toml @@ -8,7 +8,8 @@ edition = { workspace = true } rust-version = { workspace = true } [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = [ "--cfg", "docsrs" ] +rustdoc-args = [ "--cfg", "docsrs" ] [dependencies] serde = { workspace = true } diff --git a/plugins/authenticator/package.json b/plugins/authenticator/package.json index e9d24fc0b..6fb659e3c 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.9" + "@tauri-apps/api": "2.0.0-alpha.11" } } diff --git a/plugins/authenticator/src/api-iife.js b/plugins/authenticator/src/api-iife.js index c56017b87..42d197c3e 100644 --- a/plugins/authenticator/src/api-iife.js +++ b/plugins/authenticator/src/api-iife.js @@ -1 +1 @@ -if("__TAURI__"in window){var __TAURI_AUTHENTICATOR__=function(e){"use strict";var t=Object.defineProperty,n=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},i=(e,t,i)=>(n(e,t,"read from private field"),i?i.call(e):t.get(e));function a(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}((e,n)=>{for(var i in n)t(e,i,{get:n[i],enumerable:!0})})({},{Channel:()=>s,PluginListener:()=>c,addPluginListener:()=>l,convertFileSrc:()=>u,invoke:()=>o,transformCallback:()=>a});var r,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,r,(()=>{})),this.id=a((e=>{i(this,r).call(this,e)}))}set onmessage(e){var t,i,a,s;a=e,n(t=this,i=r,"write to private field"),s?s.call(t,a):i.set(t,a)}get onmessage(){return i(this,r)}toJSON(){return`__CHANNEL__:${this.id}`}};r=new WeakMap;var c=class{constructor(e,t,n){this.plugin=e,this.event=t,this.channelId=n}async unregister(){return o(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function l(e,t,n){let i=new s;return i.onmessage=n,o(`plugin:${e}|register_listener`,{event:t,handler:i}).then((()=>new c(e,t,i.id)))}async function o(e,t={},n){return window.__TAURI_INTERNALS__.invoke(e,t,n)}function u(e,t="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,t)}return e.Authenticator=class{async init(){return await o("plugin:authenticator|init_auth")}async register(e,t){return await o("plugin:authenticator|register",{timeout:1e4,challenge:e,application:t})}async verifyRegistration(e,t,n,i){return await o("plugin:authenticator|verify_registration",{challenge:e,application:t,registerData:n,clientData:i})}async sign(e,t,n){return await o("plugin:authenticator|sign",{timeout:1e4,challenge:e,application:t,keyHandle:n})}async verifySignature(e,t,n,i,a,r){return await o("plugin:authenticator|verify_signature",{challenge:e,application:t,signData:n,clientData:i,keyHandle:a,pubkey:r})}},e}({});Object.defineProperty(window.__TAURI__,"authenticator",{value:__TAURI_AUTHENTICATOR__})} +if("__TAURI__"in window){var __TAURI_AUTHENTICATOR__=function(t){"use strict";async function i(t,i={},a){return window.__TAURI_INTERNALS__.invoke(t,i,a)}"function"==typeof SuppressedError&&SuppressedError;return t.Authenticator=class{async init(){return await i("plugin:authenticator|init_auth")}async register(t,a){return await i("plugin:authenticator|register",{timeout:1e4,challenge:t,application:a})}async verifyRegistration(t,a,e,n){return await i("plugin:authenticator|verify_registration",{challenge:t,application:a,registerData:e,clientData:n})}async sign(t,a,e){return await i("plugin:authenticator|sign",{timeout:1e4,challenge:t,application:a,keyHandle:e})}async verifySignature(t,a,e,n,r,u){return await i("plugin:authenticator|verify_signature",{challenge:t,application:a,signData:e,clientData:n,keyHandle:r,pubkey:u})}},t}({});Object.defineProperty(window.__TAURI__,"authenticator",{value:__TAURI_AUTHENTICATOR__})} diff --git a/plugins/autostart/CHANGELOG.md b/plugins/autostart/CHANGELOG.md index 35880572d..03ac852c1 100644 --- a/plugins/autostart/CHANGELOG.md +++ b/plugins/autostart/CHANGELOG.md @@ -2,7 +2,7 @@ ## \[2.0.0-alpha.2] -- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.16. +- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.9. ## \[2.0.0-alpha.2] diff --git a/plugins/autostart/Cargo.toml b/plugins/autostart/Cargo.toml index 1f18e685e..3f11285dc 100644 --- a/plugins/autostart/Cargo.toml +++ b/plugins/autostart/Cargo.toml @@ -8,7 +8,8 @@ edition = { workspace = true } rust-version = { workspace = true } [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = [ "--cfg", "docsrs" ] +rustdoc-args = [ "--cfg", "docsrs" ] [dependencies] serde = { workspace = true } diff --git a/plugins/autostart/package.json b/plugins/autostart/package.json index 89f589178..3497620ad 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.9" + "@tauri-apps/api": "2.0.0-alpha.11" } } diff --git a/plugins/autostart/src/api-iife.js b/plugins/autostart/src/api-iife.js index 6d8798816..dad831483 100644 --- a/plugins/autostart/src/api-iife.js +++ b/plugins/autostart/src/api-iife.js @@ -1 +1 @@ -if("__TAURI__"in window){var __TAURI_AUTOSTART__=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));function a(e,n=!1){return window.__TAURI_INTERNALS__.transformCallback(e,n)}((e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})})({},{Channel:()=>s,PluginListener:()=>o,addPluginListener:()=>_,convertFileSrc:()=>c,invoke:()=>l,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){var n,r,a,s;a=e,t(n=this,r=i,"write to private field"),s?s.call(n,a):r.set(n,a)}get onmessage(){return r(this,i)}toJSON(){return`__CHANNEL__:${this.id}`}};i=new WeakMap;var o=class{constructor(e,n,t){this.plugin=e,this.event=n,this.channelId=t}async unregister(){return l(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function _(e,n,t){let r=new s;return r.onmessage=t,l(`plugin:${e}|register_listener`,{event:n,handler:r}).then((()=>new o(e,n,r.id)))}async function l(e,n={},t){return window.__TAURI_INTERNALS__.invoke(e,n,t)}function c(e,n="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,n)}return e.disable=async function(){await l("plugin:autostart|disable")},e.enable=async function(){await l("plugin:autostart|enable")},e.isEnabled=async function(){return await l("plugin:autostart|is_enabled")},e}({});Object.defineProperty(window.__TAURI__,"autostart",{value:__TAURI_AUTOSTART__})} +if("__TAURI__"in window){var __TAURI_AUTOSTART__=function(n){"use strict";async function t(n,t={},a){return window.__TAURI_INTERNALS__.invoke(n,t,a)}return"function"==typeof SuppressedError&&SuppressedError,n.disable=async function(){await t("plugin:autostart|disable")},n.enable=async function(){await t("plugin:autostart|enable")},n.isEnabled=async function(){return await t("plugin:autostart|is_enabled")},n}({});Object.defineProperty(window.__TAURI__,"autostart",{value:__TAURI_AUTOSTART__})} diff --git a/plugins/barcode-scanner/CHANGELOG.md b/plugins/barcode-scanner/CHANGELOG.md index 32af83e44..cbf9a277f 100644 --- a/plugins/barcode-scanner/CHANGELOG.md +++ b/plugins/barcode-scanner/CHANGELOG.md @@ -2,7 +2,7 @@ ## \[2.0.0-alpha.1] -- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.16. +- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.9. ## \[2.0.0-alpha.0] diff --git a/plugins/barcode-scanner/Cargo.toml b/plugins/barcode-scanner/Cargo.toml index 73da1d7ce..a5b21fa1a 100644 --- a/plugins/barcode-scanner/Cargo.toml +++ b/plugins/barcode-scanner/Cargo.toml @@ -9,7 +9,8 @@ rust-version = { workspace = true } links = "tauri-plugin-barcode-scanner" [package.metadata.docs.rs] -features = [ "dox" ] +rustc-args = [ "--cfg", "docsrs" ] +rustdoc-args = [ "--cfg", "docsrs" ] targets = [ "x86_64-linux-android" ] [build-dependencies] @@ -21,6 +22,3 @@ serde_json = { workspace = true } tauri = { workspace = true } log = { workspace = true } thiserror = { workspace = true } - -[features] -dox = [ "tauri/dox" ] diff --git a/plugins/barcode-scanner/android/src/main/java/BarcodeScannerPlugin.kt b/plugins/barcode-scanner/android/src/main/java/BarcodeScannerPlugin.kt index 5d8a01545..4728bad0e 100644 --- a/plugins/barcode-scanner/android/src/main/java/BarcodeScannerPlugin.kt +++ b/plugins/barcode-scanner/android/src/main/java/BarcodeScannerPlugin.kt @@ -37,6 +37,7 @@ import app.tauri.Logger import app.tauri.PermissionState import app.tauri.annotation.ActivityCallback import app.tauri.annotation.Command +import app.tauri.annotation.InvokeArg import app.tauri.annotation.Permission import app.tauri.annotation.PermissionCallback import app.tauri.annotation.TauriPlugin @@ -57,6 +58,13 @@ private const val PERMISSION_ALIAS_CAMERA = "camera" private const val PERMISSION_NAME = Manifest.permission.CAMERA private const val PREFS_PERMISSION_FIRST_TIME_ASKING = "PREFS_PERMISSION_FIRST_TIME_ASKING" +@InvokeArg +class ScanOptions { + var formats: Array? = null + var windowed: Boolean = false + var cameraDirection: String? = null +} + @TauriPlugin( permissions = [ Permission(strings = [Manifest.permission.CAMERA], alias = "camera") @@ -206,19 +214,12 @@ class BarcodeScannerPlugin(private val activity: Activity) : Plugin(activity), } } - private fun getFormats(invoke: Invoke): List { - val jsFormats = invoke.getArray("formats", JSArray()) + private fun getFormats(args: ScanOptions): List { val formats = ArrayList() - for (i in 0 until jsFormats.length()) { - try { - val targetedFormat: String = jsFormats.getString(i) - val targetedBarcodeFormat = - supportedFormats[targetedFormat] - if (targetedBarcodeFormat != null) { - formats.add(targetedBarcodeFormat) - } - } catch (e: JSONException) { - e.printStackTrace() + for (format in args.formats ?: arrayOf()) { + val targetedBarcodeFormat = supportedFormats[format] + if (targetedBarcodeFormat != null) { + formats.add(targetedBarcodeFormat) } } return formats @@ -341,14 +342,16 @@ class BarcodeScannerPlugin(private val activity: Activity) : Plugin(activity), @Command fun scan(invoke: Invoke) { + val args = invoke.parseArgs(ScanOptions::class.java) + savedInvoke = invoke if (hasCamera()) { if (getPermissionState("camera") != PermissionState.GRANTED) { throw Exception("No permission to use camera. Did you request it yet?") } else { webViewBackground = null - prepare(invoke.getString("cameraDirection", "back"), invoke.getBoolean("windowed", false)) - configureCamera(getFormats(invoke)) + prepare(args.cameraDirection ?: "back", args.windowed) + configureCamera(getFormats(args)) } } } diff --git a/plugins/barcode-scanner/build.rs b/plugins/barcode-scanner/build.rs index ea12ef852..da7cd3cc4 100644 --- a/plugins/barcode-scanner/build.rs +++ b/plugins/barcode-scanner/build.rs @@ -10,7 +10,7 @@ fn main() { { println!("{error:#}"); // when building documentation for Android the plugin build result is irrelevant to the crate itself - if !(cfg!(feature = "dox") && std::env::var("TARGET").unwrap().contains("android")) { + if !(cfg!(docsrs) && std::env::var("TARGET").unwrap().contains("android")) { std::process::exit(1); } } diff --git a/plugins/barcode-scanner/ios/Sources/BarcodeScannerPlugin.swift b/plugins/barcode-scanner/ios/Sources/BarcodeScannerPlugin.swift index b86f14887..7a329e374 100644 --- a/plugins/barcode-scanner/ios/Sources/BarcodeScannerPlugin.swift +++ b/plugins/barcode-scanner/ios/Sources/BarcodeScannerPlugin.swift @@ -7,7 +7,13 @@ import Tauri import UIKit import WebKit -enum SupportedFormat: String, CaseIterable { +struct ScanOptions: Decodable { + var formats: [SupportedFormat] = [] + let windowed: Bool? + let cameraDirection: String? +} + +enum SupportedFormat: String, CaseIterable, Decodable { // UPC_A not supported case UPC_E case EAN_8 @@ -232,19 +238,11 @@ class BarcodeScannerPlugin: Plugin, AVCaptureMetadataOutputObjectsDelegate { } } - private func runScanner(_ invoke: Invoke) { + private func runScanner(_ invoke: Invoke, args: ScanOptions) { scanFormats = [AVMetadataObject.ObjectType]() - if (invoke.data["formats"]) != nil { - let _scanFormats = invoke.getArray("formats", String.self) - - if _scanFormats != nil && _scanFormats?.count ?? 0 > 0 { - _scanFormats?.forEach { targetedFormat in - if let value = SupportedFormat(rawValue: targetedFormat)?.value { - scanFormats.append(value) - } - } - } + args.formats.forEach { format in + scanFormats.append(format.value) } if scanFormats.count == 0 { @@ -259,7 +257,9 @@ class BarcodeScannerPlugin: Plugin, AVCaptureMetadataOutputObjectsDelegate { self.isScanning = true } - @objc private func scan(_ invoke: Invoke) { + @objc private func scan(_ invoke: Invoke) throws { + let args = try invoke.parseArgs(ScanOptions.self) + self.invoke = invoke var iOS14min: Bool = false @@ -279,10 +279,10 @@ class BarcodeScannerPlugin: Plugin, AVCaptureMetadataOutputObjectsDelegate { self.loadCamera() self.dismantleCamera() self.setupCamera( - direction: invoke.getString("cameraDirection") ?? "back", - windowed: invoke.getBool("windowed") ?? false + direction: args.cameraDirection ?? "back", + windowed: args.windowed ?? false ) - self.runScanner(invoke) + self.runScanner(invoke, args: args) } } diff --git a/plugins/barcode-scanner/package.json b/plugins/barcode-scanner/package.json index 7b2a6abee..faef7f1db 100644 --- a/plugins/barcode-scanner/package.json +++ b/plugins/barcode-scanner/package.json @@ -28,6 +28,6 @@ "tslib": "^2.5.0" }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.9" + "@tauri-apps/api": "2.0.0-alpha.11" } } diff --git a/plugins/barcode-scanner/src/api-iife.js b/plugins/barcode-scanner/src/api-iife.js index adbdc978e..ec3a507cb 100644 --- a/plugins/barcode-scanner/src/api-iife.js +++ b/plugins/barcode-scanner/src/api-iife.js @@ -1 +1 @@ -if("__TAURI__"in window){var __TAURI_BARCODESCANNER__=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));function a(e,n=!1){return window.__TAURI_INTERNALS__.transformCallback(e,n)}((e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})})({},{Channel:()=>s,PluginListener:()=>o,addPluginListener:()=>_,convertFileSrc:()=>l,invoke:()=>u,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){var n,r,a,s;a=e,t(n=this,r=i,"write to private field"),s?s.call(n,a):r.set(n,a)}get onmessage(){return r(this,i)}toJSON(){return`__CHANNEL__:${this.id}`}};i=new WeakMap;var c,o=class{constructor(e,n,t){this.plugin=e,this.event=n,this.channelId=t}async unregister(){return u(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function _(e,n,t){let r=new s;return r.onmessage=t,u(`plugin:${e}|register_listener`,{event:n,handler:r}).then((()=>new o(e,n,r.id)))}async function u(e,n={},t){return window.__TAURI_INTERNALS__.invoke(e,n,t)}function l(e,n="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,n)}return e.Format=void 0,(c=e.Format||(e.Format={})).QRCode="QR_CODE",c.UPC_A="UPC_A",c.UPC_E="UPC_E",c.EAN8="EAN_8",c.EAN13="EAN_13",c.Code39="CODE_39",c.Code93="CODE_93",c.Code128="CODE_128",c.Codabar="CODABAR",c.ITF="ITF",c.Aztec="AZTEC",c.DataMatrix="DATA_MATRIX",c.PDF417="PDF_417",e.cancel=async function(){return await u("plugin:barcodeScanner|cancel")},e.checkPermissions=async function(){return await u("plugin:barcodeScanner|checkPermissions").then((e=>e.camera))},e.openAppSettings=async function(){return await u("plugin:barcodeScanner|openAppSettings")},e.requestPermissions=async function(){return await u("plugin:barcodeScanner|requestPermissions").then((e=>e.camera))},e.scan=async function(e){return await u("plugin:barcodeScanner|scan",{...e})},e}({});Object.defineProperty(window.__TAURI__,"barcodeScanner",{value:__TAURI_BARCODESCANNER__})} +if("__TAURI__"in window){var __TAURI_BARCODESCANNER__=function(n){"use strict";async function e(n,e={},r){return window.__TAURI_INTERNALS__.invoke(n,e,r)}var r;return"function"==typeof SuppressedError&&SuppressedError,n.Format=void 0,(r=n.Format||(n.Format={})).QRCode="QR_CODE",r.UPC_A="UPC_A",r.UPC_E="UPC_E",r.EAN8="EAN_8",r.EAN13="EAN_13",r.Code39="CODE_39",r.Code93="CODE_93",r.Code128="CODE_128",r.Codabar="CODABAR",r.ITF="ITF",r.Aztec="AZTEC",r.DataMatrix="DATA_MATRIX",r.PDF417="PDF_417",n.cancel=async function(){return await e("plugin:barcodeScanner|cancel")},n.checkPermissions=async function(){return await e("plugin:barcodeScanner|checkPermissions").then((n=>n.camera))},n.openAppSettings=async function(){return await e("plugin:barcodeScanner|openAppSettings")},n.requestPermissions=async function(){return await e("plugin:barcodeScanner|requestPermissions").then((n=>n.camera))},n.scan=async function(n){return await e("plugin:barcodeScanner|scan",{...n})},n}({});Object.defineProperty(window.__TAURI__,"barcodeScanner",{value:__TAURI_BARCODESCANNER__})} diff --git a/plugins/cli/CHANGELOG.md b/plugins/cli/CHANGELOG.md index 35880572d..03ac852c1 100644 --- a/plugins/cli/CHANGELOG.md +++ b/plugins/cli/CHANGELOG.md @@ -2,7 +2,7 @@ ## \[2.0.0-alpha.2] -- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.16. +- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.9. ## \[2.0.0-alpha.2] diff --git a/plugins/cli/Cargo.toml b/plugins/cli/Cargo.toml index 676f2e04b..3fc7e4e92 100644 --- a/plugins/cli/Cargo.toml +++ b/plugins/cli/Cargo.toml @@ -8,7 +8,8 @@ license = { workspace = true } rust-version = { workspace = true } [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = [ "--cfg", "docsrs" ] +rustdoc-args = [ "--cfg", "docsrs" ] [dependencies] serde = { workspace = true } diff --git a/plugins/cli/package.json b/plugins/cli/package.json index d3eeec6ab..e77d8dee9 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.9" + "@tauri-apps/api": "2.0.0-alpha.11" } } diff --git a/plugins/cli/src/api-iife.js b/plugins/cli/src/api-iife.js index 81e2042c1..270dfe803 100644 --- a/plugins/cli/src/api-iife.js +++ b/plugins/cli/src/api-iife.js @@ -1 +1 @@ -if("__TAURI__"in window){var __TAURI_CLI__=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));function i(e,n=!1){return window.__TAURI_INTERNALS__.transformCallback(e,n)}((e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})})({},{Channel:()=>s,PluginListener:()=>_,addPluginListener:()=>o,convertFileSrc:()=>l,invoke:()=>c,transformCallback:()=>i});var a,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,a,(()=>{})),this.id=i((e=>{r(this,a).call(this,e)}))}set onmessage(e){var n,r,i,s;i=e,t(n=this,r=a,"write to private field"),s?s.call(n,i):r.set(n,i)}get onmessage(){return r(this,a)}toJSON(){return`__CHANNEL__:${this.id}`}};a=new WeakMap;var _=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 o(e,n,t){let r=new s;return r.onmessage=t,c(`plugin:${e}|register_listener`,{event:n,handler:r}).then((()=>new _(e,n,r.id)))}async function c(e,n={},t){return window.__TAURI_INTERNALS__.invoke(e,n,t)}function l(e,n="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,n)}return e.getMatches=async function(){return await c("plugin:cli|cli_matches")},e}({});Object.defineProperty(window.__TAURI__,"cli",{value:__TAURI_CLI__})} +if("__TAURI__"in window){var __TAURI_CLI__=function(_){"use strict";return"function"==typeof SuppressedError&&SuppressedError,_.getMatches=async function(){return await async function(_,n={},e){return window.__TAURI_INTERNALS__.invoke(_,n,e)}("plugin:cli|cli_matches")},_}({});Object.defineProperty(window.__TAURI__,"cli",{value:__TAURI_CLI__})} diff --git a/plugins/clipboard-manager/CHANGELOG.md b/plugins/clipboard-manager/CHANGELOG.md index 35880572d..03ac852c1 100644 --- a/plugins/clipboard-manager/CHANGELOG.md +++ b/plugins/clipboard-manager/CHANGELOG.md @@ -2,7 +2,7 @@ ## \[2.0.0-alpha.2] -- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.16. +- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.9. ## \[2.0.0-alpha.2] diff --git a/plugins/clipboard-manager/Cargo.toml b/plugins/clipboard-manager/Cargo.toml index c6173b890..fdda8e97d 100644 --- a/plugins/clipboard-manager/Cargo.toml +++ b/plugins/clipboard-manager/Cargo.toml @@ -9,7 +9,8 @@ rust-version = { workspace = true } links = "tauri-plugin-clipboard-manager" [package.metadata.docs.rs] -features = [ "dox" ] +rustc-args = [ "--cfg", "docsrs" ] +rustdoc-args = [ "--cfg", "docsrs" ] targets = [ "x86_64-unknown-linux-gnu", "x86_64-linux-android" ] [build-dependencies] @@ -24,6 +25,3 @@ thiserror = { workspace = true } [target."cfg(any(target_os = \"macos\", windows, target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies] arboard = "3" - -[features] -dox = [ "tauri/dox" ] diff --git a/plugins/clipboard-manager/android/build.gradle.kts b/plugins/clipboard-manager/android/build.gradle.kts index b3c3ec322..b3caf13ef 100644 --- a/plugins/clipboard-manager/android/build.gradle.kts +++ b/plugins/clipboard-manager/android/build.gradle.kts @@ -38,6 +38,7 @@ dependencies { implementation("androidx.core:core-ktx:1.9.0") implementation("androidx.appcompat:appcompat:1.6.0") implementation("com.google.android.material:material:1.7.0") + implementation("com.fasterxml.jackson.core:jackson-databind:2.15.3") testImplementation("junit:junit:4.13.2") androidTestImplementation("androidx.test.ext:junit:1.1.5") androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") diff --git a/plugins/clipboard-manager/android/src/main/java/ClipboardPlugin.kt b/plugins/clipboard-manager/android/src/main/java/ClipboardPlugin.kt index 8f622251c..432e337e8 100644 --- a/plugins/clipboard-manager/android/src/main/java/ClipboardPlugin.kt +++ b/plugins/clipboard-manager/android/src/main/java/ClipboardPlugin.kt @@ -11,11 +11,74 @@ import android.content.ClipDescription import android.content.ClipboardManager import android.content.Context import app.tauri.annotation.Command +import app.tauri.annotation.InvokeArg import app.tauri.annotation.TauriPlugin import app.tauri.plugin.Invoke -import app.tauri.plugin.JSObject import app.tauri.plugin.Plugin +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.JsonParser +import com.fasterxml.jackson.core.JsonProcessingException +import com.fasterxml.jackson.databind.DeserializationContext +import com.fasterxml.jackson.databind.JsonDeserializer +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.ser.std.StdSerializer +import java.io.IOException +@InvokeArg +@JsonDeserialize(using = WriteOptionsDeserializer::class) +sealed class WriteOptions { + @JsonDeserialize + class PlainText: WriteOptions() { + lateinit var text: String + var label: String? = null + } +} + +@JsonSerialize(using = ReadClipDataSerializer::class) +sealed class ReadClipData { + class PlainText: ReadClipData() { + lateinit var text: String + } +} + +internal class ReadClipDataSerializer @JvmOverloads constructor(t: Class? = null) : + StdSerializer(t) { + @Throws(IOException::class, JsonProcessingException::class) + override fun serialize( + value: ReadClipData, jgen: JsonGenerator, provider: SerializerProvider + ) { + jgen.writeStartObject() + when (value) { + is ReadClipData.PlainText -> { + jgen.writeObjectFieldStart("plainText") + + jgen.writeStringField("text", value.text) + + jgen.writeEndObject() + } + else -> {} + } + + jgen.writeEndObject() + } +} + +internal class WriteOptionsDeserializer: JsonDeserializer() { + override fun deserialize( + jsonParser: JsonParser, + deserializationContext: DeserializationContext + ): WriteOptions { + val node: JsonNode = jsonParser.codec.readTree(jsonParser) + node.get("plainText")?.let { + return jsonParser.codec.treeToValue(it, WriteOptions.PlainText::class.java) + } ?: run { + throw Error("unknown write options $node") + } + } +} @TauriPlugin class ClipboardPlugin(private val activity: Activity) : Plugin(activity) { @@ -25,22 +88,14 @@ class ClipboardPlugin(private val activity: Activity) : Plugin(activity) { @Command @Suppress("MoveVariableDeclarationIntoWhen") fun write(invoke: Invoke) { - val options = invoke.getObject("options") - if (options == null) { - invoke.reject("Missing `options` input") - return - } - val kind = invoke.getString("kind", "") + val args = invoke.parseArgs(WriteOptions::class.java) - val clipData = when (kind) { - "PlainText" -> { - val label = options.getString("label", "") - val text = options.getString("text", "") - ClipData.newPlainText(label, text) + val clipData = when (args) { + is WriteOptions.PlainText -> { + ClipData.newPlainText(args.label, args.text) } - else -> { - invoke.reject("Unknown kind $kind") + invoke.reject("unimplemented clip data") return } } @@ -52,10 +107,12 @@ class ClipboardPlugin(private val activity: Activity) : Plugin(activity) { @Command fun read(invoke: Invoke) { - val (kind, options) = if (manager.hasPrimaryClip()) { + val data = if (manager.hasPrimaryClip()) { if (manager.primaryClipDescription?.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN) == true) { val item: ClipData.Item = manager.primaryClip!!.getItemAt(0) - Pair("PlainText", item.text) + val data = ReadClipData.PlainText() + data.text = item.text.toString() + data } else { // TODO invoke.reject("Clipboard content reader not implemented") @@ -66,9 +123,6 @@ class ClipboardPlugin(private val activity: Activity) : Plugin(activity) { return } - val response = JSObject() - response.put("kind", kind) - response.put("options", options) - invoke.resolve(response) + invoke.resolveObject(data) } } diff --git a/plugins/clipboard-manager/build.rs b/plugins/clipboard-manager/build.rs index ea12ef852..da7cd3cc4 100644 --- a/plugins/clipboard-manager/build.rs +++ b/plugins/clipboard-manager/build.rs @@ -10,7 +10,7 @@ fn main() { { println!("{error:#}"); // when building documentation for Android the plugin build result is irrelevant to the crate itself - if !(cfg!(feature = "dox") && std::env::var("TARGET").unwrap().contains("android")) { + if !(cfg!(docsrs) && std::env::var("TARGET").unwrap().contains("android")) { std::process::exit(1); } } diff --git a/plugins/clipboard-manager/guest-js/index.ts b/plugins/clipboard-manager/guest-js/index.ts index 04f84a9d1..c45a26421 100644 --- a/plugins/clipboard-manager/guest-js/index.ts +++ b/plugins/clipboard-manager/guest-js/index.ts @@ -10,12 +10,7 @@ import { invoke } from "@tauri-apps/api/primitives"; -interface Clip { - kind: K; - options: T; -} - -type ClipResponse = Clip<"PlainText", string>; +type ClipResponse = Record<"plainText", { text: string }>; /** * Writes plain text to the clipboard. @@ -36,8 +31,7 @@ async function writeText( ): Promise { return invoke("plugin:clipboard|write", { data: { - kind: "PlainText", - options: { + plainText: { label: opts?.label, text, }, @@ -56,7 +50,7 @@ async function writeText( */ async function readText(): Promise { const kind: ClipResponse = await invoke("plugin:clipboard|read"); - return kind.options; + return kind.plainText.text; } export { writeText, readText }; diff --git a/plugins/clipboard-manager/ios/Sources/ClipboardPlugin.swift b/plugins/clipboard-manager/ios/Sources/ClipboardPlugin.swift index 5f84aa654..30729d530 100644 --- a/plugins/clipboard-manager/ios/Sources/ClipboardPlugin.swift +++ b/plugins/clipboard-manager/ios/Sources/ClipboardPlugin.swift @@ -2,42 +2,42 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT +import SwiftRs +import Tauri import UIKit import WebKit -import Tauri -import SwiftRs + +enum WriteOptions: Codable { + case plainText(text: String) +} + +enum ReadClipData: Codable { + case plainText(text: String) +} class ClipboardPlugin: Plugin { - @objc public func write(_ invoke: Invoke) throws { - let options = invoke.getObject("options") - if let options = options { - let clipboard = UIPasteboard.general - let kind = invoke.getString("kind", "") - switch kind { - case "PlainText": - let text = options["text"] as? String - clipboard.string = text - default: - invoke.reject("Unknown kind \(kind)") - return - } - invoke.resolve() - } else { - invoke.reject("Missing `options` input") - } - } + @objc public func write(_ invoke: Invoke) throws { + let options = try invoke.parseArgs(WriteOptions.self) + let clipboard = UIPasteboard.general + switch options { + case .plainText(let text): + clipboard.string = text + default: + invoke.unimplemented() + return + } + invoke.resolve() + + } - @objc public func read(_ invoke: Invoke) throws { - let clipboard = UIPasteboard.general - if let text = clipboard.string { - invoke.resolve([ - "kind": "PlainText", - "options": text - ]) - } else { - invoke.reject("Clipboard is empty") - } - } + @objc public func read(_ invoke: Invoke) throws { + let clipboard = UIPasteboard.general + if let text = clipboard.string { + invoke.resolve(ReadClipData.plainText(text: text)) + } else { + invoke.reject("Clipboard is empty") + } + } } @_cdecl("init_plugin_clipboard") diff --git a/plugins/clipboard-manager/package.json b/plugins/clipboard-manager/package.json index 98aba2cf9..dc69adc25 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.9" + "@tauri-apps/api": "2.0.0-alpha.11" } } diff --git a/plugins/clipboard-manager/src/api-iife.js b/plugins/clipboard-manager/src/api-iife.js index 1f5f76079..b865ef294 100644 --- a/plugins/clipboard-manager/src/api-iife.js +++ b/plugins/clipboard-manager/src/api-iife.js @@ -1 +1 @@ -if("__TAURI__"in window){var __TAURI_CLIPBOARDMANAGER__=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));function i(e,n=!1){return window.__TAURI_INTERNALS__.transformCallback(e,n)}((e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})})({},{Channel:()=>s,PluginListener:()=>o,addPluginListener:()=>_,convertFileSrc:()=>c,invoke:()=>l,transformCallback:()=>i});var a,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,a,(()=>{})),this.id=i((e=>{r(this,a).call(this,e)}))}set onmessage(e){var n,r,i,s;i=e,t(n=this,r=a,"write to private field"),s?s.call(n,i):r.set(n,i)}get onmessage(){return r(this,a)}toJSON(){return`__CHANNEL__:${this.id}`}};a=new WeakMap;var o=class{constructor(e,n,t){this.plugin=e,this.event=n,this.channelId=t}async unregister(){return l(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function _(e,n,t){let r=new s;return r.onmessage=t,l(`plugin:${e}|register_listener`,{event:n,handler:r}).then((()=>new o(e,n,r.id)))}async function l(e,n={},t){return window.__TAURI_INTERNALS__.invoke(e,n,t)}function c(e,n="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,n)}return e.readText=async function(){return(await l("plugin:clipboard|read")).options},e.writeText=async function(e,n){return l("plugin:clipboard|write",{data:{kind:"PlainText",options:{label:null==n?void 0:n.label,text:e}}})},e}({});Object.defineProperty(window.__TAURI__,"clipboardManager",{value:__TAURI_CLIPBOARDMANAGER__})} +if("__TAURI__"in window){var __TAURI_CLIPBOARDMANAGER__=function(e){"use strict";async function n(e,n={},r){return window.__TAURI_INTERNALS__.invoke(e,n,r)}return"function"==typeof SuppressedError&&SuppressedError,e.readText=async function(){return(await n("plugin:clipboard|read")).plainText.text},e.writeText=async function(e,r){return n("plugin:clipboard|write",{data:{plainText:{label:null==r?void 0:r.label,text:e}}})},e}({});Object.defineProperty(window.__TAURI__,"clipboardManager",{value:__TAURI_CLIPBOARDMANAGER__})} diff --git a/plugins/clipboard-manager/src/desktop.rs b/plugins/clipboard-manager/src/desktop.rs index 8fcc8450b..555321dc1 100644 --- a/plugins/clipboard-manager/src/desktop.rs +++ b/plugins/clipboard-manager/src/desktop.rs @@ -39,7 +39,7 @@ impl Clipboard { match &self.clipboard { Ok(clipboard) => { let text = clipboard.lock().unwrap().get_text()?; - Ok(ClipboardContents::PlainText(text)) + Ok(ClipboardContents::PlainText { text }) } Err(e) => Err(crate::Error::Clipboard(e.to_string())), } diff --git a/plugins/clipboard-manager/src/models.rs b/plugins/clipboard-manager/src/models.rs index c73daf934..a223a679d 100644 --- a/plugins/clipboard-manager/src/models.rs +++ b/plugins/clipboard-manager/src/models.rs @@ -5,13 +5,13 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize)] -#[serde(tag = "kind", content = "options")] +#[serde(rename_all = "camelCase")] pub enum ClipKind { PlainText { label: Option, text: String }, } #[derive(Debug, Serialize, Deserialize)] -#[serde(tag = "kind", content = "options")] +#[serde(rename_all = "camelCase")] pub enum ClipboardContents { - PlainText(String), + PlainText { text: String }, } diff --git a/plugins/deep-link/CHANGELOG.md b/plugins/deep-link/CHANGELOG.md index e8f2c06f7..09145db47 100644 --- a/plugins/deep-link/CHANGELOG.md +++ b/plugins/deep-link/CHANGELOG.md @@ -2,7 +2,7 @@ ## \[2.0.0-alpha.1] -- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.16. +- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.9. ## \[2.0.0-alpha.0] diff --git a/plugins/deep-link/Cargo.toml b/plugins/deep-link/Cargo.toml index ecee67456..992288cac 100644 --- a/plugins/deep-link/Cargo.toml +++ b/plugins/deep-link/Cargo.toml @@ -9,7 +9,8 @@ rust-version = { workspace = true } links = "tauri-plugin-deep-link" [package.metadata.docs.rs] -features = [ "dox" ] +rustc-args = [ "--cfg", "docsrs" ] +rustdoc-args = [ "--cfg", "docsrs" ] targets = [ "x86_64-linux-android" ] [build-dependencies] @@ -24,6 +25,3 @@ tauri = { workspace = true } log = { workspace = true } thiserror = { workspace = true } url = "2" - -[features] -dox = [ "tauri/dox" ] diff --git a/plugins/deep-link/android/src/main/java/DeepLinkPlugin.kt b/plugins/deep-link/android/src/main/java/DeepLinkPlugin.kt index 4b52f7f31..58bc70c74 100644 --- a/plugins/deep-link/android/src/main/java/DeepLinkPlugin.kt +++ b/plugins/deep-link/android/src/main/java/DeepLinkPlugin.kt @@ -6,8 +6,10 @@ package app.tauri.deep_link import android.app.Activity import android.content.Intent +import android.os.Bundle import android.webkit.WebView import app.tauri.Logger +import app.tauri.annotation.InvokeArg import app.tauri.annotation.Command import app.tauri.annotation.TauriPlugin import app.tauri.plugin.Channel @@ -15,6 +17,11 @@ import app.tauri.plugin.JSObject import app.tauri.plugin.Plugin import app.tauri.plugin.Invoke +@InvokeArg +class SetEventHandlerArgs { + lateinit var handler: Channel +} + @TauriPlugin class DeepLinkPlugin(private val activity: Activity): Plugin(activity) { //private val implementation = Example() @@ -33,29 +40,17 @@ class DeepLinkPlugin(private val activity: Activity): Plugin(activity) { invoke.resolve(ret) } - /* @Command - fun registerListenerRust(invoke: Invoke) { - val value = invoke.getString("value") ?: "" - val ret = JSObject() - ret.put("value", this.currentUrl ?: "none") - invoke.resolve(ret) - } */ - @Command fun setEventHandler(invoke: Invoke) { - val channel = invoke.getChannel("handler") - - if (channel == null) { - invoke.reject("`handler` not provided") - } - this.channel = channel + val args = invoke.parseArgs(SetEventHandlerArgs::class.java) + this.channel = args.handler invoke.resolve() } override fun load(webView: WebView) { instance = this - var intent = activity.intent + val intent = activity.intent if (intent.action == Intent.ACTION_VIEW) { // TODO: check if it makes sense to split up init url and last url diff --git a/plugins/deep-link/build.rs b/plugins/deep-link/build.rs index f34520878..6e06ccadd 100644 --- a/plugins/deep-link/build.rs +++ b/plugins/deep-link/build.rs @@ -35,7 +35,7 @@ fn main() { .run() { println!("{error:#}"); - if !(cfg!(feature = "dox") && std::env::var("TARGET").unwrap().contains("android")) { + if !(cfg!(docsrs) && std::env::var("TARGET").unwrap().contains("android")) { std::process::exit(1); } } diff --git a/plugins/deep-link/examples/app/package.json b/plugins/deep-link/examples/app/package.json index c86ace99e..b6f80a57e 100644 --- a/plugins/deep-link/examples/app/package.json +++ b/plugins/deep-link/examples/app/package.json @@ -10,11 +10,11 @@ "tauri": "tauri" }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.6", + "@tauri-apps/api": "2.0.0-alpha.11", "@tauri-apps/plugin-deep-link": "2.0.0-alpha.1" }, "devDependencies": { - "@tauri-apps/cli": "2.0.0-alpha.16", + "@tauri-apps/cli": "2.0.0-alpha.17", "internal-ip": "^8.0.0", "typescript": "^5.2.2", "vite": "^4.5.0" diff --git a/plugins/deep-link/package.json b/plugins/deep-link/package.json index bfc8d0ae8..f59c99452 100644 --- a/plugins/deep-link/package.json +++ b/plugins/deep-link/package.json @@ -28,6 +28,6 @@ "tslib": "^2.5.0" }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.9" + "@tauri-apps/api": "2.0.0-alpha.11" } } diff --git a/plugins/deep-link/src/api-iife.js b/plugins/deep-link/src/api-iife.js index ba2d5b233..2f427a575 100644 --- a/plugins/deep-link/src/api-iife.js +++ b/plugins/deep-link/src/api-iife.js @@ -1 +1 @@ -if("__TAURI__"in window){var __TAURI_DEEPLINK__=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)},i=(e,n,t)=>(r(e,n,"read from private field"),t?t.call(e):n.get(e));function a(e,n=!1){return window.__TAURI_INTERNALS__.transformCallback(e,n)}t({},{Channel:()=>s,PluginListener:()=>u,addPluginListener:()=>o,convertFileSrc:()=>c,invoke:()=>l,transformCallback:()=>a});var _,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,_,(()=>{})),this.id=a((e=>{i(this,_).call(this,e)}))}set onmessage(e){((e,n,t,i)=>{r(e,n,"write to private field"),i?i.call(e,t):n.set(e,t)})(this,_,e)}get onmessage(){return i(this,_)}toJSON(){return`__CHANNEL__:${this.id}`}};_=new WeakMap;var u=class{constructor(e,n,t){this.plugin=e,this.event=n,this.channelId=t}async unregister(){return l(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function o(e,n,t){let r=new s;return r.onmessage=t,l(`plugin:${e}|register_listener`,{event:n,handler:r}).then((()=>new u(e,n,r.id)))}async function l(e,n={},t){return window.__TAURI_INTERNALS__.invoke(e,n,t)}function c(e,n="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,n)}t({},{TauriEvent:()=>d,emit:()=>v,listen:()=>h,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 E(e,n){await l("plugin:event|unlisten",{event:e,eventId:n})}async function h(e,n,t){return l("plugin:event|listen",{event:e,windowLabel:t?.target,handler:a(n)}).then((n=>async()=>E(e,n)))}async function I(e,n,t){return h(e,(t=>{n(t),E(e,t.id).catch((()=>{}))}),t)}async function v(e,n,t){await l("plugin:event|emit",{event:e,windowLabel:t?.target,payload:n})}async function N(){return await l("plugin:deep-link|get_current")}return e.getCurrent=N,e.onOpenUrl=async function(e){const n=await N();return null!=n&&e(n),await h("deep-link://new-url",(n=>e(n.payload)))},e}({});Object.defineProperty(window.__TAURI__,"deepLink",{value:__TAURI_DEEPLINK__})} +if("__TAURI__"in window){var __TAURI_DEEPLINK__=function(e){"use strict";function n(e,n=!1){return window.__TAURI_INTERNALS__.transformCallback(e,n)}async function r(e,n={},r){return window.__TAURI_INTERNALS__.invoke(e,n,r)}var t;async function _(e,t,_){return r("plugin:event|listen",{event:e,windowLabel:_?.target,handler:n(t)}).then((n=>async()=>async function(e,n){await r("plugin:event|unlisten",{event:e,eventId:n})}(e,n)))}async function i(){return await r("plugin:deep-link|get_current")}return"function"==typeof SuppressedError&&SuppressedError,function(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"}(t||(t={})),e.getCurrent=i,e.onOpenUrl=async function(e){const n=await i();return null!=n&&e(n),await _("deep-link://new-url",(n=>e(n.payload)))},e}({});Object.defineProperty(window.__TAURI__,"deepLink",{value:__TAURI_DEEPLINK__})} diff --git a/plugins/deep-link/src/lib.rs b/plugins/deep-link/src/lib.rs index 597a7e266..75223dcad 100644 --- a/plugins/deep-link/src/lib.rs +++ b/plugins/deep-link/src/lib.rs @@ -141,7 +141,7 @@ pub fn init() -> TauriPlugin> { .on_event(|_app, _event| { #[cfg(any(target_os = "macos", target_os = "ios"))] if let tauri::RunEvent::Opened { urls } = _event { - let _ = _app.emit_all("deep-link://new-url", urls); + let _ = _app.emit("deep-link://new-url", urls); _app.state::>() .current .lock() diff --git a/plugins/dialog/CHANGELOG.md b/plugins/dialog/CHANGELOG.md index 9c3d89c99..4299e9016 100644 --- a/plugins/dialog/CHANGELOG.md +++ b/plugins/dialog/CHANGELOG.md @@ -2,7 +2,7 @@ ## \[2.0.0-alpha.2] -- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.16. +- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.9. ## \[2.0.0-alpha.2] diff --git a/plugins/dialog/Cargo.toml b/plugins/dialog/Cargo.toml index e12b4c955..fc2c6c6b8 100644 --- a/plugins/dialog/Cargo.toml +++ b/plugins/dialog/Cargo.toml @@ -9,7 +9,8 @@ rust-version = { workspace = true } links = "tauri-plugin-dialog" [package.metadata.docs.rs] -features = [ "dox" ] +rustc-args = [ "--cfg", "docsrs" ] +rustdoc-args = [ "--cfg", "docsrs" ] targets = [ "x86_64-unknown-linux-gnu", "x86_64-linux-android" ] [dependencies] @@ -24,11 +25,8 @@ tauri-plugin-fs = { path = "../fs", version = "2.0.0-alpha.3" } glib = "0.16" [target."cfg(any(target_os = \"macos\", windows, target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies] -rfd = { version = "0.11", features = [ "gtk3", "common-controls-v6" ] } +rfd = { version = "0.12", features = [ "gtk3", "common-controls-v6" ] } raw-window-handle = "0.5" [build-dependencies] tauri-build = { workspace = true } - -[features] -dox = [ "tauri/dox" ] diff --git a/plugins/dialog/android/src/main/java/DialogPlugin.kt b/plugins/dialog/android/src/main/java/DialogPlugin.kt index 8806de6dd..e56011d43 100644 --- a/plugins/dialog/android/src/main/java/DialogPlugin.kt +++ b/plugins/dialog/android/src/main/java/DialogPlugin.kt @@ -14,24 +14,44 @@ import androidx.activity.result.ActivityResult import app.tauri.Logger import app.tauri.annotation.ActivityCallback import app.tauri.annotation.Command +import app.tauri.annotation.InvokeArg import app.tauri.annotation.TauriPlugin import app.tauri.plugin.Invoke import app.tauri.plugin.JSArray import app.tauri.plugin.JSObject import app.tauri.plugin.Plugin -import org.json.JSONException +@InvokeArg +class Filter { + lateinit var extensions: Array +} + +@InvokeArg +class FilePickerOptions { + lateinit var filters: Array + var multiple: Boolean? = null + var readData: Boolean? = null +} + +@InvokeArg +class MessageOptions { + var title: String? + lateinit var message: String + var okButtonLabel: String? + var cancelButtonLabel: String? +} @TauriPlugin class DialogPlugin(private val activity: Activity): Plugin(activity) { + var filePickerOptions: FilePickerOptions? = null + @Command fun showFilePicker(invoke: Invoke) { try { - val filters = invoke.getArray("filters", JSArray()) - val multiple = invoke.getBoolean("multiple", false) - val parsedTypes = parseFiltersOption(filters) + val args = invoke.parseArgs(FilePickerOptions::class.java) + val parsedTypes = parseFiltersOption(args.filters) - val intent = if (parsedTypes != null && parsedTypes.isNotEmpty()) { + val intent = if (parsedTypes.isNotEmpty()) { val intent = Intent(Intent.ACTION_PICK) intent.putExtra(Intent.EXTRA_MIME_TYPES, parsedTypes) @@ -55,7 +75,7 @@ class DialogPlugin(private val activity: Activity): Plugin(activity) { intent } - intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, multiple) + intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, args.multiple ?: false) startActivityForResult(invoke, intent, "filePickerResult") } catch (ex: Exception) { @@ -68,10 +88,9 @@ class DialogPlugin(private val activity: Activity): Plugin(activity) { @ActivityCallback fun filePickerResult(invoke: Invoke, result: ActivityResult) { try { - val readData = invoke.getBoolean("readData", false) when (result.resultCode) { Activity.RESULT_OK -> { - val callResult = createPickFilesResult(result.data, readData) + val callResult = createPickFilesResult(result.data, filePickerOptions?.readData ?: false) invoke.resolve(callResult) } Activity.RESULT_CANCELED -> invoke.reject("File picker cancelled") @@ -130,36 +149,19 @@ class DialogPlugin(private val activity: Activity): Plugin(activity) { return callResult } - private fun parseFiltersOption(filters: JSArray): Array? { - return try { - val filtersList: List = filters.toList() - val mimeTypes = mutableListOf() - for (filter in filtersList) { - val extensionsList = filter.getJSONArray("extensions") - for (i in 0 until extensionsList.length()) { - val mime = extensionsList.getString(i) - mimeTypes.add(if (mime == "text/csv") "text/comma-separated-values" else mime) - } + private fun parseFiltersOption(filters: Array): Array { + val mimeTypes = mutableListOf() + for (filter in filters) { + for (mime in filter.extensions) { + mimeTypes.add(if (mime == "text/csv") "text/comma-separated-values" else mime) } - - mimeTypes.toTypedArray() - } catch (exception: JSONException) { - Logger.error("parseTypesOption failed.", exception) - null } + return mimeTypes.toTypedArray() } @Command fun showMessageDialog(invoke: Invoke) { - val title = invoke.getString("title") - val message = invoke.getString("message") - val okButtonLabel = invoke.getString("okButtonLabel", "OK") - val cancelButtonLabel = invoke.getString("cancelButtonLabel", "Cancel") - - if (message == null) { - invoke.reject("The `message` argument is required") - return - } + val args = invoke.parseArgs(MessageOptions::class.java) if (activity.isFinishing) { invoke.reject("App is finishing") @@ -177,19 +179,19 @@ class DialogPlugin(private val activity: Activity): Plugin(activity) { .post { val builder = AlertDialog.Builder(activity) - if (title != null) { - builder.setTitle(title) + if (args.title != null) { + builder.setTitle(args.title) } builder - .setMessage(message) + .setMessage(args.message) .setPositiveButton( - okButtonLabel + args.okButtonLabel ?: "OK" ) { dialog, _ -> dialog.dismiss() handler(false, true) } .setNegativeButton( - cancelButtonLabel + args.cancelButtonLabel ?: "Cancel" ) { dialog, _ -> dialog.dismiss() handler(false, false) diff --git a/plugins/dialog/build.rs b/plugins/dialog/build.rs index ea12ef852..da7cd3cc4 100644 --- a/plugins/dialog/build.rs +++ b/plugins/dialog/build.rs @@ -10,7 +10,7 @@ fn main() { { println!("{error:#}"); // when building documentation for Android the plugin build result is irrelevant to the crate itself - if !(cfg!(feature = "dox") && std::env::var("TARGET").unwrap().contains("android")) { + if !(cfg!(docsrs) && std::env::var("TARGET").unwrap().contains("android")) { std::process::exit(1); } } diff --git a/plugins/dialog/ios/Sources/DialogPlugin.swift b/plugins/dialog/ios/Sources/DialogPlugin.swift index ef1dff717..40f515718 100644 --- a/plugins/dialog/ios/Sources/DialogPlugin.swift +++ b/plugins/dialog/ios/Sources/DialogPlugin.swift @@ -2,207 +2,223 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import UIKit import MobileCoreServices -import PhotosUI import Photos -import WebKit -import Tauri +import PhotosUI import SwiftRs +import Tauri +import UIKit +import WebKit enum FilePickerEvent { - case selected([URL]) - case cancelled - case error(String) + case selected([URL]) + case cancelled + case error(String) +} + +struct MessageDialogOptions: Decodable { + let title: String? + let message: String + var okButtonLabel = "OK" + var cancelButtonLabel = "Cancel" +} + +struct Filter: Decodable { + var extensions: [String] = [] +} + +struct FilePickerOptions: Decodable { + var multiple = false + var readData = false + var filters: [Filter] = [] } class DialogPlugin: Plugin { - var filePickerController: FilePickerController! - var pendingInvoke: Invoke? = nil - - override init() { - super.init() - filePickerController = FilePickerController(self) - } - - @objc public func showFilePicker(_ invoke: Invoke) { - let multiple = invoke.getBool("multiple", false) - let filters = invoke.getArray("filters") ?? [] - let parsedTypes = parseFiltersOption(filters) - - var isMedia = true - var uniqueMimeType: Bool? = nil - var mimeKind: String? = nil - if !parsedTypes.isEmpty { - uniqueMimeType = true - for mime in parsedTypes { - let kind = mime.components(separatedBy: "/")[0] - if kind != "image" && kind != "video" { - isMedia = false - } - if (mimeKind == nil) { - mimeKind = kind - } else if (mimeKind != kind) { - uniqueMimeType = false - } + var filePickerController: FilePickerController! + var pendingInvoke: Invoke? = nil + var pendingInvokeArgs: FilePickerOptions? = nil + + override init() { + super.init() + filePickerController = FilePickerController(self) + } + + @objc public func showFilePicker(_ invoke: Invoke) throws { + let args = try invoke.parseArgs(FilePickerOptions.self) + + let parsedTypes = parseFiltersOption(args.filters) + + var isMedia = true + var uniqueMimeType: Bool? = nil + var mimeKind: String? = nil + if !parsedTypes.isEmpty { + uniqueMimeType = true + for mime in parsedTypes { + let kind = mime.components(separatedBy: "/")[0] + if kind != "image" && kind != "video" { + isMedia = false + } + if mimeKind == nil { + mimeKind = kind + } else if mimeKind != kind { + uniqueMimeType = false + } } - } - - pendingInvoke = invoke - - if uniqueMimeType == true || isMedia { - DispatchQueue.main.async { - if #available(iOS 14, *) { - var configuration = PHPickerConfiguration(photoLibrary: PHPhotoLibrary.shared()) - configuration.selectionLimit = multiple ? 0 : 1 - - if uniqueMimeType == true { - if mimeKind == "image" { - configuration.filter = .images - } else if mimeKind == "video" { - configuration.filter = .videos - } - } - - let picker = PHPickerViewController(configuration: configuration) - picker.delegate = self.filePickerController - picker.modalPresentationStyle = .fullScreen - self.presentViewController(picker) - } else { - let picker = UIImagePickerController() - picker.delegate = self.filePickerController - - if uniqueMimeType == true && mimeKind == "image" { - picker.sourceType = .photoLibrary - } - - picker.sourceType = .photoLibrary - picker.modalPresentationStyle = .fullScreen - self.presentViewController(picker) - } - } - } else { - let documentTypes = parsedTypes.isEmpty ? ["public.data"] : parsedTypes - DispatchQueue.main.async { - let picker = UIDocumentPickerViewController(documentTypes: documentTypes, in: .import) - picker.delegate = self.filePickerController - picker.allowsMultipleSelection = multiple - picker.modalPresentationStyle = .fullScreen - self.presentViewController(picker) - } - } - } - - private func presentViewController(_ viewControllerToPresent: UIViewController) { - self.manager.viewController?.present(viewControllerToPresent, animated: true, completion: nil) - } - - private func parseFiltersOption(_ filters: JSArray) -> [String] { - var parsedTypes: [String] = [] - for (_, filter) in filters.enumerated() { - let filterObj = filter as? JSObject - if let filterObj = filterObj { - let extensions = filterObj["extensions"] as? JSArray - if let extensions = extensions { - for e in extensions { - let ext = e as? String ?? "" - guard let utType: String = UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, ext as CFString, nil)?.takeRetainedValue() as String? else { - continue - } - parsedTypes.append(utType) - } - } - } - } - return parsedTypes + } + + pendingInvoke = invoke + pendingInvokeArgs = args + + if uniqueMimeType == true || isMedia { + DispatchQueue.main.async { + if #available(iOS 14, *) { + var configuration = PHPickerConfiguration(photoLibrary: PHPhotoLibrary.shared()) + configuration.selectionLimit = args.multiple ? 0 : 1 + + if uniqueMimeType == true { + if mimeKind == "image" { + configuration.filter = .images + } else if mimeKind == "video" { + configuration.filter = .videos + } + } + + let picker = PHPickerViewController(configuration: configuration) + picker.delegate = self.filePickerController + picker.modalPresentationStyle = .fullScreen + self.presentViewController(picker) + } else { + let picker = UIImagePickerController() + picker.delegate = self.filePickerController + + if uniqueMimeType == true && mimeKind == "image" { + picker.sourceType = .photoLibrary + } + + picker.sourceType = .photoLibrary + picker.modalPresentationStyle = .fullScreen + self.presentViewController(picker) + } + } + } else { + let documentTypes = parsedTypes.isEmpty ? ["public.data"] : parsedTypes + DispatchQueue.main.async { + let picker = UIDocumentPickerViewController(documentTypes: documentTypes, in: .import) + picker.delegate = self.filePickerController + picker.allowsMultipleSelection = args.multiple + picker.modalPresentationStyle = .fullScreen + self.presentViewController(picker) + } + } + } + + private func presentViewController(_ viewControllerToPresent: UIViewController) { + self.manager.viewController?.present(viewControllerToPresent, animated: true, completion: nil) } - public func onFilePickerEvent(_ event: FilePickerEvent) { - switch event { - case .selected(let urls): - let readData = pendingInvoke?.getBool("readData", false) ?? false - do { - let filesResult = try urls.map {(url: URL) -> JSObject in - var file = JSObject() - - let mimeType = filePickerController.getMimeTypeFromUrl(url) - let isVideo = mimeType.hasPrefix("video") - let isImage = mimeType.hasPrefix("image") - - if readData { - file["data"] = try Data(contentsOf: url).base64EncodedString() - } - - if isVideo { - file["duration"] = filePickerController.getVideoDuration(url) - let (height, width) = filePickerController.getVideoDimensions(url) - if let height = height { - file["height"] = height - } - if let width = width { - file["width"] = width - } - } else if isImage { - let (height, width) = filePickerController.getImageDimensions(url) - if let height = height { - file["height"] = height - } - if let width = width { - file["width"] = width - } - } - - file["modifiedAt"] = filePickerController.getModifiedAtFromUrl(url) - file["mimeType"] = mimeType - file["name"] = url.lastPathComponent - file["path"] = url.absoluteString - file["size"] = try filePickerController.getSizeFromUrl(url) - return file - } - pendingInvoke?.resolve(["files": filesResult]) - } catch let error as NSError { - pendingInvoke?.reject(error.localizedDescription, nil, error) - return + private func parseFiltersOption(_ filters: [Filter]) -> [String] { + var parsedTypes: [String] = [] + for filter in filters { + for ext in filter.extensions { + guard + let utType: String = UTTypeCreatePreferredIdentifierForTag( + kUTTagClassMIMEType, ext as CFString, nil)?.takeRetainedValue() as String? + else { + continue } + parsedTypes.append(utType) + } + } + return parsedTypes + } + + public func onFilePickerEvent(_ event: FilePickerEvent) { + switch event { + case .selected(let urls): + let readData = pendingInvokeArgs?.readData ?? false + do { + let filesResult = try urls.map { (url: URL) -> JSObject in + var file = JSObject() + + let mimeType = filePickerController.getMimeTypeFromUrl(url) + let isVideo = mimeType.hasPrefix("video") + let isImage = mimeType.hasPrefix("image") + + if readData { + file["data"] = try Data(contentsOf: url).base64EncodedString() + } + + if isVideo { + file["duration"] = filePickerController.getVideoDuration(url) + let (height, width) = filePickerController.getVideoDimensions(url) + if let height = height { + file["height"] = height + } + if let width = width { + file["width"] = width + } + } else if isImage { + let (height, width) = filePickerController.getImageDimensions(url) + if let height = height { + file["height"] = height + } + if let width = width { + file["width"] = width + } + } + + file["modifiedAt"] = filePickerController.getModifiedAtFromUrl(url) + file["mimeType"] = mimeType + file["name"] = url.lastPathComponent + file["path"] = url.absoluteString + file["size"] = try filePickerController.getSizeFromUrl(url) + return file + } + pendingInvoke?.resolve(["files": filesResult]) + } catch let error as NSError { + pendingInvoke?.reject(error.localizedDescription, error: error) + return + } + + pendingInvoke?.resolve(["files": urls]) + case .cancelled: + let files: JSArray = [] + pendingInvoke?.resolve(["files": files]) + case .error(let error): + pendingInvoke?.reject(error) + } + } - pendingInvoke?.resolve(["files": urls]) - case .cancelled: - let files: JSArray = [] - pendingInvoke?.resolve(["files": files]) - case .error(let error): - pendingInvoke?.reject(error) - } - } - - @objc public func showMessageDialog(_ invoke: Invoke) { - let manager = self.manager - let title = invoke.getString("title") - guard let message = invoke.getString("message") else { - invoke.reject("The `message` argument is required") - return - } - let okButtonLabel = invoke.getString("okButtonLabel") ?? "OK" - let cancelButtonLabel = invoke.getString("cancelButtonLabel") ?? "Cancel" - - DispatchQueue.main.async { [] in - let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertController.Style.alert) - alert.addAction(UIAlertAction(title: cancelButtonLabel, style: UIAlertAction.Style.default, handler: { (_) -> Void in - invoke.resolve([ - "value": false, - "cancelled": false - ]) - })) - alert.addAction(UIAlertAction(title: okButtonLabel, style: UIAlertAction.Style.default, handler: { (_) -> Void in - invoke.resolve([ - "value": true, - "cancelled": false - ]) - })) - - manager.viewController?.present(alert, animated: true, completion: nil) - } - } + @objc public func showMessageDialog(_ invoke: Invoke) throws { + let manager = self.manager + let args = try invoke.parseArgs(MessageDialogOptions.self) + + DispatchQueue.main.async { [] in + let alert = UIAlertController( + title: args.title, message: args.message, preferredStyle: UIAlertController.Style.alert) + alert.addAction( + UIAlertAction( + title: args.cancelButtonLabel, style: UIAlertAction.Style.default, + handler: { (_) -> Void in + invoke.resolve([ + "value": false, + "cancelled": false, + ]) + })) + alert.addAction( + UIAlertAction( + title: args.okButtonLabel, style: UIAlertAction.Style.default, + handler: { (_) -> Void in + invoke.resolve([ + "value": true, + "cancelled": false, + ]) + })) + + manager.viewController?.present(alert, animated: true, completion: nil) + } + } } @_cdecl("init_plugin_dialog") diff --git a/plugins/dialog/package.json b/plugins/dialog/package.json index 65d75346f..2239b874f 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.9" + "@tauri-apps/api": "2.0.0-alpha.11" } } diff --git a/plugins/dialog/src/api-iife.js b/plugins/dialog/src/api-iife.js index 5fa71c3cd..e8664e408 100644 --- a/plugins/dialog/src/api-iife.js +++ b/plugins/dialog/src/api-iife.js @@ -1 +1 @@ -if("__TAURI__"in window){var __TAURI_DIALOG__=function(n){"use strict";var t=Object.defineProperty,e=(n,t,e)=>{if(!t.has(n))throw TypeError("Cannot "+e)},i=(n,t,i)=>(e(n,t,"read from private field"),i?i.call(n):t.get(n));function o(n,t=!1){return window.__TAURI_INTERNALS__.transformCallback(n,t)}((n,e)=>{for(var i in e)t(n,i,{get:e[i],enumerable:!0})})({},{Channel:()=>r,PluginListener:()=>a,addPluginListener:()=>s,convertFileSrc:()=>d,invoke:()=>u,transformCallback:()=>o});var l,r=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,((n,t,e)=>{if(t.has(n))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(n):t.set(n,e)})(this,l,(()=>{})),this.id=o((n=>{i(this,l).call(this,n)}))}set onmessage(n){var t,i,o,r;o=n,e(t=this,i=l,"write to private field"),r?r.call(t,o):i.set(t,o)}get onmessage(){return i(this,l)}toJSON(){return`__CHANNEL__:${this.id}`}};l=new WeakMap;var a=class{constructor(n,t,e){this.plugin=n,this.event=t,this.channelId=e}async unregister(){return u(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function s(n,t,e){let i=new r;return i.onmessage=e,u(`plugin:${n}|register_listener`,{event:t,handler:i}).then((()=>new a(n,t,i.id)))}async function u(n,t={},e){return window.__TAURI_INTERNALS__.invoke(n,t,e)}function d(n,t="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(n,t)}return n.ask=async function(n,t){var e,i,o,l,r;const a="string"==typeof t?{title:t}:t;return u("plugin:dialog|ask",{message:n.toString(),title:null===(e=null==a?void 0:a.title)||void 0===e?void 0:e.toString(),type_:null==a?void 0:a.type,okButtonLabel:null!==(o=null===(i=null==a?void 0:a.okLabel)||void 0===i?void 0:i.toString())&&void 0!==o?o:"Yes",cancelButtonLabel:null!==(r=null===(l=null==a?void 0:a.cancelLabel)||void 0===l?void 0:l.toString())&&void 0!==r?r:"No"})},n.confirm=async function(n,t){var e,i,o,l,r;const a="string"==typeof t?{title:t}:t;return u("plugin:dialog|confirm",{message:n.toString(),title:null===(e=null==a?void 0:a.title)||void 0===e?void 0:e.toString(),type_:null==a?void 0:a.type,okButtonLabel:null!==(o=null===(i=null==a?void 0:a.okLabel)||void 0===i?void 0:i.toString())&&void 0!==o?o:"Ok",cancelButtonLabel:null!==(r=null===(l=null==a?void 0:a.cancelLabel)||void 0===l?void 0:l.toString())&&void 0!==r?r:"Cancel"})},n.message=async function(n,t){var e,i;const o="string"==typeof t?{title:t}:t;return u("plugin:dialog|message",{message:n.toString(),title:null===(e=null==o?void 0:o.title)||void 0===e?void 0:e.toString(),type_:null==o?void 0:o.type,okButtonLabel:null===(i=null==o?void 0:o.okLabel)||void 0===i?void 0:i.toString()})},n.open=async function(n={}){return"object"==typeof n&&Object.freeze(n),u("plugin:dialog|open",{options:n})},n.save=async function(n={}){return"object"==typeof n&&Object.freeze(n),u("plugin:dialog|save",{options:n})},n}({});Object.defineProperty(window.__TAURI__,"dialog",{value:__TAURI_DIALOG__})} +if("__TAURI__"in window){var __TAURI_DIALOG__=function(n){"use strict";async function o(n,o={},t){return window.__TAURI_INTERNALS__.invoke(n,o,t)}return"function"==typeof SuppressedError&&SuppressedError,n.ask=async function(n,t){var i,l,e,u,r;const d="string"==typeof t?{title:t}:t;return o("plugin:dialog|ask",{message:n.toString(),title:null===(i=null==d?void 0:d.title)||void 0===i?void 0:i.toString(),type_:null==d?void 0:d.type,okButtonLabel:null!==(e=null===(l=null==d?void 0:d.okLabel)||void 0===l?void 0:l.toString())&&void 0!==e?e:"Yes",cancelButtonLabel:null!==(r=null===(u=null==d?void 0:d.cancelLabel)||void 0===u?void 0:u.toString())&&void 0!==r?r:"No"})},n.confirm=async function(n,t){var i,l,e,u,r;const d="string"==typeof t?{title:t}:t;return o("plugin:dialog|confirm",{message:n.toString(),title:null===(i=null==d?void 0:d.title)||void 0===i?void 0:i.toString(),type_:null==d?void 0:d.type,okButtonLabel:null!==(e=null===(l=null==d?void 0:d.okLabel)||void 0===l?void 0:l.toString())&&void 0!==e?e:"Ok",cancelButtonLabel:null!==(r=null===(u=null==d?void 0:d.cancelLabel)||void 0===u?void 0:u.toString())&&void 0!==r?r:"Cancel"})},n.message=async function(n,t){var i,l;const e="string"==typeof t?{title:t}:t;return o("plugin:dialog|message",{message:n.toString(),title:null===(i=null==e?void 0:e.title)||void 0===i?void 0:i.toString(),type_:null==e?void 0:e.type,okButtonLabel:null===(l=null==e?void 0:e.okLabel)||void 0===l?void 0:l.toString()})},n.open=async function(n={}){return"object"==typeof n&&Object.freeze(n),o("plugin:dialog|open",{options:n})},n.save=async function(n={}){return"object"==typeof n&&Object.freeze(n),o("plugin:dialog|save",{options:n})},n}({});Object.defineProperty(window.__TAURI__,"dialog",{value:__TAURI_DIALOG__})} diff --git a/plugins/dialog/src/desktop.rs b/plugins/dialog/src/desktop.rs index 4cd02bcdc..903ff5b3f 100644 --- a/plugins/dialog/src/desktop.rs +++ b/plugins/dialog/src/desktop.rs @@ -56,7 +56,10 @@ macro_rules! run_dialog { ($e:expr, $h: ident) => {{ std::thread::spawn(move || { let response = tauri::async_runtime::block_on($e); - $h(response); + $h(!matches!( + response, + rfd::MessageDialogResult::No | rfd::MessageDialogResult::Cancel + )); }); }}; } @@ -68,7 +71,10 @@ macro_rules! run_dialog { let context = glib::MainContext::default(); context.invoke_with_priority(glib::PRIORITY_HIGH, move || { let response = $e; - $h(response); + $h(!matches!( + response, + rfd::MessageDialogResult::No | rfd::MessageDialogResult::Cancel + )); }); }); }}; diff --git a/plugins/dialog/src/init-iife.js b/plugins/dialog/src/init-iife.js index fcfd45ca1..f51830fd7 100644 --- a/plugins/dialog/src/init-iife.js +++ b/plugins/dialog/src/init-iife.js @@ -1 +1 @@ -!function(){"use strict";var e=Object.defineProperty,n=(e,n,t)=>{if(!n.has(e))throw TypeError("Cannot "+t)},t=(e,t,r)=>(n(e,t,"read from private field"),r?r.call(e):t.get(e));function r(e,n=!1){return window.__TAURI_INTERNALS__.transformCallback(e,n)}((n,t)=>{for(var r in t)e(n,r,{get:t[r],enumerable:!0})})({},{Channel:()=>s,PluginListener:()=>a,addPluginListener:()=>o,convertFileSrc:()=>c,invoke:()=>l,transformCallback:()=>r});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=r((e=>{t(this,i).call(this,e)}))}set onmessage(e){var t,r,s,a;s=e,n(t=this,r=i,"write to private field"),a?a.call(t,s):r.set(t,s)}get onmessage(){return t(this,i)}toJSON(){return`__CHANNEL__:${this.id}`}};i=new WeakMap;var a=class{constructor(e,n,t){this.plugin=e,this.event=n,this.channelId=t}async unregister(){return l(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function o(e,n,t){let r=new s;return r.onmessage=t,l(`plugin:${e}|register_listener`,{event:n,handler:r}).then((()=>new a(e,n,r.id)))}async function l(e,n={},t){return window.__TAURI_INTERNALS__.invoke(e,n,t)}function c(e,n="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,n)}window.alert=function(e){l("plugin:dialog|message",{message:e.toString()})},window.confirm=function(e){return l("plugin:dialog|confirm",{message:e.toString()})}}(); +!function(){"use strict";async function n(n,i={},o){return window.__TAURI_INTERNALS__.invoke(n,i,o)}"function"==typeof SuppressedError&&SuppressedError,window.alert=function(i){n("plugin:dialog|message",{message:i.toString()})},window.confirm=function(i){return n("plugin:dialog|confirm",{message:i.toString()})}}(); diff --git a/plugins/fs/CHANGELOG.md b/plugins/fs/CHANGELOG.md index 898e2aea1..16a4ddd9c 100644 --- a/plugins/fs/CHANGELOG.md +++ b/plugins/fs/CHANGELOG.md @@ -2,7 +2,7 @@ ## \[2.0.0-alpha.2] -- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.16. +- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.9. ## \[2.0.0-alpha.2] diff --git a/plugins/fs/Cargo.toml b/plugins/fs/Cargo.toml index ff0f51ef2..991fd1188 100644 --- a/plugins/fs/Cargo.toml +++ b/plugins/fs/Cargo.toml @@ -8,7 +8,8 @@ edition = { workspace = true } rust-version = { workspace = true } [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = [ "--cfg", "docsrs" ] +rustdoc-args = [ "--cfg", "docsrs" ] [dependencies] serde = { workspace = true } diff --git a/plugins/fs/package.json b/plugins/fs/package.json index 2b09606be..07b51f9f3 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.9" + "@tauri-apps/api": "2.0.0-alpha.11" } } diff --git a/plugins/fs/src/api-iife.js b/plugins/fs/src/api-iife.js index af959a33a..d4da6a73b 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));function o(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}n({},{Channel:()=>c,PluginListener:()=>s,addPluginListener:()=>u,convertFileSrc:()=>l,invoke:()=>p,transformCallback:()=>o});var a,c=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,a,(()=>{})),this.id=o((e=>{i(this,a).call(this,e)}))}set onmessage(e){((e,t,n,i)=>{r(e,t,"write to private field"),i?i.call(e,n):t.set(e,n)})(this,a,e)}get onmessage(){return i(this,a)}toJSON(){return`__CHANNEL__:${this.id}`}};a=new WeakMap;var s=class{constructor(e,t,n){this.plugin=e,this.event=t,this.channelId=n}async unregister(){return p(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function u(e,t,n){let r=new c;return r.onmessage=n,p(`plugin:${e}|register_listener`,{event:t,handler:r}).then((()=>new s(e,t,r.id)))}async function p(e,t={},n){return window.__TAURI_INTERNALS__.invoke(e,t,n)}function l(e,t="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,t)}n({},{BaseDirectory:()=>y,appCacheDir:()=>_,appConfigDir:()=>d,appDataDir:()=>f,appLocalDataDir:()=>h,appLogDir:()=>S,audioDir:()=>g,basename:()=>V,cacheDir:()=>v,configDir:()=>m,dataDir:()=>D,delimiter:()=>O,desktopDir:()=>w,dirname:()=>H,documentDir:()=>A,downloadDir:()=>b,executableDir:()=>T,extname:()=>$,fontDir:()=>R,homeDir:()=>I,isAbsolute:()=>W,join:()=>M,localDataDir:()=>C,normalize:()=>B,pictureDir:()=>L,publicDir:()=>N,resolve:()=>z,resolveResource:()=>E,resourceDir:()=>F,runtimeDir:()=>j,sep:()=>k,tempDir:()=>P,templateDir:()=>x,videoDir:()=>U});var y=(e=>(e[e.Audio=1]="Audio",e[e.Cache=2]="Cache",e[e.Config=3]="Config",e[e.Data=4]="Data",e[e.LocalData=5]="LocalData",e[e.Document=6]="Document",e[e.Download=7]="Download",e[e.Picture=8]="Picture",e[e.Public=9]="Public",e[e.Video=10]="Video",e[e.Resource=11]="Resource",e[e.Temp=12]="Temp",e[e.AppConfig=13]="AppConfig",e[e.AppData=14]="AppData",e[e.AppLocalData=15]="AppLocalData",e[e.AppCache=16]="AppCache",e[e.AppLog=17]="AppLog",e[e.Desktop=18]="Desktop",e[e.Executable=19]="Executable",e[e.Font=20]="Font",e[e.Home=21]="Home",e[e.Runtime=22]="Runtime",e[e.Template=23]="Template",e))(y||{});async function d(){return p("plugin:path|resolve_directory",{directory:13})}async function f(){return p("plugin:path|resolve_directory",{directory:14})}async function h(){return p("plugin:path|resolve_directory",{directory:15})}async function _(){return p("plugin:path|resolve_directory",{directory:16})}async function g(){return p("plugin:path|resolve_directory",{directory:1})}async function v(){return p("plugin:path|resolve_directory",{directory:2})}async function m(){return p("plugin:path|resolve_directory",{directory:3})}async function D(){return p("plugin:path|resolve_directory",{directory:4})}async function w(){return p("plugin:path|resolve_directory",{directory:18})}async function A(){return p("plugin:path|resolve_directory",{directory:6})}async function b(){return p("plugin:path|resolve_directory",{directory:7})}async function T(){return p("plugin:path|resolve_directory",{directory:19})}async function R(){return p("plugin:path|resolve_directory",{directory:20})}async function I(){return p("plugin:path|resolve_directory",{directory:21})}async function C(){return p("plugin:path|resolve_directory",{directory:5})}async function L(){return p("plugin:path|resolve_directory",{directory:8})}async function N(){return p("plugin:path|resolve_directory",{directory:9})}async function F(){return p("plugin:path|resolve_directory",{directory:11})}async function E(e){return p("plugin:path|resolve_directory",{directory:11,path:e})}async function j(){return p("plugin:path|resolve_directory",{directory:22})}async function x(){return p("plugin:path|resolve_directory",{directory:23})}async function U(){return p("plugin:path|resolve_directory",{directory:10})}async function S(){return p("plugin:path|resolve_directory",{directory:17})}async function P(e){return p("plugin:path|resolve_directory",{directory:12})}function k(){return window.__TAURI_INTERNALS__.plugins.path.sep}function O(){return window.__TAURI_INTERNALS__.plugins.path.delimiter}async function z(...e){return p("plugin:path|resolve",{paths:e})}async function B(e){return p("plugin:path|normalize",{path:e})}async function M(...e){return p("plugin:path|join",{paths:e})}async function H(e){return p("plugin:path|dirname",{path:e})}async function $(e){return p("plugin:path|extname",{path:e})}async function V(e,t){return p("plugin:path|basename",{path:e,ext:t})}async function W(e){return p("plugin:path|isAbsolute",{path:e})}async function J(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 p("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 p("plugin:fs|copy_file",{source:e,destination:t,options:n})},e.createDir=async function(e,t={}){return await p("plugin:fs|create_dir",{path:e,options:t})},e.exists=async function(e){return await p("plugin:fs|exists",{path:e})},e.metadata=async function(e){return await p("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 p("plugin:fs|read_file",{path:e,options:t});return Uint8Array.from(n)},e.readDir=async function(e,t={}){return await p("plugin:fs|read_dir",{path:e,options:t})},e.readTextFile=async function(e,t={}){return await p("plugin:fs|read_text_file",{path:e,options:t})},e.removeDir=async function(e,t={}){return await p("plugin:fs|remove_dir",{path:e,options:t})},e.removeFile=async function(e,t={}){return await p("plugin:fs|remove_file",{path:e,options:t})},e.renameFile=async function(e,t,n={}){return await p("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 p("plugin:fs|write_file",{path:r.path,contents:Array.from(r.contents instanceof ArrayBuffer?new Uint8Array(r.contents):r.contents),options:i})},e.writeFile=J,e.writeTextFile=J,e}({});Object.defineProperty(window.__TAURI__,"fs",{value:__TAURI_FS__})} +if("__TAURI__"in window){var __TAURI_FS__=function(t){"use strict";async function e(t,e={},n){return window.__TAURI_INTERNALS__.invoke(t,e,n)}var n;async function a(t,n,a){"object"==typeof a&&Object.freeze(a),"object"==typeof t&&Object.freeze(t);const i={path:"",contents:""};let o=a;return"string"==typeof t?i.path=t:(i.path=t.path,i.contents=t.contents),"string"==typeof n?i.contents=null!=n?n:"":o=n,await e("plugin:fs|write_file",{path:i.path,contents:Array.from((new TextEncoder).encode(i.contents)),options:o})}return"function"==typeof SuppressedError&&SuppressedError,t.Dir=void 0,(n=t.Dir||(t.Dir={}))[n.Audio=1]="Audio",n[n.Cache=2]="Cache",n[n.Config=3]="Config",n[n.Data=4]="Data",n[n.LocalData=5]="LocalData",n[n.Document=6]="Document",n[n.Download=7]="Download",n[n.Picture=8]="Picture",n[n.Public=9]="Public",n[n.Video=10]="Video",n[n.Resource=11]="Resource",n[n.Temp=12]="Temp",n[n.AppConfig=13]="AppConfig",n[n.AppData=14]="AppData",n[n.AppLocalData=15]="AppLocalData",n[n.AppCache=16]="AppCache",n[n.AppLog=17]="AppLog",n[n.Desktop=18]="Desktop",n[n.Executable=19]="Executable",n[n.Font=20]="Font",n[n.Home=21]="Home",n[n.Runtime=22]="Runtime",n[n.Template=23]="Template",t.BaseDirectory=t.Dir,t.copyFile=async function(t,n,a={}){return await e("plugin:fs|copy_file",{source:t,destination:n,options:a})},t.createDir=async function(t,n={}){return await e("plugin:fs|create_dir",{path:t,options:n})},t.exists=async function(t){return await e("plugin:fs|exists",{path:t})},t.metadata=async function(t){return await e("plugin:fs|metadata",{path:t}).then((t=>{const{accessedAtMs:e,createdAtMs:n,modifiedAtMs:a,...i}=t;return{accessedAt:new Date(e),createdAt:new Date(n),modifiedAt:new Date(a),...i}}))},t.readBinaryFile=async function(t,n={}){const a=await e("plugin:fs|read_file",{path:t,options:n});return Uint8Array.from(a)},t.readDir=async function(t,n={}){return await e("plugin:fs|read_dir",{path:t,options:n})},t.readTextFile=async function(t,n={}){return await e("plugin:fs|read_text_file",{path:t,options:n})},t.removeDir=async function(t,n={}){return await e("plugin:fs|remove_dir",{path:t,options:n})},t.removeFile=async function(t,n={}){return await e("plugin:fs|remove_file",{path:t,options:n})},t.renameFile=async function(t,n,a={}){return await e("plugin:fs|rename_file",{oldPath:t,newPath:n,options:a})},t.writeBinaryFile=async function(t,n,a){"object"==typeof a&&Object.freeze(a),"object"==typeof t&&Object.freeze(t);const i={path:"",contents:[]};let o=a;return"string"==typeof t?i.path=t:(i.path=t.path,i.contents=t.contents),n&&"dir"in n?o=n:"string"==typeof t&&(i.contents=null!=n?n:[]),await e("plugin:fs|write_file",{path:i.path,contents:Array.from(i.contents instanceof ArrayBuffer?new Uint8Array(i.contents):i.contents),options:o})},t.writeFile=a,t.writeTextFile=a,t}({});Object.defineProperty(window.__TAURI__,"fs",{value:__TAURI_FS__})} diff --git a/plugins/global-shortcut/CHANGELOG.md b/plugins/global-shortcut/CHANGELOG.md index 318c3c377..1f8362aba 100644 --- a/plugins/global-shortcut/CHANGELOG.md +++ b/plugins/global-shortcut/CHANGELOG.md @@ -2,7 +2,7 @@ ## \[2.0.0-alpha.2] -- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.16. +- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.9. ## \[2.0.0-alpha.2] diff --git a/plugins/global-shortcut/Cargo.toml b/plugins/global-shortcut/Cargo.toml index d13e07810..bd9814972 100644 --- a/plugins/global-shortcut/Cargo.toml +++ b/plugins/global-shortcut/Cargo.toml @@ -8,7 +8,8 @@ license = { workspace = true } rust-version = { workspace = true } [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = [ "--cfg", "docsrs" ] +rustdoc-args = [ "--cfg", "docsrs" ] [dependencies] serde = { workspace = true } diff --git a/plugins/global-shortcut/package.json b/plugins/global-shortcut/package.json index 943c0483a..afa0dcd88 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.9" + "@tauri-apps/api": "2.0.0-alpha.11" } } diff --git a/plugins/global-shortcut/src/api-iife.js b/plugins/global-shortcut/src/api-iife.js index 3ff40c720..934749c67 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(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));function i(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}((e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})})({},{Channel:()=>a,PluginListener:()=>o,addPluginListener:()=>l,convertFileSrc:()=>c,invoke:()=>u,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=>{r(this,s).call(this,e)}))}set onmessage(e){var t,r,i,a;i=e,n(t=this,r=s,"write to private field"),a?a.call(t,i):r.set(t,i)}get onmessage(){return r(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 u(`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,u(`plugin:${e}|register_listener`,{event:t,handler:r}).then((()=>new o(e,t,r.id)))}async function u(e,t={},n){return window.__TAURI_INTERNALS__.invoke(e,t,n)}function c(e,t="asset"){return window.__TAURI_INTERNALS__.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 a;return n.onmessage=t,await u("plugin:globalShortcut|register",{shortcut:e,handler:n})},e.registerAll=async function(e,t){const n=new a;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__})} +if("__TAURI__"in window){var __TAURI_GLOBALSHORTCUT__=function(t){"use strict";function e(t,e,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(t):n?n.value:e.get(t)}var r;"function"==typeof SuppressedError&&SuppressedError;class n{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,r.set(this,(()=>{})),this.id=function(t,e=!1){return window.__TAURI_INTERNALS__.transformCallback(t,e)}((t=>{e(this,r,"f").call(this,t)}))}set onmessage(t){!function(t,e,r,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===n?o.call(t,r):o?o.value=r:e.set(t,r)}(this,r,t,"f")}get onmessage(){return e(this,r,"f")}toJSON(){return`__CHANNEL__:${this.id}`}}async function o(t,e={},r){return window.__TAURI_INTERNALS__.invoke(t,e,r)}return r=new WeakMap,t.isRegistered=async function(t){return await o("plugin:globalShortcut|is_registered",{shortcut:t})},t.register=async function(t,e){const r=new n;return r.onmessage=e,await o("plugin:globalShortcut|register",{shortcut:t,handler:r})},t.registerAll=async function(t,e){const r=new n;return r.onmessage=e,await o("plugin:globalShortcut|register_all",{shortcuts:t,handler:r})},t.unregister=async function(t){return await o("plugin:globalShortcut|unregister",{shortcut:t})},t.unregisterAll=async function(){return await o("plugin:globalShortcut|unregister_all")},t}({});Object.defineProperty(window.__TAURI__,"globalShortcut",{value:__TAURI_GLOBALSHORTCUT__})} diff --git a/plugins/http/CHANGELOG.md b/plugins/http/CHANGELOG.md index a8a356d03..23893ac0c 100644 --- a/plugins/http/CHANGELOG.md +++ b/plugins/http/CHANGELOG.md @@ -2,7 +2,7 @@ ## \[2.0.0-alpha.2] -- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.16. +- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.9. ## \[2.0.0-alpha.3] diff --git a/plugins/http/Cargo.toml b/plugins/http/Cargo.toml index 7d42c43a1..7f23cc512 100644 --- a/plugins/http/Cargo.toml +++ b/plugins/http/Cargo.toml @@ -8,7 +8,8 @@ license = { workspace = true } rust-version = { workspace = true } [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = [ "--cfg", "docsrs" ] +rustdoc-args = [ "--cfg", "docsrs" ] [dependencies] serde = { workspace = true } diff --git a/plugins/http/package.json b/plugins/http/package.json index 571532fa3..7c105d876 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.9" + "@tauri-apps/api": "2.0.0-alpha.11" } } diff --git a/plugins/http/src/api-iife.js b/plugins/http/src/api-iife.js index e1d5d3c33..1f1aedcc2 100644 --- a/plugins/http/src/api-iife.js +++ b/plugins/http/src/api-iife.js @@ -1 +1 @@ -if("__TAURI__"in window){var __TAURI_HTTP__=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));function i(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}((e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})})({},{Channel:()=>s,PluginListener:()=>o,addPluginListener:()=>c,convertFileSrc:()=>_,invoke:()=>l,transformCallback:()=>i});var a,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,a,(()=>{})),this.id=i((e=>{r(this,a).call(this,e)}))}set onmessage(e){var t,r,i,s;i=e,n(t=this,r=a,"write to private field"),s?s.call(t,i):r.set(t,i)}get onmessage(){return r(this,a)}toJSON(){return`__CHANNEL__:${this.id}`}};a=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 s;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 window.__TAURI_INTERNALS__.invoke(e,t,n)}function _(e,t="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,t)}return e.fetch=async function(e,t){const n=null==t?void 0:t.maxRedirections,r=null==t?void 0:t.maxRedirections;t&&(delete t.maxRedirections,delete t.connectTimeout);const i=new Request(e,t),a=await i.arrayBuffer(),s=a.byteLength?Array.from(new Uint8Array(a)):null,o=await l("plugin:http|fetch",{method:i.method,url:i.url,headers:Array.from(i.headers.entries()),data:s,maxRedirections:n,connectTimeout:r});i.signal.addEventListener("abort",(()=>{l("plugin:http|fetch_cancel",{rid:o})}));const{status:c,statusText:_,url:d,headers:u}=await l("plugin:http|fetch_send",{rid:o}),h=await l("plugin:http|fetch_read_body",{rid:o}),f=new Response(new Uint8Array(h),{headers:u,status:c,statusText:_});return Object.defineProperty(f,"url",{value:d}),f},e}({});Object.defineProperty(window.__TAURI__,"http",{value:__TAURI_HTTP__})} +if("__TAURI__"in window){var __TAURI_HTTP__=function(e){"use strict";async function t(e,t={},n){return window.__TAURI_INTERNALS__.invoke(e,t,n)}return"function"==typeof SuppressedError&&SuppressedError,e.fetch=async function(e,n){const r=null==n?void 0:n.maxRedirections,i=null==n?void 0:n.maxRedirections;n&&(delete n.maxRedirections,delete n.connectTimeout);const a=new Request(e,n),s=await a.arrayBuffer(),o=s.byteLength?Array.from(new Uint8Array(s)):null,u=await t("plugin:http|fetch",{method:a.method,url:a.url,headers:Array.from(a.headers.entries()),data:o,maxRedirections:r,connectTimeout:i});a.signal.addEventListener("abort",(()=>{t("plugin:http|fetch_cancel",{rid:u})}));const{status:d,statusText:c,url:_,headers:l}=await t("plugin:http|fetch_send",{rid:u}),f=await t("plugin:http|fetch_read_body",{rid:u}),h=new Response(new Uint8Array(f),{headers:l,status:d,statusText:c});return Object.defineProperty(h,"url",{value:_}),h},e}({});Object.defineProperty(window.__TAURI__,"http",{value:__TAURI_HTTP__})} diff --git a/plugins/localhost/Cargo.toml b/plugins/localhost/Cargo.toml index 1ca306bbe..7a52ce218 100644 --- a/plugins/localhost/Cargo.toml +++ b/plugins/localhost/Cargo.toml @@ -8,7 +8,8 @@ edition = { workspace = true } rust-version = { workspace = true } [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = [ "--cfg", "docsrs" ] +rustdoc-args = [ "--cfg", "docsrs" ] [dependencies] serde = { workspace = true } diff --git a/plugins/log/CHANGELOG.md b/plugins/log/CHANGELOG.md index 6a984a6a5..77273b16e 100644 --- a/plugins/log/CHANGELOG.md +++ b/plugins/log/CHANGELOG.md @@ -2,7 +2,7 @@ ## \[2.0.0-alpha.2] -- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.16. +- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.9. ## \[2.0.0-alpha.2] diff --git a/plugins/log/Cargo.toml b/plugins/log/Cargo.toml index 042389f2d..a85f8713d 100644 --- a/plugins/log/Cargo.toml +++ b/plugins/log/Cargo.toml @@ -8,7 +8,8 @@ edition = { workspace = true } rust-version = { workspace = true } [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = [ "--cfg", "docsrs" ] +rustdoc-args = [ "--cfg", "docsrs" ] [build-dependencies] tauri-build = { workspace = true } diff --git a/plugins/log/package.json b/plugins/log/package.json index e71357c2b..487febd63 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.9" + "@tauri-apps/api": "2.0.0-alpha.11" } } diff --git a/plugins/log/src/api-iife.js b/plugins/log/src/api-iife.js index 12b8c9e26..9ded0b4b7 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));function i(e,n=!1){return window.__TAURI_INTERNALS__.transformCallback(e,n)}t({},{Channel:()=>l,PluginListener:()=>s,addPluginListener:()=>c,convertFileSrc:()=>_,invoke:()=>u,transformCallback:()=>i});var o,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,o,(()=>{})),this.id=i((e=>{a(this,o).call(this,e)}))}set onmessage(e){((e,n,t,a)=>{r(e,n,"write to private field"),a?a.call(e,t):n.set(e,t)})(this,o,e)}get onmessage(){return a(this,o)}toJSON(){return`__CHANNEL__:${this.id}`}};o=new WeakMap;var s=class{constructor(e,n,t){this.plugin=e,this.event=n,this.channelId=t}async unregister(){return u(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function c(e,n,t){let r=new l;return r.onmessage=t,u(`plugin:${e}|register_listener`,{event:n,handler:r}).then((()=>new s(e,n,r.id)))}async function u(e,n={},t){return window.__TAURI_INTERNALS__.invoke(e,n,t)}function _(e,n="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,n)}t({},{TauriEvent:()=>f,emit:()=>E,listen:()=>w,once:()=>g});var d,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 v(e,n){await u("plugin:event|unlisten",{event:e,eventId:n})}async function w(e,n,t){return u("plugin:event|listen",{event:e,windowLabel:t?.target,handler:i(n)}).then((n=>async()=>v(e,n)))}async function g(e,n,t){return w(e,(t=>{n(t),v(e,t.id).catch((()=>{}))}),t)}async function E(e,n,t){await u("plugin:event|emit",{event:e,windowLabel:t?.target,payload:n})}async function h(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:s,keyValues:c}=null!=t?t:{};let _=null===(a=null==o?void 0:o[0])||void 0===a?void 0:a.filter((e=>e.length>0)).join("@");"Error"===_&&(_="webview::unknown"),await u("plugin:log|log",{level:e,message:n,location:_,file:l,line:s,keyValues:c})}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"}(d||(d={})),e.attachConsole=async function(){return await w("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 d.Trace:console.log(t);break;case d.Debug:console.debug(t);break;case d.Info:console.info(t);break;case d.Warn:console.warn(t);break;case d.Error:console.error(t);break;default:throw new Error(`unknown log level ${n.level}`)}}))},e.debug=async function(e,n){await h(d.Debug,e,n)},e.error=async function(e,n){await h(d.Error,e,n)},e.info=async function(e,n){await h(d.Info,e,n)},e.trace=async function(e,n){await h(d.Trace,e,n)},e.warn=async function(e,n){await h(d.Warn,e,n)},e}({});Object.defineProperty(window.__TAURI__,"log",{value:__TAURI_LOG__})} +if("__TAURI__"in window){var __TAURI_LOG__=function(e){"use strict";function n(e,n=!1){return window.__TAURI_INTERNALS__.transformCallback(e,n)}async function r(e,n={},r){return window.__TAURI_INTERNALS__.invoke(e,n,r)}var a,o;async function t(e,a,o){return r("plugin:event|listen",{event:e,windowLabel:o?.target,handler:n(a)}).then((n=>async()=>async function(e,n){await r("plugin:event|unlisten",{event:e,eventId:n})}(e,n)))}async function i(e,n,a){var o,t;const i=null===(o=(new Error).stack)||void 0===o?void 0:o.split("\n").map((e=>e.split("@"))),l=null==i?void 0:i.filter((([e,n])=>e.length>0&&"[native code]"!==n)),{file:u,line:c,keyValues:s}=null!=a?a:{};let _=null===(t=null==l?void 0:l[0])||void 0===t?void 0:t.filter((e=>e.length>0)).join("@");"Error"===_&&(_="webview::unknown"),await r("plugin:log|log",{level:e,message:n,location:_,file:u,line:c,keyValues:s})}return"function"==typeof SuppressedError&&SuppressedError,function(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"}(a||(a={})),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"}(o||(o={})),e.attachConsole=async function(){return await t("log://log",(e=>{const n=e.payload,r=n.message.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,"");switch(n.level){case o.Trace:console.log(r);break;case o.Debug:console.debug(r);break;case o.Info:console.info(r);break;case o.Warn:console.warn(r);break;case o.Error:console.error(r);break;default:throw new Error(`unknown log level ${n.level}`)}}))},e.debug=async function(e,n){await i(o.Debug,e,n)},e.error=async function(e,n){await i(o.Error,e,n)},e.info=async function(e,n){await i(o.Info,e,n)},e.trace=async function(e,n){await i(o.Trace,e,n)},e.warn=async function(e,n){await i(o.Warn,e,n)},e}({});Object.defineProperty(window.__TAURI__,"log",{value:__TAURI_LOG__})} diff --git a/plugins/log/src/lib.rs b/plugins/log/src/lib.rs index 4dd84082e..5f564b2d9 100644 --- a/plugins/log/src/lib.rs +++ b/plugins/log/src/lib.rs @@ -475,7 +475,7 @@ impl Builder { }; let app_handle = app_handle.clone(); tauri::async_runtime::spawn(async move { - app_handle.emit_all("log://log", payload).unwrap(); + app_handle.emit("log://log", payload).unwrap(); }); }) } diff --git a/plugins/notification/CHANGELOG.md b/plugins/notification/CHANGELOG.md index 781ce6134..29dd92adf 100644 --- a/plugins/notification/CHANGELOG.md +++ b/plugins/notification/CHANGELOG.md @@ -2,7 +2,7 @@ ## \[2.0.0-alpha.2] -- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.16. +- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.9. ## \[2.0.0-alpha.3] diff --git a/plugins/notification/Cargo.toml b/plugins/notification/Cargo.toml index 602b2a6e9..2a4139e22 100644 --- a/plugins/notification/Cargo.toml +++ b/plugins/notification/Cargo.toml @@ -9,7 +9,8 @@ rust-version = { workspace = true } links = "tauri-plugin-notification" [package.metadata.docs.rs] -features = [ "dox" ] +rustc-args = [ "--cfg", "docsrs" ] +rustdoc-args = [ "--cfg", "docsrs" ] targets = [ "x86_64-unknown-linux-gnu", "x86_64-linux-android" ] [build-dependencies] @@ -34,4 +35,3 @@ win7-notifications = { version = "0.3.1", optional = true } [features] windows7-compat = [ "win7-notifications" ] -dox = [ "tauri/dox" ] diff --git a/plugins/notification/android/build.gradle.kts b/plugins/notification/android/build.gradle.kts index 7d961104a..6fe1c46ac 100644 --- a/plugins/notification/android/build.gradle.kts +++ b/plugins/notification/android/build.gradle.kts @@ -38,6 +38,7 @@ dependencies { implementation("androidx.core:core-ktx:1.9.0") implementation("androidx.appcompat:appcompat:1.6.0") implementation("com.google.android.material:material:1.7.0") + implementation("com.fasterxml.jackson.core:jackson-databind:2.15.3") testImplementation("junit:junit:4.13.2") androidTestImplementation("androidx.test.ext:junit:1.1.5") androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") diff --git a/plugins/notification/android/src/main/AndroidManifest.xml b/plugins/notification/android/src/main/AndroidManifest.xml index 28ccac308..608de0c74 100644 --- a/plugins/notification/android/src/main/AndroidManifest.xml +++ b/plugins/notification/android/src/main/AndroidManifest.xml @@ -4,7 +4,7 @@ diff --git a/plugins/notification/android/src/main/java/ChannelManager.kt b/plugins/notification/android/src/main/java/ChannelManager.kt index 2ae740e55..206f340ab 100644 --- a/plugins/notification/android/src/main/java/ChannelManager.kt +++ b/plugins/notification/android/src/main/java/ChannelManager.kt @@ -12,21 +12,42 @@ import android.graphics.Color import android.media.AudioAttributes import android.net.Uri import android.os.Build -import androidx.core.app.NotificationCompat import app.tauri.Logger +import app.tauri.annotation.InvokeArg import app.tauri.plugin.Invoke -import app.tauri.plugin.JSArray -import app.tauri.plugin.JSObject - -private const val CHANNEL_ID = "id" -private const val CHANNEL_NAME = "name" -private const val CHANNEL_DESCRIPTION = "description" -private const val CHANNEL_IMPORTANCE = "importance" -private const val CHANNEL_VISIBILITY = "visibility" -private const val CHANNEL_SOUND = "sound" -private const val CHANNEL_VIBRATE = "vibration" -private const val CHANNEL_USE_LIGHTS = "lights" -private const val CHANNEL_LIGHT_COLOR = "lightColor" +import com.fasterxml.jackson.annotation.JsonValue + +enum class Importance(@JsonValue val value: Int) { + None(0), + Min(1), + Low(2), + Default(3), + High(4); +} + +enum class Visibility(@JsonValue val value: Int) { + Secret(-1), + Private(0), + Public(1); +} + +@InvokeArg +class Channel { + lateinit var id: String + lateinit var name: String + var description: String? = null + var sound: String? = null + var lights: Boolean? = null + var lightsColor: String? = null + var vibration: Boolean? = null + var importance: Importance? = null + var visibility: Visibility? = null +} + +@InvokeArg +class DeleteChannelArgs { + lateinit var id: String +} class ChannelManager(private var context: Context) { private var notificationManager: NotificationManager? = null @@ -38,32 +59,7 @@ class ChannelManager(private var context: Context) { fun createChannel(invoke: Invoke) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - val channel = JSObject() - if (invoke.getString(CHANNEL_ID) != null) { - channel.put(CHANNEL_ID, invoke.getString(CHANNEL_ID)) - } else { - invoke.reject("Channel missing identifier") - return - } - if (invoke.getString(CHANNEL_NAME) != null) { - channel.put(CHANNEL_NAME, invoke.getString(CHANNEL_NAME)) - } else { - invoke.reject("Channel missing name") - return - } - channel.put( - CHANNEL_IMPORTANCE, - invoke.getInt(CHANNEL_IMPORTANCE, NotificationManager.IMPORTANCE_DEFAULT) - ) - channel.put(CHANNEL_DESCRIPTION, invoke.getString(CHANNEL_DESCRIPTION, "")) - channel.put( - CHANNEL_VISIBILITY, - invoke.getInt(CHANNEL_VISIBILITY, NotificationCompat.VISIBILITY_PUBLIC) - ) - channel.put(CHANNEL_SOUND, invoke.getString(CHANNEL_SOUND)) - channel.put(CHANNEL_VIBRATE, invoke.getBoolean(CHANNEL_VIBRATE, false)) - channel.put(CHANNEL_USE_LIGHTS, invoke.getBoolean(CHANNEL_USE_LIGHTS, false)) - channel.put(CHANNEL_LIGHT_COLOR, invoke.getString(CHANNEL_LIGHT_COLOR)) + val channel = invoke.parseArgs(Channel::class.java) createChannel(channel) invoke.resolve() } else { @@ -71,18 +67,18 @@ class ChannelManager(private var context: Context) { } } - private fun createChannel(channel: JSObject) { + private fun createChannel(channel: Channel) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { val notificationChannel = NotificationChannel( - channel.getString(CHANNEL_ID), - channel.getString(CHANNEL_NAME), - channel.getInteger(CHANNEL_IMPORTANCE)!! + channel.id, + channel.name, + (channel.importance ?: Importance.Default).value ) - notificationChannel.description = channel.getString(CHANNEL_DESCRIPTION) - notificationChannel.lockscreenVisibility = channel.getInteger(CHANNEL_VISIBILITY, android.app.Notification.VISIBILITY_PRIVATE) - notificationChannel.enableVibration(channel.getBoolean(CHANNEL_VIBRATE, false)) - notificationChannel.enableLights(channel.getBoolean(CHANNEL_USE_LIGHTS, false)) - val lightColor = channel.getString(CHANNEL_LIGHT_COLOR) + notificationChannel.description = channel.description + notificationChannel.lockscreenVisibility = (channel.visibility ?: Visibility.Private).value + notificationChannel.enableVibration(channel.vibration ?: false) + notificationChannel.enableLights(channel.lights ?: false) + val lightColor = channel.lightsColor ?: "" if (lightColor.isNotEmpty()) { try { notificationChannel.lightColor = Color.parseColor(lightColor) @@ -94,7 +90,7 @@ class ChannelManager(private var context: Context) { ) } } - var sound = channel.getString(CHANNEL_SOUND) + var sound = channel.sound ?: "" if (sound.isNotEmpty()) { if (sound.contains(".")) { sound = sound.substring(0, sound.lastIndexOf('.')) @@ -113,8 +109,8 @@ class ChannelManager(private var context: Context) { fun deleteChannel(invoke: Invoke) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - val channelId = invoke.getString("id") - notificationManager?.deleteNotificationChannel(channelId) + val args = invoke.parseArgs(DeleteChannelArgs::class.java) + notificationManager?.deleteNotificationChannel(args.id) invoke.resolve() } else { invoke.reject("channel not available") @@ -125,28 +121,29 @@ class ChannelManager(private var context: Context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { val notificationChannels: List = notificationManager?.notificationChannels ?: listOf() - val channels = JSArray() + + val channels = mutableListOf() + for (notificationChannel in notificationChannels) { - val channel = JSObject() - channel.put(CHANNEL_ID, notificationChannel.id) - channel.put(CHANNEL_NAME, notificationChannel.name) - channel.put(CHANNEL_DESCRIPTION, notificationChannel.description) - channel.put(CHANNEL_IMPORTANCE, notificationChannel.importance) - channel.put(CHANNEL_VISIBILITY, notificationChannel.lockscreenVisibility) - channel.put(CHANNEL_SOUND, notificationChannel.sound) - channel.put(CHANNEL_VIBRATE, notificationChannel.shouldVibrate()) - channel.put(CHANNEL_USE_LIGHTS, notificationChannel.shouldShowLights()) - channel.put( - CHANNEL_LIGHT_COLOR, String.format( - "#%06X", - 0xFFFFFF and notificationChannel.lightColor - ) + val channel = Channel() + channel.id = notificationChannel.id + channel.name = notificationChannel.name.toString() + channel.description = notificationChannel.description + channel.sound = notificationChannel.sound.toString() + channel.lights = notificationChannel.shouldShowLights() + String.format( + "#%06X", + 0xFFFFFF and notificationChannel.lightColor ) - channels.put(channel) + channel.vibration = notificationChannel.shouldVibrate() + channel.importance = Importance.values().firstOrNull { it.value == notificationChannel.importance } + channel.visibility = Visibility.values().firstOrNull { it.value == notificationChannel.lockscreenVisibility } + + channels.add(channel) } - val result = JSObject() - result.put("channels", channels) - invoke.resolve(result) + + invoke.resolveObject(channels) + } else { invoke.reject("channel not available") } diff --git a/plugins/notification/android/src/main/java/Notification.kt b/plugins/notification/android/src/main/java/Notification.kt index 9076fa8f1..60e40675a 100644 --- a/plugins/notification/android/src/main/java/Notification.kt +++ b/plugins/notification/android/src/main/java/Notification.kt @@ -8,20 +8,22 @@ import android.content.ContentResolver import android.content.Context import android.graphics.Bitmap import android.graphics.BitmapFactory +import app.tauri.annotation.InvokeArg import app.tauri.plugin.JSArray import app.tauri.plugin.JSObject import org.json.JSONException import org.json.JSONObject +@InvokeArg class Notification { + var id: Int = 0 var title: String? = null var body: String? = null var largeBody: String? = null var summary: String? = null - var id: Int = 0 - private var sound: String? = null - private var smallIcon: String? = null - private var largeIcon: String? = null + var sound: String? = null + var icon: String? = null + var largeIcon: String? = null var iconColor: String? = null var actionTypeId: String? = null var group: String? = null @@ -33,7 +35,7 @@ class Notification { var attachments: List? = null var schedule: NotificationSchedule? = null var channelId: String? = null - var source: JSObject? = null + var sourceJson: String? = null var visibility: Int? = null var number: Int? = null @@ -54,18 +56,6 @@ class Notification { return soundPath } - fun setSound(sound: String?) { - this.sound = sound - } - - fun setSmallIcon(smallIcon: String?) { - this.smallIcon = AssetUtils.getResourceBaseName(smallIcon) - } - - fun setLargeIcon(largeIcon: String?) { - this.largeIcon = AssetUtils.getResourceBaseName(largeIcon) - } - fun getIconColor(globalColor: String): String { // use the one defined local before trying for a globally defined color return iconColor ?: globalColor @@ -73,8 +63,8 @@ class Notification { fun getSmallIcon(context: Context, defaultIcon: Int): Int { var resId: Int = AssetUtils.RESOURCE_ID_ZERO_VALUE - if (smallIcon != null) { - resId = AssetUtils.getResourceID(context, smallIcon, "drawable") + if (icon != null) { + resId = AssetUtils.getResourceID(context, icon, "drawable") } if (resId == AssetUtils.RESOURCE_ID_ZERO_VALUE) { resId = defaultIcon @@ -93,77 +83,15 @@ class Notification { val isScheduled = schedule != null companion object { - fun fromJson(jsonNotification: JSONObject): Notification { - val notification: JSObject = try { - val identifier = jsonNotification.getLong("id") - if (identifier > Int.MAX_VALUE || identifier < Int.MIN_VALUE) { - throw Exception("The notification identifier should be a 32-bit integer") - } - JSObject.fromJSONObject(jsonNotification) - } catch (e: JSONException) { - throw Exception("Invalid notification JSON object", e) - } - return fromJSObject(notification) - } - - fun fromJSObject(jsonObject: JSObject): Notification { - val notification = Notification() - notification.source = jsonObject - notification.id = jsonObject.getInteger("id") ?: throw Exception("Missing notification identifier") - notification.body = jsonObject.getString("body", null) - notification.largeBody = jsonObject.getString("largeBody", null) - notification.summary = jsonObject.getString("summary", null) - notification.actionTypeId = jsonObject.getString("actionTypeId", null) - notification.group = jsonObject.getString("group", null) - notification.setSound(jsonObject.getString("sound", null)) - notification.title = jsonObject.getString("title", null) - notification.setSmallIcon(jsonObject.getString("icon", null)) - notification.setLargeIcon(jsonObject.getString("largeIcon", null)) - notification.iconColor = jsonObject.getString("iconColor", null) - notification.attachments = NotificationAttachment.getAttachments(jsonObject) - notification.isGroupSummary = jsonObject.getBoolean("groupSummary", false) - notification.channelId = jsonObject.getString("channelId", null) - val schedule = jsonObject.getJSObject("schedule") - if (schedule != null) { - notification.schedule = NotificationSchedule(schedule) - } - notification.extra = jsonObject.getJSObject("extra") - notification.isOngoing = jsonObject.getBoolean("ongoing", false) - notification.isAutoCancel = jsonObject.getBoolean("autoCancel", true) - notification.visibility = jsonObject.getInteger("visibility") - notification.number = jsonObject.getInteger("number") - try { - val inboxLines = jsonObject.getJSONArray("inboxLines") - val inboxStringList: MutableList = ArrayList() - for (i in 0 until inboxLines.length()) { - inboxStringList.add(inboxLines.getString(i)) - } - notification.inboxLines = inboxStringList - } catch (_: Exception) { - } - return notification - } - - fun buildNotificationPendingList(notifications: List): JSObject { - val result = JSObject() - val jsArray = JSArray() + fun buildNotificationPendingList(notifications: List): List { + val pendingNotifications = mutableListOf() for (notification in notifications) { - val jsNotification = JSObject() - jsNotification.put("id", notification.id) - jsNotification.put("title", notification.title) - jsNotification.put("body", notification.body) - val schedule = notification.schedule - if (schedule != null) { - val jsSchedule = JSObject() - jsSchedule.put("kind", schedule.scheduleObj.getString("kind", null)) - jsSchedule.put("data", schedule.scheduleObj.getJSObject("data")) - jsNotification.put("schedule", jsSchedule) - } - jsNotification.put("extra", notification.extra) - jsArray.put(jsNotification) + val pendingNotification = PendingNotification(notification.id, notification.title, notification.body, notification.schedule, notification.extra) + pendingNotifications.add(pendingNotification) } - result.put("notifications", jsArray) - return result + return pendingNotifications } } -} \ No newline at end of file +} + +class PendingNotification(val id: Int, val title: String?, val body: String?, val schedule: NotificationSchedule?, val extra: JSObject?) \ No newline at end of file diff --git a/plugins/notification/android/src/main/java/NotificationAction.kt b/plugins/notification/android/src/main/java/NotificationAction.kt deleted file mode 100644 index d50d0fe99..000000000 --- a/plugins/notification/android/src/main/java/NotificationAction.kt +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2019-2023 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - -package app.tauri.notification - -import app.tauri.Logger -import app.tauri.plugin.JSArray -import app.tauri.plugin.JSObject -import org.json.JSONObject - -class NotificationAction() { - var id: String? = null - var title: String? = null - var input = false - - constructor(id: String?, title: String?, input: Boolean): this() { - this.id = id - this.title = title - this.input = input - } - - companion object { - fun buildTypes(types: JSArray): Map> { - val actionTypeMap: MutableMap> = HashMap() - try { - val objects: List = types.toList() - for (obj in objects) { - val jsObject = JSObject.fromJSONObject( - obj - ) - val actionGroupId = jsObject.getString("id") - val actions = jsObject.getJSONArray("actions") - val typesArray = mutableListOf() - for (i in 0 until actions.length()) { - val notificationAction = NotificationAction() - val action = JSObject.fromJSONObject(actions.getJSONObject(i)) - notificationAction.id = action.getString("id") - notificationAction.title = action.getString("title") - notificationAction.input = action.getBoolean("input") - typesArray.add(notificationAction) - } - actionTypeMap[actionGroupId] = typesArray.toList() - } - } catch (e: Exception) { - Logger.error(Logger.tags("Notification"), "Error when building action types", e) - } - return actionTypeMap - } - } -} \ No newline at end of file diff --git a/plugins/notification/android/src/main/java/NotificationPlugin.kt b/plugins/notification/android/src/main/java/NotificationPlugin.kt index 2b6043dc8..4b833dbc0 100644 --- a/plugins/notification/android/src/main/java/NotificationPlugin.kt +++ b/plugins/notification/android/src/main/java/NotificationPlugin.kt @@ -14,6 +14,7 @@ import android.os.Build import android.webkit.WebView import app.tauri.PermissionState import app.tauri.annotation.Command +import app.tauri.annotation.InvokeArg import app.tauri.annotation.Permission import app.tauri.annotation.PermissionCallback import app.tauri.annotation.TauriPlugin @@ -21,11 +22,55 @@ import app.tauri.plugin.Invoke import app.tauri.plugin.JSArray import app.tauri.plugin.JSObject import app.tauri.plugin.Plugin -import org.json.JSONException -import org.json.JSONObject const val LOCAL_NOTIFICATIONS = "permissionState" +@InvokeArg +class PluginConfig { + var icon: String? = null + var sound: String? = null + var iconColor: String? = null +} + +@InvokeArg +class BatchArgs { + lateinit var notifications: List +} + +@InvokeArg +class CancelArgs { + lateinit var notifications: List +} + +@InvokeArg +class NotificationAction { + lateinit var id: String + var title: String? = null + var input: Boolean? = null +} + +@InvokeArg +class ActionType { + lateinit var id: String + lateinit var actions: List +} + +@InvokeArg +class RegisterActionTypesArgs { + lateinit var types: List +} + +@InvokeArg +class ActiveNotification { + var id: Int = 0 + var tag: String? = null +} + +@InvokeArg +class RemoveActiveArgs { + var notifications: List = listOf() +} + @TauriPlugin( permissions = [ Permission(strings = [Manifest.permission.POST_NOTIFICATIONS], alias = "permissionState") @@ -41,8 +86,8 @@ class NotificationPlugin(private val activity: Activity): Plugin(activity) { companion object { var instance: NotificationPlugin? = null - fun triggerNotification(notification: JSObject) { - instance?.trigger("notification", notification) + fun triggerNotification(notification: Notification) { + instance?.triggerObject("notification", notification) } } @@ -51,23 +96,32 @@ class NotificationPlugin(private val activity: Activity): Plugin(activity) { super.load(webView) this.webView = webView - notificationStorage = NotificationStorage(activity) + notificationStorage = NotificationStorage(activity, jsonMapper()) val manager = TauriNotificationManager( notificationStorage, activity, activity, - getConfig() + getConfig(PluginConfig::class.java) ) manager.createNotificationChannel() this.manager = manager notificationManager = activity.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager + + val intent = activity.intent + intent?.let { + onIntent(it) + } } override fun onNewIntent(intent: Intent) { super.onNewIntent(intent) + onIntent(intent) + } + + fun onIntent(intent: Intent) { if (Intent.ACTION_MAIN != intent.action) { return } @@ -79,80 +133,43 @@ class NotificationPlugin(private val activity: Activity): Plugin(activity) { @Command fun show(invoke: Invoke) { - val notification = Notification.fromJSObject(invoke.data) + val notification = invoke.parseArgs(Notification::class.java) val id = manager.schedule(notification) - val returnVal = JSObject().put("id", id) - invoke.resolve(returnVal) + invoke.resolveObject(id) } @Command fun batch(invoke: Invoke) { - val notificationArray = invoke.getArray("notifications") - if (notificationArray == null) { - invoke.reject("Missing `notifications` argument") - return - } - - val notifications: MutableList = - ArrayList(notificationArray.length()) - val notificationsInput: List = try { - notificationArray.toList() - } catch (e: JSONException) { - invoke.reject("Provided notification format is invalid") - return - } + val args = invoke.parseArgs(BatchArgs::class.java) - for (jsonNotification in notificationsInput) { - val notification = Notification.fromJson(jsonNotification) - notifications.add(notification) - } - - val ids = manager.schedule(notifications) - notificationStorage.appendNotifications(notifications) + val ids = manager.schedule(args.notifications) + notificationStorage.appendNotifications(args.notifications) - val result = JSObject() - result.put("notifications", ids) - invoke.resolve(result) + invoke.resolveObject(ids) } @Command fun cancel(invoke: Invoke) { - val notifications: List = invoke.getArray("notifications", JSArray()).toList() - if (notifications.isEmpty()) { - invoke.reject("Must provide notifications array as notifications option") - return - } - - manager.cancel(notifications) + val args = invoke.parseArgs(CancelArgs::class.java) + manager.cancel(args.notifications) invoke.resolve() } @Command fun removeActive(invoke: Invoke) { - val notifications = invoke.getArray("notifications") - if (notifications == null) { + val args = invoke.parseArgs(RemoveActiveArgs::class.java) + + if (args.notifications.isEmpty()) { notificationManager.cancelAll() invoke.resolve() } else { - try { - for (o in notifications.toList()) { - if (o is JSONObject) { - val notification = JSObject.fromJSONObject((o)) - val tag = notification.getString("tag", null) - val id = notification.getInteger("id", 0) - if (tag == null) { - notificationManager.cancel(id) - } else { - notificationManager.cancel(tag, id) - } - } else { - invoke.reject("Unexpected notification type") - return - } + for (notification in args.notifications) { + if (notification.tag == null) { + notificationManager.cancel(notification.id) + } else { + notificationManager.cancel(notification.tag, notification.id) } - } catch (e: JSONException) { - invoke.reject(e.message) } invoke.resolve() } @@ -162,14 +179,13 @@ class NotificationPlugin(private val activity: Activity): Plugin(activity) { fun getPending(invoke: Invoke) { val notifications= notificationStorage.getSavedNotifications() val result = Notification.buildNotificationPendingList(notifications) - invoke.resolve(result) + invoke.resolveObject(result) } @Command fun registerActionTypes(invoke: Invoke) { - val types = invoke.getArray("types", JSArray()) - val typesArray = NotificationAction.buildTypes(types) - notificationStorage.writeActionGroup(typesArray) + val args = invoke.parseArgs(RegisterActionTypesArgs::class.java) + notificationStorage.writeActionGroup(args.types) invoke.resolve() } @@ -201,9 +217,8 @@ class NotificationPlugin(private val activity: Activity): Plugin(activity) { notifications.put(jsNotification) } } - val result = JSObject() - result.put("notifications", notifications) - invoke.resolve(result) + + invoke.resolveObject(notifications) } @Command diff --git a/plugins/notification/android/src/main/java/NotificationSchedule.kt b/plugins/notification/android/src/main/java/NotificationSchedule.kt index 64c83486d..84bad6faf 100644 --- a/plugins/notification/android/src/main/java/NotificationSchedule.kt +++ b/plugins/notification/android/src/main/java/NotificationSchedule.kt @@ -5,13 +5,26 @@ package app.tauri.notification import android.annotation.SuppressLint +import android.content.ClipData.Item import android.text.format.DateUtils -import app.tauri.plugin.JSObject +import com.fasterxml.jackson.annotation.JsonFormat +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.JsonParser +import com.fasterxml.jackson.core.JsonProcessingException +import com.fasterxml.jackson.databind.DeserializationContext +import com.fasterxml.jackson.databind.JsonDeserializer +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.ser.std.StdSerializer +import java.io.IOException import java.text.SimpleDateFormat import java.util.Calendar import java.util.Date import java.util.TimeZone + const val JS_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" enum class NotificationInterval { @@ -33,70 +46,88 @@ fun getIntervalTime(interval: NotificationInterval, count: Int): Long { } } -sealed class ScheduleKind { +@JsonDeserialize(using = NotificationScheduleDeserializer::class) +@JsonSerialize(using = NotificationScheduleSerializer::class) +sealed class NotificationSchedule { // At specific moment of time (with repeating option) - class At(var date: Date, val repeating: Boolean): ScheduleKind() - class Interval(val interval: DateMatch): ScheduleKind() - class Every(val interval: NotificationInterval, val count: Int): ScheduleKind() + class At(@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = JS_DATE_FORMAT) var date: Date, val repeating: Boolean = false, val allowWhileIdle: Boolean = false): NotificationSchedule() + class Interval(val interval: DateMatch, val allowWhileIdle: Boolean = false): NotificationSchedule() + class Every(val interval: NotificationInterval, val count: Int = 0, val allowWhileIdle: Boolean = false): NotificationSchedule() + + fun isRemovable(): Boolean { + return when (this) { + is At -> !repeating + else -> false + } + } + + fun allowWhileIdle(): Boolean { + return when (this) { + is At -> allowWhileIdle + is Interval -> allowWhileIdle + is Every -> allowWhileIdle + else -> false + } + } } -@SuppressLint("SimpleDateFormat") -class NotificationSchedule(val scheduleObj: JSObject) { - val kind: ScheduleKind - // Schedule this notification to fire even if app is idled (Doze) - var whileIdle: Boolean = false +internal class NotificationScheduleSerializer @JvmOverloads constructor(t: Class? = null) : + StdSerializer(t) { + @SuppressLint("SimpleDateFormat") + @Throws(IOException::class, JsonProcessingException::class) + override fun serialize( + value: NotificationSchedule, jgen: JsonGenerator, provider: SerializerProvider + ) { + jgen.writeStartObject() + when (value) { + is NotificationSchedule.At -> { + jgen.writeObjectFieldStart("at") - init { - val payload = scheduleObj.getJSObject("data", JSObject()) + val sdf = SimpleDateFormat(JS_DATE_FORMAT) + sdf.timeZone = TimeZone.getTimeZone("UTC") + jgen.writeStringField("date", sdf.format(value.date)) + jgen.writeBooleanField("repeating", value.repeating) - when (val scheduleKind = scheduleObj.getString("kind", "")) { - "At" -> { - val dateString = payload.getString("date") - if (dateString.isNotEmpty()) { - val sdf = SimpleDateFormat(JS_DATE_FORMAT) - sdf.timeZone = TimeZone.getTimeZone("UTC") - val at = sdf.parse(dateString) - if (at == null) { - throw Exception("could not parse `at` date") - } else { - kind = ScheduleKind.At(at, payload.getBoolean("repeating")) - } - } else { - throw Exception("`at` date cannot be empty") - } - } - "Interval" -> { - val dateMatch = onFromJson(payload) - kind = ScheduleKind.Interval(dateMatch) + jgen.writeEndObject() } - "Every" -> { - val interval = NotificationInterval.valueOf(payload.getString("interval")) - kind = ScheduleKind.Every(interval, payload.getInteger("count", 1)) + is NotificationSchedule.Interval -> { + jgen.writeObjectFieldStart("interval") + + jgen.writeObjectField("interval", value.interval) + + jgen.writeEndObject() } - else -> { - throw Exception("Unknown schedule kind $scheduleKind") + is NotificationSchedule.Every -> { + jgen.writeObjectFieldStart("every") + + jgen.writeObjectField("interval", value.interval) + jgen.writeNumberField("count", value.count) + + jgen.writeEndObject() } + else -> {} } - whileIdle = scheduleObj.getBoolean("allowWhileIdle", false) - } - private fun onFromJson(onJson: JSObject): DateMatch { - val match = DateMatch() - match.year = onJson.getInteger("year") - match.month = onJson.getInteger("month") - match.day = onJson.getInteger("day") - match.weekday = onJson.getInteger("weekday") - match.hour = onJson.getInteger("hour") - match.minute = onJson.getInteger("minute") - match.second = onJson.getInteger("second") - return match + jgen.writeEndObject() } +} - fun isRemovable(): Boolean { - return when (kind) { - is ScheduleKind.At -> !kind.repeating - else -> false +internal class NotificationScheduleDeserializer: JsonDeserializer() { + override fun deserialize( + jsonParser: JsonParser, + deserializationContext: DeserializationContext + ): NotificationSchedule { + val node: JsonNode = jsonParser.codec.readTree(jsonParser) + node.get("at")?.let { + return jsonParser.codec.treeToValue(it, NotificationSchedule.At::class.java) + } + node.get("interval")?.let { + return jsonParser.codec.treeToValue(it, NotificationSchedule.Interval::class.java) + } + node.get("every")?.let { + return jsonParser.codec.treeToValue(it, NotificationSchedule.Every::class.java) } + throw Error("unknown schedule kind $node") } } diff --git a/plugins/notification/android/src/main/java/NotificationStorage.kt b/plugins/notification/android/src/main/java/NotificationStorage.kt index 4d55a9a45..273b37c87 100644 --- a/plugins/notification/android/src/main/java/NotificationStorage.kt +++ b/plugins/notification/android/src/main/java/NotificationStorage.kt @@ -6,23 +6,23 @@ package app.tauri.notification import android.content.Context import android.content.SharedPreferences -import app.tauri.plugin.JSObject +import com.fasterxml.jackson.databind.ObjectMapper import org.json.JSONException -import java.text.ParseException +import java.lang.Exception // Key for private preferences private const val NOTIFICATION_STORE_ID = "NOTIFICATION_STORE" // Key used to save action types private const val ACTION_TYPES_ID = "ACTION_TYPE_STORE" -class NotificationStorage(private val context: Context) { +class NotificationStorage(private val context: Context, private val jsonMapper: ObjectMapper) { fun appendNotifications(localNotifications: List) { val storage = getStorage(NOTIFICATION_STORE_ID) val editor = storage.edit() for (request in localNotifications) { if (request.isScheduled) { val key: String = request.id.toString() - editor.putString(key, request.source.toString()) + editor.putString(key, request.sourceJson.toString()) } } editor.apply() @@ -43,57 +43,29 @@ class NotificationStorage(private val context: Context) { val notifications = ArrayList() for (key in all.keys) { val notificationString = all[key] as String? - val jsNotification = getNotificationFromJSONString(notificationString) - if (jsNotification != null) { - try { - val notification = - Notification.fromJSObject(jsNotification) - notifications.add(notification) - } catch (_: ParseException) { - } - } + try { + val notification = jsonMapper.readValue(notificationString, Notification::class.java) + notifications.add(notification) + } catch (_: Exception) { } } return notifications } return ArrayList() } - private fun getNotificationFromJSONString(notificationString: String?): JSObject? { - if (notificationString == null) { - return null - } - val jsNotification = try { - JSObject(notificationString) - } catch (ex: JSONException) { - return null - } - return jsNotification - } - - fun getSavedNotificationAsJSObject(key: String?): JSObject? { + fun getSavedNotification(key: String): Notification? { val storage = getStorage(NOTIFICATION_STORE_ID) val notificationString = try { storage.getString(key, null) } catch (ex: ClassCastException) { return null } ?: return null - - val jsNotification = try { - JSObject(notificationString) - } catch (ex: JSONException) { - return null - } - return jsNotification - } - fun getSavedNotification(key: String?): Notification? { - val jsNotification = getSavedNotificationAsJSObject(key) ?: return null - val notification = try { - Notification.fromJSObject(jsNotification) - } catch (ex: ParseException) { - return null + return try { + jsonMapper.readValue(notificationString, Notification::class.java) + } catch (ex: JSONException) { + null } - return notification } fun deleteNotification(id: String?) { @@ -106,15 +78,16 @@ class NotificationStorage(private val context: Context) { return context.getSharedPreferences(key, Context.MODE_PRIVATE) } - fun writeActionGroup(typesMap: Map>) { - for ((id, notificationActions) in typesMap) { - val editor = getStorage(ACTION_TYPES_ID + id).edit() + fun writeActionGroup(actions: List) { + for (type in actions) { + val i = type.id + val editor = getStorage(ACTION_TYPES_ID + type.id).edit() editor.clear() - editor.putInt("count", notificationActions.size) - for (i in notificationActions.indices) { - editor.putString("id$i", notificationActions[i].id) - editor.putString("title$i", notificationActions[i].title) - editor.putBoolean("input$i", notificationActions[i].input) + editor.putInt("count", type.actions.size) + for (action in type.actions) { + editor.putString("id$i", action.id) + editor.putString("title$i", action.title) + editor.putBoolean("input$i", action.input ?: false) } editor.apply() } @@ -128,7 +101,12 @@ class NotificationStorage(private val context: Context) { val id = storage.getString("id$i", "") val title = storage.getString("title$i", "") val input = storage.getBoolean("input$i", false) - actions[i] = NotificationAction(id, title, input) + + val action = NotificationAction() + action.id = id ?: "" + action.title = title + action.input = input + actions[i] = action } return actions } diff --git a/plugins/notification/android/src/main/java/TauriNotificationManager.kt b/plugins/notification/android/src/main/java/TauriNotificationManager.kt index 2f9480692..e653fab7c 100644 --- a/plugins/notification/android/src/main/java/TauriNotificationManager.kt +++ b/plugins/notification/android/src/main/java/TauriNotificationManager.kt @@ -26,6 +26,7 @@ import androidx.core.app.RemoteInput import app.tauri.Logger import app.tauri.plugin.JSObject import app.tauri.plugin.PluginManager +import com.fasterxml.jackson.databind.ObjectMapper import org.json.JSONException import org.json.JSONObject import java.text.SimpleDateFormat @@ -44,7 +45,7 @@ class TauriNotificationManager( private val storage: NotificationStorage, private val activity: Activity?, private val context: Context, - private val config: JSObject + private val config: PluginConfig? ) { private var defaultSoundID: Int = AssetUtils.RESOURCE_ID_ZERO_VALUE private var defaultSmallIconID: Int = AssetUtils.RESOURCE_ID_ZERO_VALUE @@ -200,7 +201,7 @@ class TauriNotificationManager( mBuilder.setOnlyAlertOnce(true) mBuilder.setSmallIcon(notification.getSmallIcon(context, getDefaultSmallIcon(context))) mBuilder.setLargeIcon(notification.getLargeIcon(context)) - val iconColor = notification.getIconColor(config.getString("iconColor")) + val iconColor = notification.getIconColor(config?.iconColor ?: "") if (iconColor.isNotEmpty()) { try { mBuilder.color = Color.parseColor(iconColor) @@ -216,7 +217,7 @@ class TauriNotificationManager( } else { notificationManager.notify(notification.id, buildNotification) try { - NotificationPlugin.triggerNotification(notification.source ?: JSObject()) + NotificationPlugin.triggerNotification(notification) } catch (_: JSONException) { } } @@ -254,7 +255,7 @@ class TauriNotificationManager( notificationAction.title, actionPendingIntent ) - if (notificationAction.input) { + if (notificationAction.input == true) { val remoteInput = RemoteInput.Builder(REMOTE_INPUT_KEY).setLabel( notificationAction.title ).build() @@ -298,7 +299,7 @@ class TauriNotificationManager( intent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP intent.putExtra(NOTIFICATION_INTENT_KEY, notification.id) intent.putExtra(ACTION_INTENT_KEY, action) - intent.putExtra(NOTIFICATION_OBJ_INTENT_KEY, notification.source.toString()) + intent.putExtra(NOTIFICATION_OBJ_INTENT_KEY, notification.sourceJson) val schedule = notification.schedule intent.putExtra(NOTIFICATION_IS_REMOVABLE_KEY, schedule == null || schedule.isRemovable()) return intent @@ -326,23 +327,22 @@ class TauriNotificationManager( var pendingIntent = PendingIntent.getBroadcast(context, request.id, notificationIntent, flags) - when (val scheduleKind = schedule?.kind) { - is ScheduleKind.At -> { - val at = scheduleKind.date - if (at.time < Date().time) { + when (schedule) { + is NotificationSchedule.At -> { + if (schedule.date.time < Date().time) { Logger.error(Logger.tags("Notification"), "Scheduled time must be *after* current time", null) return } - if (scheduleKind.repeating) { - val interval: Long = at.time - Date().time - alarmManager.setRepeating(AlarmManager.RTC, at.time, interval, pendingIntent) + if (schedule.repeating) { + val interval: Long = schedule.date.time - Date().time + alarmManager.setRepeating(AlarmManager.RTC, schedule.date.time, interval, pendingIntent) } else { - setExactIfPossible(alarmManager, schedule, at.time, pendingIntent) + setExactIfPossible(alarmManager, schedule, schedule.date.time, pendingIntent) } } - is ScheduleKind.Interval -> { - val trigger = scheduleKind.interval.nextTrigger(Date()) - notificationIntent.putExtra(TimedNotificationPublisher.CRON_KEY, scheduleKind.interval.toMatchString()) + is NotificationSchedule.Interval -> { + val trigger = schedule.interval.nextTrigger(Date()) + notificationIntent.putExtra(TimedNotificationPublisher.CRON_KEY, schedule.interval.toMatchString()) pendingIntent = PendingIntent.getBroadcast(context, request.id, notificationIntent, flags) setExactIfPossible(alarmManager, schedule, trigger, pendingIntent) @@ -352,8 +352,8 @@ class TauriNotificationManager( "notification " + request.id + " will next fire at " + sdf.format(Date(trigger)) ) } - is ScheduleKind.Every -> { - val everyInterval = getIntervalTime(scheduleKind.interval, scheduleKind.count) + is NotificationSchedule.Every -> { + val everyInterval = getIntervalTime(schedule.interval, schedule.count) val startTime: Long = Date().time + everyInterval alarmManager.setRepeating(AlarmManager.RTC, startTime, everyInterval, pendingIntent) } @@ -369,13 +369,13 @@ class TauriNotificationManager( pendingIntent: PendingIntent ) { if (SDK_INT >= Build.VERSION_CODES.S && !alarmManager.canScheduleExactAlarms()) { - if (SDK_INT >= Build.VERSION_CODES.M && schedule.whileIdle) { + if (SDK_INT >= Build.VERSION_CODES.M && schedule.allowWhileIdle()) { alarmManager.setAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, trigger, pendingIntent) } else { alarmManager[AlarmManager.RTC, trigger] = pendingIntent } } else { - if (SDK_INT >= Build.VERSION_CODES.M && schedule.whileIdle) { + if (SDK_INT >= Build.VERSION_CODES.M && schedule.allowWhileIdle()) { alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, trigger, pendingIntent) } else { alarmManager.setExact(AlarmManager.RTC, trigger, pendingIntent) @@ -426,7 +426,7 @@ class TauriNotificationManager( private fun getDefaultSound(context: Context): Int { if (defaultSoundID != AssetUtils.RESOURCE_ID_ZERO_VALUE) return defaultSoundID var resId: Int = AssetUtils.RESOURCE_ID_ZERO_VALUE - val soundConfigResourceName = AssetUtils.getResourceBaseName(config.getString("sound")) + val soundConfigResourceName = AssetUtils.getResourceBaseName(config?.sound) if (soundConfigResourceName != null) { resId = AssetUtils.getResourceID(context, soundConfigResourceName, "raw") } @@ -437,7 +437,7 @@ class TauriNotificationManager( private fun getDefaultSmallIcon(context: Context): Int { if (defaultSmallIconID != AssetUtils.RESOURCE_ID_ZERO_VALUE) return defaultSmallIconID var resId: Int = AssetUtils.RESOURCE_ID_ZERO_VALUE - val smallIconConfigResourceName = AssetUtils.getResourceBaseName(config.getString("icon")) + val smallIconConfigResourceName = AssetUtils.getResourceBaseName(config?.icon) if (smallIconConfigResourceName != null) { resId = AssetUtils.getResourceID(context, smallIconConfigResourceName, "drawable") } @@ -460,7 +460,7 @@ class NotificationDismissReceiver : BroadcastReceiver() { val isRemovable = intent.getBooleanExtra(NOTIFICATION_IS_REMOVABLE_KEY, true) if (isRemovable) { - val notificationStorage = NotificationStorage(context) + val notificationStorage = NotificationStorage(context, ObjectMapper()) notificationStorage.deleteNotification(intExtra.toString()) } } @@ -486,11 +486,13 @@ class TimedNotificationPublisher : BroadcastReceiver() { if (id == Int.MIN_VALUE) { Logger.error(Logger.tags("Notification"), "No valid id supplied", null) } - val storage = NotificationStorage(context) - val notificationJson = storage.getSavedNotificationAsJSObject(id.toString()) - if (notificationJson != null) { - NotificationPlugin.triggerNotification(notificationJson) + val storage = NotificationStorage(context, ObjectMapper()) + + val savedNotification = storage.getSavedNotification(id.toString()) + if (savedNotification != null) { + NotificationPlugin.triggerNotification(savedNotification) } + notificationManager.notify(id, notification) if (!rescheduleNotificationIfNeeded(context, intent, id)) { storage.deleteNotification(id.toString()) @@ -545,19 +547,19 @@ class LocalNotificationRestoreReceiver : BroadcastReceiver() { ) if (um == null || !um.isUserUnlocked) return } - val storage = NotificationStorage(context) + val storage = NotificationStorage(context, ObjectMapper()) val ids = storage.getSavedNotificationIds() val notifications = mutableListOf() val updatedNotifications = mutableListOf() for (id in ids) { val notification = storage.getSavedNotification(id) ?: continue val schedule = notification.schedule - if (schedule != null && schedule.kind is ScheduleKind.At) { - val at: Date = schedule.kind.date + if (schedule != null && schedule is NotificationSchedule.At) { + val at: Date = schedule.date if (at.before(Date())) { // modify the scheduled date in order to show notifications that would have been delivered while device was off. val newDateTime = Date().time + 15 * 1000 - schedule.kind.date = Date(newDateTime) + schedule.date = Date(newDateTime) updatedNotifications.add(notification) } } @@ -567,7 +569,13 @@ class LocalNotificationRestoreReceiver : BroadcastReceiver() { storage.appendNotifications(updatedNotifications) } - val notificationManager = TauriNotificationManager(storage, null, context, PluginManager.loadConfig(context, "notification")) + var config: PluginConfig? = null + try { + config = PluginManager.loadConfig(context, "notification", PluginConfig::class.java) + } catch (ex: Exception) { + ex.printStackTrace() + } + val notificationManager = TauriNotificationManager(storage, null, context, config) notificationManager.schedule(notifications) } } diff --git a/plugins/notification/build.rs b/plugins/notification/build.rs index ea12ef852..da7cd3cc4 100644 --- a/plugins/notification/build.rs +++ b/plugins/notification/build.rs @@ -10,7 +10,7 @@ fn main() { { println!("{error:#}"); // when building documentation for Android the plugin build result is irrelevant to the crate itself - if !(cfg!(feature = "dox") && std::env::var("TARGET").unwrap().contains("android")) { + if !(cfg!(docsrs) && std::env::var("TARGET").unwrap().contains("android")) { std::process::exit(1); } } diff --git a/plugins/notification/guest-js/index.ts b/plugins/notification/guest-js/index.ts index 16ecca7ee..a79714b54 100644 --- a/plugins/notification/guest-js/index.ts +++ b/plugins/notification/guest-js/index.ts @@ -150,57 +150,62 @@ type ScheduleInterval = { }; enum ScheduleEvery { - Year = "Year", - Month = "Month", - TwoWeeks = "TwoWeeks", - Week = "Week", - Day = "Day", - Hour = "Hour", - Minute = "Minute", + Year = "year", + Month = "month", + TwoWeeks = "twoWeeks", + Week = "week", + Day = "day", + Hour = "hour", + Minute = "minute", /** * Not supported on iOS. */ - Second = "Second", + Second = "second", } type ScheduleData = | { - kind: "At"; - data: { + at: { date: Date; repeating: boolean; + allowWhileIdle: boolean; }; } | { - kind: "Interval"; - data: ScheduleInterval; + interval: { + interval: ScheduleInterval; + allowWhileIdle: boolean; + }; } | { - kind: "Every"; - data: { + every: { interval: ScheduleEvery; + count: number; + allowWhileIdle: boolean; }; }; class Schedule { - kind: string; - data: unknown; + schedule: ScheduleData; private constructor(schedule: ScheduleData) { - this.kind = schedule.kind; - this.data = schedule.data; + this.schedule = schedule; + } + + toJSON(): string { + return JSON.stringify(this.schedule); } - static at(date: Date, repeating = false) { - return new Schedule({ kind: "At", data: { date, repeating } }); + static at(date: Date, repeating = false, allowWhileIdle = false) { + return new Schedule({ at: { date, repeating, allowWhileIdle } }); } - static interval(interval: ScheduleInterval) { - return new Schedule({ kind: "Interval", data: interval }); + static interval(interval: ScheduleInterval, allowWhileIdle = false) { + return new Schedule({ interval: { interval, allowWhileIdle } }); } - static every(kind: ScheduleEvery) { - return new Schedule({ kind: "Every", data: { interval: kind } }); + static every(kind: ScheduleEvery, count: number, allowWhileIdle = false) { + return new Schedule({ every: { interval: kind, count, allowWhileIdle } }); } } @@ -461,7 +466,9 @@ async function active(): Promise { * * @since 2.0.0 */ -async function removeActive(notifications: number[]): Promise { +async function removeActive( + notifications: { id: number; tag?: string }[], +): Promise { return invoke("plugin:notification|remove_active", { notifications }); } @@ -483,7 +490,7 @@ async function removeAllActive(): Promise { } /** - * Removes all active notifications. + * Creates a notification channel. * * @example * ```typescript @@ -537,7 +544,7 @@ async function removeChannel(id: string): Promise { * @since 2.0.0 */ async function channels(): Promise { - return invoke("plugin:notification|getActive"); + return invoke("plugin:notification|listChannels"); } async function onNotificationReceived( diff --git a/plugins/notification/ios/Package.swift b/plugins/notification/ios/Package.swift index 1a2c48016..9b6818696 100644 --- a/plugins/notification/ios/Package.swift +++ b/plugins/notification/ios/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.3 +// swift-tools-version:5.5 // Copyright 2019-2023 Tauri Programme within The Commons Conservancy // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT diff --git a/plugins/notification/ios/Sources/Notification.swift b/plugins/notification/ios/Sources/Notification.swift index e6f0d0773..0f572aa96 100644 --- a/plugins/notification/ios/Sources/Notification.swift +++ b/plugins/notification/ios/Sources/Notification.swift @@ -6,12 +6,7 @@ import Tauri import UserNotifications enum NotificationError: LocalizedError { - case contentNoId - case contentNoTitle - case contentNoBody case triggerRepeatIntervalTooShort - case attachmentNoId - case attachmentNoUrl case attachmentFileNotFound(path: String) case attachmentUnableToCreate(String) case pastScheduledTime @@ -19,18 +14,8 @@ enum NotificationError: LocalizedError { var errorDescription: String? { switch self { - case .contentNoId: - return "Missing notification identifier" - case .contentNoTitle: - return "Missing notification title" - case .contentNoBody: - return "Missing notification body" case .triggerRepeatIntervalTooShort: return "Schedule interval too short, must be a least 1 minute" - case .attachmentNoId: - return "Missing attachment identifier" - case .attachmentNoUrl: - return "Missing attachment URL" case .attachmentFileNotFound(let path): return "Unable to find file \(path) for attachment" case .attachmentUnableToCreate(let error): @@ -43,69 +28,56 @@ enum NotificationError: LocalizedError { } } -func makeNotificationContent(_ notification: JSObject) throws -> UNNotificationContent { - guard let title = notification["title"] as? String else { - throw NotificationError.contentNoTitle - } - guard let body = notification["body"] as? String else { - throw NotificationError.contentNoBody - } - - let extra = notification["extra"] as? JSObject ?? [:] - let schedule = notification["schedule"] as? JSObject ?? [:] +func makeNotificationContent(_ notification: Notification) throws -> UNNotificationContent { let content = UNMutableNotificationContent() - content.title = NSString.localizedUserNotificationString(forKey: title, arguments: nil) + content.title = NSString.localizedUserNotificationString( + forKey: notification.title, arguments: nil) content.body = NSString.localizedUserNotificationString( - forKey: body, + forKey: notification.body, arguments: nil) content.userInfo = [ - "__EXTRA__": extra, - "__SCHEDULE__": schedule, + "__EXTRA__": notification.extra as Any, + "__SCHEDULE__": notification.schedule as Any, ] - if let actionTypeId = notification["actionTypeId"] as? String { + if let actionTypeId = notification.actionTypeId { content.categoryIdentifier = actionTypeId } - if let threadIdentifier = notification["group"] as? String { + if let threadIdentifier = notification.group { content.threadIdentifier = threadIdentifier } - if let summaryArgument = notification["summary"] as? String { + if let summaryArgument = notification.summary { content.summaryArgument = summaryArgument } - if let sound = notification["sound"] as? String { + if let sound = notification.sound { content.sound = UNNotificationSound(named: UNNotificationSoundName(sound)) } - if let attachments = notification["attachments"] as? [JSObject] { + if let attachments = notification.attachments { content.attachments = try makeAttachments(attachments) } return content } -func makeAttachments(_ attachments: [JSObject]) throws -> [UNNotificationAttachment] { +func makeAttachments(_ attachments: [NotificationAttachment]) throws -> [UNNotificationAttachment] { var createdAttachments = [UNNotificationAttachment]() for attachment in attachments { - guard let id = attachment["id"] as? String else { - throw NotificationError.attachmentNoId - } - guard let url = attachment["url"] as? String else { - throw NotificationError.attachmentNoUrl - } - guard let urlObject = makeAttachmentUrl(url) else { - throw NotificationError.attachmentFileNotFound(path: url) + + guard let urlObject = makeAttachmentUrl(attachment.url) else { + throw NotificationError.attachmentFileNotFound(path: attachment.url) } - let options = attachment["options"] as? JSObject ?? [:] + let options = attachment.options != nil ? makeAttachmentOptions(attachment.options!) : nil do { let newAttachment = try UNNotificationAttachment( - identifier: id, url: urlObject, options: makeAttachmentOptions(options)) + identifier: attachment.id, url: urlObject, options: options) createdAttachments.append(newAttachment) } catch { throw NotificationError.attachmentUnableToCreate(error.localizedDescription) @@ -119,50 +91,37 @@ func makeAttachmentUrl(_ path: String) -> URL? { return URL(string: path) } -func makeAttachmentOptions(_ options: JSObject) -> JSObject { - var opts: JSObject = [:] +func makeAttachmentOptions(_ options: NotificationAttachmentOptions) -> [AnyHashable: Any] { + var opts: [AnyHashable: Any] = [:] - if let iosUNNotificationAttachmentOptionsTypeHintKey = options[ - "iosUNNotificationAttachmentOptionsTypeHintKey"] as? String - { - opts[UNNotificationAttachmentOptionsTypeHintKey] = iosUNNotificationAttachmentOptionsTypeHintKey + if let value = options.iosUNNotificationAttachmentOptionsTypeHintKey { + opts[UNNotificationAttachmentOptionsTypeHintKey] = value } - if let iosUNNotificationAttachmentOptionsThumbnailHiddenKey = options[ - "iosUNNotificationAttachmentOptionsThumbnailHiddenKey"] as? String - { - opts[UNNotificationAttachmentOptionsThumbnailHiddenKey] = - iosUNNotificationAttachmentOptionsThumbnailHiddenKey + if let value = options.iosUNNotificationAttachmentOptionsThumbnailHiddenKey { + opts[UNNotificationAttachmentOptionsThumbnailHiddenKey] = value } - if let iosUNNotificationAttachmentOptionsThumbnailClippingRectKey = options[ - "iosUNNotificationAttachmentOptionsThumbnailClippingRectKey"] as? String - { - opts[UNNotificationAttachmentOptionsThumbnailClippingRectKey] = - iosUNNotificationAttachmentOptionsThumbnailClippingRectKey + if let value = options.iosUNNotificationAttachmentOptionsThumbnailClippingRectKey { + opts[UNNotificationAttachmentOptionsThumbnailClippingRectKey] = value } - if let iosUNNotificationAttachmentOptionsThumbnailTimeKey = options[ - "iosUNNotificationAttachmentOptionsThumbnailTimeKey"] as? String + if let value = options + .iosUNNotificationAttachmentOptionsThumbnailTimeKey + { - opts[UNNotificationAttachmentOptionsThumbnailTimeKey] = - iosUNNotificationAttachmentOptionsThumbnailTimeKey + opts[UNNotificationAttachmentOptionsThumbnailTimeKey] = value } return opts } -func handleScheduledNotification(_ schedule: JSObject) throws +func handleScheduledNotification(_ schedule: NotificationSchedule) throws -> UNNotificationTrigger? { - let kind = schedule["kind"] as? String ?? "" - let payload = schedule["data"] as? JSObject ?? [:] - switch kind { - case "At": - let date = payload["date"] as? String ?? "" + switch schedule { + case .at(let date, let repeating): let dateFormatter = DateFormatter() dateFormatter.locale = Locale(identifier: "en_US_POSIX") dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" if let at = dateFormatter.date(from: date) { - let repeats = payload["repeats"] as? Bool ?? false - let dateInfo = Calendar.current.dateComponents(in: TimeZone.current, from: at) if dateInfo.date! < Date() { @@ -172,23 +131,20 @@ func handleScheduledNotification(_ schedule: JSObject) throws let dateInterval = DateInterval(start: Date(), end: dateInfo.date!) // Notifications that repeat have to be at least a minute between each other - if repeats && dateInterval.duration < 60 { + if repeating && dateInterval.duration < 60 { throw NotificationError.triggerRepeatIntervalTooShort } return UNTimeIntervalNotificationTrigger( - timeInterval: dateInterval.duration, repeats: repeats) + timeInterval: dateInterval.duration, repeats: repeating) } else { throw NotificationError.invalidDate(date) } - case "Interval": - let dateComponents = getDateComponents(payload) + case .interval(let interval): + let dateComponents = getDateComponents(interval) return UNCalendarNotificationTrigger(dateMatching: dateComponents, repeats: true) - case "Every": - let interval = payload["interval"] as? String ?? "" - let count = schedule["count"] as? Int ?? 1 - + case .every(let interval, let count): if let repeatDateInterval = getRepeatDateInterval(interval, count) { // Notifications that repeat have to be at least a minute between each other if repeatDateInterval.duration < 60 { @@ -198,9 +154,6 @@ func handleScheduledNotification(_ schedule: JSObject) throws return UNTimeIntervalNotificationTrigger( timeInterval: repeatDateInterval.duration, repeats: true) } - - default: - return nil } return nil @@ -209,30 +162,30 @@ func handleScheduledNotification(_ schedule: JSObject) throws /// Given our schedule format, return a DateComponents object /// that only contains the components passed in. -func getDateComponents(_ at: JSObject) -> DateComponents { +func getDateComponents(_ at: ScheduleInterval) -> DateComponents { // var dateInfo = Calendar.current.dateComponents(in: TimeZone.current, from: Date()) // dateInfo.calendar = Calendar.current var dateInfo = DateComponents() - if let year = at["year"] as? Int { + if let year = at.year { dateInfo.year = year } - if let month = at["month"] as? Int { + if let month = at.month { dateInfo.month = month } - if let day = at["day"] as? Int { + if let day = at.day { dateInfo.day = day } - if let hour = at["hour"] as? Int { + if let hour = at.hour { dateInfo.hour = hour } - if let minute = at["minute"] as? Int { + if let minute = at.minute { dateInfo.minute = minute } - if let second = at["second"] as? Int { + if let second = at.second { dateInfo.second = second } - if let weekday = at["weekday"] as? Int { + if let weekday = at.weekday { dateInfo.weekday = weekday } return dateInfo @@ -242,35 +195,33 @@ func getDateComponents(_ at: JSObject) -> DateComponents { /// interval and today. For example, if every is "month", then we /// return the interval between today and a month from today. -func getRepeatDateInterval(_ every: String, _ count: Int) -> DateInterval? { +func getRepeatDateInterval(_ every: ScheduleEveryKind, _ count: Int) -> DateInterval? { let cal = Calendar.current let now = Date() switch every { - case "Year": + case .year: let newDate = cal.date(byAdding: .year, value: count, to: now)! return DateInterval(start: now, end: newDate) - case "Month": + case .month: let newDate = cal.date(byAdding: .month, value: count, to: now)! return DateInterval(start: now, end: newDate) - case "TwoWeeks": + case .twoWeeks: let newDate = cal.date(byAdding: .weekOfYear, value: 2 * count, to: now)! return DateInterval(start: now, end: newDate) - case "Week": + case .week: let newDate = cal.date(byAdding: .weekOfYear, value: count, to: now)! return DateInterval(start: now, end: newDate) - case "Day": + case .day: let newDate = cal.date(byAdding: .day, value: count, to: now)! return DateInterval(start: now, end: newDate) - case "Hour": + case .hour: let newDate = cal.date(byAdding: .hour, value: count, to: now)! return DateInterval(start: now, end: newDate) - case "Minute": + case .minute: let newDate = cal.date(byAdding: .minute, value: count, to: now)! return DateInterval(start: now, end: newDate) - case "Second": + case .second: let newDate = cal.date(byAdding: .second, value: count, to: now)! return DateInterval(start: now, end: newDate) - default: - return nil } } diff --git a/plugins/notification/ios/Sources/NotificationCategory.swift b/plugins/notification/ios/Sources/NotificationCategory.swift index ae37ffc34..a5d4eea6b 100644 --- a/plugins/notification/ios/Sources/NotificationCategory.swift +++ b/plugins/notification/ios/Sources/NotificationCategory.swift @@ -5,21 +5,7 @@ import Tauri import UserNotifications -enum CategoryError: LocalizedError { - case noId - case noActionId - - var errorDescription: String? { - switch self { - case .noId: - return "Action type `id` missing" - case .noActionId: - return "Action `id` missing" - } - } -} - -public func makeCategories(_ actionTypes: [JSObject]) throws { +internal func makeCategories(_ actionTypes: [ActionType]) { var createdCategories = [UNNotificationCategory]() let generalCategory = UNNotificationCategory( @@ -30,22 +16,16 @@ public func makeCategories(_ actionTypes: [JSObject]) throws { createdCategories.append(generalCategory) for type in actionTypes { - guard let id = type["id"] as? String else { - throw CategoryError.noId - } - let hiddenBodyPlaceholder = type["hiddenPreviewsBodyPlaceholder"] as? String ?? "" - let actions = type["actions"] as? [JSObject] ?? [] - - let newActions = try makeActions(actions) + let newActions = makeActions(type.actions) // Create the custom actions for the TIMER_EXPIRED category. var newCategory: UNNotificationCategory? newCategory = UNNotificationCategory( - identifier: id, + identifier: type.id, actions: newActions, intentIdentifiers: [], - hiddenPreviewsBodyPlaceholder: hiddenBodyPlaceholder, + hiddenPreviewsBodyPlaceholder: type.hiddenBodyPlaceholder ?? "", options: makeCategoryOptions(type)) createdCategories.append(newCategory!) @@ -55,37 +35,28 @@ public func makeCategories(_ actionTypes: [JSObject]) throws { center.setNotificationCategories(Set(createdCategories)) } -func makeActions(_ actions: [JSObject]) throws -> [UNNotificationAction] { +func makeActions(_ actions: [Action]) -> [UNNotificationAction] { var createdActions = [UNNotificationAction]() for action in actions { - guard let id = action["id"] as? String else { - throw CategoryError.noActionId - } - let title = action["title"] as? String ?? "" - let input = action["input"] as? Bool ?? false - var newAction: UNNotificationAction - if input { - let inputButtonTitle = action["inputButtonTitle"] as? String - let inputPlaceholder = action["inputPlaceholder"] as? String ?? "" - - if inputButtonTitle != nil { + if action.input { + if action.inputButtonTitle != nil { newAction = UNTextInputNotificationAction( - identifier: id, - title: title, + identifier: action.id, + title: action.title, options: makeActionOptions(action), - textInputButtonTitle: inputButtonTitle!, - textInputPlaceholder: inputPlaceholder) + textInputButtonTitle: action.inputButtonTitle ?? "", + textInputPlaceholder: action.inputPlaceholder ?? "") } else { newAction = UNTextInputNotificationAction( - identifier: id, title: title, options: makeActionOptions(action)) + identifier: action.id, title: action.title, options: makeActionOptions(action)) } } else { // Create the custom actions for the TIMER_EXPIRED category. newAction = UNNotificationAction( - identifier: id, - title: title, + identifier: action.id, + title: action.title, options: makeActionOptions(action)) } createdActions.append(newAction) @@ -94,40 +65,31 @@ func makeActions(_ actions: [JSObject]) throws -> [UNNotificationAction] { return createdActions } -func makeActionOptions(_ action: JSObject) -> UNNotificationActionOptions { - let foreground = action["foreground"] as? Bool ?? false - let destructive = action["destructive"] as? Bool ?? false - let requiresAuthentication = action["requiresAuthentication"] as? Bool ?? false - - if foreground { +func makeActionOptions(_ action: Action) -> UNNotificationActionOptions { + if action.foreground { return .foreground } - if destructive { + if action.destructive { return .destructive } - if requiresAuthentication { + if action.requiresAuthentication { return .authenticationRequired } return UNNotificationActionOptions(rawValue: 0) } -func makeCategoryOptions(_ type: JSObject) -> UNNotificationCategoryOptions { - let customDismiss = type["customDismissAction"] as? Bool ?? false - let carPlay = type["allowInCarPlay"] as? Bool ?? false - let hiddenPreviewsShowTitle = type["hiddenPreviewsShowTitle"] as? Bool ?? false - let hiddenPreviewsShowSubtitle = type["hiddenPreviewsShowSubtitle"] as? Bool ?? false - - if customDismiss { +func makeCategoryOptions(_ type: ActionType) -> UNNotificationCategoryOptions { + if type.customDismissAction { return .customDismissAction } - if carPlay { + if type.allowInCarPlay { return .allowInCarPlay } - if hiddenPreviewsShowTitle { + if type.hiddenPreviewsShowTitle { return .hiddenPreviewsShowTitle } - if hiddenPreviewsShowSubtitle { + if type.hiddenPreviewsShowSubtitle { return .hiddenPreviewsShowSubtitle } diff --git a/plugins/notification/ios/Sources/NotificationHandler.swift b/plugins/notification/ios/Sources/NotificationHandler.swift index ac569bdf1..83ac0ae4c 100644 --- a/plugins/notification/ios/Sources/NotificationHandler.swift +++ b/plugins/notification/ios/Sources/NotificationHandler.swift @@ -9,9 +9,9 @@ public class NotificationHandler: NSObject, NotificationHandlerProtocol { public weak var plugin: Plugin? - private var notificationsMap = [String: JSObject]() + private var notificationsMap = [String: Notification]() - public func saveNotification(_ key: String, _ notification: JSObject) { + internal func saveNotification(_ key: String, _ notification: Notification) { notificationsMap.updateValue(notification, forKey: key) } @@ -30,12 +30,11 @@ public class NotificationHandler: NSObject, NotificationHandlerProtocol { } public func willPresent(notification: UNNotification) -> UNNotificationPresentationOptions { - let notificationData = makeNotificationRequestJSObject(notification.request) - self.plugin?.trigger("notification", data: notificationData) + let notificationData = toActiveNotification(notification.request) + try? self.plugin?.trigger("notification", data: notificationData) if let options = notificationsMap[notification.request.identifier] { - let silent = options["silent"] as? Bool ?? false - if silent { + if options.silent { return UNNotificationPresentationOptions.init(rawValue: 0) } } @@ -48,73 +47,72 @@ public class NotificationHandler: NSObject, NotificationHandlerProtocol { } public func didReceive(response: UNNotificationResponse) { - var data = JSObject() - let originalNotificationRequest = response.notification.request let actionId = response.actionIdentifier + var actionIdValue: String // We turn the two default actions (open/dismiss) into generic strings if actionId == UNNotificationDefaultActionIdentifier { - data["actionId"] = "tap" + actionIdValue = "tap" } else if actionId == UNNotificationDismissActionIdentifier { - data["actionId"] = "dismiss" + actionIdValue = "dismiss" } else { - data["actionId"] = actionId + actionIdValue = actionId } + var inputValue: String? = nil // If the type of action was for an input type, get the value if let inputType = response as? UNTextInputNotificationResponse { - data["inputValue"] = inputType.userText + inputValue = inputType.userText } - data["notification"] = makeNotificationRequestJSObject(originalNotificationRequest) - - self.plugin?.trigger("actionPerformed", data: data) + try? self.plugin?.trigger( + "actionPerformed", + data: ReceivedNotification( + actionId: actionIdValue, + inputValue: inputValue, + notification: toActiveNotification(originalNotificationRequest) + )) } - /** - * Turn a UNNotificationRequest into a JSObject to return back to the client. - */ - func makeNotificationRequestJSObject(_ request: UNNotificationRequest) -> JSObject { - let notificationRequest = notificationsMap[request.identifier] ?? [:] - var notification = makePendingNotificationRequestJSObject(request) - notification["sound"] = notificationRequest["sound"] ?? "" - notification["actionTypeId"] = request.content.categoryIdentifier - notification["attachments"] = notificationRequest["attachments"] ?? [JSObject]() - return notification + func toActiveNotification(_ request: UNNotificationRequest) -> ActiveNotification { + let notificationRequest = notificationsMap[request.identifier]! + return ActiveNotification( + id: Int(request.identifier) ?? -1, + title: request.content.title, + body: request.content.body, + sound: notificationRequest.sound ?? "", + actionTypeId: request.content.categoryIdentifier, + attachments: notificationRequest.attachments + ) } - func makePendingNotificationRequestJSObject(_ request: UNNotificationRequest) -> JSObject { - var notification: JSObject = [ - "id": Int(request.identifier) ?? -1, - "title": request.content.title, - "body": request.content.body, - ] - - if let userInfo = JSTypes.coerceDictionaryToJSObject(request.content.userInfo) { - var extra = userInfo["__EXTRA__"] as? JSObject ?? userInfo - - // check for any dates and convert them to strings - for (key, value) in extra { - if let date = value as? Date { - let dateString = ISO8601DateFormatter().string(from: date) - extra[key] = dateString - } - } - - notification["extra"] = extra + func toPendingNotification(_ request: UNNotificationRequest) -> PendingNotification { + return PendingNotification( + id: Int(request.identifier) ?? -1, + title: request.content.title, + body: request.content.body + ) + } +} - if var schedule = userInfo["__SCHEDULE__"] as? JSObject { - // convert schedule at date to string - if let date = schedule["at"] as? Date { - let dateString = ISO8601DateFormatter().string(from: date) - schedule["at"] = dateString - } +struct PendingNotification: Encodable { + let id: Int + let title: String + let body: String +} - notification["schedule"] = schedule - } - } +struct ActiveNotification: Encodable { + let id: Int + let title: String + let body: String + let sound: String + let actionTypeId: String + let attachments: [NotificationAttachment]? +} - return notification - } +struct ReceivedNotification: Encodable { + let actionId: String + let inputValue: String? + let notification: ActiveNotification } diff --git a/plugins/notification/ios/Sources/NotificationManager.swift b/plugins/notification/ios/Sources/NotificationManager.swift index 183b4dd51..81a585bf4 100644 --- a/plugins/notification/ios/Sources/NotificationManager.swift +++ b/plugins/notification/ios/Sources/NotificationManager.swift @@ -19,9 +19,11 @@ import UserNotifications center.delegate = self } - public func userNotificationCenter(_ center: UNUserNotificationCenter, - willPresent notification: UNNotification, - withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { + public func userNotificationCenter( + _ center: UNUserNotificationCenter, + willPresent notification: UNNotification, + withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void + ) { var presentationOptions: UNNotificationPresentationOptions? = nil if notification.request.trigger?.isKind(of: UNPushNotificationTrigger.self) != true { @@ -31,9 +33,11 @@ import UserNotifications completionHandler(presentationOptions ?? []) } - public func userNotificationCenter(_ center: UNUserNotificationCenter, - didReceive response: UNNotificationResponse, - withCompletionHandler completionHandler: @escaping () -> Void) { + public func userNotificationCenter( + _ center: UNUserNotificationCenter, + didReceive response: UNNotificationResponse, + withCompletionHandler completionHandler: @escaping () -> Void + ) { if response.notification.request.trigger?.isKind(of: UNPushNotificationTrigger.self) != true { notificationHandler?.didReceive(response: response) } diff --git a/plugins/notification/ios/Sources/NotificationPlugin.swift b/plugins/notification/ios/Sources/NotificationPlugin.swift index 2f431c73c..53c9788e0 100644 --- a/plugins/notification/ios/Sources/NotificationPlugin.swift +++ b/plugins/notification/ios/Sources/NotificationPlugin.swift @@ -9,14 +9,11 @@ import UserNotifications import WebKit enum ShowNotificationError: LocalizedError { - case noId case make(Error) case create(Error) var errorDescription: String? { switch self { - case .noId: - return "notification `id` missing" case .make(let error): return "Unable to make notification: \(error)" case .create(let error): @@ -25,13 +22,71 @@ enum ShowNotificationError: LocalizedError { } } -func showNotification(invoke: Invoke, notification: JSObject) +enum ScheduleEveryKind: String, Decodable { + case year + case month + case twoWeeks + case week + case day + case hour + case minute + case second +} + +struct ScheduleInterval: Decodable { + let year: Int? + let month: Int? + let day: Int? + let weekday: Int? + let hour: Int? + let minute: Int? + let second: Int? +} + +enum NotificationSchedule: Decodable { + case at(date: String, repeating: Bool) + case interval(interval: ScheduleInterval) + case every(interval: ScheduleEveryKind, count: Int) +} + +struct NotificationAttachmentOptions: Codable { + let iosUNNotificationAttachmentOptionsTypeHintKey: String? + let iosUNNotificationAttachmentOptionsThumbnailHiddenKey: String? + let iosUNNotificationAttachmentOptionsThumbnailClippingRectKey: String? + let iosUNNotificationAttachmentOptionsThumbnailTimeKey: String? +} + +struct NotificationAttachment: Codable { + let id: String + let url: String + let options: NotificationAttachmentOptions? +} + +struct Notification: Decodable { + let id: Int + var title: String = "" + var body: String = "" + var extra: [String: String] = [:] + let schedule: NotificationSchedule? + let attachments: [NotificationAttachment]? + let sound: String? + let group: String? + let actionTypeId: String? + let summary: String? + var silent = false +} + +struct RemoveActiveNotification: Decodable { + let id: Int +} + +struct RemoveActiveArgs: Decodable { + let notifications: [RemoveActiveNotification] +} + +func showNotification(invoke: Invoke, notification: Notification) throws -> UNNotificationRequest { - guard let identifier = notification["id"] as? Int else { - throw ShowNotificationError.noId - } - var content: UNNotificationContent do { content = try makeNotificationContent(notification) @@ -42,7 +97,7 @@ func showNotification(invoke: Invoke, notification: JSObject) var trigger: UNNotificationTrigger? do { - if let schedule = notification["schedule"] as? JSObject { + if let schedule = notification.schedule { try trigger = handleScheduledNotification(schedule) } } catch { @@ -51,7 +106,7 @@ func showNotification(invoke: Invoke, notification: JSObject) // Schedule the request. let request = UNNotificationRequest( - identifier: "\(identifier)", content: content, trigger: trigger + identifier: "\(notification.id)", content: content, trigger: trigger ) let center = UNUserNotificationCenter.current() @@ -64,6 +119,40 @@ func showNotification(invoke: Invoke, notification: JSObject) return request } +struct CancelArgs: Decodable { + let notifications: [Int] +} + +struct Action: Decodable { + let id: String + let title: String + var requiresAuthentication: Bool = false + var foreground: Bool = false + var destructive: Bool = false + var input: Bool = false + let inputButtonTitle: String? + let inputPlaceholder: String? +} + +struct ActionType: Decodable { + let id: String + let actions: [Action] + let hiddenPreviewsBodyPlaceholder: String? + var customDismissAction = false + var allowInCarPlay = false + var hiddenPreviewsShowTitle = false + var hiddenPreviewsShowSubtitle = false + let hiddenBodyPlaceholder: String? +} + +struct RegisterActionTypesArgs: Decodable { + let types: [ActionType] +} + +struct BatchArgs: Decodable { + let notifications: [Notification] +} + class NotificationPlugin: Plugin { let notificationHandler = NotificationHandler() let notificationManager = NotificationManager() @@ -75,29 +164,24 @@ class NotificationPlugin: Plugin { } @objc public func show(_ invoke: Invoke) throws { - let request = try showNotification(invoke: invoke, notification: invoke.data) - notificationHandler.saveNotification(request.identifier, invoke.data) - invoke.resolve([ - "id": Int(request.identifier) ?? -1 - ]) + let notification = try invoke.parseArgs(Notification.self) + + let request = try showNotification(invoke: invoke, notification: notification) + notificationHandler.saveNotification(request.identifier, notification) + invoke.resolve(Int(request.identifier) ?? -1) } @objc public func batch(_ invoke: Invoke) throws { - guard let notifications = invoke.getArray("notifications", JSObject.self) else { - invoke.reject("`notifications` array is required") - return - } + let args = try invoke.parseArgs(BatchArgs.self) var ids = [Int]() - for notification in notifications { + for notification in args.notifications { let request = try showNotification(invoke: invoke, notification: notification) notificationHandler.saveNotification(request.identifier, notification) ids.append(Int(request.identifier) ?? -1) } - invoke.resolve([ - "notifications": ids - ]) + invoke.resolve(ids) } @objc public override func requestPermissions(_ invoke: Invoke) { @@ -129,18 +213,11 @@ class NotificationPlugin: Plugin { } } - @objc func cancel(_ invoke: Invoke) { - guard let notifications = invoke.getArray("notifications", NSNumber.self), - notifications.count > 0 - else { - invoke.reject("`notifications` input is required") - return - } + @objc func cancel(_ invoke: Invoke) throws { + let args = try invoke.parseArgs(CancelArgs.self) UNUserNotificationCenter.current().removePendingNotificationRequests( - withIdentifiers: notifications.map({ (id) -> String in - return id.stringValue - }) + withIdentifiers: args.notifications.map { String($0) } ) invoke.resolve() } @@ -148,30 +225,27 @@ class NotificationPlugin: Plugin { @objc func getPending(_ invoke: Invoke) { UNUserNotificationCenter.current().getPendingNotificationRequests(completionHandler: { (notifications) in - let ret = notifications.compactMap({ [weak self] (notification) -> JSObject? in - return self?.notificationHandler.makePendingNotificationRequestJSObject(notification) + let ret = notifications.compactMap({ [weak self] (notification) -> PendingNotification? in + return self?.notificationHandler.toPendingNotification(notification) }) - invoke.resolve([ - "notifications": ret - ]) + invoke.resolve(ret) }) } @objc func registerActionTypes(_ invoke: Invoke) throws { - guard let types = invoke.getArray("types", JSObject.self) else { - return - } - try makeCategories(types) + let args = try invoke.parseArgs(RegisterActionTypesArgs.self) + makeCategories(args.types) invoke.resolve() } @objc func removeActive(_ invoke: Invoke) { - if let notifications = invoke.getArray("notifications", JSObject.self) { - let ids = notifications.map { "\($0["id"] ?? "")" } - UNUserNotificationCenter.current().removeDeliveredNotifications(withIdentifiers: ids) + do { + let args = try invoke.parseArgs(RemoveActiveArgs.self) + UNUserNotificationCenter.current().removeDeliveredNotifications( + withIdentifiers: args.notifications.map { String($0.id) }) invoke.resolve() - } else { + } catch { UNUserNotificationCenter.current().removeAllDeliveredNotifications() DispatchQueue.main.async(execute: { UIApplication.shared.applicationIconBadgeNumber = 0 @@ -183,13 +257,11 @@ class NotificationPlugin: Plugin { @objc func getActive(_ invoke: Invoke) { UNUserNotificationCenter.current().getDeliveredNotifications(completionHandler: { (notifications) in - let ret = notifications.map({ (notification) -> [String: Any] in - return self.notificationHandler.makeNotificationRequestJSObject( + let ret = notifications.map({ (notification) -> ActiveNotification in + return self.notificationHandler.toActiveNotification( notification.request) }) - invoke.resolve([ - "notifications": ret - ]) + invoke.resolve(ret) }) } diff --git a/plugins/notification/package.json b/plugins/notification/package.json index e6421f71f..e94e06bb1 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.9" + "@tauri-apps/api": "2.0.0-alpha.11" } } diff --git a/plugins/notification/src/api-iife.js b/plugins/notification/src/api-iife.js index 828c877c0..b2ebe1e0c 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 i=Object.defineProperty,e=(n,i,e)=>{if(!i.has(n))throw TypeError("Cannot "+e)},t=(n,i,t)=>(e(n,i,"read from private field"),t?t.call(n):i.get(n));function o(n,i=!1){return window.__TAURI_INTERNALS__.transformCallback(n,i)}((n,e)=>{for(var t in e)i(n,t,{get:e[t],enumerable:!0})})({},{Channel:()=>c,PluginListener:()=>l,addPluginListener:()=>f,convertFileSrc:()=>d,invoke:()=>_,transformCallback:()=>o});var r,c=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,((n,i,e)=>{if(i.has(n))throw TypeError("Cannot add the same private member more than once");i instanceof WeakSet?i.add(n):i.set(n,e)})(this,r,(()=>{})),this.id=o((n=>{t(this,r).call(this,n)}))}set onmessage(n){var i,t,o,c;o=n,e(i=this,t=r,"write to private field"),c?c.call(i,o):t.set(i,o)}get onmessage(){return t(this,r)}toJSON(){return`__CHANNEL__:${this.id}`}};r=new WeakMap;var a,s,u,l=class{constructor(n,i,e){this.plugin=n,this.event=i,this.channelId=e}async unregister(){return _(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function f(n,i,e){let t=new c;return t.onmessage=e,_(`plugin:${n}|register_listener`,{event:i,handler:t}).then((()=>new l(n,i,t.id)))}async function _(n,i={},e){return window.__TAURI_INTERNALS__.invoke(n,i,e)}function d(n,i="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(n,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"}(a||(a={})),n.Importance=void 0,(s=n.Importance||(n.Importance={}))[s.None=0]="None",s[s.Min=1]="Min",s[s.Low=2]="Low",s[s.Default=3]="Default",s[s.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 f("notification","actionPerformed",n)},n.onNotificationReceived=async function(n){return f("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";function i(n,i,e,t){if("a"===e&&!t)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof i?n!==i||!t:!i.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===e?t:"a"===e?t.call(n):t?t.value:i.get(n)}var e,t,o,r;"function"==typeof SuppressedError&&SuppressedError;class c{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,e.set(this,(()=>{})),this.id=function(n,i=!1){return window.__TAURI_INTERNALS__.transformCallback(n,i)}((n=>{i(this,e,"f").call(this,n)}))}set onmessage(n){!function(n,i,e,t,o){if("m"===t)throw new TypeError("Private method is not writable");if("a"===t&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof i?n!==i||!o:!i.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===t?o.call(n,e):o?o.value=e:i.set(n,e)}(this,e,n,"f")}get onmessage(){return i(this,e,"f")}toJSON(){return`__CHANNEL__:${this.id}`}}e=new WeakMap;class a{constructor(n,i,e){this.plugin=n,this.event=i,this.channelId=e}async unregister(){return u(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}}async function s(n,i,e){const t=new c;return t.onmessage=e,u(`plugin:${n}|register_listener`,{event:i,handler:t}).then((()=>new a(n,i,t.id)))}async function u(n,i={},e){return window.__TAURI_INTERNALS__.invoke(n,i,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"}(t||(t={})),n.Importance=void 0,(o=n.Importance||(n.Importance={}))[o.None=0]="None",o[o.Min=1]="Min",o[o.Low=2]="Low",o[o.Default=3]="Default",o[o.High=4]="High",n.Visibility=void 0,(r=n.Visibility||(n.Visibility={}))[r.Secret=-1]="Secret",r[r.Private=0]="Private",r[r.Public=1]="Public",n.active=async function(){return u("plugin:notification|get_active")},n.cancel=async function(n){return u("plugin:notification|cancel",{notifications:n})},n.cancelAll=async function(){return u("plugin:notification|cancel")},n.channels=async function(){return u("plugin:notification|listChannels")},n.createChannel=async function(n){return u("plugin:notification|create_channel",{...n})},n.isPermissionGranted=async function(){return"default"!==window.Notification.permission?Promise.resolve("granted"===window.Notification.permission):u("plugin:notification|is_permission_granted")},n.onAction=async function(n){return s("notification","actionPerformed",n)},n.onNotificationReceived=async function(n){return s("notification","notification",n)},n.pending=async function(){return u("plugin:notification|get_pending")},n.registerActionTypes=async function(n){return u("plugin:notification|register_action_types",{types:n})},n.removeActive=async function(n){return u("plugin:notification|remove_active",{notifications:n})},n.removeAllActive=async function(){return u("plugin:notification|remove_active")},n.removeChannel=async function(n){return u("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/notification/src/init-iife.js b/plugins/notification/src/init-iife.js index 8c9276747..b7e206b05 100644 --- a/plugins/notification/src/init-iife.js +++ b/plugins/notification/src/init-iife.js @@ -1 +1 @@ -!function(){"use strict";var e=Object.defineProperty,n=(e,n,t)=>{if(!n.has(e))throw TypeError("Cannot "+t)},t=(e,t,i)=>(n(e,t,"read from private field"),i?i.call(e):t.get(e));function i(e,n=!1){return window.__TAURI_INTERNALS__.transformCallback(e,n)}((n,t)=>{for(var i in t)e(n,i,{get:t[i],enumerable:!0})})({},{Channel:()=>o,PluginListener:()=>s,addPluginListener:()=>a,convertFileSrc:()=>l,invoke:()=>c,transformCallback:()=>i});var r,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,r,(()=>{})),this.id=i((e=>{t(this,r).call(this,e)}))}set onmessage(e){var t,i,o,s;o=e,n(t=this,i=r,"write to private field"),s?s.call(t,o):i.set(t,o)}get onmessage(){return t(this,r)}toJSON(){return`__CHANNEL__:${this.id}`}};r=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 a(e,n,t){let i=new o;return i.onmessage=t,c(`plugin:${e}|register_listener`,{event:n,handler:i}).then((()=>new s(e,n,i.id)))}async function c(e,n={},t){return window.__TAURI_INTERNALS__.invoke(e,n,t)}function l(e,n="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,n)}!function(){let e=!1,n="default";function t(n){e=!0,window.Notification.permission=n,e=!1}window.Notification=function(e,n){const t=n||{};!function(e){"object"==typeof e&&Object.freeze(e),c("plugin:notification|notify",{options:"string"==typeof e?{title:e}:e})}(Object.assign(t,{title:e}))},window.Notification.requestPermission=function(){return c("plugin:notification|request_permission").then((e=>(t("prompt"===e?"default":e),e)))},Object.defineProperty(window.Notification,"permission",{enumerable:!0,get:()=>n,set:t=>{if(!e)throw new Error("Readonly property");n=t}}),("default"!==window.Notification.permission?Promise.resolve("granted"===window.Notification.permission):c("plugin:notification|is_permission_granted")).then((function(e){t(null===e?"default":e?"granted":"denied")}))}()}(); +!function(){"use strict";async function i(i,n={},t){return window.__TAURI_INTERNALS__.invoke(i,n,t)}"function"==typeof SuppressedError&&SuppressedError,function(){let n=!1,t="default";function o(i){n=!0,window.Notification.permission=i,n=!1}window.Notification=function(n,t){const o=t||{};!function(n){"object"==typeof n&&Object.freeze(n),i("plugin:notification|notify",{options:"string"==typeof n?{title:n}:n})}(Object.assign(o,{title:n}))},window.Notification.requestPermission=function(){return i("plugin:notification|request_permission").then((i=>(o("prompt"===i?"default":i),i)))},Object.defineProperty(window.Notification,"permission",{enumerable:!0,get:()=>t,set:i=>{if(!n)throw new Error("Readonly property");t=i}}),("default"!==window.Notification.permission?Promise.resolve("granted"===window.Notification.permission):i("plugin:notification|is_permission_granted")).then((function(i){o(null===i?"default":i?"granted":"denied")}))}()}(); diff --git a/plugins/notification/src/mobile.rs b/plugins/notification/src/mobile.rs index 83513eef4..b786ed5c8 100644 --- a/plugins/notification/src/mobile.rs +++ b/plugins/notification/src/mobile.rs @@ -33,7 +33,7 @@ pub fn init( impl crate::NotificationBuilder { pub fn show(self) -> crate::Result<()> { self.handle - .run_mobile_plugin::("show", self.data) + .run_mobile_plugin::("show", self.data) .map(|_| ()) .map_err(Into::into) } @@ -89,8 +89,7 @@ impl Notification { pub fn active(&self) -> crate::Result> { self.0 - .run_mobile_plugin::("getActive", ()) - .map(|r| r.notifications) + .run_mobile_plugin("getActive", ()) .map_err(Into::into) } @@ -102,8 +101,7 @@ impl Notification { pub fn pending(&self) -> crate::Result> { self.0 - .run_mobile_plugin::("getPending", ()) - .map(|r| r.notifications) + .run_mobile_plugin("getPending", ()) .map_err(Into::into) } @@ -138,34 +136,11 @@ impl Notification { #[cfg(target_os = "android")] pub fn list_channels(&self) -> crate::Result> { self.0 - .run_mobile_plugin::("listChannels", ()) - .map(|r| r.channels) + .run_mobile_plugin("listChannels", ()) .map_err(Into::into) } } -#[cfg(target_os = "android")] -#[derive(Deserialize)] -struct ListChannelsResult { - channels: Vec, -} - -#[derive(Deserialize)] -struct PendingResponse { - notifications: Vec, -} - -#[derive(Deserialize)] -struct ActiveResponse { - notifications: Vec, -} - -#[derive(Deserialize)] -struct ShowResponse { - #[allow(dead_code)] - id: i32, -} - #[derive(Deserialize)] #[serde(rename_all = "camelCase")] struct PermissionResponse { diff --git a/plugins/notification/src/models.rs b/plugins/notification/src/models.rs index 063a3702e..0db617ed8 100644 --- a/plugins/notification/src/models.rs +++ b/plugins/notification/src/models.rs @@ -94,7 +94,7 @@ impl<'de> Deserialize<'de> for ScheduleEvery { } #[derive(Debug, Serialize, Deserialize)] -#[serde(tag = "kind", content = "data")] +#[serde(rename_all = "camelCase")] pub enum Schedule { At { #[serde( @@ -104,10 +104,19 @@ pub enum Schedule { date: time::OffsetDateTime, #[serde(default)] repeating: bool, + #[serde(default)] + allow_while_idle: bool, + }, + Interval { + interval: ScheduleInterval, + #[serde(default)] + allow_while_idle: bool, }, - Interval(ScheduleInterval), Every { interval: ScheduleEvery, + count: u8, + #[serde(default)] + allow_while_idle: bool, }, } diff --git a/plugins/os/CHANGELOG.md b/plugins/os/CHANGELOG.md index a10a8c6b2..594659216 100644 --- a/plugins/os/CHANGELOG.md +++ b/plugins/os/CHANGELOG.md @@ -2,7 +2,7 @@ ## \[2.0.0-alpha.3] -- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.16. +- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.9. ## \[2.0.0-alpha.2] diff --git a/plugins/os/Cargo.toml b/plugins/os/Cargo.toml index 9fc8da1b7..45fd6e214 100644 --- a/plugins/os/Cargo.toml +++ b/plugins/os/Cargo.toml @@ -8,7 +8,8 @@ license = { workspace = true } rust-version = { workspace = true } [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = [ "--cfg", "docsrs" ] +rustdoc-args = [ "--cfg", "docsrs" ] [dependencies] serde = { workspace = true } diff --git a/plugins/os/package.json b/plugins/os/package.json index 569691046..18d397df0 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.9" + "@tauri-apps/api": "2.0.0-alpha.11" } } diff --git a/plugins/os/src/api-iife.js b/plugins/os/src/api-iife.js index 8193db548..0adb2ae2f 100644 --- a/plugins/os/src/api-iife.js +++ b/plugins/os/src/api-iife.js @@ -1 +1 @@ -if("__TAURI__"in window){var __TAURI_OS__=function(n){"use strict";var e=Object.defineProperty,t=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)},r=(n,e,r)=>(t(n,e,"read from private field"),r?r.call(n):e.get(n));function i(n,e=!1){return window.__TAURI_INTERNALS__.transformCallback(n,e)}((n,t)=>{for(var r in t)e(n,r,{get:t[r],enumerable:!0})})({},{Channel:()=>o,PluginListener:()=>a,addPluginListener:()=>_,convertFileSrc:()=>u,invoke:()=>c,transformCallback:()=>i});var s,o=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,((n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)})(this,s,(()=>{})),this.id=i((n=>{r(this,s).call(this,n)}))}set onmessage(n){var e,r,i,o;i=n,t(e=this,r=s,"write to private field"),o?o.call(e,i):r.set(e,i)}get onmessage(){return r(this,s)}toJSON(){return`__CHANNEL__:${this.id}`}};s=new WeakMap;var a=class{constructor(n,e,t){this.plugin=n,this.event=e,this.channelId=t}async unregister(){return c(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function _(n,e,t){let r=new o;return r.onmessage=t,c(`plugin:${n}|register_listener`,{event:e,handler:r}).then((()=>new a(n,e,r.id)))}async function c(n,e={},t){return window.__TAURI_INTERNALS__.invoke(n,e,t)}function u(n,e="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(n,e)}return n.arch=async function(){return c("plugin:os|arch")},n.eol=function(){return window.__TAURI__.os.__eol},n.exeExtension=async function(){return c("plugin:os|exe_extension")},n.family=async function(){return c("plugin:os|family")},n.hostname=async function(){return c("plugin:os|hostname")},n.locale=async function(){return c("plugin:os|locale")},n.platform=async function(){return c("plugin:os|platform")},n.type=async function(){return c("plugin:os|os_type")},n.version=async function(){return c("plugin:os|version")},n}({});Object.defineProperty(window.__TAURI__,"os",{value:__TAURI_OS__})} +if("__TAURI__"in window){var __TAURI_OS__=function(n){"use strict";async function o(n,o={},e){return window.__TAURI_INTERNALS__.invoke(n,o,e)}return"function"==typeof SuppressedError&&SuppressedError,n.arch=async function(){return o("plugin:os|arch")},n.eol=function(){return window.__TAURI__.os.__eol},n.exeExtension=async function(){return o("plugin:os|exe_extension")},n.family=async function(){return o("plugin:os|family")},n.hostname=async function(){return o("plugin:os|hostname")},n.locale=async function(){return o("plugin:os|locale")},n.platform=async function(){return o("plugin:os|platform")},n.type=async function(){return o("plugin:os|os_type")},n.version=async function(){return o("plugin:os|version")},n}({});Object.defineProperty(window.__TAURI__,"os",{value:__TAURI_OS__})} diff --git a/plugins/persisted-scope/Cargo.toml b/plugins/persisted-scope/Cargo.toml index 89fd3c154..88ab9732a 100644 --- a/plugins/persisted-scope/Cargo.toml +++ b/plugins/persisted-scope/Cargo.toml @@ -8,7 +8,8 @@ edition = { workspace = true } rust-version = { workspace = true } [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = [ "--cfg", "docsrs" ] +rustdoc-args = [ "--cfg", "docsrs" ] [dependencies] serde = { workspace = true } diff --git a/plugins/positioner/CHANGELOG.md b/plugins/positioner/CHANGELOG.md index 5f04b7971..f9f0560e6 100644 --- a/plugins/positioner/CHANGELOG.md +++ b/plugins/positioner/CHANGELOG.md @@ -2,7 +2,7 @@ ## \[2.0.0-alpha.2] -- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.16. +- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.9. ## \[2.0.0-alpha.2] diff --git a/plugins/positioner/Cargo.toml b/plugins/positioner/Cargo.toml index 8107652bc..9912dbaac 100644 --- a/plugins/positioner/Cargo.toml +++ b/plugins/positioner/Cargo.toml @@ -8,7 +8,8 @@ edition = { workspace = true } rust-version = { workspace = true } [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = [ "--cfg", "docsrs" ] +rustdoc-args = [ "--cfg", "docsrs" ] [dependencies] serde = { workspace = true } diff --git a/plugins/positioner/package.json b/plugins/positioner/package.json index 7dfc7702f..e3be37b48 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.9" + "@tauri-apps/api": "2.0.0-alpha.11" } } diff --git a/plugins/positioner/src/api-iife.js b/plugins/positioner/src/api-iife.js index 6dce17438..fad6fc298 100644 --- a/plugins/positioner/src/api-iife.js +++ b/plugins/positioner/src/api-iife.js @@ -1 +1 @@ -if("__TAURI__"in window){var __TAURI_POSITIONER__=function(t){"use strict";var e=Object.defineProperty,n=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)},r=(t,e,r)=>(n(t,e,"read from private field"),r?r.call(t):e.get(t));function o(t,e=!1){return window.__TAURI_INTERNALS__.transformCallback(t,e)}((t,n)=>{for(var r in n)e(t,r,{get:n[r],enumerable:!0})})({},{Channel:()=>a,PluginListener:()=>_,addPluginListener:()=>h,convertFileSrc:()=>l,invoke:()=>c,transformCallback:()=>o});var i,a=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,((t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)})(this,i,(()=>{})),this.id=o((t=>{r(this,i).call(this,t)}))}set onmessage(t){var e,r,o,a;o=t,n(e=this,r=i,"write to private field"),a?a.call(e,o):r.set(e,o)}get onmessage(){return r(this,i)}toJSON(){return`__CHANNEL__:${this.id}`}};i=new WeakMap;var s,_=class{constructor(t,e,n){this.plugin=t,this.event=e,this.channelId=n}async unregister(){return c(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function h(t,e,n){let r=new a;return r.onmessage=n,c(`plugin:${t}|register_listener`,{event:e,handler:r}).then((()=>new _(t,e,r.id)))}async function c(t,e={},n){return window.__TAURI_INTERNALS__.invoke(t,e,n)}function l(t,e="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(t,e)}return t.Position=void 0,(s=t.Position||(t.Position={}))[s.TopLeft=0]="TopLeft",s[s.TopRight=1]="TopRight",s[s.BottomLeft=2]="BottomLeft",s[s.BottomRight=3]="BottomRight",s[s.TopCenter=4]="TopCenter",s[s.BottomCenter=5]="BottomCenter",s[s.LeftCenter=6]="LeftCenter",s[s.RightCenter=7]="RightCenter",s[s.Center=8]="Center",s[s.TrayLeft=9]="TrayLeft",s[s.TrayBottomLeft=10]="TrayBottomLeft",s[s.TrayRight=11]="TrayRight",s[s.TrayBottomRight=12]="TrayBottomRight",s[s.TrayCenter=13]="TrayCenter",s[s.TrayBottomCenter=14]="TrayBottomCenter",t.moveWindow=async function(t){await c("plugin:positioner|move_window",{position:t})},t}({});Object.defineProperty(window.__TAURI__,"positioner",{value:__TAURI_POSITIONER__})} +if("__TAURI__"in window){var __TAURI_POSITIONER__=function(t){"use strict";var o;return"function"==typeof SuppressedError&&SuppressedError,t.Position=void 0,(o=t.Position||(t.Position={}))[o.TopLeft=0]="TopLeft",o[o.TopRight=1]="TopRight",o[o.BottomLeft=2]="BottomLeft",o[o.BottomRight=3]="BottomRight",o[o.TopCenter=4]="TopCenter",o[o.BottomCenter=5]="BottomCenter",o[o.LeftCenter=6]="LeftCenter",o[o.RightCenter=7]="RightCenter",o[o.Center=8]="Center",o[o.TrayLeft=9]="TrayLeft",o[o.TrayBottomLeft=10]="TrayBottomLeft",o[o.TrayRight=11]="TrayRight",o[o.TrayBottomRight=12]="TrayBottomRight",o[o.TrayCenter=13]="TrayCenter",o[o.TrayBottomCenter=14]="TrayBottomCenter",t.moveWindow=async function(t){await async function(t,o={},e){return window.__TAURI_INTERNALS__.invoke(t,o,e)}("plugin:positioner|move_window",{position:t})},t}({});Object.defineProperty(window.__TAURI__,"positioner",{value:__TAURI_POSITIONER__})} diff --git a/plugins/process/CHANGELOG.md b/plugins/process/CHANGELOG.md index 35880572d..03ac852c1 100644 --- a/plugins/process/CHANGELOG.md +++ b/plugins/process/CHANGELOG.md @@ -2,7 +2,7 @@ ## \[2.0.0-alpha.2] -- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.16. +- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.9. ## \[2.0.0-alpha.2] diff --git a/plugins/process/Cargo.toml b/plugins/process/Cargo.toml index 6543da771..cea52c409 100644 --- a/plugins/process/Cargo.toml +++ b/plugins/process/Cargo.toml @@ -8,7 +8,8 @@ license = { workspace = true } rust-version = { workspace = true } [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = [ "--cfg", "docsrs" ] +rustdoc-args = [ "--cfg", "docsrs" ] [dependencies] tauri = { workspace = true } diff --git a/plugins/process/package.json b/plugins/process/package.json index 6420dd499..f1b05719b 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.9" + "@tauri-apps/api": "2.0.0-alpha.11" } } diff --git a/plugins/process/src/api-iife.js b/plugins/process/src/api-iife.js index 402f2154b..35dbaed1f 100644 --- a/plugins/process/src/api-iife.js +++ b/plugins/process/src/api-iife.js @@ -1 +1 @@ -if("__TAURI__"in window){var __TAURI_PROCESS__=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));function i(e,n=!1){return window.__TAURI_INTERNALS__.transformCallback(e,n)}((e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})})({},{Channel:()=>a,PluginListener:()=>o,addPluginListener:()=>_,convertFileSrc:()=>l,invoke:()=>c,transformCallback:()=>i});var s,a=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=i((e=>{r(this,s).call(this,e)}))}set onmessage(e){var n,r,i,a;i=e,t(n=this,r=s,"write to private field"),a?a.call(n,i):r.set(n,i)}get onmessage(){return r(this,s)}toJSON(){return`__CHANNEL__:${this.id}`}};s=new WeakMap;var o=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 _(e,n,t){let r=new a;return r.onmessage=t,c(`plugin:${e}|register_listener`,{event:n,handler:r}).then((()=>new o(e,n,r.id)))}async function c(e,n={},t){return window.__TAURI_INTERNALS__.invoke(e,n,t)}function l(e,n="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,n)}return e.exit=async function(e=0){return c("plugin:process|exit",{code:e})},e.relaunch=async function(){return c("plugin:process|restart")},e}({});Object.defineProperty(window.__TAURI__,"process",{value:__TAURI_PROCESS__})} +if("__TAURI__"in window){var __TAURI_PROCESS__=function(n){"use strict";async function r(n,r={},e){return window.__TAURI_INTERNALS__.invoke(n,r,e)}return"function"==typeof SuppressedError&&SuppressedError,n.exit=async function(n=0){return r("plugin:process|exit",{code:n})},n.relaunch=async function(){return r("plugin:process|restart")},n}({});Object.defineProperty(window.__TAURI__,"process",{value:__TAURI_PROCESS__})} diff --git a/plugins/shell/CHANGELOG.md b/plugins/shell/CHANGELOG.md index a1644b0a1..30d962124 100644 --- a/plugins/shell/CHANGELOG.md +++ b/plugins/shell/CHANGELOG.md @@ -2,7 +2,7 @@ ## \[2.0.0-alpha.2] -- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.16. +- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.9. ## \[2.0.0-alpha.2] diff --git a/plugins/shell/Cargo.toml b/plugins/shell/Cargo.toml index 018d189f5..47b52eecd 100644 --- a/plugins/shell/Cargo.toml +++ b/plugins/shell/Cargo.toml @@ -8,7 +8,8 @@ license = { workspace = true } rust-version = { workspace = true } [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = [ "--cfg", "docsrs" ] +rustdoc-args = [ "--cfg", "docsrs" ] [dependencies] serde = { workspace = true } diff --git a/plugins/shell/package.json b/plugins/shell/package.json index c8f055fda..1d0f6e067 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.9" + "@tauri-apps/api": "2.0.0-alpha.11" } } diff --git a/plugins/shell/src/api-iife.js b/plugins/shell/src/api-iife.js index 1f62d77f3..6247a3f5c 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";var t=Object.defineProperty,n=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},s=(e,t,s)=>(n(e,t,"read from private field"),s?s.call(e):t.get(e));function r(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}((e,n)=>{for(var s in n)t(e,s,{get:n[s],enumerable:!0})})({},{Channel:()=>o,PluginListener:()=>a,addPluginListener:()=>h,convertFileSrc:()=>l,invoke:()=>c,transformCallback:()=>r});var i,o=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,i,(()=>{})),this.id=r((e=>{s(this,i).call(this,e)}))}set onmessage(e){var t,s,r,o;r=e,n(t=this,s=i,"write to private field"),o?o.call(t,r):s.set(t,r)}get onmessage(){return s(this,i)}toJSON(){return`__CHANNEL__:${this.id}`}};i=new WeakMap;var a=class{constructor(e,t,n){this.plugin=e,this.event=t,this.channelId=n}async unregister(){return c(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function h(e,t,n){let s=new o;return s.onmessage=n,c(`plugin:${e}|register_listener`,{event:t,handler:s}).then((()=>new a(e,t,s.id)))}async function c(e,t={},n){return window.__TAURI_INTERNALS__.invoke(e,t,n)}function l(e,t="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,t)}class u{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=s=>{this.removeListener(e,n),t(s)};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=s=>{this.removeListener(e,n),t(s)};return this.prependListener(e,n)}}class d{constructor(e){this.pid=e}async write(e){return c("plugin:shell|stdin_write",{pid:this.pid,buffer:"string"==typeof e?e:Array.from(e)})}async kill(){return c("plugin:shell|kill",{cmd:"killChild",pid:this.pid})}}class p extends u{constructor(e,t=[],n){super(),this.stdout=new u,this.stderr=new u,this.program=e,this.args="string"==typeof t?[t]:t,this.options=null!=n?n:{}}static create(e,t=[],n){return new p(e,t,n)}static sidecar(e,t=[],n){const s=new p(e,t,n);return s.options.sidecar=!0,s}async spawn(){return async function(e,t,n=[],s){"object"==typeof n&&Object.freeze(n);const r=new o;return r.onmessage=e,c("plugin:shell|execute",{program:t,args:n,options:s,onEvent:r})}((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 d(e)))}async execute(){return new Promise(((e,t)=>{this.on("error",t);const n=[],s=[];this.stdout.on("data",(e=>{n.push(e)})),this.stderr.on("data",(e=>{s.push(e)})),this.on("close",(t=>{e({code:t.code,signal:t.signal,stdout:this.collectOutput(n),stderr:this.collectOutput(s)})})),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=d,e.Command=p,e.EventEmitter=u,e.open=async function(e,t){return c("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";function t(e,t,s,r){if("a"===s&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?r:"a"===s?r.call(e):r?r.value:t.get(e)}var s;"function"==typeof SuppressedError&&SuppressedError;class r{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,s.set(this,(()=>{})),this.id=function(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}((e=>{t(this,s,"f").call(this,e)}))}set onmessage(e){!function(e,t,s,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===r?n.call(e,s):n?n.value=s:t.set(e,s)}(this,s,e,"f")}get onmessage(){return t(this,s,"f")}toJSON(){return`__CHANNEL__:${this.id}`}}async function n(e,t={},s){return window.__TAURI_INTERNALS__.invoke(e,t,s)}s=new WeakMap;class i{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=r=>{this.removeListener(e,s),t(r)};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=r=>{this.removeListener(e,s),t(r)};return this.prependListener(e,s)}}class o{constructor(e){this.pid=e}async write(e){return n("plugin:shell|stdin_write",{pid:this.pid,buffer:"string"==typeof e?e:Array.from(e)})}async kill(){return n("plugin:shell|kill",{cmd:"killChild",pid:this.pid})}}class a extends i{constructor(e,t=[],s){super(),this.stdout=new i,this.stderr=new i,this.program=e,this.args="string"==typeof t?[t]:t,this.options=null!=s?s:{}}static create(e,t=[],s){return new a(e,t,s)}static sidecar(e,t=[],s){const r=new a(e,t,s);return r.options.sidecar=!0,r}async spawn(){return async function(e,t,s=[],i){"object"==typeof s&&Object.freeze(s);const o=new r;return o.onmessage=e,n("plugin:shell|execute",{program:t,args:s,options:i,onEvent:o})}((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 o(e)))}async execute(){return new Promise(((e,t)=>{this.on("error",t);const s=[],r=[];this.stdout.on("data",(e=>{s.push(e)})),this.stderr.on("data",(e=>{r.push(e)})),this.on("close",(t=>{e({code:t.code,signal:t.signal,stdout:this.collectOutput(s),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=o,e.Command=a,e.EventEmitter=i,e.open=async function(e,t){return n("plugin:shell|open",{path:e,with:t})},e}({});Object.defineProperty(window.__TAURI__,"shell",{value:__TAURI_SHELL__})} diff --git a/plugins/shell/src/init-iife.js b/plugins/shell/src/init-iife.js index 6c32a6c7f..70e3dc1ae 100644 --- a/plugins/shell/src/init-iife.js +++ b/plugins/shell/src/init-iife.js @@ -1 +1 @@ -!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));function r(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}((t,n)=>{for(var r in n)e(t,r,{get:n[r],enumerable:!0})})({},{Channel:()=>i,PluginListener:()=>s,addPluginListener:()=>o,convertFileSrc:()=>c,invoke:()=>l,transformCallback:()=>r});var a,i=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,a,(()=>{})),this.id=r((e=>{n(this,a).call(this,e)}))}set onmessage(e){var n,r,i,s;i=e,t(n=this,r=a,"write to private field"),s?s.call(n,i):r.set(n,i)}get onmessage(){return n(this,a)}toJSON(){return`__CHANNEL__:${this.id}`}};a=new WeakMap;var s=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 o(e,t,n){let r=new i;return r.onmessage=n,l(`plugin:${e}|register_listener`,{event:t,handler:r}).then((()=>new s(e,t,r.id)))}async function l(e,t={},n){return window.__TAURI_INTERNALS__.invoke(e,t,n)}function c(e,t="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,t)}function h(){var e;null===(e=document.querySelector("body"))||void 0===e||e.addEventListener("click",(function(e){let t=e.target;for(;null!=t;){if(t.matches("a")){const n=t;n.href&&["http://","https://","mailto:","tel:"].some((e=>n.href.startsWith(e)))&&"_blank"===n.target&&(l("plugin:shell|open",{path:n.href}),e.preventDefault());break}t=t.parentElement}}))}"complete"===document.readyState||"interactive"===document.readyState?h():window.addEventListener("DOMContentLoaded",h,!0)}(); +!function(){"use strict";async function e(e,t={},n){return window.__TAURI_INTERNALS__.invoke(e,t,n)}function t(){var t;null===(t=document.querySelector("body"))||void 0===t||t.addEventListener("click",(function(t){let n=t.target;for(;null!=n;){if(n.matches("a")){const r=n;r.href&&["http://","https://","mailto:","tel:"].some((e=>r.href.startsWith(e)))&&"_blank"===r.target&&(e("plugin:shell|open",{path:r.href}),t.preventDefault());break}n=n.parentElement}}))}"function"==typeof SuppressedError&&SuppressedError,"complete"===document.readyState||"interactive"===document.readyState?t():window.addEventListener("DOMContentLoaded",t,!0)}(); diff --git a/plugins/shell/src/process/mod.rs b/plugins/shell/src/process/mod.rs index 8065de405..b797be7e6 100644 --- a/plugins/shell/src/process/mod.rs +++ b/plugins/shell/src/process/mod.rs @@ -455,7 +455,7 @@ mod tests { CommandEvent::Stderr(line) => { assert_eq!( String::from_utf8(line).unwrap(), - "cat: test/: Is a directory" + "cat: test/: Is a directory\n" ); } _ => {} @@ -480,7 +480,7 @@ mod tests { CommandEvent::Stderr(line) => { assert_eq!( String::from_utf8(line).unwrap(), - "cat: test/: Is a directory" + "cat: test/: Is a directory\n" ); } _ => {} @@ -511,7 +511,7 @@ mod tests { assert_eq!(String::from_utf8(output.stdout).unwrap(), ""); assert_eq!( String::from_utf8(output.stderr).unwrap(), - "cat: test/: Is a directory\n" + "cat: test/: Is a directory\n\n" ); } } diff --git a/plugins/single-instance/Cargo.toml b/plugins/single-instance/Cargo.toml index 88d2834be..406f5ba24 100644 --- a/plugins/single-instance/Cargo.toml +++ b/plugins/single-instance/Cargo.toml @@ -9,7 +9,8 @@ rust-version = { workspace = true } exclude = [ "/examples" ] [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = [ "--cfg", "docsrs" ] +rustdoc-args = [ "--cfg", "docsrs" ] [dependencies] serde = { workspace = true } diff --git a/plugins/single-instance/examples/vanilla/package.json b/plugins/single-instance/examples/vanilla/package.json index ebeb7b922..fe889796a 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.16" + "@tauri-apps/cli": "2.0.0-alpha.17" } } diff --git a/plugins/sql/CHANGELOG.md b/plugins/sql/CHANGELOG.md index 35880572d..03ac852c1 100644 --- a/plugins/sql/CHANGELOG.md +++ b/plugins/sql/CHANGELOG.md @@ -2,7 +2,7 @@ ## \[2.0.0-alpha.2] -- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.16. +- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.9. ## \[2.0.0-alpha.2] diff --git a/plugins/sql/Cargo.toml b/plugins/sql/Cargo.toml index d63c84766..071119083 100644 --- a/plugins/sql/Cargo.toml +++ b/plugins/sql/Cargo.toml @@ -8,7 +8,9 @@ edition = { workspace = true } rust-version = { workspace = true } [package.metadata.docs.rs] -features = [ "dox", "sqlite" ] +features = [ "sqlite" ] +rustc-args = [ "--cfg", "docsrs" ] +rustdoc-args = [ "--cfg", "docsrs" ] [dependencies] serde = { workspace = true } diff --git a/plugins/sql/package.json b/plugins/sql/package.json index 236802c07..e5546d9d0 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.9" + "@tauri-apps/api": "2.0.0-alpha.11" } } diff --git a/plugins/sql/src/api-iife.js b/plugins/sql/src/api-iife.js index 60ceb80a4..3ee9c447a 100644 --- a/plugins/sql/src/api-iife.js +++ b/plugins/sql/src/api-iife.js @@ -1 +1 @@ -if("__TAURI__"in window){var __TAURI_SQL__=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));function r(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}((t,n)=>{for(var r in n)e(t,r,{get:n[r],enumerable:!0})})({},{Channel:()=>a,PluginListener:()=>i,addPluginListener:()=>l,convertFileSrc:()=>o,invoke:()=>c,transformCallback:()=>r});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=r((e=>{n(this,s).call(this,e)}))}set onmessage(e){var n,r,a,i;a=e,t(n=this,r=s,"write to private field"),i?i.call(n,a):r.set(n,a)}get onmessage(){return n(this,s)}toJSON(){return`__CHANNEL__:${this.id}`}};s=new WeakMap;var i=class{constructor(e,t,n){this.plugin=e,this.event=t,this.channelId=n}async unregister(){return c(`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,c(`plugin:${e}|register_listener`,{event:t,handler:r}).then((()=>new i(e,t,r.id)))}async function c(e,t={},n){return window.__TAURI_INTERNALS__.invoke(e,t,n)}function o(e,t="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,t)}class _{constructor(e){this.path=e}static async load(e){const t=await c("plugin:sql|load",{db:e});return new _(t)}static get(e){return new _(e)}async execute(e,t){const[n,r]=await c("plugin:sql|execute",{db:this.path,query:e,values:null!=t?t:[]});return{lastInsertId:r,rowsAffected:n}}async select(e,t){return await c("plugin:sql|select",{db:this.path,query:e,values:null!=t?t:[]})}async close(e){return await c("plugin:sql|close",{db:e})}}return _}();Object.defineProperty(window.__TAURI__,"sql",{value:__TAURI_SQL__})} +if("__TAURI__"in window){var __TAURI_SQL__=function(){"use strict";async function e(e,t={},n){return window.__TAURI_INTERNALS__.invoke(e,t,n)}"function"==typeof SuppressedError&&SuppressedError;class t{constructor(e){this.path=e}static async load(n){const s=await e("plugin:sql|load",{db:n});return new t(s)}static get(e){return new t(e)}async execute(t,n){const[s,r]=await e("plugin:sql|execute",{db:this.path,query:t,values:null!=n?n:[]});return{lastInsertId:r,rowsAffected:s}}async select(t,n){return await e("plugin:sql|select",{db:this.path,query:t,values:null!=n?n:[]})}async close(t){return await e("plugin:sql|close",{db:t})}}return t}();Object.defineProperty(window.__TAURI__,"sql",{value:__TAURI_SQL__})} diff --git a/plugins/store/CHANGELOG.md b/plugins/store/CHANGELOG.md index 35880572d..03ac852c1 100644 --- a/plugins/store/CHANGELOG.md +++ b/plugins/store/CHANGELOG.md @@ -2,7 +2,7 @@ ## \[2.0.0-alpha.2] -- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.16. +- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.9. ## \[2.0.0-alpha.2] diff --git a/plugins/store/Cargo.toml b/plugins/store/Cargo.toml index e3f1cf74c..408f903ec 100644 --- a/plugins/store/Cargo.toml +++ b/plugins/store/Cargo.toml @@ -8,7 +8,8 @@ edition = { workspace = true } rust-version = { workspace = true } [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = [ "--cfg", "docsrs" ] +rustdoc-args = [ "--cfg", "docsrs" ] [dependencies] serde = { workspace = true } diff --git a/plugins/store/package.json b/plugins/store/package.json index 47c01f906..04ae51514 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.9" + "@tauri-apps/api": "2.0.0-alpha.11" } } diff --git a/plugins/store/src/api-iife.js b/plugins/store/src/api-iife.js index 75c362244..c580c8c40 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(t){"use strict";var e=Object.defineProperty,a=(t,a)=>{for(var n in a)e(t,n,{get:a[n],enumerable:!0})},n=(t,e,a)=>{if(!e.has(t))throw TypeError("Cannot "+a)},r=(t,e,a)=>(n(t,e,"read from private field"),a?a.call(t):e.get(t));function i(t,e=!1){return window.__TAURI_INTERNALS__.transformCallback(t,e)}a({},{Channel:()=>h,PluginListener:()=>u,addPluginListener:()=>o,convertFileSrc:()=>c,invoke:()=>l,transformCallback:()=>i});var s,h=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,((t,e,a)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,a)})(this,s,(()=>{})),this.id=i((t=>{r(this,s).call(this,t)}))}set onmessage(t){((t,e,a,r)=>{n(t,e,"write to private field"),r?r.call(t,a):e.set(t,a)})(this,s,t)}get onmessage(){return r(this,s)}toJSON(){return`__CHANNEL__:${this.id}`}};s=new WeakMap;var u=class{constructor(t,e,a){this.plugin=t,this.event=e,this.channelId=a}async unregister(){return l(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function o(t,e,a){let n=new h;return n.onmessage=a,l(`plugin:${t}|register_listener`,{event:e,handler:n}).then((()=>new u(t,e,n.id)))}async function l(t,e={},a){return window.__TAURI_INTERNALS__.invoke(t,e,a)}function c(t,e="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(t,e)}a({},{TauriEvent:()=>p,emit:()=>g,listen:()=>d,once:()=>y});var p=(t=>(t.WINDOW_RESIZED="tauri://resize",t.WINDOW_MOVED="tauri://move",t.WINDOW_CLOSE_REQUESTED="tauri://close-requested",t.WINDOW_CREATED="tauri://window-created",t.WINDOW_DESTROYED="tauri://destroyed",t.WINDOW_FOCUS="tauri://focus",t.WINDOW_BLUR="tauri://blur",t.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",t.WINDOW_THEME_CHANGED="tauri://theme-changed",t.WINDOW_FILE_DROP="tauri://file-drop",t.WINDOW_FILE_DROP_HOVER="tauri://file-drop-hover",t.WINDOW_FILE_DROP_CANCELLED="tauri://file-drop-cancelled",t.MENU="tauri://menu",t))(p||{});async function _(t,e){await l("plugin:event|unlisten",{event:t,eventId:e})}async function d(t,e,a){return l("plugin:event|listen",{event:t,windowLabel:a?.target,handler:i(e)}).then((e=>async()=>_(t,e)))}async function y(t,e,a){return d(t,(a=>{e(a),_(t,a.id).catch((()=>{}))}),a)}async function g(t,e,a){await l("plugin:event|emit",{event:t,windowLabel:a?.target,payload:e})}return t.Store=class{constructor(t){this.path=t}async set(t,e){return await l("plugin:store|set",{path:this.path,key:t,value:e})}async get(t){return await l("plugin:store|get",{path:this.path,key:t})}async has(t){return await l("plugin:store|has",{path:this.path,key:t})}async delete(t){return await l("plugin:store|delete",{path:this.path,key:t})}async clear(){return await l("plugin:store|clear",{path:this.path})}async reset(){return await l("plugin:store|reset",{path:this.path})}async keys(){return await l("plugin:store|keys",{path:this.path})}async values(){return await l("plugin:store|values",{path:this.path})}async entries(){return await l("plugin:store|entries",{path:this.path})}async length(){return await l("plugin:store|length",{path:this.path})}async load(){return await l("plugin:store|load",{path:this.path})}async save(){return await l("plugin:store|save",{path:this.path})}async onKeyChange(t,e){return await d("store://change",(a=>{a.payload.path===this.path&&a.payload.key===t&&e(a.payload.value)}))}async onChange(t){return await d("store://change",(e=>{e.payload.path===this.path&&t(e.payload.key,e.payload.value)}))}},t}({});Object.defineProperty(window.__TAURI__,"store",{value:__TAURI_STORE__})} +if("__TAURI__"in window){var __TAURI_STORE__=function(t){"use strict";function a(t,a=!1){return window.__TAURI_INTERNALS__.transformCallback(t,a)}async function e(t,a={},e){return window.__TAURI_INTERNALS__.invoke(t,a,e)}var n;async function r(t,n,r){return e("plugin:event|listen",{event:t,windowLabel:r?.target,handler:a(n)}).then((a=>async()=>async function(t,a){await e("plugin:event|unlisten",{event:t,eventId:a})}(t,a)))}"function"==typeof SuppressedError&&SuppressedError,function(t){t.WINDOW_RESIZED="tauri://resize",t.WINDOW_MOVED="tauri://move",t.WINDOW_CLOSE_REQUESTED="tauri://close-requested",t.WINDOW_CREATED="tauri://window-created",t.WINDOW_DESTROYED="tauri://destroyed",t.WINDOW_FOCUS="tauri://focus",t.WINDOW_BLUR="tauri://blur",t.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",t.WINDOW_THEME_CHANGED="tauri://theme-changed",t.WINDOW_FILE_DROP="tauri://file-drop",t.WINDOW_FILE_DROP_HOVER="tauri://file-drop-hover",t.WINDOW_FILE_DROP_CANCELLED="tauri://file-drop-cancelled",t.MENU="tauri://menu"}(n||(n={}));return t.Store=class{constructor(t){this.path=t}async set(t,a){return await e("plugin:store|set",{path:this.path,key:t,value:a})}async get(t){return await e("plugin:store|get",{path:this.path,key:t})}async has(t){return await e("plugin:store|has",{path:this.path,key:t})}async delete(t){return await e("plugin:store|delete",{path:this.path,key:t})}async clear(){return await e("plugin:store|clear",{path:this.path})}async reset(){return await e("plugin:store|reset",{path:this.path})}async keys(){return await e("plugin:store|keys",{path:this.path})}async values(){return await e("plugin:store|values",{path:this.path})}async entries(){return await e("plugin:store|entries",{path:this.path})}async length(){return await e("plugin:store|length",{path:this.path})}async load(){return await e("plugin:store|load",{path:this.path})}async save(){return await e("plugin:store|save",{path:this.path})}async onKeyChange(t,a){return await r("store://change",(e=>{e.payload.path===this.path&&e.payload.key===t&&a(e.payload.value)}))}async onChange(t){return await r("store://change",(a=>{a.payload.path===this.path&&t(a.payload.key,a.payload.value)}))}},t}({});Object.defineProperty(window.__TAURI__,"store",{value:__TAURI_STORE__})} diff --git a/plugins/store/src/store.rs b/plugins/store/src/store.rs index cea0eb17f..1a7b6e1b3 100644 --- a/plugins/store/src/store.rs +++ b/plugins/store/src/store.rs @@ -208,7 +208,7 @@ impl Store { pub fn insert(&mut self, key: String, value: JsonValue) -> Result<(), Error> { self.cache.insert(key.clone(), value.clone()); - self.app.emit_all( + self.app.emit( "store://change", ChangePayload { path: &self.path, @@ -231,7 +231,7 @@ impl Store { pub fn delete(&mut self, key: impl AsRef) -> Result { let flag = self.cache.remove(key.as_ref()).is_some(); if flag { - self.app.emit_all( + self.app.emit( "store://change", ChangePayload { path: &self.path, @@ -247,7 +247,7 @@ impl Store { let keys: Vec = self.cache.keys().cloned().collect(); self.cache.clear(); for key in keys { - self.app.emit_all( + self.app.emit( "store://change", ChangePayload { path: &self.path, @@ -266,7 +266,7 @@ impl Store { if let Some(defaults) = &self.defaults { for (key, value) in &self.cache { if defaults.get(key) != Some(value) { - let _ = self.app.emit_all( + let _ = self.app.emit( "store://change", ChangePayload { path: &self.path, diff --git a/plugins/stronghold/CHANGELOG.md b/plugins/stronghold/CHANGELOG.md index 4a658d44c..e810bce08 100644 --- a/plugins/stronghold/CHANGELOG.md +++ b/plugins/stronghold/CHANGELOG.md @@ -2,7 +2,7 @@ ## \[2.0.0-alpha.3] -- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.16. +- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.9. ## \[2.0.0-alpha.2] diff --git a/plugins/stronghold/Cargo.toml b/plugins/stronghold/Cargo.toml index b5fa145e4..20163fa7d 100644 --- a/plugins/stronghold/Cargo.toml +++ b/plugins/stronghold/Cargo.toml @@ -8,7 +8,8 @@ edition = { workspace = true } rust-version = { workspace = true } [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = [ "--cfg", "docsrs" ] +rustdoc-args = [ "--cfg", "docsrs" ] [dependencies] serde = { workspace = true } diff --git a/plugins/stronghold/package.json b/plugins/stronghold/package.json index 4cb578f32..c70481ae0 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.9" + "@tauri-apps/api": "2.0.0-alpha.11" } } diff --git a/plugins/stronghold/src/api-iife.js b/plugins/stronghold/src/api-iife.js index 8fba22ec6..ab414f34f 100644 --- a/plugins/stronghold/src/api-iife.js +++ b/plugins/stronghold/src/api-iife.js @@ -1 +1 @@ -if("__TAURI__"in window){var __TAURI_STRONGHOLD__=function(t){"use strict";var e=Object.defineProperty,r=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},n=(t,e,n)=>(r(t,e,"read from private field"),n?n.call(t):e.get(t));function a(t,e=!1){return window.__TAURI_INTERNALS__.transformCallback(t,e)}((t,r)=>{for(var n in r)e(t,n,{get:r[n],enumerable:!0})})({},{Channel:()=>i,PluginListener:()=>o,addPluginListener:()=>h,convertFileSrc:()=>l,invoke:()=>c,transformCallback:()=>a});var s,i=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,((t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)})(this,s,(()=>{})),this.id=a((t=>{n(this,s).call(this,t)}))}set onmessage(t){var e,n,a,i;a=t,r(e=this,n=s,"write to private field"),i?i.call(e,a):n.set(e,a)}get onmessage(){return n(this,s)}toJSON(){return`__CHANNEL__:${this.id}`}};s=new WeakMap;var o=class{constructor(t,e,r){this.plugin=t,this.event=e,this.channelId=r}async unregister(){return c(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function h(t,e,r){let n=new i;return n.onmessage=r,c(`plugin:${t}|register_listener`,{event:e,handler:n}).then((()=>new o(t,e,n.id)))}async function c(t,e={},r){return window.__TAURI_INTERNALS__.invoke(t,e,r)}function l(t,e="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(t,e)}function u(t){return"string"==typeof t?t:Array.from(t instanceof ArrayBuffer?new Uint8Array(t):t)}class p{constructor(t,e){this.type=t,this.payload=e}static generic(t,e){return new p("Generic",{vault:u(t),record:u(e)})}static counter(t,e){return new p("Counter",{vault:u(t),counter:e})}}class d{constructor(t){this.procedureArgs=t}async generateSLIP10Seed(t,e){return await c("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"SLIP10Generate",payload:{output:t,sizeBytes:e}}}).then((t=>Uint8Array.from(t)))}async deriveSLIP10(t,e,r,n){return await c("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"SLIP10Derive",payload:{chain:t,input:{type:e,payload:r},output:n}}}).then((t=>Uint8Array.from(t)))}async recoverBIP39(t,e,r){return await c("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"BIP39Recover",payload:{mnemonic:t,passphrase:r,output:e}}}).then((t=>Uint8Array.from(t)))}async generateBIP39(t,e){return await c("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"BIP39Generate",payload:{output:t,passphrase:e}}}).then((t=>Uint8Array.from(t)))}async getEd25519PublicKey(t){return await c("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"PublicKey",payload:{type:"Ed25519",privateKey:t}}}).then((t=>Uint8Array.from(t)))}async signEd25519(t,e){return await c("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"Ed25519Sign",payload:{privateKey:t,msg:e}}}).then((t=>Uint8Array.from(t)))}}class g{constructor(t,e){this.path=t,this.name=u(e)}getVault(t){return new _(this.path,this.name,u(t))}getStore(){return new y(this.path,this.name)}}class y{constructor(t,e){this.path=t,this.client=e}async get(t){return await c("plugin:stronghold|get_store_record",{snapshotPath:this.path,client:this.client,key:u(t)}).then((t=>null!=t?Uint8Array.from(t):null))}async insert(t,e,r){return await c("plugin:stronghold|save_store_record",{snapshotPath:this.path,client:this.client,key:u(t),value:e,lifetime:r})}async remove(t){return await c("plugin:stronghold|remove_store_record",{snapshotPath:this.path,client:this.client,key:u(t)}).then((t=>null!=t?Uint8Array.from(t):null))}}class _ extends d{constructor(t,e,r){super({snapshotPath:t,client:e,vault:r}),this.path=t,this.client=u(e),this.name=u(r)}async insert(t,e){return await c("plugin:stronghold|save_secret",{snapshotPath:this.path,client:this.client,vault:this.name,recordPath:u(t),secret:e})}async remove(t){return await c("plugin:stronghold|remove_secret",{snapshotPath:this.path,client:this.client,vault:this.name,recordPath:t.payload.record})}}class w{constructor(t){this.path=t}static async load(t,e){return await c("plugin:stronghold|initialize",{snapshotPath:t,password:e}).then((()=>new w(t)))}async unload(){return await c("plugin:stronghold|destroy",{snapshotPath:this.path})}async loadClient(t){return await c("plugin:stronghold|load_client",{snapshotPath:this.path,client:u(t)}).then((()=>new g(this.path,t)))}async createClient(t){return await c("plugin:stronghold|create_client",{snapshotPath:this.path,client:u(t)}).then((()=>new g(this.path,t)))}async save(){return await c("plugin:stronghold|save",{snapshotPath:this.path})}}return t.Client=g,t.Location=p,t.Store=y,t.Stronghold=w,t.Vault=_,t}({});Object.defineProperty(window.__TAURI__,"stronghold",{value:__TAURI_STRONGHOLD__})} +if("__TAURI__"in window){var __TAURI_STRONGHOLD__=function(t){"use strict";async function e(t,e={},r){return window.__TAURI_INTERNALS__.invoke(t,e,r)}function r(t){return"string"==typeof t?t:Array.from(t instanceof ArrayBuffer?new Uint8Array(t):t)}"function"==typeof SuppressedError&&SuppressedError;class n{constructor(t,e){this.type=t,this.payload=e}static generic(t,e){return new n("Generic",{vault:r(t),record:r(e)})}static counter(t,e){return new n("Counter",{vault:r(t),counter:e})}}class a{constructor(t){this.procedureArgs=t}async generateSLIP10Seed(t,r){return await e("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"SLIP10Generate",payload:{output:t,sizeBytes:r}}}).then((t=>Uint8Array.from(t)))}async deriveSLIP10(t,r,n,a){return await e("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"SLIP10Derive",payload:{chain:t,input:{type:r,payload:n},output:a}}}).then((t=>Uint8Array.from(t)))}async recoverBIP39(t,r,n){return await e("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"BIP39Recover",payload:{mnemonic:t,passphrase:n,output:r}}}).then((t=>Uint8Array.from(t)))}async generateBIP39(t,r){return await e("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"BIP39Generate",payload:{output:t,passphrase:r}}}).then((t=>Uint8Array.from(t)))}async getEd25519PublicKey(t){return await e("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"PublicKey",payload:{type:"Ed25519",privateKey:t}}}).then((t=>Uint8Array.from(t)))}async signEd25519(t,r){return await e("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"Ed25519Sign",payload:{privateKey:t,msg:r}}}).then((t=>Uint8Array.from(t)))}}class s{constructor(t,e){this.path=t,this.name=r(e)}getVault(t){return new i(this.path,this.name,r(t))}getStore(){return new o(this.path,this.name)}}class o{constructor(t,e){this.path=t,this.client=e}async get(t){return await e("plugin:stronghold|get_store_record",{snapshotPath:this.path,client:this.client,key:r(t)}).then((t=>null!=t?Uint8Array.from(t):null))}async insert(t,n,a){return await e("plugin:stronghold|save_store_record",{snapshotPath:this.path,client:this.client,key:r(t),value:n,lifetime:a})}async remove(t){return await e("plugin:stronghold|remove_store_record",{snapshotPath:this.path,client:this.client,key:r(t)}).then((t=>null!=t?Uint8Array.from(t):null))}}class i extends a{constructor(t,e,n){super({snapshotPath:t,client:e,vault:n}),this.path=t,this.client=r(e),this.name=r(n)}async insert(t,n){return await e("plugin:stronghold|save_secret",{snapshotPath:this.path,client:this.client,vault:this.name,recordPath:r(t),secret:n})}async remove(t){return await e("plugin:stronghold|remove_secret",{snapshotPath:this.path,client:this.client,vault:this.name,recordPath:t.payload.record})}}class h{constructor(t){this.path=t}static async load(t,r){return await e("plugin:stronghold|initialize",{snapshotPath:t,password:r}).then((()=>new h(t)))}async unload(){return await e("plugin:stronghold|destroy",{snapshotPath:this.path})}async loadClient(t){return await e("plugin:stronghold|load_client",{snapshotPath:this.path,client:r(t)}).then((()=>new s(this.path,t)))}async createClient(t){return await e("plugin:stronghold|create_client",{snapshotPath:this.path,client:r(t)}).then((()=>new s(this.path,t)))}async save(){return await e("plugin:stronghold|save",{snapshotPath:this.path})}}return t.Client=s,t.Location=n,t.Store=o,t.Stronghold=h,t.Vault=i,t}({});Object.defineProperty(window.__TAURI__,"stronghold",{value:__TAURI_STRONGHOLD__})} diff --git a/plugins/updater/CHANGELOG.md b/plugins/updater/CHANGELOG.md index 0341115c0..f503bfeb3 100644 --- a/plugins/updater/CHANGELOG.md +++ b/plugins/updater/CHANGELOG.md @@ -2,7 +2,7 @@ ## \[2.0.0-alpha.2] -- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.16. +- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.9. ## \[2.0.0-alpha.2] diff --git a/plugins/updater/Cargo.toml b/plugins/updater/Cargo.toml index 60b056668..922d6b629 100644 --- a/plugins/updater/Cargo.toml +++ b/plugins/updater/Cargo.toml @@ -8,7 +8,8 @@ license = { workspace = true } rust-version = { workspace = true } [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = [ "--cfg", "docsrs" ] +rustdoc-args = [ "--cfg", "docsrs" ] [dependencies] tauri = { workspace = true } diff --git a/plugins/updater/package.json b/plugins/updater/package.json index 8b1d29dd3..339317505 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.9" + "@tauri-apps/api": "2.0.0-alpha.11" } } diff --git a/plugins/updater/src/api-iife.js b/plugins/updater/src/api-iife.js index a12f444be..0732a9872 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));function i(e,n=!1){return window.__TAURI_INTERNALS__.transformCallback(e,n)}((e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})})({},{Channel:()=>s,PluginListener:()=>o,addPluginListener:()=>l,convertFileSrc:()=>c,invoke:()=>_,transformCallback:()=>i});var a,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,a,(()=>{})),this.id=i((e=>{r(this,a).call(this,e)}))}set onmessage(e){var n,r,i,s;i=e,t(n=this,r=a,"write to private field"),s?s.call(n,i):r.set(n,i)}get onmessage(){return r(this,a)}toJSON(){return`__CHANNEL__:${this.id}`}};a=new WeakMap;var o=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 l(e,n,t){let r=new s;return r.onmessage=t,_(`plugin:${e}|register_listener`,{event:n,handler:r}).then((()=>new o(e,n,r.id)))}async function _(e,n={},t){return window.__TAURI_INTERNALS__.invoke(e,n,t)}function c(e,n="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,n)}class d{constructor(e){this.currentVersion=e.currentVersion,this.version=e.version,this.date=e.date,this.body=e.body}async downloadAndInstall(e){const n=new s;return null!=e&&(n.onmessage=e),_("plugin:updater|download_and_install",{onEvent:n})}}return e.Update=d,e.check=async function(e){return(null==e?void 0:e.headers)&&(e.headers=Array.from(new Headers(e.headers).entries())),_("plugin:updater|check",{...e}).then((e=>e.available?new d(e):null))},e}({});Object.defineProperty(window.__TAURI__,"updater",{value:__TAURI_UPDATER__})} +if("__TAURI__"in window){var __TAURI_UPDATER__=function(e){"use strict";function t(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)}var r;"function"==typeof SuppressedError&&SuppressedError;class n{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,r.set(this,(()=>{})),this.id=function(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}((e=>{t(this,r,"f").call(this,e)}))}set onmessage(e){!function(e,t,r,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===n?o.call(e,r):o?o.value=r:t.set(e,r)}(this,r,e,"f")}get onmessage(){return t(this,r,"f")}toJSON(){return`__CHANNEL__:${this.id}`}}async function o(e,t={},r){return window.__TAURI_INTERNALS__.invoke(e,t,r)}r=new WeakMap;class a{constructor(e){this.currentVersion=e.currentVersion,this.version=e.version,this.date=e.date,this.body=e.body}async downloadAndInstall(e){const t=new n;return null!=e&&(t.onmessage=e),o("plugin:updater|download_and_install",{onEvent:t})}}return e.Update=a,e.check=async function(e){return(null==e?void 0:e.headers)&&(e.headers=Array.from(new Headers(e.headers).entries())),o("plugin:updater|check",{...e}).then((e=>e.available?new a(e):null))},e}({});Object.defineProperty(window.__TAURI__,"updater",{value:__TAURI_UPDATER__})} diff --git a/plugins/upload/CHANGELOG.md b/plugins/upload/CHANGELOG.md index 35880572d..03ac852c1 100644 --- a/plugins/upload/CHANGELOG.md +++ b/plugins/upload/CHANGELOG.md @@ -2,7 +2,7 @@ ## \[2.0.0-alpha.2] -- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.16. +- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.9. ## \[2.0.0-alpha.2] diff --git a/plugins/upload/Cargo.toml b/plugins/upload/Cargo.toml index 01ad9e8e2..bb1d095c9 100644 --- a/plugins/upload/Cargo.toml +++ b/plugins/upload/Cargo.toml @@ -8,7 +8,8 @@ edition = { workspace = true } rust-version = { workspace = true } [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = [ "--cfg", "docsrs" ] +rustdoc-args = [ "--cfg", "docsrs" ] [dependencies] serde = { workspace = true } diff --git a/plugins/upload/package.json b/plugins/upload/package.json index 08bfb0c21..605026df2 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.9" + "@tauri-apps/api": "2.0.0-alpha.11" } } diff --git a/plugins/upload/src/api-iife.js b/plugins/upload/src/api-iife.js index 64b3b89d5..2b9053374 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));function a(e,n=!1){return window.__TAURI_INTERNALS__.transformCallback(e,n)}((e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})})({},{Channel:()=>o,PluginListener:()=>s,addPluginListener:()=>l,convertFileSrc:()=>u,invoke:()=>_,transformCallback:()=>a});var i,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,i,(()=>{})),this.id=a((e=>{r(this,i).call(this,e)}))}set onmessage(e){var n,r,a,o;a=e,t(n=this,r=i,"write to private field"),o?o.call(n,a):r.set(n,a)}get onmessage(){return r(this,i)}toJSON(){return`__CHANNEL__:${this.id}`}};i=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 l(e,n,t){let r=new o;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 window.__TAURI_INTERNALS__.invoke(e,n,t)}function u(e,n="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,n)}return e.download=async function(e,n,t,r){const a=new Uint32Array(1);window.crypto.getRandomValues(a);const i=a[0],s=new o;null!=t&&(s.onmessage=t),await _("plugin:upload|download",{id:i,url:e,filePath:n,headers:null!=r?r:{},onProgress:s})},e.upload=async function(e,n,t,r){const a=new Uint32Array(1);window.crypto.getRandomValues(a);const i=a[0],s=new o;null!=t&&(s.onmessage=t),await _("plugin:upload|upload",{id:i,url:e,filePath:n,headers:null!=r?r:{},onProgress:s})},e}({});Object.defineProperty(window.__TAURI__,"upload",{value:__TAURI_UPLOAD__})} +if("__TAURI__"in window){var __TAURI_UPLOAD__=function(e){"use strict";function t(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)}var n;"function"==typeof SuppressedError&&SuppressedError;class r{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,n.set(this,(()=>{})),this.id=function(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}((e=>{t(this,n,"f").call(this,e)}))}set onmessage(e){!function(e,t,n,r,o){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===r?o.call(e,n):o?o.value=n:t.set(e,n)}(this,n,e,"f")}get onmessage(){return t(this,n,"f")}toJSON(){return`__CHANNEL__:${this.id}`}}async function o(e,t={},n){return window.__TAURI_INTERNALS__.invoke(e,t,n)}return n=new WeakMap,e.download=async function(e,t,n,a){const i=new Uint32Array(1);window.crypto.getRandomValues(i);const s=i[0],l=new r;null!=n&&(l.onmessage=n),await o("plugin:upload|download",{id:s,url:e,filePath:t,headers:null!=a?a:{},onProgress:l})},e.upload=async function(e,t,n,a){const i=new Uint32Array(1);window.crypto.getRandomValues(i);const s=i[0],l=new r;null!=n&&(l.onmessage=n),await o("plugin:upload|upload",{id:s,url:e,filePath:t,headers:null!=a?a:{},onProgress:l})},e}({});Object.defineProperty(window.__TAURI__,"upload",{value:__TAURI_UPLOAD__})} diff --git a/plugins/websocket/CHANGELOG.md b/plugins/websocket/CHANGELOG.md index 57551842f..2292d26f9 100644 --- a/plugins/websocket/CHANGELOG.md +++ b/plugins/websocket/CHANGELOG.md @@ -2,7 +2,7 @@ ## \[2.0.0-alpha.2] -- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.16. +- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.9. ## \[2.0.0-alpha.2] diff --git a/plugins/websocket/Cargo.toml b/plugins/websocket/Cargo.toml index d86df4f26..e5bd55fbb 100644 --- a/plugins/websocket/Cargo.toml +++ b/plugins/websocket/Cargo.toml @@ -9,7 +9,8 @@ rust-version = { workspace = true } exclude = [ "/examples" ] [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = [ "--cfg", "docsrs" ] +rustdoc-args = [ "--cfg", "docsrs" ] [dependencies] serde = { workspace = true } diff --git a/plugins/websocket/examples/svelte-app/package.json b/plugins/websocket/examples/svelte-app/package.json index 66d842e4e..8e1ca06cc 100644 --- a/plugins/websocket/examples/svelte-app/package.json +++ b/plugins/websocket/examples/svelte-app/package.json @@ -13,7 +13,7 @@ "devDependencies": { "@sveltejs/adapter-static": "2.0.3", "@sveltejs/kit": "1.26.0", - "@tauri-apps/cli": "2.0.0-alpha.16", + "@tauri-apps/cli": "2.0.0-alpha.17", "svelte": "4.2.2", "svelte-check": "3.5.2", "tslib": "2.6.2", diff --git a/plugins/websocket/package.json b/plugins/websocket/package.json index 1af406f85..99d764194 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.9" + "@tauri-apps/api": "2.0.0-alpha.11" } } diff --git a/plugins/websocket/src/api-iife.js b/plugins/websocket/src/api-iife.js index 1e89a84f7..5f4eb9810 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";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));function r(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}((t,n)=>{for(var r in n)e(t,r,{get:n[r],enumerable:!0})})({},{Channel:()=>s,PluginListener:()=>a,addPluginListener:()=>o,convertFileSrc:()=>_,invoke:()=>c,transformCallback:()=>r});var i,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,i,(()=>{})),this.id=r((e=>{n(this,i).call(this,e)}))}set onmessage(e){var n,r,s,a;s=e,t(n=this,r=i,"write to private field"),a?a.call(n,s):r.set(n,s)}get onmessage(){return n(this,i)}toJSON(){return`__CHANNEL__:${this.id}`}};i=new WeakMap;var a=class{constructor(e,t,n){this.plugin=e,this.event=t,this.channelId=n}async unregister(){return c(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function o(e,t,n){let r=new s;return r.onmessage=n,c(`plugin:${e}|register_listener`,{event:t,handler:r}).then((()=>new a(e,t,r.id)))}async function c(e,t={},n){return window.__TAURI_INTERNALS__.invoke(e,t,n)}function _(e,t="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,t)}class l{constructor(e,t){this.id=e,this.listeners=t}static async connect(e,t){const n=[],r=new s;return r.onmessage=e=>{n.forEach((t=>t(e)))},await c("plugin:websocket|connect",{url:e,onMessage:r,config:t}).then((e=>new l(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 c("plugin:websocket|send",{id:this.id,message:t})}async disconnect(){return await this.send({type:"Close",data:{code:1e3,reason:"Disconnected by client"}})}}return l}();Object.defineProperty(window.__TAURI__,"websocket",{value:__TAURI_WEBSOCKET__})} +if("__TAURI__"in window){var __TAURI_WEBSOCKET__=function(){"use strict";function e(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)}var t;"function"==typeof SuppressedError&&SuppressedError;class r{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,t.set(this,(()=>{})),this.id=function(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}((r=>{e(this,t,"f").call(this,r)}))}set onmessage(e){!function(e,t,r,n,s){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===n?s.call(e,r):s?s.value=r:t.set(e,r)}(this,t,e,"f")}get onmessage(){return e(this,t,"f")}toJSON(){return`__CHANNEL__:${this.id}`}}async function n(e,t={},r){return window.__TAURI_INTERNALS__.invoke(e,t,r)}t=new WeakMap;class s{constructor(e,t){this.id=e,this.listeners=t}static async connect(e,t){const i=[],a=new r;return a.onmessage=e=>{i.forEach((t=>t(e)))},await n("plugin:websocket|connect",{url:e,onMessage:a,config:t}).then((e=>new s(e,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 n("plugin:websocket|send",{id:this.id,message:t})}async disconnect(){return await this.send({type:"Close",data:{code:1e3,reason:"Disconnected by client"}})}}return s}();Object.defineProperty(window.__TAURI__,"websocket",{value:__TAURI_WEBSOCKET__})} diff --git a/plugins/window-state/CHANGELOG.md b/plugins/window-state/CHANGELOG.md index 79f53e6e9..9c29e93fe 100644 --- a/plugins/window-state/CHANGELOG.md +++ b/plugins/window-state/CHANGELOG.md @@ -2,7 +2,7 @@ ## \[2.0.0-alpha.2] -- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.16. +- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.9. - [`beb6b13`](https://github.com/tauri-apps/plugins-workspace/commit/beb6b139eb669dc0346b3de919aed024f649b9d2)([#675](https://github.com/tauri-apps/plugins-workspace/pull/675)) Fix usage of no longer available `__TAURI_METADATA__` API. ## \[2.0.0-alpha.2] diff --git a/plugins/window-state/Cargo.toml b/plugins/window-state/Cargo.toml index ad4268005..836f4a712 100644 --- a/plugins/window-state/Cargo.toml +++ b/plugins/window-state/Cargo.toml @@ -8,7 +8,8 @@ edition = { workspace = true } rust-version = { workspace = true } [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = [ "--cfg", "docsrs" ] +rustdoc-args = [ "--cfg", "docsrs" ] [dependencies] serde = { workspace = true } diff --git a/plugins/window-state/package.json b/plugins/window-state/package.json index e5892c801..a1a5bd4cd 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.9" + "@tauri-apps/api": "2.0.0-alpha.11" } } diff --git a/plugins/window-state/src/api-iife.js b/plugins/window-state/src/api-iife.js index 680f61cd4..15012bf4f 100644 --- a/plugins/window-state/src/api-iife.js +++ b/plugins/window-state/src/api-iife.js @@ -1 +1 @@ -if("__TAURI__"in window){var __TAURI_WINDOWSTATE__=function(e){"use strict";var t=Object.defineProperty,i=(e,i)=>{for(var n in i)t(e,n,{get:i[n],enumerable:!0})},n=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},a=(e,t,i)=>(n(e,t,"read from private field"),i?i.call(e):t.get(e));function l(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}i({},{Channel:()=>r,PluginListener:()=>o,addPluginListener:()=>u,convertFileSrc:()=>h,invoke:()=>c,transformCallback:()=>l});var s,r=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,((e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)})(this,s,(()=>{})),this.id=l((e=>{a(this,s).call(this,e)}))}set onmessage(e){((e,t,i,a)=>{n(e,t,"write to private field"),a?a.call(e,i):t.set(e,i)})(this,s,e)}get onmessage(){return a(this,s)}toJSON(){return`__CHANNEL__:${this.id}`}};s=new WeakMap;var o=class{constructor(e,t,i){this.plugin=e,this.event=t,this.channelId=i}async unregister(){return c(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function u(e,t,i){let n=new r;return n.onmessage=i,c(`plugin:${e}|register_listener`,{event:t,handler:n}).then((()=>new o(e,t,n.id)))}async function c(e,t={},i){return window.__TAURI_INTERNALS__.invoke(e,t,i)}function h(e,t="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,t)}i({},{LogicalPosition:()=>b,LogicalSize:()=>d,PhysicalPosition:()=>p,PhysicalSize:()=>w});var d=class{constructor(e,t){this.type="Logical",this.width=e,this.height=t}},w=class{constructor(e,t){this.type="Physical",this.width=e,this.height=t}toLogical(e){return new d(this.width/e,this.height/e)}},b=class{constructor(e,t){this.type="Logical",this.x=e,this.y=t}},p=class{constructor(e,t){this.type="Physical",this.x=e,this.y=t}toLogical(e){return new b(this.x/e,this.y/e)}};i({},{TauriEvent:()=>g,emit:()=>v,listen:()=>_,once:()=>m});var g=(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))(g||{});async function y(e,t){await c("plugin:event|unlisten",{event:e,eventId:t})}async function _(e,t,i){return c("plugin:event|listen",{event:e,windowLabel:i?.target,handler:l(t)}).then((t=>async()=>y(e,t)))}async function m(e,t,i){return _(e,(i=>{t(i),y(e,i.id).catch((()=>{}))}),i)}async function v(e,t,i){await c("plugin:event|emit",{event:e,windowLabel:i?.target,payload:t})}i({},{CloseRequestedEvent:()=>I,Effect:()=>C,EffectState:()=>N,LogicalPosition:()=>b,LogicalSize:()=>d,PhysicalPosition:()=>p,PhysicalSize:()=>w,ProgressBarStatus:()=>S,UserAttentionType:()=>E,Window:()=>T,availableMonitors:()=>M,currentMonitor:()=>k,getAll:()=>z,getCurrent:()=>L,primaryMonitor:()=>x});var f,E=((f=E||{})[f.Critical=1]="Critical",f[f.Informational=2]="Informational",f),I=class{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}},S=(e=>(e.None="none",e.Normal="normal",e.Indeterminate="indeterminate",e.Paused="paused",e.Error="error",e))(S||{});function L(){return new T(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}function z(){return window.__TAURI_INTERNALS__.metadata.windows.map((e=>new T(e.label,{skip:!0})))}var P,D,A=["tauri://created","tauri://error"],T=class e{constructor(e,t={}){this.label=e,this.listeners=Object.create(null),t?.skip||c("plugin:window|create",{options:{...t,label:e}}).then((async()=>this.emit("tauri://created"))).catch((async e=>this.emit("tauri://error",e)))}static getByLabel(t){return z().some((e=>e.label===t))?new e(t,{skip:!0}):null}static getCurrent(){return L()}static getAll(){return z()}static async getFocusedWindow(){for(let e of z())if(await e.isFocused())return e;return null}async listen(e,t){return this._handleTauriEvent(e,t)?Promise.resolve((()=>{let i=this.listeners[e];i.splice(i.indexOf(t),1)})):_(e,t,{target:this.label})}async once(e,t){return this._handleTauriEvent(e,t)?Promise.resolve((()=>{let i=this.listeners[e];i.splice(i.indexOf(t),1)})):m(e,t,{target:this.label})}async emit(e,t){if(A.includes(e)){for(let i of this.listeners[e]||[])i({event:e,id:-1,windowLabel:this.label,payload:t});return Promise.resolve()}return v(e,t,{target:this.label})}_handleTauriEvent(e,t){return!!A.includes(e)&&(e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t],!0)}async scaleFactor(){return c("plugin:window|scale_factor",{label:this.label})}async innerPosition(){return c("plugin:window|inner_position",{label:this.label}).then((({x:e,y:t})=>new p(e,t)))}async outerPosition(){return c("plugin:window|outer_position",{label:this.label}).then((({x:e,y:t})=>new p(e,t)))}async innerSize(){return c("plugin:window|inner_size",{label:this.label}).then((({width:e,height:t})=>new w(e,t)))}async outerSize(){return c("plugin:window|outer_size",{label:this.label}).then((({width:e,height:t})=>new w(e,t)))}async isFullscreen(){return c("plugin:window|is_fullscreen",{label:this.label})}async isMinimized(){return c("plugin:window|is_minimized",{label:this.label})}async isMaximized(){return c("plugin:window|is_maximized",{label:this.label})}async isFocused(){return c("plugin:window|is_focused",{label:this.label})}async isDecorated(){return c("plugin:window|is_decorated",{label:this.label})}async isResizable(){return c("plugin:window|is_resizable",{label:this.label})}async isMaximizable(){return c("plugin:window|is_maximizable",{label:this.label})}async isMinimizable(){return c("plugin:window|is_minimizable",{label:this.label})}async isClosable(){return c("plugin:window|is_closable",{label:this.label})}async isVisible(){return c("plugin:window|is_visible",{label:this.label})}async title(){return c("plugin:window|title",{label:this.label})}async theme(){return c("plugin:window|theme",{label:this.label})}async center(){return c("plugin:window|center",{label:this.label})}async requestUserAttention(e){let t=null;return e&&(t=1===e?{type:"Critical"}:{type:"Informational"}),c("plugin:window|request_user_attention",{label:this.label,value:t})}async setResizable(e){return c("plugin:window|set_resizable",{label:this.label,value:e})}async setMaximizable(e){return c("plugin:window|set_maximizable",{label:this.label,value:e})}async setMinimizable(e){return c("plugin:window|set_minimizable",{label:this.label,value:e})}async setClosable(e){return c("plugin:window|set_closable",{label:this.label,value:e})}async setTitle(e){return c("plugin:window|set_title",{label:this.label,value:e})}async maximize(){return c("plugin:window|maximize",{label:this.label})}async unmaximize(){return c("plugin:window|unmaximize",{label:this.label})}async toggleMaximize(){return c("plugin:window|toggle_maximize",{label:this.label})}async minimize(){return c("plugin:window|minimize",{label:this.label})}async unminimize(){return c("plugin:window|unminimize",{label:this.label})}async show(){return c("plugin:window|show",{label:this.label})}async hide(){return c("plugin:window|hide",{label:this.label})}async close(){return c("plugin:window|close",{label:this.label})}async setDecorations(e){return c("plugin:window|set_decorations",{label:this.label,value:e})}async setShadow(e){return c("plugin:window|set_shadow",{label:this.label,value:e})}async setEffects(e){return c("plugin:window|set_effects",{label:this.label,value:e})}async clearEffects(){return c("plugin:window|set_effects",{label:this.label,value:null})}async setAlwaysOnTop(e){return c("plugin:window|set_always_on_top",{label:this.label,value:e})}async setAlwaysOnBottom(e){return c("plugin:window|set_always_on_bottom",{label:this.label,value:e})}async setContentProtected(e){return c("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 c("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 c("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 c("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 c("plugin:window|set_position",{label:this.label,value:{type:e.type,data:{x:e.x,y:e.y}}})}async setFullscreen(e){return c("plugin:window|set_fullscreen",{label:this.label,value:e})}async setFocus(){return c("plugin:window|set_focus",{label:this.label})}async setIcon(e){return c("plugin:window|set_icon",{label:this.label,value:"string"==typeof e?e:Array.from(e)})}async setSkipTaskbar(e){return c("plugin:window|set_skip_taskbar",{label:this.label,value:e})}async setCursorGrab(e){return c("plugin:window|set_cursor_grab",{label:this.label,value:e})}async setCursorVisible(e){return c("plugin:window|set_cursor_visible",{label:this.label,value:e})}async setCursorIcon(e){return c("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 c("plugin:window|set_cursor_position",{label:this.label,value:{type:e.type,data:{x:e.x,y:e.y}}})}async setIgnoreCursorEvents(e){return c("plugin:window|set_ignore_cursor_events",{label:this.label,value:e})}async startDragging(){return c("plugin:window|start_dragging",{label:this.label})}async setProgressBar(e){return c("plugin:window|set_progress_bar",{label:this.label,value:e})}async onResized(e){return this.listen("tauri://resize",(t=>{t.payload=R(t.payload),e(t)}))}async onMoved(e){return this.listen("tauri://move",(t=>{t.payload=O(t.payload),e(t)}))}async onCloseRequested(e){return this.listen("tauri://close-requested",(t=>{let i=new I(t);Promise.resolve(e(i)).then((()=>{if(!i.isPreventDefault())return this.close()}))}))}async onFocusChanged(e){let t=await this.listen("tauri://focus",(t=>{e({...t,payload:!0})})),i=await this.listen("tauri://blur",(t=>{e({...t,payload:!1})}));return()=>{t(),i()}}async onScaleChanged(e){return this.listen("tauri://scale-change",e)}async onMenuClicked(e){return this.listen("tauri://menu",e)}async onFileDropEvent(e){let t=await this.listen("tauri://file-drop",(t=>{e({...t,payload:{type:"drop",paths:t.payload}})})),i=await this.listen("tauri://file-drop-hover",(t=>{e({...t,payload:{type:"hover",paths:t.payload}})})),n=await this.listen("tauri://file-drop-cancelled",(t=>{e({...t,payload:{type:"cancel"}})}));return()=>{t(),i(),n()}}async onThemeChanged(e){return this.listen("tauri://theme-changed",e)}},C=(e=>(e.AppearanceBased="appearanceBased",e.Light="light",e.Dark="dark",e.MediumLight="mediumLight",e.UltraDark="ultraDark",e.Titlebar="titlebar",e.Selection="selection",e.Menu="menu",e.Popover="popover",e.Sidebar="sidebar",e.HeaderView="headerView",e.Sheet="sheet",e.WindowBackground="windowBackground",e.HudWindow="hudWindow",e.FullScreenUI="fullScreenUI",e.Tooltip="tooltip",e.ContentBackground="contentBackground",e.UnderWindowBackground="underWindowBackground",e.UnderPageBackground="underPageBackground",e.Mica="mica",e.Blur="blur",e.Acrylic="acrylic",e.Tabbed="tabbed",e.TabbedDark="tabbedDark",e.TabbedLight="tabbedLight",e))(C||{}),N=((P=N||{}).FollowsWindowActiveState="followsWindowActiveState",P.Active="active",P.Inactive="inactive",P);function W(e){return null===e?null:{name:e.name,scaleFactor:e.scaleFactor,position:O(e.position),size:R(e.size)}}function O(e){return new p(e.x,e.y)}function R(e){return new w(e.width,e.height)}async function k(){return c("plugin:window|current_monitor").then(W)}async function x(){return c("plugin:window|primary_monitor").then(W)}async function M(){return c("plugin:window|available_monitors").then((e=>e.map(W)))}async function F(e,t){return c("plugin:window-state|restore_state",{label:e,flags:t})}return e.StateFlags=void 0,(D=e.StateFlags||(e.StateFlags={}))[D.SIZE=1]="SIZE",D[D.POSITION=2]="POSITION",D[D.MAXIMIZED=4]="MAXIMIZED",D[D.VISIBLE=8]="VISIBLE",D[D.DECORATIONS=16]="DECORATIONS",D[D.FULLSCREEN=32]="FULLSCREEN",D[D.ALL=63]="ALL",e.restoreState=F,e.restoreStateCurrent=async function(e){return F(L().label,e)},e.saveWindowState=async function(e){return c("plugin:window-state|save_window_state",{flags:e})},e}({});Object.defineProperty(window.__TAURI__,"windowState",{value:__TAURI_WINDOWSTATE__})} +if("__TAURI__"in window){var __TAURI_WINDOWSTATE__=function(e){"use strict";function t(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}async function i(e,t={},i){return window.__TAURI_INTERNALS__.invoke(e,t,i)}"function"==typeof SuppressedError&&SuppressedError;class n{constructor(e,t){this.type="Logical",this.width=e,this.height=t}}class a{constructor(e,t){this.type="Physical",this.width=e,this.height=t}toLogical(e){return new n(this.width/e,this.height/e)}}class l{constructor(e,t){this.type="Logical",this.x=e,this.y=t}}class s{constructor(e,t){this.type="Physical",this.x=e,this.y=t}toLogical(e){return new l(this.x/e,this.y/e)}}var r,o,u;async function c(e,t){await i("plugin:event|unlisten",{event:e,eventId:t})}async function h(e,n,a){return i("plugin:event|listen",{event:e,windowLabel:a?.target,handler:t(n)}).then((t=>async()=>c(e,t)))}!function(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"}(r||(r={})),function(e){e[e.Critical=1]="Critical",e[e.Informational=2]="Informational"}(o||(o={}));class w{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 d(){return new p(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}function b(){return window.__TAURI_INTERNALS__.metadata.windows.map((e=>new p(e.label,{skip:!0})))}!function(e){e.None="none",e.Normal="normal",e.Indeterminate="indeterminate",e.Paused="paused",e.Error="error"}(u||(u={}));const y=["tauri://created","tauri://error"];class p{constructor(e,t={}){this.label=e,this.listeners=Object.create(null),t?.skip||i("plugin:window|create",{options:{...t,label:e}}).then((async()=>this.emit("tauri://created"))).catch((async e=>this.emit("tauri://error",e)))}static getByLabel(e){return b().some((t=>t.label===e))?new p(e,{skip:!0}):null}static getCurrent(){return d()}static getAll(){return b()}static async getFocusedWindow(){for(const e of b())if(await e.isFocused())return e;return null}async listen(e,t){return this._handleTauriEvent(e,t)?Promise.resolve((()=>{const i=this.listeners[e];i.splice(i.indexOf(t),1)})):h(e,t,{target:this.label})}async once(e,t){return this._handleTauriEvent(e,t)?Promise.resolve((()=>{const i=this.listeners[e];i.splice(i.indexOf(t),1)})):async function(e,t,i){return h(e,(i=>{t(i),c(e,i.id).catch((()=>{}))}),i)}(e,t,{target:this.label})}async emit(e,t){if(y.includes(e)){for(const i of this.listeners[e]||[])i({event:e,id:-1,windowLabel:this.label,payload:t});return Promise.resolve()}return async function(e,t,n){await i("plugin:event|emit",{event:e,windowLabel:n?.target,payload:t})}(e,t,{target:this.label})}_handleTauriEvent(e,t){return!!y.includes(e)&&(e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t],!0)}async scaleFactor(){return i("plugin:window|scale_factor",{label:this.label})}async innerPosition(){return i("plugin:window|inner_position",{label:this.label}).then((({x:e,y:t})=>new s(e,t)))}async outerPosition(){return i("plugin:window|outer_position",{label:this.label}).then((({x:e,y:t})=>new s(e,t)))}async innerSize(){return i("plugin:window|inner_size",{label:this.label}).then((({width:e,height:t})=>new a(e,t)))}async outerSize(){return i("plugin:window|outer_size",{label:this.label}).then((({width:e,height:t})=>new a(e,t)))}async isFullscreen(){return i("plugin:window|is_fullscreen",{label:this.label})}async isMinimized(){return i("plugin:window|is_minimized",{label:this.label})}async isMaximized(){return i("plugin:window|is_maximized",{label:this.label})}async isFocused(){return i("plugin:window|is_focused",{label:this.label})}async isDecorated(){return i("plugin:window|is_decorated",{label:this.label})}async isResizable(){return i("plugin:window|is_resizable",{label:this.label})}async isMaximizable(){return i("plugin:window|is_maximizable",{label:this.label})}async isMinimizable(){return i("plugin:window|is_minimizable",{label:this.label})}async isClosable(){return i("plugin:window|is_closable",{label:this.label})}async isVisible(){return i("plugin:window|is_visible",{label:this.label})}async title(){return i("plugin:window|title",{label:this.label})}async theme(){return i("plugin:window|theme",{label:this.label})}async center(){return i("plugin:window|center",{label:this.label})}async requestUserAttention(e){let t=null;return e&&(t=e===o.Critical?{type:"Critical"}:{type:"Informational"}),i("plugin:window|request_user_attention",{label:this.label,value:t})}async setResizable(e){return i("plugin:window|set_resizable",{label:this.label,value:e})}async setMaximizable(e){return i("plugin:window|set_maximizable",{label:this.label,value:e})}async setMinimizable(e){return i("plugin:window|set_minimizable",{label:this.label,value:e})}async setClosable(e){return i("plugin:window|set_closable",{label:this.label,value:e})}async setTitle(e){return i("plugin:window|set_title",{label:this.label,value:e})}async maximize(){return i("plugin:window|maximize",{label:this.label})}async unmaximize(){return i("plugin:window|unmaximize",{label:this.label})}async toggleMaximize(){return i("plugin:window|toggle_maximize",{label:this.label})}async minimize(){return i("plugin:window|minimize",{label:this.label})}async unminimize(){return i("plugin:window|unminimize",{label:this.label})}async show(){return i("plugin:window|show",{label:this.label})}async hide(){return i("plugin:window|hide",{label:this.label})}async close(){return i("plugin:window|close",{label:this.label})}async setDecorations(e){return i("plugin:window|set_decorations",{label:this.label,value:e})}async setShadow(e){return i("plugin:window|set_shadow",{label:this.label,value:e})}async setEffects(e){return i("plugin:window|set_effects",{label:this.label,value:e})}async clearEffects(){return i("plugin:window|set_effects",{label:this.label,value:null})}async setAlwaysOnTop(e){return i("plugin:window|set_always_on_top",{label:this.label,value:e})}async setAlwaysOnBottom(e){return i("plugin:window|set_always_on_bottom",{label:this.label,value:e})}async setContentProtected(e){return i("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 i("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 i("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 i("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 i("plugin:window|set_position",{label:this.label,value:{type:e.type,data:{x:e.x,y:e.y}}})}async setFullscreen(e){return i("plugin:window|set_fullscreen",{label:this.label,value:e})}async setFocus(){return i("plugin:window|set_focus",{label:this.label})}async setIcon(e){return i("plugin:window|set_icon",{label:this.label,value:"string"==typeof e?e:Array.from(e)})}async setSkipTaskbar(e){return i("plugin:window|set_skip_taskbar",{label:this.label,value:e})}async setCursorGrab(e){return i("plugin:window|set_cursor_grab",{label:this.label,value:e})}async setCursorVisible(e){return i("plugin:window|set_cursor_visible",{label:this.label,value:e})}async setCursorIcon(e){return i("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 i("plugin:window|set_cursor_position",{label:this.label,value:{type:e.type,data:{x:e.x,y:e.y}}})}async setIgnoreCursorEvents(e){return i("plugin:window|set_ignore_cursor_events",{label:this.label,value:e})}async startDragging(){return i("plugin:window|start_dragging",{label:this.label})}async setProgressBar(e){return i("plugin:window|set_progress_bar",{label:this.label,value:e})}async onResized(e){return this.listen(r.WINDOW_RESIZED,(t=>{var i;t.payload=(i=t.payload,new a(i.width,i.height)),e(t)}))}async onMoved(e){return this.listen(r.WINDOW_MOVED,(t=>{var i;t.payload=(i=t.payload,new s(i.x,i.y)),e(t)}))}async onCloseRequested(e){return this.listen(r.WINDOW_CLOSE_REQUESTED,(t=>{const i=new w(t);Promise.resolve(e(i)).then((()=>{if(!i.isPreventDefault())return this.close()}))}))}async onFocusChanged(e){const t=await this.listen(r.WINDOW_FOCUS,(t=>{e({...t,payload:!0})})),i=await this.listen(r.WINDOW_BLUR,(t=>{e({...t,payload:!1})}));return()=>{t(),i()}}async onScaleChanged(e){return this.listen(r.WINDOW_SCALE_FACTOR_CHANGED,e)}async onMenuClicked(e){return this.listen(r.MENU,e)}async onFileDropEvent(e){const t=await this.listen(r.WINDOW_FILE_DROP,(t=>{e({...t,payload:{type:"drop",paths:t.payload}})})),i=await this.listen(r.WINDOW_FILE_DROP_HOVER,(t=>{e({...t,payload:{type:"hover",paths:t.payload}})})),n=await this.listen(r.WINDOW_FILE_DROP_CANCELLED,(t=>{e({...t,payload:{type:"cancel"}})}));return()=>{t(),i(),n()}}async onThemeChanged(e){return this.listen(r.WINDOW_THEME_CHANGED,e)}}var _,g,m;async function v(e,t){return i("plugin:window-state|restore_state",{label:e,flags:t})}return function(e){e.AppearanceBased="appearanceBased",e.Light="light",e.Dark="dark",e.MediumLight="mediumLight",e.UltraDark="ultraDark",e.Titlebar="titlebar",e.Selection="selection",e.Menu="menu",e.Popover="popover",e.Sidebar="sidebar",e.HeaderView="headerView",e.Sheet="sheet",e.WindowBackground="windowBackground",e.HudWindow="hudWindow",e.FullScreenUI="fullScreenUI",e.Tooltip="tooltip",e.ContentBackground="contentBackground",e.UnderWindowBackground="underWindowBackground",e.UnderPageBackground="underPageBackground",e.Mica="mica",e.Blur="blur",e.Acrylic="acrylic",e.Tabbed="tabbed",e.TabbedDark="tabbedDark",e.TabbedLight="tabbedLight"}(_||(_={})),function(e){e.FollowsWindowActiveState="followsWindowActiveState",e.Active="active",e.Inactive="inactive"}(g||(g={})),e.StateFlags=void 0,(m=e.StateFlags||(e.StateFlags={}))[m.SIZE=1]="SIZE",m[m.POSITION=2]="POSITION",m[m.MAXIMIZED=4]="MAXIMIZED",m[m.VISIBLE=8]="VISIBLE",m[m.DECORATIONS=16]="DECORATIONS",m[m.FULLSCREEN=32]="FULLSCREEN",m[m.ALL=63]="ALL",e.restoreState=v,e.restoreStateCurrent=async function(e){return v(d().label,e)},e.saveWindowState=async function(e){return i("plugin:window-state|save_window_state",{flags:e})},e}({});Object.defineProperty(window.__TAURI__,"windowState",{value:__TAURI_WINDOWSTATE__})} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a22a5f447..6d979b3d1 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.9 - version: 2.0.0-alpha.9 + specifier: 2.0.0-alpha.11 + version: 2.0.0-alpha.11 '@tauri-apps/plugin-barcode-scanner': specifier: 2.0.0-alpha.1 version: link:../../plugins/barcode-scanner @@ -116,8 +116,8 @@ importers: specifier: ^2.4.6 version: 2.4.6(svelte@4.2.2)(vite@4.5.0) '@tauri-apps/cli': - specifier: 2.0.0-alpha.16 - version: 2.0.0-alpha.16 + specifier: 2.0.0-alpha.17 + version: 2.0.0-alpha.17 '@unocss/extractor-svelte': specifier: ^0.56.5 version: 0.56.5 @@ -129,7 +129,7 @@ importers: version: 4.2.2 unocss: specifier: ^0.56.5 - version: 0.56.5(postcss@8.4.31)(vite@4.5.0) + version: 0.56.5(postcss@8.4.31)(rollup@4.1.4)(vite@4.5.0) vite: specifier: ^4.5.0 version: 4.5.0 @@ -137,8 +137,8 @@ importers: plugins/authenticator: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 + specifier: 2.0.0-alpha.11 + version: 2.0.0-alpha.11 devDependencies: tslib: specifier: 2.6.0 @@ -147,8 +147,8 @@ importers: plugins/autostart: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 + specifier: 2.0.0-alpha.11 + version: 2.0.0-alpha.11 devDependencies: tslib: specifier: 2.6.0 @@ -157,8 +157,8 @@ importers: plugins/barcode-scanner: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 + specifier: 2.0.0-alpha.11 + version: 2.0.0-alpha.11 devDependencies: tslib: specifier: ^2.5.0 @@ -167,8 +167,8 @@ importers: plugins/cli: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 + specifier: 2.0.0-alpha.11 + version: 2.0.0-alpha.11 devDependencies: tslib: specifier: ^2.4.1 @@ -177,8 +177,8 @@ importers: plugins/clipboard-manager: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 + specifier: 2.0.0-alpha.11 + version: 2.0.0-alpha.11 devDependencies: tslib: specifier: ^2.4.1 @@ -187,8 +187,8 @@ importers: plugins/deep-link: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 + specifier: 2.0.0-alpha.11 + version: 2.0.0-alpha.11 devDependencies: tslib: specifier: ^2.5.0 @@ -197,15 +197,15 @@ importers: plugins/deep-link/examples/app: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.6 - version: 2.0.0-alpha.6 + specifier: 2.0.0-alpha.11 + version: 2.0.0-alpha.11 '@tauri-apps/plugin-deep-link': specifier: 2.0.0-alpha.1 version: link:../.. devDependencies: '@tauri-apps/cli': - specifier: 2.0.0-alpha.16 - version: 2.0.0-alpha.16 + specifier: 2.0.0-alpha.17 + version: 2.0.0-alpha.17 internal-ip: specifier: ^8.0.0 version: 8.0.0 @@ -219,8 +219,8 @@ importers: plugins/dialog: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 + specifier: 2.0.0-alpha.11 + version: 2.0.0-alpha.11 devDependencies: tslib: specifier: ^2.4.1 @@ -229,8 +229,8 @@ importers: plugins/fs: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 + specifier: 2.0.0-alpha.11 + version: 2.0.0-alpha.11 devDependencies: tslib: specifier: ^2.4.1 @@ -239,8 +239,8 @@ importers: plugins/global-shortcut: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 + specifier: 2.0.0-alpha.11 + version: 2.0.0-alpha.11 devDependencies: tslib: specifier: ^2.4.1 @@ -249,8 +249,8 @@ importers: plugins/http: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 + specifier: 2.0.0-alpha.11 + version: 2.0.0-alpha.11 devDependencies: tslib: specifier: ^2.5.0 @@ -259,8 +259,8 @@ importers: plugins/log: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 + specifier: 2.0.0-alpha.11 + version: 2.0.0-alpha.11 devDependencies: tslib: specifier: 2.6.0 @@ -269,8 +269,8 @@ importers: plugins/notification: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 + specifier: 2.0.0-alpha.11 + version: 2.0.0-alpha.11 devDependencies: tslib: specifier: ^2.4.1 @@ -279,8 +279,8 @@ importers: plugins/os: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 + specifier: 2.0.0-alpha.11 + version: 2.0.0-alpha.11 devDependencies: tslib: specifier: 2.6.0 @@ -289,8 +289,8 @@ importers: plugins/positioner: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 + specifier: 2.0.0-alpha.11 + version: 2.0.0-alpha.11 devDependencies: tslib: specifier: 2.6.0 @@ -299,8 +299,8 @@ importers: plugins/process: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 + specifier: 2.0.0-alpha.11 + version: 2.0.0-alpha.11 devDependencies: tslib: specifier: 2.6.0 @@ -309,8 +309,8 @@ importers: plugins/shell: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 + specifier: 2.0.0-alpha.11 + version: 2.0.0-alpha.11 devDependencies: tslib: specifier: ^2.4.1 @@ -319,14 +319,14 @@ importers: plugins/single-instance/examples/vanilla: devDependencies: '@tauri-apps/cli': - specifier: 2.0.0-alpha.16 - version: 2.0.0-alpha.16 + specifier: 2.0.0-alpha.17 + version: 2.0.0-alpha.17 plugins/sql: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 + specifier: 2.0.0-alpha.11 + version: 2.0.0-alpha.11 devDependencies: tslib: specifier: 2.6.0 @@ -335,8 +335,8 @@ importers: plugins/store: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 + specifier: 2.0.0-alpha.11 + version: 2.0.0-alpha.11 devDependencies: tslib: specifier: 2.6.0 @@ -345,8 +345,8 @@ importers: plugins/stronghold: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 + specifier: 2.0.0-alpha.11 + version: 2.0.0-alpha.11 devDependencies: tslib: specifier: 2.6.0 @@ -355,8 +355,8 @@ importers: plugins/updater: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 + specifier: 2.0.0-alpha.11 + version: 2.0.0-alpha.11 devDependencies: tslib: specifier: ^2.5.0 @@ -365,8 +365,8 @@ importers: plugins/upload: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 + specifier: 2.0.0-alpha.11 + version: 2.0.0-alpha.11 devDependencies: tslib: specifier: 2.6.0 @@ -375,8 +375,8 @@ importers: plugins/websocket: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 + specifier: 2.0.0-alpha.11 + version: 2.0.0-alpha.11 devDependencies: tslib: specifier: 2.6.0 @@ -395,8 +395,8 @@ importers: specifier: 1.26.0 version: 1.26.0(svelte@4.2.2)(vite@4.5.0) '@tauri-apps/cli': - specifier: 2.0.0-alpha.16 - version: 2.0.0-alpha.16 + specifier: 2.0.0-alpha.17 + version: 2.0.0-alpha.17 svelte: specifier: 4.2.2 version: 4.2.2 @@ -416,8 +416,8 @@ importers: plugins/window-state: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 + specifier: 2.0.0-alpha.11 + version: 2.0.0-alpha.11 devDependencies: tslib: specifier: 2.6.0 @@ -571,7 +571,7 @@ packages: peerDependencies: mocha: ^10.0.0 dependencies: - effection: 2.0.7 + effection: 2.0.7(mocha@10.2.0) mocha: 10.2.0 dev: true @@ -823,7 +823,7 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: ajv: 6.12.6 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) espree: 9.6.1 globals: 13.20.0 ignore: 5.2.4 @@ -850,7 +850,7 @@ packages: engines: {node: '>=10.10.0'} dependencies: '@humanwhocodes/object-schema': 2.0.0 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) minimatch: 3.1.2 transitivePeerDependencies: - supports-color @@ -891,7 +891,7 @@ packages: '@antfu/install-pkg': 0.1.1 '@antfu/utils': 0.7.5 '@iconify/types': 2.0.0 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) kolorist: 1.8.0 local-pkg: 0.4.3 transitivePeerDependencies: @@ -1025,7 +1025,7 @@ packages: rollup: 4.1.4 dev: true - /@rollup/pluginutils@5.0.5: + /@rollup/pluginutils@5.0.5(rollup@4.1.4): resolution: {integrity: sha512-6aEYR910NyP73oHiJglti74iRyOwgFU4x3meH/H8OJx6Ry0j6cOVZ5X/wTvub7G7Ao6qaHBEaNsV3GLJkSsF+Q==} engines: {node: '>=14.0.0'} peerDependencies: @@ -1037,6 +1037,7 @@ packages: '@types/estree': 1.0.1 estree-walker: 2.0.2 picomatch: 2.3.1 + rollup: 4.1.4 dev: true /@rollup/rollup-android-arm-eabi@4.1.4: @@ -1180,7 +1181,7 @@ packages: vite: ^4.0.0 dependencies: '@sveltejs/vite-plugin-svelte': 2.4.6(svelte@4.2.2)(vite@4.5.0) - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) svelte: 4.2.2 vite: 4.5.0 transitivePeerDependencies: @@ -1195,7 +1196,7 @@ packages: vite: ^4.0.0 dependencies: '@sveltejs/vite-plugin-svelte-inspector': 1.0.4(@sveltejs/vite-plugin-svelte@2.4.6)(svelte@4.2.2)(vite@4.5.0) - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) deepmerge: 4.3.1 kleur: 4.1.5 magic-string: 0.30.5 @@ -1207,18 +1208,13 @@ packages: - supports-color dev: true - /@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/api@2.0.0-alpha.9: - resolution: {integrity: sha512-Q5BiIQa2ToICdaJSYZdmtwbKSfdk+uQbQ7xMnbWI5C5C3frEVFlT92kVXgZFKIwrTLZBWHfiowkPR6rbFqAHIg==} + /@tauri-apps/api@2.0.0-alpha.11: + resolution: {integrity: sha512-aw7jic+MQAe/LH4fYhbd3bwx3YjXhDIwqKJIn5QO4yKmGdVURIhZSFcyeKkSe4P6Itdto0Pcz99vLfkgBwdQKw==} engines: {node: '>= 18', npm: '>= 6.6.0', yarn: '>= 1.19.1'} dev: false - /@tauri-apps/cli-darwin-arm64@2.0.0-alpha.16: - resolution: {integrity: sha512-T/yu8+m4XrI1Ja5aVnsv4v5aGqIvwz1egHarMgh4LXrlMioJ60BoxDPfenaUokO6NVee212woFSmH6p4S7V8PA==} + /@tauri-apps/cli-darwin-arm64@2.0.0-alpha.17: + resolution: {integrity: sha512-WDqekRiVwMu/hKsf/xBHcfi/YZ7X9o6Piy4Qolt+YYyfi4wh5ZYZnom+7kIZBlSCc32gtXGViBXEivhcKzFQ3w==} engines: {node: '>= 10'} cpu: [arm64] os: [darwin] @@ -1226,8 +1222,8 @@ packages: dev: true optional: true - /@tauri-apps/cli-darwin-x64@2.0.0-alpha.16: - resolution: {integrity: sha512-mhYB/UPeyn++GI0Tt8y90WmHU75Fh9yZ7cBtRCrF94kOOEldQGYqS26dwhsRrSgnNYB7vYvVPhHzQsKWziParQ==} + /@tauri-apps/cli-darwin-x64@2.0.0-alpha.17: + resolution: {integrity: sha512-WcQ+iSIaxr80gpa+ji+4e7dD0w/s3VCo29DU3wT/uQBKrCfkJUwmUAqEwyrR7INWcOurLF0IizR71In3NrYJiw==} engines: {node: '>= 10'} cpu: [x64] os: [darwin] @@ -1235,8 +1231,8 @@ packages: dev: true optional: true - /@tauri-apps/cli-linux-arm-gnueabihf@2.0.0-alpha.16: - resolution: {integrity: sha512-YP+4BSNN2ESgPnoIO37nw5tOi2k2rrU2eoeJHxQpOmRrQakjBrcZFP1HGjY3cOturexIKUALH69Ol9K6WzrJIQ==} + /@tauri-apps/cli-linux-arm-gnueabihf@2.0.0-alpha.17: + resolution: {integrity: sha512-xgVc3Pv0Wf7aWqi0eH1iEemi9uQJJfMCVqBjPrK65Bm1LsBmMw99QS5YH8XPCMfB01Jfdzf3Ty9ZCW8/vjqz3w==} engines: {node: '>= 10'} cpu: [arm] os: [linux] @@ -1244,8 +1240,8 @@ packages: dev: true optional: true - /@tauri-apps/cli-linux-arm64-gnu@2.0.0-alpha.16: - resolution: {integrity: sha512-mP/I6AdlRnrbZBUMKJWo4JsZStYD+7szh/1oo4zmDfWx0z6HUzgN6gxL+CR0pLex4kCJGUNeo1aZCGBJKzEdHg==} + /@tauri-apps/cli-linux-arm64-gnu@2.0.0-alpha.17: + resolution: {integrity: sha512-QEx92085i+I4lOdboJ0PK+DSrlHq613HTqiSO4YteD5uCXsq2R9uAcFXM08quQYpRl4b9GeG99vig5GDOZMOkw==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] @@ -1253,8 +1249,8 @@ packages: dev: true optional: true - /@tauri-apps/cli-linux-arm64-musl@2.0.0-alpha.16: - resolution: {integrity: sha512-i58pTClYkn9BBhMShNycRUJD+cfxHs+PV5PPHhBJdi3+zpL0zHNTlZAjTMpO/o4hmTYhw1rbk+kPzXEaiAnt0w==} + /@tauri-apps/cli-linux-arm64-musl@2.0.0-alpha.17: + resolution: {integrity: sha512-Iq0YHtg1yOvx3xxne6aHRS46SG6o6aQPACORGcJneGL6UjOQ7M34zKI9fX2tOWB5YEcVZBOvtNEZQOUeG2bw7g==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] @@ -1262,8 +1258,8 @@ packages: dev: true optional: true - /@tauri-apps/cli-linux-x64-gnu@2.0.0-alpha.16: - resolution: {integrity: sha512-GLb0+MvoC6/7l5HXhF3Ii1Uodg6K6l8tfSaQ7H8qplp9oVgMvNi8yd9myRT8SYApjsC1pViXTib+5n2pp3VS0A==} + /@tauri-apps/cli-linux-x64-gnu@2.0.0-alpha.17: + resolution: {integrity: sha512-CAdd2EhGsFWu3nr0o650dfTLOJhICRoqETKmAgSEpQNtpXuJwrqxA3XrIa1sUkgWZacf3dgQwyNNlvB8oYOHKg==} engines: {node: '>= 10'} cpu: [x64] os: [linux] @@ -1271,8 +1267,8 @@ packages: dev: true optional: true - /@tauri-apps/cli-linux-x64-musl@2.0.0-alpha.16: - resolution: {integrity: sha512-pZXuwVQpInzW8YjmhJsDPx3ovfVFbKJkUnXTgmVe8RvQSh6BxCSLyq8z4WG6zBRBdpjg8L5jVM8/MWf/QhdCVg==} + /@tauri-apps/cli-linux-x64-musl@2.0.0-alpha.17: + resolution: {integrity: sha512-xMhqAvcD0+b7creRhf7XnMTeoMAmmp1FvtNfosWCdWl7o9YHkqyNlkSp9rn96lhP2DG/Ew2CHxKOZaPql9gnlw==} engines: {node: '>= 10'} cpu: [x64] os: [linux] @@ -1280,8 +1276,8 @@ packages: dev: true optional: true - /@tauri-apps/cli-win32-arm64-msvc@2.0.0-alpha.16: - resolution: {integrity: sha512-YB1urpcOfSMRhKi+0Cj8I2T+dlU2Vqqc/ao+8O4wiHibGFyGIcuL/DJfC/7nHyFUngac7Shyz8/VRKgvd/jEvw==} + /@tauri-apps/cli-win32-arm64-msvc@2.0.0-alpha.17: + resolution: {integrity: sha512-j8Q6JkDGW1N8brMjg74/AkVwyg14VVfQUFoai9Ocbf8q9gGNE5IRr7KvbWjqDntUihbc7MURwcXjcsJ4duYe/A==} engines: {node: '>= 10'} cpu: [arm64] os: [win32] @@ -1289,8 +1285,8 @@ packages: dev: true optional: true - /@tauri-apps/cli-win32-ia32-msvc@2.0.0-alpha.16: - resolution: {integrity: sha512-IdODN3LwzwCaJOv1muiOhy0yD3IAIdu2UGacEukM9gnJ1VsK/JqU9ufH0SAFQkxKTWc6wpKykEAfuSNRlMIa5A==} + /@tauri-apps/cli-win32-ia32-msvc@2.0.0-alpha.17: + resolution: {integrity: sha512-YIdSHH2Y9Rcg8Z5WoRUTlEi1DZj/Okrz4q0b+z8xwJQFSGsxUhpc3U81iBW1yw/7AtXiLtzr8AiBrLAw4ZYGHA==} engines: {node: '>= 10'} cpu: [ia32] os: [win32] @@ -1298,8 +1294,8 @@ packages: dev: true optional: true - /@tauri-apps/cli-win32-x64-msvc@2.0.0-alpha.16: - resolution: {integrity: sha512-T2kg6o3Ca5cC2i5BdjsGCym0yZ64c9BGO5cmtCCrIardMTYB3hUHDvekOmKviBfqQbIsBHGZfnLDDbmjnwTLvA==} + /@tauri-apps/cli-win32-x64-msvc@2.0.0-alpha.17: + resolution: {integrity: sha512-+1stlGdRdiuyU+q1AlqieZhD2WpdLuP8EZxv2KbbjifLDt6fg1FUrcocmpIa8qsrXue7vg2sTrWNuy4aq/v4bw==} engines: {node: '>= 10'} cpu: [x64] os: [win32] @@ -1307,21 +1303,21 @@ packages: dev: true optional: true - /@tauri-apps/cli@2.0.0-alpha.16: - resolution: {integrity: sha512-zh2psjmHLkoHZkzUN1aPqcOE4KTLRTRJdd+K8CsD/y5nbQdek8qjc8ToohV2FNHDkBq0O/yETsPmPPLgQfhVhg==} + /@tauri-apps/cli@2.0.0-alpha.17: + resolution: {integrity: sha512-fXz1KQzolqHY40bmNa/mzrdid4zlIaI/catXN8iqSO/1aNXNpLhg+6PWrwW5foiD7kJ6lgLlCtICW/1jRE5BZg==} engines: {node: '>= 10'} hasBin: true optionalDependencies: - '@tauri-apps/cli-darwin-arm64': 2.0.0-alpha.16 - '@tauri-apps/cli-darwin-x64': 2.0.0-alpha.16 - '@tauri-apps/cli-linux-arm-gnueabihf': 2.0.0-alpha.16 - '@tauri-apps/cli-linux-arm64-gnu': 2.0.0-alpha.16 - '@tauri-apps/cli-linux-arm64-musl': 2.0.0-alpha.16 - '@tauri-apps/cli-linux-x64-gnu': 2.0.0-alpha.16 - '@tauri-apps/cli-linux-x64-musl': 2.0.0-alpha.16 - '@tauri-apps/cli-win32-arm64-msvc': 2.0.0-alpha.16 - '@tauri-apps/cli-win32-ia32-msvc': 2.0.0-alpha.16 - '@tauri-apps/cli-win32-x64-msvc': 2.0.0-alpha.16 + '@tauri-apps/cli-darwin-arm64': 2.0.0-alpha.17 + '@tauri-apps/cli-darwin-x64': 2.0.0-alpha.17 + '@tauri-apps/cli-linux-arm-gnueabihf': 2.0.0-alpha.17 + '@tauri-apps/cli-linux-arm64-gnu': 2.0.0-alpha.17 + '@tauri-apps/cli-linux-arm64-musl': 2.0.0-alpha.17 + '@tauri-apps/cli-linux-x64-gnu': 2.0.0-alpha.17 + '@tauri-apps/cli-linux-x64-musl': 2.0.0-alpha.17 + '@tauri-apps/cli-win32-arm64-msvc': 2.0.0-alpha.17 + '@tauri-apps/cli-win32-ia32-msvc': 2.0.0-alpha.17 + '@tauri-apps/cli-win32-x64-msvc': 2.0.0-alpha.17 dev: true /@tauri-apps/toml@2.2.4: @@ -1382,7 +1378,7 @@ packages: '@typescript-eslint/type-utils': 6.8.0(eslint@8.51.0)(typescript@5.2.2) '@typescript-eslint/utils': 6.8.0(eslint@8.51.0)(typescript@5.2.2) '@typescript-eslint/visitor-keys': 6.8.0 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) eslint: 8.51.0 graphemer: 1.4.0 ignore: 5.2.4 @@ -1408,7 +1404,7 @@ packages: '@typescript-eslint/types': 6.8.0 '@typescript-eslint/typescript-estree': 6.8.0(typescript@5.2.2) '@typescript-eslint/visitor-keys': 6.8.0 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) eslint: 8.51.0 typescript: 5.2.2 transitivePeerDependencies: @@ -1435,7 +1431,7 @@ packages: dependencies: '@typescript-eslint/typescript-estree': 6.8.0(typescript@5.2.2) '@typescript-eslint/utils': 6.8.0(eslint@8.51.0)(typescript@5.2.2) - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) eslint: 8.51.0 ts-api-utils: 1.0.1(typescript@5.2.2) typescript: 5.2.2 @@ -1459,7 +1455,7 @@ packages: dependencies: '@typescript-eslint/types': 6.8.0 '@typescript-eslint/visitor-keys': 6.8.0 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) globby: 11.1.0 is-glob: 4.0.3 semver: 7.5.4 @@ -1496,7 +1492,7 @@ packages: eslint-visitor-keys: 3.4.1 dev: true - /@unocss/astro@0.56.5(vite@4.5.0): + /@unocss/astro@0.56.5(rollup@4.1.4)(vite@4.5.0): resolution: {integrity: sha512-nkxyGV9mA7DZ5LEr4Gap/SggM60MFNUfn56ngpxCqjQHJOMRJrAcR99hCVn+78vZ9xuZl9HxdIwgZLzn41thMw==} peerDependencies: vite: ^2.9.0 || ^3.0.0-0 || ^4.0.0 @@ -1506,19 +1502,19 @@ packages: dependencies: '@unocss/core': 0.56.5 '@unocss/reset': 0.56.5 - '@unocss/vite': 0.56.5(vite@4.5.0) + '@unocss/vite': 0.56.5(rollup@4.1.4)(vite@4.5.0) vite: 4.5.0 transitivePeerDependencies: - rollup dev: true - /@unocss/cli@0.56.5: + /@unocss/cli@0.56.5(rollup@4.1.4): resolution: {integrity: sha512-VYaqu7Dr1n9ebFFdQM+9Jyg/o9BVKRShlV8bQsBS58gkXiWsA/uAl1Uy2vzpLSrT0F6uGyDmYUF6p4DaUnUO+w==} engines: {node: '>=14'} hasBin: true dependencies: '@ampproject/remapping': 2.2.1 - '@rollup/pluginutils': 5.0.5 + '@rollup/pluginutils': 5.0.5(rollup@4.1.4) '@unocss/config': 0.56.5 '@unocss/core': 0.56.5 '@unocss/preset-uno': 0.56.5 @@ -1687,13 +1683,13 @@ packages: '@unocss/core': 0.56.5 dev: true - /@unocss/vite@0.56.5(vite@4.5.0): + /@unocss/vite@0.56.5(rollup@4.1.4)(vite@4.5.0): resolution: {integrity: sha512-X4nvIukXTH//d+Oc97nJogK04sVGw4fc5LhVV1DjHQVmAOAmhTJCG6SxWGoSeqqUMx5X3gI9fVILK+5O8yl5EA==} peerDependencies: vite: ^2.9.0 || ^3.0.0-0 || ^4.0.0 dependencies: '@ampproject/remapping': 2.2.1 - '@rollup/pluginutils': 5.0.5 + '@rollup/pluginutils': 5.0.5(rollup@4.1.4) '@unocss/config': 0.56.5 '@unocss/core': 0.56.5 '@unocss/inspector': 0.56.5 @@ -2158,18 +2154,6 @@ packages: ms: 2.1.3 dev: true - /debug@4.3.4: - resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} - engines: {node: '>=6.0'} - peerDependencies: - supports-color: '*' - peerDependenciesMeta: - supports-color: - optional: true - dependencies: - ms: 2.1.2 - dev: true - /debug@4.3.4(supports-color@8.1.1): resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} engines: {node: '>=6.0'} @@ -2269,18 +2253,6 @@ packages: resolution: {integrity: sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg==} dev: true - /effection@2.0.7: - resolution: {integrity: sha512-I9ndFvtByvHbvOHwMp1NM7vlLDT0RBOu1YlIfBece46VASSot0oPnAfoGdc1YKoQShQLjigvHZ6OqZYUAxUcXg==} - dependencies: - '@effection/channel': 2.0.5 - '@effection/core': 2.2.2 - '@effection/events': 2.0.5 - '@effection/fetch': 2.0.6(mocha@10.2.0) - '@effection/main': 2.1.2 - '@effection/stream': 2.0.5 - '@effection/subscription': 2.0.5 - dev: true - /effection@2.0.7(mocha@10.2.0): resolution: {integrity: sha512-I9ndFvtByvHbvOHwMp1NM7vlLDT0RBOu1YlIfBece46VASSot0oPnAfoGdc1YKoQShQLjigvHZ6OqZYUAxUcXg==} dependencies: @@ -2615,7 +2587,7 @@ packages: ajv: 6.12.6 chalk: 4.1.2 cross-spawn: 7.0.3 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) doctrine: 3.0.0 escape-string-regexp: 4.0.0 eslint-scope: 7.2.2 @@ -3522,7 +3494,7 @@ packages: /micromark@2.11.4: resolution: {integrity: sha512-+WoovN/ppKolQOFIAajxi7Lu9kInbPxFuTBVEavFcL8eAfVstoc5MocPmqBeAdBOJV00uaVjegzH4+MA0DN/uA==} dependencies: - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) parse-entities: 2.0.0 transitivePeerDependencies: - supports-color @@ -4639,7 +4611,7 @@ packages: '@types/unist': 2.0.7 dev: true - /unocss@0.56.5(postcss@8.4.31)(vite@4.5.0): + /unocss@0.56.5(postcss@8.4.31)(rollup@4.1.4)(vite@4.5.0): resolution: {integrity: sha512-tO+9St4CntSjHpLXZqBo0/etS06MtvFF1NEny/qFJCL9sCopWwmDKuzW6/LIb4wfqZLdMpVFoEACMNv8nP849A==} engines: {node: '>=14'} peerDependencies: @@ -4651,8 +4623,8 @@ packages: vite: optional: true dependencies: - '@unocss/astro': 0.56.5(vite@4.5.0) - '@unocss/cli': 0.56.5 + '@unocss/astro': 0.56.5(rollup@4.1.4)(vite@4.5.0) + '@unocss/cli': 0.56.5(rollup@4.1.4) '@unocss/core': 0.56.5 '@unocss/extractor-arbitrary-variants': 0.56.5 '@unocss/postcss': 0.56.5(postcss@8.4.31) @@ -4670,7 +4642,7 @@ packages: '@unocss/transformer-compile-class': 0.56.5 '@unocss/transformer-directives': 0.56.5 '@unocss/transformer-variant-group': 0.56.5 - '@unocss/vite': 0.56.5(vite@4.5.0) + '@unocss/vite': 0.56.5(rollup@4.1.4)(vite@4.5.0) vite: 4.5.0 transitivePeerDependencies: - postcss diff --git a/shared/template/Cargo.toml b/shared/template/Cargo.toml index 22fa8075b..8f11e5ad6 100644 --- a/shared/template/Cargo.toml +++ b/shared/template/Cargo.toml @@ -7,7 +7,8 @@ license = { workspace = true } links = "tauri-plugin-{{name}}" [package.metadata.docs.rs] -features = [ "dox" ] +rustc-args = [ "--cfg", "docsrs" ] +rustdoc-args = [ "--cfg", "docsrs" ] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -20,6 +21,3 @@ serde_json = { workspace = true } tauri = { workspace = true } log = { workspace = true } thiserror = { workspace = true } - -[features] -dox = [ "tauri/dox" ] diff --git a/shared/template/android/src/main/java/ExamplePlugin.kt b/shared/template/android/src/main/java/ExamplePlugin.kt index 9fed811cf..2f1729745 100644 --- a/shared/template/android/src/main/java/ExamplePlugin.kt +++ b/shared/template/android/src/main/java/ExamplePlugin.kt @@ -6,18 +6,27 @@ package {{android_package_id}} import android.app.Activity import app.tauri.annotation.Command +import app.tauri.annotation.InvokeArg import app.tauri.annotation.TauriPlugin import app.tauri.plugin.JSObject import app.tauri.plugin.Plugin import app.tauri.plugin.Invoke +@InvokeArg +class PingArgs { + var value: String? = null +} + @TauriPlugin class ExamplePlugin(private val activity: Activity): Plugin(activity) { + private val implementation = Example() + @Command fun ping(invoke: Invoke) { - val value = invoke.getString("value") ?: "" + val args = invoke.parseArgs(PingArgs::class.java) + val ret = JSObject() - ret.put("value", value) + ret.put("value", implementation.pong(args.value ?: "default value :(")) invoke.resolve(ret) } } diff --git a/shared/template/build.rs b/shared/template/build.rs index ea12ef852..da7cd3cc4 100644 --- a/shared/template/build.rs +++ b/shared/template/build.rs @@ -10,7 +10,7 @@ fn main() { { println!("{error:#}"); // when building documentation for Android the plugin build result is irrelevant to the crate itself - if !(cfg!(feature = "dox") && std::env::var("TARGET").unwrap().contains("android")) { + if !(cfg!(docsrs) && std::env::var("TARGET").unwrap().contains("android")) { std::process::exit(1); } } diff --git a/shared/template/ios/Sources/ExamplePlugin.swift b/shared/template/ios/Sources/ExamplePlugin.swift index 7a36b76b5..36c3a8f74 100644 --- a/shared/template/ios/Sources/ExamplePlugin.swift +++ b/shared/template/ios/Sources/ExamplePlugin.swift @@ -2,16 +2,20 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT +import SwiftRs +import Tauri import UIKit import WebKit -import Tauri -import SwiftRs + +class PingArgs: Decodable { + let value: String? +} class ExamplePlugin: Plugin { - @objc public func ping(_ invoke: Invoke) throws { - let value = invoke.getString("value") - invoke.resolve(["value": value as Any]) - } + @objc public func ping(_ invoke: Invoke) throws { + let args = try invoke.parseArgs(PingArgs.self) + invoke.resolve(["value": args.value ?? ""]) + } } @_cdecl("init_plugin_{{ plugin_name_snake_case }}") diff --git a/shared/template/package.json b/shared/template/package.json index 76ba8ee27..388efff65 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.9" + "@tauri-apps/api": "2.0.0-alpha.11" } }