diff --git a/.cargo/audit.toml b/.cargo/audit.toml index 23c3852b..268d3716 100644 --- a/.cargo/audit.toml +++ b/.cargo/audit.toml @@ -7,5 +7,5 @@ ignore = [ # wry needs kuchiki on Android "RUSTSEC-2023-0019", # atty is only used when the `colored` feature is enabled on tauri-plugin-log - "RUSTSEC-2021-0145" -] \ No newline at end of file + "RUSTSEC-2021-0145", +] diff --git a/.changes/add-allow-downgrades.md b/.changes/add-allow-downgrades.md new file mode 100644 index 00000000..dd888671 --- /dev/null +++ b/.changes/add-allow-downgrades.md @@ -0,0 +1,8 @@ +--- +"updater": minor +"updater-js": minor +--- + +Add allowDowngrades parameter to check command + +Added a new optional `allowDowngrades` parameter to the JavaScript check command that allows the updater to consider versions that are lower than the current version as valid updates. When enabled, the version comparator will accept any version that is different from the current version, effectively allowing downgrades. diff --git a/.changes/alpha.16.md b/.changes/alpha.16.md deleted file mode 100644 index c2126e37..00000000 --- a/.changes/alpha.16.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"log-plugin": patch ---- - -Update to tauri@2.0.0-alpha.16. diff --git a/.changes/api-alpha.9.md b/.changes/api-alpha.9.md deleted file mode 100644 index b042bcf5..00000000 --- a/.changes/api-alpha.9.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -"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.16. diff --git a/.changes/autostart-feature.md b/.changes/autostart-feature.md new file mode 100644 index 00000000..1d5d956e --- /dev/null +++ b/.changes/autostart-feature.md @@ -0,0 +1,6 @@ +--- +autostart: minor +autostart-js: minor +--- + +Added a new builder method app_name() to allow customizing the application name in the autostart entry. \ No newline at end of file diff --git a/.changes/config.json b/.changes/config.json index 399448f5..93ed46e3 100644 --- a/.changes/config.json +++ b/.changes/config.json @@ -3,24 +3,50 @@ "pkgManagers": { "javascript": { "version": true, - "getPublishedVersion": "node ../../.scripts/covector/package-latest-version.cjs npm ${ pkgFile.pkg.name } ${ pkgFile.pkg.version }", - "publish": ["pnpm build", "pnpm publish --access public --no-git-checks"] + "getPublishedVersion": { + "use": "fetch:check", + "options": { + "url": "https://registry.npmjs.com/${ pkg.pkgFile.pkg.name }/${ pkg.pkgFile.version }" + } + }, + "publish": [ + { + "command": "pnpm build", + "dryRunCommand": "pnpm build" + }, + { + "command": "echo '
\n

PNPM Publish

\n\n```'", + "dryRunCommand": true, + "pipe": true + }, + { + "command": "npm publish --provenance --access public", + "dryRunCommand": "npm publish --provenance --access public --dry-run", + "pipe": true + }, + { + "command": "echo '```\n\n
\n'", + "dryRunCommand": true, + "pipe": true + } + ] }, "rust": { "version": true, - "getPublishedVersion": "node ../../.scripts/covector/package-latest-version.cjs cargo ${ pkgFile.pkg.package.name } ${ pkgFile.pkg.package.version }", + "getPublishedVersion": { + "use": "fetch:check", + "options": { + "url": "https://crates.io/api/v1/crates/${ pkg.pkgFile.pkg.package.name }/${ pkg.pkgFile.version }" + } + }, "publish": [ - { - "command": "cargo package --no-verify", - "dryRunCommand": true - }, { "command": "echo '
\n

Cargo Publish

\n\n```'", "dryRunCommand": true, "pipe": true }, { - "command": "cargo publish", + "command": "cargo publish --no-verify", "dryRunCommand": "cargo publish --dry-run", "pipe": true }, @@ -39,18 +65,24 @@ "publish": false, "dependencies": [ "barcode-scanner", - "log-plugin", + "biometric", + "log", "cli", "clipboard-manager", "dialog", "fs", "global-shortcut", + "opener", "http", + "nfc", "notification", "os", "process", "shell", - "updater" + "store", + "updater", + "geolocation", + "haptics" ] }, "api-example-js": { @@ -59,22 +91,25 @@ "publish": false, "dependencies": [ "barcode-scanner-js", + "biometric-js", "log-js", "cli-js", "clipboard-manager-js", "dialog-js", "fs-js", "global-shortcut-js", + "opener-js", "http-js", + "nfc-js", "notification-js", "os-js", "process-js", "shell-js", + "store-js", "updater-js" ], "postversion": "pnpm install --no-frozen-lockfile" }, - "deep-link-example-js": { "path": "./plugins/deep-link/examples/app", "manager": "javascript", @@ -82,16 +117,6 @@ "dependencies": ["deep-link-js"], "postversion": "pnpm install --no-frozen-lockfile" }, - - "authenticator": { - "path": "./plugins/authenticator", - "manager": "rust" - }, - "authenticator-js": { - "path": "./plugins/authenticator", - "manager": "javascript" - }, - "autostart": { "path": "./plugins/autostart", "manager": "rust" @@ -100,7 +125,6 @@ "path": "./plugins/autostart", "manager": "javascript" }, - "barcode-scanner": { "path": "./plugins/barcode-scanner", "manager": "rust" @@ -109,7 +133,14 @@ "path": "./plugins/barcode-scanner", "manager": "javascript" }, - + "biometric": { + "path": "./plugins/biometric", + "manager": "rust" + }, + "biometric-js": { + "path": "./plugins/biometric", + "manager": "javascript" + }, "cli": { "path": "./plugins/cli", "manager": "rust" @@ -118,7 +149,6 @@ "path": "./plugins/cli", "manager": "javascript" }, - "clipboard-manager": { "path": "./plugins/clipboard-manager", "manager": "rust" @@ -127,7 +157,6 @@ "path": "./plugins/clipboard-manager", "manager": "javascript" }, - "deep-link": { "path": "./plugins/deep-link", "manager": "rust" @@ -136,7 +165,6 @@ "path": "./plugins/deep-link", "manager": "javascript" }, - "fs": { "path": "./plugins/fs", "manager": "rust" @@ -145,7 +173,6 @@ "path": "./plugins/fs", "manager": "javascript" }, - "dialog": { "path": "./plugins/dialog", "manager": "rust", @@ -153,9 +180,17 @@ }, "dialog-js": { "path": "./plugins/dialog", + "manager": "javascript", + "dependencies": ["fs-js"] + }, + "geolocation": { + "path": "./plugins/geolocation", + "manager": "rust" + }, + "geolocation-js": { + "path": "./plugins/geolocation", "manager": "javascript" }, - "global-shortcut": { "path": "./plugins/global-shortcut", "manager": "rust" @@ -164,7 +199,22 @@ "path": "./plugins/global-shortcut", "manager": "javascript" }, - + "opener": { + "path": "./plugins/opener", + "manager": "rust" + }, + "opener-js": { + "path": "./plugins/opener", + "manager": "javascript" + }, + "haptics": { + "path": "./plugins/haptics", + "manager": "rust" + }, + "haptics-js": { + "path": "./plugins/haptics", + "manager": "javascript" + }, "http": { "path": "./plugins/http", "manager": "rust", @@ -172,15 +222,14 @@ }, "http-js": { "path": "./plugins/http", - "manager": "javascript" + "manager": "javascript", + "dependencies": ["fs-js"] }, - "localhost": { "path": "./plugins/localhost", "manager": "rust" }, - - "log-plugin": { + "log": { "path": "./plugins/log", "manager": "rust" }, @@ -188,7 +237,14 @@ "path": "./plugins/log", "manager": "javascript" }, - + "nfc": { + "path": "./plugins/nfc", + "manager": "rust" + }, + "nfc-js": { + "path": "./plugins/nfc", + "manager": "javascript" + }, "notification": { "path": "./plugins/notification", "manager": "rust" @@ -197,7 +253,6 @@ "path": "./plugins/notification", "manager": "javascript" }, - "os": { "path": "./plugins/os", "manager": "rust" @@ -206,13 +261,11 @@ "path": "./plugins/os", "manager": "javascript" }, - "persisted-scope": { "path": "./plugins/persisted-scope", "manager": "rust", "dependencies": ["fs"] }, - "positioner": { "path": "./plugins/positioner", "manager": "rust" @@ -221,7 +274,6 @@ "path": "./plugins/positioner", "manager": "javascript" }, - "process": { "path": "./plugins/process", "manager": "rust" @@ -230,7 +282,6 @@ "path": "./plugins/process", "manager": "javascript" }, - "shell": { "path": "./plugins/shell", "manager": "rust" @@ -239,42 +290,19 @@ "path": "./plugins/shell", "manager": "javascript" }, - "single-instance": { "path": "./plugins/single-instance", - "manager": "rust" + "manager": "rust", + "dependencies": ["deep-link"] }, - "sql": { "path": "./plugins/sql", - "manager": "rust", - "publish": [ - { - "command": "cargo package --no-verify", - "dryRunCommand": true - }, - { - "command": "echo '
\n

Cargo Publish

\n\n```'", - "dryRunCommand": true, - "pipe": true - }, - { - "command": "cargo publish --features sqlite", - "dryRunCommand": "cargo publish --features sqlite --dry-run", - "pipe": true - }, - { - "command": "echo '```\n\n
\n'", - "dryRunCommand": true, - "pipe": true - } - ] + "manager": "rust" }, "sql-js": { "path": "./plugins/sql", "manager": "javascript" }, - "store": { "path": "./plugins/store", "manager": "rust" @@ -283,7 +311,6 @@ "path": "./plugins/store", "manager": "javascript" }, - "stronghold": { "path": "./plugins/stronghold", "manager": "rust" @@ -292,7 +319,6 @@ "path": "./plugins/stronghold", "manager": "javascript" }, - "updater": { "path": "./plugins/updater", "manager": "rust" @@ -301,7 +327,6 @@ "path": "./plugins/updater", "manager": "javascript" }, - "upload": { "path": "./plugins/upload", "manager": "rust" @@ -310,7 +335,6 @@ "path": "./plugins/upload", "manager": "javascript" }, - "websocket": { "path": "./plugins/websocket", "manager": "rust" @@ -319,7 +343,6 @@ "path": "./plugins/websocket", "manager": "javascript" }, - "window-state": { "path": "./plugins/window-state", "manager": "rust" diff --git a/.changes/deep-link-initial-release.md b/.changes/deep-link-initial-release.md deleted file mode 100644 index 6dd20534..00000000 --- a/.changes/deep-link-initial-release.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"deep-link": major -"deep-link-js": major ---- - -Initial release. diff --git a/.changes/dialog-async-message-dialog.md b/.changes/dialog-async-message-dialog.md deleted file mode 100644 index adfe008b..00000000 --- a/.changes/dialog-async-message-dialog.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"dialog": "patch" ---- - -On non-Linux system, use `AsyncMessageDialog` instead of `MessageDialog`. [(tauri#7182)](https://github.com/tauri-apps/tauri/issues/7182) diff --git a/.changes/fix-docs-build.md b/.changes/fix-docs-build.md deleted file mode 100644 index 11df007a..00000000 --- a/.changes/fix-docs-build.md +++ /dev/null @@ -1,28 +0,0 @@ ---- -"authenticator": patch -"autostart": patch -"cli": patch -"clipboard-manager": 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 ---- - -Fixes docs.rs build by enabling the `tauri/dox` feature flag. diff --git a/.changes/fix-invoke-usage.md b/.changes/fix-invoke-usage.md deleted file mode 100644 index 8782bc15..00000000 --- a/.changes/fix-invoke-usage.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"shell": patch -"dialog": patch ---- - -Fix invoke usage. diff --git a/.changes/fix-permission-notification.md b/.changes/fix-permission-notification.md deleted file mode 100644 index a3377880..00000000 --- a/.changes/fix-permission-notification.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"notification": patch ---- - -Fix permission prompt. diff --git a/.changes/fix-updater-macos.md b/.changes/fix-updater-macos.md deleted file mode 100644 index c4f4d831..00000000 --- a/.changes/fix-updater-macos.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"updater": patch ---- - -Fixes update on macOS. diff --git a/.changes/fix-window-state-api.md b/.changes/fix-window-state-api.md deleted file mode 100644 index 9ed99806..00000000 --- a/.changes/fix-window-state-api.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"window-state-js": patch ---- - -Fix usage of no longer available `__TAURI_METADATA__` API. diff --git a/.changes/fs-wiret-binary-file.md b/.changes/fs-wiret-binary-file.md deleted file mode 100644 index 82dd056f..00000000 --- a/.changes/fs-wiret-binary-file.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"fs-js": patch ---- - -Fix `writeBinaryFile` crashing with `command 'write_binary_file' not found` diff --git a/.changes/global-shortcut-app-handle.md b/.changes/global-shortcut-app-handle.md deleted file mode 100644 index 37dd286f..00000000 --- a/.changes/global-shortcut-app-handle.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"global-shortcut": "patch" ---- - -**Breaking Change**: Changed `Builder::with_handler` closure to take `&AppHandle` as the first argument and the shortcut as the second argument. diff --git a/.changes/http-multipart-refactor.md b/.changes/http-multipart-refactor.md deleted file mode 100644 index 562943d5..00000000 --- a/.changes/http-multipart-refactor.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"http-js": minor ---- - -Multipart requests are now handled in JavaScript by the `Request` JavaScript class so you just need to use a `FormData` body and not set the content-type header to `multipart/form-data`. `application/x-www-form-urlencoded` requests must be done manually. diff --git a/.changes/http-plugin-refactor.md b/.changes/http-plugin-refactor.md deleted file mode 100644 index ff089543..00000000 --- a/.changes/http-plugin-refactor.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"http": minor -"http-js": minor ---- - -The http plugin has been rewritten from scratch and now only exposes a `fetch` function in Javascript and Re-exports `reqwest` crate in Rust. The new `fetch` method tries to be as close and compliant to the `fetch` Web API as possible. diff --git a/.changes/http-remove-cmd-property.md b/.changes/http-remove-cmd-property.md deleted file mode 100644 index bca5472a..00000000 --- a/.changes/http-remove-cmd-property.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"http": patch ---- - -Remove `cmd` property which breaks invoke call. diff --git a/.changes/http-response.md b/.changes/http-response.md deleted file mode 100644 index 4be8f924..00000000 --- a/.changes/http-response.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"http": patch ---- - -Improve response performance by using the new IPC streaming data. diff --git a/.changes/msrv-1.70.md b/.changes/msrv-1.70.md deleted file mode 100644 index 43aa61ba..00000000 --- a/.changes/msrv-1.70.md +++ /dev/null @@ -1,30 +0,0 @@ ---- -"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 MSRV to 1.70. diff --git a/.changes/notification-init-script.md b/.changes/notification-init-script.md deleted file mode 100644 index fce58ba4..00000000 --- a/.changes/notification-init-script.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"notification": patch ---- - -Use `window.__TAURI_INVOKE__` instead of `window.__TAURI__` in init.js, fixes usage in apps without `withGlobalTauri` enabled. diff --git a/.changes/notification-revert-sound.md b/.changes/notification-revert-sound.md deleted file mode 100644 index b21cb9a6..00000000 --- a/.changes/notification-revert-sound.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"notification": patch ---- - -Revert [7d71ad4e5](https://github.com/tauri-apps/plugins-workspace/commit/7d71ad4e587bcf47ea34645f5b226945e487b765) which added a default sound for notifications on Windows. This introduced inconsistency with other platforms that has silent notifications by default. In the upcoming releases, we will add support for modifying the notification sound across all platforms. diff --git a/.changes/notification-sound.md b/.changes/notification-sound.md deleted file mode 100644 index 35f75536..00000000 --- a/.changes/notification-sound.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"notification": patch ---- - -Play a default sound when showing a notification on Windows. diff --git a/.changes/os-OsType.md b/.changes/os-OsType.md deleted file mode 100644 index 7fab4948..00000000 --- a/.changes/os-OsType.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"os-js": "patch" ---- - -Fix `macss -> macos` typo in `OsType` type. diff --git a/.changes/os-plugin-refactor.md b/.changes/os-plugin-refactor.md deleted file mode 100644 index ff0f7384..00000000 --- a/.changes/os-plugin-refactor.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -"os": minor -"os-js": minor ---- - -The os plugin is recieving a few changes to improve consistency and add new features: - -- Renamed `Kind` enum to `OsType` and `kind()` function to `os_type()`. -- Added `family()`,`exe_extension()`, and `hostname()` functions and their equivalents for JS. -- Removed `tempdir()` function and its equivalent on JS, use `std::env::temp_dir` instead of `temp_dir` from `tauri::path::PathResolver::temp_dir` and `path.tempDir` on JS. -- Modified `platform()` implementation to return `windows` instead of `win32` and `macos` instead of `darwin` to align with Rust's `std::env::consts::OS` -- `EOL` const in JS has been modified into a function `eol()` fix import issues in frameworks like `next.js` diff --git a/.changes/persisted-scope-asset.md b/.changes/persisted-scope-asset.md deleted file mode 100644 index 5b4b933a..00000000 --- a/.changes/persisted-scope-asset.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"persisted-scope": patch ---- - -Split up fs and asset scopes. **This will reset the asset protocol scope once!** diff --git a/.changes/persisted-scope-glob.md b/.changes/persisted-scope-glob.md deleted file mode 100644 index 24875a8e..00000000 --- a/.changes/persisted-scope-glob.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"persisted-scope": patch ---- - -Fix usage of directory patterns by removing glob asterisks at the end before allowing/forbidding them. This was causing them to be escaped, and so undesirable paths were allowed/forbidden while polluting the `.persisted-scope` file. diff --git a/.changes/positioner-tray-flag.md b/.changes/positioner-tray-flag.md deleted file mode 100644 index 4cf24118..00000000 --- a/.changes/positioner-tray-flag.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"positioner": patch ---- - -Change `system-tray` feature flag to `tray-icon`. diff --git a/.changes/pre.json b/.changes/pre.json deleted file mode 100644 index 5dc8af09..00000000 --- a/.changes/pre.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "tag": "alpha", - "changes": [ - ".changes/deep-link-initial-release.md", - ".changes/dialog-async-message-dialog.md", - ".changes/fix-docs-build.md", - ".changes/fs-wiret-binary-file.md", - ".changes/http-multipart-refactor.md", - ".changes/http-plugin-refactor.md", - ".changes/http-remove-cmd-property.md", - ".changes/http-response.md", - ".changes/notification-init-script.md", - ".changes/notification-revert-sound.md", - ".changes/notification-sound.md", - ".changes/os-OsType.md", - ".changes/os-plugin-refactor.md", - ".changes/persisted-scope-asset.md", - ".changes/persisted-scope-glob.md", - ".changes/positioner-tray-flag.md", - ".changes/scanner-initial-release.md", - ".changes/shell-command-apis.md", - ".changes/shell-detached.md", - ".changes/stronghold-arg-name.md", - ".changes/stronghold-constructor.md", - ".changes/tauri-alpha.11.md", - ".changes/tauri-alpha.12.md", - ".changes/updater-nsis-admin.md", - ".changes/updater-nsis.md", - ".changes/updater-plugin-refactor.md", - ".changes/v2-alpha.md", - ".changes/window-state-decorated.md", - ".changes/window-state-promise.md" - ] -} diff --git a/.changes/readme.md b/.changes/readme.md index 002f4643..6d9396ba 100644 --- a/.changes/readme.md +++ b/.changes/readme.md @@ -6,12 +6,14 @@ As you create PRs and make changes that require a version bump, please add a new When you select the version bump required, you do _not_ need to consider dependencies. Only note the package with the actual change, and any packages that depend on that package will be bumped automatically in the process. +**Note, that in this repository, even if only the Rust code or only the JavaScript code of a plugin changed, both packages need to be bumped with the same increment!** + Use the following format: ```md --- "package-a": patch -"package-b": minor +"package-b": minor:feat --- Change summary goes here diff --git a/.changes/scanner-initial-release.md b/.changes/scanner-initial-release.md deleted file mode 100644 index 5ea48e32..00000000 --- a/.changes/scanner-initial-release.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"barcode-scanner": major -"barcode-scanner-js": major ---- - -Initial release. diff --git a/.changes/shell-command-apis.md b/.changes/shell-command-apis.md deleted file mode 100644 index 86ee5a40..00000000 --- a/.changes/shell-command-apis.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"shell": "patch" ---- - -Added `Command::arg`, `Command::env` and changed `Command::new` input type. diff --git a/.changes/shell-detached.md b/.changes/shell-detached.md deleted file mode 100644 index 4d65f865..00000000 --- a/.changes/shell-detached.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"shell": patch ---- - -Ensure the launched process is detached so it can out-live your tauri app and does not shutdown with it. diff --git a/.changes/stronghold-arg-name.md b/.changes/stronghold-arg-name.md deleted file mode 100644 index 61efc0ed..00000000 --- a/.changes/stronghold-arg-name.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"stronghold-js": patch ---- - -Change the argument name of the `Stronghold.remove` from `location` to `recordPath` to match the Stronghold command argument diff --git a/.changes/stronghold-constructor.md b/.changes/stronghold-constructor.md deleted file mode 100644 index 99966095..00000000 --- a/.changes/stronghold-constructor.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"stronghold-js": minor ---- - -Added `Stronghold.load` and removed its constructor. diff --git a/.changes/tauri-alpha-15.md b/.changes/tauri-alpha-15.md deleted file mode 100644 index 4674b691..00000000 --- a/.changes/tauri-alpha-15.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"window-state": patch -"persisted-scope": patch ---- - -Update to tauri@alpha.15. diff --git a/.changes/tauri-alpha.11.md b/.changes/tauri-alpha.11.md deleted file mode 100644 index 4346b574..00000000 --- a/.changes/tauri-alpha.11.md +++ /dev/null @@ -1,49 +0,0 @@ ---- -"authenticator": patch -"authenticator-js": patch -"autostart": patch -"autostart-js": patch -"cli": patch -"cli-js": patch -"clipboard-manager": patch -"clipboard-manager-js": patch -"dialog": patch -"dialog-js": patch -"fs": patch -"fs-js": patch -"global-shortcut": patch -"global-shortcut-js": patch -"http": patch -"http-js": patch -"localhost": patch -"log-plugin": patch -"log-js": patch -"notification": patch -"notification-js": patch -"os": patch -"os-js": patch -"persisted-scope": patch -"positioner": patch -"positioner-js": patch -"process": patch -"process-js": patch -"shell": patch -"shell-js": patch -"single-instance": patch -"sql": patch -"sql-js": patch -"store": patch -"store-js": patch -"stronghold": patch -"stronghold-js": patch -"updater": patch -"updater-js": patch -"upload": patch -"upload-js": patch -"websocket": patch -"websocket-js": patch -"window-state": patch -"window-state-js": patch ---- - -Update to alpha.11. diff --git a/.changes/tauri-alpha.12.md b/.changes/tauri-alpha.12.md deleted file mode 100644 index 97e9f4cc..00000000 --- a/.changes/tauri-alpha.12.md +++ /dev/null @@ -1,28 +0,0 @@ ---- -"authenticator": patch -"autostart": patch -"cli": patch -"clipboard-manager": 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 alpha.12. diff --git a/.changes/updater-download-headers.md b/.changes/updater-download-headers.md new file mode 100644 index 00000000..a36523ec --- /dev/null +++ b/.changes/updater-download-headers.md @@ -0,0 +1,6 @@ +--- +"updater": patch +"updater-js": patch +--- + +Fix headers option in `Update.download` and `Update.downloadAndInstall` doesn't work with `Record | Headers` types \ No newline at end of file diff --git a/.changes/updater-nsis-admin.md b/.changes/updater-nsis-admin.md deleted file mode 100644 index b4e92e87..00000000 --- a/.changes/updater-nsis-admin.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"updater": "patch" ---- - -On Windows, fix NSIS installers requiring administrator rights failing to be launched by updater. diff --git a/.changes/updater-nsis.md b/.changes/updater-nsis.md deleted file mode 100644 index adfd7f0d..00000000 --- a/.changes/updater-nsis.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"updater": patch ---- - -Implement passive mode on NSIS and automatically restart after NSIS update. diff --git a/.changes/updater-plugin-refactor.md b/.changes/updater-plugin-refactor.md deleted file mode 100644 index 06da6986..00000000 --- a/.changes/updater-plugin-refactor.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"updater": minor -"updater-js": minor ---- - -The updater plugin is recieving a few changes to improve consistency and ergonomics of the Rust and JS APIs diff --git a/.changes/updater-string-replace.md b/.changes/updater-string-replace.md deleted file mode 100644 index 1e682ef3..00000000 --- a/.changes/updater-string-replace.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"updater": "patch" ---- - -The plugin now correctly replaces `arch`, `current_version` and `target` again. diff --git a/.changes/v2-alpha.md b/.changes/v2-alpha.md deleted file mode 100644 index 5e649b73..00000000 --- a/.changes/v2-alpha.md +++ /dev/null @@ -1,49 +0,0 @@ ---- -"authenticator": major -"authenticator-js": major -"autostart": major -"autostart-js": major -"cli": major -"cli-js": major -"clipboard-manager": major -"clipboard-manager-js": major -"dialog": major -"dialog-js": major -"fs": major -"fs-js": major -"global-shortcut": major -"global-shortcut-js": major -"http": major -"http-js": major -"localhost": major -"log-plugin": major -"log-js": major -"notification": major -"notification-js": major -"os": major -"os-js": major -"persisted-scope": major -"positioner": major -"positioner-js": major -"process": major -"process-js": major -"shell": major -"shell-js": major -"single-instance": major -"sql": major -"sql-js": major -"store": major -"store-js": major -"stronghold": major -"stronghold-js": major -"updater": major -"updater-js": major -"upload": major -"upload-js": major -"websocket": major -"websocket-js": major -"window-state": major -"window-state-js": major ---- - -First v2 alpha release! diff --git a/.changes/websocket-fix-arg-name.md b/.changes/websocket-fix-arg-name.md deleted file mode 100644 index dd2bbc90..00000000 --- a/.changes/websocket-fix-arg-name.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"websocket": patch ---- - -Fix argument name mismatch that caused issues when options where provided. diff --git a/.changes/window-state-decorated.md b/.changes/window-state-decorated.md deleted file mode 100644 index 191ec5c2..00000000 --- a/.changes/window-state-decorated.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"window-state": "patch" ---- - -Correctly set decoration state if no saved state xists diff --git a/.changes/window-state-promise.md b/.changes/window-state-promise.md deleted file mode 100644 index f97c43df..00000000 --- a/.changes/window-state-promise.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"window-state-js": "patch" ---- - -Correctly propagate the promise inside `saveWindowState`, `restoreState` and `restoreStateCurrent` so callers can choose to `await` them. diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index d7526cfb..00000000 --- a/.eslintignore +++ /dev/null @@ -1,8 +0,0 @@ -target -node_modules -dist -build/ -dist-js -api-iife.js -init-iife.js -init.js \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index 96b58264..00000000 --- a/.eslintrc.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "env": { - "browser": true, - "es2021": true - }, - "extends": [ - "prettier", - "eslint:recommended", - "plugin:@typescript-eslint/recommended", - "plugin:security/recommended" - ], - "overrides": [], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaVersion": "latest", - "sourceType": "module" - }, - "plugins": ["@typescript-eslint"], - "rules": {} -} diff --git a/.github/sponsors/crabnebula.svg b/.github/sponsors/crabnebula.svg new file mode 100644 index 00000000..40e24131 --- /dev/null +++ b/.github/sponsors/crabnebula.svg @@ -0,0 +1,31 @@ + \ No newline at end of file diff --git a/.github/sponsors/rescue.png b/.github/sponsors/rescue.png new file mode 100644 index 00000000..2b5916f4 Binary files /dev/null and b/.github/sponsors/rescue.png differ diff --git a/.github/workflows/audit-javascript.yml b/.github/workflows/audit-javascript.yml index 618ebf59..f1a3ec3f 100644 --- a/.github/workflows/audit-javascript.yml +++ b/.github/workflows/audit-javascript.yml @@ -7,23 +7,23 @@ name: Audit JavaScript on: workflow_dispatch: schedule: - - cron: "0 0 * * *" + - cron: '0 0 * * *' push: branches: - v1 - v2 paths: - - ".github/workflows/audit-javascript.yml" - - "**/pnpm-lock.yaml" - - "**/package.json" + - '.github/workflows/audit-javascript.yml' + - '**/pnpm-lock.yaml' + - '**/package.json' pull_request: branches: - v1 - v2 paths: - - ".github/workflows/audit-javascript.yml" - - "**/pnpm-lock.yaml" - - "**/package.json" + - '.github/workflows/audit-javascript.yml' + - '**/pnpm-lock.yaml' + - '**/package.json' concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -33,20 +33,20 @@ jobs: audit-js: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Cache pnpm modules - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.pnpm-store key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }} restore-keys: | ${{ runner.os }}- - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: - node-version: 18 - - uses: pnpm/action-setup@v2 + node-version: 'lts/*' + - uses: pnpm/action-setup@v4 with: - version: 7.x.x + version: 10.x.x run_install: true - name: audit run: pnpm audit diff --git a/.github/workflows/audit-rust.yml b/.github/workflows/audit-rust.yml index c85d3712..e0c72a89 100644 --- a/.github/workflows/audit-rust.yml +++ b/.github/workflows/audit-rust.yml @@ -7,23 +7,23 @@ name: Audit Rust on: workflow_dispatch: schedule: - - cron: "0 0 * * *" + - cron: '0 0 * * *' push: branches: - v1 - v2 paths: - - ".github/workflows/audit-rust.yml" - - "**/Cargo.lock" - - "**/Cargo.toml" + - '.github/workflows/audit-rust.yml' + - '**/Cargo.lock' + - '**/Cargo.toml' pull_request: branches: - v1 - v2 paths: - - ".github/workflows/audit-rust.yml" - - "**/Cargo.lock" - - "**/Cargo.toml" + - '.github/workflows/audit-rust.yml' + - '**/Cargo.lock' + - '**/Cargo.toml' concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -33,7 +33,9 @@ jobs: audit-rust: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: rustsec/audit-check@v1 with: token: ${{ secrets.GITHUB_TOKEN }} + # https://github.com/tauri-apps/plugins-workspace/issues/774 + ignore: ${{ github.event_name != 'schedule' && 'RUSTSEC-2023-0071' || '' }} diff --git a/.github/workflows/check-change-files.yml b/.github/workflows/check-change-files.yml new file mode 100644 index 00000000..898f265f --- /dev/null +++ b/.github/workflows/check-change-files.yml @@ -0,0 +1,44 @@ +# Copyright 2019-2023 Tauri Programme within The Commons Conservancy +# SPDX-License-Identifier: Apache-2.0 +# SPDX-License-Identifier: MIT + +name: check change files + +on: + pull_request: + paths: + - '.changes/*.md' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: check change files end with .md + run: | + for file in .changes/* + do + if [[ ! "$file" =~ \.(md|json)$ ]]; then + echo ".changes directory should only contain files that end with .md" + echo "found an invalid file in .changes directory:" + echo "$file" + exit 1 + fi + done + + - uses: dorny/paths-filter@v3 + id: filter + with: + list-files: shell + filters: | + changes: + - added|modified: '.changes/*.md' + + - name: check + run: node ./.scripts/ci/check-change-files.js ${{ steps.filter.outputs.changes_files }} + if: ${{ steps.filter.outputs.changes == 'true' }} diff --git a/.github/workflows/check-generated-files.yml b/.github/workflows/check-generated-files.yml index 52be59f0..6a513b23 100644 --- a/.github/workflows/check-generated-files.yml +++ b/.github/workflows/check-generated-files.yml @@ -7,8 +7,9 @@ name: check generated files on: pull_request: paths: - - ".github/workflows/check-generated-files.yml" - - "**/guest-js/**" + - '.github/workflows/check-generated-files.yml' + - pnpm-lock.yaml + - '**/guest-js/**' concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -20,93 +21,124 @@ jobs: outputs: packages: ${{ steps.filter.outputs.changes }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dorny/paths-filter@v2 id: filter with: filters: | - authenticator: - - .github/workflows/check-generated-files.yml - - plugins/authenticator/guest-js/** - - plugins/authenticator/src/api-iife.js autostart: - .github/workflows/check-generated-files.yml + - pnpm-lock.yaml - plugins/autostart/guest-js/** - plugins/autostart/src/api-iife.js cli: - .github/workflows/check-generated-files.yml + - pnpm-lock.yaml - plugins/cli/guest-js/** - plugins/cli/src/api-iife.js clipboard-manager: - .github/workflows/check-generated-files.yml + - pnpm-lock.yaml - plugins/clipboard-manager/guest-js/** - plugins/clipboard-manager/src/api-iife.js dialog: - .github/workflows/check-generated-files.yml + - pnpm-lock.yaml - plugins/dialog/guest-js/** - plugins/dialog/src/api-iife.js fs: - .github/workflows/check-generated-files.yml + - pnpm-lock.yaml - plugins/fs/guest-js/** - plugins/fs/src/api-iife.js + geolocation: + - .github/workflows/check-generated-files.yml + - pnpm-lock.yaml + - plugins/geolocation/guest-js/** + - plugins/geolocation/src/api-iife.js global-shortcut: - .github/workflows/check-generated-files.yml + - pnpm-lock.yaml - plugins/global-shortcut/guest-js/** - plugins/global-shortcut/src/api-iife.js + opener: + - .github/workflows/check-generated-files.yml + - pnpm-lock.yaml + - plugins/opener/guest-js/** + - plugins/opener/src/api-iife.js + haptics: + - .github/workflows/check-generated-files.yml + - pnpm-lock.yaml + - plugins/haptics/guest-js/** + - plugins/haptics/src/api-iife.js http: - .github/workflows/check-generated-files.yml + - pnpm-lock.yaml - plugins/http/guest-js/** - plugins/http/src/api-iife.js log: - .github/workflows/check-generated-files.yml + - pnpm-lock.yaml - plugins/log/guest-js/** - plugins/log/src/api-iife.js notification: - .github/workflows/check-generated-files.yml + - pnpm-lock.yaml - plugins/notification/guest-js/** - plugins/notification/src/api-iife.js os: - .github/workflows/check-generated-files.yml + - pnpm-lock.yaml - plugins/os/guest-js/** - plugins/os/src/api-iife.js positioner: - .github/workflows/check-generated-files.yml + - pnpm-lock.yaml - plugins/positioner/guest-js/** - plugins/positioner/src/api-iife.js process: - .github/workflows/check-generated-files.yml + - pnpm-lock.yaml - plugins/process/guest-js/** - plugins/process/src/api-iife.js shell: - .github/workflows/check-generated-files.yml + - pnpm-lock.yaml - plugins/shell/guest-js/** - plugins/shell/src/api-iife.js sql: - .github/workflows/check-generated-files.yml + - pnpm-lock.yaml - plugins/sql/guest-js/** - plugins/sql/src/api-iife.js store: - .github/workflows/check-generated-files.yml + - pnpm-lock.yaml - plugins/store/guest-js/** - plugins/store/src/api-iife.js stronghold: - .github/workflows/check-generated-files.yml + - pnpm-lock.yaml - plugins/stronghold/guest-js/** - plugins/stronghold/src/api-iife.js updater: - .github/workflows/check-generated-files.yml + - pnpm-lock.yaml - plugins/updater/guest-js/** - plugins/updater/src/api-iife.js upload: - .github/workflows/check-generated-files.yml + - pnpm-lock.yaml - plugins/upload/guest-js/** - plugins/upload/src/api-iife.js websocket: - .github/workflows/check-generated-files.yml + - pnpm-lock.yaml - plugins/websocket/guest-js/** - plugins/websocket/src/api-iife.js window-state: - .github/workflows/check-generated-files.yml + - pnpm-lock.yaml - plugins/window-state/guest-js/** - plugins/window-state/src/api-iife.js @@ -121,21 +153,21 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Cache pnpm modules - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.pnpm-store key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }} restore-keys: | ${{ runner.os }}- - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: - node-version: 18 - - uses: pnpm/action-setup@v2 + node-version: 'lts/*' + - uses: pnpm/action-setup@v4 with: - version: 7.x.x + version: 10.x.x run_install: true - name: build api diff --git a/.github/workflows/check-license-header.yml b/.github/workflows/check-license-header.yml index 011a1780..338a0041 100644 --- a/.github/workflows/check-license-header.yml +++ b/.github/workflows/check-license-header.yml @@ -15,7 +15,7 @@ jobs: check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: dorny/paths-filter@v2 id: filter with: diff --git a/.github/workflows/covector-comment-on-fork.yml b/.github/workflows/covector-comment-on-fork.yml new file mode 100644 index 00000000..494a5348 --- /dev/null +++ b/.github/workflows/covector-comment-on-fork.yml @@ -0,0 +1,30 @@ +# Copyright 2019-2023 Tauri Programme within The Commons Conservancy +# SPDX-License-Identifier: Apache-2.0 +# SPDX-License-Identifier: MIT + +name: covector comment +on: + workflow_run: + workflows: [covector status] # the `name` of the workflow run on `pull_request` running `status` with `comment: true` + types: + - completed + +# note all other permissions are set to none if not specified +# and these set the permissions for `secrets.GITHUB_TOKEN` +permissions: + # to read the action artifacts on `covector status` workflows + actions: read + # to write the comment + pull-requests: write + +jobs: + download: + runs-on: ubuntu-latest + if: github.event.workflow_run.conclusion == 'success' && + (github.event.workflow_run.head_repository.full_name != github.repository || github.actor == 'dependabot[bot]') + steps: + - name: covector status + uses: jbolda/covector/packages/action@covector-v0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + command: 'status' diff --git a/.github/workflows/covector-status.yml b/.github/workflows/covector-status.yml index 562dd70a..7eeda427 100644 --- a/.github/workflows/covector-status.yml +++ b/.github/workflows/covector-status.yml @@ -10,11 +10,13 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 # required for use of git history - name: covector status uses: jbolda/covector/packages/action@covector-v0 id: covector with: - command: "status" + command: 'status' + token: ${{ secrets.GITHUB_TOKEN }} + comment: true diff --git a/.github/workflows/covector-version-or-publish-v2.yml b/.github/workflows/covector-version-or-publish-v2.yml deleted file mode 100644 index 6d1ce3a7..00000000 --- a/.github/workflows/covector-version-or-publish-v2.yml +++ /dev/null @@ -1,68 +0,0 @@ -# Copyright 2019-2023 Tauri Programme within The Commons Conservancy -# SPDX-License-Identifier: Apache-2.0 -# SPDX-License-Identifier: MIT - -name: version or publish - -on: - push: - branches: - - v2 - -jobs: - version-or-publish: - runs-on: ubuntu-latest - timeout-minutes: 65 - outputs: - change: ${{ steps.covector.outputs.change }} - commandRan: ${{ steps.covector.outputs.commandRan }} - successfulPublish: ${{ steps.covector.outputs.successfulPublish }} - - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 # required for use of git history - - - uses: actions/setup-node@v3 - with: - node-version: "lts/*" - registry-url: "https://registry.npmjs.org" - - - uses: pnpm/action-setup@v2 - with: - version: 7.x.x - run_install: true - - - name: install webkit2gtk and libudev for [authenticator] - run: | - sudo apt-get update - sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev libudev-dev - - - name: cargo login - run: cargo login ${{ secrets.ORG_CRATES_IO_TOKEN }} - - - name: git config - run: | - git config --global user.name "${{ github.event.pusher.name }}" - git config --global user.email "${{ github.event.pusher.email }}" - - - name: covector version or publish (publish when no change files present) - uses: jbolda/covector/packages/action@covector-v0 - id: covector - env: - NODE_AUTH_TOKEN: ${{ secrets.ORG_NPM_TOKEN }} - with: - token: ${{ secrets.GITHUB_TOKEN }} - command: "version-or-publish" - createRelease: true - - - name: Create Pull Request With Versions Bumped - id: cpr - uses: tauri-apps/create-pull-request@v3 - if: steps.covector.outputs.commandRan == 'version' - with: - title: "Publish New Versions (v2)" - commit-message: "publish new versions" - labels: "version updates" - branch: "release-v2" - body: ${{ steps.covector.outputs.change }} diff --git a/.github/workflows/covector-version-or-publish.yml b/.github/workflows/covector-version-or-publish.yml index c5ef8161..34bd0178 100644 --- a/.github/workflows/covector-version-or-publish.yml +++ b/.github/workflows/covector-version-or-publish.yml @@ -8,6 +8,15 @@ on: push: branches: - v1 + - v2 + +permissions: + # required for npm provenance + id-token: write + # required to create the GitHub Release + contents: write + # required for creating the Version Packages Release + pull-requests: write jobs: version-or-publish: @@ -19,25 +28,20 @@ jobs: successfulPublish: ${{ steps.covector.outputs.successfulPublish }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 # required for use of git history - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: - node-version: "lts/*" - registry-url: "https://registry.npmjs.org" + node-version: 'lts/*' + registry-url: 'https://registry.npmjs.org' - - uses: pnpm/action-setup@v2 + - uses: pnpm/action-setup@v4 with: - version: 7.x.x + version: 10.x.x run_install: true - - name: install webkit2gtk and libudev for [authenticator] - run: | - sudo apt-get update - sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev libudev-dev - - name: cargo login run: cargo login ${{ secrets.ORG_CRATES_IO_TOKEN }} @@ -46,23 +50,36 @@ jobs: git config --global user.name "${{ github.event.pusher.name }}" git config --global user.email "${{ github.event.pusher.email }}" + - name: Setup target dir on /mnt + # This directory has a larger partition size + run: | + sudo mkdir /mnt/target + WORKSPACE_OWNER="$(stat -c '%U:%G' "${GITHUB_WORKSPACE}")" + sudo chown -R "${WORKSPACE_OWNER}" /mnt/target + - name: covector version or publish (publish when no change files present) uses: jbolda/covector/packages/action@covector-v0 id: covector env: + CARGO_TARGET_DIR: /mnt/target NODE_AUTH_TOKEN: ${{ secrets.ORG_NPM_TOKEN }} with: token: ${{ secrets.GITHUB_TOKEN }} - command: "version-or-publish" + command: 'version-or-publish' createRelease: true + recognizeContributors: true + + - name: Sync Cargo.lock + if: steps.covector.outputs.commandRan == 'version' + run: cargo tree --depth 0 - name: Create Pull Request With Versions Bumped id: cpr - uses: tauri-apps/create-pull-request@v3 + uses: peter-evans/create-pull-request@dd2324fc52d5d43c699a5636bcf19fceaa70c284 # 7.0.7 if: steps.covector.outputs.commandRan == 'version' with: - title: "Publish New Versions" - commit-message: "publish new versions" - labels: "version updates" - branch: "release" + title: 'Publish New Versions (${{ github.ref_name }})' + commit-message: 'publish new versions' + labels: 'version updates' + branch: 'ci/release-${{ github.ref_name }}' body: ${{ steps.covector.outputs.change }} diff --git a/.github/workflows/fmt.yml b/.github/workflows/fmt.yml new file mode 100644 index 00000000..087b7674 --- /dev/null +++ b/.github/workflows/fmt.yml @@ -0,0 +1,59 @@ +# Copyright 2019-2023 Tauri Programme within The Commons Conservancy +# SPDX-License-Identifier: Apache-2.0 +# SPDX-License-Identifier: MIT + +name: check formatting + +on: + pull_request: + +jobs: + rustfmt: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: install Rust stable and rustfmt + uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt + + - name: run cargo fmt + run: cargo fmt --all -- --check + + prettier: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Cache pnpm modules + uses: actions/cache@v4 + with: + path: ~/.pnpm-store + key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}- + - uses: actions/setup-node@v4 + with: + node-version: 'lts/*' + - uses: pnpm/action-setup@v4 + with: + version: 10.x.x + run_install: true + - run: pnpm format:check + + taplo: + name: taplo (.toml files) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: install Rust stable + uses: dtolnay/rust-toolchain@stable + + - name: install taplo-cli + uses: taiki-e/install-action@v2 + with: + tool: taplo-cli + + - run: taplo fmt --check --diff diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index f616ef6f..fbbca96a 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -10,15 +10,15 @@ on: - v1 - v2 paths: - - ".github/workflows/integration-tests.yml" - - "plugins/updater/src/**" + - '.github/workflows/integration-tests.yml' + - 'plugins/updater/src/**' pull_request: branches: - v1 - v2 paths: - - ".github/workflows/integration-tests.yml" - - "plugins/updater/src/**" + - '.github/workflows/integration-tests.yml' + - 'plugins/updater/src/**' jobs: run-integration-tests: @@ -27,23 +27,21 @@ jobs: strategy: fail-fast: false matrix: - platform: [ubuntu-latest, macos-latest, windows-latest] + platform: [ubuntu-22.04, macos-latest, windows-latest] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: fetch-depth: 0 - name: install stable - uses: actions-rs/toolchain@v1 - with: - toolchain: stable + uses: dtolnay/rust-toolchain@stable - name: install Linux dependencies - if: matrix.platform == 'ubuntu-latest' + if: matrix.platform == 'ubuntu-22.04' run: | sudo apt-get update - sudo apt-get install -y webkit2gtk-4.1 libayatana-appindicator3-dev libfuse2 + sudo apt-get install -y webkit2gtk-4.0 libwebkit2gtk-4.1-dev libayatana-appindicator3-dev libfuse2 - uses: Swatinem/rust-cache@v2 diff --git a/.github/workflows/lint-javascript.yml b/.github/workflows/lint-javascript.yml index 02b96541..4c9db35e 100644 --- a/.github/workflows/lint-javascript.yml +++ b/.github/workflows/lint-javascript.yml @@ -10,23 +10,23 @@ on: - v1 - v2 paths: - - ".github/workflows/lint-javascript.yml" - - "plugins/*/guest-js/**" - - ".eslintignore" - - ".eslintrc.json" - - ".prettierignore" - - "**/package.json" + - '.github/workflows/lint-javascript.yml' + - 'plugins/*/guest-js/**' + - '.eslintignore' + - '.eslintrc.json' + - '.prettierignore' + - '**/package.json' pull_request: branches: - v1 - v2 paths: - - ".github/workflows/lint-javascript.yml" - - "plugins/*/guest-js/**" - - ".eslintignore" - - ".eslintrc.json" - - ".prettierignore" - - "**/package.json" + - '.github/workflows/lint-javascript.yml' + - 'plugins/*/guest-js/**' + - '.eslintignore' + - '.eslintrc.json' + - '.prettierignore' + - '**/package.json' concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -36,40 +36,20 @@ jobs: eslint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Cache pnpm modules - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.pnpm-store key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }} restore-keys: | ${{ runner.os }}- - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: - node-version: 18 - - uses: pnpm/action-setup@v2 + node-version: 'lts/*' + - uses: pnpm/action-setup@v4 with: - version: 7.x.x + version: 10.x.x run_install: true - name: eslint run: pnpm lint - prettier: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Cache pnpm modules - uses: actions/cache@v3 - with: - path: ~/.pnpm-store - key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}- - - uses: actions/setup-node@v3 - with: - node-version: 18 - - uses: pnpm/action-setup@v2 - with: - version: 7.x.x - run_install: true - - name: prettier check - run: pnpm format-check diff --git a/.github/workflows/lint-rust.yml b/.github/workflows/lint-rust.yml index b2e2a933..db922ef1 100644 --- a/.github/workflows/lint-rust.yml +++ b/.github/workflows/lint-rust.yml @@ -10,19 +10,19 @@ on: - v1 - v2 paths: - - ".github/workflows/lint-rust.yml" - - "plugins/*/src/**" - - "!plugins/*/src/api-iife.js" - - "**/Cargo.toml" + - '.github/workflows/lint-rust.yml' + - 'plugins/*/src/**' + - '!plugins/*/src/api-iife.js' + - '**/Cargo.toml' pull_request: branches: - v1 - v2 paths: - - ".github/workflows/lint-rust.yml" - - "plugins/*/src/**" - - "!plugins/*/src/api-iife.js" - - "**/Cargo.toml" + - '.github/workflows/lint-rust.yml' + - 'plugins/*/src/**' + - '!plugins/*/src/api-iife.js' + - '**/Cargo.toml' concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -36,14 +36,11 @@ jobs: outputs: packages: ${{ steps.filter.outputs.changes }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dorny/paths-filter@v2 id: filter with: filters: | - tauri-plugin-authenticator: - - .github/workflows/lint-rust.yml - - plugins/authenticator/** tauri-plugin-autostart: - .github/workflows/lint-rust.yml - plugins/autostart/** @@ -53,6 +50,9 @@ jobs: tauri-plugin-clipboard-manager: - .github/workflows/lint-rust.yml - plugins/clipboard-manager/** + tauri-plugin-deep-link: + - .github/workflows/lint-rust.yml + - plugins/deep-link/** tauri-plugin-dialog: - .github/workflows/lint-rust.yml - plugins/dialog/** @@ -60,9 +60,18 @@ jobs: tauri-plugin-fs: - .github/workflows/lint-rust.yml - plugins/fs/** + tauri-plugin-geolocation: + - .github/workflows/lint-rust.yml + - plugins/geolocation/** tauri-plugin-global-shortcut: - .github/workflows/lint-rust.yml - plugins/global-shortcut/** + tauri-plugin-opener: + - .github/workflows/lint-rust.yml + - plugins/opener/** + tauri-plugin-haptics: + - .github/workflows/lint-rust.yml + - plugins/haptics/** tauri-plugin-http: - .github/workflows/lint-rust.yml - plugins/http/** @@ -120,19 +129,19 @@ jobs: clippy: needs: changes if: ${{ needs.changes.outputs.packages != '[]' && needs.changes.outputs.packages != '' }} - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 strategy: fail-fast: false matrix: package: ${{ fromJSON(needs.changes.outputs.packages) }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - name: install webkit2gtk and libudev for [authenticator] + - name: install webkit2gtk run: | sudo apt-get update - sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev libudev-dev + sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev - name: Install clippy with stable toolchain uses: dtolnay/rust-toolchain@stable @@ -141,32 +150,8 @@ jobs: - uses: Swatinem/rust-cache@v2 - - name: create dummy dist - working-directory: examples/api - run: mkdir dist - - name: clippy ${{ matrix.package }} - if: matrix.package != 'tauri-plugin-sql' run: cargo clippy --package ${{ matrix.package }} --all-targets -- -D warnings - - name: clippy ${{ matrix.package }} mysql - if: matrix.package == 'tauri-plugin-sql' - run: cargo clippy --package ${{ matrix.package }} --all-targets --no-default-features --features mysql -- -D warnings - - - name: clippy ${{ matrix.package }} postgres - if: matrix.package == 'tauri-plugin-sql' - run: cargo clippy --package ${{ matrix.package }} --all-targets --no-default-features --features postgres -- -D warnings - - fmt: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: Install rustfmt with nightly toolchain - uses: dtolnay/rust-toolchain@nightly - with: - components: rustfmt - - - name: Check formatting - run: cargo fmt --all -- --check + - name: clippy ${{ matrix.package }} --all-features + run: cargo clippy --package ${{ matrix.package }} --all-targets --all-features -- -D warnings diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml index b34ccc7c..6764cf8a 100644 --- a/.github/workflows/sync.yml +++ b/.github/workflows/sync.yml @@ -19,26 +19,26 @@ jobs: sync-to-mirrors: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Fetch git tags run: git fetch origin 'refs/tags/*:refs/tags/*' - name: Cache pnpm modules - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.pnpm-store key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }} restore-keys: | ${{ runner.os }}- - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: - node-version: 18 + node-version: 'lts/*' - - uses: pnpm/action-setup@v2 + - uses: pnpm/action-setup@v4 with: - version: 7.x.x + version: 10.x.x run_install: true - name: Build packages diff --git a/.github/workflows/test-rust.yml b/.github/workflows/test-rust.yml index 8095d0e7..496efe6e 100644 --- a/.github/workflows/test-rust.yml +++ b/.github/workflows/test-rust.yml @@ -10,21 +10,21 @@ on: - v1 - v2 paths: - - ".github/workflows/test-rust.yml" - - "plugins/*/src/**" - - "!plugins/*/src/api-iife.js" - - "**/Cargo.toml" - - "**/Cargo.lock" + - '.github/workflows/test-rust.yml' + - 'plugins/*/src/**' + - '!plugins/*/src/api-iife.js' + - '**/Cargo.toml' + - '**/Cargo.lock' pull_request: branches: - v1 - v2 paths: - - ".github/workflows/test-rust.yml" - - "plugins/*/src/**" - - "!plugins/*/src/api-iife.js" - - "**/Cargo.toml" - - "**/Cargo.lock" + - '.github/workflows/test-rust.yml' + - 'plugins/*/src/**' + - '!plugins/*/src/api-iife.js' + - '**/Cargo.toml' + - '**/Cargo.lock' concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -38,85 +38,149 @@ jobs: outputs: packages: ${{ steps.filter.outputs.changes }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dorny/paths-filter@v2 id: filter with: + base: v2 filters: | - tauri-plugin-authenticator: - - .github/workflows/test-rust.yml - - plugins/authenticator/** tauri-plugin-autostart: - .github/workflows/test-rust.yml + - Cargo.toml + - Cargo.lock - plugins/autostart/** tauri-plugin-cli: - .github/workflows/test-rust.yml + - Cargo.toml + - Cargo.lock - plugins/cli/** tauri-plugin-clipboard-manager: - .github/workflows/test-rust.yml + - Cargo.toml + - Cargo.lock - plugins/clipboard-manager/** + tauri-plugin-deep-link: + - .github/workflows/test-rust.yml + - Cargo.toml + - Cargo.lock + - plugins/deep-link/** tauri-plugin-dialog: - .github/workflows/test-rust.yml + - Cargo.toml + - Cargo.lock - plugins/dialog/** - plugins/fs/** tauri-plugin-fs: - .github/workflows/test-rust.yml + - Cargo.toml + - Cargo.lock - plugins/fs/** + tauri-plugin-geolocation: + - .github/workflows/test-rust.yml + - Cargo.toml + - Cargo.lock + - plugins/geolocation/** tauri-plugin-global-shortcut: - .github/workflows/test-rust.yml + - Cargo.toml + - Cargo.lock - plugins/global-shortcut/** + tauri-plugin-opener: + - .github/workflows/test-rust.yml + - Cargo.toml + - Cargo.lock + - plugins/opener/** + tauri-plugin-haptics: + - .github/workflows/test-rust.yml + - Cargo.toml + - Cargo.lock + - plugins/haptics/** tauri-plugin-http: - .github/workflows/test-rust.yml + - Cargo.toml + - Cargo.lock - plugins/http/** - plugins/fs/** tauri-plugin-localhost: - .github/workflows/test-rust.yml + - Cargo.toml + - Cargo.lock - plugins/localhost/** tauri-plugin-log: - .github/workflows/test-rust.yml + - Cargo.toml + - Cargo.lock - plugins/log/** tauri-plugin-notification: - .github/workflows/test-rust.yml + - Cargo.toml + - Cargo.lock - plugins/notification/** tauri-plugin-os: - .github/workflows/test-rust.yml + - Cargo.toml + - Cargo.lock - plugins/os/** tauri-plugin-persisted-scope: - .github/workflows/test-rust.yml + - Cargo.toml + - Cargo.lock - plugins/persisted-scope/** - plugins/fs/** tauri-plugin-positioner: - .github/workflows/test-rust.yml + - Cargo.toml + - Cargo.lock - plugins/positioner/** tauri-plugin-process: - .github/workflows/test-rust.yml + - Cargo.toml + - Cargo.lock - plugins/process/** tauri-plugin-shell: - .github/workflows/test-rust.yml + - Cargo.toml + - Cargo.lock - plugins/shell/** tauri-plugin-single-instance: - .github/workflows/test-rust.yml + - Cargo.toml + - Cargo.lock - plugins/single-instance/** tauri-plugin-sql: - .github/workflows/test-rust.yml + - Cargo.toml + - Cargo.lock - plugins/sql/** tauri-plugin-store: - .github/workflows/test-rust.yml + - Cargo.toml + - Cargo.lock - plugins/store/** tauri-plugin-stronghold: - .github/workflows/test-rust.yml + - Cargo.toml + - Cargo.lock - plugins/stronghold/** tauri-plugin-updater: - .github/workflows/test-rust.yml + - Cargo.toml + - Cargo.lock - plugins/updater/** tauri-plugin-upload: - .github/workflows/test-rust.yml + - Cargo.toml + - Cargo.lock - plugins/upload/** tauri-plugin-websocket: - .github/workflows/test-rust.yml + - Cargo.toml + - Cargo.lock - plugins/websocket/** tauri-plugin-window-state: - .github/workflows/test-rust.yml + - Cargo.toml + - Cargo.lock - plugins/window-state/** test: @@ -131,51 +195,45 @@ jobs: target: x86_64-pc-windows-msvc, os: windows-latest, runner: 'cargo', - command: "test", + command: 'test' } - { target: x86_64-unknown-linux-gnu, - os: ubuntu-latest, + os: ubuntu-22.04, runner: 'cargo', - command: "test", + command: 'test' } - { - target: x86_64-apple-darwin, + target: aarch64-apple-darwin, os: macos-latest, runner: 'cargo', - command: "test", + command: 'test' } - { target: aarch64-apple-ios, os: macos-latest, runner: 'cargo', - command: "build", + command: 'build' } - { target: aarch64-linux-android, os: ubuntu-latest, runner: 'cross', - command: "build", + command: 'build' } runs-on: ${{ matrix.platform.os }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - name: install webkit2gtk and libudev for [authenticator] + - name: install webkit2gtk if: contains(matrix.platform.target, 'unknown-linux') run: | sudo apt-get update - sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev libudev-dev + sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev - - name: install openssl - if: ${{ matrix.platform.os == 'windows-latest' && matrix.package == 'tauri-plugin-authenticator' }} - run: | - echo "VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT" | Out-File -FilePath $env:GITHUB_ENV -Append - vcpkg install openssl:x64-windows-static-md - - - uses: dtolnay/rust-toolchain@1.70.0 + - uses: dtolnay/rust-toolchain@1.77.2 with: targets: ${{ matrix.platform.target }} @@ -183,22 +241,14 @@ jobs: with: key: cache-${{ matrix.package }}-${{ matrix.platform.target }} - - name: create dummy dist - working-directory: examples/api - run: mkdir dist - - name: install cross if: ${{ matrix.platform.runner == 'cross' }} - run: cargo install cross --git https://github.com/cross-rs/cross + run: cargo +stable install cross --git https://github.com/cross-rs/cross - name: test ${{ matrix.package }} - if: matrix.package != 'tauri-plugin-sql' - run: ${{ matrix.platform.runner }} ${{ matrix.platform.command }} --package ${{ matrix.package }} --target ${{ matrix.platform.target }} --all-targets + if: matrix.package != 'tauri-plugin-http' + run: ${{ matrix.platform.runner }} ${{ matrix.platform.command }} --package ${{ matrix.package }} --target ${{ matrix.platform.target }} --all-targets --all-features - - name: test ${{ matrix.package }} mysql - if: matrix.package == 'tauri-plugin-sql' - run: ${{ matrix.platform.runner }} ${{ matrix.platform.command }} --package ${{ matrix.package }} --target ${{ matrix.platform.target }} --all-targets --features mysql - - - name: test ${{ matrix.package }} postgres - if: matrix.package == 'tauri-plugin-sql' - run: ${{ matrix.platform.runner }} ${{ matrix.platform.command }} --package ${{ matrix.package }} --target ${{ matrix.platform.target }} --all-targets --features postgres + - name: test ${{ matrix.package }} + if: matrix.package == 'tauri-plugin-http' + run: ${{ matrix.platform.runner }} ${{ matrix.platform.command }} --package ${{ matrix.package }} --target ${{ matrix.platform.target }} --all-targets diff --git a/.gitignore b/.gitignore index 9a05fc88..56b2e525 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,60 @@ -target -node_modules -dist -dist-js \ No newline at end of file +# dependency directories +node_modules/ +target/ + +# Optional npm and yarn cache directory +.npm/ +.yarn/ + +# Output of 'npm pack' +*.tgz + +# dotenv environment variables file +.env + +# .vscode workspace settings file +.vscode/settings.json +.vscode/launch.json +.vscode/tasks.json + +# npm, yarn and bun lock files +package-lock.json +yarn.lock +bun.lockb + +# rust compiled folders +target/ + +# compiled plugins +dist-js/ + +# plugins .tauri directory +/plugins/*/.tauri + +# examples +examples/*/dist +plugins/*/examples/*/dist +examples/*/src-tauri/gen/schemas +plugins/*/examples/*/src-tauri/gen/schemas + +# logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# runtime data +pids +*.pid +*.seed +*.pid.lock + +# miscellaneous +/.vs +.DS_Store +.Thumbs.db +*.sublime* +.idea +debug.log +TODO.md \ No newline at end of file diff --git a/.npmrc b/.npmrc index f87a0443..30ab299d 100644 --- a/.npmrc +++ b/.npmrc @@ -1 +1 @@ -auto-install-peers=true \ No newline at end of file +link-workspace-packages=true diff --git a/.prettierignore b/.prettierignore index c2d3ae57..bc4fca6d 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,11 +1,27 @@ -target -node_modules -dist -dist-js +/.changes +/.vscode + +# dependcies and artifacts directories +node_modules/ +target/ +dist-js/ +dist/ + +# lock files pnpm-lock.yaml -Cargo.lock -.build -build + +# examples gen directory +examples/*/src-tauri/gen/ +plugins/*/examples/*/src-tauri/gen/ + +# autogenerated files +**/autogenerated/**/*.md api-iife.js init-iife.js -intermediates/ \ No newline at end of file +CHANGELOG.md +*schema.json + +# mobile build +**/ios/.build +**/.tauri +plugins/*/android/build diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000..6ca6fdd2 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,6 @@ +{ + "singleQuote": true, + "semi": false, + "trailingComma": "none", + "experimentalOperatorPosition": "start" +} diff --git a/.scripts/ci/check-change-files.js b/.scripts/ci/check-change-files.js new file mode 100644 index 00000000..c9ff7e9b --- /dev/null +++ b/.scripts/ci/check-change-files.js @@ -0,0 +1,86 @@ +#!/usr/bin/env node + +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import { readFileSync, readdirSync } from 'fs' +import { join } from 'path' + +/* const ignorePackages = [ + 'api-example', + 'api-example-js', + 'deep-link-example', + 'deep-link-example-js' +] */ + +const rsOnly = ['localhost', 'persisted-scope', 'single-instance'] + +function checkChangeFiles(changeFiles) { + let code = 0 + + for (const file of changeFiles) { + const content = readFileSync(file, 'utf8') + const [frontMatter] = /^---[\s\S.]*---\n/i.exec(content) + const packages = frontMatter + .split('\n') + .filter((l) => !(l === '---' || !l)) + .map((l) => l.replace(/('|")/g, '').split(':')) + + const rsPackages = Object.fromEntries( + packages + .filter((v) => !v[0].endsWith('-js')) + .map((v) => [v[0], v[1].trim()]) + ) + const jsPackages = Object.fromEntries( + packages + .filter((v) => v[0].endsWith('-js')) + .map((v) => [v[0].slice(0, -3), v[1].trim()]) + ) + + for (const pkg in rsPackages) { + if (rsOnly.includes(pkg)) continue + + if (!jsPackages[pkg]) { + console.error( + `Missing "${rsPackages[pkg]}" bump for JS package "${pkg}-js" in ${file}.` + ) + code = 1 + } else if (rsPackages[pkg] != jsPackages[pkg]) { + console.error( + `"${pkg}" and "${pkg}-js" have different version bumps in ${file}.` + ) + code = 1 + } + } + + for (const pkg in jsPackages) { + if (!rsPackages[pkg]) { + console.error( + `Missing "${jsPackages[pkg]}" bump for Rust package "${pkg}" in ${file}.` + ) + code = 1 + } else if (rsPackages[pkg] != jsPackages[pkg]) { + console.error( + `"${pkg}" and "${pkg}-js" have different version bumps in ${file}.` + ) + code = 1 + } + } + } + + process.exit(code) +} + +const [_bin, _script, ...files] = process.argv + +if (files.length > 0) { + checkChangeFiles( + files.filter((f) => f.toLowerCase() !== '.changes/readme.md') + ) +} else { + const changeFiles = readdirSync('.changes') + .filter((f) => f.endsWith('.md') && f.toLowerCase() !== 'readme.md') + .map((p) => join('.changes', p)) + checkChangeFiles(changeFiles) +} diff --git a/.scripts/ci/check-license-header.js b/.scripts/ci/check-license-header.js index 225e90ba..4341e5a2 100644 --- a/.scripts/ci/check-license-header.js +++ b/.scripts/ci/check-license-header.js @@ -2,124 +2,129 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import fs from "fs"; -import path from "path"; -import readline from "readline"; +import fs from 'fs' +import path from 'path' +import readline from 'readline' const header = `Copyright 2019-2023 Tauri Programme within The Commons Conservancy SPDX-License-Identifier: Apache-2.0 -SPDX-License-Identifier: MIT`; -const ignoredLicense = "// Copyright 2021 Jonas Kruckenberg"; +SPDX-License-Identifier: MIT` +const ignoredLicenses = [ + '// Copyright 2021 Flavio Oliveira', + '// Copyright 2021 Jonas Kruckenberg', + '// Copyright 2018-2023 the Deno authors.' +] -const extensions = [".rs", ".js", ".ts", ".yml", ".swift", ".kt"]; +const extensions = ['.rs', '.js', '.ts', '.yml', '.swift', '.kt'] const ignore = [ - "target", - "templates", - "node_modules", - "gen", - "dist", - "dist-js", - ".svelte-kit", - "api-iife.js", - "init-iife.js", - ".build", -]; + 'target', + 'templates', + 'node_modules', + 'gen', + 'dist', + 'dist-js', + '.svelte-kit', + 'api-iife.js', + 'init-iife.js', + '.build', + 'notify_rust' +] async function checkFile(file) { if ( - extensions.some((e) => file.endsWith(e)) && - !ignore.some((i) => file.endsWith(i)) + extensions.some((e) => file.endsWith(e)) + && !ignore.some((i) => file.includes(`${path.sep}${i}`)) ) { - const fileStream = fs.createReadStream(file); + const fileStream = fs.createReadStream(file) const rl = readline.createInterface({ input: fileStream, - crlfDelay: Infinity, - }); + crlfDelay: Infinity + }) - let contents = ``; - let i = 0; + let contents = `` + let i = 0 for await (let line of rl) { // ignore empty lines, allow shebang, swift-tools-version and bundler license if ( - line.length === 0 || - line.startsWith("#!") || - line.startsWith("// swift-tools-version:") || - line === ignoredLicense + line.length === 0 + || line.startsWith('#!') + || line.startsWith('// swift-tools-version:') + || ignoredLicenses.includes(line) ) { - continue; + continue } // strip comment marker - if (line.startsWith("// ")) { - line = line.substring(3); - } else if (line.startsWith("# ")) { - line = line.substring(2); + if (line.startsWith('// ')) { + line = line.substring(3) + } else if (line.startsWith('# ')) { + line = line.substring(2) } - contents += line; + contents += line if (++i === 3) { - break; + break } - contents += "\n"; + contents += '\n' } if (contents !== header) { - return true; + return true } } - return false; + return false } async function check(src) { - const missingHeader = []; + const missingHeader = [] for (const entry of fs.readdirSync(src, { - withFileTypes: true, + withFileTypes: true })) { - const p = path.join(src, entry.name); + const p = path.join(src, entry.name) if (entry.isSymbolicLink() || ignore.includes(entry.name)) { - continue; + continue } if (entry.isDirectory()) { - const missing = await check(p); - missingHeader.push(...missing); + const missing = await check(p) + missingHeader.push(...missing) } else { - const isMissing = await checkFile(p); + const isMissing = await checkFile(p) if (isMissing) { - missingHeader.push(p); + missingHeader.push(p) } } } - return missingHeader; + return missingHeader } -const [_bin, _script, ...files] = process.argv; +const [_bin, _script, ...files] = process.argv if (files.length > 0) { async function run() { - const missing = []; + const missing = [] for (const f of files) { - const isMissing = await checkFile(f); + const isMissing = await checkFile(f) if (isMissing) { - missing.push(f); + missing.push(f) } } if (missing.length > 0) { - console.log(missing.join("\n")); - process.exit(1); + console.log(missing.join('\n')) + process.exit(1) } } - run(); + run() } else { - check(path.resolve(new URL(import.meta.url).pathname, "../../..")).then( + check(path.resolve(new URL(import.meta.url).pathname, '../../..')).then( (missing) => { if (missing.length > 0) { - console.log(missing.join("\n")); - process.exit(1); + console.log(missing.join('\n')) + process.exit(1) } - }, - ); + } + ) } diff --git a/.scripts/ci/has-diff.sh b/.scripts/ci/has-diff.sh index dd40c06f..1f18ac64 100755 --- a/.scripts/ci/has-diff.sh +++ b/.scripts/ci/has-diff.sh @@ -5,5 +5,6 @@ then echo "working directory is clean" else echo "found diff" + git diff --name-status HEAD exit 1 fi diff --git a/.scripts/covector/package-latest-version.cjs b/.scripts/covector/package-latest-version.cjs deleted file mode 100644 index fde1d4c0..00000000 --- a/.scripts/covector/package-latest-version.cjs +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env node -// Copyright 2019-2023 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - -/* -This script is solely intended to be run as part of the `covector publish` step to -check the latest version of a crate, considering the current minor version. -*/ - -const https = require("https"); - -const kind = process.argv[2]; -const packageName = process.argv[3]; -const packageVersion = process.argv[4]; -const target = packageVersion.substring(0, packageVersion.lastIndexOf(".")); - -let url = null; -switch (kind) { - case "cargo": - url = `https://crates.io/api/v1/crates/${packageName}`; - break; - case "npm": - url = `https://registry.npmjs.org/${packageName}`; - break; - default: - throw new Error("unexpected kind " + kind); -} - -const options = { - headers: { - "Content-Type": "application/json", - Accept: "application/json", - "User-Agent": "tauri (https://github.com/tauri-apps/tauri)", - }, -}; - -https.get(url, options, (response) => { - let chunks = []; - response.on("data", function (chunk) { - chunks.push(chunk); - }); - - response.on("end", function () { - const data = JSON.parse(chunks.join("")); - if (kind === "cargo") { - if (data.versions) { - const versions = data.versions.filter((v) => v.num.startsWith(target)); - console.log(versions.length ? versions[0].num : "0.0.0"); - } else { - console.log("0.0.0"); - } - } else if (kind === "npm") { - const versions = Object.keys(data.versions || {}).filter((v) => - v.startsWith(target), - ); - console.log(versions[versions.length - 1] || "0.0.0"); - } - }); -}); diff --git a/.taurignore b/.taurignore new file mode 100644 index 00000000..28a49db3 --- /dev/null +++ b/.taurignore @@ -0,0 +1,2 @@ +plugins/*/permissions/autogenerated/ +plugins/*/android/.tauri/tauri-api/build/ diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000..68acfc90 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,8 @@ +{ + "recommendations": [ + "rust-lang.rust-analyzer", + "EditorConfig.EditorConfig", + "esbenp.prettier-vscode", + "tamasfe.even-better-toml" + ] +} diff --git a/Cargo.lock b/Cargo.lock index c4303eb9..3f3071de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,29 +2,32 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "Inflector" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" + [[package]] name = "addr2line" -version = "0.20.0" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ "gimli", ] [[package]] -name = "adler" -version = "1.0.2" +name = "adler2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" [[package]] -name = "aead" -version = "0.4.3" +name = "adler32" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877" -dependencies = [ - "generic-array", -] +checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" [[package]] name = "aead" @@ -38,83 +41,57 @@ dependencies = [ [[package]] name = "aes" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" -dependencies = [ - "cfg-if", - "cipher 0.3.0", - "cpufeatures", - "opaque-debug", -] - -[[package]] -name = "aes" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac1f845298e95f983ff1944b728ae08b8cebab80d684f0a832ed0fc74dfa27e2" +checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" dependencies = [ "cfg-if", - "cipher 0.4.4", + "cipher", "cpufeatures", ] [[package]] name = "aes-gcm" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc3be92e19a7ef47457b8e6f90707e12b6ac5d20c6f3866584fa3be0787d839f" -dependencies = [ - "aead 0.4.3", - "aes 0.7.5", - "cipher 0.3.0", - "ctr 0.7.0", - "ghash 0.4.4", - "subtle", -] - -[[package]] -name = "aes-gcm" -version = "0.10.2" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "209b47e8954a928e1d72e86eca7000ebb6655fe1436d33eefc2201cad027e237" +checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1" dependencies = [ - "aead 0.5.2", - "aes 0.8.3", - "cipher 0.4.4", - "ctr 0.9.2", - "ghash 0.5.0", + "aead", + "aes", + "cipher", + "ctr", + "ghash", "subtle", ] [[package]] name = "ahash" -version = "0.7.6" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" dependencies = [ - "getrandom 0.2.10", + "getrandom 0.2.15", "once_cell", "version_check", ] [[package]] name = "ahash" -version = "0.8.3" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", - "getrandom 0.2.10", "once_cell", "version_check", + "zerocopy 0.7.35", ] [[package]] name = "aho-corasick" -version = "1.0.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] @@ -136,9 +113,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.16" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "android-tzdata" @@ -148,20 +125,19 @@ checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" [[package]] name = "android_log-sys" -version = "0.2.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85965b6739a430150bdd138e2374a98af0c3ee0d030b3bb7fc3bddff58d0102e" +checksum = "84521a3cf562bc62942e294181d9eef17eb38ceb8c68677bc49f144e4c3d4f8d" [[package]] name = "android_logger" -version = "0.11.3" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8619b80c242aa7bd638b5c7ddd952addeecb71f69c75e33f1d47b2804f8f883a" +checksum = "f6f39be698127218cca460cb624878c9aa4e2b47dba3b277963d2bf00bad263b" dependencies = [ "android_log-sys", - "env_logger", + "env_filter", "log", - "once_cell", ] [[package]] @@ -175,62 +151,63 @@ dependencies = [ [[package]] name = "anstream" -version = "0.3.2" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", - "is-terminal", + "is_terminal_polyfill", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.1" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" [[package]] name = "anstyle-parse" -version = "0.2.1" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" +checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.59.0", ] [[package]] name = "anstyle-wincon" -version = "1.0.1" +version = "3.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" +checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" dependencies = [ "anstyle", - "windows-sys 0.48.0", + "once_cell", + "windows-sys 0.59.0", ] [[package]] name = "anyhow" -version = "1.0.72" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854" +checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" [[package]] name = "api" -version = "2.0.0-alpha.5" +version = "2.0.26" dependencies = [ "log", "serde", @@ -238,20 +215,27 @@ dependencies = [ "tauri", "tauri-build", "tauri-plugin-barcode-scanner", + "tauri-plugin-biometric", "tauri-plugin-cli", "tauri-plugin-clipboard-manager", "tauri-plugin-dialog", "tauri-plugin-fs", + "tauri-plugin-geolocation", "tauri-plugin-global-shortcut", + "tauri-plugin-haptics", "tauri-plugin-http", "tauri-plugin-log", + "tauri-plugin-nfc", "tauri-plugin-notification", + "tauri-plugin-opener", "tauri-plugin-os", "tauri-plugin-process", "tauri-plugin-shell", + "tauri-plugin-store", "tauri-plugin-updater", - "tiny_http 0.11.0", - "window-shadows", + "tauri-plugin-window-state", + "time", + "tiny_http", ] [[package]] @@ -263,41 +247,74 @@ dependencies = [ "tauri", "tauri-build", "tauri-plugin-updater", - "time 0.3.24", - "tiny_http 0.11.0", + "time", + "tiny_http", +] + +[[package]] +name = "app-updater-v2" +version = "0.1.0" +dependencies = [ + "serde", + "serde_json", + "tauri", + "tauri-build", + "tauri-plugin-updater", + "tiny_http", +] + +[[package]] +name = "app_settings_manager" +version = "0.0.0" +dependencies = [ + "serde", + "serde_json", + "tauri", + "tauri-build", + "tauri-plugin-store", +] + +[[package]] +name = "arbitrary" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dde20b3d026af13f561bdd0f15edf01fc734f0dafcedbaf42bba506a9517f223" +dependencies = [ + "derive_arbitrary", ] [[package]] name = "arboard" -version = "3.2.0" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6041616acea41d67c4a984709ddab1587fd0b10efe5cc563fee954d2f011854" +checksum = "c1df21f715862ede32a0c525ce2ca4d52626bb0007f8c18b87a384503ac33e70" dependencies = [ "clipboard-win", - "core-graphics 0.22.3", "image", "log", - "objc", - "objc-foundation", - "objc_id", - "once_cell", + "objc2 0.6.0", + "objc2-app-kit", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-foundation 0.3.0", "parking_lot", - "thiserror", - "winapi", + "percent-encoding", + "windows-sys 0.59.0", + "wl-clipboard-rs", "x11rb", ] [[package]] name = "arrayref" -version = "0.3.7" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" [[package]] name = "arrayvec" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" [[package]] name = "ascii" @@ -305,6 +322,24 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d92bec98840b8f03a5ff5413de5293bfcd8bf96467cf5452609f939ec6f5de16" +[[package]] +name = "ashpd" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6cbdf310d77fd3aaee6ea2093db7011dc2d35d2eb3481e5607f1f8d942ed99df" +dependencies = [ + "enumflags2", + "futures-channel", + "futures-util", + "rand 0.9.0", + "raw-window-handle", + "serde", + "serde_repr", + "tokio", + "url", + "zbus", +] + [[package]] name = "assert-json-diff" version = "2.0.2" @@ -317,30 +352,33 @@ dependencies = [ [[package]] name = "async-broadcast" -version = "0.5.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c48ccdbf6ca6b121e0f586cbc0e73ae440e56c67c30fa0873b4e110d9c26d2b" +checksum = "435a87a52755b8f27fcf321ac4f04b2802e337c8c4872923137471ec39c37532" dependencies = [ "event-listener", + "event-listener-strategy", "futures-core", + "pin-project-lite", ] [[package]] name = "async-channel" -version = "1.9.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" +checksum = "89b47800b0be77592da0afd425cc03468052844aff33b84e33cc696f64e77b6a" dependencies = [ "concurrent-queue", - "event-listener", + "event-listener-strategy", "futures-core", + "pin-project-lite", ] [[package]] name = "async-compression" -version = "0.4.1" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b74f44609f0f91493e3082d3734d98497e094777144380ea4db9f9905dd5b6" +checksum = "59a194f9d963d8099596278594b3107448656ba73831c9d8c783e613ce86da64" dependencies = [ "brotli", "flate2", @@ -348,126 +386,145 @@ dependencies = [ "memchr", "pin-project-lite", "tokio", + "zstd", + "zstd-safe", ] [[package]] name = "async-executor" -version = "1.5.1" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fa3dc5f2a8564f07759c008b9109dc0d39de92a88d5588b8a5036d286383afb" +checksum = "30ca9a001c1e8ba5149f91a74362376cc6bc5b919d92d988668657bd570bdcec" dependencies = [ - "async-lock", "async-task", "concurrent-queue", - "fastrand 1.9.0", + "fastrand", "futures-lite", "slab", ] [[package]] name = "async-fs" -version = "1.6.0" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "279cf904654eeebfa37ac9bb1598880884924aab82e290aa65c9e77a0e142e06" +checksum = "ebcd09b382f40fcd159c2d695175b2ae620ffa5f3bd6f664131efff4e8b9e04a" dependencies = [ "async-lock", - "autocfg", "blocking", "futures-lite", ] [[package]] name = "async-io" -version = "1.13.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" +checksum = "43a2b323ccce0a1d90b449fd71f2a06ca7faa7c54c2751f06c9bd851fc061059" dependencies = [ "async-lock", - "autocfg", "cfg-if", "concurrent-queue", + "futures-io", "futures-lite", - "log", "parking", "polling", - "rustix 0.37.23", + "rustix 0.38.44", "slab", - "socket2 0.4.9", - "waker-fn", + "tracing", + "windows-sys 0.59.0", ] [[package]] name = "async-lock" -version = "2.7.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa24f727524730b077666307f2734b4a1a1c57acb79193127dcc8914d5242dd7" +checksum = "ff6e472cdea888a4bd64f342f09b3f50e1886d32afe8df3d663c01140b811b18" dependencies = [ "event-listener", + "event-listener-strategy", + "pin-project-lite", ] [[package]] name = "async-process" -version = "1.7.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a9d28b1d97e08915212e2e45310d47854eafa69600756fc735fb788f75199c9" +checksum = "63255f1dc2381611000436537bbedfe83183faa303a5a0edaf191edef06526bb" dependencies = [ + "async-channel", "async-io", "async-lock", - "autocfg", + "async-signal", + "async-task", "blocking", "cfg-if", "event-listener", "futures-lite", - "rustix 0.37.23", - "signal-hook", - "windows-sys 0.48.0", + "rustix 0.38.44", + "tracing", ] [[package]] name = "async-recursion" -version = "1.0.4" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e97ce7de6cf12de5d7226c73f5ba9811622f4db3a5b91b55c53e987e5f91cba" +checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.100", +] + +[[package]] +name = "async-signal" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "637e00349800c0bdf8bfc21ebbc0b6524abea702b0da4168ac00d070d0c0b9f3" +dependencies = [ + "async-io", + "async-lock", + "atomic-waker", + "cfg-if", + "futures-core", + "futures-io", + "rustix 0.38.44", + "signal-hook-registry", + "slab", + "windows-sys 0.59.0", ] [[package]] name = "async-task" -version = "4.4.0" +version = "4.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc7ab41815b3c653ccd2978ec3255c81349336702dfdf62ee6f7069b12a3aae" +checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" [[package]] name = "async-trait" -version = "0.1.72" +version = "0.1.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc6dde6e4ed435a4c1ee4e73592f5ba9da2151af10076cc04858746af9352d09" +checksum = "e539d3fca749fcee5236ab05e93a52867dd549cc157c8cb7f99595f3cedffdb5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.100", ] [[package]] name = "atk" -version = "0.16.0" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39991bc421ddf72f70159011b323ff49b0f783cc676a7287c59453da2e2531cf" +checksum = "241b621213072e993be4f6f3a9e4b45f65b7e6faad43001be957184b7bb1824b" dependencies = [ "atk-sys", - "bitflags 1.3.2", "glib", "libc", ] [[package]] name = "atk-sys" -version = "0.16.0" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11ad703eb64dc058024f0e57ccfa069e15a413b98dbd50a1a950e743b7f11148" +checksum = "c5e48b684b0ca77d2bbadeef17424c2ea3c897d44d566a1617e7e8f30614d086" dependencies = [ "glib-sys", "gobject-sys", @@ -486,64 +543,47 @@ dependencies = [ [[package]] name = "atomic-waker" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1181e1e0d1fce796a03db1ae795d67167da795f9cf4a39c37589e85ef57f26d3" - -[[package]] -name = "authenticator" -version = "0.3.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08cee7a0952628fde958e149507c2bb321ab4fccfafd225da0b20adc956ef88a" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "devd-rs", - "libc", - "libudev", - "log", - "rand 0.7.3", - "runloop", - "winapi", -] +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "auto-launch" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5904a4d734f0235edf29aab320a14899f3e090446e594ff96508a6215f76f89c" +checksum = "1f012b8cc0c850f34117ec8252a44418f2e34a2cf501de89e29b241ae5f79471" dependencies = [ - "dirs", - "thiserror", + "dirs 4.0.0", + "thiserror 1.0.69", "winreg 0.10.1", ] [[package]] name = "autocfg" -version = "1.1.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "backtrace" -version = "0.3.68" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" dependencies = [ "addr2line", - "cc", "cfg-if", "libc", "miniz_oxide", "object", "rustc-demangle", + "windows-targets 0.52.6", ] [[package]] -name = "base64" -version = "0.11.0" +name = "base16ct" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" [[package]] name = "base64" @@ -553,9 +593,15 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.2" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "base64" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "base64ct" @@ -580,77 +626,122 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.3.3" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" +checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" dependencies = [ "serde", ] +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + [[package]] name = "blake2" version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" dependencies = [ - "digest 0.10.7", + "digest", ] [[package]] name = "blake2b_simd" -version = "1.0.1" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c2f0dc9a68c6317d884f97cc36cf5a3d20ba14ce404227df55e1af708ab04bc" +checksum = "06e903a20b159e944f91ec8499fe1e55651480c541ea0a584f5d967c49ad9d99" dependencies = [ "arrayref", "arrayvec", - "constant_time_eq 0.2.6", + "constant_time_eq 0.3.1", ] [[package]] -name = "block" -version = "0.1.6" +name = "block-buffer" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] [[package]] -name = "block-buffer" -version = "0.9.0" +name = "block-padding" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +checksum = "a8894febbff9f758034a5b8e12d87918f56dfc64a8e1fe757d65e29041538d93" dependencies = [ "generic-array", ] [[package]] -name = "block-buffer" -version = "0.10.4" +name = "block2" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +checksum = "2c132eebf10f5cad5289222520a4a058514204aed6d791f1cf4fe8088b82d15f" dependencies = [ - "generic-array", + "objc2 0.5.2", +] + +[[package]] +name = "block2" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d59b4c170e16f0405a2e95aff44432a0d41aa97675f3d52623effe95792a037" +dependencies = [ + "objc2 0.6.0", ] [[package]] name = "blocking" -version = "1.3.1" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77231a1c8f801696fc0123ec6150ce92cffb8e164a02afb9c8ddee0e9b65ad65" +checksum = "703f41c54fc768e63e091340b424302bb1c29ef4aa0c7f10fe849dfb114d29ea" dependencies = [ "async-channel", - "async-lock", "async-task", - "atomic-waker", - "fastrand 1.9.0", + "futures-io", "futures-lite", - "log", + "piper", +] + +[[package]] +name = "borsh" +version = "1.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad8646f98db542e39fc66e68a20b2144f6a732636df7c2354e74645faaa433ce" +dependencies = [ + "borsh-derive", + "cfg_aliases", +] + +[[package]] +name = "borsh-derive" +version = "1.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdd1d3c0c2f5833f22386f252fe8ed005c7f59fdcddeef025c01b4c3b9fd9ac3" +dependencies = [ + "once_cell", + "proc-macro-crate 3.3.0", + "proc-macro2", + "quote", + "syn 2.0.100", ] [[package]] name = "brotli" -version = "3.3.4" +version = "7.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1a0b1dbcc8ae29329621f8d4f0d835787c1c38bb1401979b49d13b0b305ff68" +checksum = "cc97b8f16f944bba54f0433f07e30be199b6dc2bd25937444bbad560bcea29bd" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -659,9 +750,9 @@ dependencies = [ [[package]] name = "brotli-decompressor" -version = "2.3.4" +version = "4.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b6561fd3f895a11e8f72af2cb7d22e08366bebc2b6b57f7744c4bda27034744" +checksum = "74fa05ad7d803d413eb8380983b092cbbaf9a85f151b871360e7b00cd7060b37" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -669,104 +760,132 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.13.0" +version = "3.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" +checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" [[package]] name = "byte-unit" -version = "4.0.19" +version = "5.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da78b32057b8fdfc352504708feeba7216dcd65a2c9ab02978cbd288d1279b6c" +checksum = "e1cd29c3c585209b0cbc7309bfe3ed7efd8c84c21b7af29c8bfae908f8777174" dependencies = [ + "rust_decimal", "serde", "utf8-width", ] [[package]] -name = "bytemuck" -version = "1.13.1" +name = "bytecheck" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea" +checksum = "23cdc57ce23ac53c931e88a43d06d070a6fd142f2617be5855eb75efc9beb1c2" +dependencies = [ + "bytecheck_derive", + "ptr_meta", + "simdutf8", +] [[package]] -name = "byteorder" -version = "1.4.3" +name = "bytecheck_derive" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "3db406d29fbcd95542e92559bed4d8ad92636d1ca8b3b72ede10b4bcc010e659" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] [[package]] -name = "bytes" -version = "0.4.12" +name = "bytemuck" +version = "1.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" -dependencies = [ - "byteorder", - "iovec", -] +checksum = "b6b1fc10dbac614ebc03540c9dbd60e83887fda27794998c6528f1782047d540" [[package]] -name = "bytes" -version = "1.4.0" +name = "byteorder" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" -dependencies = [ - "serde", -] +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] -name = "bzip2" -version = "0.4.4" +name = "byteorder-lite" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdb116a6ef3f6c3698828873ad02c3014b3c85cadb88496095628e3ef1e347f8" -dependencies = [ - "bzip2-sys", - "libc", -] +checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" [[package]] -name = "bzip2-sys" -version = "0.1.11+1.0.8" +name = "bytes" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" +checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" dependencies = [ - "cc", - "libc", - "pkg-config", + "serde", ] [[package]] name = "cairo-rs" -version = "0.16.7" +version = "0.18.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3125b15ec28b84c238f6f476c6034016a5f6cc0221cb514ca46c532139fc97d" +checksum = "8ca26ef0159422fb77631dc9d17b102f253b876fe1586b03b803e63a309b4ee2" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.9.0", "cairo-sys-rs", - "freetype-rs", "glib", "libc", "once_cell", - "thiserror", + "thiserror 1.0.69", ] [[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", "libc", "system-deps", - "x11", +] + +[[package]] +name = "camino" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b96ec4966b5813e2c0507c1f86115c8c5abaadc3980879c3424042a02fd1ad3" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-platform" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24b1f0365a6c6bb4020cd05806fd0d33c44d38046b8bd7f0e40814b9763cabfc" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afc309ed89476c8957c50fb818f56fe894db857866c3e163335faa91dc34eb85" +dependencies = [ + "camino", + "cargo-platform", + "semver", + "serde", + "serde_json", + "thiserror 1.0.69", ] [[package]] name = "cargo_toml" -version = "0.15.3" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "599aa35200ffff8f04c1925aa1acc92fa2e08874379ef42e210a80e527e60838" +checksum = "02260d489095346e5cafd04dea8e8cb54d1d74fcd759022a9b72986ebe9a1257" dependencies = [ "serde", "toml", @@ -774,11 +893,13 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.79" +version = "1.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "8e3a13707ac958681c13b39b458c073d0d9bc8a22cb1b2f4c8e55eb72c13f362" dependencies = [ "jobserver", + "libc", + "shlex", ] [[package]] @@ -800,9 +921,9 @@ dependencies = [ [[package]] name = "cfg-expr" -version = "0.15.4" +version = "0.15.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b40ccee03b5175c18cde8f37e7d2a33bcef6f8ec8f7cc0d81090d1bb380949c9" +checksum = "d067ad48b8650848b989a59a86c6c36a995d02d2bf778d45c3c5d57bc2718f02" dependencies = [ "smallvec", "target-lexicon", @@ -814,61 +935,54 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + [[package]] name = "chacha20" -version = "0.8.2" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c80e5460aa66fe3b91d40bcbdab953a597b60053e34d684ac6903f863b680a6" +checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" dependencies = [ "cfg-if", - "cipher 0.3.0", + "cipher", "cpufeatures", - "zeroize", ] [[package]] name = "chacha20poly1305" -version = "0.9.1" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18446b09be63d457bbec447509e85f662f32952b035ce892290396bc0b0cff5" +checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35" dependencies = [ - "aead 0.4.3", + "aead", "chacha20", - "cipher 0.3.0", + "cipher", "poly1305", "zeroize", ] [[package]] name = "chrono" -version = "0.4.26" +version = "0.4.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" +checksum = "1a7964611d71df112cb1730f2ee67324fcf4d0fc6606acbbe9bfe06df124637c" dependencies = [ "android-tzdata", "iana-time-zone", - "js-sys", "num-traits", "serde", - "time 0.1.45", - "wasm-bindgen", - "winapi", + "windows-link", ] [[package]] name = "chunked_transfer" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cca491388666e04d7248af3f60f0c40cfb0991c72205595d7c396e3510207d1a" - -[[package]] -name = "cipher" -version = "0.3.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" -dependencies = [ - "generic-array", -] +checksum = "6e4de3bc4ea267985becf712dc6d9eed8b04c953b3fcfb339ebc87acd9804901" [[package]] name = "cipher" @@ -878,22 +992,23 @@ checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" dependencies = [ "crypto-common", "inout", + "zeroize", ] [[package]] name = "clap" -version = "4.3.19" +version = "4.5.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fd304a20bff958a57f04c4e96a2e7594cc4490a0e809cbd48bb6437edaa452d" +checksum = "2df961d8c8a0d08aa9945718ccf584145eee3f3aa06cddbeac12933781102e04" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.3.19" +version = "4.5.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01c6a3f08f1fe5662a35cfe393aec09c4df95f60ee93b7556505260f75eee9e1" +checksum = "132dbda40fb6753878316a489d5a1242a8ef2f0d9e47ba01c951ea8aa7d013a5" dependencies = [ "anstream", "anstyle", @@ -903,136 +1018,90 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.5.0" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" [[package]] name = "clipboard-win" -version = "4.5.0" +version = "5.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7191c27c2357d9b7ef96baac1773290d4ca63b24205b82a3fd8a0637afcf0362" +checksum = "15efe7a882b08f34e38556b14f2fb3daa98769d06c7f0c1b076dfd0d983bc892" dependencies = [ "error-code", - "str-buf", - "winapi", ] [[package]] -name = "cmake" -version = "0.1.50" +name = "color-backtrace" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" +checksum = "2123a5984bd52ca861c66f66a9ab9883b27115c607f801f86c1bc2a84eb69f0f" dependencies = [ - "cc", + "backtrace", + "termcolor", ] [[package]] -name = "cocoa" -version = "0.24.1" +name = "colorchoice" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f425db7937052c684daec3bd6375c8abe2d146dca4b8b143d6db777c39138f3a" -dependencies = [ - "bitflags 1.3.2", - "block", - "cocoa-foundation", - "core-foundation", - "core-graphics 0.22.3", - "foreign-types 0.3.2", - "libc", - "objc", -] +checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] -name = "cocoa" -version = "0.25.0" +name = "colored" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6140449f97a6e97f9511815c5632d84c8aacf8ac271ad77c559218161a1373c" +checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c" dependencies = [ - "bitflags 1.3.2", - "block", - "cocoa-foundation", - "core-foundation", - "core-graphics 0.23.1", - "foreign-types 0.5.0", - "libc", - "objc", + "lazy_static", + "windows-sys 0.59.0", ] [[package]] -name = "cocoa-foundation" -version = "0.1.1" +name = "combine" +version = "4.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "931d3837c286f56e3c58423ce4eba12d08db2374461a785c86f672b08b5650d6" +checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd" dependencies = [ - "bitflags 1.3.2", - "block", - "core-foundation", - "core-graphics-types", - "foreign-types 0.3.2", - "libc", - "objc", + "bytes", + "memchr", ] [[package]] -name = "color_quant" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" - -[[package]] -name = "colorchoice" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" - -[[package]] -name = "colored" -version = "1.9.4" +name = "concurrent-queue" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a5f741c91823341bebf717d4c71bda820630ce065443b58bd1b7451af008355" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" dependencies = [ - "is-terminal", - "lazy_static", - "winapi", + "crossbeam-utils", ] [[package]] -name = "colored" -version = "2.0.4" +name = "const-oid" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2674ec482fbc38012cf31e6c42ba0177b431a0cb6f15fe40efa5aab1bda516f6" -dependencies = [ - "is-terminal", - "lazy_static", - "windows-sys 0.48.0", -] +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" [[package]] -name = "combine" -version = "4.6.6" +name = "const-random" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4" +checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359" dependencies = [ - "bytes 1.4.0", - "memchr", + "const-random-macro", ] [[package]] -name = "concurrent-queue" -version = "2.2.0" +name = "const-random-macro" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62ec6771ecfa0762d24683ee5a32ad78487a3d3afdc0fb8cae19d2c5deb50b7c" +checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" dependencies = [ - "crossbeam-utils", + "getrandom 0.2.15", + "once_cell", + "tiny-keccak", ] -[[package]] -name = "const-oid" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "795bc6e66a8e340f075fcf6227e417a2dc976b92b91f3cdc778bb858778b6747" - [[package]] name = "constant_time_eq" version = "0.1.5" @@ -1041,9 +1110,9 @@ checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" [[package]] name = "constant_time_eq" -version = "0.2.6" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21a53c0a4d288377e7415b53dcfc3c04da5cdc2cc95c8d5ac178b58f0b861ad6" +checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" [[package]] name = "convert_case" @@ -1053,37 +1122,48 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" [[package]] name = "cookie" -version = "0.16.2" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e859cd57d0710d9e06c381b550c06e76992472a8c6d527aecd2fc673dcc231fb" +checksum = "4ddef33a339a91ea89fb53151bd0a4689cfce27055c291dfa69945475d22c747" dependencies = [ "percent-encoding", - "time 0.3.24", + "time", "version_check", ] [[package]] name = "cookie_store" -version = "0.16.2" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d606d0fba62e13cf04db20536c05cb7f13673c161cb47a47a82b9b9e7d3f1daa" +checksum = "2eac901828f88a5241ee0600950ab981148a18f2f756900ffba1b125ca6a3ef9" dependencies = [ "cookie", - "idna 0.2.3", + "document-features", + "idna", "log", "publicsuffix", "serde", "serde_derive", "serde_json", - "time 0.3.24", + "time", "url", ] [[package]] name = "core-foundation" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b55271e5c8c478ad3f38ad24ef34923091e0548492a266d19b3c0b4d82574c63" dependencies = [ "core-foundation-sys", "libc", @@ -1091,107 +1171,116 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.4" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "core-graphics" -version = "0.22.3" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb" +checksum = "fa95a34622365fa5bbf40b20b75dba8dfa8c94c734aea8ac9a5ca38af14316f1" dependencies = [ - "bitflags 1.3.2", - "core-foundation", + "bitflags 2.9.0", + "core-foundation 0.10.0", "core-graphics-types", - "foreign-types 0.3.2", + "foreign-types 0.5.0", "libc", ] [[package]] -name = "core-graphics" -version = "0.23.1" +name = "core-graphics-types" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "970a29baf4110c26fedbc7f82107d42c23f7e88e404c4577ed73fe99ff85a212" +checksum = "3d44a101f213f6c4cdc1853d4b78aef6db6bdfa3468798cc1d9912f4735013eb" dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "core-graphics-types", - "foreign-types 0.5.0", + "bitflags 2.9.0", + "core-foundation 0.10.0", "libc", ] [[package]] -name = "core-graphics-types" -version = "0.1.2" +name = "core2" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bb142d41022986c1d8ff29103a1411c8a3dfad3552f87a4f8dc50d61d4f4e33" +checksum = "b49ba7ef1ad6107f8824dbe97de947cbaac53c44e7f9756a1fba0d37c1eec505" dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "libc", + "memchr", ] [[package]] name = "cpufeatures" -version = "0.2.9" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" dependencies = [ "libc", ] [[package]] name = "crc" -version = "3.0.1" +version = "3.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86ec7a15cbe22e59248fc7eadb1907dab5ba09372595da4d73dd805ed4417dfe" +checksum = "69e6e4d7b33a94f0991c26729976b10ebde1d34c3ee82408fb536164fa10d636" dependencies = [ "crc-catalog", ] [[package]] name = "crc-catalog" -version = "2.2.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cace84e55f07e7301bae1c519df89cdad8cc3cd868413d3fdbdeca9ff3db484" +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" [[package]] name = "crc32fast" -version = "1.3.2" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" dependencies = [ "cfg-if", ] [[package]] name = "crossbeam-channel" -version = "0.5.8" +version = "0.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" +checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2" dependencies = [ - "cfg-if", "crossbeam-utils", ] [[package]] name = "crossbeam-queue" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add" +checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115" dependencies = [ - "cfg-if", "crossbeam-utils", ] [[package]] name = "crossbeam-utils" -version = "0.8.16" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" + +[[package]] +name = "crunchy" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929" + +[[package]] +name = "crypto-bigint" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ - "cfg-if", + "generic-array", + "rand_core 0.6.4", + "subtle", + "zeroize", ] [[package]] @@ -1229,26 +1318,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331" dependencies = [ "quote", - "syn 2.0.28", + "syn 2.0.100", ] [[package]] name = "ctor" -version = "0.2.5" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37e366bff8cd32dd8754b0991fb66b279dc48f598c3a18914852a6673deef583" +checksum = "32a2785755761f3ddc1492979ce1e48d2c00d09311c39e4466429188f3dd6501" dependencies = [ "quote", - "syn 2.0.28", -] - -[[package]] -name = "ctr" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a232f92a03f37dd7d7dd2adc67166c77e9cd88de5b019b9a9eecfaeaf7bfd481" -dependencies = [ - "cipher 0.3.0", + "syn 2.0.100", ] [[package]] @@ -1257,27 +1337,41 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" dependencies = [ - "cipher 0.4.4", + "cipher", ] [[package]] name = "curve25519-dalek" -version = "3.2.0" +version = "4.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" +checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" dependencies = [ - "byteorder", - "digest 0.9.0", - "rand_core 0.5.1", + "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "digest", + "fiat-crypto", + "rustc_version", "subtle", "zeroize", ] +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + [[package]] name = "darling" -version = "0.20.3" +version = "0.20.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" +checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" dependencies = [ "darling_core", "darling_macro", @@ -1285,57 +1379,66 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.3" +version = "0.20.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621" +checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", "strsim", - "syn 2.0.28", + "syn 2.0.100", ] [[package]] name = "darling_macro" -version = "0.20.3" +version = "0.20.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" +checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" dependencies = [ "darling_core", "quote", - "syn 2.0.28", + "syn 2.0.100", ] +[[package]] +name = "dary_heap" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04d2cd9c18b9f454ed67da600630b021a8a80bf33f8c95896ab33aaf1c26b728" + [[package]] name = "data-encoding" -version = "2.4.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" +checksum = "2a2330da5de22e8a3cb63252ce2abb30116bf5265e89c0e01bc17015ce30a476" [[package]] name = "data-url" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41b319d1b62ffbd002e057f36bebd1f42b9f97927c9577461d855f3513c4289f" +checksum = "5c297a1c74b71ae29df00c3e22dd9534821d60eb9af5a0192823fa2acea70c2a" [[package]] name = "deep-link-example" version = "0.0.0" dependencies = [ + "log", "serde", "serde_json", "tauri", "tauri-build", "tauri-plugin-deep-link", + "tauri-plugin-log", + "tauri-plugin-single-instance", ] [[package]] name = "der" -version = "0.7.7" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c7ed52955ce76b1554f509074bb357d3fb8ac9b51288a65a3fd480d1dfba946" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" dependencies = [ "const-oid", "pem-rfc7468", @@ -1344,54 +1447,36 @@ dependencies = [ [[package]] name = "deranged" -version = "0.3.6" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8810e7e2cf385b1e9b50d68264908ec367ba642c96d02edfe61c39e88e2a3c01" +checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e" dependencies = [ + "powerfmt", "serde", ] [[package]] -name = "derivative" -version = "2.2.0" +name = "derive_arbitrary" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +checksum = "30542c1ad912e0e3d22a1935c290e12e8a29d704a420177a31faad4a601a0800" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.100", ] [[package]] name = "derive_more" -version = "0.99.17" +version = "0.99.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +checksum = "3da29a38df43d6f156149c9b43ded5e018ddff2a855cf2cfd62e8cd7d079c69f" dependencies = [ "convert_case", "proc-macro2", "quote", "rustc_version", - "syn 1.0.109", -] - -[[package]] -name = "devd-rs" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9313f104b590510b46fc01c0a324fc76505c13871454d3c48490468d04c8d395" -dependencies = [ - "libc", - "nom", -] - -[[package]] -name = "digest" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" -dependencies = [ - "generic-array", + "syn 2.0.100", ] [[package]] @@ -1400,7 +1485,7 @@ version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "block-buffer 0.10.4", + "block-buffer", "const-oid", "crypto-common", "subtle", @@ -1412,7 +1497,16 @@ version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" dependencies = [ - "dirs-sys", + "dirs-sys 0.3.7", +] + +[[package]] +name = "dirs" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e" +dependencies = [ + "dirs-sys 0.5.0", ] [[package]] @@ -1432,10 +1526,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" dependencies = [ "libc", - "redox_users", + "redox_users 0.4.6", "winapi", ] +[[package]] +name = "dirs-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab" +dependencies = [ + "libc", + "option-ext", + "redox_users 0.5.0", + "windows-sys 0.59.0", +] + [[package]] name = "dirs-sys-next" version = "0.1.2" @@ -1443,7 +1549,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" dependencies = [ "libc", - "redox_users", + "redox_users 0.4.6", "winapi", ] @@ -1454,66 +1560,195 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b" [[package]] -name = "dotenvy" -version = "0.15.7" +name = "dispatch2" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" +checksum = "1a0d569e003ff27784e0e14e4a594048698e0c0f0b66cabcb51511be55a7caa0" +dependencies = [ + "bitflags 2.9.0", + "block2 0.6.0", + "libc", + "objc2 0.6.0", +] [[package]] -name = "dtoa" -version = "1.0.9" +name = "displaydoc" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcbb2bf8e87535c23f7a8a321e364ce21462d0ff10cb6407820e8e96dfff6653" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] [[package]] -name = "dtoa-short" -version = "0.3.4" +name = "dlopen2" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbaceec3c6e4211c79e7b1800fb9680527106beb2f9c51904a3210c03a448c74" +checksum = "9e1297103d2bbaea85724fcee6294c2d50b1081f9ad47d0f6f6f61eda65315a6" dependencies = [ - "dtoa", + "dlopen2_derive", + "libc", + "once_cell", + "winapi", ] [[package]] -name = "dunce" -version = "1.0.4" +name = "dlopen2_derive" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" - -[[package]] -name = "ed25519-zebra" -version = "3.1.0" +checksum = "f2b99bf03862d7f545ebc28ddd33a665b50865f4dfd84031a393823879bd4c54" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + +[[package]] +name = "dlv-list" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "442039f5147480ba31067cb00ada1adae6892028e40e45fc5de7b7df6dcc1b5f" +dependencies = [ + "const-random", +] + +[[package]] +name = "document-features" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95249b50c6c185bee49034bcb378a49dc2b5dff0be90ff6616d31d64febab05d" +dependencies = [ + "litrs", +] + +[[package]] +name = "dotenvy" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" + +[[package]] +name = "downcast-rs" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" + +[[package]] +name = "dpi" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f25c0e292a7ca6d6498557ff1df68f32c99850012b6ea401cf8daf771f22ff53" +dependencies = [ + "serde", +] + +[[package]] +name = "dtoa" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6add3b8cff394282be81f3fc1a0605db594ed69890078ca6e2cab1c408bcf04" + +[[package]] +name = "dtoa-short" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd1511a7b6a56299bd043a9c167a6d2bfb37bf84a6dfceaba651168adfb43c87" +dependencies = [ + "dtoa", +] + +[[package]] +name = "dunce" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" + +[[package]] +name = "dyn-clone" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c7a8fb8a9fbf66c1f703fe16184d10ca0ee9d23be5b4436400408ba54a95005" + +[[package]] +name = "ecdsa" +version = "0.16.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" +dependencies = [ + "der", + "digest", + "elliptic-curve", + "rfc6979", + "signature", + "spki", +] + +[[package]] +name = "ed25519" +version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" +dependencies = [ + "signature", +] + +[[package]] +name = "ed25519-zebra" +version = "4.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d9ce6874da5d4415896cd45ffbc4d1cfc0c4f9c079427bd870742c30f2f65a9" dependencies = [ "curve25519-dalek", - "hashbrown 0.12.3", + "ed25519", + "hashbrown 0.14.5", "hex", "rand_core 0.6.4", - "sha2 0.9.9", + "sha2", "zeroize", ] [[package]] name = "either" -version = "1.9.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" dependencies = [ "serde", ] +[[package]] +name = "elliptic-curve" +version = "0.13.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" +dependencies = [ + "base16ct", + "crypto-bigint", + "digest", + "ff", + "generic-array", + "group", + "pkcs8", + "rand_core 0.6.4", + "sec1", + "subtle", + "zeroize", +] + [[package]] name = "embed-resource" -version = "2.2.0" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7f1e82a60222fc67bfd50d752a9c89da5cce4c39ed39decc84a443b07bbd69a" +checksum = "7fbc6e0d8e0c03a655b53ca813f0463d2c956bc4db8138dbc89f120b066551e3" dependencies = [ "cc", + "memchr", "rustc_version", "toml", "vswhom", - "winreg 0.11.0", + "winreg 0.52.0", ] [[package]] @@ -1524,30 +1759,24 @@ checksum = "4ef6b89e5b37196644d8796de5268852ff179b44e96276cf4290264843743bb7" [[package]] name = "encoding_rs" -version = "0.8.32" +version = "0.8.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" dependencies = [ "cfg-if", ] [[package]] -name = "enum-as-inner" -version = "0.5.1" +name = "endi" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9720bba047d567ffc8a3cba48bf19126600e249ab7f128e9233e6376976a116" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn 1.0.109", -] +checksum = "a3d8a32ae18130a3c84dd492d4215c3d913c3b07c6b63c2eb3eb7ff1101ab7bf" [[package]] name = "enumflags2" -version = "0.7.7" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c041f5090df68b32bcd905365fd51769c8b9d553fe87fde0b683534f10c01bd2" +checksum = "ba2f4b465f5318854c6f8dd686ede6c0a9dc67d4b1ac241cf0eb51521a309147" dependencies = [ "enumflags2_derive", "serde", @@ -1555,20 +1784,20 @@ dependencies = [ [[package]] name = "enumflags2_derive" -version = "0.7.7" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e9a1f9f7d83e59740248a6e14ecf93929ade55027844dfcea78beafccc15745" +checksum = "fc4caf64a58d7a6d65ab00639b046ff54399a39f5f2554728895ace4b297cd79" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.100", ] [[package]] -name = "env_logger" -version = "0.10.0" +name = "env_filter" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0" dependencies = [ "log", "regex", @@ -1576,40 +1805,35 @@ dependencies = [ [[package]] name = "equivalent" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] -name = "errno" -version = "0.3.2" +name = "erased-serde" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f" +checksum = "e004d887f51fcb9fef17317a2f3525c887d8aa3f4f50fed920816a688284a5b7" dependencies = [ - "errno-dragonfly", - "libc", - "windows-sys 0.48.0", + "serde", + "typeid", ] [[package]] -name = "errno-dragonfly" -version = "0.1.2" +name = "errno" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +checksum = "976dd42dc7e85965fe702eb8164f21f450704bdde31faefd6471dba214cb594e" dependencies = [ - "cc", "libc", + "windows-sys 0.59.0", ] [[package]] name = "error-code" -version = "2.3.1" +version = "3.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64f18991e7bf11e7ffee451b5318b5c1a73c52d0d0ada6e5a3017c8c1ced6a21" -dependencies = [ - "libc", - "str-buf", -] +checksum = "a5d9305ccc6942a704f4335694ecd3de2ea531b114ac2d51f5f843750787a92f" [[package]] name = "etcetera" @@ -1624,71 +1848,108 @@ dependencies = [ [[package]] name = "event-listener" -version = "2.5.3" +version = "5.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" +checksum = "3492acde4c3fc54c845eaab3eed8bd00c7a7d881f78bfc801e43a93dec1331ae" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] [[package]] -name = "fastrand" -version = "1.9.0" +name = "event-listener-strategy" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" +checksum = "8be9f3dfaaffdae2972880079a491a1a8bb7cbed0b8dd7a347f668b4150a3b93" dependencies = [ - "instant", + "event-listener", + "pin-project-lite", ] [[package]] name = "fastrand" -version = "2.0.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "fdeflate" -version = "0.3.0" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d329bdeac514ee06249dabc27877490f17f5d371ec693360768b838e19f3ae10" +checksum = "1e6853b52649d4ac5c0bd02320cddc5ba956bdb407c4b75a2c6b75bf51500f8c" dependencies = [ "simd-adler32", ] [[package]] name = "fern" -version = "0.6.2" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9f0c14694cbd524c8720dd69b0e3179344f04ebb5f90f2e4a440c6ea3b2f1ee" +checksum = "4316185f709b23713e41e3195f90edef7fb00c3ed4adc79769cf09cc762a3b29" dependencies = [ - "colored 1.9.4", + "colored", "log", ] +[[package]] +name = "ff" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0b50bfb653653f9ca9095b427bed08ab8d75a137839d9ad64eb11810d5b6393" +dependencies = [ + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "fiat-crypto" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" + [[package]] name = "field-offset" version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38e2275cc4e4fc009b0669731a1e5ab7ebf11f469eaede2bab9309a5b4d6057f" dependencies = [ - "memoffset 0.9.0", + "memoffset 0.9.1", "rustc_version", ] +[[package]] +name = "file-id" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bc904b9bbefcadbd8e3a9fb0d464a9b979de6324c03b3c663e8994f46a5be36" +dependencies = [ + "windows-sys 0.52.0", +] + [[package]] name = "filetime" -version = "0.2.21" +version = "0.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cbc844cecaee9d4443931972e1289c8ff485cb4cc2767cb03ca139ed6885153" +checksum = "35c0522e981e68cbfa8c3f978441a5f34b30b96e146b33cd3359176b50fe8586" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.2.16", - "windows-sys 0.48.0", + "libredox", + "windows-sys 0.59.0", ] +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + [[package]] name = "flate2" -version = "1.0.28" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" +checksum = "7ced92e76e966ca2fd84c8f7aa01a4aea65b0eb6648d72f7c8f3e2764a67fece" dependencies = [ "crc32fast", "miniz_oxide", @@ -1696,14 +1957,13 @@ dependencies = [ [[package]] name = "flume" -version = "0.10.14" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1657b4441c3403d9f7b3409e47575237dac27b1b5726df654a6ecbf92f0f7577" +checksum = "da0e4dd2a88388a1f4ccc7c9ce104604dab68d9f408dc34cd45823d5a9069095" dependencies = [ "futures-core", "futures-sink", - "pin-project", - "spin 0.9.8", + "spin", ] [[package]] @@ -1712,6 +1972,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + [[package]] name = "foreign-types" version = "0.3.2" @@ -1739,7 +2005,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.100", ] [[package]] @@ -1756,35 +2022,13 @@ checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" [[package]] name = "form_urlencoded" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" 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" @@ -1794,6 +2038,12 @@ dependencies = [ "libc", ] +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + [[package]] name = "futf" version = "0.1.5" @@ -1806,9 +2056,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.28" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" dependencies = [ "futures-channel", "futures-core", @@ -1821,9 +2071,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.28" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", "futures-sink", @@ -1831,15 +2081,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.28" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-executor" -version = "0.3.28" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" dependencies = [ "futures-core", "futures-task", @@ -1859,53 +2109,51 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.28" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-lite" -version = "1.13.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" +checksum = "f5edaec856126859abb19ed65f39e90fea3a9574b9707f13539acf4abf7eb532" dependencies = [ - "fastrand 1.9.0", + "fastrand", "futures-core", "futures-io", - "memchr", "parking", "pin-project-lite", - "waker-fn", ] [[package]] name = "futures-macro" -version = "0.3.28" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.100", ] [[package]] name = "futures-sink" -version = "0.3.28" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" [[package]] name = "futures-task" -version = "0.3.28" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-util" -version = "0.3.28" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-channel", "futures-core", @@ -1930,11 +2178,10 @@ dependencies = [ [[package]] name = "gdk" -version = "0.16.2" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa9cb33da481c6c040404a11f8212d193889e9b435db2c14fd86987f630d3ce1" +checksum = "d9f245958c627ac99d8e529166f9823fb3b838d1d41fd2b297af3075093c2691" dependencies = [ - "bitflags 1.3.2", "cairo-rs", "gdk-pixbuf", "gdk-sys", @@ -1946,22 +2193,22 @@ dependencies = [ [[package]] name = "gdk-pixbuf" -version = "0.16.7" +version = "0.18.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3578c60dee9d029ad86593ed88cb40f35c1b83360e12498d055022385dd9a05" +checksum = "50e1f5f1b0bfb830d6ccc8066d18db35c487b1b2b1e8589b5dfe9f07e8defaec" dependencies = [ - "bitflags 1.3.2", "gdk-pixbuf-sys", "gio", "glib", "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", @@ -1972,9 +2219,9 @@ dependencies = [ [[package]] name = "gdk-sys" -version = "0.16.0" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d76354f97a913e55b984759a997b693aa7dc71068c9e98bcce51aa167a0a5c5a" +checksum = "5c2d13f38594ac1e66619e188c6d5a1adb98d11b2fcf7894fc416ad76aa2f3f7" dependencies = [ "cairo-sys-rs", "gdk-pixbuf-sys", @@ -1989,9 +2236,9 @@ dependencies = [ [[package]] name = "gdkwayland-sys" -version = "0.16.0" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4511710212ed3020b61a8622a37aa6f0dd2a84516575da92e9b96928dcbe83ba" +checksum = "140071d506d223f7572b9f09b5e155afbd77428cd5cc7af8f2694c41d98dfe69" dependencies = [ "gdk-sys", "glib-sys", @@ -2002,29 +2249,30 @@ dependencies = [ ] [[package]] -name = "gdkx11-sys" -version = "0.16.0" +name = "gdkx11" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fa2bf8b5b8c414bc5d05e48b271896d0fd3ddb57464a3108438082da61de6af" +checksum = "3caa00e14351bebbc8183b3c36690327eb77c49abc2268dd4bd36b856db3fbfe" dependencies = [ - "gdk-sys", - "glib-sys", + "gdk", + "gdkx11-sys", + "gio", + "glib", "libc", - "system-deps", "x11", ] [[package]] -name = "generator" -version = "0.7.5" +name = "gdkx11-sys" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc16584ff22b460a382b7feec54b23d2908d858152e5739a120b949293bd74e" +checksum = "6e2e7445fe01ac26f11601db260dd8608fe172514eb63b3b5e261ea6b0f4428d" dependencies = [ - "cc", + "gdk-sys", + "glib-sys", "libc", - "log", - "rustversion", - "windows 0.48.0", + "system-deps", + "x11", ] [[package]] @@ -2035,26 +2283,27 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", + "zeroize", ] [[package]] name = "gethostname" -version = "0.2.3" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1ebd34e35c46e00bb73e81363248d627782724609fe1b6396f553f68fe3862e" +checksum = "0176e0459c2e4a1fe232f984bca6890e681076abb9934f6cea7c326f3fc47818" dependencies = [ "libc", - "winapi", + "windows-targets 0.48.5", ] [[package]] name = "gethostname" -version = "0.4.3" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0176e0459c2e4a1fe232f984bca6890e681076abb9934f6cea7c326f3fc47818" +checksum = "ed7131e57abbde63513e0e6636f76668a1ca9798dcae2df4e283cae9ee83859e" dependencies = [ - "libc", - "windows-targets 0.48.5", + "rustix 1.0.5", + "windows-targets 0.52.6", ] [[package]] @@ -2070,9 +2319,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "js-sys", @@ -2082,38 +2331,41 @@ dependencies = [ ] [[package]] -name = "ghash" -version = "0.4.4" +name = "getrandom" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1583cc1656d7839fd3732b80cf4f38850336cdb9b8ded1cd399ca62958de3c99" +checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0" dependencies = [ - "opaque-debug", - "polyval 0.5.3", + "cfg-if", + "js-sys", + "libc", + "r-efi", + "wasi 0.14.2+wasi-0.2.4", + "wasm-bindgen", ] [[package]] name = "ghash" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d930750de5717d2dd0b8c0d42c076c0e884c81a73e6cab859bbd2339c71e3e40" +checksum = "f0d8a4362ccb29cb0b265253fb0a2728f592895ee6854fd9bc13f2ffda266ff1" dependencies = [ "opaque-debug", - "polyval 0.6.1", + "polyval", ] [[package]] name = "gimli" -version = "0.27.3" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "gio" -version = "0.16.7" +version = "0.18.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a1c84b4534a290a29160ef5c6eff2a9c95833111472e824fc5cb78b513dd092" +checksum = "d4fc8f532f87b79cbc51a79748f16a6828fb784be93145a322fa14d06d354c73" dependencies = [ - "bitflags 1.3.2", "futures-channel", "futures-core", "futures-io", @@ -2124,14 +2376,14 @@ dependencies = [ "once_cell", "pin-project-lite", "smallvec", - "thiserror", + "thiserror 1.0.69", ] [[package]] name = "gio-sys" -version = "0.16.3" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9b693b8e39d042a95547fc258a7b07349b1f0b48f4b2fa3108ba3c51c0b5229" +checksum = "37566df850baf5e4cb0dfb78af2e4b9898d817ed9263d1090a2df958c64737d2" dependencies = [ "glib-sys", "gobject-sys", @@ -2142,11 +2394,11 @@ dependencies = [ [[package]] name = "glib" -version = "0.16.9" +version = "0.18.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16aa2475c9debed5a32832cb5ff2af5a3f9e1ab9e69df58eaadc1ab2004d6eba" +checksum = "233daaf6e83ae6a12a52055f568f9d7cf4671dabb78ff9560ab6da230ce00ee5" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.9.0", "futures-channel", "futures-core", "futures-executor", @@ -2157,32 +2409,31 @@ dependencies = [ "glib-sys", "gobject-sys", "libc", - "log", + "memchr", "once_cell", "smallvec", - "thiserror", + "thiserror 1.0.69", ] [[package]] name = "glib-macros" -version = "0.16.8" +version = "0.18.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb1a9325847aa46f1e96ffea37611b9d51fc4827e67f79e7de502a297560a67b" +checksum = "0bb0228f477c0900c880fd78c8759b95c7636dbd7842707f49e132378aa2acdc" dependencies = [ - "anyhow", - "heck", - "proc-macro-crate", + "heck 0.4.1", + "proc-macro-crate 2.0.0", "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.100", ] [[package]] name = "glib-sys" -version = "0.16.3" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61a4f46316d06bfa33a7ac22df6f0524c8be58e3db2d9ca99ccb1f357b62a65" +checksum = "063ce2eb6a8d0ea93d2bf8ba1957e78dbab6be1c2220dd3daca57d5a9d869898" dependencies = [ "libc", "system-deps", @@ -2190,43 +2441,57 @@ dependencies = [ [[package]] name = "glob" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" [[package]] name = "global-hotkey" -version = "0.2.3" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "997c3cad8588ba1079e7747961d27515e85989be4680d88f3a194b576a4f1d58" +checksum = "b9247516746aa8e53411a0db9b62b0e24efbcf6a76e0ba73e5a91b512ddabed7" dependencies = [ "crossbeam-channel", "keyboard-types", + "objc2 0.6.0", + "objc2-app-kit", "once_cell", - "thiserror", - "windows-sys 0.48.0", - "x11-dl", + "serde", + "thiserror 2.0.12", + "windows-sys 0.59.0", + "x11rb", + "xkeysym", ] [[package]] name = "gobject-sys" -version = "0.16.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3520bb9c07ae2a12c7f2fbb24d4efc11231c8146a86956413fb1a79bb760a0f1" +checksum = "0850127b514d1c4a4654ead6dedadb18198999985908e6ffe4436f53c785ce44" dependencies = [ "glib-sys", "libc", "system-deps", ] +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff", + "rand_core 0.6.4", + "subtle", +] + [[package]] name = "gtk" -version = "0.16.2" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4d3507d43908c866c805f74c9dd593c0ce7ba5c38e576e41846639cdcd4bee6" +checksum = "fd56fb197bfc42bd5d2751f4f017d44ff59fbb58140c6b49f9b3b2bdab08506a" dependencies = [ "atk", - "bitflags 1.3.2", "cairo-rs", "field-offset", "futures-channel", @@ -2237,16 +2502,15 @@ dependencies = [ "gtk-sys", "gtk3-macros", "libc", - "once_cell", "pango", "pkg-config", ] [[package]] name = "gtk-sys" -version = "0.16.0" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b5f8946685d5fe44497007786600c2f368ff6b1e61a16251c89f72a97520a3" +checksum = "8f29a1c21c59553eb7dd40e918be54dccd60c52b049b75119d5d96ce6b624414" dependencies = [ "atk-sys", "cairo-sys-rs", @@ -2262,31 +2526,30 @@ dependencies = [ [[package]] name = "gtk3-macros" -version = "0.16.3" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "096eb63c6fedf03bafe65e5924595785eaf1bcb7200dac0f2cbe9c9738f05ad8" +checksum = "52ff3c5b21f14f0736fed6dcfc0bfb4225ebf5725f3c0209edeec181e4d73e9d" dependencies = [ - "anyhow", - "proc-macro-crate", + "proc-macro-crate 1.3.1", "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.100", ] [[package]] name = "h2" -version = "0.3.20" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97ec8491ebaf99c8eaa73058b045fe58073cd6be7f596ac993ced0b0a0c01049" +checksum = "75249d144030531f8dee69fe9cea04d3edf809a017ae445e2abdff6629e86633" dependencies = [ - "bytes 1.4.0", + "atomic-waker", + "bytes", "fnv", "futures-core", "futures-sink", - "futures-util", "http", - "indexmap 1.9.3", + "indexmap 2.9.0", "slab", "tokio", "tokio-util", @@ -2294,59 +2557,42 @@ dependencies = [ ] [[package]] -name = "h3" -version = "0.0.2" +name = "hashbrown" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6de6ca43eed186fd055214af06967b0a7a68336cefec7e8a4004e96efeaccb9e" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "bytes 1.4.0", - "fastrand 1.9.0", - "futures-util", - "http", - "tokio", - "tracing", + "ahash 0.7.8", ] [[package]] -name = "h3-quinn" -version = "0.0.3" +name = "hashbrown" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d4a1a1763e4f3e82ee9f1ecf2cf862b22cc7316ebe14684e42f94532b5ec64d" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ - "bytes 1.4.0", - "futures", - "h3", - "quinn", - "quinn-proto", - "tokio-util", -] - -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -dependencies = [ - "ahash 0.7.6", + "ahash 0.8.11", + "allocator-api2", ] [[package]] name = "hashbrown" -version = "0.14.0" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" dependencies = [ - "ahash 0.8.3", "allocator-api2", + "equivalent", + "foldhash", ] [[package]] name = "hashlink" -version = "0.8.3" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "312f66718a2d7789ffef4f4b7b213138ed9f1eb3aa1d0d82fc99f88fb3ffd26f" +checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1" dependencies = [ - "hashbrown 0.14.0", + "hashbrown 0.15.2", ] [[package]] @@ -2354,15 +2600,18 @@ name = "heck" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" -dependencies = [ - "unicode-segmentation", -] + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hermit-abi" -version = "0.3.2" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" +checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" [[package]] name = "hex" @@ -2372,9 +2621,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hkdf" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "791a029f6b9fc27657f6f188ec6e5e43f6911f6f878e0dc5501396e09809d437" +checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" dependencies = [ "hmac", ] @@ -2385,27 +2634,16 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" dependencies = [ - "digest 0.10.7", + "digest", ] [[package]] name = "home" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" -dependencies = [ - "windows-sys 0.48.0", -] - -[[package]] -name = "hostname" -version = "0.3.1" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" dependencies = [ - "libc", - "match_cfg", - "winapi", + "windows-sys 0.52.0", ] [[package]] @@ -2424,23 +2662,35 @@ dependencies = [ [[package]] name = "http" -version = "0.2.9" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" +checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565" dependencies = [ - "bytes 1.4.0", + "bytes", "fnv", - "itoa 1.0.9", + "itoa 1.0.15", ] [[package]] name = "http-body" -version = "0.4.5" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ - "bytes 1.4.0", + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" +dependencies = [ + "bytes", + "futures-core", "http", + "http-body", "pin-project-lite", ] @@ -2452,79 +2702,105 @@ checksum = "21dec9db110f5f872ed9699c3ecf50cf16f423502706ba5c72462e28d3157573" [[package]] name = "httparse" -version = "1.8.0" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" [[package]] name = "httpdate" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "0.14.27" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" +checksum = "cc2b571658e38e0c01b1fdca3bbbe93c00d3d71693ff2770043f8c29bc7d6f80" dependencies = [ - "bytes 1.4.0", + "bytes", "futures-channel", - "futures-core", "futures-util", "h2", "http", "http-body", "httparse", "httpdate", - "itoa 1.0.9", + "itoa 1.0.15", "pin-project-lite", - "socket2 0.4.9", + "smallvec", "tokio", - "tower-service", - "tracing", "want", ] [[package]] name = "hyper-rustls" -version = "0.24.1" +version = "0.27.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" +checksum = "2d191583f3da1305256f22463b9bb0471acad48a4e534a5218b9963e9c1f59b2" dependencies = [ "futures-util", "http", "hyper", + "hyper-util", "rustls", + "rustls-native-certs", + "rustls-pki-types", "tokio", "tokio-rustls", + "tower-service", + "webpki-roots", ] [[package]] name = "hyper-tls" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ - "bytes 1.4.0", + "bytes", + "http-body-util", "hyper", + "hyper-util", "native-tls", "tokio", "tokio-native-tls", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "497bbc33a26fdd4af9ed9c70d63f61cf56a938375fbb32df34db9b1cd6d643f2" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "hyper", + "libc", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", ] [[package]] name = "iana-time-zone" -version = "0.1.57" +version = "0.1.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" +checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", + "log", "wasm-bindgen", - "windows 0.48.0", + "windows-core", ] [[package]] @@ -2538,61 +2814,167 @@ dependencies = [ [[package]] name = "ico" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3804960be0bb5e4edb1e1ad67afd321a9ecfd875c3e65c099468fd2717d7cae" +checksum = "cc50b891e4acf8fe0e71ef88ec43ad82ee07b3810ad09de10f1d01f072ed4b98" dependencies = [ "byteorder", "png", ] [[package]] -name = "ident_case" -version = "1.0.1" +name = "icu_collections" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] [[package]] -name = "idna" -version = "0.2.3" +name = "icu_locid" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" dependencies = [ - "matches", - "unicode-bidi", - "unicode-normalization", + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", ] [[package]] -name = "idna" -version = "0.3.0" +name = "icu_locid_transform" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" dependencies = [ - "unicode-bidi", - "unicode-normalization", + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7515e6d781098bf9f7205ab3fc7e9709d34554ae0b21ddbcb5febfa4bc7df11d" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5e8338228bdc8ab83303f16b797e177953730f601a96c25d10cb3ab0daa0cb7" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85fb8799753b75aee8d2a21d7c14d9f38921b54b3dbda10f5a3c7a7b82dba5e2" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "idna" -version = "0.4.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" dependencies = [ - "unicode-bidi", - "unicode-normalization", + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +dependencies = [ + "icu_normalizer", + "icu_properties", ] [[package]] name = "image" -version = "0.24.6" +version = "0.25.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "527909aa81e20ac3a44803521443a765550f09b5130c2c2fa1ea59c2f8f50a3a" +checksum = "db35664ce6b9810857a38a906215e75a9c879f0696556a39f59c62829710251a" dependencies = [ "bytemuck", - "byteorder", - "color_quant", - "num-rational", + "byteorder-lite", "num-traits", "png", "tiff", @@ -2611,30 +2993,31 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.0.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e" dependencies = [ "equivalent", - "hashbrown 0.14.0", + "hashbrown 0.15.2", + "serde", ] [[package]] name = "infer" -version = "0.15.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb33622da908807a06f9513c19b3c1ad50fab3e4137d82a78107d502075aa199" +checksum = "a588916bfdfd92e71cacef98a63d9b1f0d74d6599980d11894290e7ddefffcf7" dependencies = [ "cfb", ] [[package]] name = "inotify" -version = "0.9.6" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8069d3ec154eb856955c1c0fbffefbf5f3c40a104ec912d4797314c1801abff" +checksum = "f37dccff2791ab604f9babef0ba14fbe0be30bd368dc541e2b08d07c8aa908f3" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.9.0", "inotify-sys", "libc", ] @@ -2650,112 +3033,71 @@ dependencies = [ [[package]] name = "inout" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" dependencies = [ + "block-padding", "generic-array", ] -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "io-lifetimes" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" -dependencies = [ - "hermit-abi", - "libc", - "windows-sys 0.48.0", -] - [[package]] name = "iota-crypto" -version = "0.15.3" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e04d492224bff6e97142f033d0a4383bcbc05918be1ff7b3abd2c1cc85205a2" +checksum = "98a38db844c910d78825e173c083f2ef416b69cb091bba8ac1055763c6db065b" dependencies = [ - "aead 0.4.3", - "aes 0.7.5", - "aes-gcm 0.9.2", + "aead", + "aes", + "aes-gcm", "autocfg", + "base64 0.21.7", "blake2", "chacha20poly1305", + "cipher", "curve25519-dalek", - "digest 0.10.7", + "digest", "ed25519-zebra", "generic-array", - "getrandom 0.2.10", + "getrandom 0.2.15", + "hkdf", "hmac", + "iterator-sorted", + "k256", "pbkdf2", + "rand 0.8.5", + "scrypt", "serde", - "sha2 0.10.7", + "sha2", + "tiny-keccak", "unicode-normalization", "x25519-dalek", "zeroize", ] -[[package]] -name = "iota-crypto" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5d5a986d972c3a703d48ced24fdc0bf16fb2d02959ff4b152fa77b9132f6fb0" -dependencies = [ - "autocfg", -] - [[package]] name = "iota_stronghold" -version = "1.0.5" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c5baaa2460627283f54b968db7a38c9c754dc6059157cae64550ed1b79c91aa" +checksum = "8c0d301c7edbc31494d183b7d24c1bb51d3fb10fce2f3793df1baf45b6988e10" dependencies = [ "bincode", "hkdf", - "iota-crypto 0.15.3", - "rust-argon2", + "iota-crypto", + "rust-argon2 1.0.0", "serde", "stronghold-derive", "stronghold-utils", "stronghold_engine", - "thiserror", + "thiserror 1.0.69", "zeroize", ] -[[package]] -name = "iovec" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" -dependencies = [ - "libc", -] - -[[package]] -name = "ipconfig" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f" -dependencies = [ - "socket2 0.5.3", - "widestring", - "windows-sys 0.48.0", - "winreg 0.50.0", -] - [[package]] name = "ipnet" -version = "2.8.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" +checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" [[package]] name = "is-docker" @@ -2766,17 +3108,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "is-terminal" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" -dependencies = [ - "hermit-abi", - "rustix 0.38.4", - "windows-sys 0.48.0", -] - [[package]] name = "is-wsl" version = "0.4.0" @@ -2788,13 +3119,16 @@ dependencies = [ ] [[package]] -name = "itertools" -version = "0.10.5" +name = "is_terminal_polyfill" +version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" -dependencies = [ - "either", -] +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + +[[package]] +name = "iterator-sorted" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d101775d2bc8f99f4ac18bf29b9ed70c0dd138b9a1e88d7b80179470cbbe8bd2" [[package]] name = "itoa" @@ -2804,15 +3138,15 @@ checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" [[package]] name = "itoa" -version = "1.0.9" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[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", @@ -2821,9 +3155,9 @@ dependencies = [ [[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", @@ -2842,7 +3176,7 @@ dependencies = [ "combine", "jni-sys", "log", - "thiserror", + "thiserror 1.0.69", "walkdir", "windows-sys 0.45.0", ] @@ -2855,56 +3189,81 @@ checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" [[package]] name = "jobserver" -version = "0.1.26" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" +checksum = "38f262f097c174adebe41eb73d66ae9c06b2844fb0da69969647bbddd9b0538a" dependencies = [ + "getrandom 0.3.2", "libc", ] [[package]] name = "jpeg-decoder" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc0000e42512c92e31c2252315bda326620a4e034105e900c98ec492fa077b3e" +checksum = "f5d4a7da358eff58addd2877a45865158f0d78c911d43a5784ceb7bbf52833b0" [[package]] name = "js-sys" -version = "0.3.64" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" dependencies = [ + "once_cell", "wasm-bindgen", ] [[package]] name = "json-patch" -version = "1.0.0" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "863726d7afb6bc2590eeff7135d923545e5e964f004c2ccf8716c25e70a86f08" +dependencies = [ + "jsonptr", + "serde", + "serde_json", + "thiserror 1.0.69", +] + +[[package]] +name = "jsonptr" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f54898088ccb91df1b492cc80029a6fdf1c48ca0db7c6822a8babad69c94658" +checksum = "5dea2b27dd239b2556ed7a25ba842fe47fd602e7fc7433c2a8d6106d4d9edd70" dependencies = [ "serde", "serde_json", - "thiserror", - "treediff", +] + +[[package]] +name = "k256" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "once_cell", + "sha2", ] [[package]] name = "keyboard-types" -version = "0.6.2" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7668b7cff6a51fe61cdde64cd27c8a220786f399501b57ebe36f7d8112fd68" +checksum = "b750dcadc39a09dbadd74e118f6dd6598df77fa01df0cfcdc52c28dece74528a" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.9.0", "serde", "unicode-segmentation", ] [[package]] name = "kqueue" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c8fc60ba15bf51257aa9807a48a61013db043fcf3a78cb0d916e8e396dcad98" +checksum = "7447f1ca1b7b563588a205fe93dea8df60fd981423a768bc1c0ded35ed147d0c" dependencies = [ "kqueue-sys", "libc", @@ -2912,9 +3271,9 @@ dependencies = [ [[package]] name = "kqueue-sys" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8367585489f01bc55dd27404dcf56b95e6da061a256a666ab23be9ba96a2e587" +checksum = "ed9625ffda8729b85e45cf04090035ac368927b8cebc34898e7c120f52e4838b" dependencies = [ "bitflags 1.3.2", "libc", @@ -2935,18 +3294,18 @@ dependencies = [ [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" dependencies = [ - "spin 0.5.2", + "spin", ] [[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", "gtk", @@ -2957,9 +3316,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", @@ -2968,9 +3327,33 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.147" +version = "0.2.172" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" + +[[package]] +name = "libflate" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45d9dfdc14ea4ef0900c1cddbc8dcd553fbaacd8a4a282cf4018ae9dd04fb21e" +dependencies = [ + "adler32", + "core2", + "crc32fast", + "dary_heap", + "libflate_lz77", +] + +[[package]] +name = "libflate_lz77" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e0d73b369f386f1c44abd9c570d5318f55ccde816ff4b562fa452e5182863d" +dependencies = [ + "core2", + "hashbrown 0.14.5", + "rle-decode-fast", +] [[package]] name = "libloading" @@ -2984,121 +3367,96 @@ dependencies = [ [[package]] name = "libm" -version = "0.2.7" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" +checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" [[package]] -name = "libsodium-sys" -version = "0.2.7" +name = "libredox" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b779387cd56adfbc02ea4a668e704f729be8d6a6abd2c27ca5ee537849a92fd" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "cc", + "bitflags 2.9.0", "libc", - "pkg-config", - "walkdir", + "redox_syscall", ] [[package]] -name = "libsqlite3-sys" -version = "0.26.0" +name = "libsodium-sys-stable" +version = "1.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc22eff61b133b115c6e8c74e818c628d6d5e7a502afea6f64dee076dd94326" +checksum = "b023d38f2afdfe36f81e15a9d7232097701d7b107e3a93ba903083985e235239" dependencies = [ "cc", + "libc", + "libflate", + "minisign-verify", "pkg-config", + "tar", + "ureq", "vcpkg", + "zip 2.6.1", ] [[package]] -name = "libudev" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea626d3bdf40a1c5aee3bcd4f40826970cae8d80a8fec934c82a63840094dcfe" -dependencies = [ - "libc", - "libudev-sys", -] - -[[package]] -name = "libudev-sys" -version = "0.1.4" +name = "libsqlite3-sys" +version = "0.30.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c8469b4a23b962c1396b9b451dda50ef5b283e8dd309d69033475fa9b334324" +checksum = "2e99fb7a497b1e3339bc746195567ed8d3e24945ecd636e3619d20b9de9e9149" dependencies = [ - "libc", + "cc", "pkg-config", + "vcpkg", ] [[package]] -name = "line-wrap" -version = "0.1.1" +name = "linux-raw-sys" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30344350a2a51da54c1d53be93fade8a237e545dbcc4bdbe635413f2117cab9" -dependencies = [ - "safemem", -] +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" [[package]] -name = "linked-hash-map" -version = "0.5.6" +name = "linux-raw-sys" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" +checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" [[package]] -name = "linux-raw-sys" -version = "0.3.8" +name = "litemap" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" +checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" [[package]] -name = "linux-raw-sys" -version = "0.4.3" +name = "litrs" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09fc20d2ca12cb9f044c93e3bd6d32d523e6e2ec3db4f7b2939cd99026ecd3f0" +checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5" [[package]] name = "lock_api" -version = "0.4.10" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", ] [[package]] -name = "log" -version = "0.4.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" -dependencies = [ - "value-bag", -] - -[[package]] -name = "loom" -version = "0.5.6" +name = "lockfree-object-pool" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff50ecb28bb86013e935fb6683ab1f6d3a20016f123c76fd4c27470076ac30f5" -dependencies = [ - "cfg-if", - "generator", - "scoped-tls", - "serde", - "serde_json", - "tracing", - "tracing-subscriber", -] +checksum = "9374ef4228402d4b7e403e5838cb880d9ee663314b0a900d5a6aabf0c213552e" [[package]] -name = "lru-cache" -version = "0.1.2" +name = "log" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" dependencies = [ - "linked-hash-map", + "value-bag", ] [[package]] @@ -3109,25 +3467,21 @@ checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" [[package]] name = "mac-notification-sys" -version = "0.5.8" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abc434554ad0e640d772f7f262aa28e61d485212533d3673abe5f3d1729bd42a" +checksum = "0b95dfb34071d1592b45622bf93e315e3a72d414b6782aca9a015c12bec367ef" dependencies = [ "cc", - "dirs-next", - "objc-foundation", - "objc_id", - "time 0.3.24", + "objc2 0.6.0", + "objc2-foundation 0.3.0", + "time", ] [[package]] -name = "malloc_buf" -version = "0.0.6" +name = "maplit" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" -dependencies = [ - "libc", -] +checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" [[package]] name = "markup5ever" @@ -3143,21 +3497,6 @@ dependencies = [ "tendril", ] -[[package]] -name = "match_cfg" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" - -[[package]] -name = "matchers" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" -dependencies = [ - "regex-automata 0.1.10", -] - [[package]] name = "matches" version = "0.1.10" @@ -3166,18 +3505,19 @@ checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" [[package]] name = "md-5" -version = "0.10.5" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6365506850d44bff6e2fbcb5176cf63650e48bd45ef2fe2665ae1570e0f4b9ca" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" dependencies = [ - "digest 0.10.7", + "cfg-if", + "digest", ] [[package]] name = "memchr" -version = "2.5.0" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "memoffset" @@ -3190,18 +3530,9 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" -dependencies = [ - "autocfg", -] - -[[package]] -name = "memoffset" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" dependencies = [ "autocfg", ] @@ -3214,9 +3545,9 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "mime_guess" -version = "2.0.4" +version = "2.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" +checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e" dependencies = [ "mime", "unicase", @@ -3230,99 +3561,107 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "minisign-verify" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "933dca44d65cdd53b355d0b73d380a2ff5da71f87f036053188bf1eab6a19881" +checksum = "6367d84fb54d4242af283086402907277715b8fe46976963af5ebf173f8efba3" [[package]] name = "miniz_oxide" -version = "0.7.1" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "3be647b768db090acb35d5ec5db2b0e1f1de11133ca123b9eacf5137868f892a" dependencies = [ - "adler", + "adler2", "simd-adler32", ] [[package]] name = "mio" -version = "0.8.8" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" dependencies = [ "libc", "log", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "mockito" -version = "0.31.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80f9fece9bd97ab74339fe19f4bcaf52b76dcc18e5364c7977c1838f76b38de9" +checksum = "7760e0e418d9b7e5777c0374009ca4c93861b9066f18cb334a20ce50ab63aa48" dependencies = [ "assert-json-diff", - "colored 2.0.4", - "httparse", - "lazy_static", + "bytes", + "colored", + "futures-util", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-util", "log", - "rand 0.8.5", + "rand 0.9.0", "regex", "serde_json", "serde_urlencoded", "similar", + "tokio", ] [[package]] name = "muda" -version = "0.8.7" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41fe753ec4d3e8137a1d3ecb1aee1192b8f7661fe1247641968f5bf5f2e6ebbe" +checksum = "4de14a9b5d569ca68d7c891d613b390cf5ab4f851c77aaa2f9e435555d3d9492" dependencies = [ - "cocoa 0.25.0", "crossbeam-channel", - "gdk", - "gdk-pixbuf", + "dpi", "gtk", "keyboard-types", - "objc", + "objc2 0.6.0", + "objc2-app-kit", + "objc2-core-foundation", + "objc2-foundation 0.3.0", "once_cell", "png", - "thiserror", - "windows-sys 0.48.0", + "serde", + "thiserror 2.0.12", + "windows-sys 0.59.0", ] [[package]] name = "native-tls" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" dependencies = [ - "lazy_static", "libc", "log", "openssl", "openssl-probe", "openssl-sys", "schannel", - "security-framework", + "security-framework 2.11.1", "security-framework-sys", "tempfile", ] [[package]] name = "ndk" -version = "0.7.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "451422b7e4718271c8b5b3aadf5adedba43dc76312454b387e98fae0fc951aa0" +checksum = "c3f42e7bbe13d351b6bead8286a43aac9534b82bd3cc43e47037f012ebfd62d4" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.9.0", "jni-sys", + "log", "ndk-sys", "num_enum", "raw-window-handle", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -3333,18 +3672,18 @@ checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" [[package]] name = "ndk-sys" -version = "0.4.1+23.1.7779620" +version = "0.6.0+11769913" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cf2aae958bd232cac5069850591667ad422d263686d75b52a065f9badeee5a3" +checksum = "ee6cda3051665f1fb8d9e08fc35c96d5a244fb1be711a03b71118828afc9a873" dependencies = [ "jni-sys", ] [[package]] name = "new_debug_unreachable" -version = "1.0.4" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" +checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" [[package]] name = "nix" @@ -3360,15 +3699,15 @@ dependencies = [ [[package]] name = "nix" -version = "0.26.2" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" +checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.9.0", "cfg-if", + "cfg_aliases", "libc", - "memoffset 0.7.1", - "static_assertions", + "memoffset 0.9.1", ] [[package]] @@ -3389,40 +3728,43 @@ dependencies = [ [[package]] name = "notify" -version = "5.2.0" +version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "729f63e1ca555a43fe3efa4f3efdf4801c479da85b432242a7b726f353c88486" +checksum = "2fee8403b3d66ac7b26aee6e40a897d85dc5ce26f44da36b8b73e987cc52e943" dependencies = [ - "bitflags 1.3.2", - "crossbeam-channel", + "bitflags 2.9.0", "filetime", "fsevent-sys", "inotify", "kqueue", "libc", + "log", "mio", - "serde", + "notify-types", "walkdir", - "windows-sys 0.45.0", + "windows-sys 0.59.0", ] [[package]] -name = "notify-debouncer-mini" -version = "0.2.1" +name = "notify-debouncer-full" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e23e9fa24f094b143c1eb61f90ac6457de87be6987bc70746e0179f7dbc9007b" +checksum = "d2d88b1a7538054351c8258338df7c931a590513fb3745e8c15eb9ff4199b8d1" dependencies = [ - "crossbeam-channel", + "file-id", + "log", "notify", - "serde", + "notify-types", + "walkdir", ] [[package]] name = "notify-rust" -version = "4.8.0" +version = "4.11.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bfa211d18e360f08e36c364308f394b5eb23a6629150690e109a916dc6f610e" +checksum = "6442248665a5aa2514e794af3b39661a8e73033b1cc5e59899e1276117ee4400" dependencies = [ + "futures-lite", "log", "mac-notification-sys", "serde", @@ -3431,13 +3773,12 @@ dependencies = [ ] [[package]] -name = "nu-ansi-term" -version = "0.46.0" +name = "notify-types" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +checksum = "5e0826a989adedc2a244799e823aece04662b66609d96af8dff7ac6df9a8925d" dependencies = [ - "overload", - "winapi", + "serde", ] [[package]] @@ -3458,31 +3799,25 @@ dependencies = [ ] [[package]] -name = "num-integer" -version = "0.1.45" +name = "num-conv" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg", - "num-traits", -] +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" [[package]] -name = "num-iter" -version = "0.1.43" +name = "num-integer" +version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "autocfg", - "num-integer", "num-traits", ] [[package]] -name = "num-rational" -version = "0.4.1" +name = "num-iter" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" dependencies = [ "autocfg", "num-integer", @@ -3491,235 +3826,434 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", "libm", ] -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi", - "libc", -] - [[package]] name = "num_enum" -version = "0.5.11" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f646caf906c20226733ed5b1374287eb97e3c2a5c227ce668c1f2ce20ae57c9" +checksum = "4e613fc340b2220f734a8595782c551f1250e969d87d3be1ae0579e8d4065179" dependencies = [ "num_enum_derive", ] [[package]] name = "num_enum_derive" -version = "0.5.11" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799" +checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 3.3.0", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.100", ] [[package]] name = "num_threads" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44" +checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9" dependencies = [ "libc", ] [[package]] -name = "objc" -version = "0.2.7" +name = "objc-sys" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" -dependencies = [ - "malloc_buf", - "objc_exception", -] +checksum = "cdb91bdd390c7ce1a8607f35f3ca7151b65afc0ff5ff3b34fa350f7d7c7e4310" [[package]] -name = "objc-foundation" -version = "0.1.1" +name = "objc2" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9" +checksum = "46a785d4eeff09c14c487497c162e92766fbb3e4059a71840cecc03d9a50b804" dependencies = [ - "block", - "objc", - "objc_id", + "objc-sys", + "objc2-encode", ] [[package]] -name = "objc_exception" -version = "0.1.2" +name = "objc2" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad970fb455818ad6cba4c122ad012fae53ae8b4795f86378bce65e4f6bab2ca4" +checksum = "3531f65190d9cff863b77a99857e74c314dd16bf56c538c4b57c7cbc3f3a6e59" dependencies = [ - "cc", + "objc2-encode", + "objc2-exception-helper", ] [[package]] -name = "objc_id" -version = "0.1.1" +name = "objc2-app-kit" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b" +checksum = "5906f93257178e2f7ae069efb89fbd6ee94f0592740b5f8a1512ca498814d0fb" dependencies = [ - "objc", + "bitflags 2.9.0", + "block2 0.6.0", + "libc", + "objc2 0.6.0", + "objc2-cloud-kit", + "objc2-core-data", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-core-image", + "objc2-foundation 0.3.0", + "objc2-quartz-core 0.3.0", ] [[package]] -name = "object" -version = "0.31.1" +name = "objc2-cloud-kit" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1" +checksum = "6c1948a9be5f469deadbd6bcb86ad7ff9e47b4f632380139722f7d9840c0d42c" dependencies = [ - "memchr", + "bitflags 2.9.0", + "objc2 0.6.0", + "objc2-foundation 0.3.0", ] [[package]] -name = "once_cell" -version = "1.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" - -[[package]] -name = "opaque-debug" +name = "objc2-core-data" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +checksum = "1f860f8e841f6d32f754836f51e6bc7777cd7e7053cf18528233f6811d3eceb4" +dependencies = [ + "bitflags 2.9.0", + "objc2 0.6.0", + "objc2-foundation 0.3.0", +] [[package]] -name = "open" -version = "4.2.0" +name = "objc2-core-foundation" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a083c0c7e5e4a8ec4176346cf61f67ac674e8bfb059d9226e1c54a96b377c12" +checksum = "daeaf60f25471d26948a1c2f840e3f7d86f4109e3af4e8e4b5cd70c39690d925" dependencies = [ - "is-wsl", - "libc", - "pathdiff", + "bitflags 2.9.0", + "objc2 0.6.0", ] [[package]] -name = "openssl" -version = "0.10.55" +name = "objc2-core-graphics" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "345df152bc43501c5eb9e4654ff05f794effb78d4efe3d53abc158baddc0703d" +checksum = "f8dca602628b65356b6513290a21a6405b4d4027b8b250f0b98dddbb28b7de02" dependencies = [ - "bitflags 1.3.2", - "cfg-if", - "foreign-types 0.3.2", - "libc", - "once_cell", - "openssl-macros", - "openssl-sys", + "bitflags 2.9.0", + "objc2 0.6.0", + "objc2-core-foundation", + "objc2-io-surface", ] [[package]] -name = "openssl-macros" -version = "0.1.1" +name = "objc2-core-image" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +checksum = "6ffa6bea72bf42c78b0b34e89c0bafac877d5f80bf91e159a5d96ea7f693ca56" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.28", + "objc2 0.6.0", + "objc2-foundation 0.3.0", ] [[package]] -name = "openssl-probe" -version = "0.1.5" +name = "objc2-encode" +version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33" [[package]] -name = "openssl-src" -version = "111.26.0+1.1.1u" +name = "objc2-exception-helper" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efc62c9f12b22b8f5208c23a7200a442b2e5999f8bdf80233852122b5a4f6f37" +checksum = "c7a1c5fbb72d7735b076bb47b578523aedc40f3c439bea6dfd595c089d79d98a" dependencies = [ "cc", ] [[package]] -name = "openssl-sys" -version = "0.9.90" +name = "objc2-foundation" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374533b0e45f3a7ced10fcaeccca020e66656bc03dac384f852e4e5a7a8104a6" +checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8" dependencies = [ - "cc", + "bitflags 2.9.0", + "block2 0.5.1", "libc", - "openssl-src", - "pkg-config", - "vcpkg", + "objc2 0.5.2", ] [[package]] -name = "ordered-stream" -version = "0.2.0" +name = "objc2-foundation" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aa2b01e1d916879f73a53d01d1d6cee68adbb31d6d9177a8cfce093cced1d50" +checksum = "3a21c6c9014b82c39515db5b396f91645182611c97d24637cf56ac01e5f8d998" dependencies = [ - "futures-core", - "pin-project-lite", + "bitflags 2.9.0", + "block2 0.6.0", + "libc", + "objc2 0.6.0", + "objc2-core-foundation", ] [[package]] -name = "os_info" -version = "3.7.0" +name = "objc2-io-surface" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "006e42d5b888366f1880eda20371fedde764ed2213dc8496f49622fa0c99cd5e" +checksum = "161a8b87e32610086e1a7a9e9ec39f84459db7b3a0881c1f16ca5a2605581c19" dependencies = [ - "log", - "serde", - "winapi", + "bitflags 2.9.0", + "objc2 0.6.0", + "objc2-core-foundation", ] [[package]] -name = "os_pipe" -version = "1.1.4" +name = "objc2-metal" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ae859aa07428ca9a929b936690f8b12dc5f11dd8c6992a18ca93919f28bc177" +checksum = "dd0cba1276f6023976a406a14ffa85e1fdd19df6b0f737b063b95f6c8c7aadd6" dependencies = [ - "libc", - "windows-sys 0.48.0", + "bitflags 2.9.0", + "block2 0.5.1", + "objc2 0.5.2", + "objc2-foundation 0.2.2", ] [[package]] -name = "overload" -version = "0.1.1" +name = "objc2-osa-kit" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" +checksum = "a1ac59da3ceebc4a82179b35dc550431ad9458f9cc326e053f49ba371ce76c5a" +dependencies = [ + "bitflags 2.9.0", + "objc2 0.6.0", + "objc2-app-kit", + "objc2-foundation 0.3.0", +] [[package]] -name = "pango" -version = "0.16.5" +name = "objc2-quartz-core" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdff66b271861037b89d028656184059e03b0b6ccb36003820be19f7200b1e94" +checksum = "e42bee7bff906b14b167da2bac5efe6b6a07e6f7c0a21a7308d40c960242dc7a" dependencies = [ - "bitflags 1.3.2", - "gio", - "glib", - "libc", + "bitflags 2.9.0", + "block2 0.5.1", + "objc2 0.5.2", + "objc2-foundation 0.2.2", + "objc2-metal", +] + +[[package]] +name = "objc2-quartz-core" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fb3794501bb1bee12f08dcad8c61f2a5875791ad1c6f47faa71a0f033f20071" +dependencies = [ + "bitflags 2.9.0", + "objc2 0.6.0", + "objc2-foundation 0.3.0", +] + +[[package]] +name = "objc2-ui-kit" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "777a571be14a42a3990d4ebedaeb8b54cd17377ec21b92e8200ac03797b3bee1" +dependencies = [ + "bitflags 2.9.0", + "objc2 0.6.0", + "objc2-core-foundation", + "objc2-foundation 0.3.0", +] + +[[package]] +name = "objc2-web-kit" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b717127e4014b0f9f3e8bba3d3f2acec81f1bde01f656823036e823ed2c94dce" +dependencies = [ + "bitflags 2.9.0", + "block2 0.6.0", + "objc2 0.6.0", + "objc2-app-kit", + "objc2-core-foundation", + "objc2-foundation 0.3.0", +] + +[[package]] +name = "object" +version = "0.36.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "opaque-debug" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" + +[[package]] +name = "open" +version = "5.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2483562e62ea94312f3576a7aca397306df7990b8d89033e18766744377ef95" +dependencies = [ + "dunce", + "is-wsl", + "libc", + "pathdiff", +] + +[[package]] +name = "openssl" +version = "0.10.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fedfea7d58a1f73118430a55da6a286e7b044961736ce96a16a17068ea25e5da" +dependencies = [ + "bitflags 2.9.0", + "cfg-if", + "foreign-types 0.3.2", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + +[[package]] +name = "openssl-probe" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" + +[[package]] +name = "openssl-src" +version = "300.5.0+3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8ce546f549326b0e6052b649198487d91320875da901e7bd11a06d1ee3f9c2f" +dependencies = [ + "cc", +] + +[[package]] +name = "openssl-sys" +version = "0.9.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8288979acd84749c744a9014b4382d42b8f7b2592847b5afb2ed29e5d16ede07" +dependencies = [ + "cc", + "libc", + "openssl-src", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + +[[package]] +name = "ordered-multimap" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49203cdcae0030493bad186b28da2fa25645fa276a51b6fec8010d281e02ef79" +dependencies = [ + "dlv-list", + "hashbrown 0.14.5", +] + +[[package]] +name = "ordered-stream" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aa2b01e1d916879f73a53d01d1d6cee68adbb31d6d9177a8cfce093cced1d50" +dependencies = [ + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "os_info" +version = "3.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a604e53c24761286860eba4e2c8b23a0161526476b1de520139d69cdb85a6b5" +dependencies = [ + "log", + "serde", + "windows-sys 0.52.0", +] + +[[package]] +name = "os_pipe" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ffd2b0a5634335b135d5728d84c5e0fd726954b87111f7506a61c502280d982" +dependencies = [ + "libc", + "windows-sys 0.59.0", +] + +[[package]] +name = "osakit" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "732c71caeaa72c065bb69d7ea08717bd3f4863a4f451402fc9513e29dbd5261b" +dependencies = [ + "objc2 0.6.0", + "objc2-foundation 0.3.0", + "objc2-osa-kit", + "serde", + "serde_json", + "thiserror 2.0.12", +] + +[[package]] +name = "pango" +version = "0.18.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ca27ec1eb0457ab26f3036ea52229edbdb74dee1edd29063f5b9b010e7ebee4" +dependencies = [ + "gio", + "glib", + "libc", "once_cell", "pango-sys", ] [[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", @@ -3729,15 +4263,15 @@ dependencies = [ [[package]] name = "parking" -version = "2.1.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14f2252c834a40ed9bb5422029649578e63aa341ac401f74e719dd1afda8394e" +checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" [[package]] name = "parking_lot" -version = "0.12.1" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" dependencies = [ "lock_api", "parking_lot_core", @@ -3745,50 +4279,37 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.8" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.3.5", + "redox_syscall", "smallvec", - "windows-targets 0.48.5", -] - -[[package]] -name = "password-hash" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700" -dependencies = [ - "base64ct", - "rand_core 0.6.4", - "subtle", + "windows-targets 0.52.6", ] [[package]] name = "paste" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "pathdiff" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" +checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3" [[package]] name = "pbkdf2" -version = "0.11.0" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" +checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" dependencies = [ - "digest 0.10.7", + "digest", "hmac", - "password-hash", - "sha2 0.10.7", ] [[package]] @@ -3802,9 +4323,19 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.3.0" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "petgraph" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" +dependencies = [ + "fixedbitset", + "indexmap 2.9.0", +] [[package]] name = "phf" @@ -3828,12 +4359,12 @@ dependencies = [ [[package]] name = "phf" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" +checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078" dependencies = [ - "phf_macros 0.11.2", - "phf_shared 0.11.2", + "phf_macros 0.11.3", + "phf_shared 0.11.3", ] [[package]] @@ -3878,11 +4409,11 @@ dependencies = [ [[package]] name = "phf_generator" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" +checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d" dependencies = [ - "phf_shared 0.11.2", + "phf_shared 0.11.3", "rand 0.8.5", ] @@ -3902,15 +4433,15 @@ dependencies = [ [[package]] name = "phf_macros" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b" +checksum = "f84ac04429c13a7ff43785d75ad27569f2951ce0ffd30a3321230db2fc727216" dependencies = [ - "phf_generator 0.11.2", - "phf_shared 0.11.2", + "phf_generator 0.11.3", + "phf_shared 0.11.3", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.100", ] [[package]] @@ -3919,7 +4450,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c00cf8b9eafe68dde5e9eaa2cef8ee84a9336a47d566ec55ca16589633b65af7" dependencies = [ - "siphasher", + "siphasher 0.3.11", ] [[package]] @@ -3928,43 +4459,23 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" dependencies = [ - "siphasher", + "siphasher 0.3.11", ] [[package]] name = "phf_shared" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b" -dependencies = [ - "siphasher", -] - -[[package]] -name = "pin-project" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "030ad2bc4db10a8944cb0d837f158bdfec4d4a4873ab701a95046770d11f8842" -dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "1.1.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec2e072ecce94ec471b13398d5402c188e76ac03cf74dd1a975161b23a3f6d9c" +checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.28", + "siphasher 1.0.1", ] [[package]] name = "pin-project-lite" -version = "0.2.10" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c40d25201921e5ff0c862a505c6557ea88568a4e3ace775ab55e93f2f4f9d57" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" [[package]] name = "pin-utils" @@ -3972,6 +4483,17 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "piper" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96c8c490f422ef9a4efd2cb5b42b76c8613d7e7dfc1caf667b8a3350a5acc066" +dependencies = [ + "atomic-waker", + "fastrand", + "futures-io", +] + [[package]] name = "pkcs1" version = "0.7.5" @@ -3995,29 +4517,28 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.27" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" [[package]] name = "plist" -version = "1.5.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdc0001cfea3db57a2e24bc0d818e9e20e554b5f97fabb9bc231dc240269ae06" +checksum = "eac26e981c03a6e53e0aee43c113e3202f5581d5360dae7bd2c70e800dd0451d" dependencies = [ - "base64 0.21.2", - "indexmap 1.9.3", - "line-wrap", - "quick-xml 0.29.0", + "base64 0.22.1", + "indexmap 2.9.0", + "quick-xml 0.32.0", "serde", - "time 0.3.24", + "time", ] [[package]] name = "png" -version = "0.17.9" +version = "0.17.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59871cc5b6cce7eaccca5a802b4173377a1c2ba90654246789a8fa2334426d11" +checksum = "82151a2fc869e011c153adc57cf2789ccb8d9906ce52c0b39a6b5697749d7526" dependencies = [ "bitflags 1.3.2", "crc32fast", @@ -4028,60 +4549,56 @@ dependencies = [ [[package]] name = "polling" -version = "2.8.0" +version = "3.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" +checksum = "a604568c3202727d1507653cb121dbd627a58684eb09a820fd746bee38b4442f" dependencies = [ - "autocfg", - "bitflags 1.3.2", "cfg-if", "concurrent-queue", - "libc", - "log", + "hermit-abi", "pin-project-lite", - "windows-sys 0.48.0", + "rustix 0.38.44", + "tracing", + "windows-sys 0.59.0", ] [[package]] name = "poly1305" -version = "0.7.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "048aeb476be11a4b6ca432ca569e375810de9294ae78f4774e78ea98a9246ede" +checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" dependencies = [ "cpufeatures", "opaque-debug", - "universal-hash 0.4.0", + "universal-hash", ] [[package]] name = "polyval" -version = "0.5.3" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8419d2b623c7c0896ff2d5d96e2cb4ede590fed28fcc34934f4c33c036e620a1" +checksum = "9d1fe60d06143b2430aa532c94cfe9e29783047f06c0d7fd359a9a51b729fa25" dependencies = [ "cfg-if", "cpufeatures", "opaque-debug", - "universal-hash 0.4.0", + "universal-hash", ] [[package]] -name = "polyval" -version = "0.6.1" +name = "powerfmt" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52cff9d1d4dee5fe6d03729099f4a310a41179e0a10dbf542039873f2e826fb" -dependencies = [ - "cfg-if", - "cpufeatures", - "opaque-debug", - "universal-hash 0.5.1", -] +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy 0.8.24", +] [[package]] name = "precomputed-hash" @@ -4096,7 +4613,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell", - "toml_edit", + "toml_edit 0.19.15", +] + +[[package]] +name = "proc-macro-crate" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8" +dependencies = [ + "toml_edit 0.20.7", +] + +[[package]] +name = "proc-macro-crate" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edce586971a4dfaa28950c6f18ed55e0406c1ab88bbce2c6f6293a7aaba73d35" +dependencies = [ + "toml_edit 0.22.24", ] [[package]] @@ -4131,9 +4666,9 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" dependencies = [ "unicode-ident", ] @@ -4144,13 +4679,33 @@ version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33cb294fe86a74cbcf50d4445b37da762029549ebeea341421c7c70370f86cac" +[[package]] +name = "ptr_meta" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" +dependencies = [ + "ptr_meta_derive", +] + +[[package]] +name = "ptr_meta_derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "publicsuffix" -version = "2.2.3" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96a8c1bda5ae1af7f99a2962e49df150414a43d62404644d98dd5c3a93d07457" +checksum = "6f42ea446cab60335f76979ec15e12619a2165b5ae2c12166bef27d283a9fadf" dependencies = [ - "idna 0.3.0", + "idna", "psl-types", ] @@ -4162,78 +4717,97 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quick-xml" -version = "0.23.1" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11bafc859c6815fbaffbbbf4229ecb767ac913fecb27f9ad4343662e9ef099ea" +checksum = "1d3a6e5838b60e0e8fa7a43f22ade549a37d61f8bdbe636d0d7816191de969c2" dependencies = [ "memchr", ] [[package]] name = "quick-xml" -version = "0.29.0" +version = "0.37.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81b9228215d82c7b61490fec1de287136b5de6f5700f6e58ea9ad61a7964ca51" +checksum = "a4ce8c88de324ff838700f36fb6ab86c96df0e3c4ab6ef3a9b2044465cce1369" dependencies = [ "memchr", ] [[package]] name = "quinn" -version = "0.10.2" +version = "0.11.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cc2c5017e4b43d5995dcea317bc46c1e09404c0a9664d2908f7f02dfe943d75" +checksum = "c3bd15a6f2967aef83887dcb9fec0014580467e33720d073560cf015a5683012" dependencies = [ - "bytes 1.4.0", + "bytes", + "cfg_aliases", "pin-project-lite", "quinn-proto", "quinn-udp", "rustc-hash", "rustls", - "thiserror", + "socket2", + "thiserror 2.0.12", "tokio", "tracing", + "web-time", ] [[package]] name = "quinn-proto" -version = "0.10.5" +version = "0.11.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c78e758510582acc40acb90458401172d41f1016f8c9dde89e49677afb7eec1" +checksum = "b820744eb4dc9b57a3398183639c511b5a26d2ed702cedd3febaa1393caa22cc" dependencies = [ - "bytes 1.4.0", - "rand 0.8.5", - "ring 0.16.20", + "bytes", + "getrandom 0.3.2", + "rand 0.9.0", + "ring", "rustc-hash", "rustls", + "rustls-pki-types", "slab", - "thiserror", + "thiserror 2.0.12", "tinyvec", "tracing", + "web-time", ] [[package]] name = "quinn-udp" -version = "0.4.0" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6df19e284d93757a9fb91d63672f7741b129246a669db09d1c0063071debc0c0" +checksum = "541d0f57c6ec747a90738a52741d3221f7960e8ac2f0ff4b1a63680e033b4ab5" dependencies = [ - "bytes 1.4.0", + "cfg_aliases", "libc", - "socket2 0.5.3", + "once_cell", + "socket2", "tracing", - "windows-sys 0.48.0", + "windows-sys 0.59.0", ] [[package]] name = "quote" -version = "1.0.32" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] +[[package]] +name = "r-efi" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + [[package]] name = "rand" version = "0.7.3" @@ -4259,6 +4833,17 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "rand" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.3", + "zerocopy 0.8.24", +] + [[package]] name = "rand_chacha" version = "0.2.2" @@ -4279,6 +4864,16 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.3", +] + [[package]] name = "rand_core" version = "0.5.1" @@ -4294,7 +4889,16 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.10", + "getrandom 0.2.15", +] + +[[package]] +name = "rand_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" +dependencies = [ + "getrandom 0.3.2", ] [[package]] @@ -4317,9 +4921,9 @@ dependencies = [ [[package]] name = "raw-window-handle" -version = "0.5.2" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9" +checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" [[package]] name = "read-progress-stream" @@ -4327,93 +4931,89 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6435842fc2fea44b528719eb8c32203bbc1bb2f5b619fbe0c0a3d8350fd8d2a8" dependencies = [ - "bytes 1.4.0", + "bytes", "futures", "pin-project-lite", ] [[package]] name = "redox_syscall" -version = "0.2.16" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +checksum = "d2f103c6d277498fbceb16e84d317e2a400f160f46904d5f5410848c829511a3" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.9.0", ] [[package]] -name = "redox_syscall" -version = "0.3.5" +name = "redox_users" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ - "bitflags 1.3.2", + "getrandom 0.2.15", + "libredox", + "thiserror 1.0.69", ] [[package]] name = "redox_users" -version = "0.4.3" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +checksum = "dd6f9d3d47bdd2ad6945c5015a226ec6155d0bcdfd8f7cd29f86b71f8de99d2b" dependencies = [ - "getrandom 0.2.10", - "redox_syscall 0.2.16", - "thiserror", + "getrandom 0.2.15", + "libredox", + "thiserror 2.0.12", ] [[package]] name = "regex" -version = "1.9.1" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2eae68fc220f7cf2532e4494aded17545fce192d59cd996e0fe7887f4ceb575" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.3.4", - "regex-syntax 0.7.4", -] - -[[package]] -name = "regex-automata" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" -dependencies = [ - "regex-syntax 0.6.29", + "regex-automata", + "regex-syntax", ] [[package]] name = "regex-automata" -version = "0.3.4" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7b6d6190b7594385f61bd3911cd1be99dfddcfc365a4160cc2ab5bff4aed294" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.7.4", + "regex-syntax", ] [[package]] name = "regex-syntax" -version = "0.6.29" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] -name = "regex-syntax" -version = "0.7.4" +name = "rend" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" +checksum = "71fe3824f5629716b1589be05dacd749f6aa084c87e00e016714a8cdfccc997c" +dependencies = [ + "bytecheck", +] [[package]] name = "reqwest" -version = "0.11.18" +version = "0.12.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde824a14b7c14f85caff81225f411faacc04a2013f41670f41443742b1c1c55" +checksum = "d19c46a6fdd48bc4dab94b6103fccc55d34c67cc0ad04653aad4ea2a07cd7bbb" dependencies = [ "async-compression", - "base64 0.21.2", - "bytes 1.4.0", + "base64 0.22.1", + "bytes", "cookie", "cookie_store", "encoding_rs", @@ -4421,13 +5021,13 @@ dependencies = [ "futures-core", "futures-util", "h2", - "h3", - "h3-quinn", "http", "http-body", + "http-body-util", "hyper", "hyper-rustls", "hyper-tls", + "hyper-util", "ipnet", "js-sys", "log", @@ -4441,101 +5041,122 @@ dependencies = [ "rustls", "rustls-native-certs", "rustls-pemfile", + "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", + "sync_wrapper", + "system-configuration", "tokio", "tokio-native-tls", "tokio-rustls", "tokio-socks", "tokio-util", + "tower", "tower-service", - "trust-dns-resolver", "url", "wasm-bindgen", "wasm-bindgen-futures", "wasm-streams", "web-sys", - "webpki-roots 0.22.6", - "winreg 0.10.1", + "webpki-roots", + "windows-registry 0.4.0", ] [[package]] -name = "resolv-conf" -version = "0.7.0" +name = "rfc6979" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52e44394d2086d010551b14b53b1f24e31647570cd1deb0379e2c21b329aba00" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" dependencies = [ - "hostname", - "quick-error", + "hmac", + "subtle", ] [[package]] name = "rfd" -version = "0.11.4" +version = "0.15.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fe664af397d2b6a13a8ba1d172a2b5c87c6c5149039edbf8fa122b98c9ed96f" +checksum = "80c844748fdc82aae252ee4594a89b6e7ebef1063de7951545564cbc4e57075d" dependencies = [ - "async-io", - "block", - "dispatch", - "futures-util", + "ashpd", + "block2 0.6.0", + "dispatch2", "glib-sys", "gobject-sys", "gtk-sys", "js-sys", "log", - "objc", - "objc-foundation", - "objc_id", + "objc2 0.6.0", + "objc2-app-kit", + "objc2-core-foundation", + "objc2-foundation 0.3.0", "raw-window-handle", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "windows 0.44.0", + "windows-sys 0.59.0", ] [[package]] name = "ring" -version = "0.16.20" +version = "0.17.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" dependencies = [ "cc", + "cfg-if", + "getrandom 0.2.15", "libc", - "once_cell", - "spin 0.5.2", - "untrusted 0.7.1", - "web-sys", - "winapi", + "untrusted", + "windows-sys 0.52.0", ] [[package]] -name = "ring" -version = "0.17.3" +name = "rkyv" +version = "0.7.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9babe80d5c16becf6594aa32ad2be8fe08498e7ae60b77de8df700e67f191d7e" +checksum = "9008cd6385b9e161d8229e1f6549dd23c3d022f132a2ea37ac3a10ac4935779b" dependencies = [ - "cc", - "getrandom 0.2.10", - "libc", - "spin 0.9.8", - "untrusted 0.9.0", - "windows-sys 0.48.0", + "bitvec", + "bytecheck", + "bytes", + "hashbrown 0.12.3", + "ptr_meta", + "rend", + "rkyv_derive", + "seahash", + "tinyvec", + "uuid", +] + +[[package]] +name = "rkyv_derive" +version = "0.7.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "503d1d27590a2b0a3a4ca4c94755aa2875657196ecbf401a42eff41d7de532c0" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", ] +[[package]] +name = "rle-decode-fast" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3582f63211428f83597b51b2ddb88e2a91a9d52d12831f9d08f5e624e8977422" + [[package]] name = "rsa" -version = "0.9.2" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ab43bb47d23c1a631b4b680199a45255dce26fa9ab2fa902581f624ff13e6a8" +checksum = "78928ac1ed176a5ca1d17e578a1825f3d81ca54cf41053a592584b020cfd691b" dependencies = [ - "byteorder", "const-oid", - "digest 0.10.7", + "digest", "num-bigint-dig", "num-integer", - "num-iter", "num-traits", "pkcs1", "pkcs8", @@ -4546,12 +5167,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "runloop" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d79b4b604167921892e84afbbaad9d5ad74e091bf6c511d9dbfb0593f09fabd" - [[package]] name = "rust-argon2" version = "1.0.0" @@ -4564,102 +5179,151 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "rust-argon2" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d9848531d60c9cbbcf9d166c885316c24bc0e2a9d3eba0956bb6cbbd79bc6e8" +dependencies = [ + "base64 0.21.7", + "blake2b_simd", + "constant_time_eq 0.3.1", +] + +[[package]] +name = "rust-ini" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e310ef0e1b6eeb79169a1171daf9abcb87a2e17c03bee2c4bb100b55c75409f" +dependencies = [ + "cfg-if", + "ordered-multimap", + "trim-in-place", +] + +[[package]] +name = "rust_decimal" +version = "1.37.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faa7de2ba56ac291bd90c6b9bece784a52ae1411f9506544b3eae36dd2356d50" +dependencies = [ + "arrayvec", + "borsh", + "bytes", + "num-traits", + "rand 0.8.5", + "rkyv", + "serde", + "serde_json", +] + [[package]] name = "rustc-demangle" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc-hash" -version = "1.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" [[package]] name = "rustc_version" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ "semver", ] [[package]] name = "rustix" -version = "0.37.23" +version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.9.0", "errno", - "io-lifetimes", "libc", - "linux-raw-sys 0.3.8", - "windows-sys 0.48.0", + "linux-raw-sys 0.4.15", + "windows-sys 0.59.0", ] [[package]] name = "rustix" -version = "0.38.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a962918ea88d644592894bc6dc55acc6c0956488adcebbfb6e273506b7fd6e5" +checksum = "d97817398dd4bb2e6da002002db259209759911da105da92bec29ccb12cf58bf" dependencies = [ - "bitflags 2.3.3", + "bitflags 2.9.0", "errno", "libc", - "linux-raw-sys 0.4.3", - "windows-sys 0.48.0", + "linux-raw-sys 0.9.4", + "windows-sys 0.59.0", ] [[package]] name = "rustls" -version = "0.21.7" +version = "0.23.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" +checksum = "df51b5869f3a441595eac5e8ff14d486ff285f7b8c0df8770e49c3b56351f0f0" dependencies = [ - "log", - "ring 0.16.20", + "once_cell", + "ring", + "rustls-pki-types", "rustls-webpki", - "sct", + "subtle", + "zeroize", ] [[package]] name = "rustls-native-certs" -version = "0.6.3" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" +checksum = "7fcff2dd52b58a8d98a70243663a0d234c4e2b79235637849d15913394a247d3" dependencies = [ "openssl-probe", - "rustls-pemfile", + "rustls-pki-types", "schannel", - "security-framework", + "security-framework 3.2.0", ] [[package]] name = "rustls-pemfile" -version = "1.0.3" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" +checksum = "917ce264624a4b4db1c364dcc35bfca9ded014d0a958cd47ad3e960e988ea51c" dependencies = [ - "base64 0.21.2", + "web-time", ] [[package]] name = "rustls-webpki" -version = "0.101.6" +version = "0.103.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c7d5dece342910d9ba34d259310cae3e0154b873b35408b787b59bce53d34fe" +checksum = "fef8b8769aaccf73098557a87cd1816b4f9c7c16811c9c77142aa695c16f2c03" dependencies = [ - "ring 0.16.20", - "untrusted 0.7.1", + "ring", + "rustls-pki-types", + "untrusted", ] [[package]] name = "rustversion" -version = "1.0.14" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" +checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" [[package]] name = "rusty-fork" @@ -4675,15 +5339,18 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.15" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] -name = "safemem" -version = "0.3.3" +name = "salsa20" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" +checksum = "97a22f5af31f73a954c10289c93e8a50cc23d971e80ee446f1f6f7137a088213" +dependencies = [ + "cipher", +] [[package]] name = "same-file" @@ -4696,18 +5363,39 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.22" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" +checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.59.0", ] [[package]] -name = "scoped-tls" -version = "1.0.1" +name = "schemars" +version = "0.8.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fbf2ae1b8bc8e02df939598064d22402220cd5bbcca1c76f7d6a310974d5615" +dependencies = [ + "dyn-clone", + "indexmap 1.9.3", + "schemars_derive", + "serde", + "serde_json", + "url", + "uuid", +] + +[[package]] +name = "schemars_derive" +version = "0.8.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" +checksum = "32e265784ad618884abaea0600a9adf15393368d840e0222d101a072f3f7534d" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 2.0.100", +] [[package]] name = "scopeguard" @@ -4716,23 +5404,57 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] -name = "sct" -version = "0.7.0" +name = "scrypt" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0516a385866c09368f0b5bcd1caff3366aace790fcd46e2bb032697bb172fd1f" +dependencies = [ + "pbkdf2", + "salsa20", + "sha2", +] + +[[package]] +name = "seahash" +version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" + +[[package]] +name = "sec1" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" dependencies = [ - "ring 0.16.20", - "untrusted 0.7.1", + "base16ct", + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", ] [[package]] name = "security-framework" -version = "2.9.2" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ - "bitflags 1.3.2", - "core-foundation", + "bitflags 2.9.0", + "core-foundation 0.9.4", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271720403f46ca04f7ba6f55d438f8bd878d6b8ca0a1046e8228c4145bcbb316" +dependencies = [ + "bitflags 2.9.0", + "core-foundation 0.10.0", "core-foundation-sys", "libc", "security-framework-sys", @@ -4740,9 +5462,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.9.1" +version = "2.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" +checksum = "49db231d56a190491cb4aeda9527f1ad45345af50b0851622a7adb8c03b01c32" dependencies = [ "core-foundation-sys", "libc", @@ -4770,60 +5492,83 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.18" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" +checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0" dependencies = [ "serde", ] [[package]] name = "serde" -version = "1.0.179" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a5bf42b8d227d4abf38a1ddb08602e229108a517cd4e5bb28f9c7eaafdce5c0" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ "serde_derive", ] +[[package]] +name = "serde-untagged" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "299d9c19d7d466db4ab10addd5703e4c615dec2a5a16dbbafe191045e87ee66e" +dependencies = [ + "erased-serde", + "serde", + "typeid", +] + [[package]] name = "serde_derive" -version = "1.0.179" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + +[[package]] +name = "serde_derive_internals" +version = "0.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "741e124f5485c7e60c03b043f79f320bff3527f4bbf12cf3831750dc46a0ec2c" +checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.100", ] [[package]] name = "serde_json" -version = "1.0.104" +version = "1.0.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "076066c5f1078eac5b722a31827a8832fe108bed65dfa75e233c89f8206e976c" +checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" dependencies = [ - "itoa 1.0.9", + "itoa 1.0.15", + "memchr", "ryu", "serde", ] [[package]] name = "serde_repr" -version = "0.1.16" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8725e1dfadb3a50f7e5ce0b1a540466f6ed3fe7a0fca2ac2b8b831d31316bd00" +checksum = "175ee3e80ae9982737ca543e96133087cbd9a485eecc3bc4de9c1a37b47ea59c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.100", ] [[package]] name = "serde_spanned" -version = "0.6.3" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" +checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" dependencies = [ "serde", ] @@ -4835,37 +5580,39 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" dependencies = [ "form_urlencoded", - "itoa 1.0.9", + "itoa 1.0.15", "ryu", "serde", ] [[package]] name = "serde_with" -version = "3.1.0" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21e47d95bc83ed33b2ecf84f4187ad1ab9685d18ff28db000c99deac8ce180e3" +checksum = "d6b6f7f2fcb69f747921f79f3926bd1e203fce4fef62c268dd3abfb6d86029aa" dependencies = [ - "base64 0.21.2", + "base64 0.22.1", "chrono", "hex", "indexmap 1.9.3", + "indexmap 2.9.0", "serde", + "serde_derive", "serde_json", "serde_with_macros", - "time 0.3.24", + "time", ] [[package]] name = "serde_with_macros" -version = "3.1.0" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea3cee93715c2e266b9338b7544da68a9f24e227722ba482bd1c024367c77c65" +checksum = "8d00caa5193a3c8362ac2b73be6b9e768aa5a4b2f721d8f4b339600c3cb51f8e" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.100", ] [[package]] @@ -4902,84 +5649,58 @@ dependencies = [ [[package]] name = "sha1" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest 0.10.7", -] - -[[package]] -name = "sha2" -version = "0.9.9" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" dependencies = [ - "block-buffer 0.9.0", "cfg-if", "cpufeatures", - "digest 0.9.0", - "opaque-debug", + "digest", ] [[package]] name = "sha2" -version = "0.10.7" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.10.7", -] - -[[package]] -name = "sharded-slab" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" -dependencies = [ - "lazy_static", + "digest", ] [[package]] name = "shared_child" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0d94659ad3c2137fef23ae75b03d5241d633f8acded53d672decfa0e6e0caef" +checksum = "09fa9338aed9a1df411814a5b2252f7cd206c55ae9bf2fa763f8de84603aa60c" dependencies = [ "libc", - "winapi", + "windows-sys 0.59.0", ] [[package]] -name = "signal-hook" -version = "0.3.17" +name = "shlex" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801" -dependencies = [ - "libc", - "signal-hook-registry", -] +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "signal-hook-registry" -version = "1.4.1" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" dependencies = [ "libc", ] [[package]] name = "signature" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ - "digest 0.10.7", + "digest", "rand_core 0.6.4", ] @@ -4989,11 +5710,17 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" +[[package]] +name = "simdutf8" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" + [[package]] name = "similar" -version = "2.2.1" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "420acb44afdae038210c99e69aae24109f32f15500aa708e81d46c9f29d55fcf" +checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa" [[package]] name = "single-instance-example" @@ -5003,70 +5730,90 @@ dependencies = [ "serde_json", "tauri", "tauri-build", + "tauri-plugin-cli", "tauri-plugin-single-instance", ] [[package]] name = "siphasher" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" [[package]] -name = "slab" -version = "0.4.8" +name = "siphasher" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ "autocfg", ] [[package]] name = "smallvec" -version = "1.11.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" +checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9" +dependencies = [ + "serde", +] [[package]] name = "socket2" -version = "0.4.9" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" +checksum = "4f5fd57c80058a56cf5c777ab8a126398ece8e442983605d280a44ce79d0edef" dependencies = [ "libc", - "winapi", + "windows-sys 0.52.0", ] [[package]] -name = "socket2" -version = "0.5.3" +name = "softbuffer" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877" +checksum = "18051cdd562e792cad055119e0cdb2cfc137e44e3987532e0f9659a77931bb08" dependencies = [ - "libc", - "windows-sys 0.48.0", + "bytemuck", + "cfg_aliases", + "core-graphics", + "foreign-types 0.5.0", + "js-sys", + "log", + "objc2 0.5.2", + "objc2-foundation 0.2.2", + "objc2-quartz-core 0.2.2", + "raw-window-handle", + "redox_syscall", + "wasm-bindgen", + "web-sys", + "windows-sys 0.59.0", ] [[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", "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", @@ -5076,10 +5823,27 @@ dependencies = [ ] [[package]] -name = "spin" -version = "0.5.2" +name = "specta" +version = "2.0.0-rc.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab7f01e9310a820edd31c80fde3cae445295adde21a3f9416517d7d65015b971" +dependencies = [ + "paste", + "specta-macros", + "thiserror 1.0.69", +] + +[[package]] +name = "specta-macros" +version = "2.0.0-rc.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +checksum = "c0074b9e30ed84c6924eb63ad8d2fe71cdc82628525d84b1fcb1f2fd40676517" +dependencies = [ + "Inflector", + "proc-macro2", + "quote", + "syn 2.0.100", +] [[package]] name = "spin" @@ -5092,30 +5856,19 @@ dependencies = [ [[package]] name = "spki" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" dependencies = [ "base64ct", "der", ] -[[package]] -name = "sqlformat" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c12bc9199d1db8234678b7051747c07f517cdcf019262d1847b94ec8b1aee3e" -dependencies = [ - "itertools", - "nom", - "unicode_categories", -] - [[package]] name = "sqlx" -version = "0.7.1" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e58421b6bc416714d5115a2ca953718f6c621a51b68e4f4922aea5a4391a721" +checksum = "f3c3a85280daca669cfd3bcb68a337882a8bc57ec882f72c5d13a430613a738e" dependencies = [ "sqlx-core", "sqlx-macros", @@ -5126,82 +5879,75 @@ dependencies = [ [[package]] name = "sqlx-core" -version = "0.7.1" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd4cef4251aabbae751a3710927945901ee1d97ee96d757f6880ebb9a79bfd53" +checksum = "f743f2a3cea30a58cd479013f75550e879009e3a02f616f18ca699335aa248c3" dependencies = [ - "ahash 0.8.3", - "atoi", - "byteorder", - "bytes 1.4.0", + "base64 0.22.1", + "bytes", "crc", "crossbeam-queue", - "dotenvy", "either", "event-listener", - "futures-channel", "futures-core", "futures-intrusive", "futures-io", "futures-util", + "hashbrown 0.15.2", "hashlink", - "hex", - "indexmap 2.0.0", + "indexmap 2.9.0", "log", "memchr", "once_cell", - "paste", "percent-encoding", "rustls", - "rustls-pemfile", "serde", "serde_json", - "sha2 0.10.7", + "sha2", "smallvec", - "sqlformat", - "thiserror", - "time 0.3.24", + "thiserror 2.0.12", + "time", "tokio", "tokio-stream", "tracing", "url", - "webpki-roots 0.24.0", + "webpki-roots", ] [[package]] name = "sqlx-macros" -version = "0.7.1" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "208e3165167afd7f3881b16c1ef3f2af69fa75980897aac8874a0696516d12c2" +checksum = "7f4200e0fde19834956d4252347c12a083bdcb237d7a1a1446bffd8768417dce" dependencies = [ "proc-macro2", "quote", "sqlx-core", "sqlx-macros-core", - "syn 1.0.109", + "syn 2.0.100", ] [[package]] name = "sqlx-macros-core" -version = "0.7.1" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a4a8336d278c62231d87f24e8a7a74898156e34c1c18942857be2acb29c7dfc" +checksum = "882ceaa29cade31beca7129b6beeb05737f44f82dbe2a9806ecea5a7093d00b7" dependencies = [ "dotenvy", "either", - "heck", + "heck 0.5.0", "hex", "once_cell", "proc-macro2", "quote", "serde", "serde_json", - "sha2 0.10.7", + "sha2", "sqlx-core", "sqlx-mysql", "sqlx-postgres", "sqlx-sqlite", - "syn 1.0.109", + "syn 2.0.100", "tempfile", "tokio", "url", @@ -5209,17 +5955,17 @@ dependencies = [ [[package]] name = "sqlx-mysql" -version = "0.7.1" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ca69bf415b93b60b80dc8fda3cb4ef52b2336614d8da2de5456cc942a110482" +checksum = "0afdd3aa7a629683c2d750c2df343025545087081ab5942593a5288855b1b7a7" dependencies = [ "atoi", - "base64 0.21.2", - "bitflags 2.3.3", + "base64 0.22.1", + "bitflags 2.9.0", "byteorder", - "bytes 1.4.0", + "bytes", "crc", - "digest 0.10.7", + "digest", "dotenvy", "either", "futures-channel", @@ -5230,7 +5976,7 @@ dependencies = [ "hex", "hkdf", "hmac", - "itoa 1.0.9", + "itoa 1.0.15", "log", "md-5", "memchr", @@ -5240,38 +5986,37 @@ dependencies = [ "rsa", "serde", "sha1", - "sha2 0.10.7", + "sha2", "smallvec", "sqlx-core", "stringprep", - "thiserror", - "time 0.3.24", + "thiserror 2.0.12", + "time", "tracing", "whoami", ] [[package]] name = "sqlx-postgres" -version = "0.7.1" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0db2df1b8731c3651e204629dd55e52adbae0462fa1bdcbed56a2302c18181e" +checksum = "a0bedbe1bbb5e2615ef347a5e9d8cd7680fb63e77d9dafc0f29be15e53f1ebe6" dependencies = [ "atoi", - "base64 0.21.2", - "bitflags 2.3.3", + "base64 0.22.1", + "bitflags 2.9.0", "byteorder", "crc", "dotenvy", "etcetera", "futures-channel", "futures-core", - "futures-io", "futures-util", "hex", "hkdf", "hmac", "home", - "itoa 1.0.9", + "itoa 1.0.15", "log", "md-5", "memchr", @@ -5279,22 +6024,21 @@ dependencies = [ "rand 0.8.5", "serde", "serde_json", - "sha1", - "sha2 0.10.7", + "sha2", "smallvec", "sqlx-core", "stringprep", - "thiserror", - "time 0.3.24", + "thiserror 2.0.12", + "time", "tracing", "whoami", ] [[package]] name = "sqlx-sqlite" -version = "0.7.1" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4c21bf34c7cae5b283efb3ac1bcc7670df7561124dc2f8bdc0b59be40f79a2" +checksum = "c26083e9a520e8eb87a06b12347679b142dc2ea29e6e409f805644a7a979a5bc" dependencies = [ "atoi", "flume", @@ -5307,8 +6051,10 @@ dependencies = [ "log", "percent-encoding", "serde", + "serde_urlencoded", "sqlx-core", - "time 0.3.24", + "thiserror 2.0.12", + "time", "tracing", "url", ] @@ -5319,61 +6065,46 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" -[[package]] -name = "state" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b8c4a4445d81357df8b1a650d0d0d6fbbbfe99d064aa5e02f3e4022061476d8" -dependencies = [ - "loom", -] - [[package]] name = "static_assertions" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "str-buf" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e08d8363704e6c71fc928674353e6b7c23dcea9d82d7012c8faf2a3a025f8d0" - [[package]] name = "string_cache" -version = "0.8.7" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f91138e76242f575eb1d3b38b4f1362f10d3a43f47d182a5b359af488a02293b" +checksum = "bf776ba3fa74f83bf4b63c3dcbbf82173db2632ed8452cb2d891d33f459de70f" dependencies = [ "new_debug_unreachable", - "once_cell", "parking_lot", - "phf_shared 0.10.0", + "phf_shared 0.11.3", "precomputed-hash", "serde", ] [[package]] name = "string_cache_codegen" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bb30289b722be4ff74a408c3cc27edeaad656e06cb1fe8fa9231fa59c728988" +checksum = "c711928715f1fe0fe509c53b43e993a9a557babc2d0a3567d0a3006f1ac931a0" dependencies = [ - "phf_generator 0.10.0", - "phf_shared 0.10.0", + "phf_generator 0.11.3", + "phf_shared 0.11.3", "proc-macro2", "quote", ] [[package]] name = "stringprep" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3737bde7edce97102e0e2b15365bf7a20bfdb5f60f4f9e8d7004258a51a8da" +checksum = "7b4df3d392d81bd458a8a621b8bffbd2302a12ffe288a9d931670948749463b1" dependencies = [ "unicode-bidi", "unicode-normalization", + "unicode-properties", ] [[package]] @@ -5389,19 +6120,19 @@ dependencies = [ [[package]] name = "stronghold-runtime" -version = "1.0.2" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d93abb10fbd11335d31c33a70b2523c0caab348215caa2ce6da04a268c30afcb" +checksum = "18db7cc51450cefdab5f4990e128dd02c98da6d2992b93ffef8992ac0d2f3ddf" dependencies = [ - "dirs", - "iota-crypto 0.15.3", + "dirs 4.0.0", + "iota-crypto", "libc", - "libsodium-sys", + "libsodium-sys-stable", "log", "nix 0.24.3", "rand 0.8.5", "serde", - "thiserror", + "thiserror 1.0.69", "windows 0.36.1", "zeroize", ] @@ -5418,41 +6149,41 @@ dependencies = [ [[package]] name = "stronghold_engine" -version = "1.0.2" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d68a609d0a4f05dbde8b704619faa7f861069bbc649e3abecb4d389f10236f" +checksum = "2fd7371c42e557dd71a7f860bb2ec6b6fdb32f97a97987ccc2435fdd1f3a8615" dependencies = [ "anyhow", "dirs-next", "hex", - "iota-crypto 0.15.3", + "iota-crypto", "once_cell", "paste", "serde", "stronghold-runtime", - "thiserror", + "thiserror 1.0.69", "zeroize", ] [[package]] name = "strsim" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "subtle" -version = "2.5.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "swift-rs" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bbdb58577b6301f8d17ae2561f32002a5bae056d444e0f69e611e504a276204" +checksum = "4057c98e2e852d51fdcfca832aac7b571f6b351ad159f9eda5db1655f8d0c4d7" dependencies = [ - "base64 0.21.2", + "base64 0.21.7", "serde", "serde_json", ] @@ -5470,33 +6201,73 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.28" +version = "2.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567" +checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", +] + +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + [[package]] name = "sys-locale" -version = "0.3.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea0b9eefabb91675082b41eb94c3ecd91af7656caee3fb4961a07c0ec8c7ca6f" +checksum = "8eab9a99a024a169fe8a903cf9d4a3b3601109bcc13bd9e3c6fff259138626c4" dependencies = [ "libc", - "windows-sys 0.45.0", +] + +[[package]] +name = "system-configuration" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" +dependencies = [ + "bitflags 2.9.0", + "core-foundation 0.9.4", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +dependencies = [ + "core-foundation-sys", + "libc", ] [[package]] name = "system-deps" -version = "6.1.1" +version = "6.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30c2de8a4d8f4b823d634affc9cd2a74ec98c53a756f317e529a48046cbf71f3" +checksum = "a3e535eb8dded36d55ec13eddacd30dec501792ff23a0b1682c38601b8cf2349" dependencies = [ "cfg-expr", - "heck", + "heck 0.5.0", "pkg-config", "toml", "version-compare", @@ -5504,29 +6275,20 @@ dependencies = [ [[package]] name = "tao" -version = "0.22.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60279ecb16c33a6cef45cd37a9602455c190942d20e360bd8499bff49f2a48f3" +checksum = "1e59c1f38e657351a2e822eadf40d6a2ad4627b9c25557bc1180ec1b3295ef82" dependencies = [ - "bitflags 1.3.2", - "cairo-rs", - "cc", - "cocoa 0.24.1", - "core-foundation", - "core-graphics 0.22.3", + "bitflags 2.9.0", + "core-foundation 0.10.0", + "core-graphics", "crossbeam-channel", "dispatch", - "gdk", - "gdk-pixbuf", - "gdk-sys", + "dlopen2", + "dpi", "gdkwayland-sys", "gdkx11-sys", - "gio", - "glib", - "glib-sys", "gtk", - "image", - "instant", "jni", "lazy_static", "libc", @@ -5534,39 +6296,44 @@ dependencies = [ "ndk", "ndk-context", "ndk-sys", - "objc", + "objc2 0.6.0", + "objc2-app-kit", + "objc2-foundation 0.3.0", "once_cell", "parking_lot", - "png", "raw-window-handle", "scopeguard", - "serde", "tao-macros", "unicode-segmentation", "url", - "uuid", - "windows 0.48.0", - "windows-implement 0.48.0", + "windows 0.61.1", + "windows-core", + "windows-version", "x11-dl", - "zbus", ] [[package]] name = "tao-macros" -version = "0.1.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b27a4bcc5eb524658234589bdffc7e7bfb996dbae6ce9393bfd39cb4159b445" +checksum = "f4e16beb8b2ac17db28eab8bca40e62dbfbb34c0fcdc6d9826b11b7b5d047dfd" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.100", ] +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + [[package]] name = "tar" -version = "0.4.39" +version = "0.4.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec96d2ffad078296368d46ff1cb309be1c23c513b4ab0e22a45de0185275ac96" +checksum = "1d863878d212c87a19c1a610eb53bb01fe12951c0501cf5a0d65f724914a667a" dependencies = [ "filetime", "libc", @@ -5575,93 +6342,96 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.10" +version = "0.12.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2faeef5759ab89935255b1a4cd98e0baf99d1085e37d36599c625dac49ae8e" +checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "tauri" -version = "2.0.0-alpha.16" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "350fce27e96fda5a5741ae200ebf775cc3423c682154224cfbd78066db777fc6" +checksum = "be03adf68fba02f87c4653da7bd73f40b0ecf9c6b7c2c39830f6981d0651912f" dependencies = [ "anyhow", - "bytes 1.4.0", - "cocoa 0.25.0", - "dirs-next", + "bytes", + "dirs 6.0.0", + "dunce", "embed_plist", "futures-util", - "getrandom 0.2.10", - "glib", + "getrandom 0.2.15", "glob", "gtk", - "heck", + "heck 0.5.0", "http", "http-range", - "ico", - "infer", + "image", "jni", "libc", "log", "mime", "muda", - "objc", - "once_cell", + "objc2 0.6.0", + "objc2-app-kit", + "objc2-foundation 0.3.0", + "objc2-ui-kit", "percent-encoding", - "png", + "plist", "raw-window-handle", "reqwest", "serde", "serde_json", "serde_repr", "serialize-to-javascript", - "state", + "specta", "swift-rs", "tauri-build", "tauri-macros", "tauri-runtime", "tauri-runtime-wry", "tauri-utils", - "thiserror", + "thiserror 2.0.12", "tokio", "tray-icon", "url", + "urlpattern", "uuid", "webkit2gtk", "webview2-com", "window-vibrancy", - "windows 0.48.0", + "windows 0.61.1", ] [[package]] name = "tauri-build" -version = "2.0.0-alpha.10" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55e3fe1435d7bcf64d15182815f5e1b0b05ec71cd365ed5055204efb5436ebc4" +checksum = "d7a0350f0df1db385ca5c02888a83e0e66655c245b7443db8b78a70da7d7f8fc" dependencies = [ "anyhow", "cargo_toml", - "heck", + "dirs 6.0.0", + "glob", + "heck 0.5.0", "json-patch", - "plist", "quote", + "schemars", "semver", "serde", "serde_json", - "swift-rs", "tauri-codegen", "tauri-utils", "tauri-winres", + "toml", "walkdir", ] [[package]] name = "tauri-codegen" -version = "2.0.0-alpha.9" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff206ba5a7de8f20068f36d5fa49756a9fd375a156a2332278273b6d0dc57033" +checksum = "f93f035551bf7b11b3f51ad9bc231ebbe5e085565527991c16cf326aa38cdf47" dependencies = [ - "base64 0.21.2", + "base64 0.22.1", "brotli", "ico", "json-patch", @@ -5672,10 +6442,11 @@ dependencies = [ "semver", "serde", "serde_json", - "sha2 0.10.7", + "sha2", + "syn 2.0.100", "tauri-utils", - "thiserror", - "time 0.3.24", + "thiserror 2.0.12", + "time", "url", "uuid", "walkdir", @@ -5683,212 +6454,310 @@ dependencies = [ [[package]] name = "tauri-macros" -version = "2.0.0-alpha.9" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29a29d42cca831a9d9c8be91412ef6416813e7307e8dcfd1df38f3b13f3cc73" +checksum = "8db4df25e2d9d45de0c4c910da61cd5500190da14ae4830749fee3466dddd112" dependencies = [ - "heck", + "heck 0.5.0", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.100", "tauri-codegen", "tauri-utils", ] [[package]] -name = "tauri-plugin-authenticator" -version = "2.0.0-alpha.2" +name = "tauri-plugin" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37a5ebe6a610d1b78a94650896e6f7c9796323f408800cef436e0fa0539de601" dependencies = [ - "authenticator", - "base64 0.21.2", - "chrono", - "log", - "once_cell", - "rand 0.8.5", - "rusty-fork", + "anyhow", + "glob", + "plist", + "schemars", "serde", "serde_json", - "sha2 0.10.7", - "tauri", - "thiserror", - "u2f", + "tauri-utils", + "toml", + "walkdir", ] [[package]] name = "tauri-plugin-autostart" -version = "2.0.0-alpha.2" +version = "2.3.0" dependencies = [ "auto-launch", - "log", "serde", "serde_json", "tauri", - "thiserror", + "tauri-plugin", + "thiserror 2.0.12", ] [[package]] name = "tauri-plugin-barcode-scanner" -version = "2.0.0-alpha.0" +version = "2.2.0" dependencies = [ "log", "serde", "serde_json", "tauri", - "tauri-build", - "thiserror", + "tauri-plugin", + "thiserror 2.0.12", +] + +[[package]] +name = "tauri-plugin-biometric" +version = "2.2.1" +dependencies = [ + "log", + "serde", + "serde_json", + "serde_repr", + "tauri", + "tauri-plugin", + "thiserror 2.0.12", ] [[package]] name = "tauri-plugin-cli" -version = "2.0.0-alpha.2" +version = "2.2.0" dependencies = [ "clap", "log", "serde", "serde_json", "tauri", - "thiserror", + "tauri-plugin", + "thiserror 2.0.12", ] [[package]] name = "tauri-plugin-clipboard-manager" -version = "2.0.0-alpha.2" +version = "2.2.2" dependencies = [ "arboard", "log", "serde", "serde_json", "tauri", - "tauri-build", - "thiserror", + "tauri-plugin", + "thiserror 2.0.12", ] [[package]] name = "tauri-plugin-deep-link" -version = "2.0.0-alpha.0" +version = "2.3.0" dependencies = [ - "log", + "dunce", + "rust-ini", "serde", "serde_json", "tauri", - "tauri-build", - "thiserror", + "tauri-plugin", + "tauri-utils", + "thiserror 2.0.12", + "tracing", "url", + "windows-registry 0.5.1", + "windows-result", ] [[package]] name = "tauri-plugin-dialog" -version = "2.0.0-alpha.2" +version = "2.2.2" dependencies = [ - "glib", "log", "raw-window-handle", "rfd", "serde", "serde_json", "tauri", - "tauri-build", + "tauri-plugin", "tauri-plugin-fs", - "thiserror", + "thiserror 2.0.12", + "url", ] [[package]] name = "tauri-plugin-fs" -version = "2.0.0-alpha.2" +version = "2.3.0" dependencies = [ "anyhow", + "dunce", "glob", "notify", - "notify-debouncer-mini", + "notify-debouncer-full", + "percent-encoding", + "schemars", "serde", + "serde_json", + "serde_repr", "tauri", - "thiserror", - "uuid", + "tauri-plugin", + "tauri-utils", + "thiserror 2.0.12", + "toml", + "url", +] + +[[package]] +name = "tauri-plugin-geolocation" +version = "2.2.4" +dependencies = [ + "log", + "serde", + "serde_json", + "specta", + "tauri", + "tauri-plugin", + "thiserror 2.0.12", ] [[package]] name = "tauri-plugin-global-shortcut" -version = "2.0.0-alpha.2" +version = "2.2.1" dependencies = [ "global-hotkey", "log", "serde", "serde_json", "tauri", - "thiserror", + "tauri-plugin", + "thiserror 2.0.12", +] + +[[package]] +name = "tauri-plugin-haptics" +version = "2.2.4" +dependencies = [ + "log", + "serde", + "serde_json", + "specta", + "tauri", + "tauri-plugin", + "thiserror 2.0.12", ] [[package]] name = "tauri-plugin-http" -version = "2.0.0-alpha.3" +version = "2.4.4" dependencies = [ + "bytes", + "cookie_store", "data-url", - "glob", "http", + "regex", "reqwest", + "schemars", "serde", "serde_json", "tauri", + "tauri-plugin", "tauri-plugin-fs", - "thiserror", + "thiserror 2.0.12", + "tokio", + "tracing", "url", + "urlpattern", ] [[package]] name = "tauri-plugin-localhost" -version = "2.0.0-alpha.2" +version = "2.2.0" dependencies = [ "http", "log", "serde", "serde_json", "tauri", - "thiserror", - "tiny_http 0.12.0", + "thiserror 2.0.12", + "tiny_http", ] [[package]] name = "tauri-plugin-log" -version = "2.0.0-alpha.2" +version = "2.4.0" dependencies = [ "android_logger", "byte-unit", - "cocoa 0.24.1", "fern", "log", - "objc", + "objc2 0.6.0", + "objc2-foundation 0.3.0", "serde", "serde_json", "serde_repr", "swift-rs", "tauri", - "tauri-build", - "time 0.3.24", + "tauri-plugin", + "thiserror 2.0.12", + "time", + "tracing", ] [[package]] -name = "tauri-plugin-notification" -version = "2.0.0-alpha.3" +name = "tauri-plugin-nfc" +version = "2.2.0" dependencies = [ "log", - "notify-rust", - "rand 0.8.5", "serde", "serde_json", "serde_repr", "tauri", - "tauri-build", - "thiserror", - "time 0.3.24", - "url", - "win7-notifications", + "tauri-plugin", + "thiserror 2.0.12", ] [[package]] -name = "tauri-plugin-os" -version = "2.0.0-alpha.2" +name = "tauri-plugin-notification" +version = "2.2.2" dependencies = [ - "gethostname 0.4.3", + "color-backtrace", + "ctor", + "log", + "maplit", + "notify-rust", + "rand 0.8.5", + "serde", + "serde_json", + "serde_repr", + "tauri", + "tauri-plugin", + "thiserror 2.0.12", + "time", + "url", + "win7-notifications", + "windows-version", +] + +[[package]] +name = "tauri-plugin-opener" +version = "2.2.7" +dependencies = [ + "dunce", + "glob", + "objc2-app-kit", + "objc2-foundation 0.3.0", + "open", + "schemars", + "serde", + "serde_json", + "tauri", + "tauri-plugin", + "thiserror 2.0.12", + "url", + "windows 0.61.1", + "zbus", +] + +[[package]] +name = "tauri-plugin-os" +version = "2.2.1" +dependencies = [ + "gethostname 1.0.1", "log", "os_info", "serde", @@ -5896,12 +6765,13 @@ dependencies = [ "serialize-to-javascript", "sys-locale", "tauri", - "thiserror", + "tauri-plugin", + "thiserror 2.0.12", ] [[package]] name = "tauri-plugin-persisted-scope" -version = "2.0.0-alpha.2" +version = "2.2.2" dependencies = [ "aho-corasick", "bincode", @@ -5910,111 +6780,129 @@ dependencies = [ "serde_json", "tauri", "tauri-plugin-fs", - "thiserror", + "thiserror 2.0.12", ] [[package]] name = "tauri-plugin-positioner" -version = "2.0.0-alpha.2" +version = "2.2.0" dependencies = [ "log", "serde", "serde_json", "serde_repr", "tauri", - "thiserror", + "tauri-plugin", + "thiserror 2.0.12", ] [[package]] name = "tauri-plugin-process" -version = "2.0.0-alpha.2" +version = "2.2.1" dependencies = [ "tauri", + "tauri-plugin", ] [[package]] name = "tauri-plugin-shell" -version = "2.0.0-alpha.2" +version = "2.2.1" dependencies = [ "encoding_rs", "log", "open", "os_pipe", "regex", + "schemars", "serde", "serde_json", "shared_child", "tauri", - "thiserror", + "tauri-plugin", + "thiserror 2.0.12", + "tokio", ] [[package]] name = "tauri-plugin-single-instance" -version = "2.0.0-alpha.2" +version = "2.2.4" dependencies = [ - "log", + "semver", "serde", "serde_json", "tauri", - "thiserror", - "windows-sys 0.48.0", + "tauri-plugin-deep-link", + "thiserror 2.0.12", + "tracing", + "windows-sys 0.59.0", "zbus", ] [[package]] name = "tauri-plugin-sql" -version = "2.0.0-alpha.2" +version = "2.2.0" dependencies = [ "futures-core", + "indexmap 2.9.0", "log", "serde", "serde_json", "sqlx", "tauri", - "thiserror", - "time 0.3.24", + "tauri-plugin", + "thiserror 2.0.12", + "time", "tokio", ] [[package]] name = "tauri-plugin-store" -version = "2.0.0-alpha.2" +version = "2.2.0" dependencies = [ - "log", + "dunce", "serde", "serde_json", "tauri", - "thiserror", + "tauri-plugin", + "thiserror 2.0.12", + "tokio", + "tracing", ] [[package]] name = "tauri-plugin-stronghold" -version = "2.0.0-alpha.2" +version = "2.2.0" dependencies = [ "hex", - "iota-crypto 0.23.0", + "iota-crypto", "iota_stronghold", "log", "rand 0.8.5", + "rand_chacha 0.3.1", + "rand_core 0.6.4", + "rust-argon2 2.1.0", "rusty-fork", "serde", "serde_json", "tauri", - "thiserror", + "tauri-plugin", + "thiserror 2.0.12", "zeroize", ] [[package]] name = "tauri-plugin-updater" -version = "2.0.0-alpha.2" +version = "2.7.1" dependencies = [ - "base64 0.21.2", - "dirs-next", + "base64 0.22.1", + "dirs 6.0.0", "flate2", "futures-util", "http", + "infer", + "log", "minisign-verify", - "mockito", + "osakit", "percent-encoding", "reqwest", "semver", @@ -6022,134 +6910,159 @@ dependencies = [ "serde_json", "tar", "tauri", + "tauri-plugin", "tempfile", - "thiserror", - "time 0.3.24", + "thiserror 2.0.12", + "time", "tokio", "url", - "zip", + "windows-sys 0.59.0", + "zip 4.0.0", ] [[package]] name = "tauri-plugin-upload" -version = "2.0.0-alpha.2" +version = "2.2.1" dependencies = [ "futures-util", "log", + "mockito", "read-progress-stream", "reqwest", "serde", "serde_json", "tauri", - "thiserror", + "tauri-plugin", + "thiserror 2.0.12", "tokio", "tokio-util", ] [[package]] name = "tauri-plugin-websocket" -version = "2.0.0-alpha.2" +version = "2.3.0" dependencies = [ "futures-util", + "http", "log", "rand 0.8.5", "serde", "serde_json", "tauri", - "thiserror", + "tauri-plugin", + "thiserror 2.0.12", "tokio", "tokio-tungstenite", ] [[package]] name = "tauri-plugin-window-state" -version = "2.0.0-alpha.2" +version = "2.2.2" dependencies = [ - "bincode", - "bitflags 2.3.3", + "bitflags 2.9.0", "log", "serde", "serde_json", "tauri", - "thiserror", + "tauri-plugin", + "thiserror 2.0.12", ] [[package]] name = "tauri-runtime" -version = "1.0.0-alpha.3" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c373492a8e2d369c638bff48fc07abbe7292f8ddb867bc3b992fb7ea10006212" +checksum = "00f004905d549854069e6774533d742b03cacfd6f03deb08940a8677586cbe39" dependencies = [ + "cookie", + "dpi", "gtk", "http", "jni", + "objc2 0.6.0", + "objc2-ui-kit", "raw-window-handle", "serde", "serde_json", "tauri-utils", - "thiserror", + "thiserror 2.0.12", "url", - "windows 0.48.0", + "windows 0.61.1", ] [[package]] name = "tauri-runtime-wry" -version = "1.0.0-alpha.4" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef7b8a49504f67c65a55188013439edf815356a6f8e2a9d2ed005120a201c98f" +checksum = "f85d056f4d4b014fe874814034f3416d57114b617a493a4fe552580851a3f3a2" dependencies = [ - "cocoa 0.24.1", "gtk", "http", "jni", + "log", + "objc2 0.6.0", + "objc2-app-kit", + "objc2-foundation 0.3.0", + "once_cell", "percent-encoding", "raw-window-handle", + "softbuffer", + "tao", "tauri-runtime", "tauri-utils", + "url", "webkit2gtk", "webview2-com", - "windows 0.48.0", + "windows 0.61.1", "wry", ] [[package]] name = "tauri-utils" -version = "2.0.0-alpha.9" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b821e0e6b5b94c6bde3c95568f5161eb70939a7b0d511f79c0cf85fed3b29c9" +checksum = "b2900399c239a471bcff7f15c4399eb1a8c4fe511ba2853e07c996d771a5e0a4" dependencies = [ - "aes-gcm 0.10.2", + "aes-gcm", + "anyhow", "brotli", + "cargo_metadata", "ctor", "dunce", - "getrandom 0.2.10", + "getrandom 0.2.15", "glob", - "heck", "html5ever", + "http", "infer", "json-patch", "kuchikiki", "log", "memchr", - "phf 0.11.2", + "phf 0.11.3", "proc-macro2", "quote", + "regex", + "schemars", "semver", "serde", + "serde-untagged", "serde_json", "serde_with", "serialize-to-javascript", - "thiserror", + "swift-rs", + "thiserror 2.0.12", + "toml", "url", + "urlpattern", + "uuid", "walkdir", - "windows 0.51.1", ] [[package]] name = "tauri-winres" -version = "0.1.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5993dc129e544393574288923d1ec447c857f3f644187f4fbf7d9a875fbfc4fb" +checksum = "56eaa45f707bedf34d19312c26d350bc0f3c59a47e58e8adbeecdc850d2c13a0" dependencies = [ "embed-resource", "toml", @@ -6157,25 +7070,27 @@ dependencies = [ [[package]] name = "tauri-winrt-notification" -version = "0.1.2" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f5bff1d532fead7c43324a0fa33643b8621a47ce2944a633be4cb6c0240898f" +checksum = "0b1e66e07de489fe43a46678dd0b8df65e0c973909df1b60ba33874e297ba9b9" dependencies = [ - "quick-xml 0.23.1", - "windows 0.39.0", + "quick-xml 0.37.4", + "thiserror 2.0.12", + "windows 0.61.1", + "windows-version", ] [[package]] name = "tempfile" -version = "3.7.0" +version = "3.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5486094ee78b2e5038a6382ed7645bc084dc2ec433426ca4c3cb61e2007b8998" +checksum = "7437ac7763b9b123ccf33c338a5cc1bac6f69b45a136c19bdd8a65e3916435bf" dependencies = [ - "cfg-if", - "fastrand 2.0.0", - "redox_syscall 0.3.5", - "rustix 0.38.4", - "windows-sys 0.48.0", + "fastrand", + "getrandom 0.3.2", + "once_cell", + "rustix 1.0.5", + "windows-sys 0.59.0", ] [[package]] @@ -6189,6 +7104,15 @@ dependencies = [ "utf-8", ] +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + [[package]] name = "thin-slice" version = "0.1.1" @@ -6197,39 +7121,49 @@ checksum = "8eaa81235c7058867fa8c0e7314f33dcce9c215f535d1913822a2b3f5e289f3c" [[package]] name = "thiserror" -version = "1.0.44" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "611040a08a0439f8248d1990b111c95baa9c704c805fa1f62104b39655fd7f90" +checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" dependencies = [ - "thiserror-impl", + "thiserror-impl 2.0.12", ] [[package]] name = "thiserror-impl" -version = "1.0.44" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090198534930841fab3a5d1bb637cde49e339654e606195f8d9c76eeb081dc96" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.100", ] [[package]] -name = "thread_local" -version = "1.1.7" +name = "thiserror-impl" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" dependencies = [ - "cfg-if", - "once_cell", + "proc-macro2", + "quote", + "syn 2.0.100", ] [[package]] name = "tiff" -version = "0.8.1" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7449334f9ff2baf290d55d73983a7d6fa15e01198faef72af07e2a8db851e471" +checksum = "ba1310fcea54c6a9a4fd1aad794ecc02c31682f6bfbecdf460bf19533eed1e3e" dependencies = [ "flate2", "jpeg-decoder", @@ -6238,25 +7172,16 @@ dependencies = [ [[package]] name = "time" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" -dependencies = [ - "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi", -] - -[[package]] -name = "time" -version = "0.3.24" +version = "0.3.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b79eabcd964882a646b3584543ccabeae7869e9ac32a46f6f22b7a5bd405308b" +checksum = "8a7619e19bc266e0f9c5e6686659d394bc57973859340060a69221e57dbc0c40" dependencies = [ "deranged", - "itoa 1.0.9", + "itoa 1.0.15", "libc", + "num-conv", "num_threads", + "powerfmt", "serde", "time-core", "time-macros", @@ -6264,30 +7189,27 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.1" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" +checksum = "c9e9a38711f559d9e3ce1cdb06dd7c5b8ea546bc90052da6d06bb76da74bb07c" [[package]] name = "time-macros" -version = "0.2.11" +version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb71511c991639bb078fd5bf97757e03914361c48100d52878b8e52b46fb92cd" +checksum = "3526739392ec93fd8b359c8e98514cb3e8e021beb4e5f597b00a0221f8ed8a49" dependencies = [ + "num-conv", "time-core", ] [[package]] -name = "tiny_http" -version = "0.11.0" +name = "tiny-keccak" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0d6ef4e10d23c1efb862eecad25c5054429a71958b4eeef85eb5e7170b477ca" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" dependencies = [ - "ascii", - "chunked_transfer", - "log", - "time 0.3.24", - "url", + "crunchy", ] [[package]] @@ -6302,11 +7224,21 @@ dependencies = [ "log", ] +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + [[package]] name = "tinyvec" -version = "1.6.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +checksum = "09b3661f17e86524eccd4371ab0429194e0d7c008abb45f7a7495b1719463c71" dependencies = [ "tinyvec_macros", ] @@ -6319,19 +7251,32 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.29.1" +version = "1.44.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "532826ff75199d5833b9d2c5fe410f29235e25704ee5f0ef599fb51c21f4a4da" +checksum = "e6b88822cbe49de4185e3a4cbf8321dd487cf5fe0c5c65695fef6346371e9c48" dependencies = [ - "autocfg", "backtrace", - "bytes 1.4.0", + "bytes", "libc", "mio", - "num_cpus", + "parking_lot", "pin-project-lite", - "socket2 0.4.9", - "windows-sys 0.48.0", + "signal-hook-registry", + "socket2", + "tokio-macros", + "tracing", + "windows-sys 0.52.0", +] + +[[package]] +name = "tokio-macros" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", ] [[package]] @@ -6346,9 +7291,9 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.24.1" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" +checksum = "8e727b36a1a0e8b74c376ac2211e40c2c8af09fb4013c60d910495810f008e9b" dependencies = [ "rustls", "tokio", @@ -6356,21 +7301,21 @@ dependencies = [ [[package]] name = "tokio-socks" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51165dfa029d2a65969413a6cc96f354b86b464498702f174a4efa13608fd8c0" +checksum = "0d4770b8024672c1101b3f6733eab95b18007dbe0847a8afe341fcf79e06043f" dependencies = [ "either", "futures-util", - "thiserror", + "thiserror 1.0.69", "tokio", ] [[package]] name = "tokio-stream" -version = "0.1.14" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" +checksum = "eca58d7bba4a75707817a2c44174253f9236b2d5fbd055602e9d5c07c139a047" dependencies = [ "futures-core", "pin-project-lite", @@ -6379,82 +7324,125 @@ dependencies = [ [[package]] name = "tokio-tungstenite" -version = "0.20.1" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" +checksum = "7a9daff607c6d2bf6c16fd681ccb7eecc83e4e2cdc1ca067ffaadfca5de7f084" dependencies = [ "futures-util", "log", "native-tls", "rustls", + "rustls-native-certs", + "rustls-pki-types", "tokio", "tokio-native-tls", "tokio-rustls", "tungstenite", - "webpki-roots 0.25.2", + "webpki-roots", ] [[package]] name = "tokio-util" -version = "0.7.8" +version = "0.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" +checksum = "6b9590b93e6fcc1739458317cccd391ad3955e2bde8913edf6f95f9e65a8f034" dependencies = [ - "bytes 1.4.0", + "bytes", "futures-core", "futures-sink", "pin-project-lite", "tokio", - "tracing", ] [[package]] name = "toml" -version = "0.7.6" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542" +checksum = "cd87a5cdd6ffab733b2f74bc4fd7ee5fff6634124999ac278c35fc78c6120148" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit", + "toml_edit 0.22.24", ] [[package]] name = "toml_datetime" -version = "0.6.3" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.19.14" +version = "0.19.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" +dependencies = [ + "indexmap 2.9.0", + "toml_datetime", + "winnow 0.5.40", +] + +[[package]] +name = "toml_edit" +version = "0.20.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81" +dependencies = [ + "indexmap 2.9.0", + "toml_datetime", + "winnow 0.5.40", +] + +[[package]] +name = "toml_edit" +version = "0.22.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a" +checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" dependencies = [ - "indexmap 2.0.0", + "indexmap 2.9.0", "serde", "serde_spanned", "toml_datetime", - "winnow", + "winnow 0.7.6", ] +[[package]] +name = "tower" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + [[package]] name = "tower-service" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" -version = "0.1.37" +version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" dependencies = [ - "cfg-if", "log", "pin-project-lite", "tracing-attributes", @@ -6463,238 +7451,193 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.26" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.100", ] [[package]] name = "tracing-core" -version = "0.1.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" -dependencies = [ - "once_cell", - "valuable", -] - -[[package]] -name = "tracing-log" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" -dependencies = [ - "lazy_static", - "log", - "tracing-core", -] - -[[package]] -name = "tracing-subscriber" -version = "0.3.17" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" +checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" dependencies = [ - "matchers", - "nu-ansi-term", "once_cell", - "regex", - "sharded-slab", - "smallvec", - "thread_local", - "tracing", - "tracing-core", - "tracing-log", ] [[package]] name = "tray-icon" -version = "0.8.1" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b0e5bec13da15e62330e9bcf8b9fd42489b5acfe29ac8fec7ed659dbee21d9" +checksum = "d433764348e7084bad2c5ea22c96c71b61b17afe3a11645710f533bd72b6a2b5" dependencies = [ - "cocoa 0.25.0", - "core-graphics 0.23.1", "crossbeam-channel", - "dirs-next", + "dirs 6.0.0", "libappindicator", "muda", - "objc", + "objc2 0.6.0", + "objc2-app-kit", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-foundation 0.3.0", "once_cell", "png", - "thiserror", - "windows-sys 0.48.0", -] - -[[package]] -name = "treediff" -version = "4.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52984d277bdf2a751072b5df30ec0377febdb02f7696d64c2d7d54630bac4303" -dependencies = [ - "serde_json", + "serde", + "thiserror 2.0.12", + "windows-sys 0.59.0", ] [[package]] -name = "trust-dns-proto" -version = "0.22.0" +name = "tree_magic_mini" +version = "3.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f7f83d1e4a0e4358ac54c5c3681e5d7da5efc5a7a632c90bb6d6669ddd9bc26" +checksum = "aac5e8971f245c3389a5a76e648bfc80803ae066a1243a75db0064d7c1129d63" dependencies = [ - "async-trait", - "cfg-if", - "data-encoding", - "enum-as-inner", - "futures-channel", - "futures-io", - "futures-util", - "idna 0.2.3", - "ipnet", - "lazy_static", - "rand 0.8.5", - "smallvec", - "thiserror", - "tinyvec", - "tokio", - "tracing", - "url", + "fnv", + "memchr", + "nom", + "once_cell", + "petgraph", ] [[package]] -name = "trust-dns-resolver" -version = "0.22.0" +name = "trim-in-place" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aff21aa4dcefb0a1afbfac26deb0adc93888c7d295fb63ab273ef276ba2b7cfe" -dependencies = [ - "cfg-if", - "futures-util", - "ipconfig", - "lazy_static", - "lru-cache", - "parking_lot", - "resolv-conf", - "smallvec", - "thiserror", - "tokio", - "tracing", - "trust-dns-proto", -] +checksum = "343e926fc669bc8cde4fa3129ab681c63671bae288b1f1081ceee6d9d37904fc" [[package]] name = "try-lock" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "tungstenite" -version = "0.20.1" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e3dac10fd62eaf6617d3a904ae222845979aec67c615d1c842b4002c7666fb9" +checksum = "4793cb5e56680ecbb1d843515b23b6de9a75eb04b66643e256a396d43be33c13" dependencies = [ - "byteorder", - "bytes 1.4.0", + "bytes", "data-encoding", "http", "httparse", "log", "native-tls", - "rand 0.8.5", + "rand 0.9.0", "rustls", + "rustls-pki-types", "sha1", - "thiserror", - "url", + "thiserror 2.0.12", "utf-8", ] +[[package]] +name = "typeid" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c" + [[package]] name = "typenum" -version = "1.16.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" [[package]] -name = "u2f" -version = "0.2.0" +name = "uds_windows" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2f285392366190c4d46823458f4543ac0f35174759c78e80c5baa39e1f7aa4f" +checksum = "89daebc3e6fd160ac4aa9fc8b3bf71e1f74fbf92367ae71fb83a037e8bf164b9" dependencies = [ - "base64 0.11.0", - "byteorder", - "bytes 0.4.12", - "chrono", - "openssl", - "serde", - "serde_derive", - "serde_json", - "time 0.1.45", + "memoffset 0.9.1", + "tempfile", + "winapi", ] [[package]] -name = "uds_windows" -version = "1.0.2" +name = "unic-char-property" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce65604324d3cce9b966701489fbd0cf318cb1f7bd9dd07ac9a4ee6fb791930d" +checksum = "a8c57a407d9b6fa02b4795eb81c5b6652060a15a7903ea981f3d723e6c0be221" dependencies = [ - "tempfile", - "winapi", + "unic-char-range", ] [[package]] -name = "unicase" -version = "2.6.0" +name = "unic-char-range" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0398022d5f700414f6b899e10b8348231abf9173fa93144cbc1a43b9793c1fbc" + +[[package]] +name = "unic-common" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d7ff825a6a654ee85a63e80f92f054f904f21e7d12da4e22f9834a4aaa35bc" + +[[package]] +name = "unic-ucd-ident" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" +checksum = "e230a37c0381caa9219d67cf063aa3a375ffed5bf541a452db16e744bdab6987" dependencies = [ - "version_check", + "unic-char-property", + "unic-char-range", + "unic-ucd-version", ] +[[package]] +name = "unic-ucd-version" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96bd2f2237fe450fcd0a1d2f5f4e91711124f7857ba2e964247776ebeeb7b0c4" +dependencies = [ + "unic-common", +] + +[[package]] +name = "unicase" +version = "2.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75b844d17643ee918803943289730bec8aac480150456169e647ed0b576ba539" + [[package]] name = "unicode-bidi" -version = "0.3.13" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" +checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5" [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" [[package]] name = "unicode-normalization" -version = "0.1.22" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" dependencies = [ "tinyvec", ] [[package]] -name = "unicode-segmentation" -version = "1.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" - -[[package]] -name = "unicode_categories" -version = "0.1.1" +name = "unicode-properties" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" +checksum = "e70f2a8b45122e719eb623c01822704c4e0907e7e426a05927e1a1cfff5b75d0" [[package]] -name = "universal-hash" -version = "0.4.0" +name = "unicode-segmentation" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8326b2c654932e3e4f9196e69d08fdf7cfd718e1dc6f66b347e6024a0c961402" -dependencies = [ - "generic-array", - "subtle", -] +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" [[package]] name = "universal-hash" @@ -6708,66 +7651,104 @@ dependencies = [ [[package]] name = "untrusted" -version = "0.7.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] -name = "untrusted" -version = "0.9.0" +name = "updater-migration-test" +version = "0.1.0" +dependencies = [ + "serde", + "serde_json", + "tauri", + "tauri-build", + "tauri-plugin-updater", + "time", + "tiny_http", +] + +[[package]] +name = "ureq" +version = "2.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" +checksum = "02d1a66277ed75f640d608235660df48c8e3c19f3b4edb6a263315626cc3c01d" +dependencies = [ + "base64 0.22.1", + "log", + "once_cell", + "url", +] [[package]] name = "url" -version = "2.4.0" +version = "2.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" +checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" dependencies = [ "form_urlencoded", - "idna 0.4.0", + "idna", "percent-encoding", "serde", ] +[[package]] +name = "urlpattern" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70acd30e3aa1450bc2eece896ce2ad0d178e9c079493819301573dae3c37ba6d" +dependencies = [ + "regex", + "serde", + "unic-ucd-ident", + "url", +] + [[package]] name = "utf-8" version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + [[package]] name = "utf8-width" -version = "0.1.6" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86bd8d4e895da8537e5315b8254664e6b769c4ff3db18321b297a1e7004392e3" + +[[package]] +name = "utf8_iter" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5190c9442dcdaf0ddd50f37420417d219ae5261bbf5db120d0f9bab996c9cba1" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" [[package]] name = "utf8parse" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.4.1" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" +checksum = "458f7a779bf54acc9f347480ac654f68407d3aab21269a6e3c9f922acd9e2da9" dependencies = [ - "getrandom 0.2.10", + "getrandom 0.3.2", + "serde", ] -[[package]] -name = "valuable" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" - [[package]] name = "value-bag" -version = "1.4.1" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d92ccd67fb88503048c01b59152a04effd0782d035a83a6d256ce6085f08f4a3" +checksum = "943ce29a8a743eb10d6082545d861b24f9d1b160b7d741e0f2cdf726bec909c5" [[package]] name = "vcpkg" @@ -6777,15 +7758,15 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "version-compare" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "579a42fc0b8e0c63b76519a339be31bed574929511fa53c1a3acae26eb258f29" +checksum = "852e951cb7832cb45cb1169900d19760cfa39b82bc0ea9c0e5a14ae88411c98b" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "vswhom" @@ -6799,9 +7780,9 @@ dependencies = [ [[package]] name = "vswhom-sys" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3b17ae1f6c8a2b28506cd96d412eebf83b4a0ff2cbefeeb952f2f9dfa44ba18" +checksum = "fb067e4cbd1ff067d1df46c9194b5de0e98efd2810bbc95c5d5e5f25a3231150" dependencies = [ "cc", "libc", @@ -6809,24 +7790,18 @@ dependencies = [ [[package]] name = "wait-timeout" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" +checksum = "09ac3b126d3914f9849036f826e054cbabdc8519970b8998ddaf3b5bd3c65f11" dependencies = [ "libc", ] -[[package]] -name = "waker-fn" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" - [[package]] name = "walkdir" -version = "2.3.3" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" dependencies = [ "same-file", "winapi-util", @@ -6849,58 +7824,69 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" +version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" +version = "0.14.2+wasi-0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" +dependencies = [ + "wit-bindgen-rt", +] + +[[package]] +name = "wasite" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" [[package]] name = "wasm-bindgen" -version = "0.2.87" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" dependencies = [ "cfg-if", + "once_cell", + "rustversion", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.87" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" dependencies = [ "bumpalo", "log", - "once_cell", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.100", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.37" +version = "0.4.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" +checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" dependencies = [ "cfg-if", "js-sys", + "once_cell", "wasm-bindgen", "web-sys", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.87" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -6908,28 +7894,31 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.87" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.100", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.87" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] [[package]] name = "wasm-streams" -version = "0.2.3" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bbae3363c08332cadccd13b67db371814cd214c2524020932f0804b8cf7c078" +checksum = "15053d8d85c7eccdbefef60f06769760a563c7f0a9d6902a13d35c7800b0ad65" dependencies = [ "futures-util", "js-sys", @@ -6938,21 +7927,101 @@ dependencies = [ "web-sys", ] +[[package]] +name = "wayland-backend" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7208998eaa3870dad37ec8836979581506e0c5c64c20c9e79e9d2a10d6f47bf" +dependencies = [ + "cc", + "downcast-rs", + "rustix 0.38.44", + "smallvec", + "wayland-sys", +] + +[[package]] +name = "wayland-client" +version = "0.31.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2120de3d33638aaef5b9f4472bff75f07c56379cf76ea320bd3a3d65ecaf73f" +dependencies = [ + "bitflags 2.9.0", + "rustix 0.38.44", + "wayland-backend", + "wayland-scanner", +] + +[[package]] +name = "wayland-protocols" +version = "0.32.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0781cf46869b37e36928f7b432273c0995aa8aed9552c556fb18754420541efc" +dependencies = [ + "bitflags 2.9.0", + "wayland-backend", + "wayland-client", + "wayland-scanner", +] + +[[package]] +name = "wayland-protocols-wlr" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "248a02e6f595aad796561fa82d25601bd2c8c3b145b1c7453fc8f94c1a58f8b2" +dependencies = [ + "bitflags 2.9.0", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-scanner", +] + +[[package]] +name = "wayland-scanner" +version = "0.31.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "896fdafd5d28145fce7958917d69f2fd44469b1d4e861cb5961bcbeebc6d1484" +dependencies = [ + "proc-macro2", + "quick-xml 0.37.4", + "quote", +] + +[[package]] +name = "wayland-sys" +version = "0.31.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbcebb399c77d5aa9fa5db874806ee7b4eba4e73650948e8f93963f128896615" +dependencies = [ + "pkg-config", +] + [[package]] name = "web-sys" -version = "0.3.64" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" dependencies = [ "js-sys", "wasm-bindgen", ] [[package]] -name = "webkit2gtk" +name = "web-time" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ba4cce9085e0fb02575cfd45c328740dde78253cba516b1e8be2ca0f57bd8bf" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webkit2gtk" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76b1bc1e54c581da1e9f179d0b38512ba358fb1af2d634a1affe42e37172361a" dependencies = [ "bitflags 1.3.2", "cairo-rs", @@ -6974,9 +8043,9 @@ 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", @@ -6992,40 +8061,15 @@ dependencies = [ "system-deps", ] -[[package]] -name = "webpki" -version = "0.22.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed63aea5ce73d0ff405984102c42de94fc55a6b75765d621c65262469b3c9b53" -dependencies = [ - "ring 0.17.3", - "untrusted 0.9.0", -] - -[[package]] -name = "webpki-roots" -version = "0.22.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" -dependencies = [ - "webpki", -] - [[package]] name = "webpki-roots" -version = "0.24.0" +version = "0.26.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b291546d5d9d1eab74f069c77749f2cb8504a12caa20f0f2de93ddbf6f411888" +checksum = "2210b291f7ea53617fbafcc4939f10914214ec15aace5ba62293a668f322c5c9" dependencies = [ - "rustls-webpki", + "rustls-pki-types", ] -[[package]] -name = "webpki-roots" -version = "0.25.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" - [[package]] name = "websocket-example" version = "0.1.0" @@ -7042,69 +8086,64 @@ dependencies = [ [[package]] name = "webview2-com" -version = "0.25.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79e563ffe8e84d42e43ffacbace8780c0244fc8910346f334613559d92e203ad" +checksum = "b542b5cfbd9618c46c2784e4d41ba218c336ac70d44c55e47b251033e7d85601" dependencies = [ "webview2-com-macros", "webview2-com-sys", - "windows 0.48.0", - "windows-implement 0.48.0", - "windows-interface 0.48.0", + "windows 0.61.1", + "windows-core", + "windows-implement", + "windows-interface", ] [[package]] name = "webview2-com-macros" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac1345798ecd8122468840bcdf1b95e5dc6d2206c5e4b0eafa078d061f59c9bc" +checksum = "1d228f15bba3b9d56dde8bddbee66fa24545bd17b48d5128ccf4a8742b18e431" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.100", ] [[package]] name = "webview2-com-sys" -version = "0.25.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19d39576804304cf9ead192467ef47f7859a1a12fec3bd459d5ba34b8cd65ed5" +checksum = "8ae2d11c4a686e4409659d7891791254cf9286d3cfe0eef54df1523533d22295" dependencies = [ - "regex", - "serde", - "serde_json", - "thiserror", - "windows 0.48.0", - "windows-bindgen", - "windows-metadata", + "thiserror 2.0.12", + "windows 0.61.1", + "windows-core", ] [[package]] name = "weezl" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb" +checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082" [[package]] name = "whoami" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22fc3756b8a9133049b26c7f61ab35416c130e8c09b660f5b3958b446f52cc50" - -[[package]] -name = "widestring" -version = "1.0.2" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "653f141f39ec16bba3c5abe400a0c60da7468261cc2cbf36805022876bc721a8" +checksum = "6994d13118ab492c3c80c1f81928718159254c53c472bf9ce36f8dae4add02a7" +dependencies = [ + "redox_syscall", + "wasite", +] [[package]] name = "win7-notifications" -version = "0.3.1" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "210952d7163b9ed83a6fd9754ab2a101d14480f8491b5f1d6292771d88dbee70" +checksum = "63b4745047a00800bd8f2b8fb4b0eb6f7d96822084127f0ff7d68d07f692fe38" dependencies = [ "once_cell", - "windows-sys 0.36.1", + "windows-sys 0.59.0", ] [[package]] @@ -7125,20 +8164,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi", -] - -[[package]] -name = "winapi-wsapoll" -version = "0.1.1" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c17110f57155602a80dca10be03852116403c9ff3cd25b079d666f2aa3df6e" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "winapi", + "windows-sys 0.59.0", ] [[package]] @@ -7147,28 +8177,19 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "window-shadows" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29d30320647cfc3dc45554c8ad825b84831def81f967a2f7589931328ff9b16d" -dependencies = [ - "cocoa 0.24.1", - "objc", - "raw-window-handle", - "windows-sys 0.42.0", -] - [[package]] name = "window-vibrancy" -version = "0.4.2" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5931735e675b972fada30c7a402915d4d827aa5ef6c929c133d640c4b785e963" +checksum = "d9bec5a31f3f9362f2258fd0e9c9dd61a9ca432e7306cc78c444258f0dce9a9c" dependencies = [ - "cocoa 0.25.0", - "objc", + "objc2 0.6.0", + "objc2-app-kit", + "objc2-core-foundation", + "objc2-foundation 0.3.0", "raw-window-handle", - "windows-sys 0.48.0", + "windows-sys 0.59.0", + "windows-version", ] [[package]] @@ -7186,144 +8207,134 @@ dependencies = [ [[package]] name = "windows" -version = "0.39.0" +version = "0.61.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1c4bd0a50ac6020f65184721f758dba47bb9fbc2133df715ec74a237b26794a" +checksum = "c5ee8f3d025738cb02bad7868bbb5f8a6327501e870bf51f1b455b0a2454a419" dependencies = [ - "windows_aarch64_msvc 0.39.0", - "windows_i686_gnu 0.39.0", - "windows_i686_msvc 0.39.0", - "windows_x86_64_gnu 0.39.0", - "windows_x86_64_msvc 0.39.0", + "windows-collections", + "windows-core", + "windows-future", + "windows-link", + "windows-numerics", ] [[package]] -name = "windows" -version = "0.44.0" +name = "windows-collections" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e745dab35a0c4c77aa3ce42d595e13d2003d6902d6b08c9ef5fc326d08da12b" +checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8" dependencies = [ - "windows-targets 0.42.2", + "windows-core", ] [[package]] -name = "windows" -version = "0.48.0" +name = "windows-core" +version = "0.61.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +checksum = "4763c1de310c86d75a878046489e2e5ba02c649d185f21c67d4cf8a56d098980" dependencies = [ - "windows-implement 0.48.0", - "windows-interface 0.48.0", - "windows-targets 0.48.5", + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings 0.4.0", ] [[package]] -name = "windows" -version = "0.51.1" +name = "windows-future" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca229916c5ee38c2f2bc1e9d8f04df975b4bd93f9955dc69fabb5d91270045c9" +checksum = "7a1d6bbefcb7b60acd19828e1bc965da6fcf18a7e39490c5f8be71e54a19ba32" dependencies = [ "windows-core", - "windows-implement 0.51.1", - "windows-interface 0.51.1", - "windows-targets 0.48.5", + "windows-link", ] [[package]] -name = "windows-bindgen" -version = "0.48.0" +name = "windows-implement" +version = "0.60.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fe21a77bc54b7312dbd66f041605e098990c98be48cd52967b85b5e60e75ae6" +checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" dependencies = [ - "windows-metadata", - "windows-tokens", + "proc-macro2", + "quote", + "syn 2.0.100", ] [[package]] -name = "windows-core" -version = "0.51.1" +name = "windows-interface" +version = "0.59.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" +checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" dependencies = [ - "windows-targets 0.48.5", + "proc-macro2", + "quote", + "syn 2.0.100", ] [[package]] -name = "windows-implement" -version = "0.48.0" +name = "windows-link" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e2ee588991b9e7e6c8338edf3333fbe4da35dc72092643958ebb43f0ab2c49c" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] +checksum = "76840935b766e1b0a05c0066835fb9ec80071d4c09a16f6bd5f7e655e3c14c38" [[package]] -name = "windows-implement" -version = "0.51.1" +name = "windows-numerics" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb2b158efec5af20d8846836622f50a87e6556b9153a42772fa047f773c0e555" +checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.28", + "windows-core", + "windows-link", ] [[package]] -name = "windows-interface" -version = "0.48.0" +name = "windows-registry" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6fb8df20c9bcaa8ad6ab513f7b40104840c8867d5751126e4df3b08388d0cc7" +checksum = "4286ad90ddb45071efd1a66dfa43eb02dd0dfbae1545ad6cc3c51cf34d7e8ba3" dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", + "windows-result", + "windows-strings 0.3.1", + "windows-targets 0.53.0", ] [[package]] -name = "windows-interface" -version = "0.51.1" +name = "windows-registry" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0546e63e1ce64c04403d2311fa0e3ab5ae3a367bd524b4a38d8d8d18c70cfa76" +checksum = "ad1da3e436dc7653dfdf3da67332e22bff09bb0e28b0239e1624499c7830842e" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.28", + "windows-link", + "windows-result", + "windows-strings 0.4.0", ] [[package]] -name = "windows-metadata" -version = "0.48.0" +name = "windows-result" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "422ee0e5f0e2cc372bb6addbfff9a8add712155cd743df9c15f6ab000f31432d" +checksum = "c64fd11a4fd95df68efcfee5f44a294fe71b8bc6a91993e2791938abcc712252" +dependencies = [ + "windows-link", +] [[package]] -name = "windows-sys" -version = "0.36.1" +name = "windows-strings" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" +checksum = "87fa48cc5d406560701792be122a10132491cff9d0aeb23583cc2dcafc847319" dependencies = [ - "windows_aarch64_msvc 0.36.1", - "windows_i686_gnu 0.36.1", - "windows_i686_msvc 0.36.1", - "windows_x86_64_gnu 0.36.1", - "windows_x86_64_msvc 0.36.1", + "windows-link", ] [[package]] -name = "windows-sys" -version = "0.42.0" +name = "windows-strings" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +checksum = "7a2ba9642430ee452d5a7aa78d72907ebe8cfda358e8cb7918a2050581322f97" dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", + "windows-link", ] [[package]] @@ -7344,6 +8355,24 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-targets" version = "0.42.2" @@ -7375,10 +8404,45 @@ dependencies = [ ] [[package]] -name = "windows-tokens" -version = "0.48.0" +name = "windows-targets" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b34c9a3b28cb41db7385546f7f9a8179348dffc89923dde66857b1ba5312f6b4" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1e4c7e8ceaaf9cb7d7507c974735728ab453b67ef8f18febdd7c11fe59dca8b" +dependencies = [ + "windows_aarch64_gnullvm 0.53.0", + "windows_aarch64_msvc 0.53.0", + "windows_i686_gnu 0.53.0", + "windows_i686_gnullvm 0.53.0", + "windows_i686_msvc 0.53.0", + "windows_x86_64_gnu 0.53.0", + "windows_x86_64_gnullvm 0.53.0", + "windows_x86_64_msvc 0.53.0", +] + +[[package]] +name = "windows-version" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e04a5c6627e310a23ad2358483286c7df260c964eb2d003d8efd6d0f4e79265c" +dependencies = [ + "windows-link", +] [[package]] name = "windows_aarch64_gnullvm" @@ -7393,16 +8457,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] -name = "windows_aarch64_msvc" -version = "0.36.1" +name = "windows_aarch64_gnullvm" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" [[package]] name = "windows_aarch64_msvc" -version = "0.39.0" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec7711666096bd4096ffa835238905bb33fb87267910e154b18b44eaabb340f2" +checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" [[package]] name = "windows_aarch64_msvc" @@ -7417,16 +8487,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] -name = "windows_i686_gnu" -version = "0.36.1" +name = "windows_aarch64_msvc" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" [[package]] name = "windows_i686_gnu" -version = "0.39.0" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "763fc57100a5f7042e3057e7e8d9bdd7860d330070251a73d003563a3bb49e1b" +checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" [[package]] name = "windows_i686_gnu" @@ -7441,16 +8517,34 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] -name = "windows_i686_msvc" -version = "0.36.1" +name = "windows_i686_gnu" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" [[package]] name = "windows_i686_msvc" -version = "0.39.0" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bc7cbfe58828921e10a9f446fcaaf649204dcfe6c1ddd712c5eebae6bda1106" +checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" [[package]] name = "windows_i686_msvc" @@ -7465,16 +8559,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] -name = "windows_x86_64_gnu" -version = "0.36.1" +name = "windows_i686_msvc" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_i686_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" [[package]] name = "windows_x86_64_gnu" -version = "0.39.0" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6868c165637d653ae1e8dc4d82c25d4f97dd6605eaa8d784b5c6e0ab2a252b65" +checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" [[package]] name = "windows_x86_64_gnu" @@ -7488,6 +8588,18 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" + [[package]] name = "windows_x86_64_gnullvm" version = "0.42.2" @@ -7501,16 +8613,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] -name = "windows_x86_64_msvc" -version = "0.36.1" +name = "windows_x86_64_gnullvm" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" [[package]] name = "windows_x86_64_msvc" -version = "0.39.0" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e4d40883ae9cae962787ca76ba76390ffa29214667a111db9e0a1ad8377e809" +checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" [[package]] name = "windows_x86_64_msvc" @@ -7524,11 +8642,32 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" + [[package]] name = "winnow" -version = "0.5.2" +version = "0.5.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bd122eb777186e60c3fdf765a58ac76e41c582f1f535fbf3314434c6b58f3f7" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +dependencies = [ + "memchr", +] + +[[package]] +name = "winnow" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63d3fcd9bba44b03821e7d699eeee959f3126dcc4aa8e4ae18ec617c2a5cea10" dependencies = [ "memchr", ] @@ -7544,61 +8683,105 @@ dependencies = [ [[package]] name = "winreg" -version = "0.11.0" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76a1a57ff50e9b408431e8f97d5456f2807f8eb2a2cd79b06068fc87f8ecf189" +checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" dependencies = [ "cfg-if", - "winapi", + "windows-sys 0.48.0", ] [[package]] -name = "winreg" -version = "0.50.0" +name = "wit-bindgen-rt" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" dependencies = [ - "cfg-if", - "windows-sys 0.48.0", + "bitflags 2.9.0", ] +[[package]] +name = "wl-clipboard-rs" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5ff8d0e60065f549fafd9d6cb626203ea64a798186c80d8e7df4f8af56baeb" +dependencies = [ + "libc", + "log", + "os_pipe", + "rustix 0.38.44", + "tempfile", + "thiserror 2.0.12", + "tree_magic_mini", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-protocols-wlr", +] + +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + [[package]] name = "wry" -version = "0.33.0" +version = "0.51.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf906b43b8042615c85a978dceb4d4b72214d27b850b54abc3edeb7c5a67abab" +checksum = "c886a0a9d2a94fd90cfa1d929629b79cfefb1546e2c7430c63a47f0664c0e4e2" dependencies = [ - "base64 0.21.2", - "block", - "cocoa 0.24.1", - "core-graphics 0.22.3", + "base64 0.22.1", + "block2 0.6.0", + "cookie", "crossbeam-channel", + "dpi", "dunce", - "gdk", - "gio", - "glib", + "gdkx11", "gtk", "html5ever", "http", "javascriptcore-rs", + "jni", "kuchikiki", "libc", - "log", - "objc", - "objc_id", + "ndk", + "objc2 0.6.0", + "objc2-app-kit", + "objc2-core-foundation", + "objc2-foundation 0.3.0", + "objc2-ui-kit", + "objc2-web-kit", "once_cell", - "serde", - "serde_json", - "sha2 0.10.7", + "percent-encoding", + "raw-window-handle", + "sha2", "soup3", - "tao", - "thiserror", + "tao-macros", + "thiserror 2.0.12", "url", "webkit2gtk", "webkit2gtk-sys", "webview2-com", - "windows 0.48.0", - "windows-implement 0.48.0", + "windows 0.61.1", + "windows-core", + "windows-version", + "x11-dl", +] + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", ] [[package]] @@ -7624,61 +8807,87 @@ dependencies = [ [[package]] name = "x11rb" -version = "0.10.1" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "592b4883219f345e712b3209c62654ebda0bb50887f330cbd018d0f654bfd507" +checksum = "5d91ffca73ee7f68ce055750bf9f6eca0780b8c85eff9bc046a3b0da41755e12" dependencies = [ - "gethostname 0.2.3", - "nix 0.24.3", - "winapi", - "winapi-wsapoll", + "gethostname 0.4.3", + "rustix 0.38.44", "x11rb-protocol", ] [[package]] name = "x11rb-protocol" -version = "0.10.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56b245751c0ac9db0e006dc812031482784e434630205a93c73cfefcaabeac67" -dependencies = [ - "nix 0.24.3", -] +checksum = "ec107c4503ea0b4a98ef47356329af139c0a4f7750e621cf2973cd3385ebcb3d" [[package]] name = "x25519-dalek" -version = "1.1.1" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a0c105152107e3b96f6a00a65e86ce82d9b125230e1c4302940eca58ff71f4f" +checksum = "c7e468321c81fb07fa7f4c636c3972b9100f0346e5b6a9f2bd0603a52f7ed277" dependencies = [ "curve25519-dalek", - "rand_core 0.5.1", + "rand_core 0.6.4", "zeroize", ] [[package]] name = "xattr" -version = "0.2.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d1526bbe5aaeb5eb06885f4d987bcdfa5e23187055de9b83fe00156a821fabc" +checksum = "0d65cbf2f12c15564212d48f4e3dfb87923d25d611f2aed18f4cb23f0413d89e" dependencies = [ "libc", + "rustix 1.0.5", ] [[package]] name = "xdg-home" -version = "1.0.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2769203cd13a0c6015d515be729c526d041e9cf2c0cc478d57faee85f40c6dcd" +checksum = "ec1cdab258fb55c0da61328dc52c8764709b249011b2cad0454c72f0bf10a1f6" dependencies = [ - "nix 0.26.2", - "winapi", + "libc", + "windows-sys 0.59.0", +] + +[[package]] +name = "xkeysym" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9cc00251562a284751c9973bace760d86c0276c471b4be569fe6b068ee97a56" + +[[package]] +name = "yoke" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", + "synstructure", ] [[package]] name = "zbus" -version = "3.14.1" +version = "5.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31de390a2d872e4cd04edd71b425e29853f786dc99317ed72d73d6fcf5ebb948" +checksum = "59c333f648ea1b647bc95dc1d34807c8e25ed7a6feff3394034dc4776054b236" dependencies = [ "async-broadcast", "async-executor", @@ -7690,25 +8899,21 @@ dependencies = [ "async-task", "async-trait", "blocking", - "byteorder", - "derivative", "enumflags2", "event-listener", "futures-core", - "futures-sink", - "futures-util", + "futures-lite", "hex", - "nix 0.26.2", - "once_cell", + "nix 0.29.0", "ordered-stream", - "rand 0.8.5", "serde", "serde_repr", - "sha1", "static_assertions", + "tokio", "tracing", "uds_windows", - "winapi", + "windows-sys 0.59.0", + "winnow 0.7.6", "xdg-home", "zbus_macros", "zbus_names", @@ -7717,35 +8922,99 @@ dependencies = [ [[package]] name = "zbus_macros" -version = "3.14.1" +version = "5.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d1794a946878c0e807f55a397187c11fc7a038ba5d868e7db4f3bd7760bc9d" +checksum = "f325ad10eb0d0a3eb060203494c3b7ec3162a01a59db75d2deee100339709fc0" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 3.3.0", "proc-macro2", "quote", - "regex", - "syn 1.0.109", + "syn 2.0.100", + "zbus_names", + "zvariant", "zvariant_utils", ] [[package]] name = "zbus_names" -version = "2.6.0" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb80bb776dbda6e23d705cf0123c3b95df99c4ebeaec6c2599d4a5419902b4a9" +checksum = "7be68e64bf6ce8db94f63e72f0c7eb9a60d733f7e0499e628dfab0f84d6bcb97" dependencies = [ "serde", "static_assertions", + "winnow 0.7.6", "zvariant", ] +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "zerocopy-derive 0.7.35", +] + +[[package]] +name = "zerocopy" +version = "0.8.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2586fea28e186957ef732a5f8b3be2da217d65c5969d4b1e17f973ebbe876879" +dependencies = [ + "zerocopy-derive 0.8.24", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a996a8f63c5c4448cd959ac1bab0aaa3306ccfd060472f85943ee0750f0169be" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + +[[package]] +name = "zerofrom" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", + "synstructure", +] + [[package]] name = "zeroize" -version = "1.6.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" dependencies = [ + "serde", "zeroize_derive", ] @@ -7757,93 +9026,139 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.100", +] + +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", ] [[package]] name = "zip" -version = "0.6.6" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" +checksum = "1dcb24d0152526ae49b9b96c1dcf71850ca1e0b882e4e28ed898a93c41334744" dependencies = [ - "aes 0.8.3", - "byteorder", - "bzip2", - "constant_time_eq 0.1.5", + "arbitrary", "crc32fast", "crossbeam-utils", "flate2", - "hmac", - "pbkdf2", - "sha1", - "time 0.3.24", - "zstd", + "indexmap 2.9.0", + "memchr", + "zopfli", +] + +[[package]] +name = "zip" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "153a6fff49d264c4babdcfa6b4d534747f520e56e8f0f384f3b808c4b64cc1fd" +dependencies = [ + "arbitrary", + "crc32fast", + "indexmap 2.9.0", + "memchr", +] + +[[package]] +name = "zopfli" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5019f391bac5cf252e93bbcc53d039ffd62c7bfb7c150414d61369afe57e946" +dependencies = [ + "bumpalo", + "crc32fast", + "lockfree-object-pool", + "log", + "once_cell", + "simd-adler32", ] [[package]] name = "zstd" -version = "0.11.2+zstd.1.5.2" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" +checksum = "e91ee311a569c327171651566e07972200e76fcfe2242a4fa446149a3881c08a" dependencies = [ "zstd-safe", ] [[package]] name = "zstd-safe" -version = "5.0.2+zstd.1.5.2" +version = "7.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" +checksum = "8f49c4d5f0abb602a93fb8736af2a4f4dd9512e36f7f570d66e65ff867ed3b9d" dependencies = [ - "libc", "zstd-sys", ] [[package]] name = "zstd-sys" -version = "2.0.8+zstd.1.5.5" +version = "2.0.15+zstd.1.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5556e6ee25d32df2586c098bbfa278803692a20d0ab9565e049480d52707ec8c" +checksum = "eb81183ddd97d0c74cedf1d50d85c8d08c1b8b68ee863bdee9e706eedba1a237" dependencies = [ "cc", - "libc", "pkg-config", ] [[package]] name = "zvariant" -version = "3.15.0" +version = "5.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44b291bee0d960c53170780af148dca5fa260a63cdd24f1962fa82e03e53338c" +checksum = "b2df9ee044893fcffbdc25de30546edef3e32341466811ca18421e3cd6c5a3ac" dependencies = [ - "byteorder", + "endi", "enumflags2", - "libc", "serde", "static_assertions", + "url", + "winnow 0.7.6", "zvariant_derive", + "zvariant_utils", ] [[package]] name = "zvariant_derive" -version = "3.15.0" +version = "5.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "934d7a7dfc310d6ee06c87ffe88ef4eca7d3e37bb251dece2ef93da8f17d8ecd" +checksum = "74170caa85b8b84cc4935f2d56a57c7a15ea6185ccdd7eadb57e6edd90f94b2f" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 3.3.0", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.100", "zvariant_utils", ] [[package]] name = "zvariant_utils" -version = "1.0.1" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7234f0d811589db492d16893e3f21e8e2fd282e6d01b0cddee310322062cc200" +checksum = "e16edfee43e5d7b553b77872d99bc36afdda75c223ca7ad5e3fbecd82ca5fc34" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "serde", + "static_assertions", + "syn 2.0.100", + "winnow 0.7.6", ] diff --git a/Cargo.toml b/Cargo.toml index 5dbff89b..d85be889 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,20 +1,36 @@ [workspace] -members = ["plugins/*", "plugins/*/tests/*", "plugins/*/examples/*/src-tauri", "examples/*/src-tauri"] +members = [ + "plugins/*", + "plugins/*/tests/*", + "plugins/updater/tests/updater-migration/v2-app", + "plugins/*/examples/*/src-tauri", + "examples/*/src-tauri", +] resolver = "2" [workspace.dependencies] serde = { version = "1", features = ["derive"] } +tracing = "0.1" log = "0.4" -tauri = "2.0.0-alpha.16" -tauri-build = "2.0.0-alpha.10" +tauri = { version = "2", default-features = false } +tauri-build = "2" +tauri-plugin = "2" +tauri-utils = "2" serde_json = "1" -thiserror = "1" +thiserror = "2" +url = "2" +schemars = "0.8" +dunce = "1" +specta = "^2.0.0-rc.16" +glob = "0.3" +zbus = "5" [workspace.package] edition = "2021" -authors = [ "Tauri Programme within The Commons Conservancy" ] +authors = ["Tauri Programme within The Commons Conservancy"] license = "Apache-2.0 OR MIT" -rust-version = "1.70" +rust-version = "1.77.2" +repository = "https://github.com/tauri-apps/plugins-workspace" # default to small, optimized release binaries [profile.release] diff --git a/README.md b/README.md index cb36fb3a..33039295 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,62 @@ +# Official Tauri Plugins + +This repo and all plugins require a Rust version of at least **1.77.2** + ## Plugins Found Here -| | | Win | Mac | Lin | iOS | And | -| ------------------------------------------ | ------------------------------------------------------ | --- | --- | --- | --- | --- | -| [authenticator](plugins/authenticator) | Interface with hardware security keys. | ✅ | ✅ | ✅ | ? | ? | -| [autostart](plugins/autostart) | Automatically launch your app at system startup. | ✅ | ✅ | ✅ | ? | ? | -| [localhost](plugins/localhost) | Use a localhost server in production apps. | ✅ | ✅ | ✅ | ? | ? | -| [log](plugins/log) | Configurable logging. | ✅ | ✅ | ✅ | ✅ | ✅ | -| [persisted-scope](plugins/persisted-scope) | Persist runtime scope changes on the filesystem. | ✅ | ✅ | ✅ | ? | ? | -| [positioner](plugins/positioner) | Move windows to common locations. | ✅ | ✅ | ✅ | ? | ? | -| [single-instance](plugins/single-instance) | Ensure a single instance of your tauri app is running. | ✅ | ? | ✅ | ? | ? | -| [sql](plugins/sql) | Interface with SQL databases. | ✅ | ✅ | ✅ | ? | ? | -| [store](plugins/store) | Persistent key value storage. | ✅ | ✅ | ✅ | ? | ? | -| [stronghold](plugins/stronghold) | Encrypted, secure database. | ✅ | ✅ | ✅ | ? | ? | -| [upload](plugins/upload) | Tauri plugin for file uploads through HTTP. | ✅ | ✅ | ✅ | ? | ? | -| [websocket](plugins/websocket) | Open a WebSocket connection using a Rust client in JS. | ✅ | ✅ | ✅ | ? | ? | -| [window-state](plugins/window-state) | Persist window sizes and positions. | ✅ | ✅ | ✅ | ? | ? | - -_This repo and all plugins require a Rust version of at least **1.70**_ +| | | Win | Mac | Lin | iOS | And | +| ---------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | --- | --- | --- | --- | +| [autostart](plugins/autostart) | Automatically launch your app at system startup. | ✅ | ✅ | ✅ | ❌ | ❌ | +| [barcode-scanner](plugins/barcode-scanner) | Allows your mobile application to use the camera to scan QR codes, EAN-13 and other kinds of barcodes. | ? | ? | ? | ✅ | ✅ | +| [biometric](plugins/biometric) | Prompt the user for biometric authentication on Android and iOS. | ? | ? | ? | ✅ | ✅ | +| [cli](plugins/cli) | Parse arguments from your Command Line Interface | ✅ | ✅ | ✅ | ❌ | ❌ | +| [clipboard-manager](plugins/clipboard-manager) | Read and write to the system clipboard. | ✅ | ✅ | ✅ | ✅ | ✅ | +| [deep-link](plugins/deep-link) | Set your Tauri application as the default handler for an URL. | ✅ | ✅ | ✅ | ✅ | ✅ | +| [dialog](plugins/dialog) | Native system dialogs for opening and saving files along with message dialogs. | ✅ | ✅ | ✅ | ✅ | ✅ | +| [fs](plugins/fs) | Access the file system. | ✅ | ✅ | ✅ | ? | ? | +| [geolocation](plugins/geolocation) | Get and track current device position. | ? | ? | ? | ✅ | ✅ | +| [global-shortcut](plugins/global-shortcut) | Register global shortcuts. | ✅ | ✅ | ✅ | ? | ? | +| [haptics](plugins/haptics) | Haptic feedback and vibrations. | ? | ? | ? | ✅ | ✅ | +| [http](plugins/http) | Access the HTTP client written in Rust. | ✅ | ✅ | ✅ | ✅ | ✅ | +| [localhost](plugins/localhost) | Use a localhost server in production apps. | ✅ | ✅ | ✅ | ? | ? | +| [log](plugins/log) | Configurable logging. | ✅ | ✅ | ✅ | ✅ | ✅ | +| [nfc](plugins/nfc) | Read and write NFC tags on Android and iOS. | ? | ? | ? | ✅ | ✅ | +| [notification](plugins/notification) | Send message notifications (brief auto-expiring OS window element) to your user. Can also be used with the Notification Web API. | ✅ | ✅ | ✅ | ✅ | ✅ | +| [opener](plugins/opener) | Open files and URLs using their default application. | ✅ | ✅ | ✅ | ? | ? | +| [os](plugins/os) | Read information about the operating system. | ✅ | ✅ | ✅ | ✅ | ✅ | +| [persisted-scope](plugins/persisted-scope) | Persist runtime scope changes on the filesystem. | ✅ | ✅ | ✅ | ? | ? | +| [positioner](plugins/positioner) | Move windows to common locations. | ✅ | ✅ | ✅ | ❌ | ❌ | +| [process](plugins/process) | This plugin provides APIs to access the current process. To spawn child processes, see the [`shell`](https://github.com/tauri-apps/tauri-plugin-shell) plugin. | ✅ | ✅ | ✅ | ? | ? | +| [shell](plugins/shell) | Access the system shell. Allows you to spawn child processes and manage files and URLs using their default application. | ✅ | ✅ | ✅ | ? | ? | +| [single-instance](plugins/single-instance) | Ensure a single instance of your tauri app is running. | ✅ | ✅ | ✅ | ❌ | ❌ | +| [sql](plugins/sql) | Interface with SQL databases. | ✅ | ✅ | ✅ | ✅ | ✅ | +| [store](plugins/store) | Persistent key value storage. | ✅ | ✅ | ✅ | ✅ | ✅ | +| [stronghold](plugins/stronghold) | Encrypted, secure database. | ✅ | ✅ | ✅ | ? | ? | +| [updater](plugins/updater) | In-app updates for Tauri applications. | ✅ | ✅ | ✅ | ❌ | ❌ | +| [upload](plugins/upload) | Tauri plugin for file uploads through HTTP. | ✅ | ✅ | ✅ | ? | ? | +| [websocket](plugins/websocket) | Open a WebSocket connection using a Rust client in JS. | ✅ | ✅ | ✅ | ? | ? | +| [window-state](plugins/window-state) | Persist window sizes and positions. | ✅ | ✅ | ✅ | ❌ | ❌ | + +- ✅: (Partially) Supported +- ❌: Not supported +- `?` : Unknown/Untested or Planned + +## Contributing + +PRs accepted. Please make sure to read the [Contributing Guide](https://github.com/tauri-apps/tauri/blob/dev/.github/CONTRIBUTING.md) before making a pull request. + +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..4f09bbac --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,23 @@ +# Security Policy + +**Do not report security vulnerabilities through public GitHub issues.** + +**Please use the [Private Vulnerability Disclosure](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) feature of GitHub.** + +Include as much of the following information: + +- Type of issue (e.g. improper input parsing, privilege escalation, etc.) +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- The distribution affected or used to help us with reproduction of the issue +- Step-by-step instructions to reproduce the issue +- Ideally a reproduction repository +- Impact of the issue, including how an attacker might exploit the issue + +We prefer to receive reports in English. + +## Contact + +Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). + +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 00000000..f34103ee --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,38 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import eslint from '@eslint/js' +import eslintConfigPrettier from 'eslint-config-prettier' +import eslintPluginSecurity from 'eslint-plugin-security' +import tseslint from 'typescript-eslint' + +export default tseslint.config( + { + ignores: [ + '**/target', + '**/node_modules', + '**/examples', + '**/dist', + '**/dist-js', + '**/build', + '**/api-iife.js', + '**/init-iife.js', + '**/init.js', + '**/rollup.config.js', + '**/bindings.ts', + '**/.test-server', + '.scripts', + 'eslint.config.js' + ] + }, + eslint.configs.recommended, + eslintConfigPrettier, + eslintPluginSecurity.configs.recommended, + ...tseslint.configs.recommendedTypeChecked, + { + languageOptions: { + parserOptions: { project: true, tsconfigRootDir: import.meta.dirname } + } + } +) diff --git a/examples/api/.gitignore b/examples/api/.gitignore deleted file mode 100644 index ac9643a2..00000000 --- a/examples/api/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -/node_modules/ -/.vscode/ -.DS_Store -.cargo diff --git a/examples/api/CHANGELOG.md b/examples/api/CHANGELOG.md index 5f5ead97..6cc04295 100644 --- a/examples/api/CHANGELOG.md +++ b/examples/api/CHANGELOG.md @@ -1,5 +1,567 @@ # Changelog +## \[2.0.22] + +### Dependencies + +- Upgraded to `fs-js@2.3.0` +- Upgraded to `global-shortcut-js@2.2.1` +- Upgraded to `http-js@2.4.4` +- Upgraded to `opener-js@2.2.7` +- Upgraded to `dialog-js@2.2.2` + +## \[2.0.21] + +### Dependencies + +- Upgraded to `log-js@2.4.0` +- Upgraded to `biometric-js@2.2.1` +- Upgraded to `updater-js@2.7.1` + +## \[2.0.20] + +### Dependencies + +- Upgraded to `http-js@2.4.3` +- Upgraded to `shell-js@2.2.1` +- Upgraded to `fs-js@2.2.1` +- Upgraded to `process-js@2.2.1` +- Upgraded to `updater-js@2.7.0` +- Upgraded to `dialog-js@2.2.1` + +## \[2.0.19] + +### Dependencies + +- Upgraded to `http-js@2.4.2` +- Upgraded to `updater-js@2.6.1` + +## \[2.0.18] + +### Dependencies + +- Upgraded to `http-js@2.4.1` + +## \[2.0.17] + +### Dependencies + +- Upgraded to `log-js@2.3.1` + +## \[2.0.16] + +### Dependencies + +- Upgraded to `clipboard-manager-js@2.2.2` +- Upgraded to `notification-js@2.2.2` +- Upgraded to `os-js@2.2.1` +- Upgraded to `http-js@2.4.0` +- Upgraded to `log-js@2.3.0` +- Upgraded to `updater-js@2.6.0` + +## \[2.0.15] + +### Dependencies + +- Upgraded to `log-js@2.2.3` +- Upgraded to `opener-js@2.2.6` + +## \[2.0.14] + +### Dependencies + +- Upgraded to `log-js@2.2.2` +- Upgraded to `updater-js@2.5.1` + +## \[2.0.13] + +### Dependencies + +- Upgraded to `updater-js@2.5.0` + +## \[2.0.12] + +### Dependencies + +- Upgraded to `clipboard-manager-js@2.2.1` +- Upgraded to `http-js@2.3.0` +- Upgraded to `log-js@2.2.1` +- Upgraded to `updater-js@2.4.0` + +## \[2.0.11] + +### Dependencies + +- Upgraded to `opener-js@2.2.5` + +## \[2.0.10] + +### Dependencies + +- Upgraded to `notification-js@2.2.1` +- Upgraded to `opener-js@2.2.4` + +## \[2.0.9] + +### Dependencies + +- Upgraded to `opener-js@2.2.3` +- Upgraded to `updater-js@2.3.1` + +## \[2.0.8] + +### Dependencies + +- Upgraded to `opener-js@2.2.2` + +## \[2.0.7] + +### Dependencies + +- Upgraded to `updater-js@2.3.0` +- Upgraded to `opener-js@2.2.1` + +## \[2.0.6] + +### Dependencies + +- Upgraded to `barcode-scanner-js@2.1.0` +- Upgraded to `biometric-js@2.1.0` +- Upgraded to `cli-js@2.1.0` +- Upgraded to `clipboard-manager-js@2.1.0` +- Upgraded to `dialog-js@2.1.0` +- Upgraded to `fs-js@2.1.0` +- Upgraded to `global-shortcut-js@2.1.0` +- Upgraded to `http-js@2.1.0` +- Upgraded to `log-js@2.1.0` +- Upgraded to `nfc-js@2.1.0` +- Upgraded to `notification-js@2.1.0` +- Upgraded to `opener-js@2.1.0` +- Upgraded to `os-js@2.1.0` +- Upgraded to `process-js@2.1.0` +- Upgraded to `shell-js@2.1.0` +- Upgraded to `store-js@2.2.0` +- Upgraded to `updater-js@2.1.0` + +## \[2.0.5] + +### Dependencies + +- Upgraded to `fs-js@2.0.4` +- Upgraded to `dialog-js@2.0.2` +- Upgraded to `http-js@2.0.2` + +## \[2.0.4] + +### Dependencies + +- Upgraded to `log-js@2.0.2` + +## \[2.0.3] + +### Dependencies + +- Upgraded to `clipboard-manager-js@2.0.1` +- Upgraded to `log-js@2.0.1` +- Upgraded to `fs-js@2.0.3` +- Upgraded to `opener-js@2.0.0` + +## \[2.0.2] + +### Dependencies + +- Upgraded to `fs-js@2.0.2` + +## \[2.0.1] + +### Dependencies + +- Upgraded to `dialog-js@2.0.1` +- Upgraded to `fs-js@2.0.1` +- Upgraded to `http-js@2.0.1` +- Upgraded to `shell-js@2.0.1` +- Upgraded to `store-js@2.1.0` + +## \[2.0.0] + +- [`e2c4dfb6`](https://github.com/tauri-apps/plugins-workspace/commit/e2c4dfb6af43e5dd8d9ceba232c315f5febd55c1) Update to tauri v2 stable release. + +### Dependencies + +- Upgraded to `barcode-scanner-js@2.0.0` +- Upgraded to `biometric-js@2.0.0` +- Upgraded to `cli-js@2.0.0` +- Upgraded to `clipboard-manager-js@2.0.0` +- Upgraded to `fs-js@2.0.0` +- Upgraded to `dialog-js@2.0.0` +- Upgraded to `global-shortcut-js@2.0.0` +- Upgraded to `http-js@2.0.0` +- Upgraded to `log-js@2.0.0` +- Upgraded to `nfc-js@2.0.0` +- Upgraded to `notification-js@2.0.0` +- Upgraded to `os-js@2.0.0` +- Upgraded to `process-js@2.0.0` +- Upgraded to `shell-js@2.0.0` +- Upgraded to `store-js@2.0.0` +- Upgraded to `updater-js@2.0.0` + +## \[2.0.0-rc.5] + +### Dependencies + +- Upgraded to `store-js@2.0.0-rc.2` + +## \[2.0.0-rc.4] + +### Dependencies + +- Upgraded to `barcode-scanner-js@2.0.0-rc.2` +- Upgraded to `clipboard-manager-js@2.0.0-rc.2` + +## \[2.0.0-rc.3] + +### Dependencies + +- Upgraded to `updater-js@2.0.0-rc.2` + +## \[2.0.0-rc.2] + +### Dependencies + +- Upgraded to `barcode-scanner-js@2.0.0-rc.1` +- Upgraded to `notification-js@2.0.0-rc.1` +- Upgraded to `dialog-js@2.0.0-rc.1` +- Upgraded to `biometric-js@2.0.0-rc.1` +- Upgraded to `cli-js@2.0.0-rc.1` +- Upgraded to `clipboard-manager-js@2.0.0-rc.1` +- Upgraded to `fs-js@2.0.0-rc.2` +- Upgraded to `global-shortcut-js@2.0.0-rc.1` +- Upgraded to `http-js@2.0.0-rc.2` +- Upgraded to `log-js@2.0.0-rc.1` +- Upgraded to `nfc-js@2.0.0-rc.1` +- Upgraded to `os-js@2.0.0-rc.1` +- Upgraded to `process-js@2.0.0-rc.1` +- Upgraded to `shell-js@2.0.0-rc.1` +- Upgraded to `store-js@2.0.0-rc.1` +- Upgraded to `updater-js@2.0.0-rc.1` + +## \[2.0.0-rc.1] + +### Dependencies + +- Upgraded to `http-js@2.0.0-rc.1` +- Upgraded to `fs-js@2.0.0-rc.1` + +## \[2.0.0-rc.0] + +### Dependencies + +- Upgraded to `barcode-scanner-js@2.0.0-rc.0` +- Upgraded to `biometric-js@2.0.0-rc.0` +- Upgraded to `cli-js@2.0.0-rc.0` +- Upgraded to `clipboard-manager-js@2.0.0-rc.0` +- Upgraded to `dialog-js@2.0.0-rc.0` +- Upgraded to `fs-js@2.0.0-rc.0` +- Upgraded to `global-shortcut-js@2.0.0-rc.0` +- Upgraded to `http-js@2.0.0-rc.0` +- Upgraded to `log-js@2.0.0-rc.0` +- Upgraded to `nfc-js@2.0.0-rc.0` +- Upgraded to `notification-js@2.0.0-rc.0` +- Upgraded to `os-js@2.0.0-rc.0` +- Upgraded to `process-js@2.0.0-rc.0` +- Upgraded to `shell-js@2.0.0-rc.0` +- Upgraded to `updater-js@2.0.0-rc.0` + +## \[2.0.0-beta.12] + +### Dependencies + +- Upgraded to `barcode-scanner-js@2.0.0-beta.8` +- Upgraded to `biometric-js@2.0.0-beta.8` +- Upgraded to `cli-js@2.0.0-beta.8` +- Upgraded to `clipboard-manager-js@2.1.0-beta.6` +- Upgraded to `dialog-js@2.0.0-beta.8` +- Upgraded to `fs-js@2.0.0-beta.8` +- Upgraded to `global-shortcut-js@2.0.0-beta.8` +- Upgraded to `http-js@2.0.0-beta.9` +- Upgraded to `log-js@2.0.0-beta.9` +- Upgraded to `nfc-js@2.0.0-beta.8` +- Upgraded to `notification-js@2.0.0-beta.8` +- Upgraded to `os-js@2.0.0-beta.8` +- Upgraded to `process-js@2.0.0-beta.8` +- Upgraded to `shell-js@2.0.0-beta.9` +- Upgraded to `updater-js@2.0.0-beta.8` + +## \[2.0.0-beta.11] + +### Dependencies + +- Upgraded to `global-shortcut-js@2.0.0-beta.7` +- Upgraded to `http-js@2.0.0-beta.8` +- Upgraded to `os-js@2.0.0-beta.7` +- Upgraded to `barcode-scanner-js@2.0.0-beta.7` +- Upgraded to `biometric-js@2.0.0-beta.7` +- Upgraded to `cli-js@2.0.0-beta.7` +- Upgraded to `clipboard-manager-js@2.1.0-beta.5` +- Upgraded to `dialog-js@2.0.0-beta.7` +- Upgraded to `fs-js@2.0.0-beta.7` +- Upgraded to `log-js@2.0.0-beta.8` +- Upgraded to `nfc-js@2.0.0-beta.7` +- Upgraded to `notification-js@2.0.0-beta.7` +- Upgraded to `process-js@2.0.0-beta.7` +- Upgraded to `shell-js@2.0.0-beta.8` +- Upgraded to `updater-js@2.0.0-beta.7` + +## \[2.0.0-beta.10] + +### Dependencies + +- Upgraded to `os-js@2.0.0-beta.6` +- Upgraded to `barcode-scanner-js@2.0.0-beta.6` +- Upgraded to `biometric-js@2.0.0-beta.6` +- Upgraded to `cli-js@2.0.0-beta.6` +- Upgraded to `clipboard-manager-js@2.1.0-beta.4` +- Upgraded to `dialog-js@2.0.0-beta.6` +- Upgraded to `fs-js@2.0.0-beta.6` +- Upgraded to `global-shortcut-js@2.0.0-beta.6` +- Upgraded to `http-js@2.0.0-beta.7` +- Upgraded to `log-js@2.0.0-beta.7` +- Upgraded to `nfc-js@2.0.0-beta.6` +- Upgraded to `notification-js@2.0.0-beta.6` +- Upgraded to `process-js@2.0.0-beta.6` +- Upgraded to `shell-js@2.0.0-beta.7` +- Upgraded to `updater-js@2.0.0-beta.6` + +## \[2.0.0-beta.9] + +### Dependencies + +- Upgraded to `http-js@2.0.0-beta.6` + +## \[2.0.0-beta.8] + +### Dependencies + +- Upgraded to `barcode-scanner-js@2.0.0-beta.5` +- Upgraded to `biometric-js@2.0.0-beta.5` +- Upgraded to `cli-js@2.0.0-beta.5` +- Upgraded to `clipboard-manager-js@2.1.0-beta.3` +- Upgraded to `dialog-js@2.0.0-beta.5` +- Upgraded to `fs-js@2.0.0-beta.5` +- Upgraded to `global-shortcut-js@2.0.0-beta.5` +- Upgraded to `http-js@2.0.0-beta.5` +- Upgraded to `log-js@2.0.0-beta.6` +- Upgraded to `nfc-js@2.0.0-beta.5` +- Upgraded to `notification-js@2.0.0-beta.5` +- Upgraded to `os-js@2.0.0-beta.5` +- Upgraded to `process-js@2.0.0-beta.5` +- Upgraded to `shell-js@2.0.0-beta.6` +- Upgraded to `updater-js@2.0.0-beta.5` + +## \[2.0.0-beta.7] + +### Dependencies + +- Upgraded to `http-js@2.0.0-beta.4` +- Upgraded to `barcode-scanner-js@2.0.0-beta.4` +- Upgraded to `biometric-js@2.0.0-beta.4` +- Upgraded to `cli-js@2.0.0-beta.4` +- Upgraded to `clipboard-manager-js@2.1.0-beta.2` +- Upgraded to `dialog-js@2.0.0-beta.4` +- Upgraded to `fs-js@2.0.0-beta.4` +- Upgraded to `global-shortcut-js@2.0.0-beta.4` +- Upgraded to `log-js@2.0.0-beta.5` +- Upgraded to `nfc-js@2.0.0-beta.4` +- Upgraded to `notification-js@2.0.0-beta.4` +- Upgraded to `os-js@2.0.0-beta.4` +- Upgraded to `process-js@2.0.0-beta.4` +- Upgraded to `shell-js@2.0.0-beta.5` +- Upgraded to `updater-js@2.0.0-beta.4` + +## \[2.0.0-beta.6] + +### Dependencies + +- Upgraded to `shell-js@2.0.0-beta.4` + +## \[2.0.0-beta.5] + +### Dependencies + +- Upgraded to `global-shortcut-js@2.0.0-beta.3` +- Upgraded to `barcode-scanner-js@2.0.0-beta.3` +- Upgraded to `biometric-js@2.0.0-beta.3` +- Upgraded to `cli-js@2.0.0-beta.3` +- Upgraded to `clipboard-manager-js@2.1.0-beta.1` +- Upgraded to `dialog-js@2.0.0-beta.3` +- Upgraded to `fs-js@2.0.0-beta.3` +- Upgraded to `http-js@2.0.0-beta.3` +- Upgraded to `log-js@2.0.0-beta.4` +- Upgraded to `nfc-js@2.0.0-beta.3` +- Upgraded to `notification-js@2.0.0-beta.3` +- Upgraded to `os-js@2.0.0-beta.3` +- Upgraded to `process-js@2.0.0-beta.3` +- Upgraded to `shell-js@2.0.0-beta.3` +- Upgraded to `updater-js@2.0.0-beta.3` + +## \[2.0.0-beta.4] + +### Dependencies + +- Upgraded to `log-js@2.0.0-beta.3` + +## \[2.0.0-beta.3] + +### Dependencies + +- Upgraded to `clipboard-manager-js@2.1.0-beta.0` + +## \[2.0.0-beta.2] + +### Dependencies + +- Upgraded to `clipboard-manager-js@2.0.0-beta.2` +- Upgraded to `dialog-js@2.0.0-beta.2` +- Upgraded to `fs-js@2.0.0-beta.2` +- Upgraded to `http-js@2.0.0-beta.2` +- Upgraded to `shell-js@2.0.0-beta.2` +- Upgraded to `barcode-scanner-js@2.0.0-beta.2` +- Upgraded to `biometric-js@2.0.0-beta.2` +- Upgraded to `cli-js@2.0.0-beta.2` +- Upgraded to `global-shortcut-js@2.0.0-beta.2` +- Upgraded to `log-js@2.0.0-beta.2` +- Upgraded to `nfc-js@2.0.0-beta.2` +- Upgraded to `notification-js@2.0.0-beta.2` +- Upgraded to `os-js@2.0.0-beta.2` +- Upgraded to `process-js@2.0.0-beta.2` +- Upgraded to `updater-js@2.0.0-beta.2` + +## \[2.0.0-beta.1] + +### Dependencies + +- Upgraded to `barcode-scanner-js@2.0.0-beta.1` +- Upgraded to `biometric-js@2.0.0-beta.1` +- Upgraded to `cli-js@2.0.0-beta.1` +- Upgraded to `clipboard-manager-js@2.0.0-beta.1` +- Upgraded to `dialog-js@2.0.0-beta.1` +- Upgraded to `fs-js@2.0.0-beta.1` +- Upgraded to `global-shortcut-js@2.0.0-beta.1` +- Upgraded to `http-js@2.0.0-beta.1` +- Upgraded to `log-js@2.0.0-beta.1` +- Upgraded to `nfc-js@2.0.0-beta.1` +- Upgraded to `notification-js@2.0.0-beta.1` +- Upgraded to `os-js@2.0.0-beta.1` +- Upgraded to `process-js@2.0.0-beta.1` +- Upgraded to `shell-js@2.0.0-beta.1` +- Upgraded to `updater-js@2.0.0-beta.1` + +## \[2.0.0-beta.0] + +### Dependencies + +- Upgraded to `barcode-scanner-js@2.0.0-beta.0` +- Upgraded to `biometric-js@2.0.0-beta.0` +- Upgraded to `cli-js@2.0.0-beta.0` +- Upgraded to `clipboard-manager-js@2.0.0-beta.0` +- Upgraded to `dialog-js@2.0.0-beta.0` +- Upgraded to `fs-js@2.0.0-beta.0` +- Upgraded to `global-shortcut-js@2.0.0-beta.0` +- Upgraded to `http-js@2.0.0-beta.0` +- Upgraded to `log-js@2.0.0-beta.0` +- Upgraded to `nfc-js@2.0.0-beta.0` +- Upgraded to `notification-js@2.0.0-beta.0` +- Upgraded to `os-js@2.0.0-beta.0` +- Upgraded to `process-js@2.0.0-beta.0` +- Upgraded to `shell-js@2.0.0-beta.0` +- Upgraded to `updater-js@2.0.0-beta.0` + +## \[2.0.0-alpha.9] + +### Dependencies + +- Upgraded to `fs-js@2.0.0-alpha.6` + +## \[2.0.0-alpha.8] + +### Dependencies + +- Upgraded to `http-js@2.0.0-alpha.6` + +## \[2.0.0-alpha.7] + +### Dependencies + +- Upgraded to `barcode-scanner-js@2.0.0-alpha.4` +- Upgraded to `cli-js@2.0.0-alpha.5` +- Upgraded to `clipboard-manager-js@2.0.0-alpha.5` +- Upgraded to `dialog-js@2.0.0-alpha.5` +- Upgraded to `fs-js@2.0.0-alpha.5` +- Upgraded to `global-shortcut-js@2.0.0-alpha.5` +- Upgraded to `http-js@2.0.0-alpha.5` +- Upgraded to `log-js@2.0.0-alpha.5` +- Upgraded to `notification-js@2.0.0-alpha.5` +- Upgraded to `os-js@2.0.0-alpha.6` +- Upgraded to `process-js@2.0.0-alpha.5` +- Upgraded to `shell-js@2.0.0-alpha.5` +- Upgraded to `updater-js@2.0.0-alpha.5` +- Upgraded to `biometric-js@2.0.0-alpha.0` +- Upgraded to `nfc-js@2.0.0-alpha.0` + +## \[2.0.0-alpha.6] + +### Dependencies + +- Upgraded to `barcode-scanner-js@2.0.0-alpha.3` +- Upgraded to `cli-js@2.0.0-alpha.4` +- Upgraded to `clipboard-manager-js@2.0.0-alpha.4` +- Upgraded to `dialog-js@2.0.0-alpha.4` +- Upgraded to `fs-js@2.0.0-alpha.4` +- Upgraded to `global-shortcut-js@2.0.0-alpha.4` +- Upgraded to `http-js@2.0.0-alpha.4` +- Upgraded to `log-js@2.0.0-alpha.4` +- Upgraded to `notification-js@2.0.0-alpha.4` +- Upgraded to `os-js@2.0.0-alpha.5` +- Upgraded to `process-js@2.0.0-alpha.4` +- Upgraded to `shell-js@2.0.0-alpha.4` +- Upgraded to `updater-js@2.0.0-alpha.4` + +## \[2.0.0-alpha.5] + +### Dependencies + +- Upgraded to `barcode-scanner-js@2.0.0-alpha.2` +- Upgraded to `cli-js@2.0.0-alpha.3` +- Upgraded to `clipboard-manager-js@2.0.0-alpha.3` +- Upgraded to `dialog-js@2.0.0-alpha.3` +- Upgraded to `fs-js@2.0.0-alpha.3` +- Upgraded to `global-shortcut-js@2.0.0-alpha.3` +- Upgraded to `http-js@2.0.0-alpha.3` +- Upgraded to `log-js@2.0.0-alpha.3` +- Upgraded to `notification-js@2.0.0-alpha.3` +- Upgraded to `os-js@2.0.0-alpha.4` +- Upgraded to `process-js@2.0.0-alpha.3` +- Upgraded to `shell-js@2.0.0-alpha.3` +- Upgraded to `updater-js@2.0.0-alpha.3` + +## \[2.0.0-alpha.4] + +### Dependencies + +- Upgraded to `barcode-scanner-js@2.0.0-alpha.1` +- Upgraded to `cli-js@2.0.0-alpha.2` +- Upgraded to `clipboard-manager-js@2.0.0-alpha.2` +- Upgraded to `dialog-js@2.0.0-alpha.2` +- Upgraded to `fs-js@2.0.0-alpha.2` +- Upgraded to `global-shortcut-js@2.0.0-alpha.2` +- Upgraded to `http-js@2.0.0-alpha.2` +- Upgraded to `log-js@2.0.0-alpha.2` +- Upgraded to `notification-js@2.0.0-alpha.2` +- Upgraded to `os-js@2.0.0-alpha.3` +- Upgraded to `process-js@2.0.0-alpha.2` +- Upgraded to `shell-js@2.0.0-alpha.2` +- Upgraded to `updater-js@2.0.0-alpha.2` + ## \[2.0.0-alpha.3] ### Dependencies diff --git a/examples/api/isolation-dist/index.js b/examples/api/isolation-dist/index.js index 83f35e0d..7e2df30d 100644 --- a/examples/api/isolation-dist/index.js +++ b/examples/api/isolation-dist/index.js @@ -3,5 +3,5 @@ // SPDX-License-Identifier: MIT window.__TAURI_ISOLATION_HOOK__ = (payload) => { - return payload; -}; + return payload +} diff --git a/examples/api/jsconfig.json b/examples/api/jsconfig.json index 42585941..5696a2de 100644 --- a/examples/api/jsconfig.json +++ b/examples/api/jsconfig.json @@ -1,14 +1,14 @@ { "compilerOptions": { - "moduleResolution": "node", - "target": "esnext", - "module": "esnext", + "moduleResolution": "bundler", + "target": "ESNext", + "module": "ESNext", /** * svelte-preprocess cannot figure out whether you have * a value or a type, so tell TypeScript to enforce using * `import type` instead of `import` for Types. */ - "importsNotUsedAsValues": "error", + "verbatimModuleSyntax": true, "isolatedModules": true, "resolveJsonModule": true, /** @@ -18,8 +18,6 @@ "sourceMap": true, "esModuleInterop": true, "skipLibCheck": true, - "forceConsistentCasingInFileNames": true, - "baseUrl": ".", /** * Typecheck JS in `.svelte` and `.js` files by default. * Disable this if you'd like to use dynamic types. diff --git a/examples/api/package.json b/examples/api/package.json index 499d6b0d..74a618eb 100644 --- a/examples/api/package.json +++ b/examples/api/package.json @@ -1,38 +1,44 @@ { - "name": "svelte-app", + "name": "api", "private": true, - "version": "2.0.0-alpha.3", + "version": "2.0.22", "type": "module", "scripts": { "dev": "vite --clearScreen false", "build": "vite build", - "serve": "vite preview" + "serve": "vite preview", + "tauri": "tauri" }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.9", - "@tauri-apps/plugin-barcode-scanner": "2.0.0-alpha.0", - "@tauri-apps/plugin-cli": "2.0.0-alpha.1", - "@tauri-apps/plugin-clipboard-manager": "2.0.0-alpha.1", - "@tauri-apps/plugin-dialog": "2.0.0-alpha.1", - "@tauri-apps/plugin-fs": "2.0.0-alpha.1", - "@tauri-apps/plugin-global-shortcut": "2.0.0-alpha.1", - "@tauri-apps/plugin-http": "2.0.0-alpha.1", - "@tauri-apps/plugin-notification": "2.0.0-alpha.1", - "@tauri-apps/plugin-os": "2.0.0-alpha.2", - "@tauri-apps/plugin-process": "2.0.0-alpha.1", - "@tauri-apps/plugin-shell": "2.0.0-alpha.1", - "@tauri-apps/plugin-updater": "2.0.0-alpha.1", - "@zerodevx/svelte-json-view": "1.0.7" + "@tauri-apps/api": "2.5.0", + "@tauri-apps/plugin-barcode-scanner": "^2.2.0", + "@tauri-apps/plugin-biometric": "^2.2.1", + "@tauri-apps/plugin-cli": "^2.2.0", + "@tauri-apps/plugin-clipboard-manager": "^2.2.2", + "@tauri-apps/plugin-dialog": "^2.2.2", + "@tauri-apps/plugin-fs": "^2.3.0", + "@tauri-apps/plugin-geolocation": "^2.2.0", + "@tauri-apps/plugin-global-shortcut": "^2.2.1", + "@tauri-apps/plugin-haptics": "^2.2.0", + "@tauri-apps/plugin-http": "^2.4.4", + "@tauri-apps/plugin-nfc": "^2.2.0", + "@tauri-apps/plugin-notification": "^2.2.2", + "@tauri-apps/plugin-opener": "^2.2.7", + "@tauri-apps/plugin-os": "^2.2.1", + "@tauri-apps/plugin-process": "^2.2.1", + "@tauri-apps/plugin-shell": "^2.2.1", + "@tauri-apps/plugin-store": "^2.2.0", + "@tauri-apps/plugin-updater": "^2.7.1", + "@zerodevx/svelte-json-view": "1.0.11" }, "devDependencies": { - "@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", - "@unocss/extractor-svelte": "^0.56.5", - "internal-ip": "^8.0.0", - "svelte": "^4.2.2", - "unocss": "^0.56.5", - "vite": "^4.5.0" + "@iconify-json/codicon": "^1.2.12", + "@iconify-json/ph": "^1.2.2", + "@sveltejs/vite-plugin-svelte": "^5.0.3", + "@tauri-apps/cli": "2.5.0", + "@unocss/extractor-svelte": "^66.0.0", + "svelte": "^5.20.4", + "unocss": "^66.0.0", + "vite": "^6.2.6" } } diff --git a/examples/api/src-tauri/.gitignore b/examples/api/src-tauri/.gitignore index 211f2466..99cb2b7c 100644 --- a/examples/api/src-tauri/.gitignore +++ b/examples/api/src-tauri/.gitignore @@ -4,3 +4,7 @@ # cargo-mobile .cargo/ + +gen/schemas/*.json +!gen/schemas/desktop-schema.json +!gen/schemas/mobile-schema.json diff --git a/examples/api/src-tauri/CHANGELOG.md b/examples/api/src-tauri/CHANGELOG.md index 5cd80f98..7399722d 100644 --- a/examples/api/src-tauri/CHANGELOG.md +++ b/examples/api/src-tauri/CHANGELOG.md @@ -1,5 +1,732 @@ # Changelog +## \[2.0.26] + +### Dependencies + +- Upgraded to `fs@2.3.0` +- Upgraded to `global-shortcut@2.2.1` +- Upgraded to `http@2.4.4` +- Upgraded to `opener@2.2.7` +- Upgraded to `dialog@2.2.2` + +## \[2.0.25] + +### Dependencies + +- Upgraded to `log@2.4.0` +- Upgraded to `biometric@2.2.1` +- Upgraded to `updater@2.7.1` + +## \[2.0.24] + +### Dependencies + +- Upgraded to `http@2.4.3` +- Upgraded to `shell@2.2.1` +- Upgraded to `fs@2.2.1` +- Upgraded to `process@2.2.1` +- Upgraded to `updater@2.7.0` +- Upgraded to `dialog@2.2.1` + +## \[2.0.23] + +### Dependencies + +- Upgraded to `http@2.4.2` +- Upgraded to `updater@2.6.1` + +## \[2.0.22] + +### Dependencies + +- Upgraded to `http@2.4.1` + +## \[2.0.21] + +### Dependencies + +- Upgraded to `log@2.3.1` + +## \[2.0.20] + +### Dependencies + +- Upgraded to `clipboard-manager@2.2.2` +- Upgraded to `geolocation@2.2.4` +- Upgraded to `haptics@2.2.4` +- Upgraded to `notification@2.2.2` +- Upgraded to `os@2.2.1` +- Upgraded to `http@2.4.0` +- Upgraded to `log@2.3.0` +- Upgraded to `updater@2.6.0` + +## \[2.0.19] + +### Dependencies + +- Upgraded to `log@2.2.3` +- Upgraded to `opener@2.2.6` + +## \[2.0.18] + +### Dependencies + +- Upgraded to `log@2.2.2` +- Upgraded to `updater@2.5.1` + +## \[2.0.17] + +### Dependencies + +- Upgraded to `updater@2.5.0` + +## \[2.0.16] + +### Dependencies + +- Upgraded to `clipboard-manager@2.2.1` +- Upgraded to `http@2.3.0` +- Upgraded to `log@2.2.1` +- Upgraded to `updater@2.4.0` + +## \[2.0.15] + +### Dependencies + +- Upgraded to `haptics@2.2.3` +- Upgraded to `geolocation@2.2.3` +- Upgraded to `opener@2.2.5` + +## \[2.0.14] + +### Dependencies + +- Upgraded to `geolocation@2.2.2` +- Upgraded to `haptics@2.2.2` +- Upgraded to `notification@2.2.1` +- Upgraded to `opener@2.2.4` + +## \[2.0.13] + +### Dependencies + +- Upgraded to `geolocation@2.2.1` +- Upgraded to `haptics@2.2.1` + +## \[2.0.12] + +### Dependencies + +- Upgraded to `opener@2.2.3` +- Upgraded to `updater@2.3.1` + +## \[2.0.11] + +### Dependencies + +- Upgraded to `opener@2.2.2` + +## \[2.0.10] + +### Dependencies + +- Upgraded to `updater@2.3.0` +- Upgraded to `opener@2.2.1` + +## \[2.0.9] + +### Dependencies + +- Upgraded to `barcode-scanner@2.1.0` +- Upgraded to `biometric@2.1.0` +- Upgraded to `cli@2.1.0` +- Upgraded to `clipboard-manager@2.1.0` +- Upgraded to `dialog@2.1.0` +- Upgraded to `fs@2.2.0` +- Upgraded to `geolocation@2.1.0` +- Upgraded to `global-shortcut@2.1.0` +- Upgraded to `haptics@2.1.0` +- Upgraded to `http@2.1.0` +- Upgraded to `log@2.1.0` +- Upgraded to `nfc@2.1.0` +- Upgraded to `notification@2.1.0` +- Upgraded to `opener@2.1.0` +- Upgraded to `os@2.1.0` +- Upgraded to `process@2.1.0` +- Upgraded to `shell@2.1.0` +- Upgraded to `store@2.2.0` +- Upgraded to `updater@2.2.0` + +## \[2.0.8] + +### Dependencies + +- Upgraded to `fs@2.1.1` +- Upgraded to `dialog@2.0.5` +- Upgraded to `http@2.0.5` + +## \[2.0.7] + +### Dependencies + +- Upgraded to `log@2.0.4` + +## \[2.0.6] + +### Dependencies + +- Upgraded to `fs@2.1.0` +- Upgraded to `updater@2.1.0` +- Upgraded to `dialog@2.0.4` +- Upgraded to `log-plugin@2.0.3` +- Upgraded to `http@2.0.4` +- Upgraded to `opener@2.0.0` + +## \[2.0.5] + +### Dependencies + +- Upgraded to `clipboard-manager@2.0.2` +- Upgraded to `log-plugin@2.0.2` + +## \[2.0.4] + +### Dependencies + +- Upgraded to `fs@2.0.3` +- Upgraded to `dialog@2.0.3` +- Upgraded to `http@2.0.3` + +## \[2.0.3] + +### Dependencies + +- Upgraded to `dialog@2.0.2` +- Upgraded to `fs@2.0.2` +- Upgraded to `http@2.0.2` +- Upgraded to `shell@2.0.2` +- Upgraded to `store@2.1.0` + +## \[2.0.2] + +- [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. + +### Dependencies + +- Upgraded to `barcode-scanner@2.0.1` +- Upgraded to `biometric@2.0.1` +- Upgraded to `cli@2.0.1` +- Upgraded to `clipboard-manager@2.0.1` +- Upgraded to `fs@2.0.1` +- Upgraded to `dialog@2.0.1` +- Upgraded to `geolocation@2.0.1` +- Upgraded to `global-shortcut@2.0.1` +- Upgraded to `haptics@2.0.1` +- Upgraded to `http@2.0.1` +- Upgraded to `log-plugin@2.0.1` +- Upgraded to `nfc@2.0.1` +- Upgraded to `notification@2.0.1` +- Upgraded to `os@2.0.1` +- Upgraded to `process@2.0.1` +- Upgraded to `shell@2.0.1` +- Upgraded to `store@2.0.1` +- Upgraded to `updater@2.0.2` + +## \[2.0.1] + +### Dependencies + +- Upgraded to `updater@2.0.1` + +## \[2.0.0] + +- [`e2c4dfb6`](https://github.com/tauri-apps/plugins-workspace/commit/e2c4dfb6af43e5dd8d9ceba232c315f5febd55c1) Update to tauri v2 stable release. + +### Dependencies + +- Upgraded to `barcode-scanner@2.0.0` +- Upgraded to `biometric@2.0.0` +- Upgraded to `cli@2.0.0` +- Upgraded to `clipboard-manager@2.0.0` +- Upgraded to `fs@2.0.0` +- Upgraded to `dialog@2.0.0` +- Upgraded to `global-shortcut@2.0.0` +- Upgraded to `http@2.0.0` +- Upgraded to `log-plugin@2.0.0` +- Upgraded to `nfc@2.0.0` +- Upgraded to `notification@2.0.0` +- Upgraded to `os@2.0.0` +- Upgraded to `process@2.0.0` +- Upgraded to `shell@2.0.0` +- Upgraded to `store@2.0.0` +- Upgraded to `updater@2.0.0` + +## \[2.0.0-rc.8] + +### Dependencies + +- Upgraded to `cli@2.0.0-rc.2` +- Upgraded to `dialog@2.0.0-rc.8` +- Upgraded to `fs@2.0.0-rc.6` +- Upgraded to `shell@2.0.0-rc.4` +- Upgraded to `store@2.0.0-rc.4` +- Upgraded to `updater@2.0.0-rc.4` +- Upgraded to `http@2.0.0-rc.6` + +## \[2.0.0-rc.7] + +### Dependencies + +- Upgraded to `clipboard-manager@2.0.0-rc.4` +- Upgraded to `fs@2.0.0-rc.5` +- Upgraded to `notification@2.0.0-rc.5` +- Upgraded to `dialog@2.0.0-rc.7` +- Upgraded to `http@2.0.0-rc.5` + +## \[2.0.0-rc.6] + +### Dependencies + +- Upgraded to `dialog@2.0.0-rc.6` +- Upgraded to `fs@2.0.0-rc.4` +- Upgraded to `http@2.0.0-rc.4` + +## \[2.0.0-rc.5] + +### Dependencies + +- Upgraded to `barcode-scanner@2.0.0-rc.4` +- Upgraded to `notification@2.0.0-rc.4` + +## \[2.0.0-rc.4] + +### Dependencies + +- Upgraded to `fs@2.0.0-rc.3` +- Upgraded to `dialog@2.0.0-rc.5` +- Upgraded to `updater@2.0.0-rc.3` +- Upgraded to `http@2.0.0-rc.3` + +## \[2.0.0-rc.3] + +### Dependencies + +- Upgraded to `fs@2.0.0-rc.2` +- Upgraded to `dialog@2.0.0-rc.4` +- Upgraded to `http@2.0.0-rc.2` + +## \[2.0.0-rc.2] + +### Dependencies + +- Upgraded to `barcode-scanner@2.0.0-rc.3` +- Upgraded to `notification@2.0.0-rc.3` +- Upgraded to `dialog@2.0.0-rc.3` +- Upgraded to `fs@2.0.0-rc.1` +- Upgraded to `global-shortcut@2.0.0-rc.2` +- Upgraded to `store@2.0.0-rc.3` +- Upgraded to `biometric@2.0.0-rc.3` +- Upgraded to `cli@2.0.0-rc.1` +- Upgraded to `clipboard-manager@2.0.0-rc.3` +- Upgraded to `http@2.0.0-rc.1` +- Upgraded to `log-plugin@2.0.0-rc.2` +- Upgraded to `nfc@2.0.0-rc.3` +- Upgraded to `os@2.0.0-rc.1` +- Upgraded to `process@2.0.0-rc.1` +- Upgraded to `shell@2.0.0-rc.3` +- Upgraded to `updater@2.0.0-rc.2` + +## \[2.0.0-rc.1] + +### Dependencies + +- Upgraded to `barcode-scanner@2.0.0-rc.2` +- Upgraded to `biometric@2.0.0-rc.2` +- Upgraded to `clipboard-manager@2.0.0-rc.2` +- Upgraded to `dialog@2.0.0-rc.2` +- Upgraded to `log-plugin@2.0.0-rc.1` +- Upgraded to `nfc@2.0.0-rc.2` +- Upgraded to `notification@2.0.0-rc.2` +- Upgraded to `shell@2.0.0-rc.2` + +## \[2.0.0-rc.0] + +### Dependencies + +- Upgraded to `dialog@2.0.0-rc.1` +- Upgraded to `updater@2.0.0-rc.1` +- Upgraded to `barcode-scanner@2.0.0-rc.1` +- Upgraded to `clipboard-manager@2.0.0-rc.1` +- Upgraded to `global-shortcut@2.0.0-rc.1` +- Upgraded to `biometric@2.0.0-rc.1` +- Upgraded to `nfc@2.0.0-rc.1` +- Upgraded to `notification@2.0.0-rc.1` +- Upgraded to `shell@2.0.0-rc.1` + +## \[2.0.0-beta.17] + +### Dependencies + +- Upgraded to `barcode-scanner@2.0.0-rc.0` +- Upgraded to `biometric@2.0.0-rc.0` +- Upgraded to `cli@2.0.0-rc.0` +- Upgraded to `clipboard-manager@2.0.0-rc.0` +- Upgraded to `dialog@2.0.0-rc.0` +- Upgraded to `fs@2.0.0-rc.0` +- Upgraded to `global-shortcut@2.0.0-rc.0` +- Upgraded to `http@2.0.0-rc.0` +- Upgraded to `log-plugin@2.0.0-rc.0` +- Upgraded to `nfc@2.0.0-rc.0` +- Upgraded to `notification@2.0.0-rc.0` +- Upgraded to `os@2.0.0-rc.0` +- Upgraded to `process@2.0.0-rc.0` +- Upgraded to `shell@2.0.0-rc.0` +- Upgraded to `updater@2.0.0-rc.0` + +## \[2.0.0-beta.16] + +### Dependencies + +- Upgraded to `fs@2.0.0-beta.12` +- Upgraded to `barcode-scanner@2.0.0-beta.10` +- Upgraded to `biometric@2.0.0-beta.9` +- Upgraded to `cli@2.0.0-beta.9` +- Upgraded to `clipboard-manager@2.1.0-beta.7` +- Upgraded to `dialog@2.0.0-beta.12` +- Upgraded to `global-shortcut@2.0.0-beta.9` +- Upgraded to `http@2.0.0-beta.13` +- Upgraded to `log-plugin@2.0.0-beta.10` +- Upgraded to `nfc@2.0.0-beta.9` +- Upgraded to `notification@2.0.0-beta.12` +- Upgraded to `os@2.0.0-beta.9` +- Upgraded to `process@2.0.0-beta.9` +- Upgraded to `shell@2.0.0-beta.10` +- Upgraded to `updater@2.0.0-beta.12` + +## \[2.0.0-beta.15] + +### Dependencies + +- Upgraded to `log-plugin@2.0.0-beta.9` + +## \[2.0.0-beta.14] + +### Dependencies + +- Upgraded to `notification@2.0.0-beta.11` +- Upgraded to `updater@2.0.0-beta.11` + +## \[2.0.0-beta.13] + +### Dependencies + +- Upgraded to `biometric@2.0.0-beta.8` +- Upgraded to `global-shortcut@2.0.0-beta.8` +- Upgraded to `http@2.0.0-beta.12` +- Upgraded to `barcode-scanner@2.0.0-beta.9` +- Upgraded to `cli@2.0.0-beta.8` +- Upgraded to `clipboard-manager@2.1.0-beta.6` +- Upgraded to `dialog@2.0.0-beta.11` +- Upgraded to `fs@2.0.0-beta.11` +- Upgraded to `log-plugin@2.0.0-beta.8` +- Upgraded to `nfc@2.0.0-beta.8` +- Upgraded to `notification@2.0.0-beta.10` +- Upgraded to `os@2.0.0-beta.8` +- Upgraded to `process@2.0.0-beta.8` +- Upgraded to `shell@2.0.0-beta.9` +- Upgraded to `updater@2.0.0-beta.10` + +## \[2.0.0-beta.12] + +### Dependencies + +- Upgraded to `clipboard-manager@2.1.0-beta.5` +- Upgraded to `fs@2.0.0-beta.10` +- Upgraded to `updater@2.0.0-beta.9` +- Upgraded to `notification@2.0.0-beta.9` +- Upgraded to `os@2.0.0-beta.7` +- Upgraded to `barcode-scanner@2.0.0-beta.8` +- Upgraded to `biometric@2.0.0-beta.7` +- Upgraded to `cli@2.0.0-beta.7` +- Upgraded to `dialog@2.0.0-beta.10` +- Upgraded to `global-shortcut@2.0.0-beta.7` +- Upgraded to `http@2.0.0-beta.11` +- Upgraded to `log-plugin@2.0.0-beta.7` +- Upgraded to `nfc@2.0.0-beta.7` +- Upgraded to `process@2.0.0-beta.7` +- Upgraded to `shell@2.0.0-beta.8` + +## \[2.0.0-beta.11] + +### Dependencies + +- Upgraded to `notification@2.0.0-beta.8` +- Upgraded to `http@2.0.0-beta.10` +- Upgraded to `updater@2.0.0-beta.8` + +## \[2.0.0-beta.10] + +### Dependencies + +- Upgraded to `barcode-scanner@2.0.0-beta.7` +- Upgraded to `biometric@2.0.0-beta.6` +- Upgraded to `clipboard-manager@2.1.0-beta.4` +- Upgraded to `nfc@2.0.0-beta.6` +- Upgraded to `notification@2.0.0-beta.7` +- Upgraded to `shell@2.0.0-beta.7` +- Upgraded to `cli@2.0.0-beta.6` +- Upgraded to `dialog@2.0.0-beta.9` +- Upgraded to `fs@2.0.0-beta.9` +- Upgraded to `global-shortcut@2.0.0-beta.6` +- Upgraded to `http@2.0.0-beta.9` +- Upgraded to `log-plugin@2.0.0-beta.6` +- Upgraded to `os@2.0.0-beta.6` +- Upgraded to `process@2.0.0-beta.6` +- Upgraded to `updater@2.0.0-beta.7` + +## \[2.0.0-beta.9] + +### Dependencies + +- Upgraded to `clipboard-manager@2.1.0-beta.3` +- Upgraded to `dialog@2.0.0-beta.8` +- Upgraded to `http@2.0.0-beta.8` +- Upgraded to `notification@2.0.0-beta.6` +- Upgraded to `shell@2.0.0-beta.6` +- Upgraded to `barcode-scanner@2.0.0-beta.6` +- Upgraded to `biometric@2.0.0-beta.5` +- Upgraded to `nfc@2.0.0-beta.5` +- Upgraded to `cli@2.0.0-beta.5` +- Upgraded to `fs@2.0.0-beta.8` +- Upgraded to `global-shortcut@2.0.0-beta.5` +- Upgraded to `log-plugin@2.0.0-beta.5` +- Upgraded to `os@2.0.0-beta.5` +- Upgraded to `process@2.0.0-beta.5` +- Upgraded to `updater@2.0.0-beta.6` + +## \[2.0.0-beta.8] + +### Dependencies + +- Upgraded to `shell@2.0.0-beta.5` + +## \[2.0.0-beta.7] + +### Dependencies + +- Upgraded to `clipboard-manager@2.1.0-beta.2` +- Upgraded to `global-shortcut@2.0.0-beta.4` +- Upgraded to `barcode-scanner@2.0.0-beta.5` +- Upgraded to `biometric@2.0.0-beta.4` +- Upgraded to `cli@2.0.0-beta.4` +- Upgraded to `dialog@2.0.0-beta.7` +- Upgraded to `fs@2.0.0-beta.7` +- Upgraded to `http@2.0.0-beta.7` +- Upgraded to `log-plugin@2.0.0-beta.4` +- Upgraded to `nfc@2.0.0-beta.4` +- Upgraded to `notification@2.0.0-beta.5` +- Upgraded to `os@2.0.0-beta.4` +- Upgraded to `process@2.0.0-beta.4` +- Upgraded to `shell@2.0.0-beta.4` +- Upgraded to `updater@2.0.0-beta.5` + +## \[2.0.0-beta.6] + +### Dependencies + +- Upgraded to `notification@2.0.0-beta.4` +- Upgraded to `barcode-scanner@2.0.0-beta.4` +- Upgraded to `dialog@2.0.0-beta.6` +- Upgraded to `fs@2.0.0-beta.6` +- Upgraded to `http@2.0.0-beta.6` + +## \[2.0.0-beta.5] + +### Dependencies + +- Upgraded to `clipboard-manager@2.1.0-beta.1` +- Upgraded to `http@2.0.0-beta.5` +- Upgraded to `updater@2.0.0-beta.4` +- Upgraded to `dialog@2.0.0-beta.5` +- Upgraded to `fs@2.0.0-beta.5` + +## \[2.0.0-beta.4] + +### Dependencies + +- Upgraded to `dialog@2.0.0-beta.4` +- Upgraded to `fs@2.0.0-beta.4` +- Upgraded to `http@2.0.0-beta.4` + +## \[2.0.0-beta.3] + +### Dependencies + +- Upgraded to `clipboard-manager@2.1.0-beta.0` +- Upgraded to `dialog@2.0.0-beta.3` +- Upgraded to `fs@2.0.0-beta.3` +- Upgraded to `http@2.0.0-beta.3` +- Upgraded to `updater@2.0.0-beta.3` +- Upgraded to `barcode-scanner@2.0.0-beta.3` +- Upgraded to `biometric@2.0.0-beta.3` +- Upgraded to `cli@2.0.0-beta.3` +- Upgraded to `global-shortcut@2.0.0-beta.3` +- Upgraded to `log-plugin@2.0.0-beta.3` +- Upgraded to `nfc@2.0.0-beta.3` +- Upgraded to `notification@2.0.0-beta.3` +- Upgraded to `os@2.0.0-beta.3` +- Upgraded to `process@2.0.0-beta.3` +- Upgraded to `shell@2.0.0-beta.3` + +## \[2.0.0-beta.2] + +### Dependencies + +- Upgraded to `clipboard-manager@2.0.0-beta.2` +- Upgraded to `dialog@2.0.0-beta.2` +- Upgraded to `http@2.0.0-beta.2` +- Upgraded to `fs@2.0.0-beta.2` +- Upgraded to `shell@2.0.0-beta.2` +- Upgraded to `barcode-scanner@2.0.0-beta.2` +- Upgraded to `biometric@2.0.0-beta.2` +- Upgraded to `cli@2.0.0-beta.2` +- Upgraded to `global-shortcut@2.0.0-beta.2` +- Upgraded to `log-plugin@2.0.0-beta.2` +- Upgraded to `nfc@2.0.0-beta.2` +- Upgraded to `notification@2.0.0-beta.2` +- Upgraded to `os@2.0.0-beta.2` +- Upgraded to `process@2.0.0-beta.2` +- Upgraded to `updater@2.0.0-beta.2` + +## \[2.0.0-beta.1] + +### Dependencies + +- Upgraded to `barcode-scanner@2.0.0-beta.1` +- Upgraded to `biometric@2.0.0-beta.1` +- Upgraded to `cli@2.0.0-beta.1` +- Upgraded to `clipboard-manager@2.0.0-beta.1` +- Upgraded to `dialog@2.0.0-beta.1` +- Upgraded to `fs@2.0.0-beta.1` +- Upgraded to `global-shortcut@2.0.0-beta.1` +- Upgraded to `http@2.0.0-beta.1` +- Upgraded to `log-plugin@2.0.0-beta.1` +- Upgraded to `nfc@2.0.0-beta.1` +- Upgraded to `notification@2.0.0-beta.1` +- Upgraded to `os@2.0.0-beta.1` +- Upgraded to `process@2.0.0-beta.1` +- Upgraded to `shell@2.0.0-beta.1` +- Upgraded to `updater@2.0.0-beta.1` + +## \[2.0.0-beta.0] + +### Dependencies + +- Upgraded to `barcode-scanner@2.0.0-beta.0` +- Upgraded to `biometric@2.0.0-beta.0` +- Upgraded to `cli@2.0.0-beta.0` +- Upgraded to `clipboard-manager@2.0.0-beta.0` +- Upgraded to `dialog@2.0.0-beta.0` +- Upgraded to `fs@2.0.0-beta.0` +- Upgraded to `global-shortcut@2.0.0-beta.0` +- Upgraded to `http@2.0.0-beta.0` +- Upgraded to `log@2.0.0-beta.0` +- Upgraded to `nfc@2.0.0-beta.0` +- Upgraded to `notification@2.0.0-beta.0` +- Upgraded to `os@2.0.0-beta.0` +- Upgraded to `process@2.0.0-beta.0` +- Upgraded to `shell@2.0.0-beta.0` +- Upgraded to `updater@2.0.0-beta.0` + +## \[2.0.0-alpha.11] + +### Dependencies + +- Upgraded to `fs@2.0.0-alpha.7` +- Upgraded to `dialog@2.0.0-alpha.7` +- Upgraded to `http@2.0.0-alpha.9` + +## \[2.0.0-alpha.10] + +### Dependencies + +- Upgraded to `http@2.0.0-alpha.8` + +## \[2.0.0-alpha.9] + +### Dependencies + +- Upgraded to `barcode-scanner@2.0.0-alpha.4` +- Upgraded to `cli@2.0.0-alpha.6` +- Upgraded to `clipboard-manager@2.0.0-alpha.6` +- Upgraded to `dialog@2.0.0-alpha.6` +- Upgraded to `fs@2.0.0-alpha.6` +- Upgraded to `global-shortcut@2.0.0-alpha.6` +- Upgraded to `http@2.0.0-alpha.7` +- Upgraded to `log-plugin@2.0.0-alpha.6` +- Upgraded to `notification@2.0.0-alpha.7` +- Upgraded to `os@2.0.0-alpha.6` +- Upgraded to `process@2.0.0-alpha.6` +- Upgraded to `shell@2.0.0-alpha.6` +- Upgraded to `updater@2.0.0-alpha.6` +- Upgraded to `biometric@2.0.0-alpha.0` +- Upgraded to `nfc@2.0.0-alpha.0` + +## \[2.0.0-alpha.8] + +### Dependencies + +- Upgraded to `barcode-scanner@2.0.0-alpha.3` +- Upgraded to `cli@2.0.0-alpha.5` +- Upgraded to `clipboard-manager@2.0.0-alpha.5` +- Upgraded to `dialog@2.0.0-alpha.5` +- Upgraded to `fs@2.0.0-alpha.5` +- Upgraded to `global-shortcut@2.0.0-alpha.5` +- Upgraded to `http@2.0.0-alpha.6` +- Upgraded to `log-plugin@2.0.0-alpha.5` +- Upgraded to `notification@2.0.0-alpha.6` +- Upgraded to `os@2.0.0-alpha.5` +- Upgraded to `process@2.0.0-alpha.5` +- Upgraded to `shell@2.0.0-alpha.5` +- Upgraded to `updater@2.0.0-alpha.5` + +## \[2.0.0-alpha.7] + +### Dependencies + +- Upgraded to `barcode-scanner@2.0.0-alpha.2` +- Upgraded to `cli@2.0.0-alpha.4` +- Upgraded to `clipboard-manager@2.0.0-alpha.4` +- Upgraded to `dialog@2.0.0-alpha.4` +- Upgraded to `fs@2.0.0-alpha.4` +- Upgraded to `global-shortcut@2.0.0-alpha.4` +- Upgraded to `http@2.0.0-alpha.5` +- Upgraded to `log-plugin@2.0.0-alpha.4` +- Upgraded to `notification@2.0.0-alpha.5` +- Upgraded to `os@2.0.0-alpha.4` +- Upgraded to `process@2.0.0-alpha.4` +- Upgraded to `shell@2.0.0-alpha.4` +- Upgraded to `updater@2.0.0-alpha.4` + +## \[2.0.0-alpha.6] + +### Dependencies + +- Upgraded to `log-plugin@2.0.0-alpha.3` +- Upgraded to `shell@2.0.0-alpha.3` +- Upgraded to `dialog@2.0.0-alpha.3` +- Upgraded to `notification@2.0.0-alpha.4` +- Upgraded to `updater@2.0.0-alpha.3` +- Upgraded to `global-shortcut@2.0.0-alpha.3` +- Upgraded to `barcode-scanner@2.0.0-alpha.1` +- Upgraded to `cli@2.0.0-alpha.3` +- Upgraded to `clipboard-manager@2.0.0-alpha.3` +- Upgraded to `fs@2.0.0-alpha.3` +- Upgraded to `http@2.0.0-alpha.4` +- Upgraded to `os@2.0.0-alpha.3` +- Upgraded to `process@2.0.0-alpha.3` + ## \[2.0.0-alpha.5] ### Dependencies diff --git a/examples/api/src-tauri/Cargo.toml b/examples/api/src-tauri/Cargo.toml index 21741e79..e8e291fe 100644 --- a/examples/api/src-tauri/Cargo.toml +++ b/examples/api/src-tauri/Cargo.toml @@ -1,54 +1,69 @@ [package] name = "api" publish = false -version = "2.0.0-alpha.5" +version = "2.0.26" description = "An example Tauri Application showcasing the api" edition = "2021" rust-version = { workspace = true } license = "Apache-2.0 OR MIT" [lib] -crate-type = [ "staticlib", "cdylib", "rlib" ] +name = "api_lib" +crate-type = ["staticlib", "cdylib", "rlib"] [build-dependencies] -tauri-build = { workspace = true, features = [ "codegen", "isolation" ] } +tauri-build = { workspace = true, features = ["codegen", "isolation"] } [dependencies] serde_json = { workspace = true } serde = { workspace = true } -tiny_http = "0.11" +tiny_http = "0.12" +time = "0.3" log = { workspace = true } -tauri-plugin-log = { path = "../../../plugins/log", version = "2.0.0-alpha.2" } -tauri-plugin-fs = { path = "../../../plugins/fs", version = "2.0.0-alpha.2" } -tauri-plugin-clipboard-manager = { path = "../../../plugins/clipboard-manager", version = "2.0.0-alpha.2" } -tauri-plugin-dialog = { path = "../../../plugins/dialog", version = "2.0.0-alpha.2" } -tauri-plugin-http = { path = "../../../plugins/http", features = [ "multipart" ], version = "2.0.0-alpha.3" } -tauri-plugin-notification = { path = "../../../plugins/notification", version = "2.0.0-alpha.3", features = [ "windows7-compat" ] } -tauri-plugin-os = { path = "../../../plugins/os", version = "2.0.0-alpha.2" } -tauri-plugin-process = { path = "../../../plugins/process", version = "2.0.0-alpha.2" } -tauri-plugin-shell = { path = "../../../plugins/shell", version = "2.0.0-alpha.2" } +tauri-plugin-log = { path = "../../../plugins/log", version = "2.4.0" } +tauri-plugin-fs = { path = "../../../plugins/fs", version = "2.3.0", features = [ + "watch", +] } +tauri-plugin-clipboard-manager = { path = "../../../plugins/clipboard-manager", version = "2.2.2" } +tauri-plugin-dialog = { path = "../../../plugins/dialog", version = "2.2.2" } +tauri-plugin-http = { path = "../../../plugins/http", features = [ + "multipart", + "cookies", +], version = "2.4.4" } +tauri-plugin-notification = { path = "../../../plugins/notification", version = "2.2.2", features = [ + "windows7-compat", +] } +tauri-plugin-os = { path = "../../../plugins/os", version = "2.2.1" } +tauri-plugin-process = { path = "../../../plugins/process", version = "2.2.1" } +tauri-plugin-opener = { path = "../../../plugins/opener", version = "2.2.7" } +tauri-plugin-shell = { path = "../../../plugins/shell", version = "2.2.1" } +tauri-plugin-store = { path = "../../../plugins/store", version = "2.2.0" } - [dependencies.tauri] - workspace = true - features = [ - "icon-ico", - "icon-png", +[dependencies.tauri] +workspace = true +features = [ + "wry", + "compression", + "image-ico", + "image-png", "isolation", "macos-private-api", "tray-icon", - "protocol-asset" + "protocol-asset", ] [target."cfg(any(target_os = \"macos\", windows, target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies] -tauri-plugin-cli = { path = "../../../plugins/cli", version = "2.0.0-alpha.2" } -tauri-plugin-global-shortcut = { path = "../../../plugins/global-shortcut", version = "2.0.0-alpha.2" } -tauri-plugin-updater = { path = "../../../plugins/updater", version = "2.0.0-alpha.2" } +tauri-plugin-cli = { path = "../../../plugins/cli", version = "2.2.0" } +tauri-plugin-global-shortcut = { path = "../../../plugins/global-shortcut", version = "2.2.1" } +tauri-plugin-updater = { path = "../../../plugins/updater", version = "2.7.1" } +tauri-plugin-window-state = { path = "../../../plugins/window-state", version = "2.2.0" } [target."cfg(any(target_os = \"android\", target_os = \"ios\"))".dependencies] -tauri-plugin-barcode-scanner = { path = "../../../plugins/barcode-scanner/", version = "2.0.0-alpha.0" } - -[target."cfg(target_os = \"windows\")".dependencies] -window-shadows = "0.2" +tauri-plugin-barcode-scanner = { path = "../../../plugins/barcode-scanner/", version = "2.2.0" } +tauri-plugin-nfc = { path = "../../../plugins/nfc", version = "2.2.0" } +tauri-plugin-biometric = { path = "../../../plugins/biometric/", version = "2.2.1" } +tauri-plugin-geolocation = { path = "../../../plugins/geolocation/", version = "2.2.4" } +tauri-plugin-haptics = { path = "../../../plugins/haptics/", version = "2.2.4" } [features] -custom-protocol = [ "tauri/custom-protocol" ] +prod = ["tauri/custom-protocol"] diff --git a/examples/api/src-tauri/Info.plist b/examples/api/src-tauri/Info.plist index fe253ec7..4dcd6aca 100644 --- a/examples/api/src-tauri/Info.plist +++ b/examples/api/src-tauri/Info.plist @@ -1,10 +1,14 @@ - - NSCameraUsageDescription - Request camera access for WebRTC - NSMicrophoneUsageDescription - Request microphone access for WebRTC - + + NSCameraUsageDescription + Request camera access for WebRTC + NSMicrophoneUsageDescription + Request microphone access for WebRTC + NSFaceIDUsageDescription + Authenticate with biometrics + NFCReaderUsageDescription + Read and write to NFC tags for testing + diff --git a/examples/api/src-tauri/build.rs b/examples/api/src-tauri/build.rs index e9f99b29..88537dde 100644 --- a/examples/api/src-tauri/build.rs +++ b/examples/api/src-tauri/build.rs @@ -3,10 +3,5 @@ // SPDX-License-Identifier: MIT fn main() { - let mut codegen = tauri_build::CodegenContext::new(); - if !cfg!(feature = "custom-protocol") { - codegen = codegen.dev(); - } - codegen.build(); tauri_build::build(); } diff --git a/examples/api/src-tauri/capabilities/base.json b/examples/api/src-tauri/capabilities/base.json new file mode 100644 index 00000000..cefc4d8a --- /dev/null +++ b/examples/api/src-tauri/capabilities/base.json @@ -0,0 +1,91 @@ +{ + "$schema": "../gen/schemas/desktop-schema.json", + "identifier": "run-app-base", + "description": "Base permissions to run the app", + "windows": ["main"], + "permissions": [ + "log:default", + { + "identifier": "http:default", + "allow": [ + "https://tauri.app", + { + "url": "http://localhost:3003" + } + ] + }, + "core:default", + "fs:default", + "core:window:allow-minimize", + "core:window:allow-maximize", + "core:window:allow-unmaximize", + "core:window:allow-close", + "core:window:allow-start-dragging", + "notification:default", + "os:allow-platform", + "dialog:allow-open", + "dialog:allow-ask", + "dialog:allow-save", + "dialog:allow-confirm", + "dialog:allow-message", + { + "identifier": "shell:allow-spawn", + "allow": [ + { + "name": "sh", + "cmd": "sh", + "args": [ + "-c", + { + "validator": ".+" + } + ] + }, + { + "name": "cmd", + "cmd": "cmd", + "args": [ + "/C", + { + "validator": ".+" + } + ] + } + ] + }, + "shell:default", + "shell:allow-kill", + "shell:allow-stdin-write", + "process:allow-exit", + "process:allow-restart", + "clipboard-manager:allow-read-text", + "clipboard-manager:allow-write-text", + "clipboard-manager:allow-read-image", + "clipboard-manager:allow-write-image", + "fs:allow-open", + "fs:allow-write", + "fs:allow-read", + "fs:allow-rename", + "fs:allow-mkdir", + "fs:allow-remove", + "fs:allow-write-text-file", + "fs:read-meta", + "fs:scope-download-recursive", + "fs:scope-resource-recursive", + { + "identifier": "fs:scope-appdata-recursive", + "allow": [ + { + "path": "$APPDATA/db/**" + } + ], + "deny": ["$APPDATA/db/*.stronghold"] + }, + "store:default", + "opener:default", + { + "identifier": "opener:allow-open-path", + "allow": [{ "path": "$APPDATA" }, { "path": "$APPDATA/**" }] + } + ] +} diff --git a/examples/api/src-tauri/capabilities/desktop.json b/examples/api/src-tauri/capabilities/desktop.json new file mode 100644 index 00000000..82d8354f --- /dev/null +++ b/examples/api/src-tauri/capabilities/desktop.json @@ -0,0 +1,16 @@ +{ + "$schema": "../gen/schemas/desktop-schema.json", + "identifier": "run-app-desktop", + "description": "Permissions to run the app (desktop only)", + "windows": ["main"], + "platforms": ["linux", "macOS", "windows"], + "permissions": [ + "cli:default", + "updater:default", + "global-shortcut:allow-unregister", + "global-shortcut:allow-register", + "global-shortcut:allow-unregister-all", + { "identifier": "fs:allow-watch", "allow": ["*", "**/*"] }, + "fs:allow-unwatch" + ] +} diff --git a/examples/api/src-tauri/capabilities/mobile.json b/examples/api/src-tauri/capabilities/mobile.json new file mode 100644 index 00000000..da77f5e5 --- /dev/null +++ b/examples/api/src-tauri/capabilities/mobile.json @@ -0,0 +1,24 @@ +{ + "$schema": "../gen/schemas/mobile-schema.json", + "identifier": "run-app-mobile", + "description": "Permissions to run the app (mobile only)", + "windows": ["main"], + "platforms": ["android", "iOS"], + "permissions": [ + "nfc:allow-write", + "nfc:allow-scan", + "biometric:allow-authenticate", + "barcode-scanner:allow-scan", + "barcode-scanner:allow-cancel", + "barcode-scanner:allow-request-permissions", + "barcode-scanner:allow-check-permissions", + "geolocation:allow-check-permissions", + "geolocation:allow-request-permissions", + "geolocation:allow-watch-position", + "geolocation:allow-get-current-position", + "haptics:allow-impact-feedback", + "haptics:allow-notification-feedback", + "haptics:allow-selection-feedback", + "haptics:allow-vibrate" + ] +} diff --git a/examples/api/src-tauri/gen/android/.idea/compiler.xml b/examples/api/src-tauri/gen/android/.idea/compiler.xml new file mode 100644 index 00000000..b589d56e --- /dev/null +++ b/examples/api/src-tauri/gen/android/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/examples/api/src-tauri/gen/android/.idea/gradle.xml b/examples/api/src-tauri/gen/android/.idea/gradle.xml new file mode 100644 index 00000000..ff118549 --- /dev/null +++ b/examples/api/src-tauri/gen/android/.idea/gradle.xml @@ -0,0 +1,42 @@ + + + + + + + \ No newline at end of file diff --git a/examples/api/src-tauri/gen/android/.idea/kotlinc.xml b/examples/api/src-tauri/gen/android/.idea/kotlinc.xml new file mode 100644 index 00000000..4cb74572 --- /dev/null +++ b/examples/api/src-tauri/gen/android/.idea/kotlinc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/examples/api/src-tauri/gen/android/.idea/misc.xml b/examples/api/src-tauri/gen/android/.idea/misc.xml new file mode 100644 index 00000000..8978d23d --- /dev/null +++ b/examples/api/src-tauri/gen/android/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/examples/api/src-tauri/gen/android/.idea/vcs.xml b/examples/api/src-tauri/gen/android/.idea/vcs.xml new file mode 100644 index 00000000..bc599707 --- /dev/null +++ b/examples/api/src-tauri/gen/android/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/examples/api/src-tauri/gen/android/app/.gitignore b/examples/api/src-tauri/gen/android/app/.gitignore index ff9cb538..4008dd74 100644 --- a/examples/api/src-tauri/gen/android/app/.gitignore +++ b/examples/api/src-tauri/gen/android/app/.gitignore @@ -2,4 +2,5 @@ /src/main/jniLibs/**/*.so /src/main/assets/tauri.conf.json /tauri.build.gradle.kts -/proguard-tauri.pro \ No newline at end of file +/proguard-tauri.pro +/tauri.properties \ No newline at end of file diff --git a/examples/api/src-tauri/gen/android/app/build.gradle.kts b/examples/api/src-tauri/gen/android/app/build.gradle.kts index e3de36fd..f7047ca0 100644 --- a/examples/api/src-tauri/gen/android/app/build.gradle.kts +++ b/examples/api/src-tauri/gen/android/app/build.gradle.kts @@ -1,19 +1,28 @@ +import java.util.Properties + plugins { id("com.android.application") id("org.jetbrains.kotlin.android") id("rust") } +val tauriProperties = Properties().apply { + val propFile = file("tauri.properties") + if (propFile.exists()) { + propFile.inputStream().use { load(it) } + } +} + android { - compileSdk = 33 + compileSdk = 34 namespace = "com.tauri.api" defaultConfig { manifestPlaceholders["usesCleartextTraffic"] = "false" applicationId = "com.tauri.api" minSdk = 24 - targetSdk = 33 - versionCode = 1 - versionName = "1.0" + targetSdk = 34 + versionCode = tauriProperties.getProperty("tauri.android.versionCode", "1").toInt() + versionName = tauriProperties.getProperty("tauri.android.versionName", "1.0") } buildTypes { getByName("debug") { @@ -39,6 +48,9 @@ android { kotlinOptions { jvmTarget = "1.8" } + buildFeatures { + buildConfig = true + } } rust { @@ -54,4 +66,4 @@ dependencies { androidTestImplementation("androidx.test.espresso:espresso-core:3.5.0") } -apply(from = "tauri.build.gradle.kts") +apply(from = "tauri.build.gradle.kts") \ No newline at end of file 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 6ad2d210..8ebe7c4b 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,10 @@ + + + + + + + + + + + + + + + + + + + + + + + + NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@1x.png b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@1x.png index f8b128e3..a6ac2a8c 100644 Binary files a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@1x.png and b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@1x.png differ diff --git a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@2x-1.png b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@2x-1.png index 6bbd9e3c..2869541f 100644 Binary files a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@2x-1.png and b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@2x-1.png differ diff --git a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@2x.png b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@2x.png index 6bbd9e3c..2869541f 100644 Binary files a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@2x.png and b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@2x.png differ diff --git a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@3x.png b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@3x.png index f702cc04..cf265a45 100644 Binary files a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@3x.png and b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@3x.png differ diff --git a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@1x.png b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@1x.png index c5e92f78..29c9746c 100644 Binary files a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@1x.png and b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@1x.png differ diff --git a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@2x-1.png b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@2x-1.png index 1c607d5c..a4e68c8d 100644 Binary files a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@2x-1.png and b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@2x-1.png differ diff --git a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@2x.png b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@2x.png index 1c607d5c..a4e68c8d 100644 Binary files a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@2x.png and b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@2x.png differ diff --git a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@3x.png b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@3x.png index 60e93a6a..e4adcbce 100644 Binary files a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@3x.png and b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@3x.png differ diff --git a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@1x.png b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@1x.png index 6bbd9e3c..2869541f 100644 Binary files a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@1x.png and b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@1x.png differ diff --git a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@2x-1.png b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@2x-1.png index 819410f9..a414e65b 100644 Binary files a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@2x-1.png and b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@2x-1.png differ diff --git a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@2x.png b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@2x.png index 819410f9..a414e65b 100644 Binary files a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@2x.png and b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@2x.png differ diff --git a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@3x.png b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@3x.png index e00ae5a6..a0807e5d 100644 Binary files a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@3x.png and b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@3x.png differ diff --git a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png index f5301f37..704c9291 100644 Binary files a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png and b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png differ diff --git a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-512x512@2x.png b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-512x512@2x.png deleted file mode 100644 index 5e9add73..00000000 Binary files a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-512x512@2x.png and /dev/null differ diff --git a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-60x60@2x.png b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-60x60@2x.png index e00ae5a6..a0807e5d 100644 Binary files a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-60x60@2x.png and b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-60x60@2x.png differ diff --git a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-60x60@3x.png b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-60x60@3x.png index 3546ca10..2a9fbc26 100644 Binary files a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-60x60@3x.png and b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-60x60@3x.png differ diff --git a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-76x76@1x.png b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-76x76@1x.png index d8367101..2cdf1848 100644 Binary files a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-76x76@1x.png and b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-76x76@1x.png differ diff --git a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-76x76@2x.png b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-76x76@2x.png index 29925f2a..4723e4b4 100644 Binary files a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-76x76@2x.png and b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-76x76@2x.png differ diff --git a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-83.5x83.5@2x.png b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-83.5x83.5@2x.png index dfd22619..f26fee45 100644 Binary files a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-83.5x83.5@2x.png and b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-83.5x83.5@2x.png differ diff --git a/examples/api/src-tauri/gen/apple/ExportOptions.plist b/examples/api/src-tauri/gen/apple/ExportOptions.plist index b69cf1de..0428a171 100644 --- a/examples/api/src-tauri/gen/apple/ExportOptions.plist +++ b/examples/api/src-tauri/gen/apple/ExportOptions.plist @@ -3,6 +3,6 @@ method - development + debugging diff --git a/examples/api/src-tauri/gen/apple/LaunchScreen.storyboard b/examples/api/src-tauri/gen/apple/LaunchScreen.storyboard new file mode 100644 index 00000000..dd79351e --- /dev/null +++ b/examples/api/src-tauri/gen/apple/LaunchScreen.storyboard @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/api/src-tauri/gen/apple/api.xcodeproj/project.pbxproj b/examples/api/src-tauri/gen/apple/api.xcodeproj/project.pbxproj index 8528f099..64ef20a8 100644 --- a/examples/api/src-tauri/gen/apple/api.xcodeproj/project.pbxproj +++ b/examples/api/src-tauri/gen/apple/api.xcodeproj/project.pbxproj @@ -3,16 +3,17 @@ archiveVersion = 1; classes = { }; - objectVersion = 51; + objectVersion = 56; objects = { /* Begin PBXBuildFile section */ - 2ECFC1BC47D948875C8CEC41 /* libapi.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FC53D4128D7F74E4E6338455 /* libapi.a */; }; 3043432501C9BC2DB6B4CB95 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 71EB788DE4662CFC0D97F567 /* CoreGraphics.framework */; }; 328B4ADB3700C1873BEB7B10 /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = 90D3B673AFAB8D8AB561F616 /* main.mm */; }; 6F379F15DA085785BA2624D4 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6B7E79E23E646BA7968B457C /* Assets.xcassets */; }; + 832F9A55FEDEF3D807D8C40A /* libapp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 248286BAA086BB1A5F98B2B2 /* libapp.a */; }; 9AADB041D25772D04E543F15 /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 62601E25FA39E62BE119B74D /* Metal.framework */; }; 9DDA3BE70DD0E4013973FE38 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B6082E363D51372A7658C351 /* UIKit.framework */; }; + AC8BDC2C7A63FA3FDC5967F4 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4B2D1B108AE002010BDEC6D2 /* LaunchScreen.storyboard */; }; AFA0CA286325FD7A34968CA2 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 384966E551417F94A02D2706 /* Security.framework */; }; B60763BD194DFACA215EC7DA /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC377692DC31A070A0188C9D /* QuartzCore.framework */; }; C6D80743F168BDF017B7769E /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 59CFE20DCF760BE67D9CE3D6 /* WebKit.framework */; }; @@ -21,25 +22,26 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 0E96CE07CD20273DD46BF325 /* main.rs */ = {isa = PBXFileReference; path = main.rs; sourceTree = ""; }; - 1C1AB1B414CA2795AFBEDDB9 /* tray.rs */ = {isa = PBXFileReference; path = tray.rs; sourceTree = ""; }; + 0E96CE07CD20273DD46BF325 /* main.rs */ = {isa = PBXFileReference; lastKnownFileType = text; path = main.rs; sourceTree = ""; }; + 1C1AB1B414CA2795AFBEDDB9 /* tray.rs */ = {isa = PBXFileReference; lastKnownFileType = text; path = tray.rs; sourceTree = ""; }; + 248286BAA086BB1A5F98B2B2 /* libapp.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libapp.a; sourceTree = ""; }; 2F63E2AA460089BB58D40C79 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; 338E66700FD330B99D434DD7 /* MetalKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MetalKit.framework; path = System/Library/Frameworks/MetalKit.framework; sourceTree = SDKROOT; }; 384966E551417F94A02D2706 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; + 4B2D1B108AE002010BDEC6D2 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = ""; }; 59CFE20DCF760BE67D9CE3D6 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; }; - 5AC703CEBA41A121596066F3 /* api_iOS.app */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.application; path = api_iOS.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 5AC703CEBA41A121596066F3 /* Tauri API.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Tauri API.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 62601E25FA39E62BE119B74D /* Metal.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Metal.framework; path = System/Library/Frameworks/Metal.framework; sourceTree = SDKROOT; }; 6B7E79E23E646BA7968B457C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 71EB788DE4662CFC0D97F567 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 74A8FDFB350B966F5AAD4A24 /* assets */ = {isa = PBXFileReference; lastKnownFileType = folder; path = assets; sourceTree = SOURCE_ROOT; }; - 785D025E9542F7E098BF22B5 /* lib.rs */ = {isa = PBXFileReference; path = lib.rs; sourceTree = ""; }; + 785D025E9542F7E098BF22B5 /* lib.rs */ = {isa = PBXFileReference; lastKnownFileType = text; path = lib.rs; sourceTree = ""; }; 879941AE3DAA14534BBC6391 /* api_iOS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = api_iOS.entitlements; sourceTree = ""; }; 90D3B673AFAB8D8AB561F616 /* main.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = main.mm; sourceTree = ""; }; B6082E363D51372A7658C351 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; DC377692DC31A070A0188C9D /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; EC8C7948C50C3C9B5D96CB61 /* bindings.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = bindings.h; sourceTree = ""; }; - F835F52713CE8F029D5D252C /* cmd.rs */ = {isa = PBXFileReference; path = cmd.rs; sourceTree = ""; }; - FC53D4128D7F74E4E6338455 /* libapi.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libapi.a; sourceTree = ""; }; + F835F52713CE8F029D5D252C /* cmd.rs */ = {isa = PBXFileReference; lastKnownFileType = text; path = cmd.rs; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -47,7 +49,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 2ECFC1BC47D948875C8CEC41 /* libapi.a in Frameworks */, + 832F9A55FEDEF3D807D8C40A /* libapp.a in Frameworks */, 3043432501C9BC2DB6B4CB95 /* CoreGraphics.framework in Frameworks */, 9AADB041D25772D04E543F15 /* Metal.framework in Frameworks */, DFFF888045C8D9D9FB69E8FD /* MetalKit.framework in Frameworks */, @@ -66,6 +68,7 @@ children = ( 74A8FDFB350B966F5AAD4A24 /* assets */, 6B7E79E23E646BA7968B457C /* Assets.xcassets */, + 4B2D1B108AE002010BDEC6D2 /* LaunchScreen.storyboard */, F2116A6428EED18BE2A07E2B /* api_iOS */, 86D903732E10FAC4D300E8DF /* Externals */, 7A9A7AC155D9E22E54D6D847 /* Sources */, @@ -87,7 +90,7 @@ isa = PBXGroup; children = ( 71EB788DE4662CFC0D97F567 /* CoreGraphics.framework */, - FC53D4128D7F74E4E6338455 /* libapi.a */, + 248286BAA086BB1A5F98B2B2 /* libapp.a */, 62601E25FA39E62BE119B74D /* Metal.framework */, 338E66700FD330B99D434DD7 /* MetalKit.framework */, DC377692DC31A070A0188C9D /* QuartzCore.framework */, @@ -101,7 +104,7 @@ 4AC51E67B71E27F15B02C5CD /* Products */ = { isa = PBXGroup; children = ( - 5AC703CEBA41A121596066F3 /* api_iOS.app */, + 5AC703CEBA41A121596066F3 /* Tauri API.app */, ); name = Products; sourceTree = ""; @@ -169,7 +172,7 @@ ); name = api_iOS; productName = api_iOS; - productReference = 5AC703CEBA41A121596066F3 /* api_iOS.app */; + productReference = 5AC703CEBA41A121596066F3 /* Tauri API.app */; productType = "com.apple.product-type.application"; }; /* End PBXNativeTarget section */ @@ -178,7 +181,8 @@ 9BC88C3717DA5D4B78A51C15 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1200; + BuildIndependentTargetsInParallel = YES; + LastUpgradeCheck = 1430; TargetAttributes = { 54DC6E273C78071F3BA12EF3 = { DevelopmentTeam = Q93MBH6S2F; @@ -186,7 +190,7 @@ }; }; buildConfigurationList = 8FA67D0F928A09CD639137D1 /* Build configuration list for PBXProject "api" */; - compatibilityVersion = "Xcode 11.0"; + compatibilityVersion = "Xcode 14.0"; developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( @@ -208,6 +212,7 @@ buildActionMask = 2147483647; files = ( 6F379F15DA085785BA2624D4 /* Assets.xcassets in Resources */, + AC8BDC2C7A63FA3FDC5967F4 /* LaunchScreen.storyboard in Resources */, F86717F05E27C72C9FA1FB27 /* assets in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -229,12 +234,13 @@ outputFileListPaths = ( ); outputPaths = ( - "$(SRCROOT)/target/aarch64-apple-ios/${CONFIGURATION}/deps/libapi.a", - "$(SRCROOT)/target/x86_64-apple-ios/${CONFIGURATION}/deps/libapi.a", + "$(SRCROOT)/Externals/x86_64/${CONFIGURATION}/libapp.a", + "$(SRCROOT)/Externals/arm64/${CONFIGURATION}/libapp.a", + "$(SRCROOT)/Externals/arm64-sim/${CONFIGURATION}/libapp.a", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "node ../../../node_modules/.bin/../@tauri-apps/cli/tauri.js ios xcode-script -v --platform ${PLATFORM_DISPLAY_NAME:?} --sdk-root ${SDKROOT:?} --framework-search-paths \"${FRAMEWORK_SEARCH_PATHS:?}\" --header-search-paths \"${HEADER_SEARCH_PATHS:?}\" --gcc-preprocessor-definitions \"${GCC_PREPROCESSOR_DEFINITIONS:-}\" --configuration ${CONFIGURATION:?} ${FORCE_COLOR} ${ARCHS:?}"; + shellScript = "pnpm tauri ios xcode-script -v --platform ${PLATFORM_DISPLAY_NAME:?} --sdk-root ${SDKROOT:?} --framework-search-paths \"${FRAMEWORK_SEARCH_PATHS:?}\" --header-search-paths \"${HEADER_SEARCH_PATHS:?}\" --gcc-preprocessor-definitions \"${GCC_PREPROCESSOR_DEFINITIONS:-}\" --configuration ${CONFIGURATION:?} ${FORCE_COLOR} ${ARCHS:?}"; }; /* End PBXShellScriptBuildPhase section */ @@ -380,20 +386,42 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = api_iOS/api_iOS.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = Q93MBH6S2F; ENABLE_BITCODE = NO; + "EXCLUDED_ARCHS[sdk=iphoneos*]" = "arm64-sim x86_64"; + "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\".\"", ); INFOPLIST_FILE = api_iOS/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - "LIBRARY_SEARCH_PATHS[arch=arm64-sim]" = "$(inherited) $(PROJECT_DIR)/Externals/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)"; - "LIBRARY_SEARCH_PATHS[arch=arm64]" = "$(inherited) $(PROJECT_DIR)/Externals/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)"; - "LIBRARY_SEARCH_PATHS[arch=x86_64]" = "$(inherited) $(PROJECT_DIR)/Externals/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)"; + "LIBRARY_SEARCH_PATHS[arch=arm64-sim]" = ( + "$(inherited)", + "$(PROJECT_DIR)/Externals/arm64-sim/$(CONFIGURATION)", + "$(SDKROOT)/usr/lib/swift", + "$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)", + "$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)", + ); + "LIBRARY_SEARCH_PATHS[arch=arm64]" = ( + "$(inherited)", + "$(PROJECT_DIR)/Externals/arm64/$(CONFIGURATION)", + "$(SDKROOT)/usr/lib/swift", + "$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)", + "$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)", + ); + "LIBRARY_SEARCH_PATHS[arch=x86_64]" = ( + "$(inherited)", + "$(PROJECT_DIR)/Externals/x86_64/$(CONFIGURATION)", + "$(SDKROOT)/usr/lib/swift", + "$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)", + "$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)", + ); PRODUCT_BUNDLE_IDENTIFIER = com.tauri.api; PRODUCT_NAME = "Tauri API"; SDKROOT = iphoneos; @@ -413,20 +441,42 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = api_iOS/api_iOS.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = Q93MBH6S2F; ENABLE_BITCODE = NO; + "EXCLUDED_ARCHS[sdk=iphoneos*]" = "arm64-sim x86_64"; + "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\".\"", ); INFOPLIST_FILE = api_iOS/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - "LIBRARY_SEARCH_PATHS[arch=arm64-sim]" = "$(inherited) $(PROJECT_DIR)/Externals/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)"; - "LIBRARY_SEARCH_PATHS[arch=arm64]" = "$(inherited) $(PROJECT_DIR)/Externals/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)"; - "LIBRARY_SEARCH_PATHS[arch=x86_64]" = "$(inherited) $(PROJECT_DIR)/Externals/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)"; + "LIBRARY_SEARCH_PATHS[arch=arm64-sim]" = ( + "$(inherited)", + "$(PROJECT_DIR)/Externals/arm64-sim/$(CONFIGURATION)", + "$(SDKROOT)/usr/lib/swift", + "$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)", + "$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)", + ); + "LIBRARY_SEARCH_PATHS[arch=arm64]" = ( + "$(inherited)", + "$(PROJECT_DIR)/Externals/arm64/$(CONFIGURATION)", + "$(SDKROOT)/usr/lib/swift", + "$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)", + "$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)", + ); + "LIBRARY_SEARCH_PATHS[arch=x86_64]" = ( + "$(inherited)", + "$(PROJECT_DIR)/Externals/x86_64/$(CONFIGURATION)", + "$(SDKROOT)/usr/lib/swift", + "$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)", + "$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)", + ); PRODUCT_BUNDLE_IDENTIFIER = com.tauri.api; PRODUCT_NAME = "Tauri API"; SDKROOT = iphoneos; diff --git a/examples/api/src-tauri/gen/apple/api.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/examples/api/src-tauri/gen/apple/api.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/examples/api/src-tauri/gen/apple/api.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/examples/api/src-tauri/gen/apple/api.xcodeproj/xcshareddata/xcschemes/api_iOS.xcscheme b/examples/api/src-tauri/gen/apple/api.xcodeproj/xcshareddata/xcschemes/api_iOS.xcscheme index 3680d405..2a9f5045 100644 --- a/examples/api/src-tauri/gen/apple/api.xcodeproj/xcshareddata/xcschemes/api_iOS.xcscheme +++ b/examples/api/src-tauri/gen/apple/api.xcodeproj/xcshareddata/xcschemes/api_iOS.xcscheme @@ -1,11 +1,10 @@ + LastUpgradeVersion = "1430" + version = "1.3"> + buildImplicitDependencies = "YES"> @@ -27,21 +26,16 @@ buildConfiguration = "debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - shouldUseLaunchSchemeArgsEnv = "NO" - onlyGenerateCoverageForSpecifiedTargets = "NO"> + shouldUseLaunchSchemeArgsEnv = "NO"> - - - - + + - - - - UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + NSFaceIDUsageDescription + Authenticate with biometrics + NSCameraUsageDescription + Request camera access for WebRTC + NSMicrophoneUsageDescription + Request microphone access for WebRTC + NFCReaderUsageDescription + Read and write to NFC tags for testing - + \ No newline at end of file diff --git a/examples/api/src-tauri/gen/apple/api_iOS/api_iOS.entitlements b/examples/api/src-tauri/gen/apple/api_iOS/api_iOS.entitlements index 0c67376e..2bb4dee1 100644 --- a/examples/api/src-tauri/gen/apple/api_iOS/api_iOS.entitlements +++ b/examples/api/src-tauri/gen/apple/api_iOS/api_iOS.entitlements @@ -1,5 +1,10 @@ - + + com.apple.developer.nfc.readersession.formats + + TAG + + diff --git a/examples/api/src-tauri/gen/apple/project.yml b/examples/api/src-tauri/gen/apple/project.yml index 1be5cc64..9705de23 100644 --- a/examples/api/src-tauri/gen/apple/project.yml +++ b/examples/api/src-tauri/gen/apple/project.yml @@ -1,8 +1,8 @@ name: api options: - bundleIdPrefix: com.tauri + bundleIdPrefix: com.tauri.api deploymentTarget: - iOS: 13.0 + iOS: 14.0 fileGroups: [../../src] configs: debug: debug @@ -36,6 +36,7 @@ targets: - path: assets buildPhase: resources type: folder + - path: LaunchScreen.storyboard info: path: api_iOS/Info.plist properties: @@ -63,14 +64,16 @@ targets: base: ENABLE_BITCODE: false ARCHS: [arm64, arm64-sim] - VALID_ARCHS: arm64 arm64-sim - LIBRARY_SEARCH_PATHS[arch=x86_64]: $(inherited) $(PROJECT_DIR)/Externals/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME) - LIBRARY_SEARCH_PATHS[arch=arm64]: $(inherited) $(PROJECT_DIR)/Externals/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME) - LIBRARY_SEARCH_PATHS[arch=arm64-sim]: $(inherited) $(PROJECT_DIR)/Externals/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME) + VALID_ARCHS: arm64 arm64-sim + LIBRARY_SEARCH_PATHS[arch=x86_64]: $(inherited) $(PROJECT_DIR)/Externals/x86_64/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME) + LIBRARY_SEARCH_PATHS[arch=arm64]: $(inherited) $(PROJECT_DIR)/Externals/arm64/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME) + LIBRARY_SEARCH_PATHS[arch=arm64-sim]: $(inherited) $(PROJECT_DIR)/Externals/arm64-sim/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME) ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES: true + EXCLUDED_ARCHS[sdk=iphonesimulator*]: arm64 + EXCLUDED_ARCHS[sdk=iphoneos*]: arm64-sim x86_64 groups: [app] dependencies: - - framework: libapi.a + - framework: libapp.a embed: false - sdk: CoreGraphics.framework - sdk: Metal.framework @@ -80,9 +83,10 @@ targets: - sdk: UIKit.framework - sdk: WebKit.framework preBuildScripts: - - script: node ../../../node_modules/.bin/../@tauri-apps/cli/tauri.js ios xcode-script -v --platform ${PLATFORM_DISPLAY_NAME:?} --sdk-root ${SDKROOT:?} --framework-search-paths "${FRAMEWORK_SEARCH_PATHS:?}" --header-search-paths "${HEADER_SEARCH_PATHS:?}" --gcc-preprocessor-definitions "${GCC_PREPROCESSOR_DEFINITIONS:-}" --configuration ${CONFIGURATION:?} ${FORCE_COLOR} ${ARCHS:?} + - script: pnpm tauri ios xcode-script -v --platform ${PLATFORM_DISPLAY_NAME:?} --sdk-root ${SDKROOT:?} --framework-search-paths "${FRAMEWORK_SEARCH_PATHS:?}" --header-search-paths "${HEADER_SEARCH_PATHS:?}" --gcc-preprocessor-definitions "${GCC_PREPROCESSOR_DEFINITIONS:-}" --configuration ${CONFIGURATION:?} ${FORCE_COLOR} ${ARCHS:?} name: Build Rust Code basedOnDependencyAnalysis: false outputFiles: - - $(SRCROOT)/target/aarch64-apple-ios/${CONFIGURATION}/deps/libapi.a - - $(SRCROOT)/target/x86_64-apple-ios/${CONFIGURATION}/deps/libapi.a \ No newline at end of file + - $(SRCROOT)/Externals/x86_64/${CONFIGURATION}/libapp.a + - $(SRCROOT)/Externals/arm64/${CONFIGURATION}/libapp.a + - $(SRCROOT)/Externals/arm64-sim/${CONFIGURATION}/libapp.a diff --git a/examples/api/src-tauri/src/lib.rs b/examples/api/src-tauri/src/lib.rs index f9d34567..a19992b0 100644 --- a/examples/api/src-tauri/src/lib.rs +++ b/examples/api/src-tauri/src/lib.rs @@ -2,17 +2,15 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -#![cfg_attr( - all(not(debug_assertions), target_os = "windows"), - windows_subsystem = "windows" -)] - mod cmd; #[cfg(desktop)] mod tray; use serde::Serialize; -use tauri::{window::WindowBuilder, App, AppHandle, RunEvent, WindowUrl}; +use tauri::{ + webview::{PageLoadEvent, WebviewWindowBuilder}, + App, AppHandle, Emitter, Listener, RunEvent, WebviewUrl, +}; #[derive(Clone, Serialize)] struct Reply { @@ -38,7 +36,9 @@ pub fn run() { .plugin(tauri_plugin_notification::init()) .plugin(tauri_plugin_os::init()) .plugin(tauri_plugin_process::init()) + .plugin(tauri_plugin_opener::init()) .plugin(tauri_plugin_shell::init()) + .plugin(tauri_plugin_store::Builder::default().build()) .setup(move |app| { #[cfg(desktop)] { @@ -46,28 +46,35 @@ pub fn run() { app.handle().plugin(tauri_plugin_cli::init())?; app.handle() .plugin(tauri_plugin_global_shortcut::Builder::new().build())?; + app.handle() + .plugin(tauri_plugin_window_state::Builder::new().build())?; app.handle() .plugin(tauri_plugin_updater::Builder::new().build())?; } #[cfg(mobile)] { app.handle().plugin(tauri_plugin_barcode_scanner::init())?; + app.handle().plugin(tauri_plugin_nfc::init())?; + app.handle().plugin(tauri_plugin_biometric::init())?; + app.handle().plugin(tauri_plugin_geolocation::init())?; + app.handle().plugin(tauri_plugin_haptics::init())?; } - let mut window_builder = WindowBuilder::new(app, "main", WindowUrl::default()); + let mut webview_window_builder = + WebviewWindowBuilder::new(app, "main", WebviewUrl::default()); #[cfg(desktop)] { - window_builder = window_builder + webview_window_builder = webview_window_builder .user_agent(&format!("Tauri API - {}", std::env::consts::OS)) .title("Tauri API Validation") .inner_size(1000., 800.) .min_inner_size(600., 400.) - .content_protected(true); + .visible(false); } #[cfg(target_os = "windows")] { - window_builder = window_builder + webview_window_builder = webview_window_builder .transparent(true) .shadow(true) .decorations(false); @@ -75,15 +82,14 @@ pub fn run() { #[cfg(target_os = "macos")] { - window_builder = window_builder.transparent(true); + webview_window_builder = webview_window_builder.transparent(true); } - let window = window_builder.build().unwrap(); + let webview = webview_window_builder.build().unwrap(); #[cfg(debug_assertions)] - window.open_devtools(); + webview.open_devtools(); - #[cfg(desktop)] std::thread::spawn(|| { let server = match tiny_http::Server::http("localhost:3003") { Ok(s) => s, @@ -96,9 +102,28 @@ pub fn run() { if let Ok(mut request) = server.recv() { let mut body = Vec::new(); let _ = request.as_reader().read_to_end(&mut body); + let mut headers = request.headers().to_vec(); + + if !headers.iter().any(|header| header.field == tiny_http::HeaderField::from_bytes(b"Cookie").unwrap()) { + let expires = time::OffsetDateTime::now_utc() + time::Duration::days(1); + // RFC 1123 format + let format = time::macros::format_description!( + "[weekday repr:short], [day] [month repr:short] [year] [hour]:[minute]:[second] GMT" + ); + let expires_str = expires.format(format).unwrap(); + headers.push( + tiny_http::Header::from_bytes( + &b"Set-Cookie"[..], + format!("session-token=test-value; Secure; Path=/; Expires={expires_str}") + .as_bytes(), + ) + .unwrap(), + ); + } + let response = tiny_http::Response::new( tiny_http::StatusCode(200), - request.headers().to_vec(), + headers, std::io::Cursor::new(body), request.body_length(), None, @@ -110,18 +135,20 @@ pub fn run() { Ok(()) }) - .on_page_load(|window, _| { - let window_ = window.clone(); - window.listen("js-event", move |event| { - println!("got js-event with message '{:?}'", event.payload()); - let reply = Reply { - data: "something else".to_string(), - }; - - window_ - .emit("rust-event", Some(reply)) - .expect("failed to emit"); - }); + .on_page_load(|webview, payload| { + if payload.event() == PageLoadEvent::Finished { + let webview_ = webview.clone(); + webview.listen("js-event", move |event| { + println!("got js-event with message '{:?}'", event.payload()); + let reply = Reply { + data: "something else".to_string(), + }; + + webview_ + .emit("rust-event", Some(reply)) + .expect("failed to emit"); + }); + } }); #[cfg(target_os = "macos")] @@ -135,7 +162,7 @@ pub fn run() { cmd::log_operation, cmd::perform_request, ]) - .build(tauri::tauri_build_context!()) + .build(tauri::generate_context!()) .expect("error while building tauri application"); #[cfg(target_os = "macos")] @@ -143,10 +170,12 @@ pub fn run() { app.run(move |_app_handle, _event| { #[cfg(desktop)] - if let RunEvent::ExitRequested { api, .. } = &_event { - // Keep the event loop running even if all windows are closed - // This allow us to catch system tray events when there is no window - api.prevent_exit(); + if let RunEvent::ExitRequested { code, api, .. } = &_event { + if code.is_none() { + // Keep the event loop running even if all windows are closed + // This allow us to catch system tray events when there is no window + api.prevent_exit(); + } } }) } diff --git a/examples/api/src-tauri/src/main.rs b/examples/api/src-tauri/src/main.rs index 2eb029af..bbed006b 100644 --- a/examples/api/src-tauri/src/main.rs +++ b/examples/api/src-tauri/src/main.rs @@ -6,6 +6,5 @@ #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] fn main() { - #[cfg(desktop)] - api::run(); + api_lib::run(); } diff --git a/examples/api/src-tauri/src/tray.rs b/examples/api/src-tauri/src/tray.rs index 9028057d..7b1321a5 100644 --- a/examples/api/src-tauri/src/tray.rs +++ b/examples/api/src-tauri/src/tray.rs @@ -5,20 +5,21 @@ use std::sync::atomic::{AtomicBool, Ordering}; use tauri::{ menu::{Menu, MenuItem}, - tray::{ClickType, TrayIconBuilder}, - Manager, Runtime, WindowBuilder, WindowUrl, + tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent}, + Manager, Runtime, WebviewUrl, WebviewWindowBuilder, }; pub fn create_tray(app: &tauri::AppHandle) -> tauri::Result<()> { - let toggle_i = MenuItem::with_id(app, "toggle", "Toggle", true, None); - let new_window_i = MenuItem::with_id(app, "new-window", "New window", true, None); - let icon_i_1 = MenuItem::with_id(app, "icon-1", "Icon 1", true, None); - let icon_i_2 = MenuItem::with_id(app, "icon-2", "Icon 2", true, None); + let toggle_i = MenuItem::with_id(app, "toggle", "Toggle", true, None::<&str>)?; + let new_window_i = MenuItem::with_id(app, "new-window", "New window", true, None::<&str>)?; + let icon_i_1 = MenuItem::with_id(app, "icon-1", "Icon 1", true, None::<&str>)?; + let icon_i_2 = MenuItem::with_id(app, "icon-2", "Icon 2", true, None::<&str>)?; #[cfg(target_os = "macos")] - let set_title_i = MenuItem::with_id(app, "set-title", "Set Title", true, None); - let switch_i = MenuItem::with_id(app, "switch-menu", "Switch Menu", true, None); - let quit_i = MenuItem::with_id(app, "quit", "Quit", true, None); - let remove_tray_i = MenuItem::with_id(app, "remove-tray", "Remove Tray icon", true, None); + let set_title_i = MenuItem::with_id(app, "set-title", "Set Title", true, None::<&str>)?; + let switch_i = MenuItem::with_id(app, "switch-menu", "Switch Menu", true, None::<&str>)?; + let quit_i = MenuItem::with_id(app, "quit", "Quit", true, None::<&str>)?; + let remove_tray_i = + MenuItem::with_id(app, "remove-tray", "Remove Tray icon", true, None::<&str>)?; let menu1 = Menu::with_items( app, &[ @@ -44,7 +45,7 @@ pub fn create_tray(app: &tauri::AppHandle) -> tauri::Result<()> { .tooltip("Tauri") .icon(app.default_window_icon().unwrap().clone()) .menu(&menu1) - .menu_on_left_click(false) + .show_menu_on_left_click(false) .on_menu_event(move |app, event| match event.id.as_ref() { "quit" => { app.exit(0); @@ -53,7 +54,7 @@ pub fn create_tray(app: &tauri::AppHandle) -> tauri::Result<()> { app.remove_tray_by_id("tray-1"); } "toggle" => { - if let Some(window) = app.get_window("main") { + if let Some(window) = app.get_webview_window("main") { let new_title = if window.is_visible().unwrap_or_default() { let _ = window.hide(); "Show" @@ -66,7 +67,7 @@ pub fn create_tray(app: &tauri::AppHandle) -> tauri::Result<()> { } } "new-window" => { - let _ = WindowBuilder::new(app, "new", WindowUrl::App("index.html".into())) + let _ = WebviewWindowBuilder::new(app, "new", WebviewUrl::App("index.html".into())) .title("Tauri") .build(); } @@ -78,11 +79,15 @@ pub fn create_tray(app: &tauri::AppHandle) -> tauri::Result<()> { } i @ "icon-1" | i @ "icon-2" => { if let Some(tray) = app.tray_by_id("tray-1") { - let _ = tray.set_icon(Some(tauri::Icon::Raw(if i == "icon-1" { - include_bytes!("../icons/icon.ico").to_vec() + let _ = tray.set_icon(Some(if i == "icon-1" { + tauri::image::Image::from_bytes(include_bytes!("../icons/icon.ico")) + .unwrap() } else { - include_bytes!("../icons/tray_icon_with_transparency.png").to_vec() - }))); + tauri::image::Image::from_bytes(include_bytes!( + "../icons/tray_icon_with_transparency.png" + )) + .unwrap() + })); } } "switch-menu" => { @@ -102,9 +107,14 @@ pub fn create_tray(app: &tauri::AppHandle) -> tauri::Result<()> { _ => {} }) .on_tray_icon_event(|tray, event| { - if event.click_type == ClickType::Left { + if let TrayIconEvent::Click { + button_state: MouseButtonState::Down, + button: MouseButton::Left, + .. + } = event + { let app = tray.app_handle(); - if let Some(window) = app.get_window("main") { + if let Some(window) = app.get_webview_window("main") { let _ = window.show(); let _ = window.set_focus(); } diff --git a/examples/api/src-tauri/tauri.conf.json b/examples/api/src-tauri/tauri.conf.json index 02fd5c3b..00b095be 100644 --- a/examples/api/src-tauri/tauri.conf.json +++ b/examples/api/src-tauri/tauri.conf.json @@ -1,15 +1,40 @@ { - "$schema": "../node_modules/@tauri-apps/cli/schema.json", + "$schema": "../node_modules/@tauri-apps/cli/config.schema.json", + "productName": "Tauri API", + "version": "2.0.0", + "identifier": "com.tauri.api", "build": { - "distDir": "../dist", - "devPath": "http://localhost:5173", - "beforeDevCommand": "yarn dev", - "beforeBuildCommand": "yarn build", - "withGlobalTauri": true + "devUrl": "http://localhost:5173", + "frontendDist": "../dist", + "beforeDevCommand": "pnpm dev", + "beforeBuildCommand": "pnpm build" }, - "package": { - "productName": "Tauri API", - "version": "2.0.0" + "app": { + "withGlobalTauri": true, + "macOSPrivateApi": true, + "security": { + "pattern": { + "use": "isolation", + "options": { + "dir": "../isolation-dist/" + } + }, + "csp": { + "default-src": "'self' customprotocol: asset:", + "connect-src": "ipc: http://ipc.localhost", + "font-src": ["https://fonts.gstatic.com"], + "img-src": "'self' asset: http://asset.localhost blob: data:", + "style-src": "'unsafe-inline' 'self' http://fonts.googleapis.com" + }, + "freezePrototype": true, + "assetProtocol": { + "enable": true, + "scope": { + "allow": ["$APPDATA/db/**", "$RESOURCE/**"], + "deny": ["$APPDATA/db/*.stronghold"] + } + } + } }, "plugins": { "cli": { @@ -47,96 +72,37 @@ } } }, - "fs": { - "scope": { - "allow": ["$APPDATA/db/**", "$DOWNLOAD/**", "$RESOURCE/**"], - "deny": ["$APPDATA/db/*.stronghold"] - } - }, "shell": { - "open": true, - "scope": [ - { - "name": "sh", - "cmd": "sh", - "args": [ - "-c", - { - "validator": "\\S+" - } - ] - }, - { - "name": "cmd", - "cmd": "cmd", - "args": [ - "/C", - { - "validator": "\\S+" - } - ] - } - ] - }, - "http": { - "scope": ["http://localhost:3003"] + "open": true }, "updater": { + "pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDE5QzMxNjYwNTM5OEUwNTgKUldSWTRKaFRZQmJER1h4d1ZMYVA3dnluSjdpN2RmMldJR09hUFFlZDY0SlFqckkvRUJhZDJVZXAK", "endpoints": [ "https://tauri-update-server.vercel.app/update/{{target}}/{{current_version}}" ] } }, - "tauri": { - "pattern": { - "use": "isolation", - "options": { - "dir": "../isolation-dist/" - } - }, - "macOSPrivateApi": true, - "bundle": { - "active": true, - "identifier": "com.tauri.api", - "icon": [ - "icons/32x32.png", - "icons/128x128.png", - "icons/128x128@2x.png", - "icons/icon.icns", - "icons/icon.ico" - ], - "windows": { - "wix": { - "language": { - "en-US": {}, - "pt-BR": { - "localePath": "locales/pt-BR.wxl" - } + "bundle": { + "active": true, + "icon": [ + "icons/32x32.png", + "icons/128x128.png", + "icons/128x128@2x.png", + "icons/icon.icns", + "icons/icon.ico" + ], + "windows": { + "wix": { + "language": { + "en-US": {}, + "pt-BR": { + "localePath": "locales/pt-BR.wxl" } } - }, - "updater": { - "active": true, - "pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDE5QzMxNjYwNTM5OEUwNTgKUldSWTRKaFRZQmJER1h4d1ZMYVA3dnluSjdpN2RmMldJR09hUFFlZDY0SlFqckkvRUJhZDJVZXAK" } }, - "windows": [], - "security": { - "csp": { - "default-src": "'self' customprotocol: asset:", - "connect-src": "ipc: http://ipc.localhost", - "font-src": ["https://fonts.gstatic.com"], - "img-src": "'self' asset: http://asset.localhost blob: data:", - "style-src": "'unsafe-inline' 'self' http://fonts.googleapis.com" - }, - "freezePrototype": true, - "assetProtocol": { - "enable": true, - "scope": { - "allow": ["$APPDATA/db/**", "$RESOURCE/**"], - "deny": ["$APPDATA/db/*.stronghold"] - } - } + "iOS": { + "minimumSystemVersion": "14.0" } } } diff --git a/examples/api/src/App.svelte b/examples/api/src/App.svelte index 6c24851e..9396f6f9 100644 --- a/examples/api/src/App.svelte +++ b/examples/api/src/App.svelte @@ -1,295 +1,333 @@ @@ -307,42 +345,46 @@ children:h-100% children:w-12 children:inline-flex children:items-center children:justify-center" > - {#if isDark} -
+
{:else} -
+
{/if} - - + +
{/if} @@ -350,13 +392,13 @@ @@ -368,24 +410,21 @@ class="lt-sm:h-screen lt-sm:shadow-lg lt-sm:shadow lt-sm:transition-transform lt-sm:absolute lt-sm:z-1999 bg-darkPrimaryLighter transition-colors-250 overflow-hidden grid select-none px-2" > - open("https://tauri.app/")} - class="self-center p-7 cursor-pointer" - src="tauri_logo.png" - alt="Tauri logo" - /> + + Tauri logo + {#if !isWindows} {#if isDark} Switch to Light mode -
+
{:else} Switch to Dark mode -
+
{/if}

-
+

{/if} @@ -395,7 +434,7 @@ href="https://tauri.app/v1/guides/" > Documentation - + GitHub - + Source - +
-
+

{ - select(view); - isSideBarOpen = false; + select(view) + isSideBarOpen = false }} > -
+

{view.label}

{/if} @@ -458,23 +497,28 @@ id="console" class="select-none h-15rem grid grid-rows-[2px_2rem_1fr] gap-1 overflow-hidden" > +
+ >

Console

-
-
-
+
+
-
+
{#each $messages as r} {@html r.html} {/each} diff --git a/examples/api/src/app.css b/examples/api/src/app.css index 6987e423..6e8ae62d 100644 --- a/examples/api/src/app.css +++ b/examples/api/src/app.css @@ -5,7 +5,7 @@ * { box-sizing: border-box; - font-family: "Rubik", sans-serif; + font-family: 'Rubik', sans-serif; } ::-webkit-scrollbar { diff --git a/examples/api/src/lib/utils.js b/examples/api/src/lib/utils.js new file mode 100644 index 00000000..a5ddc058 --- /dev/null +++ b/examples/api/src/lib/utils.js @@ -0,0 +1,15 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +export function arrayBufferToBase64(buffer, callback) { + const blob = new Blob([buffer], { + type: 'application/octet-binary' + }) + const reader = new FileReader() + reader.onload = function (evt) { + const dataurl = evt.target.result + callback(dataurl.substr(dataurl.indexOf(',') + 1)) + } + reader.readAsDataURL(blob) +} diff --git a/examples/api/src/main.js b/examples/api/src/main.js index f9785b74..5b7473f6 100644 --- a/examples/api/src/main.js +++ b/examples/api/src/main.js @@ -2,12 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import "uno.css"; -import "./app.css"; -import App from "./App.svelte"; +import 'uno.css' +import './app.css' +import App from './App.svelte' +import { mount } from 'svelte' -const app = new App({ - target: document.querySelector("#app"), -}); +const app = mount(App, { + target: document.querySelector('#app') +}) -export default app; +export default app diff --git a/examples/api/src/views/Biometric.svelte b/examples/api/src/views/Biometric.svelte new file mode 100644 index 00000000..3f287b0d --- /dev/null +++ b/examples/api/src/views/Biometric.svelte @@ -0,0 +1,30 @@ + + +
+ + +
+ diff --git a/examples/api/src/views/Cli.svelte b/examples/api/src/views/Cli.svelte index 53c3ee36..06f38e02 100644 --- a/examples/api/src/views/Cli.svelte +++ b/examples/api/src/views/Cli.svelte @@ -1,14 +1,14 @@ -

+

This binary can be run from the terminal and takes the following arguments:
@@ -17,7 +17,7 @@
   --verbose
Additionally, it has a update --background subcommand. -

+

Note that the arguments are only parsed, not implemented. diff --git a/examples/api/src/views/Clipboard.svelte b/examples/api/src/views/Clipboard.svelte index f571b2ee..f16a7d71 100644 --- a/examples/api/src/views/Clipboard.svelte +++ b/examples/api/src/views/Clipboard.svelte @@ -1,23 +1,59 @@ @@ -27,6 +63,7 @@ placeholder="Text to write to the clipboard" bind:value={text} /> - + +
diff --git a/examples/api/src/views/Communication.svelte b/examples/api/src/views/Communication.svelte index d795a114..f34dcd3e 100644 --- a/examples/api/src/views/Communication.svelte +++ b/examples/api/src/views/Communication.svelte @@ -1,15 +1,15 @@ diff --git a/examples/api/src/views/Dialog.svelte b/examples/api/src/views/Dialog.svelte index 46f91a56..462eecff 100644 --- a/examples/api/src/views/Dialog.svelte +++ b/examples/api/src/views/Dialog.svelte @@ -1,6 +1,6 @@ -
+

- + + + + +
+ + +
- + {#if file} +
+ + +
+ {/if} + +

Watch

+ + +
+
+ + +
+
+
+ + +
+
+
+ + +
+

diff --git a/examples/api/src/views/Geolocation.svelte b/examples/api/src/views/Geolocation.svelte new file mode 100644 index 00000000..cd181dfb --- /dev/null +++ b/examples/api/src/views/Geolocation.svelte @@ -0,0 +1,29 @@ + + + diff --git a/examples/api/src/views/Haptics.svelte b/examples/api/src/views/Haptics.svelte new file mode 100644 index 00000000..9ddf15c1 --- /dev/null +++ b/examples/api/src/views/Haptics.svelte @@ -0,0 +1,46 @@ + + +
+ + + + + +
+ +
+ +

+ Depending on your device settings for haptic feedback some of the buttons may + not work. +

diff --git a/examples/api/src/views/Http.svelte b/examples/api/src/views/Http.svelte index 842816b8..5c7c3c49 100644 --- a/examples/api/src/views/Http.svelte +++ b/examples/api/src/views/Http.svelte @@ -1,69 +1,69 @@ @@ -82,7 +82,7 @@ placeholder="Request body" rows="5" bind:value={httpBody} - /> + >
diff --git a/examples/api/src/views/Nfc.svelte b/examples/api/src/views/Nfc.svelte new file mode 100644 index 00000000..4d7ea2c3 --- /dev/null +++ b/examples/api/src/views/Nfc.svelte @@ -0,0 +1,126 @@ + + +
+
+
+ + +
+ + +
+ + {#if isAndroid} +
+

Filters

+
+ + + +
+
+ +
+
+ {/if} + +
+

Write Records

+
+ + +
+
+ + +
diff --git a/examples/api/src/views/Notifications.svelte b/examples/api/src/views/Notifications.svelte index 624561df..e01d57fc 100644 --- a/examples/api/src/views/Notifications.svelte +++ b/examples/api/src/views/Notifications.svelte @@ -29,6 +29,6 @@ } - diff --git a/examples/api/src/views/Opener.svelte b/examples/api/src/views/Opener.svelte new file mode 100644 index 00000000..eca634ac --- /dev/null +++ b/examples/api/src/views/Opener.svelte @@ -0,0 +1,66 @@ + + +
+
+ + + with + +
+ +
+ + + with + +
+ +
+ + +
+
diff --git a/examples/api/src/views/Scanner.svelte b/examples/api/src/views/Scanner.svelte index 57ff904c..ea0609e3 100644 --- a/examples/api/src/views/Scanner.svelte +++ b/examples/api/src/views/Scanner.svelte @@ -1,38 +1,44 @@ @@ -59,11 +65,12 @@

Aim your camera at a QR code

- +
-
+
@@ -111,7 +118,7 @@ transition: 0.3s; } .square:after { - content: ""; + content: ''; top: 0; display: block; padding-bottom: 100%; @@ -141,7 +148,8 @@ width: 100%; margin: 1rem; border: 2px solid #fff; - box-shadow: 0px 0px 2px 1px rgb(0 0 0 / 0.5), + box-shadow: + 0px 0px 2px 1px rgb(0 0 0 / 0.5), inset 0px 0px 2px 1px rgb(0 0 0 / 0.5); border-radius: 1rem; } diff --git a/examples/api/src/views/Shell.svelte b/examples/api/src/views/Shell.svelte index 5f5e2d25..faaa8c4c 100644 --- a/examples/api/src/views/Shell.svelte +++ b/examples/api/src/views/Shell.svelte @@ -59,7 +59,7 @@ } function writeToStdin() { - child.write(stdin).catch(onMessage); + child.write(`${stdin}\n`).catch(onMessage); } diff --git a/examples/api/src/views/Shortcuts.svelte b/examples/api/src/views/Shortcuts.svelte index cdcc9066..41d0271d 100644 --- a/examples/api/src/views/Shortcuts.svelte +++ b/examples/api/src/views/Shortcuts.svelte @@ -1,9 +1,8 @@ + +
+
+
+ Key: + +
+ +
+ Value: + +
+ +
+ + + + +
+
+ +
+ {#each Object.entries(cache) as [k, v]} +
{k} = {v}
+ {/each} +
+
diff --git a/examples/api/src/views/Updater.svelte b/examples/api/src/views/Updater.svelte index 808e5868..26d074a6 100644 --- a/examples/api/src/views/Updater.svelte +++ b/examples/api/src/views/Updater.svelte @@ -1,56 +1,60 @@
@@ -61,7 +65,7 @@ {:else}
{progress}% -
+
{/if}
diff --git a/examples/api/unocss.config.js b/examples/api/unocss.config.js index 44d926cd..d2069a49 100644 --- a/examples/api/unocss.config.js +++ b/examples/api/unocss.config.js @@ -2,43 +2,43 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { defineConfig, presetIcons, presetUno, presetWebFonts } from "unocss"; -import extractorSvelte from "@unocss/extractor-svelte"; +import { defineConfig, presetIcons, presetUno, presetWebFonts } from 'unocss' +import extractorSvelte from '@unocss/extractor-svelte' export default defineConfig({ theme: { colors: { - primary: "#FFFFFF", - primaryLighter: "#e9ecef", - darkPrimary: "#1B1B1D", - darkPrimaryLighter: "#242526", - primaryText: "#1C1E21", - darkPrimaryText: "#E3E3E3", - secondaryText: "#858A91", - darkSecondaryText: "#C2C5CA", - accent: "#3578E5", - accentDark: "#306cce", - accentDarker: "#2d66c3", - accentDarkest: "#2554a0", - accentLight: "#538ce9", - accentLighter: "#72a1ed", - accentLightest: "#9abcf2", - accentText: "#FFFFFF", - darkAccent: "#67d6ed", - darkAccentDark: "#49cee9", - darkAccentDarker: "#39cae8", - darkAccentDarkest: "#19b5d5", - darkAccentLight: "#85def1", - darkAccentLighter: "#95e2f2", - darkAccentLightest: "#c2eff8", - darkAccentText: "#1C1E21", - code: "#d6d8da", - codeDark: "#282a2e", - hoverOverlay: "rgba(0,0,0,.05)", - hoverOverlayDarker: "rgba(0,0,0,.1)", - darkHoverOverlay: "hsla(0,0%,100%,.05)", - darkHoverOverlayDarker: "hsla(0,0%,100%,.1)", - }, + primary: '#FFFFFF', + primaryLighter: '#e9ecef', + darkPrimary: '#1B1B1D', + darkPrimaryLighter: '#242526', + primaryText: '#1C1E21', + darkPrimaryText: '#E3E3E3', + secondaryText: '#858A91', + darkSecondaryText: '#C2C5CA', + accent: '#3578E5', + accentDark: '#306cce', + accentDarker: '#2d66c3', + accentDarkest: '#2554a0', + accentLight: '#538ce9', + accentLighter: '#72a1ed', + accentLightest: '#9abcf2', + accentText: '#FFFFFF', + darkAccent: '#67d6ed', + darkAccentDark: '#49cee9', + darkAccentDarker: '#39cae8', + darkAccentDarkest: '#19b5d5', + darkAccentLight: '#85def1', + darkAccentLighter: '#95e2f2', + darkAccentLightest: '#c2eff8', + darkAccentText: '#1C1E21', + code: '#d6d8da', + codeDark: '#282a2e', + hoverOverlay: 'rgba(0,0,0,.05)', + hoverOverlayDarker: 'rgba(0,0,0,.1)', + darkHoverOverlay: 'hsla(0,0%,100%,.05)', + darkHoverOverlayDarker: 'hsla(0,0%,100%,.1)' + } }, preflights: [ { @@ -54,7 +54,7 @@ export default defineConfig({ code { font-size: ${theme.fontSize.xs[0]}; font-family: ${theme.fontFamily.mono}; - border-radius: ${theme.borderRadius["DEFAULT"]}; + border-radius: ${theme.borderRadius['DEFAULT']}; background-color: ${theme.colors.code}; } @@ -66,8 +66,8 @@ export default defineConfig({ .dark code { background-color: ${theme.colors.codeDark}; } - `, - }, + ` + } ], shortcuts: { btn: `select-none outline-none shadow-md p-2 rd-1 text-primaryText border-none font-400 dark:font-600 @@ -81,20 +81,20 @@ export default defineConfig({ note: `decoration-none flex-inline items-center relative p-2 rd-1 border-l-4 border-accent dark:border-darkAccent bg-accent/10 dark:bg-darkAccent/10`, - "note-red": - "note bg-red-700/10 dark:bg-red-700/10 after:bg-red-700 dark:after:bg-red-700", + 'note-red': + 'note bg-red-700/10 dark:bg-red-700/10 after:bg-red-700 dark:after:bg-red-700', input: - "h-10 flex items-center outline-none border-none p-2 rd-1 shadow-md bg-primaryLighter dark:bg-darkPrimaryLighter text-primaryText dark:text-darkPrimaryText", + 'h-10 flex items-center outline-none border-none p-2 rd-1 shadow-md bg-primaryLighter dark:bg-darkPrimaryLighter text-primaryText dark:text-darkPrimaryText' }, presets: [ presetUno(), presetIcons(), presetWebFonts({ fonts: { - sans: "Rubik", - mono: ["Fira Code", "Fira Mono:400,700"], - }, - }), + sans: 'Rubik', + mono: ['Fira Code', 'Fira Mono:400,700'] + } + }) ], - extractors: [extractorSvelte], -}); + extractors: [extractorSvelte] +}) diff --git a/examples/api/vite.config.js b/examples/api/vite.config.js index df8c64f2..f7d87db8 100644 --- a/examples/api/vite.config.js +++ b/examples/api/vite.config.js @@ -2,19 +2,15 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { defineConfig } from "vite"; -import Unocss from "unocss/vite"; -import { svelte } from "@sveltejs/vite-plugin-svelte"; -import { internalIpV4 } from "internal-ip"; -import process from "process"; +import { defineConfig } from 'vite' +import Unocss from 'unocss/vite' +import { svelte } from '@sveltejs/vite-plugin-svelte' +import process from 'process' + +const host = process.env.TAURI_DEV_HOST // https://vitejs.dev/config/ export default defineConfig(async () => { - const host = - process.env.TAURI_PLATFORM === "android" || - process.env.TAURI_PLATFORM === "ios" - ? await internalIpV4() - : "localhost"; return { plugins: [Unocss(), svelte()], build: { @@ -22,22 +18,17 @@ export default defineConfig(async () => { output: { entryFileNames: `assets/[name].js`, chunkFileNames: `assets/[name].js`, - assetFileNames: `assets/[name].[ext]`, - }, - }, + assetFileNames: `assets/[name].[ext]` + } + } }, server: { - host: "0.0.0.0", + host: host || false, port: 5173, strictPort: true, - hmr: { - protocol: "ws", - host, - port: 5183, - }, fs: { - allow: [".", "../../tooling/api/dist"], - }, - }, - }; -}); + allow: ['.', '../../tooling/api/dist'] + } + } + } +}) diff --git a/package.json b/package.json index 13f4c46a..14f6cb54 100644 --- a/package.json +++ b/package.json @@ -1,37 +1,39 @@ { "name": "plugins-workspace", "private": true, - "license": "MIT or APACHE-2.0", + "license": "MIT OR Apache-2.0", "type": "module", "scripts": { "build": "pnpm run -r --parallel --filter !plugins-workspace --filter !\"./plugins/*/examples/**\" --filter !\"./examples/*\" build", "lint": "eslint .", - "format": "prettier --write \"./**/*.{cjs,mjs,js,jsx,mts,ts,tsx,html,css,json}\" --ignore-path .prettierignore", - "format-check": "prettier --check \"./**/*.{cjs,mjs,js,jsx,mts,ts,tsx,html,css,json}\" --ignore-path .prettierignore" + "format": "prettier --write .", + "format:check": "prettier --check .", + "example:api:dev": "pnpm run --filter \"api\" tauri dev" }, "devDependencies": { - "@rollup/plugin-node-resolve": "15.2.3", + "@eslint/js": "9.28.0", + "@rollup/plugin-node-resolve": "16.0.1", "@rollup/plugin-terser": "0.4.4", - "@rollup/plugin-typescript": "11.1.5", - "@typescript-eslint/eslint-plugin": "6.8.0", - "@typescript-eslint/parser": "6.8.0", - "covector": "^0.10.2", - "eslint": "8.51.0", - "eslint-config-prettier": "9.0.0", - "eslint-config-standard-with-typescript": "39.1.1", - "eslint-plugin-import": "2.28.1", - "eslint-plugin-n": "16.2.0", - "eslint-plugin-promise": "6.1.1", - "eslint-plugin-security": "1.7.1", - "prettier": "3.0.3", - "rollup": "4.1.4", - "typescript": "5.2.2" + "@rollup/plugin-typescript": "12.1.2", + "covector": "^0.12.4", + "eslint": "9.28.0", + "eslint-config-prettier": "10.1.5", + "eslint-plugin-security": "3.0.1", + "prettier": "3.5.3", + "rollup": "4.41.1", + "tslib": "2.8.1", + "typescript": "5.8.3", + "typescript-eslint": "8.34.0" }, - "resolutions": { - "semver": ">=7.5.2", - "optionator": ">=0.9.3" + "pnpm": { + "overrides": { + "esbuild@<0.25.0": ">=0.25.0" + }, + "onlyBuiltDependencies": [ + "esbuild" + ] }, "engines": { - "pnpm": ">=7.33.1" + "pnpm": "^10.0.0" } } diff --git a/plugins/authenticator/.gitignore b/plugins/authenticator/.gitignore deleted file mode 100644 index b512c09d..00000000 --- a/plugins/authenticator/.gitignore +++ /dev/null @@ -1 +0,0 @@ -node_modules \ No newline at end of file diff --git a/plugins/authenticator/CHANGELOG.md b/plugins/authenticator/CHANGELOG.md deleted file mode 100644 index 3109c03f..00000000 --- a/plugins/authenticator/CHANGELOG.md +++ /dev/null @@ -1,18 +0,0 @@ -# Changelog - -## \[2.0.0-alpha.2] - -- [`4e2cef9`](https://github.com/tauri-apps/plugins-workspace/commit/4e2cef9b702bbbb9cf4ee17de50791cb21f1b2a4)([#593](https://github.com/tauri-apps/plugins-workspace/pull/593)) Update to alpha.12. - -## \[2.0.0-alpha.1] - -- [`d74fc0a`](https://github.com/tauri-apps/plugins-workspace/commit/d74fc0a097996e90a37be8f57d50b7d1f6ca616f)([#555](https://github.com/tauri-apps/plugins-workspace/pull/555)) Update to alpha.11. - -## \[2.0.0-alpha.0] - -- [`717ae67`](https://github.com/tauri-apps/plugins-workspace/commit/717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! - te to alpha.11. - -## \[2.0.0-alpha.0] - -- [`717ae67`](https://github.com/tauri-apps/plugins-workspace/commit/717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! diff --git a/plugins/authenticator/Cargo.toml b/plugins/authenticator/Cargo.toml deleted file mode 100644 index b5df861f..00000000 --- a/plugins/authenticator/Cargo.toml +++ /dev/null @@ -1,30 +0,0 @@ -[package] -name = "tauri-plugin-authenticator" -version = "2.0.0-alpha.2" -description = "Use hardware security-keys in your Tauri App." -authors = { workspace = true } -license = { workspace = true } -edition = { workspace = true } -rust-version = { workspace = true } - -[package.metadata.docs.rs] -features = [ "tauri/dox" ] - -[dependencies] -serde = { workspace = true } -serde_json = { workspace = true } -tauri = { workspace = true } -log = { workspace = true } -thiserror = { workspace = true } - -[target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies] -authenticator = "0.3.1" -once_cell = "1" -sha2 = "0.10" -base64 = "0.21" -u2f = "0.2" -chrono = "0.4" - -[dev-dependencies] -rand = "0.8" -rusty-fork = "0.3" diff --git a/plugins/authenticator/README.md b/plugins/authenticator/README.md deleted file mode 100644 index 14641c86..00000000 --- a/plugins/authenticator/README.md +++ /dev/null @@ -1,127 +0,0 @@ -![plugin-authenticator](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/authenticator/banner.png) - -Use hardware security-keys in your Tauri App. - -- Supported platforms: Windows, Linux, FreeBSD, NetBSD, OpenBSD, and macOS. - -## Install - -_This plugin requires a Rust version of at least **1.70**_ - -There are three general methods of installation that we can recommend. - -1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked) -2. Pull sources directly from Github using git tags / revision hashes (most secure) -3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use) - -Install the Core plugin by adding the following to your `Cargo.toml` file: - -`src-tauri/Cargo.toml` - -```toml -# you can add the dependencies on the `[dependencies]` section if you do not target mobile -[target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies] -tauri-plugin-authenticator = "2.0.0-alpha" -# alternatively with Git: -tauri-plugin-authenticator = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } -``` - -You can install the JavaScript Guest bindings using your preferred JavaScript package manager: - -> Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use. - -```sh -pnpm add @tauri-apps/plugin-authenticator -# or -npm add @tauri-apps/plugin-authenticator -# or -yarn add @tauri-apps/plugin-authenticator -``` - -Alternatively with Git: - -```sh -pnpm add https://github.com/tauri-apps/tauri-plugin-authenticator#v2 -# or -npm add https://github.com/tauri-apps/tauri-plugin-authenticator#v2 -# or -yarn add https://github.com/tauri-apps/tauri-plugin-authenticator#v2 -``` - -## Usage - -First you need to register the core plugin with Tauri: - -`src-tauri/src/main.rs` - -```rust -fn main() { - tauri::Builder::default() - .setup(|app| { - #[cfg(desktop)] - app.handle().plugin(tauri_plugin_authenticator::init())?; - Ok(()) - }) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); -} -``` - -Afterwards all the plugin's APIs are available through the JavaScript guest bindings: - -```javascript -import { Authenticator } from "@tauri-apps/plugin-authenticator"; - -const auth = new Authenticator(); -auth.init(); // initialize transports - -// generate a 32-bytes long random challenge -const arr = new Uint32Array(32); -window.crypto.getRandomValues(arr); -const b64 = btoa(String.fromCharCode.apply(null, arr)); -// web-safe base64 -const challenge = b64.replace(/\+/g, "-").replace(/\//g, "_"); - -const domain = "https://tauri.app"; - -// attempt to register with the security key -const json = await auth.register(challenge, domain); -const registerResult = JSON.parse(json); - -// verify te registration was successfull -const r2 = await auth.verifyRegistration( - challenge, - app, - registerResult.registerData, - registerResult.clientData, -); -const j2 = JSON.parse(r2); - -// sign some data -const json = await auth.sign(challenge, app, keyHandle); -const signData = JSON.parse(json); - -// verify the signature again -const counter = await auth.verifySignature( - challenge, - app, - signData.signData, - clientData, - keyHandle, - pubkey, -); - -if (counter && counter > 0) { - console.log("SUCCESS!"); -} -``` - -## Contributing - -PRs accepted. Please make sure to read the Contributing Guide before making a pull request. - -## License - -Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. - -MIT or MIT/Apache 2.0 where applicable. diff --git a/plugins/authenticator/banner.png b/plugins/authenticator/banner.png deleted file mode 100644 index 405dc601..00000000 Binary files a/plugins/authenticator/banner.png and /dev/null differ diff --git a/plugins/authenticator/guest-js/index.ts b/plugins/authenticator/guest-js/index.ts deleted file mode 100644 index 0719bc1f..00000000 --- a/plugins/authenticator/guest-js/index.ts +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2019-2023 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - -import { invoke } from "@tauri-apps/api/primitives"; - -export class Authenticator { - async init(): Promise { - return await invoke("plugin:authenticator|init_auth"); - } - - async register(challenge: string, application: string): Promise { - return await invoke("plugin:authenticator|register", { - timeout: 10000, - challenge, - application, - }); - } - - async verifyRegistration( - challenge: string, - application: string, - registerData: string, - clientData: string, - ): Promise { - return await invoke("plugin:authenticator|verify_registration", { - challenge, - application, - registerData, - clientData, - }); - } - - async sign( - challenge: string, - application: string, - keyHandle: string, - ): Promise { - return await invoke("plugin:authenticator|sign", { - timeout: 10000, - challenge, - application, - keyHandle, - }); - } - - async verifySignature( - challenge: string, - application: string, - signData: string, - clientData: string, - keyHandle: string, - pubkey: string, - ): Promise { - return await invoke("plugin:authenticator|verify_signature", { - challenge, - application, - signData, - clientData, - keyHandle, - pubkey, - }); - } -} diff --git a/plugins/authenticator/package.json b/plugins/authenticator/package.json deleted file mode 100644 index 0435def5..00000000 --- a/plugins/authenticator/package.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "@tauri-apps/plugin-authenticator", - "version": "2.0.0-alpha.1", - "description": "Use hardware security-keys in your Tauri App.", - "license": "MIT or APACHE-2.0", - "authors": [ - "Tauri Programme within The Commons Conservancy" - ], - "type": "module", - "browser": "dist-js/index.min.js", - "module": "dist-js/index.mjs", - "types": "dist-js/index.d.ts", - "exports": { - "import": "./dist-js/index.mjs", - "types": "./dist-js/index.d.ts", - "browser": "./dist-js/index.min.js" - }, - "scripts": { - "build": "rollup -c" - }, - "files": [ - "dist-js", - "!dist-js/**/*.map", - "README.md", - "LICENSE" - ], - "devDependencies": { - "tslib": "2.6.0" - }, - "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.9" - } -} diff --git a/plugins/authenticator/rollup.config.mjs b/plugins/authenticator/rollup.config.mjs deleted file mode 100644 index 99a3dd31..00000000 --- a/plugins/authenticator/rollup.config.mjs +++ /dev/null @@ -1,11 +0,0 @@ -import { readFileSync } from "fs"; - -import { createConfig } from "../../shared/rollup.config.mjs"; - -export default createConfig({ - input: "guest-js/index.ts", - pkg: JSON.parse( - readFileSync(new URL("./package.json", import.meta.url), "utf8"), - ), - external: [/^@tauri-apps\/api/], -}); diff --git a/plugins/authenticator/src/api-iife.js b/plugins/authenticator/src/api-iife.js deleted file mode 100644 index c56017b8..00000000 --- a/plugins/authenticator/src/api-iife.js +++ /dev/null @@ -1 +0,0 @@ -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__})} diff --git a/plugins/authenticator/src/auth.rs b/plugins/authenticator/src/auth.rs deleted file mode 100644 index 34bc332b..00000000 --- a/plugins/authenticator/src/auth.rs +++ /dev/null @@ -1,212 +0,0 @@ -// Copyright 2019-2023 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - -use authenticator::{ - authenticatorservice::AuthenticatorService, statecallback::StateCallback, - AuthenticatorTransports, KeyHandle, RegisterFlags, SignFlags, StatusUpdate, -}; -use base64::{engine::general_purpose::URL_SAFE_NO_PAD, Engine}; -use once_cell::sync::Lazy; -use serde::Serialize; -use sha2::{Digest, Sha256}; -use std::io; -use std::sync::mpsc::channel; -use std::{convert::Into, sync::Mutex}; - -static MANAGER: Lazy> = Lazy::new(|| { - let manager = AuthenticatorService::new().expect("The auth service should initialize safely"); - Mutex::new(manager) -}); - -pub fn init_usb() { - let mut manager = MANAGER.lock().unwrap(); - // theres also "add_detected_transports()" in the docs? - manager.add_u2f_usb_hid_platform_transports(); -} - -#[derive(Serialize, Clone)] -#[serde(rename_all = "camelCase")] -pub struct Registration { - pub key_handle: String, - pub pubkey: String, - pub register_data: String, - pub client_data: String, -} - -pub fn register(application: String, timeout: u64, challenge: String) -> crate::Result { - let (chall_bytes, app_bytes, client_data_string) = - format_client_data(application.as_str(), challenge.as_str()); - - // log the status rx? - let (status_tx, _status_rx) = channel::(); - - let mut manager = MANAGER.lock().unwrap(); - - let (register_tx, register_rx) = channel(); - let callback = StateCallback::new(Box::new(move |rv| { - register_tx.send(rv).unwrap(); - })); - - let res = manager.register( - RegisterFlags::empty(), - timeout, - chall_bytes, - app_bytes, - vec![], - status_tx, - callback, - ); - - match res { - Ok(_r) => { - let register_result = register_rx - .recv() - .expect("Problem receiving, unable to continue"); - - if let Err(e) = register_result { - return Err(e.into()); - } - - let (register_data, device_info) = register_result.unwrap(); // error already has been checked - - // println!("Register result: {}", base64::encode(®ister_data)); - println!("Device info: {}", &device_info); - - let (key_handle, public_key) = - _u2f_get_key_handle_and_public_key_from_register_response(®ister_data).unwrap(); - let key_handle_base64 = URL_SAFE_NO_PAD.encode(key_handle); - let public_key_base64 = URL_SAFE_NO_PAD.encode(public_key); - let register_data_base64 = URL_SAFE_NO_PAD.encode(®ister_data); - println!("Key Handle: {}", &key_handle_base64); - println!("Public Key: {}", &public_key_base64); - - // Ok(base64::encode(®ister_data)) - // Ok(key_handle_base64) - let res = serde_json::to_string(&Registration { - key_handle: key_handle_base64, - pubkey: public_key_base64, - register_data: register_data_base64, - client_data: client_data_string, - })?; - Ok(res) - } - Err(e) => Err(e.into()), - } -} - -#[derive(Serialize, Clone)] -#[serde(rename_all = "camelCase")] -pub struct Signature { - pub key_handle: String, - pub sign_data: String, -} - -pub fn sign( - application: String, - timeout: u64, - challenge: String, - key_handle: String, -) -> crate::Result { - let credential = match URL_SAFE_NO_PAD.decode(key_handle) { - Ok(v) => v, - Err(e) => { - return Err(e.into()); - } - }; - let key_handle = KeyHandle { - credential, - transports: AuthenticatorTransports::empty(), - }; - - let (chall_bytes, app_bytes, _) = format_client_data(application.as_str(), challenge.as_str()); - - let (sign_tx, sign_rx) = channel(); - let callback = StateCallback::new(Box::new(move |rv| { - sign_tx.send(rv).unwrap(); - })); - - // log the status rx? - let (status_tx, _status_rx) = channel::(); - - let mut manager = MANAGER.lock().unwrap(); - - let res = manager.sign( - SignFlags::empty(), - timeout, - chall_bytes, - vec![app_bytes], - vec![key_handle], - status_tx, - callback, - ); - match res { - Ok(_v) => { - let sign_result = sign_rx - .recv() - .expect("Problem receiving, unable to continue"); - - if let Err(e) = sign_result { - return Err(e.into()); - } - - let (_, handle_used, sign_data, device_info) = sign_result.unwrap(); - - let sig = URL_SAFE_NO_PAD.encode(sign_data); - - println!("Sign result: {sig}"); - println!("Key handle used: {}", URL_SAFE_NO_PAD.encode(&handle_used)); - println!("Device info: {}", &device_info); - println!("Done."); - - let res = serde_json::to_string(&Signature { - sign_data: sig, - key_handle: URL_SAFE_NO_PAD.encode(&handle_used), - })?; - Ok(res) - } - Err(e) => Err(e.into()), - } -} - -fn format_client_data(application: &str, challenge: &str) -> (Vec, Vec, String) { - let d = - format!(r#"{{"challenge": "{challenge}", "version": "U2F_V2", "appId": "{application}"}}"#); - let mut challenge = Sha256::new(); - challenge.update(d.as_bytes()); - let chall_bytes = challenge.finalize().to_vec(); - - let mut app = Sha256::new(); - app.update(application.as_bytes()); - let app_bytes = app.finalize().to_vec(); - - (chall_bytes, app_bytes, d) -} - -fn _u2f_get_key_handle_and_public_key_from_register_response( - register_response: &[u8], -) -> io::Result<(Vec, Vec)> { - if register_response[0] != 0x05 { - return Err(io::Error::new( - io::ErrorKind::InvalidData, - "Reserved byte not set correctly", - )); - } - - // 1: reserved - // 65: public key - // 1: key handle length - // key handle - // x.509 cert - // sig - - let key_handle_len = register_response[66] as usize; - let mut public_key = register_response.to_owned(); - let mut key_handle = public_key.split_off(67); - let _attestation = key_handle.split_off(key_handle_len); - - // remove fist (reserved) and last (handle len) bytes - let pk: Vec = public_key[1..public_key.len() - 1].to_vec(); - - Ok((key_handle, pk)) -} diff --git a/plugins/authenticator/src/lib.rs b/plugins/authenticator/src/lib.rs deleted file mode 100644 index 92fef471..00000000 --- a/plugins/authenticator/src/lib.rs +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2019-2023 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - -//! [![](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/authenticator/banner.png)](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/authenticator) -//! -//! Use hardware security-keys in your Tauri App. -//! -//! - Supported platforms: Windows, Linux, FreeBSD, NetBSD, OpenBSD, and macOS. - -#![doc( - html_logo_url = "https://github.com/tauri-apps/tauri/raw/dev/app-icon.png", - html_favicon_url = "https://github.com/tauri-apps/tauri/raw/dev/app-icon.png" -)] -#![cfg(not(any(target_os = "android", target_os = "ios")))] - -mod auth; -mod error; -mod u2f; - -use tauri::{ - plugin::{Builder as PluginBuilder, TauriPlugin}, - Runtime, -}; - -pub use error::Error; -type Result = std::result::Result; - -#[tauri::command] -fn init_auth() { - auth::init_usb(); -} - -#[tauri::command] -fn register(timeout: u64, challenge: String, application: String) -> crate::Result { - auth::register(application, timeout, challenge) -} - -#[tauri::command] -fn verify_registration( - challenge: String, - application: String, - register_data: String, - client_data: String, -) -> crate::Result { - u2f::verify_registration(application, challenge, register_data, client_data) -} - -#[tauri::command] -fn sign( - timeout: u64, - challenge: String, - application: String, - key_handle: String, -) -> crate::Result { - auth::sign(application, timeout, challenge, key_handle) -} - -#[tauri::command] -fn verify_signature( - challenge: String, - application: String, - sign_data: String, - client_data: String, - key_handle: String, - pubkey: String, -) -> crate::Result { - u2f::verify_signature( - application, - challenge, - sign_data, - client_data, - key_handle, - pubkey, - ) -} - -pub fn init() -> TauriPlugin { - PluginBuilder::new("authenticator") - .js_init_script(include_str!("api-iife.js").to_string()) - .invoke_handler(tauri::generate_handler![ - init_auth, - register, - verify_registration, - sign, - verify_signature - ]) - .build() -} diff --git a/plugins/authenticator/src/u2f.rs b/plugins/authenticator/src/u2f.rs deleted file mode 100644 index 12f1d6c3..00000000 --- a/plugins/authenticator/src/u2f.rs +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright 2019-2023 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - -use base64::{engine::general_purpose::URL_SAFE_NO_PAD, Engine}; -use chrono::prelude::*; -use serde::Serialize; -use std::convert::Into; -use u2f::messages::*; -use u2f::protocol::*; -use u2f::register::*; - -static VERSION: &str = "U2F_V2"; - -pub fn make_challenge(app_id: &str, challenge_bytes: Vec) -> Challenge { - let utc: DateTime = Utc::now(); - Challenge { - challenge: URL_SAFE_NO_PAD.encode(challenge_bytes), - timestamp: format!("{utc:?}"), - app_id: app_id.to_string(), - } -} - -#[derive(Serialize, Clone)] -#[serde(rename_all = "camelCase")] -pub struct RegistrationVerification { - pub key_handle: String, - pub pubkey: String, - pub device_name: Option, -} - -pub fn verify_registration( - app_id: String, - challenge: String, - register_data: String, - client_data: String, -) -> crate::Result { - let challenge_bytes = URL_SAFE_NO_PAD.decode(challenge)?; - let challenge = make_challenge(&app_id, challenge_bytes); - let client_data_bytes: Vec = client_data.as_bytes().into(); - let client_data_base64 = URL_SAFE_NO_PAD.encode(client_data_bytes); - let client = U2f::new(app_id); - match client.register_response( - challenge, - RegisterResponse { - registration_data: register_data, - client_data: client_data_base64, - version: VERSION.to_string(), - }, - ) { - Ok(v) => { - let rv = RegistrationVerification { - key_handle: URL_SAFE_NO_PAD.encode(&v.key_handle), - pubkey: URL_SAFE_NO_PAD.encode(&v.pub_key), - device_name: v.device_name, - }; - Ok(serde_json::to_string(&rv)?) - } - Err(e) => Err(e.into()), - } -} - -#[derive(Serialize, Clone)] -#[serde(rename_all = "camelCase")] -pub struct SignatureVerification { - pub counter: u8, -} - -pub fn verify_signature( - app_id: String, - challenge: String, - sign_data: String, - client_data: String, - key_handle: String, - pub_key: String, -) -> crate::Result { - let challenge_bytes = URL_SAFE_NO_PAD.decode(challenge)?; - let chal = make_challenge(&app_id, challenge_bytes); - let client_data_bytes: Vec = client_data.as_bytes().into(); - let client_data_base64 = URL_SAFE_NO_PAD.encode(client_data_bytes); - let key_handle_bytes = URL_SAFE_NO_PAD.decode(&key_handle)?; - let pubkey_bytes = URL_SAFE_NO_PAD.decode(pub_key)?; - let client = U2f::new(app_id); - let mut _counter: u32 = 0; - match client.sign_response( - chal, - Registration { - // here only needs pubkey and keyhandle - key_handle: key_handle_bytes, - pub_key: pubkey_bytes, - attestation_cert: None, - device_name: None, - }, - SignResponse { - // here needs client data and sig data and key_handle - signature_data: sign_data, - client_data: client_data_base64, - key_handle, - }, - _counter, - ) { - Ok(v) => Ok(v), - Err(e) => Err(e.into()), - } -} diff --git a/plugins/autostart/.gitignore b/plugins/autostart/.gitignore deleted file mode 100644 index b512c09d..00000000 --- a/plugins/autostart/.gitignore +++ /dev/null @@ -1 +0,0 @@ -node_modules \ No newline at end of file diff --git a/plugins/autostart/CHANGELOG.md b/plugins/autostart/CHANGELOG.md index 3109c03f..2a2f31e5 100644 --- a/plugins/autostart/CHANGELOG.md +++ b/plugins/autostart/CHANGELOG.md @@ -1,5 +1,90 @@ # Changelog +## \[2.3.0] + +- [`8ecb418a`](https://github.com/tauri-apps/plugins-workspace/commit/8ecb418a1a35d7f234dc5d833746ac2d8e062aec) ([#2569](https://github.com/tauri-apps/plugins-workspace/pull/2569)) Add a `Builder` for more flexible settings + +## \[2.2.0] + +- [`3a79266b`](https://github.com/tauri-apps/plugins-workspace/commit/3a79266b8cf96a55b1ae6339d725567d45a44b1d) ([#2173](https://github.com/tauri-apps/plugins-workspace/pull/2173) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Bumped all plugins to `v2.2.0`. From now, the versions for the Rust and JavaScript packages of each plugin will be in sync with each other. + +## \[2.0.1] + +- [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. + +## \[2.0.0] + +- [`e2c4dfb6`](https://github.com/tauri-apps/plugins-workspace/commit/e2c4dfb6af43e5dd8d9ceba232c315f5febd55c1) Update to tauri v2 stable release. + +## \[2.0.0-rc.1] + +- [`e2e97db5`](https://github.com/tauri-apps/plugins-workspace/commit/e2e97db51983267f5be84d4f6f0278d58834d1f5) ([#1701](https://github.com/tauri-apps/plugins-workspace/pull/1701) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri 2.0.0-rc.8 + +## \[2.0.0-rc.0] + +- [`9887d1`](https://github.com/tauri-apps/plugins-workspace/commit/9887d14bd0e971c4c0f5c1188fc4005d3fc2e29e) Update to tauri RC. + +## \[2.0.0-beta.8] + +- [`99d6ac0f`](https://github.com/tauri-apps/plugins-workspace/commit/99d6ac0f9506a6a4a1aa59c728157190a7441af6) ([#1606](https://github.com/tauri-apps/plugins-workspace/pull/1606) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) The JS packages now specify the *minimum* `@tauri-apps/api` version instead of a single exact version. +- [`6de87966`](https://github.com/tauri-apps/plugins-workspace/commit/6de87966ecc00ad9d91c25be452f1f46bd2b7e1f) ([#1597](https://github.com/tauri-apps/plugins-workspace/pull/1597) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Update to tauri beta.25. + +## \[2.0.0-beta.7] + +- [`22a17980`](https://github.com/tauri-apps/plugins-workspace/commit/22a17980ff4f6f8c40adb1b8f4ffc6dae2fe7e30) ([#1537](https://github.com/tauri-apps/plugins-workspace/pull/1537) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri beta.24. + +## \[2.0.0-beta.6] + +- [`76daee7a`](https://github.com/tauri-apps/plugins-workspace/commit/76daee7aafece34de3092c86e531cf9eb1138989) ([#1512](https://github.com/tauri-apps/plugins-workspace/pull/1512) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Update to tauri beta.23. + +## \[2.0.0-beta.5] + +- [`9013854f`](https://github.com/tauri-apps/plugins-workspace/commit/9013854f42a49a230b9dbb9d02774765528a923f)([#1382](https://github.com/tauri-apps/plugins-workspace/pull/1382)) Update to tauri beta.22. + +## \[2.0.0-beta.4] + +- [`430bd6f4`](https://github.com/tauri-apps/plugins-workspace/commit/430bd6f4f379bee5d232ae6b098ae131db7f178a)([#1363](https://github.com/tauri-apps/plugins-workspace/pull/1363)) Update to tauri beta.20. + +## \[2.0.0-beta.3] + +- [`bd1ed590`](https://github.com/tauri-apps/plugins-workspace/commit/bd1ed5903ffcce5500310dac1e59e8c67674ef1e)([#1237](https://github.com/tauri-apps/plugins-workspace/pull/1237)) Update to tauri beta.17. + +## \[2.0.0-beta.4] + +- [`a233919`](https://github.com/tauri-apps/plugins-workspace/commit/a2339195aa940bff86d76375fd05087595bf06ce)([#1118](https://github.com/tauri-apps/plugins-workspace/pull/1118)) Fix LaunchAgent-based autostart for macOS. + +## \[2.0.0-beta.3] + +- [`a04ea2f`](https://github.com/tauri-apps/plugins-workspace/commit/a04ea2f38294d5a3987578283badc8eec87a7752)([#1071](https://github.com/tauri-apps/plugins-workspace/pull/1071)) The global API script is now only added to the binary when the `withGlobalTauri` config is true. + +## \[2.0.0-beta.2] + +- [`99bea25`](https://github.com/tauri-apps/plugins-workspace/commit/99bea2559c2c0648c2519c50a18cd124dacef57b)([#1005](https://github.com/tauri-apps/plugins-workspace/pull/1005)) Update to tauri beta.8. + +## \[2.0.0-beta.1] + +- [`569defb`](https://github.com/tauri-apps/plugins-workspace/commit/569defbe9492e38938554bb7bdc1be9151456d21) Update to tauri beta.4. + +## \[2.0.0-beta.0] + +- [`d198c01`](https://github.com/tauri-apps/plugins-workspace/commit/d198c014863ee260cb0de88a14b7fc4356ef7474)([#862](https://github.com/tauri-apps/plugins-workspace/pull/862)) Update to tauri beta. + +## \[2.0.0-alpha.5] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.13. + +## \[2.0.0-alpha.4] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.12. + +## \[2.0.0-alpha.3] + +- [`e438e0a`](https://github.com/tauri-apps/plugins-workspace/commit/e438e0a62d4b430a5159f05f13ecd397dd891a0d)([#676](https://github.com/tauri-apps/plugins-workspace/pull/676)) Update to @tauri-apps/api v2.0.0-alpha.11. + +## \[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.9. + ## \[2.0.0-alpha.2] - [`4e2cef9`](https://github.com/tauri-apps/plugins-workspace/commit/4e2cef9b702bbbb9cf4ee17de50791cb21f1b2a4)([#593](https://github.com/tauri-apps/plugins-workspace/pull/593)) Update to alpha.12. @@ -10,9 +95,4 @@ ## \[2.0.0-alpha.0] -- [`717ae67`](https://github.com/tauri-apps/plugins-workspace/commit/717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! - te to alpha.11. - -## \[2.0.0-alpha.0] - - [`717ae67`](https://github.com/tauri-apps/plugins-workspace/commit/717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! diff --git a/plugins/autostart/Cargo.toml b/plugins/autostart/Cargo.toml index aa499665..9a30eff9 100644 --- a/plugins/autostart/Cargo.toml +++ b/plugins/autostart/Cargo.toml @@ -1,19 +1,31 @@ [package] name = "tauri-plugin-autostart" -version = "2.0.0-alpha.2" +version = "2.3.0" description = "Automatically launch your application at startup." authors = { workspace = true } license = { workspace = true } edition = { workspace = true } rust-version = { workspace = true } +repository = { workspace = true } +links = "tauri-plugin-autostart" [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] + +[package.metadata.platforms.support] +windows = { level = "full", notes = "" } +linux = { level = "full", notes = "" } +macos = { level = "full", notes = "" } +android = { level = "none", notes = "" } +ios = { level = "none", notes = "" } + +[build-dependencies] +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } serde_json = { workspace = true } tauri = { workspace = true } -log = { workspace = true } thiserror = { workspace = true } -auto-launch = "0.4" +auto-launch = "0.5" diff --git a/plugins/autostart/README.md b/plugins/autostart/README.md index 938f5a3b..cef284d6 100644 --- a/plugins/autostart/README.md +++ b/plugins/autostart/README.md @@ -1,10 +1,18 @@ ![plugin-autostart](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/autostart/banner.png) -Automatically launch your application at startup. Supports Windows, Mac (via AppleScript or Launch Agent), and Linux. +Automatically launch your application at startup. + +| Platform | Supported | +| -------- | --------- | +| Linux | ✓ | +| Windows | ✓ | +| macOS | ✓ | +| Android | x | +| iOS | x | ## Install -_This plugin requires a Rust version of at least **1.70**_ +_This plugin requires a Rust version of at least **1.77.2**_ There are three general methods of installation that we can recommend. @@ -18,7 +26,7 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] -tauri-plugin-autostart = "2.0.0-alpha" +tauri-plugin-autostart = "2.0.0" # alternatively with Git: tauri-plugin-autostart = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -46,14 +54,15 @@ yarn add https://github.com/tauri-apps/tauri-plugin-autostart#v2 First you need to register the core plugin with Tauri: -`src-tauri/src/main.rs` +`src-tauri/src/lib.rs` ```rust -use tauri_plugin_autostart::MacosLauncher; - fn main() { tauri::Builder::default() - .plugin(tauri_plugin_autostart::init(MacosLauncher::LaunchAgent, Some(vec!["--flag1", "--flag2"]) /* arbitrary number of args to pass to your app */)) + .plugin(tauri_plugin_autostart::Builder::new() + .args(["--flag1", "--flag2"]) + .app_name("My Custom Name") + .build()) .run(tauri::generate_context!()) .expect("error while running tauri application"); } @@ -62,19 +71,35 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import { enable, isEnabled, disable } from "@tauri-apps/plugin-autostart"; +import { enable, isEnabled, disable } from '@tauri-apps/plugin-autostart' -await enable(); +await enable() -console.log(`registered for autostart? ${await isEnabled()}`); +console.log(`registered for autostart? ${await isEnabled()}`) -disable(); +disable() ``` ## Contributing PRs accepted. Please make sure to read the Contributing Guide before making a pull request. +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + ## License Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. diff --git a/plugins/autostart/SECURITY.md b/plugins/autostart/SECURITY.md new file mode 100644 index 00000000..4f09bbac --- /dev/null +++ b/plugins/autostart/SECURITY.md @@ -0,0 +1,23 @@ +# Security Policy + +**Do not report security vulnerabilities through public GitHub issues.** + +**Please use the [Private Vulnerability Disclosure](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) feature of GitHub.** + +Include as much of the following information: + +- Type of issue (e.g. improper input parsing, privilege escalation, etc.) +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- The distribution affected or used to help us with reproduction of the issue +- Step-by-step instructions to reproduce the issue +- Ideally a reproduction repository +- Impact of the issue, including how an attacker might exploit the issue + +We prefer to receive reports in English. + +## Contact + +Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). + +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/autostart/api-iife.js b/plugins/autostart/api-iife.js new file mode 100644 index 00000000..77a12c92 --- /dev/null +++ b/plugins/autostart/api-iife.js @@ -0,0 +1 @@ +if("__TAURI__"in window){var __TAURI_PLUGIN_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_PLUGIN_AUTOSTART__})} diff --git a/plugins/autostart/build.rs b/plugins/autostart/build.rs new file mode 100644 index 00000000..1460469b --- /dev/null +++ b/plugins/autostart/build.rs @@ -0,0 +1,11 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +const COMMANDS: &[&str] = &["enable", "disable", "is_enabled"]; + +fn main() { + tauri_plugin::Builder::new(COMMANDS) + .global_api_script_path("./api-iife.js") + .build(); +} diff --git a/plugins/autostart/guest-js/index.ts b/plugins/autostart/guest-js/index.ts index 697e9b41..fca8344f 100644 --- a/plugins/autostart/guest-js/index.ts +++ b/plugins/autostart/guest-js/index.ts @@ -2,16 +2,16 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { invoke } from "@tauri-apps/api/primitives"; +import { invoke } from '@tauri-apps/api/core' export async function isEnabled(): Promise { - return await invoke("plugin:autostart|is_enabled"); + return await invoke('plugin:autostart|is_enabled') } export async function enable(): Promise { - await invoke("plugin:autostart|enable"); + await invoke('plugin:autostart|enable') } export async function disable(): Promise { - await invoke("plugin:autostart|disable"); + await invoke('plugin:autostart|disable') } diff --git a/plugins/autostart/package.json b/plugins/autostart/package.json index f9b666f0..c2840616 100644 --- a/plugins/autostart/package.json +++ b/plugins/autostart/package.json @@ -1,32 +1,29 @@ { "name": "@tauri-apps/plugin-autostart", - "version": "2.0.0-alpha.1", - "license": "MIT or APACHE-2.0", + "version": "2.3.0", + "license": "MIT OR Apache-2.0", "authors": [ "Tauri Programme within The Commons Conservancy" ], + "repository": "https://github.com/tauri-apps/plugins-workspace", "type": "module", - "browser": "dist-js/index.min.js", - "module": "dist-js/index.mjs", - "types": "dist-js/index.d.ts", + "types": "./dist-js/index.d.ts", + "main": "./dist-js/index.cjs", + "module": "./dist-js/index.js", "exports": { - "import": "./dist-js/index.mjs", "types": "./dist-js/index.d.ts", - "browser": "./dist-js/index.min.js" + "import": "./dist-js/index.js", + "require": "./dist-js/index.cjs" }, "scripts": { "build": "rollup -c" }, "files": [ "dist-js", - "!dist-js/**/*.map", "README.md", "LICENSE" ], - "devDependencies": { - "tslib": "2.6.0" - }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.9" + "@tauri-apps/api": "^2.0.0" } } diff --git a/plugins/autostart/permissions/autogenerated/commands/disable.toml b/plugins/autostart/permissions/autogenerated/commands/disable.toml new file mode 100644 index 00000000..849c50a2 --- /dev/null +++ b/plugins/autostart/permissions/autogenerated/commands/disable.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-disable" +description = "Enables the disable command without any pre-configured scope." +commands.allow = ["disable"] + +[[permission]] +identifier = "deny-disable" +description = "Denies the disable command without any pre-configured scope." +commands.deny = ["disable"] diff --git a/plugins/autostart/permissions/autogenerated/commands/enable.toml b/plugins/autostart/permissions/autogenerated/commands/enable.toml new file mode 100644 index 00000000..f931a9e5 --- /dev/null +++ b/plugins/autostart/permissions/autogenerated/commands/enable.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-enable" +description = "Enables the enable command without any pre-configured scope." +commands.allow = ["enable"] + +[[permission]] +identifier = "deny-enable" +description = "Denies the enable command without any pre-configured scope." +commands.deny = ["enable"] diff --git a/plugins/autostart/permissions/autogenerated/commands/is_enabled.toml b/plugins/autostart/permissions/autogenerated/commands/is_enabled.toml new file mode 100644 index 00000000..88a6a282 --- /dev/null +++ b/plugins/autostart/permissions/autogenerated/commands/is_enabled.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-is-enabled" +description = "Enables the is_enabled command without any pre-configured scope." +commands.allow = ["is_enabled"] + +[[permission]] +identifier = "deny-is-enabled" +description = "Denies the is_enabled command without any pre-configured scope." +commands.deny = ["is_enabled"] diff --git a/plugins/autostart/permissions/autogenerated/reference.md b/plugins/autostart/permissions/autogenerated/reference.md new file mode 100644 index 00000000..6adb2be4 --- /dev/null +++ b/plugins/autostart/permissions/autogenerated/reference.md @@ -0,0 +1,106 @@ +## Default Permission + +This permission set configures if your +application can enable or disable auto +starting the application on boot. + +#### Granted Permissions + +It allows all to check, enable and +disable the automatic start on boot. + + + +#### This default permission set includes the following: + +- `allow-enable` +- `allow-disable` +- `allow-is-enabled` + +## Permission Table + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IdentifierDescription
+ +`autostart:allow-disable` + + + +Enables the disable command without any pre-configured scope. + +
+ +`autostart:deny-disable` + + + +Denies the disable command without any pre-configured scope. + +
+ +`autostart:allow-enable` + + + +Enables the enable command without any pre-configured scope. + +
+ +`autostart:deny-enable` + + + +Denies the enable command without any pre-configured scope. + +
+ +`autostart:allow-is-enabled` + + + +Enables the is_enabled command without any pre-configured scope. + +
+ +`autostart:deny-is-enabled` + + + +Denies the is_enabled command without any pre-configured scope. + +
diff --git a/plugins/autostart/permissions/default.toml b/plugins/autostart/permissions/default.toml new file mode 100644 index 00000000..a2ac766f --- /dev/null +++ b/plugins/autostart/permissions/default.toml @@ -0,0 +1,15 @@ +"$schema" = "schemas/schema.json" +[default] +description = """ +This permission set configures if your +application can enable or disable auto +starting the application on boot. + +#### Granted Permissions + +It allows all to check, enable and +disable the automatic start on boot. + +""" + +permissions = ["allow-enable", "allow-disable", "allow-is-enabled"] diff --git a/plugins/autostart/permissions/schemas/schema.json b/plugins/autostart/permissions/schemas/schema.json new file mode 100644 index 00000000..af681221 --- /dev/null +++ b/plugins/autostart/permissions/schemas/schema.json @@ -0,0 +1,342 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "PermissionFile", + "description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.", + "type": "object", + "properties": { + "default": { + "description": "The default permission set for the plugin", + "anyOf": [ + { + "$ref": "#/definitions/DefaultPermission" + }, + { + "type": "null" + } + ] + }, + "set": { + "description": "A list of permissions sets defined", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionSet" + } + }, + "permission": { + "description": "A list of inlined permissions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Permission" + } + } + }, + "definitions": { + "DefaultPermission": { + "description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.", + "type": "object", + "required": [ + "permissions" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "PermissionSet": { + "description": "A set of direct permissions grouped together under a new name.", + "type": "object", + "required": [ + "description", + "identifier", + "permissions" + ], + "properties": { + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does.", + "type": "string" + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionKind" + } + } + } + }, + "Permission": { + "description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.", + "type": "object", + "required": [ + "identifier" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri internal convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "commands": { + "description": "Allowed or denied commands when using this permission.", + "default": { + "allow": [], + "deny": [] + }, + "allOf": [ + { + "$ref": "#/definitions/Commands" + } + ] + }, + "scope": { + "description": "Allowed or denied scoped when using this permission.", + "allOf": [ + { + "$ref": "#/definitions/Scopes" + } + ] + }, + "platforms": { + "description": "Target platforms this permission applies. By default all platforms are affected by this permission.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Target" + } + } + } + }, + "Commands": { + "description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.", + "type": "object", + "properties": { + "allow": { + "description": "Allowed command.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "deny": { + "description": "Denied command, which takes priority.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "Scopes": { + "description": "An argument for fine grained behavior control of Tauri commands.\n\nIt can be of any serde serializable type and is used to allow or prevent certain actions inside a Tauri command. The configured scope is passed to the command and will be enforced by the command implementation.\n\n## Example\n\n```json { \"allow\": [{ \"path\": \"$HOME/**\" }], \"deny\": [{ \"path\": \"$HOME/secret.txt\" }] } ```", + "type": "object", + "properties": { + "allow": { + "description": "Data that defines what is allowed by the scope.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + }, + "deny": { + "description": "Data that defines what is denied by the scope. This should be prioritized by validation logic.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + } + } + }, + "Value": { + "description": "All supported ACL values.", + "anyOf": [ + { + "description": "Represents a null JSON value.", + "type": "null" + }, + { + "description": "Represents a [`bool`].", + "type": "boolean" + }, + { + "description": "Represents a valid ACL [`Number`].", + "allOf": [ + { + "$ref": "#/definitions/Number" + } + ] + }, + { + "description": "Represents a [`String`].", + "type": "string" + }, + { + "description": "Represents a list of other [`Value`]s.", + "type": "array", + "items": { + "$ref": "#/definitions/Value" + } + }, + { + "description": "Represents a map of [`String`] keys to [`Value`]s.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/Value" + } + } + ] + }, + "Number": { + "description": "A valid ACL number.", + "anyOf": [ + { + "description": "Represents an [`i64`].", + "type": "integer", + "format": "int64" + }, + { + "description": "Represents a [`f64`].", + "type": "number", + "format": "double" + } + ] + }, + "Target": { + "description": "Platform target.", + "oneOf": [ + { + "description": "MacOS.", + "type": "string", + "enum": [ + "macOS" + ] + }, + { + "description": "Windows.", + "type": "string", + "enum": [ + "windows" + ] + }, + { + "description": "Linux.", + "type": "string", + "enum": [ + "linux" + ] + }, + { + "description": "Android.", + "type": "string", + "enum": [ + "android" + ] + }, + { + "description": "iOS.", + "type": "string", + "enum": [ + "iOS" + ] + } + ] + }, + "PermissionKind": { + "type": "string", + "oneOf": [ + { + "description": "Enables the disable command without any pre-configured scope.", + "type": "string", + "const": "allow-disable", + "markdownDescription": "Enables the disable command without any pre-configured scope." + }, + { + "description": "Denies the disable command without any pre-configured scope.", + "type": "string", + "const": "deny-disable", + "markdownDescription": "Denies the disable command without any pre-configured scope." + }, + { + "description": "Enables the enable command without any pre-configured scope.", + "type": "string", + "const": "allow-enable", + "markdownDescription": "Enables the enable command without any pre-configured scope." + }, + { + "description": "Denies the enable command without any pre-configured scope.", + "type": "string", + "const": "deny-enable", + "markdownDescription": "Denies the enable command without any pre-configured scope." + }, + { + "description": "Enables the is_enabled command without any pre-configured scope.", + "type": "string", + "const": "allow-is-enabled", + "markdownDescription": "Enables the is_enabled command without any pre-configured scope." + }, + { + "description": "Denies the is_enabled command without any pre-configured scope.", + "type": "string", + "const": "deny-is-enabled", + "markdownDescription": "Denies the is_enabled command without any pre-configured scope." + }, + { + "description": "This permission set configures if your\napplication can enable or disable auto\nstarting the application on boot.\n\n#### Granted Permissions\n\nIt allows all to check, enable and\ndisable the automatic start on boot.\n\n\n#### This default permission set includes:\n\n- `allow-enable`\n- `allow-disable`\n- `allow-is-enabled`", + "type": "string", + "const": "default", + "markdownDescription": "This permission set configures if your\napplication can enable or disable auto\nstarting the application on boot.\n\n#### Granted Permissions\n\nIt allows all to check, enable and\ndisable the automatic start on boot.\n\n\n#### This default permission set includes:\n\n- `allow-enable`\n- `allow-disable`\n- `allow-is-enabled`" + } + ] + } + } +} \ No newline at end of file diff --git a/plugins/autostart/rollup.config.js b/plugins/autostart/rollup.config.js new file mode 100644 index 00000000..1f349ec8 --- /dev/null +++ b/plugins/autostart/rollup.config.js @@ -0,0 +1,7 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import { createConfig } from '../../shared/rollup.config.js' + +export default createConfig() diff --git a/plugins/autostart/rollup.config.mjs b/plugins/autostart/rollup.config.mjs deleted file mode 100644 index 99a3dd31..00000000 --- a/plugins/autostart/rollup.config.mjs +++ /dev/null @@ -1,11 +0,0 @@ -import { readFileSync } from "fs"; - -import { createConfig } from "../../shared/rollup.config.mjs"; - -export default createConfig({ - input: "guest-js/index.ts", - pkg: JSON.parse( - readFileSync(new URL("./package.json", import.meta.url), "utf8"), - ), - external: [/^@tauri-apps\/api/], -}); diff --git a/plugins/autostart/src/api-iife.js b/plugins/autostart/src/api-iife.js deleted file mode 100644 index 6d879881..00000000 --- a/plugins/autostart/src/api-iife.js +++ /dev/null @@ -1 +0,0 @@ -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__})} diff --git a/plugins/autostart/src/lib.rs b/plugins/autostart/src/lib.rs index b4338208..4b4c7c23 100644 --- a/plugins/autostart/src/lib.rs +++ b/plugins/autostart/src/lib.rs @@ -2,8 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -//! [![](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/autostart/banner.png)](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/autostart) -//! //! Automatically launch your application at startup. Supports Windows, Mac (via AppleScript or Launch Agent), and Linux. #![doc( @@ -13,12 +11,10 @@ #![cfg(not(any(target_os = "android", target_os = "ios")))] use auto_launch::{AutoLaunch, AutoLaunchBuilder}; -#[cfg(target_os = "macos")] -use log::info; use serde::{ser::Serializer, Serialize}; use tauri::{ command, - plugin::{Builder, TauriPlugin}, + plugin::{Builder as PluginBuilder, TauriPlugin}, Manager, Runtime, State, }; @@ -26,8 +22,9 @@ use std::env::current_exe; type Result = std::result::Result; -#[derive(Debug, Copy, Clone)] +#[derive(Debug, Default, Copy, Clone)] pub enum MacosLauncher { + #[default] LaunchAgent, AppleScript, } @@ -75,10 +72,12 @@ impl AutoLaunchManager { } pub trait ManagerExt { + /// TODO: Rename these to `autostart` or `auto_start` in v3 fn autolaunch(&self) -> State<'_, AutoLaunchManager>; } impl> ManagerExt for T { + /// TODO: Rename these to `autostart` or `auto_start` in v3 fn autolaunch(&self) -> State<'_, AutoLaunchManager> { self.state::() } @@ -99,60 +98,153 @@ async fn is_enabled(manager: State<'_, AutoLaunchManager>) -> Result { manager.is_enabled() } +#[derive(Default)] +pub struct Builder { + #[cfg(target_os = "macos")] + macos_launcher: MacosLauncher, + args: Vec, + app_name: Option, +} + +impl Builder { + /// Create a new auto start builder with default settings + pub fn new() -> Self { + Self::default() + } + + /// Adds an argument to pass to your app on startup. + /// + /// ## Examples + /// + /// ```no_run + /// Builder::new() + /// .arg("--from-autostart") + /// .arg("--hey") + /// .build(); + /// ``` + pub fn arg>(mut self, arg: S) -> Self { + self.args.push(arg.into()); + self + } + + /// Adds multiple arguments to pass to your app on startup. + /// + /// ## Examples + /// + /// ```no_run + /// Builder::new() + /// .args(["--from-autostart", "--hey"]) + /// .build(); + /// ``` + pub fn args(mut self, args: I) -> Self + where + I: IntoIterator, + S: Into, + { + for arg in args { + self = self.arg(arg); + } + self + } + + /// Sets whether to use launch agent or apple script to be used to enable auto start, + /// the builder's default is [`MacosLauncher::LaunchAgent`] + #[cfg(target_os = "macos")] + pub fn macos_launcher(mut self, macos_launcher: MacosLauncher) -> Self { + self.macos_launcher = macos_launcher; + self + } + + /// Sets the app name to be used for the auto start entry. + /// + /// ## Examples + /// + /// ```no_run + /// Builder::new() + /// .app_name("My Custom Name")) + /// .build(); + /// ``` + pub fn app_name>(mut self, app_name: S) -> Self { + self.app_name = Some(app_name.into()); + self + } + + pub fn build(self) -> TauriPlugin { + PluginBuilder::new("autostart") + .invoke_handler(tauri::generate_handler![enable, disable, is_enabled]) + .setup(move |app, _api| { + let mut builder = AutoLaunchBuilder::new(); + + let app_name = self + .app_name + .as_ref() + .unwrap_or_else(|| &app.package_info().name); + builder.set_app_name(app_name); + + builder.set_args(&self.args); + + let current_exe = current_exe()?; + + #[cfg(windows)] + builder.set_app_path(¤t_exe.display().to_string()); + + #[cfg(target_os = "macos")] + { + builder.set_use_launch_agent(matches!( + self.macos_launcher, + MacosLauncher::LaunchAgent + )); + // on macOS, current_exe gives path to /Applications/Example.app/MacOS/Example + // but this results in seeing a Unix Executable in macOS login items + // It must be: /Applications/Example.app + // If it didn't find exactly a single occurance of .app, it will default to + // exe path to not break it. + let exe_path = current_exe.canonicalize()?.display().to_string(); + let parts: Vec<&str> = exe_path.split(".app/").collect(); + let app_path = if parts.len() == 2 + && matches!(self.macos_launcher, MacosLauncher::AppleScript) + { + format!("{}.app", parts.first().unwrap()) + } else { + exe_path + }; + builder.set_app_path(&app_path); + } + + #[cfg(target_os = "linux")] + if let Some(appimage) = app + .env() + .appimage + .and_then(|p| p.to_str().map(|s| s.to_string())) + { + builder.set_app_path(&appimage); + } else { + builder.set_app_path(¤t_exe.display().to_string()); + } + + app.manage(AutoLaunchManager( + builder.build().map_err(|e| e.to_string())?, + )); + Ok(()) + }) + .build() + } +} + /// Initializes the plugin. /// /// `args` - are passed to your app on startup. pub fn init( - macos_launcher: MacosLauncher, + #[allow(unused)] macos_launcher: MacosLauncher, args: Option>, ) -> TauriPlugin { - Builder::new("autostart") - .js_init_script(include_str!("api-iife.js").to_string()) - .invoke_handler(tauri::generate_handler![enable, disable, is_enabled]) - .setup(move |app, _api| { - let mut builder = AutoLaunchBuilder::new(); - builder.set_app_name(&app.package_info().name); - if let Some(args) = args { - builder.set_args(&args); - } - builder.set_use_launch_agent(matches!(macos_launcher, MacosLauncher::LaunchAgent)); - - let current_exe = current_exe()?; - - #[cfg(windows)] - builder.set_app_path(¤t_exe.display().to_string()); - #[cfg(target_os = "macos")] - { - // on macOS, current_exe gives path to /Applications/Example.app/MacOS/Example - // but this results in seeing a Unix Executable in macOS login items - // It must be: /Applications/Example.app - // If it didn't find exactly a single occurance of .app, it will default to - // exe path to not break it. - let exe_path = current_exe.canonicalize()?.display().to_string(); - let parts: Vec<&str> = exe_path.split(".app/").collect(); - let app_path = if parts.len() == 2 { - format!("{}.app", parts.first().unwrap()) - } else { - exe_path - }; - info!("auto_start path {}", &app_path); - builder.set_app_path(&app_path); - } - #[cfg(target_os = "linux")] - if let Some(appimage) = app - .env() - .appimage - .and_then(|p| p.to_str().map(|s| s.to_string())) - { - builder.set_app_path(&appimage); - } else { - builder.set_app_path(¤t_exe.display().to_string()); - } - - app.manage(AutoLaunchManager( - builder.build().map_err(|e| e.to_string())?, - )); - Ok(()) - }) - .build() + let mut builder = Builder::new(); + if let Some(args) = args { + builder = builder.args(args) + } + #[cfg(target_os = "macos")] + { + builder = builder.macos_launcher(macos_launcher); + } + builder.build() } diff --git a/plugins/barcode-scanner/CHANGELOG.md b/plugins/barcode-scanner/CHANGELOG.md index 99cb2cea..3fa878fd 100644 --- a/plugins/barcode-scanner/CHANGELOG.md +++ b/plugins/barcode-scanner/CHANGELOG.md @@ -1,5 +1,115 @@ # Changelog +## \[2.2.0] + +- [`3a79266b`](https://github.com/tauri-apps/plugins-workspace/commit/3a79266b8cf96a55b1ae6339d725567d45a44b1d) ([#2173](https://github.com/tauri-apps/plugins-workspace/pull/2173) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Bumped all plugins to `v2.2.0`. From now, the versions for the Rust and JavaScript packages of each plugin will be in sync with each other. + +## \[2.0.1] + +- [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. + +## \[2.0.0] + +- [`e2c4dfb6`](https://github.com/tauri-apps/plugins-workspace/commit/e2c4dfb6af43e5dd8d9ceba232c315f5febd55c1) Update to tauri v2 stable release. + +## \[2.0.0-rc.2] + +- [`79d6e19c`](https://github.com/tauri-apps/plugins-workspace/commit/79d6e19c4b38bae0cab29eb88df379e2237d9aac) ([#1777](https://github.com/tauri-apps/plugins-workspace/pull/1777)) Fixed an issue which caused checkPermission and requestPermission to be mixed up. + +## \[2.0.0-rc.4] + +- [`713c54ef`](https://github.com/tauri-apps/plugins-workspace/commit/713c54ef8365d36afd84585dcabed2fbb751223d) ([#1749](https://github.com/tauri-apps/plugins-workspace/pull/1749) by [@olivierlemasle](https://github.com/tauri-apps/plugins-workspace/../../olivierlemasle)) Remove unused Android dependencies. +- [`8c3a6a25`](https://github.com/tauri-apps/plugins-workspace/commit/8c3a6a253d7029d370659d2102f91a458745d345) ([#1758](https://github.com/tauri-apps/plugins-workspace/pull/1758) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Validate missing `NSCameraUsageDescription` Info.plist value. + +## \[2.0.0-rc.1] + +- [`e2e97db5`](https://github.com/tauri-apps/plugins-workspace/commit/e2e97db51983267f5be84d4f6f0278d58834d1f5) ([#1701](https://github.com/tauri-apps/plugins-workspace/pull/1701) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Use `PermissionState` from the `tauri` crate, which now also includes a "prompt with rationale" variant for Android (returned when your app must explain to the user why it needs the permission). +- [`e2e97db5`](https://github.com/tauri-apps/plugins-workspace/commit/e2e97db51983267f5be84d4f6f0278d58834d1f5) ([#1701](https://github.com/tauri-apps/plugins-workspace/pull/1701) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri 2.0.0-rc.8 + +## \[2.0.0-rc.2] + +- [`b9147758`](https://github.com/tauri-apps/plugins-workspace/commit/b914775898c2bee7ceb20bd17ee595005cd17a64) ([#1679](https://github.com/tauri-apps/plugins-workspace/pull/1679) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Explicitly set a minimum macOS version for the Swift package. + +## \[2.0.0-rc.1] + +- [`2c00c029`](https://github.com/tauri-apps/plugins-workspace/commit/2c00c0292c9127b81567de46691e8c0f73557261) ([#1630](https://github.com/tauri-apps/plugins-workspace/pull/1630) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Fixed an issue that caused multi-word IIFE names to not be formatted correctly. For example the `barcode-scanner` was defined as `window.__TAURI_PLUGIN_CLIPBOARDMANAGER__` instead of `window.__TAURI_PLUGIN_CLIPBOARD_MANAGER__`. + +### changes + +- [`6b079cfd`](https://github.com/tauri-apps/plugins-workspace/commit/6b079cfdd107c94abc2c7300f6af00bac3ff4040) ([#1649](https://github.com/tauri-apps/plugins-workspace/pull/1649) by [@ahqsoftwares](https://github.com/tauri-apps/plugins-workspace/../../ahqsoftwares)) Remove targetSdk from build.kts files as it is deprecated and will be removed from DSL v9.0 + +## \[2.0.0-rc.0] + +- [`9887d1`](https://github.com/tauri-apps/plugins-workspace/commit/9887d14bd0e971c4c0f5c1188fc4005d3fc2e29e) Update to tauri RC. + +## \[2.0.0-beta.8] + +- [`99d6ac0f`](https://github.com/tauri-apps/plugins-workspace/commit/99d6ac0f9506a6a4a1aa59c728157190a7441af6) ([#1606](https://github.com/tauri-apps/plugins-workspace/pull/1606) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) The JS packages now specify the *minimum* `@tauri-apps/api` version instead of a single exact version. +- [`6de87966`](https://github.com/tauri-apps/plugins-workspace/commit/6de87966ecc00ad9d91c25be452f1f46bd2b7e1f) ([#1597](https://github.com/tauri-apps/plugins-workspace/pull/1597) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Update to tauri beta.25. + +## \[2.0.0-beta.7] + +- [`22a17980`](https://github.com/tauri-apps/plugins-workspace/commit/22a17980ff4f6f8c40adb1b8f4ffc6dae2fe7e30) ([#1537](https://github.com/tauri-apps/plugins-workspace/pull/1537) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri beta.24. + +## \[2.0.0-beta.6] + +- [`76daee7a`](https://github.com/tauri-apps/plugins-workspace/commit/76daee7aafece34de3092c86e531cf9eb1138989) ([#1512](https://github.com/tauri-apps/plugins-workspace/pull/1512) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Update to tauri beta.23. + +## \[2.0.0-beta.5] + +- [`9013854f`](https://github.com/tauri-apps/plugins-workspace/commit/9013854f42a49a230b9dbb9d02774765528a923f)([#1382](https://github.com/tauri-apps/plugins-workspace/pull/1382)) Update to tauri beta.22. + +## \[2.0.0-beta.4] + +- [`430bd6f4`](https://github.com/tauri-apps/plugins-workspace/commit/430bd6f4f379bee5d232ae6b098ae131db7f178a)([#1363](https://github.com/tauri-apps/plugins-workspace/pull/1363)) Update to tauri beta.20. + +## \[2.0.0-beta.3] + +- [`bd1ed590`](https://github.com/tauri-apps/plugins-workspace/commit/bd1ed5903ffcce5500310dac1e59e8c67674ef1e)([#1237](https://github.com/tauri-apps/plugins-workspace/pull/1237)) Update to tauri beta.17. + +## \[2.0.0-beta.4] + +- [`326df688`](https://github.com/tauri-apps/plugins-workspace/commit/326df6883998d416fc0837583ed972854628bb52)([#1236](https://github.com/tauri-apps/plugins-workspace/pull/1236)) Fixes command argument parsing on iOS. + +## \[2.0.0-beta.3] + +- [`a04ea2f`](https://github.com/tauri-apps/plugins-workspace/commit/a04ea2f38294d5a3987578283badc8eec87a7752)([#1071](https://github.com/tauri-apps/plugins-workspace/pull/1071)) The global API script is now only added to the binary when the `withGlobalTauri` config is true. + +## \[2.0.0-beta.2] + +- [`99bea25`](https://github.com/tauri-apps/plugins-workspace/commit/99bea2559c2c0648c2519c50a18cd124dacef57b)([#1005](https://github.com/tauri-apps/plugins-workspace/pull/1005)) Update to tauri beta.8. + +## \[2.0.0-beta.1] + +- [`569defb`](https://github.com/tauri-apps/plugins-workspace/commit/569defbe9492e38938554bb7bdc1be9151456d21) Update to tauri beta.4. + +## \[2.0.0-beta.0] + +- [`d198c01`](https://github.com/tauri-apps/plugins-workspace/commit/d198c014863ee260cb0de88a14b7fc4356ef7474)([#862](https://github.com/tauri-apps/plugins-workspace/pull/862)) Update to tauri beta. +- [`d198c01`](https://github.com/tauri-apps/plugins-workspace/commit/d198c014863ee260cb0de88a14b7fc4356ef7474)([#862](https://github.com/tauri-apps/plugins-workspace/pull/862)) Add permissions. + +## \[2.0.0-alpha.4] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.13. + +## \[2.0.0-alpha.3] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.12. + +## \[2.0.0-alpha.2] + +- [`e438e0a`](https://github.com/tauri-apps/plugins-workspace/commit/e438e0a62d4b430a5159f05f13ecd397dd891a0d)([#676](https://github.com/tauri-apps/plugins-workspace/pull/676)) Update to @tauri-apps/api v2.0.0-alpha.11. + +## \[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.9. + ## \[2.0.0-alpha.0] - [`454428c`](https://github.com/tauri-apps/plugins-workspace/commit/454428cd50ce4962f0bad8e355aebc68af8cc61f)([#536](https://github.com/tauri-apps/plugins-workspace/pull/536)) Initial release. + commit/454428cd50ce4962f0bad8e355aebc68af8cc61f)([#536](https://github.com/tauri-apps/plugins-workspace/pull/536)) Initial release. + 36]\(https://github.com/tauri-apps/plugins-workspace/pull/536)) Initial release. + commit/454428cd50ce4962f0bad8e355aebc68af8cc61f)([#536](https://github.com/tauri-apps/plugins-workspace/pull/536)) Initial release. + . + commit/454428cd50ce4962f0bad8e355aebc68af8cc61f)([#536](https://github.com/tauri-apps/plugins-workspace/pull/536)) Initial release. + github.com/tauri-apps/plugins-workspace/pull/536)) Initial release. diff --git a/plugins/barcode-scanner/Cargo.toml b/plugins/barcode-scanner/Cargo.toml index 63762f18..018b4908 100644 --- a/plugins/barcode-scanner/Cargo.toml +++ b/plugins/barcode-scanner/Cargo.toml @@ -1,19 +1,29 @@ [package] name = "tauri-plugin-barcode-scanner" -version = "2.0.0-alpha.0" +version = "2.2.0" description = "Scan QR codes, EAN-13 and other kinds of barcodes on Android and iOS" edition = { workspace = true } authors = { workspace = true } license = { workspace = true } rust-version = { workspace = true } +repository = { workspace = true } links = "tauri-plugin-barcode-scanner" [package.metadata.docs.rs] -features = [ "dox" ] -targets = [ "x86_64-linux-android" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] +targets = ["x86_64-linux-android"] + +[package.metadata.platforms.support] +windows = { level = "none", notes = "" } +linux = { level = "none", notes = "" } +macos = { level = "none", notes = "" } +android = { level = "full", notes = "" } +ios = { level = "full", notes = "" } + [build-dependencies] -tauri-build = { workspace = true } +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } @@ -22,5 +32,5 @@ tauri = { workspace = true } log = { workspace = true } thiserror = { workspace = true } -[features] -dox = [ "tauri/dox" ] +[target.'cfg(target_os = "ios")'.dependencies] +tauri = { workspace = true, features = ["wry"] } diff --git a/plugins/barcode-scanner/README.md b/plugins/barcode-scanner/README.md index 30f6572f..4abbef0a 100644 --- a/plugins/barcode-scanner/README.md +++ b/plugins/barcode-scanner/README.md @@ -1,7 +1,15 @@ -![Barcode Scanner](banner.png) +![Barcode Scanner](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/barcode-scanner/banner.png) Allows your mobile application to use the camera to scan QR codes, EAN-13 and other kinds of barcodes. +| Platform | Supported | +| -------- | --------- | +| Linux | x | +| Windows | x | +| macOS | x | +| Android | ✓ | +| iOS | ✓ | + ## Install _This plugin requires a Rust version of at least **1.64**_ @@ -18,7 +26,7 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] -tauri-plugin-barcode-scanner = "2.0.0-alpha" +tauri-plugin-barcode-scanner = "2.0.0" # alternatively with Git: tauri-plugin-barcode-scanner = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -46,7 +54,7 @@ yarn add https://github.com/tauri-apps/tauri-plugin-barcode-scanner#v2 First you need to register the core plugin with Tauri: -`src-tauri/src/main.rs` +`src-tauri/src/lib.rs` ```rust fn main() { @@ -60,12 +68,12 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import { scan } from "@tauri-apps/plugin-barcode-scanner"; +import { scan } from '@tauri-apps/plugin-barcode-scanner' // `windowed: true` actually sets the webview to transparent // instead of opening a separate view for the camera // make sure your user interface is ready to show what is underneath with a transparent element -scan({ windowed: true, formats: [""] }) +scan({ windowed: true, formats: [''] }) ``` ## Contributing @@ -91,6 +99,22 @@ PRs accepted. Please make sure to read the Contributing Guide before making a pu +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + ## License Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. diff --git a/plugins/barcode-scanner/SECURITY.md b/plugins/barcode-scanner/SECURITY.md new file mode 100644 index 00000000..135504ec --- /dev/null +++ b/plugins/barcode-scanner/SECURITY.md @@ -0,0 +1,65 @@ +# Security Policy + +**Do not report security vulnerabilities through public GitHub issues.** + +**Please use the [Private Vulnerability Disclosure](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) feature of GitHub.** + +Include as much of the following information: + +- Type of issue (e.g. improper input parsing, privilege escalation, etc.) +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- The distribution affected or used to help us with reproduction of the issue +- Step-by-step instructions to reproduce the issue +- Ideally a reproduction repository +- Impact of the issue, including how an attacker might exploit the issue + +We prefer to receive reports in English. + +## Contact + +Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). + +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). + +## Threat Model + +As there are only the `scan` and `cancel` commands exposed to the frontend, +there is no additional risk or exposure of additional information. +Only barcodes are passed and no raw camera access is used, which means no images are available to the frontend. + +The application is only usable on iOS and Android and therefore the specific mobile operating system security boundaries need to be considered. + +### Security Assumptions + +- The QR code parsing into a link/text is trusted and correctly handled by the mobile operating system +- The link itself is untrusted and additional validation/sanitization needs to be handled by the app developer +- The camera is not passing images to the app +- The camera permission is granted at first use by the user and can be revoked at any time +- The Android manifest also states that the camera permission is required + +### Threats + +#### Silent Interaction + +##### When is it possible? + +The following threat is either caused by a malicious developer, which has further implications and should be considered as a full compromise of an application or system, or by +compromise of the application frontend. In the second case there are several impact minimization methods (e.g. the CSP) and if all of these fail the possible risk could occur. +Therefore it is unlikely to occur in most cases but should be considered when using this plugin. + +##### What is possible? + +The camera has two modes. The first one is where the user can see the background camera image and no further interaction is possible. +The second mode allows the developer to assist the user and add a transparent overlay to the image, providing hints or additional information (like a link preview). +The overlay could be made non-transparent by the application frontend and as long as the app is open (and in some cases) it could read QR codes in range of the camera lense. + +#### Out Of Scope + +- Exploits in the operating system QR code parsing functionality +- Exploits based on the string passed to the application using this plugin +- Continous camera/QR scan usage even when application is in background + +## Best Practices + +There is no additional exposure aside from reading barcodes in the webview and there are no specific best practices for secure usage. diff --git a/plugins/barcode-scanner/android/build.gradle.kts b/plugins/barcode-scanner/android/build.gradle.kts index 8b060f64..f3ecd6c7 100644 --- a/plugins/barcode-scanner/android/build.gradle.kts +++ b/plugins/barcode-scanner/android/build.gradle.kts @@ -5,11 +5,10 @@ plugins { android { namespace = "app.tauri.barcodescanner" - compileSdk = 32 + compileSdk = 34 defaultConfig { - minSdk = 24 - targetSdk = 32 + minSdk = 24 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles("consumer-rules.pro") @@ -48,9 +47,5 @@ dependencies { testImplementation("junit:junit:4.13.2") androidTestImplementation("androidx.test.ext:junit:1.1.5") androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") - implementation("com.journeyapps:zxing-android-embedded:4.3.0") { - isTransitive = false - } - implementation("com.google.zxing:core:3.3.0") implementation(project(":tauri-android")) } diff --git a/plugins/barcode-scanner/android/src/main/AndroidManifest.xml b/plugins/barcode-scanner/android/src/main/AndroidManifest.xml index b4050b4f..750a724b 100644 --- a/plugins/barcode-scanner/android/src/main/AndroidManifest.xml +++ b/plugins/barcode-scanner/android/src/main/AndroidManifest.xml @@ -2,10 +2,8 @@ xmlns:tools="http://schemas.android.com/tools" android:hardwareAccelerated="true"> - - - - - + + + diff --git a/plugins/barcode-scanner/android/src/main/java/BarcodeScannerPlugin.kt b/plugins/barcode-scanner/android/src/main/java/BarcodeScannerPlugin.kt index 5d8a0154..ef2eeb34 100644 --- a/plugins/barcode-scanner/android/src/main/java/BarcodeScannerPlugin.kt +++ b/plugins/barcode-scanner/android/src/main/java/BarcodeScannerPlugin.kt @@ -37,11 +37,11 @@ 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 import app.tauri.plugin.Invoke -import app.tauri.plugin.JSArray import app.tauri.plugin.JSObject import app.tauri.plugin.Plugin import com.google.common.util.concurrent.ListenableFuture @@ -49,7 +49,6 @@ import com.google.mlkit.vision.barcode.BarcodeScannerOptions import com.google.mlkit.vision.barcode.BarcodeScanning import com.google.mlkit.vision.barcode.common.Barcode import com.google.mlkit.vision.common.InputImage -import org.json.JSONException import java.util.Collections import java.util.concurrent.ExecutionException @@ -57,6 +56,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 +212,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 +340,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/android/src/main/java/GraphicOverlay.kt b/plugins/barcode-scanner/android/src/main/java/GraphicOverlay.kt index 76817540..1b1d3b2c 100644 --- a/plugins/barcode-scanner/android/src/main/java/GraphicOverlay.kt +++ b/plugins/barcode-scanner/android/src/main/java/GraphicOverlay.kt @@ -91,22 +91,10 @@ class GraphicOverlay: View { return } - val zLowerBoundInScreenPixel: Float - val zUpperBoundInScreenPixel: Float - if (rescaleZForVisualization) { - zLowerBoundInScreenPixel = (-0.001f).coerceAtMost(scale(zMin)) - zUpperBoundInScreenPixel = 0.001f.coerceAtLeast(scale(zMax)) - } else { - val defaultRangeFactor = 1f - zLowerBoundInScreenPixel = -defaultRangeFactor * canvas.width - zUpperBoundInScreenPixel = defaultRangeFactor * canvas.width - } val zInScreenPixel = scale(zInImagePixel) if (zInScreenPixel < 0) { - val v = (zInScreenPixel / zLowerBoundInScreenPixel * 255).toInt() paint.setARGB(0, 0, 255, 0) } else { - val v = (zInScreenPixel / zUpperBoundInScreenPixel * 255).toInt() paint.setARGB(0, 0, 255, 0) } } @@ -180,7 +168,7 @@ class GraphicOverlay: View { needUpdateTransformation = false } - override fun onDraw(canvas: Canvas?) { + override fun onDraw(canvas: Canvas) { super.onDraw(canvas) synchronized(lock) { updateTransformationIfNeeded() diff --git a/plugins/barcode-scanner/api-iife.js b/plugins/barcode-scanner/api-iife.js new file mode 100644 index 00000000..620b59a7 --- /dev/null +++ b/plugins/barcode-scanner/api-iife.js @@ -0,0 +1 @@ +if("__TAURI__"in window){var __TAURI_PLUGIN_BARCODE_SCANNER__=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(){await e("plugin:barcode-scanner|cancel")},n.checkPermissions=async function(){return await async function(n){return e(`plugin:${n}|check_permissions`)}("barcode-scanner").then((n=>n.camera))},n.openAppSettings=async function(){await e("plugin:barcode-scanner|open_app_settings")},n.requestPermissions=async function(){return await async function(n){return e(`plugin:${n}|request_permissions`)}("barcode-scanner").then((n=>n.camera))},n.scan=async function(n){return await e("plugin:barcode-scanner|scan",{...n})},n}({});Object.defineProperty(window.__TAURI__,"barcodeScanner",{value:__TAURI_PLUGIN_BARCODE_SCANNER__})} diff --git a/plugins/barcode-scanner/build.rs b/plugins/barcode-scanner/build.rs index ea12ef85..25896b57 100644 --- a/plugins/barcode-scanner/build.rs +++ b/plugins/barcode-scanner/build.rs @@ -2,16 +2,24 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT +const COMMANDS: &[&str] = &[ + "scan", + "cancel", + "request_permissions", + "check_permissions", + "open_app_settings", + "vibrate", +]; + fn main() { - if let Err(error) = tauri_build::mobile::PluginBuilder::new() + let result = tauri_plugin::Builder::new(COMMANDS) + .global_api_script_path("./api-iife.js") .android_path("android") .ios_path("ios") - .run() - { - 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")) { - std::process::exit(1); - } + .try_build(); + + // when building documentation for Android the plugin build result is always Err() and is irrelevant to the crate documentation build + if !(cfg!(docsrs) && std::env::var("TARGET").unwrap().contains("android")) { + result.unwrap(); } } diff --git a/plugins/barcode-scanner/guest-js/index.ts b/plugins/barcode-scanner/guest-js/index.ts index 5464c1af..2f2361be 100644 --- a/plugins/barcode-scanner/guest-js/index.ts +++ b/plugins/barcode-scanner/guest-js/index.ts @@ -2,36 +2,40 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { invoke } from "@tauri-apps/api/primitives"; +import { + invoke, + requestPermissions as requestPermissions_, + checkPermissions as checkPermissions_ +} from '@tauri-apps/api/core' -export type PermissionState = "granted" | "denied" | "prompt"; +export type { PermissionState } from '@tauri-apps/api/core' export enum Format { - QRCode = "QR_CODE", - UPC_A = "UPC_A", - UPC_E = "UPC_E", - EAN8 = "EAN_8", - EAN13 = "EAN_13", - Code39 = "CODE_39", - Code93 = "CODE_93", - Code128 = "CODE_128", - Codabar = "CODABAR", - ITF = "ITF", - Aztec = "AZTEC", - DataMatrix = "DATA_MATRIX", - PDF417 = "PDF_417", + QRCode = 'QR_CODE', + UPC_A = 'UPC_A', + UPC_E = 'UPC_E', + EAN8 = 'EAN_8', + EAN13 = 'EAN_13', + Code39 = 'CODE_39', + Code93 = 'CODE_93', + Code128 = 'CODE_128', + Codabar = 'CODABAR', + ITF = 'ITF', + Aztec = 'AZTEC', + DataMatrix = 'DATA_MATRIX', + PDF417 = 'PDF_417' } export interface ScanOptions { - cameraDirection?: "back" | "front"; - formats?: Format[]; - windowed?: boolean; + cameraDirection?: 'back' | 'front' + formats?: Format[] + windowed?: boolean } export interface Scanned { - content: string; - format: Format; - bounds: unknown; + content: string + format: Format + bounds: unknown } /** @@ -39,37 +43,37 @@ export interface Scanned { * @param options */ export async function scan(options?: ScanOptions): Promise { - return await invoke("plugin:barcodeScanner|scan", { ...options }); + return await invoke('plugin:barcode-scanner|scan', { ...options }) } /** * Cancel the current scan process. */ export async function cancel(): Promise { - return await invoke("plugin:barcodeScanner|cancel"); + await invoke('plugin:barcode-scanner|cancel') } /** * Get permission state. */ export async function checkPermissions(): Promise { - return await invoke<{ camera: PermissionState }>( - "plugin:barcodeScanner|checkPermissions", - ).then((r) => r.camera); + return await checkPermissions_<{ camera: PermissionState }>( + 'barcode-scanner' + ).then((r) => r.camera) } /** * Request permissions to use the camera. */ export async function requestPermissions(): Promise { - return await invoke<{ camera: PermissionState }>( - "plugin:barcodeScanner|requestPermissions", - ).then((r) => r.camera); + return await requestPermissions_<{ camera: PermissionState }>( + 'barcode-scanner' + ).then((r) => r.camera) } /** * Open application settings. Useful if permission was denied and the user must manually enable it. */ export async function openAppSettings(): Promise { - return await invoke("plugin:barcodeScanner|openAppSettings"); + await invoke('plugin:barcode-scanner|open_app_settings') } diff --git a/plugins/barcode-scanner/ios/Package.swift b/plugins/barcode-scanner/ios/Package.swift index aafb41c3..cf39b812 100644 --- a/plugins/barcode-scanner/ios/Package.swift +++ b/plugins/barcode-scanner/ios/Package.swift @@ -10,7 +10,8 @@ import PackageDescription let package = Package( name: "tauri-plugin-barcode-scanner", platforms: [ - .iOS(.v13) + .macOS(.v10_13), + .iOS(.v13), ], products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. diff --git a/plugins/barcode-scanner/ios/Sources/BarcodeScannerPlugin.swift b/plugins/barcode-scanner/ios/Sources/BarcodeScannerPlugin.swift index b86f1488..cde8d680 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]? + var windowed: Bool? + var 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,9 +257,18 @@ 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 + let entry = Bundle.main.infoDictionary?["NSCameraUsageDescription"] as? String + + if entry == nil || entry?.count == 0 { + invoke.reject("NSCameraUsageDescription is not in the app Info.plist") + return + } + var iOS14min: Bool = false if #available(iOS 14.0, *) { iOS14min = true } if !iOS14min && self.getPermissionState() != "granted" { @@ -279,10 +286,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 b6855276..9e8c8b56 100644 --- a/plugins/barcode-scanner/package.json +++ b/plugins/barcode-scanner/package.json @@ -1,33 +1,30 @@ { "name": "@tauri-apps/plugin-barcode-scanner", - "version": "2.0.0-alpha.0", + "version": "2.2.0", "description": "Scan QR codes, EAN-13 and other kinds of barcodes on Android and iOS", - "license": "MIT or APACHE-2.0", + "license": "MIT OR Apache-2.0", "authors": [ "Tauri Programme within The Commons Conservancy" ], + "repository": "https://github.com/tauri-apps/plugins-workspace", "type": "module", - "browser": "dist-js/index.min.js", - "module": "dist-js/index.mjs", - "types": "dist-js/index.d.ts", + "types": "./dist-js/index.d.ts", + "main": "./dist-js/index.cjs", + "module": "./dist-js/index.js", "exports": { - "import": "./dist-js/index.mjs", "types": "./dist-js/index.d.ts", - "browser": "./dist-js/index.min.js" + "import": "./dist-js/index.js", + "require": "./dist-js/index.cjs" }, "scripts": { "build": "rollup -c" }, "files": [ "dist-js", - "!dist-js/**/*.map", "README.md", "LICENSE" ], - "devDependencies": { - "tslib": "^2.5.0" - }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.9" + "@tauri-apps/api": "^2.0.0" } } diff --git a/plugins/barcode-scanner/permissions/autogenerated/commands/cancel.toml b/plugins/barcode-scanner/permissions/autogenerated/commands/cancel.toml new file mode 100644 index 00000000..91efeaa0 --- /dev/null +++ b/plugins/barcode-scanner/permissions/autogenerated/commands/cancel.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-cancel" +description = "Enables the cancel command without any pre-configured scope." +commands.allow = ["cancel"] + +[[permission]] +identifier = "deny-cancel" +description = "Denies the cancel command without any pre-configured scope." +commands.deny = ["cancel"] diff --git a/plugins/barcode-scanner/permissions/autogenerated/commands/check_permissions.toml b/plugins/barcode-scanner/permissions/autogenerated/commands/check_permissions.toml new file mode 100644 index 00000000..f5af08b1 --- /dev/null +++ b/plugins/barcode-scanner/permissions/autogenerated/commands/check_permissions.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-check-permissions" +description = "Enables the check_permissions command without any pre-configured scope." +commands.allow = ["check_permissions"] + +[[permission]] +identifier = "deny-check-permissions" +description = "Denies the check_permissions command without any pre-configured scope." +commands.deny = ["check_permissions"] diff --git a/plugins/barcode-scanner/permissions/autogenerated/commands/open_app_settings.toml b/plugins/barcode-scanner/permissions/autogenerated/commands/open_app_settings.toml new file mode 100644 index 00000000..9da98d85 --- /dev/null +++ b/plugins/barcode-scanner/permissions/autogenerated/commands/open_app_settings.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-open-app-settings" +description = "Enables the open_app_settings command without any pre-configured scope." +commands.allow = ["open_app_settings"] + +[[permission]] +identifier = "deny-open-app-settings" +description = "Denies the open_app_settings command without any pre-configured scope." +commands.deny = ["open_app_settings"] diff --git a/plugins/barcode-scanner/permissions/autogenerated/commands/request_permissions.toml b/plugins/barcode-scanner/permissions/autogenerated/commands/request_permissions.toml new file mode 100644 index 00000000..02dcd627 --- /dev/null +++ b/plugins/barcode-scanner/permissions/autogenerated/commands/request_permissions.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-request-permissions" +description = "Enables the request_permissions command without any pre-configured scope." +commands.allow = ["request_permissions"] + +[[permission]] +identifier = "deny-request-permissions" +description = "Denies the request_permissions command without any pre-configured scope." +commands.deny = ["request_permissions"] diff --git a/plugins/barcode-scanner/permissions/autogenerated/commands/scan.toml b/plugins/barcode-scanner/permissions/autogenerated/commands/scan.toml new file mode 100644 index 00000000..efa621dd --- /dev/null +++ b/plugins/barcode-scanner/permissions/autogenerated/commands/scan.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-scan" +description = "Enables the scan command without any pre-configured scope." +commands.allow = ["scan"] + +[[permission]] +identifier = "deny-scan" +description = "Denies the scan command without any pre-configured scope." +commands.deny = ["scan"] diff --git a/plugins/barcode-scanner/permissions/autogenerated/commands/vibrate.toml b/plugins/barcode-scanner/permissions/autogenerated/commands/vibrate.toml new file mode 100644 index 00000000..4c2fe94e --- /dev/null +++ b/plugins/barcode-scanner/permissions/autogenerated/commands/vibrate.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-vibrate" +description = "Enables the vibrate command without any pre-configured scope." +commands.allow = ["vibrate"] + +[[permission]] +identifier = "deny-vibrate" +description = "Denies the vibrate command without any pre-configured scope." +commands.deny = ["vibrate"] diff --git a/plugins/barcode-scanner/permissions/autogenerated/reference.md b/plugins/barcode-scanner/permissions/autogenerated/reference.md new file mode 100644 index 00000000..9cc9f3c6 --- /dev/null +++ b/plugins/barcode-scanner/permissions/autogenerated/reference.md @@ -0,0 +1,185 @@ +## Default Permission + +This permission set configures which +barcode scanning features are by default exposed. + +#### Granted Permissions + +It allows all barcode related features. + + + +#### This default permission set includes the following: + +- `allow-cancel` +- `allow-check-permissions` +- `allow-open-app-settings` +- `allow-request-permissions` +- `allow-scan` +- `allow-vibrate` + +## Permission Table + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IdentifierDescription
+ +`barcode-scanner:allow-cancel` + + + +Enables the cancel command without any pre-configured scope. + +
+ +`barcode-scanner:deny-cancel` + + + +Denies the cancel command without any pre-configured scope. + +
+ +`barcode-scanner:allow-check-permissions` + + + +Enables the check_permissions command without any pre-configured scope. + +
+ +`barcode-scanner:deny-check-permissions` + + + +Denies the check_permissions command without any pre-configured scope. + +
+ +`barcode-scanner:allow-open-app-settings` + + + +Enables the open_app_settings command without any pre-configured scope. + +
+ +`barcode-scanner:deny-open-app-settings` + + + +Denies the open_app_settings command without any pre-configured scope. + +
+ +`barcode-scanner:allow-request-permissions` + + + +Enables the request_permissions command without any pre-configured scope. + +
+ +`barcode-scanner:deny-request-permissions` + + + +Denies the request_permissions command without any pre-configured scope. + +
+ +`barcode-scanner:allow-scan` + + + +Enables the scan command without any pre-configured scope. + +
+ +`barcode-scanner:deny-scan` + + + +Denies the scan command without any pre-configured scope. + +
+ +`barcode-scanner:allow-vibrate` + + + +Enables the vibrate command without any pre-configured scope. + +
+ +`barcode-scanner:deny-vibrate` + + + +Denies the vibrate command without any pre-configured scope. + +
diff --git a/plugins/barcode-scanner/permissions/default.toml b/plugins/barcode-scanner/permissions/default.toml new file mode 100644 index 00000000..3b5a2dfd --- /dev/null +++ b/plugins/barcode-scanner/permissions/default.toml @@ -0,0 +1,20 @@ +"$schema" = "schemas/schema.json" +[default] +description = """ +This permission set configures which +barcode scanning features are by default exposed. + +#### Granted Permissions + +It allows all barcode related features. + +""" + +permissions = [ + "allow-cancel", + "allow-check-permissions", + "allow-open-app-settings", + "allow-request-permissions", + "allow-scan", + "allow-vibrate", +] diff --git a/plugins/barcode-scanner/permissions/schemas/schema.json b/plugins/barcode-scanner/permissions/schemas/schema.json new file mode 100644 index 00000000..69fb0d5d --- /dev/null +++ b/plugins/barcode-scanner/permissions/schemas/schema.json @@ -0,0 +1,378 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "PermissionFile", + "description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.", + "type": "object", + "properties": { + "default": { + "description": "The default permission set for the plugin", + "anyOf": [ + { + "$ref": "#/definitions/DefaultPermission" + }, + { + "type": "null" + } + ] + }, + "set": { + "description": "A list of permissions sets defined", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionSet" + } + }, + "permission": { + "description": "A list of inlined permissions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Permission" + } + } + }, + "definitions": { + "DefaultPermission": { + "description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.", + "type": "object", + "required": [ + "permissions" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "PermissionSet": { + "description": "A set of direct permissions grouped together under a new name.", + "type": "object", + "required": [ + "description", + "identifier", + "permissions" + ], + "properties": { + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does.", + "type": "string" + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionKind" + } + } + } + }, + "Permission": { + "description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.", + "type": "object", + "required": [ + "identifier" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri internal convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "commands": { + "description": "Allowed or denied commands when using this permission.", + "default": { + "allow": [], + "deny": [] + }, + "allOf": [ + { + "$ref": "#/definitions/Commands" + } + ] + }, + "scope": { + "description": "Allowed or denied scoped when using this permission.", + "allOf": [ + { + "$ref": "#/definitions/Scopes" + } + ] + }, + "platforms": { + "description": "Target platforms this permission applies. By default all platforms are affected by this permission.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Target" + } + } + } + }, + "Commands": { + "description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.", + "type": "object", + "properties": { + "allow": { + "description": "Allowed command.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "deny": { + "description": "Denied command, which takes priority.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "Scopes": { + "description": "An argument for fine grained behavior control of Tauri commands.\n\nIt can be of any serde serializable type and is used to allow or prevent certain actions inside a Tauri command. The configured scope is passed to the command and will be enforced by the command implementation.\n\n## Example\n\n```json { \"allow\": [{ \"path\": \"$HOME/**\" }], \"deny\": [{ \"path\": \"$HOME/secret.txt\" }] } ```", + "type": "object", + "properties": { + "allow": { + "description": "Data that defines what is allowed by the scope.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + }, + "deny": { + "description": "Data that defines what is denied by the scope. This should be prioritized by validation logic.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + } + } + }, + "Value": { + "description": "All supported ACL values.", + "anyOf": [ + { + "description": "Represents a null JSON value.", + "type": "null" + }, + { + "description": "Represents a [`bool`].", + "type": "boolean" + }, + { + "description": "Represents a valid ACL [`Number`].", + "allOf": [ + { + "$ref": "#/definitions/Number" + } + ] + }, + { + "description": "Represents a [`String`].", + "type": "string" + }, + { + "description": "Represents a list of other [`Value`]s.", + "type": "array", + "items": { + "$ref": "#/definitions/Value" + } + }, + { + "description": "Represents a map of [`String`] keys to [`Value`]s.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/Value" + } + } + ] + }, + "Number": { + "description": "A valid ACL number.", + "anyOf": [ + { + "description": "Represents an [`i64`].", + "type": "integer", + "format": "int64" + }, + { + "description": "Represents a [`f64`].", + "type": "number", + "format": "double" + } + ] + }, + "Target": { + "description": "Platform target.", + "oneOf": [ + { + "description": "MacOS.", + "type": "string", + "enum": [ + "macOS" + ] + }, + { + "description": "Windows.", + "type": "string", + "enum": [ + "windows" + ] + }, + { + "description": "Linux.", + "type": "string", + "enum": [ + "linux" + ] + }, + { + "description": "Android.", + "type": "string", + "enum": [ + "android" + ] + }, + { + "description": "iOS.", + "type": "string", + "enum": [ + "iOS" + ] + } + ] + }, + "PermissionKind": { + "type": "string", + "oneOf": [ + { + "description": "Enables the cancel command without any pre-configured scope.", + "type": "string", + "const": "allow-cancel", + "markdownDescription": "Enables the cancel command without any pre-configured scope." + }, + { + "description": "Denies the cancel command without any pre-configured scope.", + "type": "string", + "const": "deny-cancel", + "markdownDescription": "Denies the cancel command without any pre-configured scope." + }, + { + "description": "Enables the check_permissions command without any pre-configured scope.", + "type": "string", + "const": "allow-check-permissions", + "markdownDescription": "Enables the check_permissions command without any pre-configured scope." + }, + { + "description": "Denies the check_permissions command without any pre-configured scope.", + "type": "string", + "const": "deny-check-permissions", + "markdownDescription": "Denies the check_permissions command without any pre-configured scope." + }, + { + "description": "Enables the open_app_settings command without any pre-configured scope.", + "type": "string", + "const": "allow-open-app-settings", + "markdownDescription": "Enables the open_app_settings command without any pre-configured scope." + }, + { + "description": "Denies the open_app_settings command without any pre-configured scope.", + "type": "string", + "const": "deny-open-app-settings", + "markdownDescription": "Denies the open_app_settings command without any pre-configured scope." + }, + { + "description": "Enables the request_permissions command without any pre-configured scope.", + "type": "string", + "const": "allow-request-permissions", + "markdownDescription": "Enables the request_permissions command without any pre-configured scope." + }, + { + "description": "Denies the request_permissions command without any pre-configured scope.", + "type": "string", + "const": "deny-request-permissions", + "markdownDescription": "Denies the request_permissions command without any pre-configured scope." + }, + { + "description": "Enables the scan command without any pre-configured scope.", + "type": "string", + "const": "allow-scan", + "markdownDescription": "Enables the scan command without any pre-configured scope." + }, + { + "description": "Denies the scan command without any pre-configured scope.", + "type": "string", + "const": "deny-scan", + "markdownDescription": "Denies the scan command without any pre-configured scope." + }, + { + "description": "Enables the vibrate command without any pre-configured scope.", + "type": "string", + "const": "allow-vibrate", + "markdownDescription": "Enables the vibrate command without any pre-configured scope." + }, + { + "description": "Denies the vibrate command without any pre-configured scope.", + "type": "string", + "const": "deny-vibrate", + "markdownDescription": "Denies the vibrate command without any pre-configured scope." + }, + { + "description": "This permission set configures which\nbarcode scanning features are by default exposed.\n\n#### Granted Permissions\n\nIt allows all barcode related features.\n\n\n#### This default permission set includes:\n\n- `allow-cancel`\n- `allow-check-permissions`\n- `allow-open-app-settings`\n- `allow-request-permissions`\n- `allow-scan`\n- `allow-vibrate`", + "type": "string", + "const": "default", + "markdownDescription": "This permission set configures which\nbarcode scanning features are by default exposed.\n\n#### Granted Permissions\n\nIt allows all barcode related features.\n\n\n#### This default permission set includes:\n\n- `allow-cancel`\n- `allow-check-permissions`\n- `allow-open-app-settings`\n- `allow-request-permissions`\n- `allow-scan`\n- `allow-vibrate`" + } + ] + } + } +} \ No newline at end of file diff --git a/plugins/barcode-scanner/rollup.config.js b/plugins/barcode-scanner/rollup.config.js new file mode 100644 index 00000000..1f349ec8 --- /dev/null +++ b/plugins/barcode-scanner/rollup.config.js @@ -0,0 +1,7 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import { createConfig } from '../../shared/rollup.config.js' + +export default createConfig() diff --git a/plugins/barcode-scanner/rollup.config.mjs b/plugins/barcode-scanner/rollup.config.mjs deleted file mode 100644 index 99a3dd31..00000000 --- a/plugins/barcode-scanner/rollup.config.mjs +++ /dev/null @@ -1,11 +0,0 @@ -import { readFileSync } from "fs"; - -import { createConfig } from "../../shared/rollup.config.mjs"; - -export default createConfig({ - input: "guest-js/index.ts", - pkg: JSON.parse( - readFileSync(new URL("./package.json", import.meta.url), "utf8"), - ), - external: [/^@tauri-apps\/api/], -}); diff --git a/plugins/barcode-scanner/src/api-iife.js b/plugins/barcode-scanner/src/api-iife.js deleted file mode 100644 index adbdc978..00000000 --- a/plugins/barcode-scanner/src/api-iife.js +++ /dev/null @@ -1 +0,0 @@ -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__})} diff --git a/plugins/barcode-scanner/src/lib.rs b/plugins/barcode-scanner/src/lib.rs index 0ca82036..2f2e7ee9 100644 --- a/plugins/barcode-scanner/src/lib.rs +++ b/plugins/barcode-scanner/src/lib.rs @@ -27,7 +27,7 @@ pub struct BarcodeScanner(PluginHandle); impl BarcodeScanner {} -/// Extensions to [`tauri::App`], [`tauri::AppHandle`] and [`tauri::Window`] to access the barcode scanner APIs. +/// Extensions to [`tauri::App`], [`tauri::AppHandle`], [`tauri::WebviewWindow`], [`tauri::Webview`] and [`tauri::Window`] to access the barcode scanner APIs. pub trait BarcodeScannerExt { fn barcode_scanner(&self) -> &BarcodeScanner; } @@ -40,7 +40,7 @@ impl> crate::BarcodeScannerExt for T { /// Initializes the plugin. pub fn init() -> TauriPlugin { - Builder::new("barcodeScanner") + Builder::new("barcode-scanner") .setup(|app, api| { #[cfg(target_os = "android")] let handle = api.register_android_plugin(PLUGIN_IDENTIFIER, "BarcodeScannerPlugin")?; diff --git a/plugins/biometric/CHANGELOG.md b/plugins/biometric/CHANGELOG.md new file mode 100644 index 00000000..5ebbe50f --- /dev/null +++ b/plugins/biometric/CHANGELOG.md @@ -0,0 +1,94 @@ +# Changelog + +## \[2.2.1] + +### bug + +- [`10f9e66e`](https://github.com/tauri-apps/plugins-workspace/commit/10f9e66e32141dd35f4bf884fbf9102691187e92) ([#2633](https://github.com/tauri-apps/plugins-workspace/pull/2633) by [@pjf-dev](https://github.com/tauri-apps/plugins-workspace/../../pjf-dev)) Fix biometric plugin ignoring fallback logic when biometry status is unavailable or not enrolled on iOS. + +## \[2.2.0] + +- [`3a79266b`](https://github.com/tauri-apps/plugins-workspace/commit/3a79266b8cf96a55b1ae6339d725567d45a44b1d) ([#2173](https://github.com/tauri-apps/plugins-workspace/pull/2173) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Bumped all plugins to `v2.2.0`. From now, the versions for the Rust and JavaScript packages of each plugin will be in sync with each other. + +## \[2.0.1] + +- [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. + +## \[2.0.0] + +- [`e2c4dfb6`](https://github.com/tauri-apps/plugins-workspace/commit/e2c4dfb6af43e5dd8d9ceba232c315f5febd55c1) Update to tauri v2 stable release. + +## \[2.0.0-rc.1] + +- [`e2e97db5`](https://github.com/tauri-apps/plugins-workspace/commit/e2e97db51983267f5be84d4f6f0278d58834d1f5) ([#1701](https://github.com/tauri-apps/plugins-workspace/pull/1701) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri 2.0.0-rc.8 + +## \[2.0.0-rc.2] + +- [`b9147758`](https://github.com/tauri-apps/plugins-workspace/commit/b914775898c2bee7ceb20bd17ee595005cd17a64) ([#1679](https://github.com/tauri-apps/plugins-workspace/pull/1679) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Explicitly set a minimum macOS version for the Swift package. + +## \[2.0.0-rc.1] + +### changes + +- [`6b079cfd`](https://github.com/tauri-apps/plugins-workspace/commit/6b079cfdd107c94abc2c7300f6af00bac3ff4040) ([#1649](https://github.com/tauri-apps/plugins-workspace/pull/1649) by [@ahqsoftwares](https://github.com/tauri-apps/plugins-workspace/../../ahqsoftwares)) Remove targetSdk from build.kts files as it is deprecated and will be removed from DSL v9.0 + +## \[2.0.0-rc.0] + +- [`9887d1`](https://github.com/tauri-apps/plugins-workspace/commit/9887d14bd0e971c4c0f5c1188fc4005d3fc2e29e) Update to tauri RC. + +## \[2.0.0-beta.8] + +- [`99d6ac0f`](https://github.com/tauri-apps/plugins-workspace/commit/99d6ac0f9506a6a4a1aa59c728157190a7441af6) ([#1606](https://github.com/tauri-apps/plugins-workspace/pull/1606) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) The JS packages now specify the *minimum* `@tauri-apps/api` version instead of a single exact version. +- [`6de87966`](https://github.com/tauri-apps/plugins-workspace/commit/6de87966ecc00ad9d91c25be452f1f46bd2b7e1f) ([#1597](https://github.com/tauri-apps/plugins-workspace/pull/1597) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Update to tauri beta.25. + +## \[2.0.0-beta.7] + +- [`22a17980`](https://github.com/tauri-apps/plugins-workspace/commit/22a17980ff4f6f8c40adb1b8f4ffc6dae2fe7e30) ([#1537](https://github.com/tauri-apps/plugins-workspace/pull/1537) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri beta.24. + +## \[2.0.0-beta.6] + +- [`76daee7a`](https://github.com/tauri-apps/plugins-workspace/commit/76daee7aafece34de3092c86e531cf9eb1138989) ([#1512](https://github.com/tauri-apps/plugins-workspace/pull/1512) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Update to tauri beta.23. + +## \[2.0.0-beta.5] + +- [`9013854f`](https://github.com/tauri-apps/plugins-workspace/commit/9013854f42a49a230b9dbb9d02774765528a923f)([#1382](https://github.com/tauri-apps/plugins-workspace/pull/1382)) Update to tauri beta.22. + +## \[2.0.0-beta.4] + +- [`430bd6f4`](https://github.com/tauri-apps/plugins-workspace/commit/430bd6f4f379bee5d232ae6b098ae131db7f178a)([#1363](https://github.com/tauri-apps/plugins-workspace/pull/1363)) Update to tauri beta.20. + +## \[2.0.0-beta.3] + +- [`bd1ed590`](https://github.com/tauri-apps/plugins-workspace/commit/bd1ed5903ffcce5500310dac1e59e8c67674ef1e)([#1237](https://github.com/tauri-apps/plugins-workspace/pull/1237)) Update to tauri beta.17. + +## \[2.0.0-beta.3] + +- [`a04ea2f`](https://github.com/tauri-apps/plugins-workspace/commit/a04ea2f38294d5a3987578283badc8eec87a7752)([#1071](https://github.com/tauri-apps/plugins-workspace/pull/1071)) The global API script is now only added to the binary when the `withGlobalTauri` config is true. + +## \[2.0.0-beta.2] + +- [`99bea25`](https://github.com/tauri-apps/plugins-workspace/commit/99bea2559c2c0648c2519c50a18cd124dacef57b)([#1005](https://github.com/tauri-apps/plugins-workspace/pull/1005)) Update to tauri beta.8. + +## \[2.0.0-beta.1] + +- [`569defb`](https://github.com/tauri-apps/plugins-workspace/commit/569defbe9492e38938554bb7bdc1be9151456d21) Update to tauri beta.4. + +## \[2.0.0-beta.0] + +- [`d198c01`](https://github.com/tauri-apps/plugins-workspace/commit/d198c014863ee260cb0de88a14b7fc4356ef7474)([#862](https://github.com/tauri-apps/plugins-workspace/pull/862)) Update to tauri beta. + +## \[2.0.0-alpha.0] + +- [`8df28a9`](https://github.com/tauri-apps/plugins-workspace/commit/8df28a987519ecfa03dcb8635443025f8d010362)([#829](https://github.com/tauri-apps/plugins-workspace/pull/829)) Initial release. +- [`8df28a9`](https://github.com/tauri-apps/plugins-workspace/commit/8df28a987519ecfa03dcb8635443025f8d010362)([#829](https://github.com/tauri-apps/plugins-workspace/pull/829)) Initial release. + commit/8df28a987519ecfa03dcb8635443025f8d010362)([#829](https://github.com/tauri-apps/plugins-workspace/pull/829)) Initial release. + 29]\(https://github.com/tauri-apps/plugins-workspace/pull/829)) Initial release. + commit/8df28a987519ecfa03dcb8635443025f8d010362)([#829](https://github.com/tauri-apps/plugins-workspace/pull/829)) Initial release. + . + commit/8df28a987519ecfa03dcb8635443025f8d010362)([#829](https://github.com/tauri-apps/plugins-workspace/pull/829)) Initial release. + itial release. + 29]\(https://github.com/tauri-apps/plugins-workspace/pull/829)) Initial release. + commit/8df28a987519ecfa03dcb8635443025f8d010362)([#829](https://github.com/tauri-apps/plugins-workspace/pull/829)) Initial release. + . + commit/8df28a987519ecfa03dcb8635443025f8d010362)([#829](https://github.com/tauri-apps/plugins-workspace/pull/829)) Initial release. + ithub.com/tauri-apps/plugins-workspace/pull/829)) Initial release. diff --git a/plugins/biometric/Cargo.toml b/plugins/biometric/Cargo.toml new file mode 100644 index 00000000..2b76fea4 --- /dev/null +++ b/plugins/biometric/Cargo.toml @@ -0,0 +1,33 @@ +[package] +name = "tauri-plugin-biometric" +version = "2.2.1" +description = "Prompt the user for biometric authentication on Android and iOS." +edition = { workspace = true } +authors = { workspace = true } +license = { workspace = true } +repository = { workspace = true } +links = "tauri-plugin-biometric" + +[package.metadata.docs.rs] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] +targets = ["x86_64-linux-android"] + +[package.metadata.platforms.support] +windows = { level = "none", notes = "" } +linux = { level = "none", notes = "" } +macos = { level = "none", notes = "" } +android = { level = "full", notes = "" } +ios = { level = "full", notes = "" } + + +[build-dependencies] +tauri-plugin = { workspace = true, features = ["build"] } + +[dependencies] +serde = { workspace = true } +serde_json = { workspace = true } +tauri = { workspace = true } +log = { workspace = true } +thiserror = { workspace = true } +serde_repr = "0.1" diff --git a/plugins/authenticator/LICENSE.spdx b/plugins/biometric/LICENSE.spdx similarity index 100% rename from plugins/authenticator/LICENSE.spdx rename to plugins/biometric/LICENSE.spdx diff --git a/plugins/authenticator/LICENSE_APACHE-2.0 b/plugins/biometric/LICENSE_APACHE-2.0 similarity index 100% rename from plugins/authenticator/LICENSE_APACHE-2.0 rename to plugins/biometric/LICENSE_APACHE-2.0 diff --git a/plugins/authenticator/LICENSE_MIT b/plugins/biometric/LICENSE_MIT similarity index 100% rename from plugins/authenticator/LICENSE_MIT rename to plugins/biometric/LICENSE_MIT diff --git a/plugins/biometric/README.md b/plugins/biometric/README.md new file mode 100644 index 00000000..c7844f7b --- /dev/null +++ b/plugins/biometric/README.md @@ -0,0 +1,120 @@ +![biometric](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/biometric/banner.png) + +Prompt the user for biometric authentication on Android and iOS. + +| Platform | Supported | +| -------- | --------- | +| Linux | x | +| Windows | x | +| macOS | x | +| Android | ✓ | +| iOS | ✓ | + +## Install + +_This plugin requires a Rust version of at least **1.65**_ + +There are three general methods of installation that we can recommend. + +1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked) +2. Pull sources directly from Github using git tags / revision hashes (most secure) +3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use) + +Install the Core plugin by adding the following to your `Cargo.toml` file: + +`src-tauri/Cargo.toml` + +```toml +[dependencies] +tauri-plugin-biometric = "2.0.0" +# alternatively with Git: +tauri-plugin-biometric = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } +``` + +You can install the JavaScript Guest bindings using your preferred JavaScript package manager: + +> Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use. + + + +```sh +pnpm add @tauri-apps/plugin-biometric +# or +npm add @tauri-apps/plugin-biometric +# or +yarn add @tauri-apps/plugin-biometric + +# alternatively with Git: +pnpm add https://github.com/tauri-apps/tauri-plugin-biometric#v2 +# or +npm add https://github.com/tauri-apps/tauri-plugin-biometric#v2 +# or +yarn add https://github.com/tauri-apps/tauri-plugin-biometric#v2 +``` + +## Usage + +First you need to register the core plugin with Tauri: + +`src-tauri/src/lib.rs` + +```rust +fn main() { + tauri::Builder::default() + .plugin(tauri_plugin_biometric::init()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} +``` + +Afterwards all the plugin's APIs are available through the JavaScript guest bindings: + +```javascript +import { authenticate } from '@tauri-apps/plugin-biometric' +await authenticate('Open your wallet') +``` + +## Contributing + +PRs accepted. Please make sure to read the Contributing Guide before making a pull request. + +## Contributed By + + + + + + + + +
+ + CrabNebula + + + + Impierce + +
+ +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + +## License + +Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. + +MIT or MIT/Apache 2.0 where applicable. diff --git a/plugins/biometric/SECURITY.md b/plugins/biometric/SECURITY.md new file mode 100644 index 00000000..4f09bbac --- /dev/null +++ b/plugins/biometric/SECURITY.md @@ -0,0 +1,23 @@ +# Security Policy + +**Do not report security vulnerabilities through public GitHub issues.** + +**Please use the [Private Vulnerability Disclosure](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) feature of GitHub.** + +Include as much of the following information: + +- Type of issue (e.g. improper input parsing, privilege escalation, etc.) +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- The distribution affected or used to help us with reproduction of the issue +- Step-by-step instructions to reproduce the issue +- Ideally a reproduction repository +- Impact of the issue, including how an attacker might exploit the issue + +We prefer to receive reports in English. + +## Contact + +Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). + +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/clipboard-manager/.gitignore b/plugins/biometric/android/.gitignore similarity index 53% rename from plugins/clipboard-manager/.gitignore rename to plugins/biometric/android/.gitignore index 1b0b469d..c0f21ec2 100644 --- a/plugins/clipboard-manager/.gitignore +++ b/plugins/biometric/android/.gitignore @@ -1 +1,2 @@ +/build /.tauri diff --git a/plugins/biometric/android/build.gradle.kts b/plugins/biometric/android/build.gradle.kts new file mode 100644 index 00000000..d8833662 --- /dev/null +++ b/plugins/biometric/android/build.gradle.kts @@ -0,0 +1,44 @@ +plugins { + id("com.android.library") + id("org.jetbrains.kotlin.android") +} + +android { + namespace = "app.tauri.biometric" + compileSdk = 34 + + defaultConfig { + minSdk = 24 + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles("consumer-rules.pro") + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = "1.8" + } +} + +dependencies { + implementation("androidx.biometric:biometric:1.1.0") + implementation("androidx.core:core-ktx:1.9.0") + implementation("androidx.appcompat:appcompat:1.6.0") + implementation("com.google.android.material:material:1.7.0") + testImplementation("junit:junit:4.13.2") + androidTestImplementation("androidx.test.ext:junit:1.1.5") + androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") + implementation(project(":tauri-android")) +} diff --git a/plugins/biometric/android/proguard-rules.pro b/plugins/biometric/android/proguard-rules.pro new file mode 100644 index 00000000..481bb434 --- /dev/null +++ b/plugins/biometric/android/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/plugins/biometric/android/settings.gradle b/plugins/biometric/android/settings.gradle new file mode 100644 index 00000000..14a752e4 --- /dev/null +++ b/plugins/biometric/android/settings.gradle @@ -0,0 +1,2 @@ +include ':tauri-android' +project(':tauri-android').projectDir = new File('./.tauri/tauri-api') diff --git a/plugins/biometric/android/src/androidTest/java/ExampleInstrumentedTest.kt b/plugins/biometric/android/src/androidTest/java/ExampleInstrumentedTest.kt new file mode 100644 index 00000000..5efaa023 --- /dev/null +++ b/plugins/biometric/android/src/androidTest/java/ExampleInstrumentedTest.kt @@ -0,0 +1,28 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +package app.tauri.biometric + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("app.tauri.biometric", appContext.packageName) + } +} diff --git a/plugins/biometric/android/src/main/AndroidManifest.xml b/plugins/biometric/android/src/main/AndroidManifest.xml new file mode 100644 index 00000000..90328cb7 --- /dev/null +++ b/plugins/biometric/android/src/main/AndroidManifest.xml @@ -0,0 +1,9 @@ + + + + + + diff --git a/plugins/biometric/android/src/main/java/BiometricActivity.kt b/plugins/biometric/android/src/main/java/BiometricActivity.kt new file mode 100644 index 00000000..011de4d5 --- /dev/null +++ b/plugins/biometric/android/src/main/java/BiometricActivity.kt @@ -0,0 +1,129 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +package app.tauri.biometric + +import android.annotation.SuppressLint +import android.app.Activity +import android.app.KeyguardManager +import android.content.Context +import android.content.Intent +import android.hardware.biometrics.BiometricManager +import android.os.Build +import android.os.Bundle +import android.os.Handler +import androidx.appcompat.app.AppCompatActivity +import androidx.biometric.BiometricPrompt +import java.util.concurrent.Executor + +class BiometricActivity : AppCompatActivity() { + @SuppressLint("WrongConstant") + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.auth_activity) + + val executor = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + this.mainExecutor + } else { + Executor { command: Runnable? -> + Handler(this.mainLooper).post( + command!! + ) + } + } + + val builder = BiometricPrompt.PromptInfo.Builder() + val intent = intent + var title = intent.getStringExtra(BiometricPlugin.TITLE) + val subtitle = intent.getStringExtra(BiometricPlugin.SUBTITLE) + val description = intent.getStringExtra(BiometricPlugin.REASON) + allowDeviceCredential = false + // Android docs say we should check if the device is secure before enabling device credential fallback + val manager = getSystemService( + Context.KEYGUARD_SERVICE + ) as KeyguardManager + if (manager.isDeviceSecure) { + allowDeviceCredential = + intent.getBooleanExtra(BiometricPlugin.DEVICE_CREDENTIAL, false) + } + + if (title.isNullOrEmpty()) { + title = "Authenticate" + } + + builder.setTitle(title).setSubtitle(subtitle).setDescription(description) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + var authenticators = BiometricManager.Authenticators.BIOMETRIC_WEAK + if (allowDeviceCredential) { + authenticators = authenticators or BiometricManager.Authenticators.DEVICE_CREDENTIAL + } + builder.setAllowedAuthenticators(authenticators) + } else { + @Suppress("DEPRECATION") + builder.setDeviceCredentialAllowed(allowDeviceCredential) + } + + // From the Android docs: + // You can't call setNegativeButtonText() and setAllowedAuthenticators(... or DEVICE_CREDENTIAL) + // at the same time on a BiometricPrompt.PromptInfo.Builder instance. + if (!allowDeviceCredential) { + val negativeButtonText = intent.getStringExtra(BiometricPlugin.CANCEL_TITLE) + builder.setNegativeButtonText( + if (negativeButtonText.isNullOrEmpty()) "Cancel" else negativeButtonText + ) + } + builder.setConfirmationRequired( + intent.getBooleanExtra(BiometricPlugin.CONFIRMATION_REQUIRED, true) + ) + val promptInfo = builder.build() + val prompt = BiometricPrompt( + this, + executor, + object : BiometricPrompt.AuthenticationCallback() { + override fun onAuthenticationError( + errorCode: Int, + errorMessage: CharSequence + ) { + super.onAuthenticationError(errorCode, errorMessage) + finishActivity( + BiometryResultType.ERROR, + errorCode, + errorMessage as String + ) + } + + override fun onAuthenticationSucceeded( + result: BiometricPrompt.AuthenticationResult + ) { + super.onAuthenticationSucceeded(result) + finishActivity() + } + } + ) + prompt.authenticate(promptInfo) + } + + @JvmOverloads + fun finishActivity( + resultType: BiometryResultType = BiometryResultType.SUCCESS, + errorCode: Int = 0, + errorMessage: String? = "" + ) { + val intent = Intent() + val prefix = BiometricPlugin.RESULT_EXTRA_PREFIX + intent + .putExtra(prefix + BiometricPlugin.RESULT_TYPE, resultType.toString()) + .putExtra(prefix + BiometricPlugin.RESULT_ERROR_CODE, errorCode) + .putExtra( + prefix + BiometricPlugin.RESULT_ERROR_MESSAGE, + errorMessage + ) + setResult(Activity.RESULT_OK, intent) + finish() + } + + companion object { + var allowDeviceCredential = false + } +} \ No newline at end of file diff --git a/plugins/biometric/android/src/main/java/BiometricPlugin.kt b/plugins/biometric/android/src/main/java/BiometricPlugin.kt new file mode 100644 index 00000000..b3436fd4 --- /dev/null +++ b/plugins/biometric/android/src/main/java/BiometricPlugin.kt @@ -0,0 +1,254 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +package app.tauri.biometric + +import android.app.Activity +import android.content.Intent +import android.content.pm.PackageManager +import android.os.Build +import android.webkit.WebView +import androidx.activity.result.ActivityResult +import androidx.biometric.BiometricManager +import androidx.biometric.BiometricPrompt +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 java.util.EnumMap +import java.util.HashMap +import kotlin.math.max + +enum class BiometryResultType { + SUCCESS, FAILURE, ERROR +} + +private const val MAX_ATTEMPTS = "maxAttemps" +private const val BIOMETRIC_FAILURE = "authenticationFailed" +private const val INVALID_CONTEXT_ERROR = "invalidContext" + +@InvokeArg +class AuthOptions { + lateinit var reason: String + var allowDeviceCredential: Boolean = false + var title: String? = null + var subtitle: String? = null + var cancelTitle: String? = null + var confirmationRequired: Boolean? = null + var maxAttemps: Int = 3 +} + +@TauriPlugin +class BiometricPlugin(private val activity: Activity): Plugin(activity) { + private var biometryTypes: ArrayList = arrayListOf() + + companion object { + var RESULT_EXTRA_PREFIX = "" + const val TITLE = "title" + const val SUBTITLE = "subtitle" + const val REASON = "reason" + const val CANCEL_TITLE = "cancelTitle" + const val RESULT_TYPE = "type" + const val RESULT_ERROR_CODE = "errorCode" + const val RESULT_ERROR_MESSAGE = "errorMessage" + const val DEVICE_CREDENTIAL = "allowDeviceCredential" + const val CONFIRMATION_REQUIRED = "confirmationRequired" + + // Maps biometry error numbers to string error codes + private var biometryErrorCodeMap: MutableMap = HashMap() + private var biometryNameMap: MutableMap = EnumMap(BiometryType::class.java) + + init { + biometryErrorCodeMap[BiometricManager.BIOMETRIC_SUCCESS] = "" + biometryErrorCodeMap[BiometricManager.BIOMETRIC_SUCCESS] = "" + biometryErrorCodeMap[BiometricPrompt.ERROR_CANCELED] = "systemCancel" + biometryErrorCodeMap[BiometricPrompt.ERROR_HW_NOT_PRESENT] = "biometryNotAvailable" + biometryErrorCodeMap[BiometricPrompt.ERROR_HW_UNAVAILABLE] = "biometryNotAvailable" + biometryErrorCodeMap[BiometricPrompt.ERROR_LOCKOUT] = "biometryLockout" + biometryErrorCodeMap[BiometricPrompt.ERROR_LOCKOUT_PERMANENT] = "biometryLockout" + biometryErrorCodeMap[BiometricPrompt.ERROR_NEGATIVE_BUTTON] = "userCancel" + biometryErrorCodeMap[BiometricPrompt.ERROR_NO_BIOMETRICS] = "biometryNotEnrolled" + biometryErrorCodeMap[BiometricPrompt.ERROR_NO_DEVICE_CREDENTIAL] = "noDeviceCredential" + biometryErrorCodeMap[BiometricPrompt.ERROR_NO_SPACE] = "systemCancel" + biometryErrorCodeMap[BiometricPrompt.ERROR_TIMEOUT] = "systemCancel" + biometryErrorCodeMap[BiometricPrompt.ERROR_UNABLE_TO_PROCESS] = "systemCancel" + biometryErrorCodeMap[BiometricPrompt.ERROR_USER_CANCELED] = "userCancel" + biometryErrorCodeMap[BiometricPrompt.ERROR_VENDOR] = "systemCancel" + + biometryNameMap[BiometryType.NONE] = "No Authentication" + biometryNameMap[BiometryType.FINGERPRINT] = "Fingerprint Authentication" + biometryNameMap[BiometryType.FACE] = "Face Authentication" + biometryNameMap[BiometryType.IRIS] = "Iris Authentication" + } + } + + override fun load(webView: WebView) { + super.load(webView) + + biometryTypes = ArrayList() + val manager = activity.packageManager + if (manager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) { + biometryTypes.add(BiometryType.FINGERPRINT) + } + if (manager.hasSystemFeature(PackageManager.FEATURE_FACE)) { + biometryTypes.add(BiometryType.FACE) + } + if (manager.hasSystemFeature(PackageManager.FEATURE_IRIS)) { + biometryTypes.add(BiometryType.IRIS) + } + if (biometryTypes.size == 0) { + biometryTypes.add(BiometryType.NONE) + } + } + + /** + * Check the device's availability and type of biometric authentication. + */ + @Command + fun status(invoke: Invoke) { + val manager = BiometricManager.from(activity) + val biometryResult = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + manager.canAuthenticate(BiometricManager.Authenticators.BIOMETRIC_WEAK) + } else { + @Suppress("DEPRECATION") + manager.canAuthenticate() + } + val ret = JSObject() + + val available = biometryResult == BiometricManager.BIOMETRIC_SUCCESS + ret.put( + "isAvailable", + available + ) + + ret.put("biometryType", biometryTypes[0].type) + + if (!available) { + var reason = "" + when (biometryResult) { + BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE -> reason = + "Biometry unavailable." + BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED -> reason = + "Biometrics not enrolled." + BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE -> reason = + "No biometric on this device." + BiometricManager.BIOMETRIC_ERROR_SECURITY_UPDATE_REQUIRED -> reason = + "A security update is required." + BiometricManager.BIOMETRIC_ERROR_UNSUPPORTED -> reason = + "Unsupported biometry." + BiometricManager.BIOMETRIC_STATUS_UNKNOWN -> reason = + "Unknown biometry state." + } + + var errorCode = biometryErrorCodeMap[biometryResult] + if (errorCode == null) { + errorCode = "biometryNotAvailable" + } + ret.put("error", reason) + ret.put("errorCode", errorCode) + } + + invoke.resolve(ret) + } + + /** + * Prompt the user for biometric authentication. + */ + @Command + fun authenticate(invoke: Invoke) { + // The result of an intent is supposed to have the package name as a prefix + RESULT_EXTRA_PREFIX = activity.packageName + "." + val intent = Intent( + activity, + BiometricActivity::class.java + ) + + val args = invoke.parseArgs(AuthOptions::class.java) + + // Pass the options to the activity + intent.putExtra( + TITLE, + args.title ?: (biometryNameMap[biometryTypes[0]] ?: "") + ) + intent.putExtra(SUBTITLE, args.subtitle) + intent.putExtra(REASON, args.reason) + intent.putExtra(CANCEL_TITLE, args.cancelTitle) + intent.putExtra(DEVICE_CREDENTIAL, args.allowDeviceCredential) + args.confirmationRequired?.let { + intent.putExtra(CONFIRMATION_REQUIRED, it) + } + + val maxAttemptsConfig = args.maxAttemps + val maxAttempts = max(maxAttemptsConfig, 1) + intent.putExtra(MAX_ATTEMPTS, maxAttempts) + startActivityForResult(invoke, intent, "authenticateResult") + } + + @ActivityCallback + private fun authenticateResult(invoke: Invoke, result: ActivityResult) { + val resultCode = result.resultCode + + // If the system canceled the activity, we might get RESULT_CANCELED in resultCode. + // In that case return that immediately, because there won't be any data. + if (resultCode == Activity.RESULT_CANCELED) { + invoke.reject( + "The system canceled authentication", + biometryErrorCodeMap[BiometricPrompt.ERROR_CANCELED] + ) + return + } + + // Convert the string result type to an enum + val data = result.data + val resultTypeName = data?.getStringExtra( + RESULT_EXTRA_PREFIX + RESULT_TYPE + ) + if (resultTypeName == null) { + invoke.reject( + "Missing data in the result of the activity", + INVALID_CONTEXT_ERROR + ) + return + } + val resultType = try { + BiometryResultType.valueOf(resultTypeName) + } catch (e: IllegalArgumentException) { + invoke.reject( + "Invalid data in the result of the activity", + INVALID_CONTEXT_ERROR + ) + return + } + val errorCode = data.getIntExtra( + RESULT_EXTRA_PREFIX + RESULT_ERROR_CODE, + 0 + ) + var errorMessage = data.getStringExtra( + RESULT_EXTRA_PREFIX + RESULT_ERROR_MESSAGE + ) + when (resultType) { + BiometryResultType.SUCCESS -> invoke.resolve() + BiometryResultType.FAILURE -> // Biometry was successfully presented but was not recognized + invoke.reject(errorMessage, BIOMETRIC_FAILURE) + + BiometryResultType.ERROR -> { + // The user cancelled, the system cancelled, or some error occurred. + // If the user cancelled, errorMessage is the text of the "negative" button, + // which is not especially descriptive. + if (errorCode == BiometricPrompt.ERROR_NEGATIVE_BUTTON) { + errorMessage = "Cancel button was pressed" + } + invoke.reject(errorMessage, biometryErrorCodeMap[errorCode]) + } + } + } + + internal enum class BiometryType(val type: Int) { + NONE(0), FINGERPRINT(1), FACE(2), IRIS(3); + } +} diff --git a/plugins/biometric/android/src/main/res/layout/auth_activity.xml b/plugins/biometric/android/src/main/res/layout/auth_activity.xml new file mode 100644 index 00000000..d88f20da --- /dev/null +++ b/plugins/biometric/android/src/main/res/layout/auth_activity.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/plugins/biometric/android/src/main/res/values/styles.xml b/plugins/biometric/android/src/main/res/values/styles.xml new file mode 100644 index 00000000..3caed83b --- /dev/null +++ b/plugins/biometric/android/src/main/res/values/styles.xml @@ -0,0 +1,10 @@ + + + \ No newline at end of file diff --git a/plugins/biometric/android/src/test/java/ExampleUnitTest.kt b/plugins/biometric/android/src/test/java/ExampleUnitTest.kt new file mode 100644 index 00000000..128d8bce --- /dev/null +++ b/plugins/biometric/android/src/test/java/ExampleUnitTest.kt @@ -0,0 +1,21 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +package app.tauri.biometric + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} diff --git a/plugins/biometric/api-iife.js b/plugins/biometric/api-iife.js new file mode 100644 index 00000000..3da2296b --- /dev/null +++ b/plugins/biometric/api-iife.js @@ -0,0 +1 @@ +if("__TAURI__"in window){var __TAURI_PLUGIN_BIOMETRIC__=function(e){"use strict";async function i(e,i={},t){return window.__TAURI_INTERNALS__.invoke(e,i,t)}var t;return"function"==typeof SuppressedError&&SuppressedError,e.BiometryType=void 0,(t=e.BiometryType||(e.BiometryType={}))[t.None=0]="None",t[t.TouchID=1]="TouchID",t[t.FaceID=2]="FaceID",t[t.Iris=3]="Iris",e.authenticate=async function(e,t){await i("plugin:biometric|authenticate",{reason:e,...t})},e.checkStatus=async function(){return await i("plugin:biometric|status")},e}({});Object.defineProperty(window.__TAURI__,"biometric",{value:__TAURI_PLUGIN_BIOMETRIC__})} diff --git a/plugins/biometric/build.rs b/plugins/biometric/build.rs new file mode 100644 index 00000000..070986b2 --- /dev/null +++ b/plugins/biometric/build.rs @@ -0,0 +1,18 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +const COMMANDS: &[&str] = &["authenticate", "status"]; + +fn main() { + let result = tauri_plugin::Builder::new(COMMANDS) + .global_api_script_path("./api-iife.js") + .android_path("android") + .ios_path("ios") + .try_build(); + + // when building documentation for Android the plugin build result is always Err() and is irrelevant to the crate documentation build + if !(cfg!(docsrs) && std::env::var("TARGET").unwrap().contains("android")) { + result.unwrap(); + } +} diff --git a/plugins/biometric/contributors/crabnebula.svg b/plugins/biometric/contributors/crabnebula.svg new file mode 100644 index 00000000..a9bb4609 --- /dev/null +++ b/plugins/biometric/contributors/crabnebula.svg @@ -0,0 +1,31 @@ + \ No newline at end of file diff --git a/plugins/biometric/contributors/impierce.svg b/plugins/biometric/contributors/impierce.svg new file mode 100644 index 00000000..9d2a510b --- /dev/null +++ b/plugins/biometric/contributors/impierce.svg @@ -0,0 +1,21 @@ + \ No newline at end of file diff --git a/plugins/biometric/guest-js/index.ts b/plugins/biometric/guest-js/index.ts new file mode 100644 index 00000000..5c3eb8df --- /dev/null +++ b/plugins/biometric/guest-js/index.ts @@ -0,0 +1,77 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import { invoke } from '@tauri-apps/api/core' + +export enum BiometryType { + None = 0, + // Apple TouchID or Android fingerprint + TouchID = 1, + // Apple FaceID or Android face authentication + FaceID = 2, + // Android iris authentication + Iris = 3 +} + +export interface Status { + isAvailable: boolean + biometryType: BiometryType + error?: string + errorCode?: + | 'appCancel' + | 'authenticationFailed' + | 'invalidContext' + | 'notInteractive' + | 'passcodeNotSet' + | 'systemCancel' + | 'userCancel' + | 'userFallback' + | 'biometryLockout' + | 'biometryNotAvailable' + | 'biometryNotEnrolled' +} + +export interface AuthOptions { + allowDeviceCredential?: boolean + cancelTitle?: string + + // iOS options + fallbackTitle?: string + + // android options + title?: string + subtitle?: string + confirmationRequired?: boolean + maxAttemps?: number +} + +/** + * Checks if the biometric authentication is available. + * @returns a promise resolving to an object containing all the information about the status of the biometry. + */ +export async function checkStatus(): Promise { + return await invoke('plugin:biometric|status') +} + +/** + * Prompts the user for authentication using the system interface (touchID, faceID or Android Iris). + * Rejects if the authentication fails. + * + * ```javascript + * import { authenticate } from "@tauri-apps/plugin-biometric"; + * await authenticate('Open your wallet'); + * ``` + * @param reason + * @param options + * @returns + */ +export async function authenticate( + reason: string, + options?: AuthOptions +): Promise { + await invoke('plugin:biometric|authenticate', { + reason, + ...options + }) +} diff --git a/plugins/biometric/ios/.gitignore b/plugins/biometric/ios/.gitignore new file mode 100644 index 00000000..5922fdaa --- /dev/null +++ b/plugins/biometric/ios/.gitignore @@ -0,0 +1,10 @@ +.DS_Store +/.build +/Packages +/*.xcodeproj +xcuserdata/ +DerivedData/ +.swiftpm/config/registries.json +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +.netrc +Package.resolved diff --git a/plugins/biometric/ios/Package.swift b/plugins/biometric/ios/Package.swift new file mode 100644 index 00000000..7860f476 --- /dev/null +++ b/plugins/biometric/ios/Package.swift @@ -0,0 +1,34 @@ +// swift-tools-version:5.3 +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import PackageDescription + +let package = Package( + name: "tauri-plugin-biometric", + platforms: [ + .macOS(.v10_13), + .iOS(.v13), + ], + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .library( + name: "tauri-plugin-biometric", + type: .static, + targets: ["tauri-plugin-biometric"]) + ], + dependencies: [ + .package(name: "Tauri", path: "../.tauri/tauri-api") + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .target( + name: "tauri-plugin-biometric", + dependencies: [ + .byName(name: "Tauri") + ], + path: "Sources") + ] +) diff --git a/plugins/biometric/ios/README.md b/plugins/biometric/ios/README.md new file mode 100644 index 00000000..f4900bdd --- /dev/null +++ b/plugins/biometric/ios/README.md @@ -0,0 +1,3 @@ +# Tauri Plugin {{ plugin_name_original }} + +A description of this package. diff --git a/plugins/biometric/ios/Sources/BiometricPlugin.swift b/plugins/biometric/ios/Sources/BiometricPlugin.swift new file mode 100644 index 00000000..c295904a --- /dev/null +++ b/plugins/biometric/ios/Sources/BiometricPlugin.swift @@ -0,0 +1,153 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import LocalAuthentication +import SwiftRs +import Tauri +import UIKit +import WebKit + +class BiometricStatus { + let available: Bool + let biometryType: LABiometryType + let errorReason: String? + let errorCode: String? + + init(available: Bool, biometryType: LABiometryType, errorReason: String?, errorCode: String?) { + self.available = available + self.biometryType = biometryType + self.errorReason = errorReason + self.errorCode = errorCode + } +} + +struct AuthOptions: Decodable { + let reason: String + var allowDeviceCredential: Bool? + var fallbackTitle: String? + var cancelTitle: String? +} + +class BiometricPlugin: Plugin { + let authenticationErrorCodeMap: [Int: String] = [ + 0: "", + LAError.appCancel.rawValue: "appCancel", + LAError.authenticationFailed.rawValue: "authenticationFailed", + LAError.invalidContext.rawValue: "invalidContext", + LAError.notInteractive.rawValue: "notInteractive", + LAError.passcodeNotSet.rawValue: "passcodeNotSet", + LAError.systemCancel.rawValue: "systemCancel", + LAError.userCancel.rawValue: "userCancel", + LAError.userFallback.rawValue: "userFallback", + LAError.biometryLockout.rawValue: "biometryLockout", + LAError.biometryNotAvailable.rawValue: "biometryNotAvailable", + LAError.biometryNotEnrolled.rawValue: "biometryNotEnrolled", + ] + + var status: BiometricStatus! + + public override func load(webview: WKWebView) { + let context = LAContext() + var error: NSError? + var available = context.canEvaluatePolicy( + .deviceOwnerAuthenticationWithBiometrics, error: &error) + var reason: String? = nil + var errorCode: String? = nil + + if available && context.biometryType == .faceID { + let entry = Bundle.main.infoDictionary?["NSFaceIDUsageDescription"] as? String + + if entry == nil || entry?.count == 0 { + available = false + reason = "NSFaceIDUsageDescription is not in the app Info.plist" + errorCode = authenticationErrorCodeMap[LAError.biometryNotAvailable.rawValue] ?? "" + } + } else if !available, let error = error { + reason = error.localizedDescription + if let failureReason = error.localizedFailureReason { + reason = "\(reason ?? ""): \(failureReason)" + } + errorCode = + authenticationErrorCodeMap[error.code] ?? authenticationErrorCodeMap[ + LAError.biometryNotAvailable.rawValue] ?? "" + } + + self.status = BiometricStatus( + available: available, + biometryType: context.biometryType, + errorReason: reason, + errorCode: errorCode + ) + } + + @objc func status(_ invoke: Invoke) { + if self.status.available { + invoke.resolve([ + "isAvailable": self.status.available, + "biometryType": self.status.biometryType.rawValue, + ]) + } else { + invoke.resolve([ + "isAvailable": self.status.available, + "biometryType": self.status.biometryType.rawValue, + "error": self.status.errorReason ?? "", + "errorCode": self.status.errorCode ?? "", + ]) + } + } + + @objc func authenticate(_ invoke: Invoke) throws { + let args = try invoke.parseArgs(AuthOptions.self) + + let allowDeviceCredential = args.allowDeviceCredential ?? false + + guard self.status.available || allowDeviceCredential else { + // Biometry unavailable, fallback disabled + invoke.reject( + self.status.errorReason ?? "", + code: self.status.errorCode ?? "" + ) + return + } + + let context = LAContext() + context.localizedFallbackTitle = args.fallbackTitle + context.localizedCancelTitle = args.cancelTitle + context.touchIDAuthenticationAllowableReuseDuration = 0 + + // force system default fallback title if an empty string is provided (the OS hides the fallback button in this case) + if allowDeviceCredential, + let fallbackTitle = context.localizedFallbackTitle, + fallbackTitle.isEmpty + { + context.localizedFallbackTitle = nil + } + + context.evaluatePolicy( + allowDeviceCredential + ? .deviceOwnerAuthentication : .deviceOwnerAuthenticationWithBiometrics, + localizedReason: args.reason + ) { success, error in + if success { + invoke.resolve() + } else { + if let policyError = error as? LAError { + let code = self.authenticationErrorCodeMap[policyError.code.rawValue] + invoke.reject(policyError.localizedDescription, code: code) + } else { + invoke.reject( + "Unknown error", + code: self.authenticationErrorCodeMap[LAError.authenticationFailed.rawValue] + ) + } + } + } + + } +} + +@_cdecl("init_plugin_biometric") +func initPlugin() -> Plugin { + return BiometricPlugin() +} diff --git a/plugins/biometric/ios/Tests/PluginTests/PluginTests.swift b/plugins/biometric/ios/Tests/PluginTests/PluginTests.swift new file mode 100644 index 00000000..99992ce4 --- /dev/null +++ b/plugins/biometric/ios/Tests/PluginTests/PluginTests.swift @@ -0,0 +1,12 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import XCTest +@testable import ExamplePlugin + +final class ExamplePluginTests: XCTestCase { + func testExample() throws { + let plugin = ExamplePlugin() + } +} diff --git a/plugins/biometric/package.json b/plugins/biometric/package.json new file mode 100644 index 00000000..2307d67b --- /dev/null +++ b/plugins/biometric/package.json @@ -0,0 +1,30 @@ +{ + "name": "@tauri-apps/plugin-biometric", + "version": "2.2.1", + "license": "MIT OR Apache-2.0", + "authors": [ + "Tauri Programme within The Commons Conservancy" + ], + "repository": "https://github.com/tauri-apps/plugins-workspace", + "type": "module", + "types": "./dist-js/index.d.ts", + "main": "./dist-js/index.cjs", + "module": "./dist-js/index.js", + "exports": { + "types": "./dist-js/index.d.ts", + "import": "./dist-js/index.js", + "require": "./dist-js/index.cjs" + }, + "scripts": { + "build": "rollup -c" + }, + "files": [ + "dist-js", + "!dist-js/**/*.map", + "README.md", + "LICENSE" + ], + "dependencies": { + "@tauri-apps/api": "^2.0.0" + } +} diff --git a/plugins/biometric/permissions/autogenerated/commands/authenticate.toml b/plugins/biometric/permissions/autogenerated/commands/authenticate.toml new file mode 100644 index 00000000..be4c9f9b --- /dev/null +++ b/plugins/biometric/permissions/autogenerated/commands/authenticate.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-authenticate" +description = "Enables the authenticate command without any pre-configured scope." +commands.allow = ["authenticate"] + +[[permission]] +identifier = "deny-authenticate" +description = "Denies the authenticate command without any pre-configured scope." +commands.deny = ["authenticate"] diff --git a/plugins/biometric/permissions/autogenerated/commands/status.toml b/plugins/biometric/permissions/autogenerated/commands/status.toml new file mode 100644 index 00000000..c8ed433c --- /dev/null +++ b/plugins/biometric/permissions/autogenerated/commands/status.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-status" +description = "Enables the status command without any pre-configured scope." +commands.allow = ["status"] + +[[permission]] +identifier = "deny-status" +description = "Denies the status command without any pre-configured scope." +commands.deny = ["status"] diff --git a/plugins/biometric/permissions/autogenerated/reference.md b/plugins/biometric/permissions/autogenerated/reference.md new file mode 100644 index 00000000..8f085093 --- /dev/null +++ b/plugins/biometric/permissions/autogenerated/reference.md @@ -0,0 +1,77 @@ +## Default Permission + +This permission set configures which +biometric features are by default exposed. + +#### Granted Permissions + +It allows acccess to all biometric commands. + + + +#### This default permission set includes the following: + +- `allow-authenticate` +- `allow-status` + +## Permission Table + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IdentifierDescription
+ +`biometric:allow-authenticate` + + + +Enables the authenticate command without any pre-configured scope. + +
+ +`biometric:deny-authenticate` + + + +Denies the authenticate command without any pre-configured scope. + +
+ +`biometric:allow-status` + + + +Enables the status command without any pre-configured scope. + +
+ +`biometric:deny-status` + + + +Denies the status command without any pre-configured scope. + +
diff --git a/plugins/biometric/permissions/default.toml b/plugins/biometric/permissions/default.toml new file mode 100644 index 00000000..651990ef --- /dev/null +++ b/plugins/biometric/permissions/default.toml @@ -0,0 +1,13 @@ +"$schema" = "schemas/schema.json" +[default] +description = """ +This permission set configures which +biometric features are by default exposed. + +#### Granted Permissions + +It allows acccess to all biometric commands. + +""" + +permissions = ["allow-authenticate", "allow-status"] diff --git a/plugins/biometric/permissions/schemas/schema.json b/plugins/biometric/permissions/schemas/schema.json new file mode 100644 index 00000000..416759b5 --- /dev/null +++ b/plugins/biometric/permissions/schemas/schema.json @@ -0,0 +1,330 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "PermissionFile", + "description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.", + "type": "object", + "properties": { + "default": { + "description": "The default permission set for the plugin", + "anyOf": [ + { + "$ref": "#/definitions/DefaultPermission" + }, + { + "type": "null" + } + ] + }, + "set": { + "description": "A list of permissions sets defined", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionSet" + } + }, + "permission": { + "description": "A list of inlined permissions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Permission" + } + } + }, + "definitions": { + "DefaultPermission": { + "description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.", + "type": "object", + "required": [ + "permissions" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "PermissionSet": { + "description": "A set of direct permissions grouped together under a new name.", + "type": "object", + "required": [ + "description", + "identifier", + "permissions" + ], + "properties": { + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does.", + "type": "string" + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionKind" + } + } + } + }, + "Permission": { + "description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.", + "type": "object", + "required": [ + "identifier" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri internal convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "commands": { + "description": "Allowed or denied commands when using this permission.", + "default": { + "allow": [], + "deny": [] + }, + "allOf": [ + { + "$ref": "#/definitions/Commands" + } + ] + }, + "scope": { + "description": "Allowed or denied scoped when using this permission.", + "allOf": [ + { + "$ref": "#/definitions/Scopes" + } + ] + }, + "platforms": { + "description": "Target platforms this permission applies. By default all platforms are affected by this permission.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Target" + } + } + } + }, + "Commands": { + "description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.", + "type": "object", + "properties": { + "allow": { + "description": "Allowed command.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "deny": { + "description": "Denied command, which takes priority.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "Scopes": { + "description": "An argument for fine grained behavior control of Tauri commands.\n\nIt can be of any serde serializable type and is used to allow or prevent certain actions inside a Tauri command. The configured scope is passed to the command and will be enforced by the command implementation.\n\n## Example\n\n```json { \"allow\": [{ \"path\": \"$HOME/**\" }], \"deny\": [{ \"path\": \"$HOME/secret.txt\" }] } ```", + "type": "object", + "properties": { + "allow": { + "description": "Data that defines what is allowed by the scope.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + }, + "deny": { + "description": "Data that defines what is denied by the scope. This should be prioritized by validation logic.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + } + } + }, + "Value": { + "description": "All supported ACL values.", + "anyOf": [ + { + "description": "Represents a null JSON value.", + "type": "null" + }, + { + "description": "Represents a [`bool`].", + "type": "boolean" + }, + { + "description": "Represents a valid ACL [`Number`].", + "allOf": [ + { + "$ref": "#/definitions/Number" + } + ] + }, + { + "description": "Represents a [`String`].", + "type": "string" + }, + { + "description": "Represents a list of other [`Value`]s.", + "type": "array", + "items": { + "$ref": "#/definitions/Value" + } + }, + { + "description": "Represents a map of [`String`] keys to [`Value`]s.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/Value" + } + } + ] + }, + "Number": { + "description": "A valid ACL number.", + "anyOf": [ + { + "description": "Represents an [`i64`].", + "type": "integer", + "format": "int64" + }, + { + "description": "Represents a [`f64`].", + "type": "number", + "format": "double" + } + ] + }, + "Target": { + "description": "Platform target.", + "oneOf": [ + { + "description": "MacOS.", + "type": "string", + "enum": [ + "macOS" + ] + }, + { + "description": "Windows.", + "type": "string", + "enum": [ + "windows" + ] + }, + { + "description": "Linux.", + "type": "string", + "enum": [ + "linux" + ] + }, + { + "description": "Android.", + "type": "string", + "enum": [ + "android" + ] + }, + { + "description": "iOS.", + "type": "string", + "enum": [ + "iOS" + ] + } + ] + }, + "PermissionKind": { + "type": "string", + "oneOf": [ + { + "description": "Enables the authenticate command without any pre-configured scope.", + "type": "string", + "const": "allow-authenticate", + "markdownDescription": "Enables the authenticate command without any pre-configured scope." + }, + { + "description": "Denies the authenticate command without any pre-configured scope.", + "type": "string", + "const": "deny-authenticate", + "markdownDescription": "Denies the authenticate command without any pre-configured scope." + }, + { + "description": "Enables the status command without any pre-configured scope.", + "type": "string", + "const": "allow-status", + "markdownDescription": "Enables the status command without any pre-configured scope." + }, + { + "description": "Denies the status command without any pre-configured scope.", + "type": "string", + "const": "deny-status", + "markdownDescription": "Denies the status command without any pre-configured scope." + }, + { + "description": "This permission set configures which\nbiometric features are by default exposed.\n\n#### Granted Permissions\n\nIt allows acccess to all biometric commands.\n\n\n#### This default permission set includes:\n\n- `allow-authenticate`\n- `allow-status`", + "type": "string", + "const": "default", + "markdownDescription": "This permission set configures which\nbiometric features are by default exposed.\n\n#### Granted Permissions\n\nIt allows acccess to all biometric commands.\n\n\n#### This default permission set includes:\n\n- `allow-authenticate`\n- `allow-status`" + } + ] + } + } +} \ No newline at end of file diff --git a/plugins/biometric/rollup.config.js b/plugins/biometric/rollup.config.js new file mode 100644 index 00000000..1f349ec8 --- /dev/null +++ b/plugins/biometric/rollup.config.js @@ -0,0 +1,7 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import { createConfig } from '../../shared/rollup.config.js' + +export default createConfig() diff --git a/plugins/authenticator/src/error.rs b/plugins/biometric/src/error.rs similarity index 62% rename from plugins/authenticator/src/error.rs rename to plugins/biometric/src/error.rs index 8cc5df00..339e763b 100644 --- a/plugins/authenticator/src/error.rs +++ b/plugins/biometric/src/error.rs @@ -2,18 +2,17 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use serde::{Serialize, Serializer}; +use serde::{ser::Serializer, Serialize}; + +pub type Result = std::result::Result; #[derive(Debug, thiserror::Error)] pub enum Error { #[error(transparent)] - Base64Decode(#[from] base64::DecodeError), - #[error(transparent)] - JSON(#[from] serde_json::Error), - #[error(transparent)] - U2F(#[from] u2f::u2ferror::U2fError), + Io(#[from] std::io::Error), + #[cfg(mobile)] #[error(transparent)] - Auth(#[from] authenticator::errors::AuthenticatorError), + PluginInvoke(#[from] tauri::plugin::mobile::PluginInvokeError), } impl Serialize for Error { diff --git a/plugins/biometric/src/lib.rs b/plugins/biometric/src/lib.rs new file mode 100644 index 00000000..f79a104d --- /dev/null +++ b/plugins/biometric/src/lib.rs @@ -0,0 +1,71 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +#![cfg(mobile)] + +use serde::Serialize; +use tauri::{ + plugin::{Builder, PluginHandle, TauriPlugin}, + Manager, Runtime, +}; + +pub use models::*; + +mod error; +mod models; + +pub use error::{Error, Result}; + +#[cfg(target_os = "android")] +const PLUGIN_IDENTIFIER: &str = "app.tauri.biometric"; + +#[cfg(target_os = "ios")] +tauri::ios_plugin_binding!(init_plugin_biometric); + +/// Access to the biometric APIs. +pub struct Biometric(PluginHandle); + +#[derive(Serialize)] +struct AuthenticatePayload { + reason: String, + #[serde(flatten)] + options: AuthOptions, +} + +impl Biometric { + pub fn status(&self) -> crate::Result { + self.0.run_mobile_plugin("status", ()).map_err(Into::into) + } + + pub fn authenticate(&self, reason: String, options: AuthOptions) -> crate::Result<()> { + self.0 + .run_mobile_plugin("authenticate", AuthenticatePayload { reason, options }) + .map_err(Into::into) + } +} + +/// Extensions to [`tauri::App`], [`tauri::AppHandle`], [`tauri::WebviewWindow`], [`tauri::Webview`] and [`tauri::Window`] to access the biometric APIs. +pub trait BiometricExt { + fn biometric(&self) -> &Biometric; +} + +impl> crate::BiometricExt for T { + fn biometric(&self) -> &Biometric { + self.state::>().inner() + } +} + +/// Initializes the plugin. +pub fn init() -> TauriPlugin { + Builder::new("biometric") + .setup(|app, api| { + #[cfg(target_os = "android")] + let handle = api.register_android_plugin(PLUGIN_IDENTIFIER, "BiometricPlugin")?; + #[cfg(target_os = "ios")] + let handle = api.register_ios_plugin(init_plugin_biometric)?; + app.manage(Biometric(handle)); + Ok(()) + }) + .build() +} diff --git a/plugins/biometric/src/models.rs b/plugins/biometric/src/models.rs new file mode 100644 index 00000000..49c84300 --- /dev/null +++ b/plugins/biometric/src/models.rs @@ -0,0 +1,39 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Default, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct AuthOptions { + /// Enables authentication using the device's password. This feature is available on both Android and iOS. + pub allow_device_credential: bool, + /// Label for the Cancel button. This feature is available on both Android and iOS. + pub cancel_title: Option, + /// Specifies the text displayed on the fallback button if biometric authentication fails. This feature is available iOS only. + pub fallback_title: Option, + /// Title indicating the purpose of biometric verification. This feature is available Android only. + pub title: Option, + /// SubTitle providing contextual information of biometric verification. This feature is available Android only. + pub subtitle: Option, + /// Specifies whether additional user confirmation is required, such as pressing a button after successful biometric authentication. This feature is available Android only. + pub confirmation_required: Option, +} + +#[derive(Debug, Clone, serde_repr::Deserialize_repr)] +#[repr(u8)] +pub enum BiometryType { + None = 0, + TouchID = 1, + FaceID = 2, +} + +#[derive(Debug, Clone, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct Status { + pub is_available: bool, + pub biometry_type: BiometryType, + pub error: Option, + pub error_code: Option, +} diff --git a/plugins/authenticator/tsconfig.json b/plugins/biometric/tsconfig.json similarity index 100% rename from plugins/authenticator/tsconfig.json rename to plugins/biometric/tsconfig.json diff --git a/plugins/cli/CHANGELOG.md b/plugins/cli/CHANGELOG.md index 3109c03f..c2c011e2 100644 --- a/plugins/cli/CHANGELOG.md +++ b/plugins/cli/CHANGELOG.md @@ -1,5 +1,86 @@ # Changelog +## \[2.2.0] + +- [`3a79266b`](https://github.com/tauri-apps/plugins-workspace/commit/3a79266b8cf96a55b1ae6339d725567d45a44b1d) ([#2173](https://github.com/tauri-apps/plugins-workspace/pull/2173) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Bumped all plugins to `v2.2.0`. From now, the versions for the Rust and JavaScript packages of each plugin will be in sync with each other. + +## \[2.0.1] + +- [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. + +## \[2.0.0] + +- [`e2c4dfb6`](https://github.com/tauri-apps/plugins-workspace/commit/e2c4dfb6af43e5dd8d9ceba232c315f5febd55c1) Update to tauri v2 stable release. + +## \[2.0.0-rc.2] + +- [`68579934`](https://github.com/tauri-apps/plugins-workspace/commit/68579934c93f6ed2edbc97474560d6a8a00e8f70) ([#1856](https://github.com/tauri-apps/plugins-workspace/pull/1856) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Expose `Matches`, `SubcommandMatches` and `ArgData` structs. + +## \[2.0.0-rc.1] + +- [`e2e97db5`](https://github.com/tauri-apps/plugins-workspace/commit/e2e97db51983267f5be84d4f6f0278d58834d1f5) ([#1701](https://github.com/tauri-apps/plugins-workspace/pull/1701) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri 2.0.0-rc.8 + +## \[2.0.0-rc.0] + +- [`9887d1`](https://github.com/tauri-apps/plugins-workspace/commit/9887d14bd0e971c4c0f5c1188fc4005d3fc2e29e) Update to tauri RC. + +## \[2.0.0-beta.8] + +- [`99d6ac0f`](https://github.com/tauri-apps/plugins-workspace/commit/99d6ac0f9506a6a4a1aa59c728157190a7441af6) ([#1606](https://github.com/tauri-apps/plugins-workspace/pull/1606) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) The JS packages now specify the *minimum* `@tauri-apps/api` version instead of a single exact version. +- [`6de87966`](https://github.com/tauri-apps/plugins-workspace/commit/6de87966ecc00ad9d91c25be452f1f46bd2b7e1f) ([#1597](https://github.com/tauri-apps/plugins-workspace/pull/1597) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Update to tauri beta.25. + +## \[2.0.0-beta.7] + +- [`22a17980`](https://github.com/tauri-apps/plugins-workspace/commit/22a17980ff4f6f8c40adb1b8f4ffc6dae2fe7e30) ([#1537](https://github.com/tauri-apps/plugins-workspace/pull/1537) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri beta.24. + +## \[2.0.0-beta.6] + +- [`76daee7a`](https://github.com/tauri-apps/plugins-workspace/commit/76daee7aafece34de3092c86e531cf9eb1138989) ([#1512](https://github.com/tauri-apps/plugins-workspace/pull/1512) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Update to tauri beta.23. + +## \[2.0.0-beta.5] + +- [`9013854f`](https://github.com/tauri-apps/plugins-workspace/commit/9013854f42a49a230b9dbb9d02774765528a923f)([#1382](https://github.com/tauri-apps/plugins-workspace/pull/1382)) Update to tauri beta.22. + +## \[2.0.0-beta.4] + +- [`430bd6f4`](https://github.com/tauri-apps/plugins-workspace/commit/430bd6f4f379bee5d232ae6b098ae131db7f178a)([#1363](https://github.com/tauri-apps/plugins-workspace/pull/1363)) Update to tauri beta.20. + +## \[2.0.0-beta.3] + +- [`bd1ed590`](https://github.com/tauri-apps/plugins-workspace/commit/bd1ed5903ffcce5500310dac1e59e8c67674ef1e)([#1237](https://github.com/tauri-apps/plugins-workspace/pull/1237)) Update to tauri beta.17. + +## \[2.0.0-beta.3] + +- [`a04ea2f`](https://github.com/tauri-apps/plugins-workspace/commit/a04ea2f38294d5a3987578283badc8eec87a7752)([#1071](https://github.com/tauri-apps/plugins-workspace/pull/1071)) The global API script is now only added to the binary when the `withGlobalTauri` config is true. + +## \[2.0.0-beta.2] + +- [`99bea25`](https://github.com/tauri-apps/plugins-workspace/commit/99bea2559c2c0648c2519c50a18cd124dacef57b)([#1005](https://github.com/tauri-apps/plugins-workspace/pull/1005)) Update to tauri beta.8. + +## \[2.0.0-beta.1] + +- [`569defb`](https://github.com/tauri-apps/plugins-workspace/commit/569defbe9492e38938554bb7bdc1be9151456d21) Update to tauri beta.4. + +## \[2.0.0-beta.0] + +- [`d198c01`](https://github.com/tauri-apps/plugins-workspace/commit/d198c014863ee260cb0de88a14b7fc4356ef7474)([#862](https://github.com/tauri-apps/plugins-workspace/pull/862)) Update to tauri beta. + +## \[2.0.0-alpha.5] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.13. + +## \[2.0.0-alpha.4] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.12. + +## \[2.0.0-alpha.3] + +- [`e438e0a`](https://github.com/tauri-apps/plugins-workspace/commit/e438e0a62d4b430a5159f05f13ecd397dd891a0d)([#676](https://github.com/tauri-apps/plugins-workspace/pull/676)) Update to @tauri-apps/api v2.0.0-alpha.11. + +## \[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.9. + ## \[2.0.0-alpha.2] - [`4e2cef9`](https://github.com/tauri-apps/plugins-workspace/commit/4e2cef9b702bbbb9cf4ee17de50791cb21f1b2a4)([#593](https://github.com/tauri-apps/plugins-workspace/pull/593)) Update to alpha.12. @@ -12,7 +93,3 @@ - [`717ae67`](https://github.com/tauri-apps/plugins-workspace/commit/717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! te to alpha.11. - -## \[2.0.0-alpha.0] - -- [`717ae67`](https://github.com/tauri-apps/plugins-workspace/commit/717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! diff --git a/plugins/cli/Cargo.toml b/plugins/cli/Cargo.toml index a03f72e4..500ba957 100644 --- a/plugins/cli/Cargo.toml +++ b/plugins/cli/Cargo.toml @@ -1,14 +1,28 @@ [package] name = "tauri-plugin-cli" -version = "2.0.0-alpha.2" +version = "2.2.0" description = "Parse arguments from your Tauri application's command line interface." edition = { workspace = true } authors = { workspace = true } license = { workspace = true } rust-version = { workspace = true } +repository = { workspace = true } +links = "tauri-plugin-cli" [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] + +[package.metadata.platforms.support] +windows = { level = "full", notes = "" } +linux = { level = "full", notes = "" } +macos = { level = "full", notes = "" } +android = { level = "none", notes = "" } +ios = { level = "none", notes = "" } + + +[build-dependencies] +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } @@ -16,4 +30,4 @@ serde_json = { workspace = true } tauri = { workspace = true } log = { workspace = true } thiserror = { workspace = true } -clap = { version = "4", features = [ "string" ] } +clap = { version = "4", features = ["string"] } diff --git a/plugins/cli/README.md b/plugins/cli/README.md index 676098a5..91a8080b 100644 --- a/plugins/cli/README.md +++ b/plugins/cli/README.md @@ -2,11 +2,17 @@ Parse arguments from your Command Line Interface. -- Supported platforms: Windows, Linux and macOS. +| Platform | Supported | +| -------- | --------- | +| Linux | ✓ | +| Windows | ✓ | +| macOS | ✓ | +| Android | x | +| iOS | x | ## Install -_This plugin requires a Rust version of at least **1.70**_ +_This plugin requires a Rust version of at least **1.77.2**_ There are three general methods of installation that we can recommend. @@ -21,7 +27,7 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml # you can add the dependencies on the `[dependencies]` section if you do not target mobile [target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies] -tauri-plugin-cli = "2.0.0-alpha" +tauri-plugin-cli = "2.0.0" # alternatively with Git: tauri-plugin-cli = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -49,7 +55,7 @@ yarn add https://github.com/tauri-apps/tauri-plugin-cli#v2 First you need to register the core plugin with Tauri: -`src-tauri/src/main.rs` +`src-tauri/src/lib.rs` ```rust fn main() { @@ -67,16 +73,16 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import { getMatches } from "@tauri-apps/plugin-cli"; -const matches = await getMatches(); -if (matches.subcommand?.name === "run") { +import { getMatches } from '@tauri-apps/plugin-cli' +const matches = await getMatches() +if (matches.subcommand?.name === 'run') { // `./your-app run $ARGS` was executed - const args = matches.subcommand?.matches.args; - if ("debug" in args) { + const args = matches.subcommand?.matches.args + if ('debug' in args) { // `./your-app run --debug` was executed } } else { - const args = matches.args; + const args = matches.args // `./your-app $ARGS` was executed } ``` @@ -85,6 +91,22 @@ if (matches.subcommand?.name === "run") { PRs accepted. Please make sure to read the Contributing Guide before making a pull request. +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + ## License Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. diff --git a/plugins/cli/SECURITY.md b/plugins/cli/SECURITY.md new file mode 100644 index 00000000..4f09bbac --- /dev/null +++ b/plugins/cli/SECURITY.md @@ -0,0 +1,23 @@ +# Security Policy + +**Do not report security vulnerabilities through public GitHub issues.** + +**Please use the [Private Vulnerability Disclosure](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) feature of GitHub.** + +Include as much of the following information: + +- Type of issue (e.g. improper input parsing, privilege escalation, etc.) +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- The distribution affected or used to help us with reproduction of the issue +- Step-by-step instructions to reproduce the issue +- Ideally a reproduction repository +- Impact of the issue, including how an attacker might exploit the issue + +We prefer to receive reports in English. + +## Contact + +Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). + +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/cli/api-iife.js b/plugins/cli/api-iife.js new file mode 100644 index 00000000..90b2f35f --- /dev/null +++ b/plugins/cli/api-iife.js @@ -0,0 +1 @@ +if("__TAURI__"in window){var __TAURI_PLUGIN_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_PLUGIN_CLI__})} diff --git a/plugins/cli/build.rs b/plugins/cli/build.rs new file mode 100644 index 00000000..50d88849 --- /dev/null +++ b/plugins/cli/build.rs @@ -0,0 +1,11 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +const COMMANDS: &[&str] = &["cli_matches"]; + +fn main() { + tauri_plugin::Builder::new(COMMANDS) + .global_api_script_path("./api-iife.js") + .build(); +} diff --git a/plugins/cli/guest-js/index.ts b/plugins/cli/guest-js/index.ts index 2fb47243..7a7f4acf 100644 --- a/plugins/cli/guest-js/index.ts +++ b/plugins/cli/guest-js/index.ts @@ -8,7 +8,7 @@ * @module */ -import { invoke } from "@tauri-apps/api/primitives"; +import { invoke } from '@tauri-apps/api/core' /** * @since 2.0.0 @@ -19,27 +19,27 @@ interface ArgMatch { * boolean if flag * string[] or null if takes multiple values */ - value: string | boolean | string[] | null; + value: string | boolean | string[] | null /** * Number of occurrences */ - occurrences: number; + occurrences: number } /** * @since 2.0.0 */ interface SubcommandMatch { - name: string; - matches: CliMatches; + name: string + matches: CliMatches } /** * @since 2.0.0 */ interface CliMatches { - args: Record; - subcommand: SubcommandMatch | null; + args: Record + subcommand: SubcommandMatch | null } /** @@ -64,9 +64,9 @@ interface CliMatches { * @since 2.0.0 */ async function getMatches(): Promise { - return await invoke("plugin:cli|cli_matches"); + return await invoke('plugin:cli|cli_matches') } -export type { ArgMatch, SubcommandMatch, CliMatches }; +export type { ArgMatch, SubcommandMatch, CliMatches } -export { getMatches }; +export { getMatches } diff --git a/plugins/cli/package.json b/plugins/cli/package.json index 681276a5..e5ff8b73 100644 --- a/plugins/cli/package.json +++ b/plugins/cli/package.json @@ -1,32 +1,29 @@ { "name": "@tauri-apps/plugin-cli", - "version": "2.0.0-alpha.1", - "license": "MIT or APACHE-2.0", + "version": "2.2.0", + "license": "MIT OR Apache-2.0", "authors": [ "Tauri Programme within The Commons Conservancy" ], + "repository": "https://github.com/tauri-apps/plugins-workspace", "type": "module", - "browser": "dist-js/index.min.js", - "module": "dist-js/index.mjs", - "types": "dist-js/index.d.ts", + "types": "./dist-js/index.d.ts", + "main": "./dist-js/index.cjs", + "module": "./dist-js/index.js", "exports": { - "import": "./dist-js/index.mjs", "types": "./dist-js/index.d.ts", - "browser": "./dist-js/index.min.js" + "import": "./dist-js/index.js", + "require": "./dist-js/index.cjs" }, "scripts": { "build": "rollup -c" }, "files": [ "dist-js", - "!dist-js/**/*.map", "README.md", "LICENSE" ], - "devDependencies": { - "tslib": "^2.4.1" - }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.9" + "@tauri-apps/api": "^2.0.0" } } diff --git a/plugins/cli/permissions/autogenerated/commands/cli_matches.toml b/plugins/cli/permissions/autogenerated/commands/cli_matches.toml new file mode 100644 index 00000000..b0a2e8f3 --- /dev/null +++ b/plugins/cli/permissions/autogenerated/commands/cli_matches.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-cli-matches" +description = "Enables the cli_matches command without any pre-configured scope." +commands.allow = ["cli_matches"] + +[[permission]] +identifier = "deny-cli-matches" +description = "Denies the cli_matches command without any pre-configured scope." +commands.deny = ["cli_matches"] diff --git a/plugins/cli/permissions/autogenerated/reference.md b/plugins/cli/permissions/autogenerated/reference.md new file mode 100644 index 00000000..cfa83f0a --- /dev/null +++ b/plugins/cli/permissions/autogenerated/reference.md @@ -0,0 +1,43 @@ +## Default Permission + +Allows reading the CLI matches + +#### This default permission set includes the following: + +- `allow-cli-matches` + +## Permission Table + + + + + + + + + + + + + + + + + +
IdentifierDescription
+ +`cli:allow-cli-matches` + + + +Enables the cli_matches command without any pre-configured scope. + +
+ +`cli:deny-cli-matches` + + + +Denies the cli_matches command without any pre-configured scope. + +
diff --git a/plugins/cli/permissions/default.toml b/plugins/cli/permissions/default.toml new file mode 100644 index 00000000..82bf7ca8 --- /dev/null +++ b/plugins/cli/permissions/default.toml @@ -0,0 +1,4 @@ +"$schema" = "schemas/schema.json" +[default] +description = "Allows reading the CLI matches" +permissions = ["allow-cli-matches"] diff --git a/plugins/cli/permissions/schemas/schema.json b/plugins/cli/permissions/schemas/schema.json new file mode 100644 index 00000000..45941514 --- /dev/null +++ b/plugins/cli/permissions/schemas/schema.json @@ -0,0 +1,318 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "PermissionFile", + "description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.", + "type": "object", + "properties": { + "default": { + "description": "The default permission set for the plugin", + "anyOf": [ + { + "$ref": "#/definitions/DefaultPermission" + }, + { + "type": "null" + } + ] + }, + "set": { + "description": "A list of permissions sets defined", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionSet" + } + }, + "permission": { + "description": "A list of inlined permissions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Permission" + } + } + }, + "definitions": { + "DefaultPermission": { + "description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.", + "type": "object", + "required": [ + "permissions" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "PermissionSet": { + "description": "A set of direct permissions grouped together under a new name.", + "type": "object", + "required": [ + "description", + "identifier", + "permissions" + ], + "properties": { + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does.", + "type": "string" + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionKind" + } + } + } + }, + "Permission": { + "description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.", + "type": "object", + "required": [ + "identifier" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri internal convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "commands": { + "description": "Allowed or denied commands when using this permission.", + "default": { + "allow": [], + "deny": [] + }, + "allOf": [ + { + "$ref": "#/definitions/Commands" + } + ] + }, + "scope": { + "description": "Allowed or denied scoped when using this permission.", + "allOf": [ + { + "$ref": "#/definitions/Scopes" + } + ] + }, + "platforms": { + "description": "Target platforms this permission applies. By default all platforms are affected by this permission.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Target" + } + } + } + }, + "Commands": { + "description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.", + "type": "object", + "properties": { + "allow": { + "description": "Allowed command.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "deny": { + "description": "Denied command, which takes priority.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "Scopes": { + "description": "An argument for fine grained behavior control of Tauri commands.\n\nIt can be of any serde serializable type and is used to allow or prevent certain actions inside a Tauri command. The configured scope is passed to the command and will be enforced by the command implementation.\n\n## Example\n\n```json { \"allow\": [{ \"path\": \"$HOME/**\" }], \"deny\": [{ \"path\": \"$HOME/secret.txt\" }] } ```", + "type": "object", + "properties": { + "allow": { + "description": "Data that defines what is allowed by the scope.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + }, + "deny": { + "description": "Data that defines what is denied by the scope. This should be prioritized by validation logic.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + } + } + }, + "Value": { + "description": "All supported ACL values.", + "anyOf": [ + { + "description": "Represents a null JSON value.", + "type": "null" + }, + { + "description": "Represents a [`bool`].", + "type": "boolean" + }, + { + "description": "Represents a valid ACL [`Number`].", + "allOf": [ + { + "$ref": "#/definitions/Number" + } + ] + }, + { + "description": "Represents a [`String`].", + "type": "string" + }, + { + "description": "Represents a list of other [`Value`]s.", + "type": "array", + "items": { + "$ref": "#/definitions/Value" + } + }, + { + "description": "Represents a map of [`String`] keys to [`Value`]s.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/Value" + } + } + ] + }, + "Number": { + "description": "A valid ACL number.", + "anyOf": [ + { + "description": "Represents an [`i64`].", + "type": "integer", + "format": "int64" + }, + { + "description": "Represents a [`f64`].", + "type": "number", + "format": "double" + } + ] + }, + "Target": { + "description": "Platform target.", + "oneOf": [ + { + "description": "MacOS.", + "type": "string", + "enum": [ + "macOS" + ] + }, + { + "description": "Windows.", + "type": "string", + "enum": [ + "windows" + ] + }, + { + "description": "Linux.", + "type": "string", + "enum": [ + "linux" + ] + }, + { + "description": "Android.", + "type": "string", + "enum": [ + "android" + ] + }, + { + "description": "iOS.", + "type": "string", + "enum": [ + "iOS" + ] + } + ] + }, + "PermissionKind": { + "type": "string", + "oneOf": [ + { + "description": "Enables the cli_matches command without any pre-configured scope.", + "type": "string", + "const": "allow-cli-matches", + "markdownDescription": "Enables the cli_matches command without any pre-configured scope." + }, + { + "description": "Denies the cli_matches command without any pre-configured scope.", + "type": "string", + "const": "deny-cli-matches", + "markdownDescription": "Denies the cli_matches command without any pre-configured scope." + }, + { + "description": "Allows reading the CLI matches\n#### This default permission set includes:\n\n- `allow-cli-matches`", + "type": "string", + "const": "default", + "markdownDescription": "Allows reading the CLI matches\n#### This default permission set includes:\n\n- `allow-cli-matches`" + } + ] + } + } +} \ No newline at end of file diff --git a/plugins/cli/rollup.config.js b/plugins/cli/rollup.config.js new file mode 100644 index 00000000..1f349ec8 --- /dev/null +++ b/plugins/cli/rollup.config.js @@ -0,0 +1,7 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import { createConfig } from '../../shared/rollup.config.js' + +export default createConfig() diff --git a/plugins/cli/rollup.config.mjs b/plugins/cli/rollup.config.mjs deleted file mode 100644 index 99a3dd31..00000000 --- a/plugins/cli/rollup.config.mjs +++ /dev/null @@ -1,11 +0,0 @@ -import { readFileSync } from "fs"; - -import { createConfig } from "../../shared/rollup.config.mjs"; - -export default createConfig({ - input: "guest-js/index.ts", - pkg: JSON.parse( - readFileSync(new URL("./package.json", import.meta.url), "utf8"), - ), - external: [/^@tauri-apps\/api/], -}); diff --git a/plugins/cli/src/api-iife.js b/plugins/cli/src/api-iife.js deleted file mode 100644 index 81e2042c..00000000 --- a/plugins/cli/src/api-iife.js +++ /dev/null @@ -1 +0,0 @@ -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__})} diff --git a/plugins/cli/src/error.rs b/plugins/cli/src/error.rs index b4bd2872..2b5e1602 100644 --- a/plugins/cli/src/error.rs +++ b/plugins/cli/src/error.rs @@ -18,3 +18,5 @@ impl Serialize for Error { serializer.serialize_str(self.to_string().as_ref()) } } + +pub type Result = std::result::Result; diff --git a/plugins/cli/src/lib.rs b/plugins/cli/src/lib.rs index c666874c..3e144376 100644 --- a/plugins/cli/src/lib.rs +++ b/plugins/cli/src/lib.rs @@ -2,8 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -//! [![](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/cli/banner.png)](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/cli) -//! //! Parse arguments from your Command Line Interface. //! //! - Supported platforms: Windows, Linux and macOS. @@ -23,8 +21,9 @@ mod error; mod parser; use config::{Arg, Config}; -pub use error::Error; -type Result = std::result::Result; + +pub use error::{Error, Result}; +pub use parser::{ArgData, Matches, SubcommandMatches}; pub struct Cli(PluginApi); @@ -51,7 +50,6 @@ fn cli_matches(_app: AppHandle, cli: State<'_, Cli>) -> Result pub fn init() -> TauriPlugin { Builder::new("cli") - .js_init_script(include_str!("api-iife.js").to_string()) .invoke_handler(tauri::generate_handler![cli_matches]) .setup(|app, api| { app.manage(Cli(api)); diff --git a/plugins/clipboard-manager/CHANGELOG.md b/plugins/clipboard-manager/CHANGELOG.md index 3109c03f..895d8c71 100644 --- a/plugins/clipboard-manager/CHANGELOG.md +++ b/plugins/clipboard-manager/CHANGELOG.md @@ -1,5 +1,124 @@ # Changelog +## \[2.2.2] + +### bug + +- [`d37bbdef`](https://github.com/tauri-apps/plugins-workspace/commit/d37bbdef8dc70e61e59f9fe0bb8b2a48999d0aa1) ([#2507](https://github.com/tauri-apps/plugins-workspace/pull/2507) by [@SquitchYT](https://github.com/tauri-apps/plugins-workspace/../../SquitchYT)) Fix clipboard-manager Wayland support. + +## \[2.2.1] + +- [`ce11079f`](https://github.com/tauri-apps/plugins-workspace/commit/ce11079f19852fbefdecf0e4c7d947af3624fee0) ([#2280](https://github.com/tauri-apps/plugins-workspace/pull/2280) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Explicitly drop `arboard::Clipboard` on exit. Add recommendation to not use read methods on the mainthread. + +## \[2.2.0] + +- [`3a79266b`](https://github.com/tauri-apps/plugins-workspace/commit/3a79266b8cf96a55b1ae6339d725567d45a44b1d) ([#2173](https://github.com/tauri-apps/plugins-workspace/pull/2173) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Bumped all plugins to `v2.2.0`. From now, the versions for the Rust and JavaScript packages of each plugin will be in sync with each other. + +## \[2.0.1] + +- [`3fa0fc09`](https://github.com/tauri-apps/plugins-workspace/commit/3fa0fc09bbee0d619801e5757af9fb3c09883c97) ([#2099](https://github.com/tauri-apps/plugins-workspace/pull/2099) by [@rasteiner](https://github.com/tauri-apps/plugins-workspace/../../rasteiner)) Fix clipboard manager client side api not copying fallback alternative text when calling `writeHtml`. + +## \[2.0.2] + +- [`d57df4de`](https://github.com/tauri-apps/plugins-workspace/commit/d57df4debe7c75cfbd6d6558fff1beb07dbee54c) ([#1986](https://github.com/tauri-apps/plugins-workspace/pull/1986) by [@RikaKagurasaka](https://github.com/tauri-apps/plugins-workspace/../../RikaKagurasaka)) Fix that `read_image` wrongly set the image rgba data with binary PNG data. + +## \[2.0.1] + +- [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. + +## \[2.0.0] + +- [`e2c4dfb6`](https://github.com/tauri-apps/plugins-workspace/commit/e2c4dfb6af43e5dd8d9ceba232c315f5febd55c1) Update to tauri v2 stable release. + +## \[2.0.0-rc.2] + +- [`341a5320`](https://github.com/tauri-apps/plugins-workspace/commit/341a5320c33d3c7b041abf7eb0ab7ad8009e6c3f) ([#1771](https://github.com/tauri-apps/plugins-workspace/pull/1771)) Fix warnings and clear implementation on Android below SDK 28. + +## \[2.0.0-rc.1] + +- [`e2e97db5`](https://github.com/tauri-apps/plugins-workspace/commit/e2e97db51983267f5be84d4f6f0278d58834d1f5) ([#1701](https://github.com/tauri-apps/plugins-workspace/pull/1701) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri 2.0.0-rc.8 + +## \[2.0.0-rc.2] + +- [`b9147758`](https://github.com/tauri-apps/plugins-workspace/commit/b914775898c2bee7ceb20bd17ee595005cd17a64) ([#1679](https://github.com/tauri-apps/plugins-workspace/pull/1679) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Explicitly set a minimum macOS version for the Swift package. + +## \[2.0.0-rc.1] + +- [`2c00c029`](https://github.com/tauri-apps/plugins-workspace/commit/2c00c0292c9127b81567de46691e8c0f73557261) ([#1630](https://github.com/tauri-apps/plugins-workspace/pull/1630) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Fixed an issue that caused multi-word IIFE names to not be formatted correctly. For example the `barcode-scanner` was defined as `window.__TAURI_PLUGIN_CLIPBOARDMANAGER__` instead of `window.__TAURI_PLUGIN_CLIPBOARD_MANAGER__`. + +### changes + +- [`6b079cfd`](https://github.com/tauri-apps/plugins-workspace/commit/6b079cfdd107c94abc2c7300f6af00bac3ff4040) ([#1649](https://github.com/tauri-apps/plugins-workspace/pull/1649) by [@ahqsoftwares](https://github.com/tauri-apps/plugins-workspace/../../ahqsoftwares)) Remove targetSdk from build.kts files as it is deprecated and will be removed from DSL v9.0 + +## \[2.0.0-rc.0] + +- [`9887d1`](https://github.com/tauri-apps/plugins-workspace/commit/9887d14bd0e971c4c0f5c1188fc4005d3fc2e29e) Update to tauri RC. + +## \[2.1.0-beta.6] + +- [`99d6ac0f`](https://github.com/tauri-apps/plugins-workspace/commit/99d6ac0f9506a6a4a1aa59c728157190a7441af6) ([#1606](https://github.com/tauri-apps/plugins-workspace/pull/1606) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) The JS packages now specify the *minimum* `@tauri-apps/api` version instead of a single exact version. +- [`6de87966`](https://github.com/tauri-apps/plugins-workspace/commit/6de87966ecc00ad9d91c25be452f1f46bd2b7e1f) ([#1597](https://github.com/tauri-apps/plugins-workspace/pull/1597) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Update to tauri beta.25. + +## \[2.1.0-beta.5] + +- [`22a17980`](https://github.com/tauri-apps/plugins-workspace/commit/22a17980ff4f6f8c40adb1b8f4ffc6dae2fe7e30) ([#1537](https://github.com/tauri-apps/plugins-workspace/pull/1537) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri beta.24. + +## \[2.1.0-beta.4] + +- [`76daee7a`](https://github.com/tauri-apps/plugins-workspace/commit/76daee7aafece34de3092c86e531cf9eb1138989) ([#1512](https://github.com/tauri-apps/plugins-workspace/pull/1512) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Update to tauri beta.23. + +## \[2.1.0-beta.3] + +- [`9013854f`](https://github.com/tauri-apps/plugins-workspace/commit/9013854f42a49a230b9dbb9d02774765528a923f)([#1382](https://github.com/tauri-apps/plugins-workspace/pull/1382)) Update to tauri beta.22. + +## \[2.1.0-beta.2] + +- [`430bd6f4`](https://github.com/tauri-apps/plugins-workspace/commit/430bd6f4f379bee5d232ae6b098ae131db7f178a)([#1363](https://github.com/tauri-apps/plugins-workspace/pull/1363)) Update to tauri beta.20. + +## \[2.1.0-beta.1] + +- [`bd1ed590`](https://github.com/tauri-apps/plugins-workspace/commit/bd1ed5903ffcce5500310dac1e59e8c67674ef1e)([#1237](https://github.com/tauri-apps/plugins-workspace/pull/1237)) Update to tauri beta.17. + +## \[2.1.0-beta.1] + +- [`27b258c`](https://github.com/tauri-apps/plugins-workspace/commit/27b258cf31ae5557c99ae66537fb9196368d4d8b)([#1185](https://github.com/tauri-apps/plugins-workspace/pull/1185)) Expose `Clipboard` struct +- [`e3d41f4`](https://github.com/tauri-apps/plugins-workspace/commit/e3d41f4011bd3ea3ce281bb38bbe31d3709f8e0f)([#1191](https://github.com/tauri-apps/plugins-workspace/pull/1191)) Internally use the webview scoped resources table instead of the app one, so other webviews can't access other webviews resources. +- [`e3d41f4`](https://github.com/tauri-apps/plugins-workspace/commit/e3d41f4011bd3ea3ce281bb38bbe31d3709f8e0f)([#1191](https://github.com/tauri-apps/plugins-workspace/pull/1191)) Update for tauri 2.0.0-beta.15. + +## \[2.1.0-beta.0] + +- [`9dec960`](https://github.com/tauri-apps/plugins-workspace/commit/9dec9605ed1ce19dbef697e55debddf9008ecba1)([#845](https://github.com/tauri-apps/plugins-workspace/pull/845)) Add support for `read_image` and `write_image` to the clipboard plugin (desktop). + +## \[2.0.0-beta.2] + +- [`dc6d332`](https://github.com/tauri-apps/plugins-workspace/commit/dc6d3321e5305fa8b7250553bd179cbee995998a)([#977](https://github.com/tauri-apps/plugins-workspace/pull/977)) Add support for writing HTML content to the clipboard. +- [`99bea25`](https://github.com/tauri-apps/plugins-workspace/commit/99bea2559c2c0648c2519c50a18cd124dacef57b)([#1005](https://github.com/tauri-apps/plugins-workspace/pull/1005)) Update to tauri beta.8. + +## \[2.0.0-beta.1] + +- [`569defb`](https://github.com/tauri-apps/plugins-workspace/commit/569defbe9492e38938554bb7bdc1be9151456d21) Update to tauri beta.4. + +## \[2.0.0-beta.0] + +- [`d198c01`](https://github.com/tauri-apps/plugins-workspace/commit/d198c014863ee260cb0de88a14b7fc4356ef7474)([#862](https://github.com/tauri-apps/plugins-workspace/pull/862)) Update to tauri beta. +- [`d198c01`](https://github.com/tauri-apps/plugins-workspace/commit/d198c014863ee260cb0de88a14b7fc4356ef7474)([#862](https://github.com/tauri-apps/plugins-workspace/pull/862)) Add permissions. + +## \[2.0.0-alpha.5] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.13. + +## \[2.0.0-alpha.4] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.12. + +## \[2.0.0-alpha.3] + +- [`e438e0a`](https://github.com/tauri-apps/plugins-workspace/commit/e438e0a62d4b430a5159f05f13ecd397dd891a0d)([#676](https://github.com/tauri-apps/plugins-workspace/pull/676)) Update to @tauri-apps/api v2.0.0-alpha.11. + +## \[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.9. + ## \[2.0.0-alpha.2] - [`4e2cef9`](https://github.com/tauri-apps/plugins-workspace/commit/4e2cef9b702bbbb9cf4ee17de50791cb21f1b2a4)([#593](https://github.com/tauri-apps/plugins-workspace/pull/593)) Update to alpha.12. @@ -10,9 +129,4 @@ ## \[2.0.0-alpha.0] -- [`717ae67`](https://github.com/tauri-apps/plugins-workspace/commit/717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! - te to alpha.11. - -## \[2.0.0-alpha.0] - - [`717ae67`](https://github.com/tauri-apps/plugins-workspace/commit/717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! diff --git a/plugins/clipboard-manager/Cargo.toml b/plugins/clipboard-manager/Cargo.toml index d6610082..0c35e591 100644 --- a/plugins/clipboard-manager/Cargo.toml +++ b/plugins/clipboard-manager/Cargo.toml @@ -1,22 +1,29 @@ [package] name = "tauri-plugin-clipboard-manager" -version = "2.0.0-alpha.2" +version = "2.2.2" description = "Read and write to the system clipboard." edition = { workspace = true } authors = { workspace = true } license = { workspace = true } rust-version = { workspace = true } +repository = { workspace = true } links = "tauri-plugin-clipboard-manager" [package.metadata.docs.rs] -features = [ "dox" ] -targets = [ - "x86_64-unknown-linux-gnu", - "x86_64-linux-android" -] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] +targets = ["x86_64-unknown-linux-gnu", "x86_64-linux-android"] + +[package.metadata.platforms.support] +windows = { level = "full", notes = "" } +linux = { level = "full", notes = "" } +macos = { level = "full", notes = "" } +android = { level = "partial", notes = "Only plain-text content support" } +ios = { level = "partial", notes = "Only plain-text content support" } + [build-dependencies] -tauri-build = { workspace = true } +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } @@ -25,8 +32,8 @@ tauri = { workspace = true } log = { workspace = true } 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" +[target.'cfg(target_os = "ios")'.dependencies] +tauri = { workspace = true, features = ["wry"] } -[features] -dox = [ "tauri/dox" ] +[target."cfg(any(target_os = \"macos\", windows, target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies] +arboard = { version = "3", features = ["wayland-data-control"] } diff --git a/plugins/clipboard-manager/README.md b/plugins/clipboard-manager/README.md index c794014c..57b89526 100644 --- a/plugins/clipboard-manager/README.md +++ b/plugins/clipboard-manager/README.md @@ -2,9 +2,17 @@ Read and write to the system clipboard. +| Platform | Supported | +| -------- | --------- | +| Linux | ✓ | +| Windows | ✓ | +| macOS | ✓ | +| Android | ✓ | +| iOS | ✓ | + ## Install -_This plugin requires a Rust version of at least **1.70**_ +_This plugin requires a Rust version of at least **1.77.2**_ There are three general methods of installation that we can recommend. @@ -18,7 +26,7 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] -tauri-plugin-clipboard-manager = "2.0.0-alpha" +tauri-plugin-clipboard-manager = "2.0.0" # alternatively with Git: tauri-plugin-clipboard-manager = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -46,7 +54,7 @@ yarn add https://github.com/tauri-apps/tauri-plugin-clipboard-manager#v2 First you need to register the core plugin with Tauri: -`src-tauri/src/main.rs` +`src-tauri/src/lib.rs` ```rust fn main() { @@ -60,15 +68,36 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import { writeText, readText } from "@tauri-apps/plugin-clipboard-manager"; -await writeText("Tauri is awesome!"); -assert(await readText(), "Tauri is awesome!"); +import { + writeText, + readText, + writeHtml, + clear +} from '@tauri-apps/plugin-clipboard-manager' +await writeText('Tauri is awesome!') +assert(await readText(), 'Tauri is awesome!') ``` ## Contributing PRs accepted. Please make sure to read the Contributing Guide before making a pull request. +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + ## License Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. diff --git a/plugins/clipboard-manager/SECURITY.md b/plugins/clipboard-manager/SECURITY.md new file mode 100644 index 00000000..4f09bbac --- /dev/null +++ b/plugins/clipboard-manager/SECURITY.md @@ -0,0 +1,23 @@ +# Security Policy + +**Do not report security vulnerabilities through public GitHub issues.** + +**Please use the [Private Vulnerability Disclosure](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) feature of GitHub.** + +Include as much of the following information: + +- Type of issue (e.g. improper input parsing, privilege escalation, etc.) +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- The distribution affected or used to help us with reproduction of the issue +- Step-by-step instructions to reproduce the issue +- Ideally a reproduction repository +- Impact of the issue, including how an attacker might exploit the issue + +We prefer to receive reports in English. + +## Contact + +Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). + +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/clipboard-manager/android/build.gradle.kts b/plugins/clipboard-manager/android/build.gradle.kts index b3c3ec32..b12a7482 100644 --- a/plugins/clipboard-manager/android/build.gradle.kts +++ b/plugins/clipboard-manager/android/build.gradle.kts @@ -5,11 +5,10 @@ plugins { android { namespace = "app.tauri.clipboard" - compileSdk = 32 + compileSdk = 34 defaultConfig { - minSdk = 24 - targetSdk = 32 + minSdk = 24 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles("consumer-rules.pro") @@ -38,6 +37,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 8f622251..ebb931b4 100644 --- a/plugins/clipboard-manager/android/src/main/java/ClipboardPlugin.kt +++ b/plugins/clipboard-manager/android/src/main/java/ClipboardPlugin.kt @@ -4,18 +4,83 @@ package app.tauri.clipboard -import android.R.attr.value import android.app.Activity import android.content.ClipData import android.content.ClipDescription import android.content.ClipboardManager import android.content.Context +import android.os.Build 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 -> { + throw Exception("unimplemented ReadClipData") + } + } + + 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) { @@ -24,25 +89,17 @@ 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 clipData = when (kind) { - "PlainText" -> { - val label = options.getString("label", "") - val text = options.getString("text", "") - ClipData.newPlainText(label, text) - } + fun writeText(invoke: Invoke) { + val args = invoke.parseArgs(WriteOptions::class.java) - else -> { - invoke.reject("Unknown kind $kind") + val clipData = when (args) { + is WriteOptions.PlainText -> { + ClipData.newPlainText(args.label, args.text) + } else -> { + invoke.reject("unimplemented WriteOptions") return } + } manager.setPrimaryClip(clipData) @@ -51,11 +108,13 @@ class ClipboardPlugin(private val activity: Activity) : Plugin(activity) { } @Command - fun read(invoke: Invoke) { - val (kind, options) = if (manager.hasPrimaryClip()) { + fun readText(invoke: Invoke) { + 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 +125,18 @@ 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) + } + + @Command + fun clear(invoke: Invoke) { + if (manager.hasPrimaryClip()) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + manager.clearPrimaryClip() + } else { + manager.setPrimaryClip(ClipData.newPlainText("", "")) + } + } + invoke.resolve() } } diff --git a/plugins/clipboard-manager/api-iife.js b/plugins/clipboard-manager/api-iife.js new file mode 100644 index 00000000..f3e28be5 --- /dev/null +++ b/plugins/clipboard-manager/api-iife.js @@ -0,0 +1 @@ +if("__TAURI__"in window){var __TAURI_PLUGIN_CLIPBOARD_MANAGER__=function(e){"use strict";var n;async function t(e,n={},t){return window.__TAURI_INTERNALS__.invoke(e,n,t)}"function"==typeof SuppressedError&&SuppressedError;class r{get rid(){return function(e,n,t,r){if("function"==typeof n||!n.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===t?r:"a"===t?r.call(e):r?r.value:n.get(e)}(this,n,"f")}constructor(e){n.set(this,void 0),function(e,n,t){if("function"==typeof n||!n.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");n.set(e,t)}(this,n,e)}async close(){return t("plugin:resources|close",{rid:this.rid})}}n=new WeakMap;class a extends r{constructor(e){super(e)}static async new(e,n,r){return t("plugin:image|new",{rgba:i(e),width:n,height:r}).then((e=>new a(e)))}static async fromBytes(e){return t("plugin:image|from_bytes",{bytes:i(e)}).then((e=>new a(e)))}static async fromPath(e){return t("plugin:image|from_path",{path:e}).then((e=>new a(e)))}async rgba(){return t("plugin:image|rgba",{rid:this.rid}).then((e=>new Uint8Array(e)))}async size(){return t("plugin:image|size",{rid:this.rid})}}function i(e){return null==e?null:"string"==typeof e?e:e instanceof a?e.rid:e}return e.clear=async function(){await t("plugin:clipboard-manager|clear")},e.readImage=async function(){return await t("plugin:clipboard-manager|read_image").then((e=>new a(e)))},e.readText=async function(){return await t("plugin:clipboard-manager|read_text")},e.writeHtml=async function(e,n){await t("plugin:clipboard-manager|write_html",{html:e,altText:n})},e.writeImage=async function(e){await t("plugin:clipboard-manager|write_image",{image:i(e)})},e.writeText=async function(e,n){await t("plugin:clipboard-manager|write_text",{label:n?.label,text:e})},e}({});Object.defineProperty(window.__TAURI__,"clipboardManager",{value:__TAURI_PLUGIN_CLIPBOARD_MANAGER__})} diff --git a/plugins/clipboard-manager/build.rs b/plugins/clipboard-manager/build.rs index ea12ef85..9bbeddfc 100644 --- a/plugins/clipboard-manager/build.rs +++ b/plugins/clipboard-manager/build.rs @@ -2,16 +2,24 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT +const COMMANDS: &[&str] = &[ + "write_text", + "read_text", + "write_image", + "read_image", + "write_html", + "clear", +]; + fn main() { - if let Err(error) = tauri_build::mobile::PluginBuilder::new() + let result = tauri_plugin::Builder::new(COMMANDS) + .global_api_script_path("./api-iife.js") .android_path("android") .ios_path("ios") - .run() - { - 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")) { - std::process::exit(1); - } + .try_build(); + + // when building documentation for Android the plugin build result is always Err() and is irrelevant to the crate documentation build + if !(cfg!(docsrs) && std::env::var("TARGET").unwrap().contains("android")) { + result.unwrap(); } } diff --git a/plugins/clipboard-manager/guest-js/index.ts b/plugins/clipboard-manager/guest-js/index.ts index 04f84a9d..a37bbfab 100644 --- a/plugins/clipboard-manager/guest-js/index.ts +++ b/plugins/clipboard-manager/guest-js/index.ts @@ -8,14 +8,8 @@ * @module */ -import { invoke } from "@tauri-apps/api/primitives"; - -interface Clip { - kind: K; - options: T; -} - -type ClipResponse = Clip<"PlainText", string>; +import { invoke } from '@tauri-apps/api/core' +import { Image, transformImage } from '@tauri-apps/api/image' /** * Writes plain text to the clipboard. @@ -32,17 +26,12 @@ type ClipResponse = Clip<"PlainText", string>; */ async function writeText( text: string, - opts?: { label?: string }, + opts?: { label?: string } ): Promise { - return invoke("plugin:clipboard|write", { - data: { - kind: "PlainText", - options: { - label: opts?.label, - text, - }, - }, - }); + await invoke('plugin:clipboard-manager|write_text', { + label: opts?.label, + text + }) } /** @@ -55,8 +44,108 @@ async function writeText( * @since 2.0.0 */ async function readText(): Promise { - const kind: ClipResponse = await invoke("plugin:clipboard|read"); - return kind.options; + return await invoke('plugin:clipboard-manager|read_text') +} + +/** + * Writes image buffer to the clipboard. + * + * #### Platform-specific + * + * - **Android / iOS:** Not supported. + * + * @example + * ```typescript + * import { writeImage } from '@tauri-apps/plugin-clipboard-manager'; + * const buffer = [ + * // A red pixel + * 255, 0, 0, 255, + * + * // A green pixel + * 0, 255, 0, 255, + * ]; + * await writeImage(buffer); + * ``` + * + * @returns A promise indicating the success or failure of the operation. + * + * @since 2.0.0 + */ +async function writeImage( + image: string | Image | Uint8Array | ArrayBuffer | number[] +): Promise { + await invoke('plugin:clipboard-manager|write_image', { + image: transformImage(image) + }) +} + +/** + * Gets the clipboard content as Uint8Array image. + * + * #### Platform-specific + * + * - **Android / iOS:** Not supported. + * + * @example + * ```typescript + * import { readImage } from '@tauri-apps/plugin-clipboard-manager'; + * + * const clipboardImage = await readImage(); + * const blob = new Blob([await clipboardImage.rgba()], { type: 'image' }) + * const url = URL.createObjectURL(blob) + * ``` + * @since 2.0.0 + */ +async function readImage(): Promise { + return await invoke('plugin:clipboard-manager|read_image').then( + (rid) => new Image(rid) + ) +} + +/** + * * Writes HTML or fallbacks to write provided plain text to the clipboard. + * + * #### Platform-specific + * + * - **Android / iOS:** Not supported. + * + * @example + * ```typescript + * import { writeHtml } from '@tauri-apps/plugin-clipboard-manager'; + * await writeHtml('

Tauri is awesome!

', 'plaintext'); + * // The following will write "

Tauri is awesome

" as plain text + * await writeHtml('

Tauri is awesome!

', '

Tauri is awesome

'); + * // we can read html data only as a string so there's just readText(), no readHtml() + * assert(await readText(), '

Tauri is awesome!

'); + * ``` + * + * @returns A promise indicating the success or failure of the operation. + * + * @since 2.0.0 + */ +async function writeHtml(html: string, altText?: string): Promise { + await invoke('plugin:clipboard-manager|write_html', { + html, + altText + }) +} + +/** + * Clears the clipboard. + * + * #### Platform-specific + * + * - **Android:** Only supported on SDK 28+. For older releases we write an empty string to the clipboard instead. + * + * @example + * ```typescript + * import { clear } from '@tauri-apps/plugin-clipboard-manager'; + * await clear(); + * ``` + * @since 2.0.0 + */ +async function clear(): Promise { + await invoke('plugin:clipboard-manager|clear') } -export { writeText, readText }; +export { writeText, readText, writeHtml, clear, readImage, writeImage } diff --git a/plugins/clipboard-manager/ios/Package.swift b/plugins/clipboard-manager/ios/Package.swift index f6200857..6da5303e 100644 --- a/plugins/clipboard-manager/ios/Package.swift +++ b/plugins/clipboard-manager/ios/Package.swift @@ -6,28 +6,29 @@ import PackageDescription let package = Package( - name: "tauri-plugin-clipboard-manager", - platforms: [ - .iOS(.v13), - ], - products: [ - // Products define the executables and libraries a package produces, and make them visible to other packages. - .library( - name: "tauri-plugin-clipboard-manager", - type: .static, - targets: ["tauri-plugin-clipboard-manager"]), - ], - dependencies: [ - .package(name: "Tauri", path: "../.tauri/tauri-api") - ], - targets: [ - // Targets are the basic building blocks of a package. A target can define a module or a test suite. - // Targets can depend on other targets in this package, and on products in packages this package depends on. - .target( - name: "tauri-plugin-clipboard-manager", - dependencies: [ - .byName(name: "Tauri") - ], - path: "Sources") - ] + name: "tauri-plugin-clipboard-manager", + platforms: [ + .macOS(.v10_13), + .iOS(.v13), + ], + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .library( + name: "tauri-plugin-clipboard-manager", + type: .static, + targets: ["tauri-plugin-clipboard-manager"]) + ], + dependencies: [ + .package(name: "Tauri", path: "../.tauri/tauri-api") + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .target( + name: "tauri-plugin-clipboard-manager", + dependencies: [ + .byName(name: "Tauri") + ], + path: "Sources") + ] ) diff --git a/plugins/clipboard-manager/ios/Sources/ClipboardPlugin.swift b/plugins/clipboard-manager/ios/Sources/ClipboardPlugin.swift index 5f84aa65..cb4fc9b2 100644 --- a/plugins/clipboard-manager/ios/Sources/ClipboardPlugin.swift +++ b/plugins/clipboard-manager/ios/Sources/ClipboardPlugin.swift @@ -2,42 +2,48 @@ // 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 writeText(_ 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 readText(_ invoke: Invoke) throws { + let clipboard = UIPasteboard.general + if let text = clipboard.string { + invoke.resolve(ReadClipData.plainText(text: text)) + } else { + invoke.reject("Clipboard is empty") + } + } + + @objc public func clear(_ invoke: Invoke) throws { + let clipboard = UIPasteboard.general + clipboard.items = [] + invoke.resolve() + } } @_cdecl("init_plugin_clipboard") diff --git a/plugins/clipboard-manager/package.json b/plugins/clipboard-manager/package.json index da878abb..9b78843b 100644 --- a/plugins/clipboard-manager/package.json +++ b/plugins/clipboard-manager/package.json @@ -1,32 +1,29 @@ { "name": "@tauri-apps/plugin-clipboard-manager", - "version": "2.0.0-alpha.1", - "license": "MIT or APACHE-2.0", + "version": "2.2.2", + "license": "MIT OR Apache-2.0", "authors": [ "Tauri Programme within The Commons Conservancy" ], + "repository": "https://github.com/tauri-apps/plugins-workspace", "type": "module", - "browser": "dist-js/index.min.js", - "module": "dist-js/index.mjs", - "types": "dist-js/index.d.ts", + "types": "./dist-js/index.d.ts", + "main": "./dist-js/index.cjs", + "module": "./dist-js/index.js", "exports": { - "import": "./dist-js/index.mjs", "types": "./dist-js/index.d.ts", - "browser": "./dist-js/index.min.js" + "import": "./dist-js/index.js", + "require": "./dist-js/index.cjs" }, "scripts": { "build": "rollup -c" }, "files": [ "dist-js", - "!dist-js/**/*.map", "README.md", "LICENSE" ], - "devDependencies": { - "tslib": "^2.4.1" - }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.9" + "@tauri-apps/api": "^2.0.0" } } diff --git a/plugins/clipboard-manager/permissions/autogenerated/commands/clear.toml b/plugins/clipboard-manager/permissions/autogenerated/commands/clear.toml new file mode 100644 index 00000000..83de1819 --- /dev/null +++ b/plugins/clipboard-manager/permissions/autogenerated/commands/clear.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-clear" +description = "Enables the clear command without any pre-configured scope." +commands.allow = ["clear"] + +[[permission]] +identifier = "deny-clear" +description = "Denies the clear command without any pre-configured scope." +commands.deny = ["clear"] diff --git a/plugins/clipboard-manager/permissions/autogenerated/commands/read_image.toml b/plugins/clipboard-manager/permissions/autogenerated/commands/read_image.toml new file mode 100644 index 00000000..cfed86db --- /dev/null +++ b/plugins/clipboard-manager/permissions/autogenerated/commands/read_image.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-read-image" +description = "Enables the read_image command without any pre-configured scope." +commands.allow = ["read_image"] + +[[permission]] +identifier = "deny-read-image" +description = "Denies the read_image command without any pre-configured scope." +commands.deny = ["read_image"] diff --git a/plugins/clipboard-manager/permissions/autogenerated/commands/read_text.toml b/plugins/clipboard-manager/permissions/autogenerated/commands/read_text.toml new file mode 100644 index 00000000..29844892 --- /dev/null +++ b/plugins/clipboard-manager/permissions/autogenerated/commands/read_text.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-read-text" +description = "Enables the read_text command without any pre-configured scope." +commands.allow = ["read_text"] + +[[permission]] +identifier = "deny-read-text" +description = "Denies the read_text command without any pre-configured scope." +commands.deny = ["read_text"] diff --git a/plugins/clipboard-manager/permissions/autogenerated/commands/write_html.toml b/plugins/clipboard-manager/permissions/autogenerated/commands/write_html.toml new file mode 100644 index 00000000..5e292808 --- /dev/null +++ b/plugins/clipboard-manager/permissions/autogenerated/commands/write_html.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-write-html" +description = "Enables the write_html command without any pre-configured scope." +commands.allow = ["write_html"] + +[[permission]] +identifier = "deny-write-html" +description = "Denies the write_html command without any pre-configured scope." +commands.deny = ["write_html"] diff --git a/plugins/clipboard-manager/permissions/autogenerated/commands/write_image.toml b/plugins/clipboard-manager/permissions/autogenerated/commands/write_image.toml new file mode 100644 index 00000000..12e8e235 --- /dev/null +++ b/plugins/clipboard-manager/permissions/autogenerated/commands/write_image.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-write-image" +description = "Enables the write_image command without any pre-configured scope." +commands.allow = ["write_image"] + +[[permission]] +identifier = "deny-write-image" +description = "Denies the write_image command without any pre-configured scope." +commands.deny = ["write_image"] diff --git a/plugins/clipboard-manager/permissions/autogenerated/commands/write_text.toml b/plugins/clipboard-manager/permissions/autogenerated/commands/write_text.toml new file mode 100644 index 00000000..ebff875a --- /dev/null +++ b/plugins/clipboard-manager/permissions/autogenerated/commands/write_text.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-write-text" +description = "Enables the write_text command without any pre-configured scope." +commands.allow = ["write_text"] + +[[permission]] +identifier = "deny-write-text" +description = "Denies the write_text command without any pre-configured scope." +commands.deny = ["write_text"] diff --git a/plugins/clipboard-manager/permissions/autogenerated/reference.md b/plugins/clipboard-manager/permissions/autogenerated/reference.md new file mode 100644 index 00000000..f8bed009 --- /dev/null +++ b/plugins/clipboard-manager/permissions/autogenerated/reference.md @@ -0,0 +1,177 @@ +## Default Permission + +No features are enabled by default, as we believe +the clipboard can be inherently dangerous and it is +application specific if read and/or write access is needed. + +Clipboard interaction needs to be explicitly enabled. + + +#### This default permission set includes the following: + + +## Permission Table + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IdentifierDescription
+ +`clipboard-manager:allow-clear` + + + +Enables the clear command without any pre-configured scope. + +
+ +`clipboard-manager:deny-clear` + + + +Denies the clear command without any pre-configured scope. + +
+ +`clipboard-manager:allow-read-image` + + + +Enables the read_image command without any pre-configured scope. + +
+ +`clipboard-manager:deny-read-image` + + + +Denies the read_image command without any pre-configured scope. + +
+ +`clipboard-manager:allow-read-text` + + + +Enables the read_text command without any pre-configured scope. + +
+ +`clipboard-manager:deny-read-text` + + + +Denies the read_text command without any pre-configured scope. + +
+ +`clipboard-manager:allow-write-html` + + + +Enables the write_html command without any pre-configured scope. + +
+ +`clipboard-manager:deny-write-html` + + + +Denies the write_html command without any pre-configured scope. + +
+ +`clipboard-manager:allow-write-image` + + + +Enables the write_image command without any pre-configured scope. + +
+ +`clipboard-manager:deny-write-image` + + + +Denies the write_image command without any pre-configured scope. + +
+ +`clipboard-manager:allow-write-text` + + + +Enables the write_text command without any pre-configured scope. + +
+ +`clipboard-manager:deny-write-text` + + + +Denies the write_text command without any pre-configured scope. + +
diff --git a/plugins/clipboard-manager/permissions/default.toml b/plugins/clipboard-manager/permissions/default.toml new file mode 100644 index 00000000..d6f65195 --- /dev/null +++ b/plugins/clipboard-manager/permissions/default.toml @@ -0,0 +1,11 @@ +"$schema" = "schemas/schema.json" +[default] +description = """ +No features are enabled by default, as we believe +the clipboard can be inherently dangerous and it is +application specific if read and/or write access is needed. + +Clipboard interaction needs to be explicitly enabled. +""" + +permissions = [] diff --git a/plugins/clipboard-manager/permissions/schemas/schema.json b/plugins/clipboard-manager/permissions/schemas/schema.json new file mode 100644 index 00000000..891c6f0d --- /dev/null +++ b/plugins/clipboard-manager/permissions/schemas/schema.json @@ -0,0 +1,378 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "PermissionFile", + "description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.", + "type": "object", + "properties": { + "default": { + "description": "The default permission set for the plugin", + "anyOf": [ + { + "$ref": "#/definitions/DefaultPermission" + }, + { + "type": "null" + } + ] + }, + "set": { + "description": "A list of permissions sets defined", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionSet" + } + }, + "permission": { + "description": "A list of inlined permissions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Permission" + } + } + }, + "definitions": { + "DefaultPermission": { + "description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.", + "type": "object", + "required": [ + "permissions" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "PermissionSet": { + "description": "A set of direct permissions grouped together under a new name.", + "type": "object", + "required": [ + "description", + "identifier", + "permissions" + ], + "properties": { + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does.", + "type": "string" + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionKind" + } + } + } + }, + "Permission": { + "description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.", + "type": "object", + "required": [ + "identifier" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri internal convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "commands": { + "description": "Allowed or denied commands when using this permission.", + "default": { + "allow": [], + "deny": [] + }, + "allOf": [ + { + "$ref": "#/definitions/Commands" + } + ] + }, + "scope": { + "description": "Allowed or denied scoped when using this permission.", + "allOf": [ + { + "$ref": "#/definitions/Scopes" + } + ] + }, + "platforms": { + "description": "Target platforms this permission applies. By default all platforms are affected by this permission.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Target" + } + } + } + }, + "Commands": { + "description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.", + "type": "object", + "properties": { + "allow": { + "description": "Allowed command.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "deny": { + "description": "Denied command, which takes priority.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "Scopes": { + "description": "An argument for fine grained behavior control of Tauri commands.\n\nIt can be of any serde serializable type and is used to allow or prevent certain actions inside a Tauri command. The configured scope is passed to the command and will be enforced by the command implementation.\n\n## Example\n\n```json { \"allow\": [{ \"path\": \"$HOME/**\" }], \"deny\": [{ \"path\": \"$HOME/secret.txt\" }] } ```", + "type": "object", + "properties": { + "allow": { + "description": "Data that defines what is allowed by the scope.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + }, + "deny": { + "description": "Data that defines what is denied by the scope. This should be prioritized by validation logic.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + } + } + }, + "Value": { + "description": "All supported ACL values.", + "anyOf": [ + { + "description": "Represents a null JSON value.", + "type": "null" + }, + { + "description": "Represents a [`bool`].", + "type": "boolean" + }, + { + "description": "Represents a valid ACL [`Number`].", + "allOf": [ + { + "$ref": "#/definitions/Number" + } + ] + }, + { + "description": "Represents a [`String`].", + "type": "string" + }, + { + "description": "Represents a list of other [`Value`]s.", + "type": "array", + "items": { + "$ref": "#/definitions/Value" + } + }, + { + "description": "Represents a map of [`String`] keys to [`Value`]s.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/Value" + } + } + ] + }, + "Number": { + "description": "A valid ACL number.", + "anyOf": [ + { + "description": "Represents an [`i64`].", + "type": "integer", + "format": "int64" + }, + { + "description": "Represents a [`f64`].", + "type": "number", + "format": "double" + } + ] + }, + "Target": { + "description": "Platform target.", + "oneOf": [ + { + "description": "MacOS.", + "type": "string", + "enum": [ + "macOS" + ] + }, + { + "description": "Windows.", + "type": "string", + "enum": [ + "windows" + ] + }, + { + "description": "Linux.", + "type": "string", + "enum": [ + "linux" + ] + }, + { + "description": "Android.", + "type": "string", + "enum": [ + "android" + ] + }, + { + "description": "iOS.", + "type": "string", + "enum": [ + "iOS" + ] + } + ] + }, + "PermissionKind": { + "type": "string", + "oneOf": [ + { + "description": "Enables the clear command without any pre-configured scope.", + "type": "string", + "const": "allow-clear", + "markdownDescription": "Enables the clear command without any pre-configured scope." + }, + { + "description": "Denies the clear command without any pre-configured scope.", + "type": "string", + "const": "deny-clear", + "markdownDescription": "Denies the clear command without any pre-configured scope." + }, + { + "description": "Enables the read_image command without any pre-configured scope.", + "type": "string", + "const": "allow-read-image", + "markdownDescription": "Enables the read_image command without any pre-configured scope." + }, + { + "description": "Denies the read_image command without any pre-configured scope.", + "type": "string", + "const": "deny-read-image", + "markdownDescription": "Denies the read_image command without any pre-configured scope." + }, + { + "description": "Enables the read_text command without any pre-configured scope.", + "type": "string", + "const": "allow-read-text", + "markdownDescription": "Enables the read_text command without any pre-configured scope." + }, + { + "description": "Denies the read_text command without any pre-configured scope.", + "type": "string", + "const": "deny-read-text", + "markdownDescription": "Denies the read_text command without any pre-configured scope." + }, + { + "description": "Enables the write_html command without any pre-configured scope.", + "type": "string", + "const": "allow-write-html", + "markdownDescription": "Enables the write_html command without any pre-configured scope." + }, + { + "description": "Denies the write_html command without any pre-configured scope.", + "type": "string", + "const": "deny-write-html", + "markdownDescription": "Denies the write_html command without any pre-configured scope." + }, + { + "description": "Enables the write_image command without any pre-configured scope.", + "type": "string", + "const": "allow-write-image", + "markdownDescription": "Enables the write_image command without any pre-configured scope." + }, + { + "description": "Denies the write_image command without any pre-configured scope.", + "type": "string", + "const": "deny-write-image", + "markdownDescription": "Denies the write_image command without any pre-configured scope." + }, + { + "description": "Enables the write_text command without any pre-configured scope.", + "type": "string", + "const": "allow-write-text", + "markdownDescription": "Enables the write_text command without any pre-configured scope." + }, + { + "description": "Denies the write_text command without any pre-configured scope.", + "type": "string", + "const": "deny-write-text", + "markdownDescription": "Denies the write_text command without any pre-configured scope." + }, + { + "description": "No features are enabled by default, as we believe\nthe clipboard can be inherently dangerous and it is \napplication specific if read and/or write access is needed.\n\nClipboard interaction needs to be explicitly enabled.\n", + "type": "string", + "const": "default", + "markdownDescription": "No features are enabled by default, as we believe\nthe clipboard can be inherently dangerous and it is \napplication specific if read and/or write access is needed.\n\nClipboard interaction needs to be explicitly enabled.\n" + } + ] + } + } +} \ No newline at end of file diff --git a/plugins/clipboard-manager/rollup.config.js b/plugins/clipboard-manager/rollup.config.js new file mode 100644 index 00000000..1f349ec8 --- /dev/null +++ b/plugins/clipboard-manager/rollup.config.js @@ -0,0 +1,7 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import { createConfig } from '../../shared/rollup.config.js' + +export default createConfig() diff --git a/plugins/clipboard-manager/rollup.config.mjs b/plugins/clipboard-manager/rollup.config.mjs deleted file mode 100644 index 99a3dd31..00000000 --- a/plugins/clipboard-manager/rollup.config.mjs +++ /dev/null @@ -1,11 +0,0 @@ -import { readFileSync } from "fs"; - -import { createConfig } from "../../shared/rollup.config.mjs"; - -export default createConfig({ - input: "guest-js/index.ts", - pkg: JSON.parse( - readFileSync(new URL("./package.json", import.meta.url), "utf8"), - ), - external: [/^@tauri-apps\/api/], -}); diff --git a/plugins/clipboard-manager/src/api-iife.js b/plugins/clipboard-manager/src/api-iife.js deleted file mode 100644 index 1f5f7607..00000000 --- a/plugins/clipboard-manager/src/api-iife.js +++ /dev/null @@ -1 +0,0 @@ -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__})} diff --git a/plugins/clipboard-manager/src/commands.rs b/plugins/clipboard-manager/src/commands.rs index eec868a8..a8dd94ac 100644 --- a/plugins/clipboard-manager/src/commands.rs +++ b/plugins/clipboard-manager/src/commands.rs @@ -2,23 +2,79 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use tauri::{command, AppHandle, Runtime, State}; +use tauri::{command, image::JsImage, AppHandle, Manager, ResourceId, Runtime, State, Webview}; -use crate::{ClipKind, Clipboard, ClipboardContents, Result}; +use crate::{Clipboard, Result}; #[command] -pub(crate) async fn write( +#[cfg(desktop)] +pub(crate) async fn write_text( _app: AppHandle, clipboard: State<'_, Clipboard>, - data: ClipKind, + text: &str, + #[allow(unused)] label: Option, ) -> Result<()> { - clipboard.write(data) + clipboard.write_text(text) } #[command] -pub(crate) async fn read( +#[cfg(not(desktop))] +pub(crate) async fn write_text( _app: AppHandle, clipboard: State<'_, Clipboard>, -) -> Result { - clipboard.read() + text: &str, + #[allow(unused)] label: Option<&str>, +) -> Result<()> { + match label { + Some(label) => clipboard.write_text_with_label(text, label), + None => clipboard.write_text(text), + } +} + +#[command] +pub(crate) async fn read_text( + _app: AppHandle, + clipboard: State<'_, Clipboard>, +) -> Result { + clipboard.read_text() +} + +#[command] +pub(crate) async fn write_image( + webview: Webview, + clipboard: State<'_, Clipboard>, + image: JsImage, +) -> Result<()> { + let resources_table = webview.resources_table(); + let image = image.into_img(&resources_table)?; + clipboard.write_image(&image) +} + +#[command] +pub(crate) async fn read_image( + webview: Webview, + clipboard: State<'_, Clipboard>, +) -> Result { + let image = clipboard.read_image()?.to_owned(); + let mut resources_table = webview.resources_table(); + let rid = resources_table.add(image); + Ok(rid) +} + +#[command] +pub(crate) async fn write_html( + _app: AppHandle, + clipboard: State<'_, Clipboard>, + html: &str, + alt_text: Option<&str>, +) -> Result<()> { + clipboard.write_html(html, alt_text) +} + +#[command] +pub(crate) async fn clear( + _app: AppHandle, + clipboard: State<'_, Clipboard>, +) -> Result<()> { + clipboard.clear() } diff --git a/plugins/clipboard-manager/src/desktop.rs b/plugins/clipboard-manager/src/desktop.rs index 8fcc8450..f3570cc0 100644 --- a/plugins/clipboard-manager/src/desktop.rs +++ b/plugins/clipboard-manager/src/desktop.rs @@ -2,12 +2,11 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT +use arboard::ImageData; use serde::de::DeserializeOwned; -use tauri::{plugin::PluginApi, AppHandle, Runtime}; +use tauri::{image::Image, plugin::PluginApi, AppHandle, Runtime}; -use crate::models::*; - -use std::sync::Mutex; +use std::{borrow::Cow, sync::Mutex}; pub fn init( app: &AppHandle, @@ -15,7 +14,7 @@ pub fn init( ) -> crate::Result> { Ok(Clipboard { app: app.clone(), - clipboard: arboard::Clipboard::new().map(Mutex::new), + clipboard: arboard::Clipboard::new().map(|c| Mutex::new(Some(c))), }) } @@ -23,25 +22,102 @@ pub fn init( pub struct Clipboard { #[allow(dead_code)] app: AppHandle, - clipboard: Result, arboard::Error>, + // According to arboard docs the clipboard must be dropped before exit. + // Since tauri doesn't call drop on exit we'll use an Option to take() on RunEvent::Exit. + clipboard: Result>, arboard::Error>, } impl Clipboard { - pub fn write(&self, kind: ClipKind) -> crate::Result<()> { - let ClipKind::PlainText { text, .. } = kind; + pub fn write_text<'a, T: Into>>(&self, text: T) -> crate::Result<()> { + match &self.clipboard { + Ok(clipboard) => clipboard + .lock() + .unwrap() + .as_mut() + .unwrap() + .set_text(text) + .map_err(Into::into), + Err(e) => Err(crate::Error::Clipboard(e.to_string())), + } + } + + pub fn write_image(&self, image: &Image<'_>) -> crate::Result<()> { + match &self.clipboard { + Ok(clipboard) => clipboard + .lock() + .unwrap() + .as_mut() + .unwrap() + .set_image(ImageData { + bytes: Cow::Borrowed(image.rgba()), + width: image.width() as usize, + height: image.height() as usize, + }) + .map_err(Into::into), + Err(e) => Err(crate::Error::Clipboard(e.to_string())), + } + } + + /// Warning: This method should not be used on the main thread! Otherwise the underlying libraries may deadlock on Linux, freezing the whole app, when trying to copy data copied from this app, for example if the user copies text from the WebView. + pub fn read_text(&self) -> crate::Result { + match &self.clipboard { + Ok(clipboard) => { + let text = clipboard.lock().unwrap().as_mut().unwrap().get_text()?; + Ok(text) + } + Err(e) => Err(crate::Error::Clipboard(e.to_string())), + } + } + + pub fn write_html<'a, T: Into>>( + &self, + html: T, + alt_text: Option, + ) -> crate::Result<()> { match &self.clipboard { - Ok(clipboard) => clipboard.lock().unwrap().set_text(text).map_err(Into::into), + Ok(clipboard) => clipboard + .lock() + .unwrap() + .as_mut() + .unwrap() + .set_html(html, alt_text) + .map_err(Into::into), Err(e) => Err(crate::Error::Clipboard(e.to_string())), } } - pub fn read(&self) -> crate::Result { + pub fn clear(&self) -> crate::Result<()> { + match &self.clipboard { + Ok(clipboard) => clipboard + .lock() + .unwrap() + .as_mut() + .unwrap() + .clear() + .map_err(Into::into), + Err(e) => Err(crate::Error::Clipboard(e.to_string())), + } + } + + /// Warning: This method should not be used on the main thread! Otherwise the underlying libraries may deadlock on Linux, freezing the whole app, when trying to copy data copied from this app, for example if the user copies text from the WebView. + pub fn read_image(&self) -> crate::Result> { match &self.clipboard { Ok(clipboard) => { - let text = clipboard.lock().unwrap().get_text()?; - Ok(ClipboardContents::PlainText(text)) + let image = clipboard.lock().unwrap().as_mut().unwrap().get_image()?; + let image = Image::new_owned( + image.bytes.to_vec(), + image.width as u32, + image.height as u32, + ); + Ok(image) } Err(e) => Err(crate::Error::Clipboard(e.to_string())), } } + + pub(crate) fn cleanup(&self) { + if let Ok(clipboard) = &self.clipboard { + clipboard.lock().unwrap().take(); + } + } } diff --git a/plugins/clipboard-manager/src/error.rs b/plugins/clipboard-manager/src/error.rs index bf71802f..1b8cf482 100644 --- a/plugins/clipboard-manager/src/error.rs +++ b/plugins/clipboard-manager/src/error.rs @@ -11,9 +11,10 @@ pub enum Error { #[cfg(mobile)] #[error(transparent)] PluginInvoke(#[from] tauri::plugin::mobile::PluginInvokeError), - #[cfg(desktop)] #[error("{0}")] Clipboard(String), + #[error(transparent)] + Tauri(#[from] tauri::Error), } impl Serialize for Error { diff --git a/plugins/clipboard-manager/src/lib.rs b/plugins/clipboard-manager/src/lib.rs index d4ccdb0a..0cbb4e41 100644 --- a/plugins/clipboard-manager/src/lib.rs +++ b/plugins/clipboard-manager/src/lib.rs @@ -2,8 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -//! [![](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/clipboard-manager/banner.png)](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/clipboard-manager) -//! //! Read and write to the system clipboard. #![doc( @@ -13,11 +11,9 @@ use tauri::{ plugin::{Builder, TauriPlugin}, - Manager, Runtime, + Manager, RunEvent, Runtime, }; -pub use models::*; - #[cfg(desktop)] mod desktop; #[cfg(mobile)] @@ -25,16 +21,15 @@ mod mobile; mod commands; mod error; -mod models; pub use error::{Error, Result}; #[cfg(desktop)] -use desktop::Clipboard; +pub use desktop::Clipboard; #[cfg(mobile)] -use mobile::Clipboard; +pub use mobile::Clipboard; -/// Extensions to [`tauri::App`], [`tauri::AppHandle`] and [`tauri::Window`] to access the clipboard APIs. +/// Extensions to [`tauri::App`], [`tauri::AppHandle`], [`tauri::WebviewWindow`], [`tauri::Webview`] and [`tauri::Window`] to access the clipboard APIs. pub trait ClipboardExt { fn clipboard(&self) -> &Clipboard; } @@ -47,9 +42,15 @@ impl> crate::ClipboardExt for T { /// Initializes the plugin. pub fn init() -> TauriPlugin { - Builder::new("clipboard") - .js_init_script(include_str!("api-iife.js").to_string()) - .invoke_handler(tauri::generate_handler![commands::write, commands::read]) + Builder::new("clipboard-manager") + .invoke_handler(tauri::generate_handler![ + commands::write_text, + commands::read_text, + commands::read_image, + commands::write_image, + commands::write_html, + commands::clear + ]) .setup(|app, api| { #[cfg(mobile)] let clipboard = mobile::init(app, api)?; @@ -58,5 +59,11 @@ pub fn init() -> TauriPlugin { app.manage(clipboard); Ok(()) }) + .on_event(|_app, _event| { + #[cfg(desktop)] + if let RunEvent::Exit = _event { + _app.clipboard().cleanup(); + } + }) .build() } diff --git a/plugins/clipboard-manager/src/mobile.rs b/plugins/clipboard-manager/src/mobile.rs index 07964711..72d5f6e0 100644 --- a/plugins/clipboard-manager/src/mobile.rs +++ b/plugins/clipboard-manager/src/mobile.rs @@ -3,12 +3,14 @@ // SPDX-License-Identifier: MIT use serde::de::DeserializeOwned; +use serde::{Deserialize, Serialize}; use tauri::{ + image::Image, plugin::{PluginApi, PluginHandle}, AppHandle, Runtime, }; -use crate::models::*; +use std::borrow::Cow; #[cfg(target_os = "android")] const PLUGIN_IDENTIFIER: &str = "app.tauri.clipboard"; @@ -32,11 +34,76 @@ pub fn init( pub struct Clipboard(PluginHandle); impl Clipboard { - pub fn write(&self, kind: ClipKind) -> crate::Result<()> { - self.0.run_mobile_plugin("write", kind).map_err(Into::into) + pub fn write_text<'a, T: Into>>(&self, text: T) -> crate::Result<()> { + let text = text.into().to_string(); + self.0 + .run_mobile_plugin("writeText", ClipKind::PlainText { text, label: None }) + .map_err(Into::into) } - pub fn read(&self) -> crate::Result { - self.0.run_mobile_plugin("read", ()).map_err(Into::into) + pub fn write_text_with_label<'a, T: Into>>( + &self, + text: T, + label: T, + ) -> crate::Result<()> { + let text = text.into().to_string(); + let label = label.into().to_string(); + self.0 + .run_mobile_plugin( + "writeText", + ClipKind::PlainText { + text, + label: Some(label), + }, + ) + .map_err(Into::into) } + + pub fn write_image(&self, _image: &Image<'_>) -> crate::Result<()> { + Err(crate::Error::Clipboard( + "Unsupported on this platform".to_string(), + )) + } + + pub fn read_text(&self) -> crate::Result { + self.0 + .run_mobile_plugin("readText", ()) + .map(|c| match c { + ClipboardContents::PlainText { text } => text, + }) + .map_err(Into::into) + } + + pub fn read_image(&self) -> crate::Result> { + Err(crate::Error::Clipboard( + "Unsupported on this platform".to_string(), + )) + } + + // Treat HTML as unsupported on mobile until tested + pub fn write_html<'a, T: Into>>( + &self, + _html: T, + _alt_text: Option, + ) -> crate::Result<()> { + Err(crate::Error::Clipboard( + "Unsupported on this platform".to_string(), + )) + } + + pub fn clear(&self) -> crate::Result<()> { + self.0.run_mobile_plugin("clear", ()).map_err(Into::into) + } +} + +#[derive(Debug, Deserialize, Serialize)] +#[serde(rename_all = "camelCase")] +enum ClipKind { + PlainText { label: Option, text: String }, +} + +#[derive(Debug, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +enum ClipboardContents { + PlainText { text: String }, } diff --git a/plugins/clipboard-manager/src/models.rs b/plugins/clipboard-manager/src/models.rs deleted file mode 100644 index c73daf93..00000000 --- a/plugins/clipboard-manager/src/models.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2019-2023 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - -use serde::{Deserialize, Serialize}; - -#[derive(Debug, Serialize, Deserialize)] -#[serde(tag = "kind", content = "options")] -pub enum ClipKind { - PlainText { label: Option, text: String }, -} - -#[derive(Debug, Serialize, Deserialize)] -#[serde(tag = "kind", content = "options")] -pub enum ClipboardContents { - PlainText(String), -} diff --git a/plugins/deep-link/.test-server/.well-known/apple-app-site-association b/plugins/deep-link/.test-server/.well-known/apple-app-site-association new file mode 100644 index 00000000..da5d0a77 --- /dev/null +++ b/plugins/deep-link/.test-server/.well-known/apple-app-site-association @@ -0,0 +1,17 @@ +{ + "applinks": { + "details": [ + { + "appIDs": [ + "Q93MBH6S2F.com.tauri.deep-link-example" + ], + "components": [ + { + "/": "/open/*", + "comment": "Matches any URL whose path starts with /open/" + } + ] + } + ] + } +} diff --git a/plugins/deep-link/.test-server/server.js b/plugins/deep-link/.test-server/server.js new file mode 100644 index 00000000..0e2fec50 --- /dev/null +++ b/plugins/deep-link/.test-server/server.js @@ -0,0 +1,27 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import http from 'http' +import fs from 'fs' + +const hostname = 'localhost' +const port = 8080 + +const server = http.createServer(function (req, res) { + console.log(req.url) + if (req.url == '/.well-known/apple-app-site-association') { + const association = fs.readFileSync( + '.well-known/apple-app-site-association' + ) + res.writeHead(200, { 'Content-Type': 'application/json' }) + res.end(association) + } else { + res.writeHead(404) + res.end('404 NOT FOUND') + } +}) + +server.listen(port, hostname, () => { + console.log('Server started on port', port) +}) diff --git a/plugins/deep-link/CHANGELOG.md b/plugins/deep-link/CHANGELOG.md index 62296851..742f392b 100644 --- a/plugins/deep-link/CHANGELOG.md +++ b/plugins/deep-link/CHANGELOG.md @@ -1,5 +1,155 @@ # Changelog +## \[2.3.0] + +- [`4d10acee`](https://github.com/tauri-apps/plugins-workspace/commit/4d10acee61bad8045705508121424ed5f2d381f6) ([#993](https://github.com/tauri-apps/plugins-workspace/pull/993) by [@m00nwtchr](https://github.com/tauri-apps/plugins-workspace/../../m00nwtchr)) Exposed Android's `path`, `pathPattern` and `pathSuffix` configurations. +- [`4d10acee`](https://github.com/tauri-apps/plugins-workspace/commit/4d10acee61bad8045705508121424ed5f2d381f6) ([#993](https://github.com/tauri-apps/plugins-workspace/pull/993) by [@m00nwtchr](https://github.com/tauri-apps/plugins-workspace/../../m00nwtchr)) Added a `scheme` configuration to set a scheme other than http/https. This is only supported on Android and will still default to http,https if not set. + +## \[2.2.1] + +### bug + +- [`38deef43`](https://github.com/tauri-apps/plugins-workspace/commit/38deef43dca9d5a09a38ed2da45b0f86c6afa1c5) ([#2483](https://github.com/tauri-apps/plugins-workspace/pull/2483)) Fix `is_registered` not being able to pickup deep link registered in `HKEY_LOCAL_MACHINE` on Windows +- [`38deef43`](https://github.com/tauri-apps/plugins-workspace/commit/38deef43dca9d5a09a38ed2da45b0f86c6afa1c5) ([#2483](https://github.com/tauri-apps/plugins-workspace/pull/2483)) Fix `unregister` not being able to remove deep link registered in `HKEY_LOCAL_MACHINE` on Windows + +## \[2.2.0] + +- [`3a79266b`](https://github.com/tauri-apps/plugins-workspace/commit/3a79266b8cf96a55b1ae6339d725567d45a44b1d) ([#2173](https://github.com/tauri-apps/plugins-workspace/pull/2173) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Bumped all plugins to `v2.2.0`. From now, the versions for the Rust and JavaScript packages of each plugin will be in sync with each other. + +## \[2.0.1] + +- [`b2aea045`](https://github.com/tauri-apps/plugins-workspace/commit/b2aea0456799775a7243706fdd7a5abf9a193992) ([#2008](https://github.com/tauri-apps/plugins-workspace/pull/2008) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) `onOpenUrl()` will now not call `getCurrent()` anymore, matching the documented behavior. + +## \[2.0.1] + +- [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. + +## \[2.0.0] + +- [`e2c4dfb6`](https://github.com/tauri-apps/plugins-workspace/commit/e2c4dfb6af43e5dd8d9ceba232c315f5febd55c1) Update to tauri v2 stable release. + +## \[2.0.0-rc.7] + +- [`3168e176`](https://github.com/tauri-apps/plugins-workspace/commit/3168e176031a61215be542595ba90ca51f8f2d97) ([#1806](https://github.com/tauri-apps/plugins-workspace/pull/1806) by [@auggiebennett](https://github.com/tauri-apps/plugins-workspace/../../auggiebennett)) Fix fails to start when having spaces in the main binary path on Windows + +## \[2.0.0-rc.6] + +- [`6f3f6679`](https://github.com/tauri-apps/plugins-workspace/commit/6f3f66794a87ef9d1c16667c425d5ad7091a9c2f) ([#1780](https://github.com/tauri-apps/plugins-workspace/pull/1780)) Added `DeepLink::on_open_url` function to match the JavaScript API implementation, + which wraps the `deep-link://new-url` event and also send the current deep link if there's any. + +## \[2.0.0-rc.5] + +- [`984110a9`](https://github.com/tauri-apps/plugins-workspace/commit/984110a978774712bad4d746ed06134d54debcd0) ([#1770](https://github.com/tauri-apps/plugins-workspace/pull/1770) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Emit the `deep-link://new-url` event on Linux and Windows when the app is executed with a deep link CLI argument, + matching the iOS and macOS behavior. + +## \[2.0.0-rc.2] + +- [`64a6240f`](https://github.com/tauri-apps/plugins-workspace/commit/64a6240f79fcd52267c8d721b727ae695055d7ff) ([#1759](https://github.com/tauri-apps/plugins-workspace/pull/1759) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Implement `get_current` on Linux and Windows. + +## \[2.0.0-rc.3] + +- [`4654591d`](https://github.com/tauri-apps/plugins-workspace/commit/4654591d820403d6fa1a007fd55bb0d85947a6cc) ([#1732](https://github.com/tauri-apps/plugins-workspace/pull/1732) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Allow empty configuration values. + +## \[2.0.0-rc.1] + +- [`e2e97db5`](https://github.com/tauri-apps/plugins-workspace/commit/e2e97db51983267f5be84d4f6f0278d58834d1f5) ([#1701](https://github.com/tauri-apps/plugins-workspace/pull/1701) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri 2.0.0-rc.8 + +## \[2.0.0-rc.1] + +- [`2c00c029`](https://github.com/tauri-apps/plugins-workspace/commit/2c00c0292c9127b81567de46691e8c0f73557261) ([#1630](https://github.com/tauri-apps/plugins-workspace/pull/1630) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Fixed an issue that caused multi-word IIFE names to not be formatted correctly. For example the `barcode-scanner` was defined as `window.__TAURI_PLUGIN_CLIPBOARDMANAGER__` instead of `window.__TAURI_PLUGIN_CLIPBOARD_MANAGER__`. +- [`5d170a54`](https://github.com/tauri-apps/plugins-workspace/commit/5d170a5444982dcc14135f6f1fc3e5da359f0eb0) ([#1671](https://github.com/tauri-apps/plugins-workspace/pull/1671) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri 2.0.0-rc.3. + +### changes + +- [`6b079cfd`](https://github.com/tauri-apps/plugins-workspace/commit/6b079cfdd107c94abc2c7300f6af00bac3ff4040) ([#1649](https://github.com/tauri-apps/plugins-workspace/pull/1649) by [@ahqsoftwares](https://github.com/tauri-apps/plugins-workspace/../../ahqsoftwares)) Remove targetSdk from build.kts files as it is deprecated and will be removed from DSL v9.0 + +## \[2.0.0-rc.0] + +- [`9887d1`](https://github.com/tauri-apps/plugins-workspace/commit/9887d14bd0e971c4c0f5c1188fc4005d3fc2e29e) Update to tauri RC. + +## \[2.0.0-beta.10] + +- [`99d6ac0f`](https://github.com/tauri-apps/plugins-workspace/commit/99d6ac0f9506a6a4a1aa59c728157190a7441af6) ([#1606](https://github.com/tauri-apps/plugins-workspace/pull/1606) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) The JS packages now specify the *minimum* `@tauri-apps/api` version instead of a single exact version. +- [`6de87966`](https://github.com/tauri-apps/plugins-workspace/commit/6de87966ecc00ad9d91c25be452f1f46bd2b7e1f) ([#1597](https://github.com/tauri-apps/plugins-workspace/pull/1597) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Update to tauri beta.25. + +## \[2.0.0-beta.9] + +- [`22a17980`](https://github.com/tauri-apps/plugins-workspace/commit/22a17980ff4f6f8c40adb1b8f4ffc6dae2fe7e30) ([#1537](https://github.com/tauri-apps/plugins-workspace/pull/1537) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri beta.24. + +## \[2.0.0-beta.8] + +- [`76daee7a`](https://github.com/tauri-apps/plugins-workspace/commit/76daee7aafece34de3092c86e531cf9eb1138989) ([#1512](https://github.com/tauri-apps/plugins-workspace/pull/1512) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Update to tauri beta.23. + +## \[2.0.0-beta.7] + +- [`0b008882`](https://github.com/tauri-apps/plugins-workspace/commit/0b0088821e50e33825f7d573b1c826cfeb38dda0) ([#1404](https://github.com/tauri-apps/plugins-workspace/pull/1404) by [@simonhyll](https://github.com/tauri-apps/plugins-workspace/../../simonhyll)) Fixed a typo in the `deep-link` js bindings causing `isRegistered` to not work. + +## \[2.0.0-beta.6] + +- [`9013854f`](https://github.com/tauri-apps/plugins-workspace/commit/9013854f42a49a230b9dbb9d02774765528a923f)([#1382](https://github.com/tauri-apps/plugins-workspace/pull/1382)) Update to tauri beta.22. + +## \[2.0.0-beta.5] + +- [`430bd6f4`](https://github.com/tauri-apps/plugins-workspace/commit/430bd6f4f379bee5d232ae6b098ae131db7f178a)([#1363](https://github.com/tauri-apps/plugins-workspace/pull/1363)) Update to tauri beta.20. + +## \[2.0.0-beta.4] + +- [`021d23be`](https://github.com/tauri-apps/plugins-workspace/commit/021d23bef330de4ce001993e0ef2c7ab7815f044)([#916](https://github.com/tauri-apps/plugins-workspace/pull/916)) Added desktop support. + +## \[2.0.0-beta.3] + +- [`bd1ed590`](https://github.com/tauri-apps/plugins-workspace/commit/bd1ed5903ffcce5500310dac1e59e8c67674ef1e)([#1237](https://github.com/tauri-apps/plugins-workspace/pull/1237)) Update to tauri beta.17. + +## \[2.0.0-beta.3] + +- [`a04ea2f`](https://github.com/tauri-apps/plugins-workspace/commit/a04ea2f38294d5a3987578283badc8eec87a7752)([#1071](https://github.com/tauri-apps/plugins-workspace/pull/1071)) The global API script is now only added to the binary when the `withGlobalTauri` config is true. + +## \[2.0.0-beta.2] + +- [`99bea25`](https://github.com/tauri-apps/plugins-workspace/commit/99bea2559c2c0648c2519c50a18cd124dacef57b)([#1005](https://github.com/tauri-apps/plugins-workspace/pull/1005)) Update to tauri beta.8. + +## \[2.0.0-beta.1] + +- [`569defb`](https://github.com/tauri-apps/plugins-workspace/commit/569defbe9492e38938554bb7bdc1be9151456d21) Update to tauri beta.4. + +## \[2.0.0-beta.0] + +- [`d198c01`](https://github.com/tauri-apps/plugins-workspace/commit/d198c014863ee260cb0de88a14b7fc4356ef7474)([#862](https://github.com/tauri-apps/plugins-workspace/pull/862)) Update to tauri beta. + +## \[2.0.0-alpha.5] + +- [`8b1d821`](https://github.com/tauri-apps/plugins-workspace/commit/8b1d821a375d66a61e06c78b7148e255855cfe1b)([#844](https://github.com/tauri-apps/plugins-workspace/pull/844)) Fixes issue with tauri alpha.20. + +## \[2.0.0-alpha.4] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.13. + +## \[2.0.0-alpha.3] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.12. + +## \[2.0.0-alpha.2] + +- [`e438e0a`](https://github.com/tauri-apps/plugins-workspace/commit/e438e0a62d4b430a5159f05f13ecd397dd891a0d)([#676](https://github.com/tauri-apps/plugins-workspace/pull/676)) Update to @tauri-apps/api v2.0.0-alpha.11. + +## \[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.9. + ## \[2.0.0-alpha.0] - [`eccd6f9`](https://github.com/tauri-apps/plugins-workspace/commit/eccd6f977af7629255b6f5a5205666c9079a86ed)([#504](https://github.com/tauri-apps/plugins-workspace/pull/504)) Initial release. + 0.0-alpha.0] + +- [`eccd6f9`](https://github.com/tauri-apps/plugins-workspace/commit/eccd6f977af7629255b6f5a5205666c9079a86ed)([#504](https://github.com/tauri-apps/plugins-workspace/pull/504)) Initial release. + +- [`eccd6f9`](https://github.com/tauri-apps/plugins-workspace/commit/eccd6f977af7629255b6f5a5205666c9079a86ed)([#504](https://github.com/tauri-apps/plugins-workspace/pull/504)) Initial release. + commit/eccd6f977af7629255b6f5a5205666c9079a86ed)([#504](https://github.com/tauri-apps/plugins-workspace/pull/504)) Initial release. + om/tauri-apps/plugins-workspace/commit/eccd6f977af7629255b6f5a5205666c9079a86ed)([#504](https://github.com/tauri-apps/plugins-workspace/pull/504)) Initial release. + +- [`eccd6f9`](https://github.com/tauri-apps/plugins-workspace/commit/eccd6f977af7629255b6f5a5205666c9079a86ed)([#504](https://github.com/tauri-apps/plugins-workspace/pull/504)) Initial release. + commit/eccd6f977af7629255b6f5a5205666c9079a86ed)([#504](https://github.com/tauri-apps/plugins-workspace/pull/504)) Initial release. + ithub.com/tauri-apps/plugins-workspace/pull/504)) Initial release. + ]\(https://github.com/tauri-apps/plugins-workspace/commit/eccd6f977af7629255b6f5a5205666c9079a86ed)([#504](https://github.com/tauri-apps/plugins-workspace/pull/504)) Initial release. + commit/eccd6f977af7629255b6f5a5205666c9079a86ed)([#504](https://github.com/tauri-apps/plugins-workspace/pull/504)) Initial release. + ithub.com/tauri-apps/plugins-workspace/pull/504)) Initial release. diff --git a/plugins/deep-link/Cargo.lock b/plugins/deep-link/Cargo.lock deleted file mode 100644 index 75626f5f..00000000 --- a/plugins/deep-link/Cargo.lock +++ /dev/null @@ -1,4089 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "addr2line" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - -[[package]] -name = "aho-corasick" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" -dependencies = [ - "memchr", -] - -[[package]] -name = "alloc-no-stdlib" -version = "2.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3" - -[[package]] -name = "alloc-stdlib" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece" -dependencies = [ - "alloc-no-stdlib", -] - -[[package]] -name = "android-tzdata" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" - -[[package]] -name = "android_system_properties" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" -dependencies = [ - "libc", -] - -[[package]] -name = "anyhow" -version = "1.0.71" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" - -[[package]] -name = "async-broadcast" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c48ccdbf6ca6b121e0f586cbc0e73ae440e56c67c30fa0873b4e110d9c26d2b" -dependencies = [ - "event-listener", - "futures-core", -] - -[[package]] -name = "async-channel" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" -dependencies = [ - "concurrent-queue", - "event-listener", - "futures-core", -] - -[[package]] -name = "async-executor" -version = "1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fa3dc5f2a8564f07759c008b9109dc0d39de92a88d5588b8a5036d286383afb" -dependencies = [ - "async-lock", - "async-task", - "concurrent-queue", - "fastrand", - "futures-lite", - "slab", -] - -[[package]] -name = "async-fs" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "279cf904654eeebfa37ac9bb1598880884924aab82e290aa65c9e77a0e142e06" -dependencies = [ - "async-lock", - "autocfg", - "blocking", - "futures-lite", -] - -[[package]] -name = "async-io" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" -dependencies = [ - "async-lock", - "autocfg", - "cfg-if", - "concurrent-queue", - "futures-lite", - "log", - "parking", - "polling", - "rustix", - "slab", - "socket2", - "waker-fn", -] - -[[package]] -name = "async-lock" -version = "2.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa24f727524730b077666307f2734b4a1a1c57acb79193127dcc8914d5242dd7" -dependencies = [ - "event-listener", -] - -[[package]] -name = "async-process" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a9d28b1d97e08915212e2e45310d47854eafa69600756fc735fb788f75199c9" -dependencies = [ - "async-io", - "async-lock", - "autocfg", - "blocking", - "cfg-if", - "event-listener", - "futures-lite", - "rustix", - "signal-hook", - "windows-sys", -] - -[[package]] -name = "async-recursion" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e97ce7de6cf12de5d7226c73f5ba9811622f4db3a5b91b55c53e987e5f91cba" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.25", -] - -[[package]] -name = "async-task" -version = "4.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc7ab41815b3c653ccd2978ec3255c81349336702dfdf62ee6f7069b12a3aae" - -[[package]] -name = "async-trait" -version = "0.1.71" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a564d521dd56509c4c47480d00b80ee55f7e385ae48db5744c67ad50c92d2ebf" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.25", -] - -[[package]] -name = "atk" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39991bc421ddf72f70159011b323ff49b0f783cc676a7287c59453da2e2531cf" -dependencies = [ - "atk-sys", - "bitflags", - "glib", - "libc", -] - -[[package]] -name = "atk-sys" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11ad703eb64dc058024f0e57ccfa069e15a413b98dbd50a1a950e743b7f11148" -dependencies = [ - "glib-sys", - "gobject-sys", - "libc", - "system-deps", -] - -[[package]] -name = "atomic-waker" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1181e1e0d1fce796a03db1ae795d67167da795f9cf4a39c37589e85ef57f26d3" - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "backtrace" -version = "0.3.68" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12" -dependencies = [ - "addr2line", - "cc", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", -] - -[[package]] -name = "base64" -version = "0.21.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "block" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" - -[[package]] -name = "block-buffer" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" -dependencies = [ - "generic-array", -] - -[[package]] -name = "blocking" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77231a1c8f801696fc0123ec6150ce92cffb8e164a02afb9c8ddee0e9b65ad65" -dependencies = [ - "async-channel", - "async-lock", - "async-task", - "atomic-waker", - "fastrand", - "futures-lite", - "log", -] - -[[package]] -name = "brotli" -version = "3.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1a0b1dbcc8ae29329621f8d4f0d835787c1c38bb1401979b49d13b0b305ff68" -dependencies = [ - "alloc-no-stdlib", - "alloc-stdlib", - "brotli-decompressor", -] - -[[package]] -name = "brotli-decompressor" -version = "2.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b6561fd3f895a11e8f72af2cb7d22e08366bebc2b6b57f7744c4bda27034744" -dependencies = [ - "alloc-no-stdlib", - "alloc-stdlib", -] - -[[package]] -name = "bumpalo" -version = "3.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" - -[[package]] -name = "bytemuck" -version = "1.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea" - -[[package]] -name = "byteorder" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" - -[[package]] -name = "bytes" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" -dependencies = [ - "serde", -] - -[[package]] -name = "cairo-rs" -version = "0.16.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3125b15ec28b84c238f6f476c6034016a5f6cc0221cb514ca46c532139fc97d" -dependencies = [ - "bitflags", - "cairo-sys-rs", - "glib", - "libc", - "once_cell", - "thiserror", -] - -[[package]] -name = "cairo-sys-rs" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c48f4af05fabdcfa9658178e1326efa061853f040ce7d72e33af6885196f421" -dependencies = [ - "glib-sys", - "libc", - "system-deps", -] - -[[package]] -name = "cargo_toml" -version = "0.15.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "599aa35200ffff8f04c1925aa1acc92fa2e08874379ef42e210a80e527e60838" -dependencies = [ - "serde", - "toml", -] - -[[package]] -name = "cc" -version = "1.0.79" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" - -[[package]] -name = "cesu8" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" - -[[package]] -name = "cfb" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d38f2da7a0a2c4ccf0065be06397cc26a81f4e528be095826eee9d4adbb8c60f" -dependencies = [ - "byteorder", - "fnv", - "uuid", -] - -[[package]] -name = "cfg-expr" -version = "0.15.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "215c0072ecc28f92eeb0eea38ba63ddfcb65c2828c46311d646f1a3ff5f9841c" -dependencies = [ - "smallvec", - "target-lexicon", -] - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "chrono" -version = "0.4.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" -dependencies = [ - "android-tzdata", - "iana-time-zone", - "num-traits", - "serde", - "winapi", -] - -[[package]] -name = "cocoa" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f425db7937052c684daec3bd6375c8abe2d146dca4b8b143d6db777c39138f3a" -dependencies = [ - "bitflags", - "block", - "cocoa-foundation", - "core-foundation", - "core-graphics", - "foreign-types", - "libc", - "objc", -] - -[[package]] -name = "cocoa-foundation" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "931d3837c286f56e3c58423ce4eba12d08db2374461a785c86f672b08b5650d6" -dependencies = [ - "bitflags", - "block", - "core-foundation", - "core-graphics-types", - "foreign-types", - "libc", - "objc", -] - -[[package]] -name = "color_quant" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" - -[[package]] -name = "combine" -version = "4.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4" -dependencies = [ - "bytes", - "memchr", -] - -[[package]] -name = "concurrent-queue" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62ec6771ecfa0762d24683ee5a32ad78487a3d3afdc0fb8cae19d2c5deb50b7c" -dependencies = [ - "crossbeam-utils", -] - -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - -[[package]] -name = "core-foundation" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" - -[[package]] -name = "core-graphics" -version = "0.22.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb" -dependencies = [ - "bitflags", - "core-foundation", - "core-graphics-types", - "foreign-types", - "libc", -] - -[[package]] -name = "core-graphics-types" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bb142d41022986c1d8ff29103a1411c8a3dfad3552f87a4f8dc50d61d4f4e33" -dependencies = [ - "bitflags", - "core-foundation", - "libc", -] - -[[package]] -name = "cpufeatures" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" -dependencies = [ - "libc", -] - -[[package]] -name = "crc32fast" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "crossbeam-channel" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" -dependencies = [ - "cfg-if", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array", - "typenum", -] - -[[package]] -name = "cssparser" -version = "0.27.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "754b69d351cdc2d8ee09ae203db831e005560fc6030da058f86ad60c92a9cb0a" -dependencies = [ - "cssparser-macros", - "dtoa-short", - "itoa 0.4.8", - "matches", - "phf 0.8.0", - "proc-macro2", - "quote", - "smallvec", - "syn 1.0.109", -] - -[[package]] -name = "cssparser-macros" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331" -dependencies = [ - "quote", - "syn 2.0.25", -] - -[[package]] -name = "ctor" -version = "0.1.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096" -dependencies = [ - "quote", - "syn 1.0.109", -] - -[[package]] -name = "darling" -version = "0.20.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0558d22a7b463ed0241e993f76f09f30b126687447751a8638587b864e4b3944" -dependencies = [ - "darling_core", - "darling_macro", -] - -[[package]] -name = "darling_core" -version = "0.20.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab8bfa2e259f8ee1ce5e97824a3c55ec4404a0d772ca7fa96bf19f0752a046eb" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn 2.0.25", -] - -[[package]] -name = "darling_macro" -version = "0.20.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29a358ff9f12ec09c3e61fef9b5a9902623a695a46a917b07f269bff1445611a" -dependencies = [ - "darling_core", - "quote", - "syn 2.0.25", -] - -[[package]] -name = "derivative" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "rustc_version", - "syn 1.0.109", -] - -[[package]] -name = "digest" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" -dependencies = [ - "block-buffer", - "crypto-common", -] - -[[package]] -name = "dirs-next" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" -dependencies = [ - "cfg-if", - "dirs-sys-next", -] - -[[package]] -name = "dirs-sys-next" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" -dependencies = [ - "libc", - "redox_users", - "winapi", -] - -[[package]] -name = "dispatch" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b" - -[[package]] -name = "dtoa" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "519b83cd10f5f6e969625a409f735182bea5558cd8b64c655806ceaae36f1999" - -[[package]] -name = "dtoa-short" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbaceec3c6e4211c79e7b1800fb9680527106beb2f9c51904a3210c03a448c74" -dependencies = [ - "dtoa", -] - -[[package]] -name = "dunce" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" - -[[package]] -name = "embed-resource" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7f1e82a60222fc67bfd50d752a9c89da5cce4c39ed39decc84a443b07bbd69a" -dependencies = [ - "cc", - "rustc_version", - "toml", - "vswhom", - "winreg 0.11.0", -] - -[[package]] -name = "embed_plist" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ef6b89e5b37196644d8796de5268852ff179b44e96276cf4290264843743bb7" - -[[package]] -name = "encoding_rs" -version = "0.8.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "enumflags2" -version = "0.7.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c041f5090df68b32bcd905365fd51769c8b9d553fe87fde0b683534f10c01bd2" -dependencies = [ - "enumflags2_derive", - "serde", -] - -[[package]] -name = "enumflags2_derive" -version = "0.7.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e9a1f9f7d83e59740248a6e14ecf93929ade55027844dfcea78beafccc15745" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.25", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "errno" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" -dependencies = [ - "errno-dragonfly", - "libc", - "windows-sys", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", - "libc", -] - -[[package]] -name = "event-listener" -version = "2.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" - -[[package]] -name = "fastrand" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" -dependencies = [ - "instant", -] - -[[package]] -name = "fdeflate" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d329bdeac514ee06249dabc27877490f17f5d371ec693360768b838e19f3ae10" -dependencies = [ - "simd-adler32", -] - -[[package]] -name = "field-offset" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38e2275cc4e4fc009b0669731a1e5ab7ebf11f469eaede2bab9309a5b4d6057f" -dependencies = [ - "memoffset 0.9.0", - "rustc_version", -] - -[[package]] -name = "flate2" -version = "1.0.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" -dependencies = [ - "crc32fast", - "miniz_oxide", -] - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - -[[package]] -name = "form_urlencoded" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" -dependencies = [ - "percent-encoding", -] - -[[package]] -name = "futf" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df420e2e84819663797d1ec6544b13c5be84629e7bb00dc960d6917db2987843" -dependencies = [ - "mac", - "new_debug_unreachable", -] - -[[package]] -name = "futures-channel" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" -dependencies = [ - "futures-core", -] - -[[package]] -name = "futures-core" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" - -[[package]] -name = "futures-executor" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" -dependencies = [ - "futures-core", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-io" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" - -[[package]] -name = "futures-lite" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" -dependencies = [ - "fastrand", - "futures-core", - "futures-io", - "memchr", - "parking", - "pin-project-lite", - "waker-fn", -] - -[[package]] -name = "futures-macro" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.25", -] - -[[package]] -name = "futures-sink" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" - -[[package]] -name = "futures-task" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" - -[[package]] -name = "futures-util" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" -dependencies = [ - "futures-core", - "futures-io", - "futures-macro", - "futures-sink", - "futures-task", - "memchr", - "pin-project-lite", - "pin-utils", - "slab", -] - -[[package]] -name = "fxhash" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" -dependencies = [ - "byteorder", -] - -[[package]] -name = "gdk" -version = "0.16.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa9cb33da481c6c040404a11f8212d193889e9b435db2c14fd86987f630d3ce1" -dependencies = [ - "bitflags", - "cairo-rs", - "gdk-pixbuf", - "gdk-sys", - "gio", - "glib", - "libc", - "pango", -] - -[[package]] -name = "gdk-pixbuf" -version = "0.16.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3578c60dee9d029ad86593ed88cb40f35c1b83360e12498d055022385dd9a05" -dependencies = [ - "bitflags", - "gdk-pixbuf-sys", - "gio", - "glib", - "libc", -] - -[[package]] -name = "gdk-pixbuf-sys" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3092cf797a5f1210479ea38070d9ae8a5b8e9f8f1be9f32f4643c529c7d70016" -dependencies = [ - "gio-sys", - "glib-sys", - "gobject-sys", - "libc", - "system-deps", -] - -[[package]] -name = "gdk-sys" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d76354f97a913e55b984759a997b693aa7dc71068c9e98bcce51aa167a0a5c5a" -dependencies = [ - "cairo-sys-rs", - "gdk-pixbuf-sys", - "gio-sys", - "glib-sys", - "gobject-sys", - "libc", - "pango-sys", - "pkg-config", - "system-deps", -] - -[[package]] -name = "gdkwayland-sys" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4511710212ed3020b61a8622a37aa6f0dd2a84516575da92e9b96928dcbe83ba" -dependencies = [ - "gdk-sys", - "glib-sys", - "gobject-sys", - "libc", - "pkg-config", - "system-deps", -] - -[[package]] -name = "gdkx11-sys" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fa2bf8b5b8c414bc5d05e48b271896d0fd3ddb57464a3108438082da61de6af" -dependencies = [ - "gdk-sys", - "glib-sys", - "libc", - "system-deps", - "x11", -] - -[[package]] -name = "generator" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc16584ff22b460a382b7feec54b23d2908d858152e5739a120b949293bd74e" -dependencies = [ - "cc", - "libc", - "log", - "rustversion", - "windows", -] - -[[package]] -name = "generic-array" -version = "0.14.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" -dependencies = [ - "typenum", - "version_check", -] - -[[package]] -name = "getrandom" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" -dependencies = [ - "cfg-if", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - -[[package]] -name = "getrandom" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" -dependencies = [ - "cfg-if", - "libc", - "wasi 0.11.0+wasi-snapshot-preview1", -] - -[[package]] -name = "gimli" -version = "0.27.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" - -[[package]] -name = "gio" -version = "0.16.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a1c84b4534a290a29160ef5c6eff2a9c95833111472e824fc5cb78b513dd092" -dependencies = [ - "bitflags", - "futures-channel", - "futures-core", - "futures-io", - "futures-util", - "gio-sys", - "glib", - "libc", - "once_cell", - "pin-project-lite", - "smallvec", - "thiserror", -] - -[[package]] -name = "gio-sys" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9b693b8e39d042a95547fc258a7b07349b1f0b48f4b2fa3108ba3c51c0b5229" -dependencies = [ - "glib-sys", - "gobject-sys", - "libc", - "system-deps", - "winapi", -] - -[[package]] -name = "glib" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16aa2475c9debed5a32832cb5ff2af5a3f9e1ab9e69df58eaadc1ab2004d6eba" -dependencies = [ - "bitflags", - "futures-channel", - "futures-core", - "futures-executor", - "futures-task", - "futures-util", - "gio-sys", - "glib-macros", - "glib-sys", - "gobject-sys", - "libc", - "once_cell", - "smallvec", - "thiserror", -] - -[[package]] -name = "glib-macros" -version = "0.16.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb1a9325847aa46f1e96ffea37611b9d51fc4827e67f79e7de502a297560a67b" -dependencies = [ - "anyhow", - "heck", - "proc-macro-crate", - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "glib-sys" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61a4f46316d06bfa33a7ac22df6f0524c8be58e3db2d9ca99ccb1f357b62a65" -dependencies = [ - "libc", - "system-deps", -] - -[[package]] -name = "glob" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" - -[[package]] -name = "gobject-sys" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3520bb9c07ae2a12c7f2fbb24d4efc11231c8146a86956413fb1a79bb760a0f1" -dependencies = [ - "glib-sys", - "libc", - "system-deps", -] - -[[package]] -name = "gtk" -version = "0.16.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4d3507d43908c866c805f74c9dd593c0ce7ba5c38e576e41846639cdcd4bee6" -dependencies = [ - "atk", - "bitflags", - "cairo-rs", - "field-offset", - "futures-channel", - "gdk", - "gdk-pixbuf", - "gio", - "glib", - "gtk-sys", - "gtk3-macros", - "libc", - "once_cell", - "pango", - "pkg-config", -] - -[[package]] -name = "gtk-sys" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b5f8946685d5fe44497007786600c2f368ff6b1e61a16251c89f72a97520a3" -dependencies = [ - "atk-sys", - "cairo-sys-rs", - "gdk-pixbuf-sys", - "gdk-sys", - "gio-sys", - "glib-sys", - "gobject-sys", - "libc", - "pango-sys", - "system-deps", -] - -[[package]] -name = "gtk3-macros" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "096eb63c6fedf03bafe65e5924595785eaf1bcb7200dac0f2cbe9c9738f05ad8" -dependencies = [ - "anyhow", - "proc-macro-crate", - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "h2" -version = "0.3.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97ec8491ebaf99c8eaa73058b045fe58073cd6be7f596ac993ced0b0a0c01049" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http", - "indexmap 1.9.3", - "slab", - "tokio", - "tokio-util", - "tracing", -] - -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - -[[package]] -name = "hashbrown" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" - -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - -[[package]] -name = "hermit-abi" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "html5ever" -version = "0.25.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5c13fb08e5d4dfc151ee5e88bae63f7773d61852f3bdc73c9f4b9e1bde03148" -dependencies = [ - "log", - "mac", - "markup5ever 0.10.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "html5ever" -version = "0.26.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bea68cab48b8459f17cf1c944c67ddc572d272d9f2b274140f223ecb1da4a3b7" -dependencies = [ - "log", - "mac", - "markup5ever 0.11.0", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "http" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" -dependencies = [ - "bytes", - "fnv", - "itoa 1.0.8", -] - -[[package]] -name = "http-body" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" -dependencies = [ - "bytes", - "http", - "pin-project-lite", -] - -[[package]] -name = "http-range" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21dec9db110f5f872ed9699c3ecf50cf16f423502706ba5c72462e28d3157573" - -[[package]] -name = "httparse" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" - -[[package]] -name = "httpdate" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" - -[[package]] -name = "hyper" -version = "0.14.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" -dependencies = [ - "bytes", - "futures-channel", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "httparse", - "httpdate", - "itoa 1.0.8", - "pin-project-lite", - "socket2", - "tokio", - "tower-service", - "tracing", - "want", -] - -[[package]] -name = "iana-time-zone" -version = "0.1.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "wasm-bindgen", - "windows", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" -dependencies = [ - "cc", -] - -[[package]] -name = "ico" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3804960be0bb5e4edb1e1ad67afd321a9ecfd875c3e65c099468fd2717d7cae" -dependencies = [ - "byteorder", - "png", -] - -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - -[[package]] -name = "idna" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" -dependencies = [ - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "image" -version = "0.24.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "527909aa81e20ac3a44803521443a765550f09b5130c2c2fa1ea59c2f8f50a3a" -dependencies = [ - "bytemuck", - "byteorder", - "color_quant", - "num-rational", - "num-traits", -] - -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", - "serde", -] - -[[package]] -name = "indexmap" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" -dependencies = [ - "equivalent", - "hashbrown 0.14.0", -] - -[[package]] -name = "infer" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a898e4b7951673fce96614ce5751d13c40fc5674bc2d759288e46c3ab62598b3" -dependencies = [ - "cfb", -] - -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "io-lifetimes" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" -dependencies = [ - "hermit-abi", - "libc", - "windows-sys", -] - -[[package]] -name = "ipnet" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" - -[[package]] -name = "itoa" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" - -[[package]] -name = "itoa" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b02a5381cc465bd3041d84623d0fa3b66738b52b8e2fc3bab8ad63ab032f4a" - -[[package]] -name = "javascriptcore-rs" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cfcc681b896b083864a4a3c3b3ea196f14ff66b8641a68fde209c6d84434056" -dependencies = [ - "bitflags", - "glib", - "javascriptcore-rs-sys", -] - -[[package]] -name = "javascriptcore-rs-sys" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0983ba5b3ab9a0c0918de02c42dc71f795d6de08092f88a98ce9fdfdee4ba91" -dependencies = [ - "glib-sys", - "gobject-sys", - "libc", - "system-deps", -] - -[[package]] -name = "jni" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "039022cdf4d7b1cf548d31f60ae783138e5fd42013f6271049d7df7afadef96c" -dependencies = [ - "cesu8", - "combine", - "jni-sys", - "log", - "thiserror", - "walkdir", -] - -[[package]] -name = "jni-sys" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" - -[[package]] -name = "js-sys" -version = "0.3.64" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "json-patch" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f54898088ccb91df1b492cc80029a6fdf1c48ca0db7c6822a8babad69c94658" -dependencies = [ - "serde", - "serde_json", - "thiserror", - "treediff", -] - -[[package]] -name = "kuchiki" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ea8e9c6e031377cff82ee3001dc8026cdf431ed4e2e6b51f98ab8c73484a358" -dependencies = [ - "cssparser", - "html5ever 0.25.2", - "matches", - "selectors", -] - -[[package]] -name = "kuchikiki" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e4755b7b995046f510a7520c42b2fed58b77bd94d5a87a8eb43d2fd126da8" -dependencies = [ - "cssparser", - "html5ever 0.26.0", - "indexmap 1.9.3", - "matches", - "selectors", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "libc" -version = "0.2.147" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" - -[[package]] -name = "line-wrap" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30344350a2a51da54c1d53be93fade8a237e545dbcc4bdbe635413f2117cab9" -dependencies = [ - "safemem", -] - -[[package]] -name = "linux-raw-sys" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" - -[[package]] -name = "lock_api" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" -dependencies = [ - "autocfg", - "scopeguard", -] - -[[package]] -name = "log" -version = "0.4.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" - -[[package]] -name = "loom" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff50ecb28bb86013e935fb6683ab1f6d3a20016f123c76fd4c27470076ac30f5" -dependencies = [ - "cfg-if", - "generator", - "scoped-tls", - "serde", - "serde_json", - "tracing", - "tracing-subscriber", -] - -[[package]] -name = "mac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" - -[[package]] -name = "malloc_buf" -version = "0.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" -dependencies = [ - "libc", -] - -[[package]] -name = "markup5ever" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a24f40fb03852d1cdd84330cddcaf98e9ec08a7b7768e952fad3b4cf048ec8fd" -dependencies = [ - "log", - "phf 0.8.0", - "phf_codegen 0.8.0", - "string_cache", - "string_cache_codegen", - "tendril", -] - -[[package]] -name = "markup5ever" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a2629bb1404f3d34c2e921f21fd34ba00b206124c81f65c50b43b6aaefeb016" -dependencies = [ - "log", - "phf 0.10.1", - "phf_codegen 0.10.0", - "string_cache", - "string_cache_codegen", - "tendril", -] - -[[package]] -name = "matchers" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" -dependencies = [ - "regex-automata 0.1.10", -] - -[[package]] -name = "matches" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" - -[[package]] -name = "memchr" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" - -[[package]] -name = "memoffset" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" -dependencies = [ - "autocfg", -] - -[[package]] -name = "memoffset" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" -dependencies = [ - "autocfg", -] - -[[package]] -name = "mime" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" - -[[package]] -name = "miniz_oxide" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" -dependencies = [ - "adler", - "simd-adler32", -] - -[[package]] -name = "mio" -version = "0.8.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" -dependencies = [ - "libc", - "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys", -] - -[[package]] -name = "ndk" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "451422b7e4718271c8b5b3aadf5adedba43dc76312454b387e98fae0fc951aa0" -dependencies = [ - "bitflags", - "jni-sys", - "ndk-sys", - "num_enum", - "raw-window-handle", - "thiserror", -] - -[[package]] -name = "ndk-context" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" - -[[package]] -name = "ndk-sys" -version = "0.4.1+23.1.7779620" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cf2aae958bd232cac5069850591667ad422d263686d75b52a065f9badeee5a3" -dependencies = [ - "jni-sys", -] - -[[package]] -name = "new_debug_unreachable" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" - -[[package]] -name = "nix" -version = "0.26.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" -dependencies = [ - "bitflags", - "cfg-if", - "libc", - "memoffset 0.7.1", - "static_assertions", -] - -[[package]] -name = "nodrop" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" - -[[package]] -name = "nu-ansi-term" -version = "0.46.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" -dependencies = [ - "overload", - "winapi", -] - -[[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" -dependencies = [ - "autocfg", -] - -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi", - "libc", -] - -[[package]] -name = "num_enum" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f646caf906c20226733ed5b1374287eb97e3c2a5c227ce668c1f2ce20ae57c9" -dependencies = [ - "num_enum_derive", -] - -[[package]] -name = "num_enum_derive" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "objc" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" -dependencies = [ - "malloc_buf", - "objc_exception", -] - -[[package]] -name = "objc_exception" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad970fb455818ad6cba4c122ad012fae53ae8b4795f86378bce65e4f6bab2ca4" -dependencies = [ - "cc", -] - -[[package]] -name = "objc_id" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b" -dependencies = [ - "objc", -] - -[[package]] -name = "object" -version = "0.31.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1" -dependencies = [ - "memchr", -] - -[[package]] -name = "once_cell" -version = "1.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" - -[[package]] -name = "ordered-stream" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aa2b01e1d916879f73a53d01d1d6cee68adbb31d6d9177a8cfce093cced1d50" -dependencies = [ - "futures-core", - "pin-project-lite", -] - -[[package]] -name = "overload" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" - -[[package]] -name = "pango" -version = "0.16.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdff66b271861037b89d028656184059e03b0b6ccb36003820be19f7200b1e94" -dependencies = [ - "bitflags", - "gio", - "glib", - "libc", - "once_cell", - "pango-sys", -] - -[[package]] -name = "pango-sys" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e134909a9a293e04d2cc31928aa95679c5e4df954d0b85483159bd20d8f047f" -dependencies = [ - "glib-sys", - "gobject-sys", - "libc", - "system-deps", -] - -[[package]] -name = "parking" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14f2252c834a40ed9bb5422029649578e63aa341ac401f74e719dd1afda8394e" - -[[package]] -name = "parking_lot" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall 0.3.5", - "smallvec", - "windows-targets", -] - -[[package]] -name = "percent-encoding" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" - -[[package]] -name = "phf" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dfb61232e34fcb633f43d12c58f83c1df82962dcdfa565a4e866ffc17dafe12" -dependencies = [ - "phf_macros 0.8.0", - "phf_shared 0.8.0", - "proc-macro-hack", -] - -[[package]] -name = "phf" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259" -dependencies = [ - "phf_macros 0.10.0", - "phf_shared 0.10.0", - "proc-macro-hack", -] - -[[package]] -name = "phf_codegen" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbffee61585b0411840d3ece935cce9cb6321f01c45477d30066498cd5e1a815" -dependencies = [ - "phf_generator 0.8.0", - "phf_shared 0.8.0", -] - -[[package]] -name = "phf_codegen" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb1c3a8bc4dd4e5cfce29b44ffc14bedd2ee294559a294e2a4d4c9e9a6a13cd" -dependencies = [ - "phf_generator 0.10.0", - "phf_shared 0.10.0", -] - -[[package]] -name = "phf_generator" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17367f0cc86f2d25802b2c26ee58a7b23faeccf78a396094c13dced0d0182526" -dependencies = [ - "phf_shared 0.8.0", - "rand 0.7.3", -] - -[[package]] -name = "phf_generator" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6" -dependencies = [ - "phf_shared 0.10.0", - "rand 0.8.5", -] - -[[package]] -name = "phf_macros" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f6fde18ff429ffc8fe78e2bf7f8b7a5a5a6e2a8b58bc5a9ac69198bbda9189c" -dependencies = [ - "phf_generator 0.8.0", - "phf_shared 0.8.0", - "proc-macro-hack", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "phf_macros" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58fdf3184dd560f160dd73922bea2d5cd6e8f064bf4b13110abd81b03697b4e0" -dependencies = [ - "phf_generator 0.10.0", - "phf_shared 0.10.0", - "proc-macro-hack", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "phf_shared" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c00cf8b9eafe68dde5e9eaa2cef8ee84a9336a47d566ec55ca16589633b65af7" -dependencies = [ - "siphasher", -] - -[[package]] -name = "phf_shared" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" -dependencies = [ - "siphasher", -] - -[[package]] -name = "pin-project-lite" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c40d25201921e5ff0c862a505c6557ea88568a4e3ace775ab55e93f2f4f9d57" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "pkg-config" -version = "0.3.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" - -[[package]] -name = "plist" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdc0001cfea3db57a2e24bc0d818e9e20e554b5f97fabb9bc231dc240269ae06" -dependencies = [ - "base64", - "indexmap 1.9.3", - "line-wrap", - "quick-xml", - "serde", - "time", -] - -[[package]] -name = "png" -version = "0.17.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59871cc5b6cce7eaccca5a802b4173377a1c2ba90654246789a8fa2334426d11" -dependencies = [ - "bitflags", - "crc32fast", - "fdeflate", - "flate2", - "miniz_oxide", -] - -[[package]] -name = "polling" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" -dependencies = [ - "autocfg", - "bitflags", - "cfg-if", - "concurrent-queue", - "libc", - "log", - "pin-project-lite", - "windows-sys", -] - -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - -[[package]] -name = "precomputed-hash" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" - -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit", -] - -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn 1.0.109", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - -[[package]] -name = "proc-macro-hack" -version = "0.5.20+deprecated" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" - -[[package]] -name = "proc-macro2" -version = "1.0.64" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78803b62cbf1f46fde80d7c0e803111524b9877184cfe7c3033659490ac7a7da" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quick-xml" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81b9228215d82c7b61490fec1de287136b5de6f5700f6e58ea9ad61a7964ca51" -dependencies = [ - "memchr", -] - -[[package]] -name = "quote" -version = "1.0.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom 0.1.16", - "libc", - "rand_chacha 0.2.2", - "rand_core 0.5.1", - "rand_hc", - "rand_pcg", -] - -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha 0.3.1", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_chacha" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" -dependencies = [ - "ppv-lite86", - "rand_core 0.5.1", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom 0.1.16", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom 0.2.10", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core 0.5.1", -] - -[[package]] -name = "rand_pcg" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" -dependencies = [ - "rand_core 0.5.1", -] - -[[package]] -name = "raw-window-handle" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9" - -[[package]] -name = "redox_syscall" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" -dependencies = [ - "bitflags", -] - -[[package]] -name = "redox_syscall" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" -dependencies = [ - "bitflags", -] - -[[package]] -name = "redox_users" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" -dependencies = [ - "getrandom 0.2.10", - "redox_syscall 0.2.16", - "thiserror", -] - -[[package]] -name = "regex" -version = "1.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2eae68fc220f7cf2532e4494aded17545fce192d59cd996e0fe7887f4ceb575" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata 0.3.2", - "regex-syntax 0.7.4", -] - -[[package]] -name = "regex-automata" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" -dependencies = [ - "regex-syntax 0.6.29", -] - -[[package]] -name = "regex-automata" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83d3daa6976cffb758ec878f108ba0e062a45b2d6ca3a2cca965338855476caf" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax 0.7.4", -] - -[[package]] -name = "regex-syntax" -version = "0.6.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" - -[[package]] -name = "regex-syntax" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" - -[[package]] -name = "reqwest" -version = "0.11.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde824a14b7c14f85caff81225f411faacc04a2013f41670f41443742b1c1c55" -dependencies = [ - "base64", - "bytes", - "encoding_rs", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "hyper", - "ipnet", - "js-sys", - "log", - "mime", - "once_cell", - "percent-encoding", - "pin-project-lite", - "serde", - "serde_json", - "serde_urlencoded", - "tokio", - "tokio-util", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "wasm-streams", - "web-sys", - "winreg 0.10.1", -] - -[[package]] -name = "rustc-demangle" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" - -[[package]] -name = "rustc_version" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver", -] - -[[package]] -name = "rustix" -version = "0.37.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06" -dependencies = [ - "bitflags", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys", - "windows-sys", -] - -[[package]] -name = "rustversion" -version = "1.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc31bd9b61a32c31f9650d18add92aa83a49ba979c143eefd27fe7177b05bd5f" - -[[package]] -name = "ryu" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe232bdf6be8c8de797b22184ee71118d63780ea42ac85b61d1baa6d3b782ae9" - -[[package]] -name = "safemem" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" - -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "scoped-tls" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" - -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - -[[package]] -name = "selectors" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df320f1889ac4ba6bc0cdc9c9af7af4bd64bb927bccdf32d81140dc1f9be12fe" -dependencies = [ - "bitflags", - "cssparser", - "derive_more", - "fxhash", - "log", - "matches", - "phf 0.8.0", - "phf_codegen 0.8.0", - "precomputed-hash", - "servo_arc", - "smallvec", - "thin-slice", -] - -[[package]] -name = "semver" -version = "1.0.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" - -[[package]] -name = "serde" -version = "1.0.171" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30e27d1e4fd7659406c492fd6cfaf2066ba8773de45ca75e855590f856dc34a9" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.171" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "389894603bd18c46fa56231694f8d827779c0951a667087194cf9de94ed24682" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.25", -] - -[[package]] -name = "serde_json" -version = "1.0.100" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f1e14e89be7aa4c4b78bdbdc9eb5bf8517829a600ae8eaa39a6e1d960b5185c" -dependencies = [ - "itoa 1.0.8", - "ryu", - "serde", -] - -[[package]] -name = "serde_repr" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d89a8107374290037607734c0b73a85db7ed80cae314b3c5791f192a496e731" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.25", -] - -[[package]] -name = "serde_spanned" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" -dependencies = [ - "serde", -] - -[[package]] -name = "serde_urlencoded" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" -dependencies = [ - "form_urlencoded", - "itoa 1.0.8", - "ryu", - "serde", -] - -[[package]] -name = "serde_with" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f02d8aa6e3c385bf084924f660ce2a3a6bd333ba55b35e8590b321f35d88513" -dependencies = [ - "base64", - "chrono", - "hex", - "indexmap 1.9.3", - "serde", - "serde_json", - "serde_with_macros", - "time", -] - -[[package]] -name = "serde_with_macros" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edc7d5d3932fb12ce722ee5e64dd38c504efba37567f0c402f6ca728c3b8b070" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn 2.0.25", -] - -[[package]] -name = "serialize-to-javascript" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9823f2d3b6a81d98228151fdeaf848206a7855a7a042bbf9bf870449a66cafb" -dependencies = [ - "serde", - "serde_json", - "serialize-to-javascript-impl", -] - -[[package]] -name = "serialize-to-javascript-impl" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74064874e9f6a15f04c1f3cb627902d0e6b410abbf36668afa873c61889f1763" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "servo_arc" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d98238b800e0d1576d8b6e3de32827c2d74bee68bb97748dcf5071fb53965432" -dependencies = [ - "nodrop", - "stable_deref_trait", -] - -[[package]] -name = "sha1" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - -[[package]] -name = "sha2" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - -[[package]] -name = "sharded-slab" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "signal-hook" -version = "0.3.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b824b6e687aff278cdbf3b36f07aa52d4bd4099699324d5da86a2ebce3aa00b3" -dependencies = [ - "libc", - "signal-hook-registry", -] - -[[package]] -name = "signal-hook-registry" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" -dependencies = [ - "libc", -] - -[[package]] -name = "simd-adler32" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "238abfbb77c1915110ad968465608b68e869e0772622c9656714e73e5a1a522f" - -[[package]] -name = "siphasher" -version = "0.3.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" - -[[package]] -name = "slab" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" -dependencies = [ - "autocfg", -] - -[[package]] -name = "smallvec" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" - -[[package]] -name = "socket2" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "soup3" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82bc46048125fefd69d30b32b9d263d6556c9ffe82a7a7df181a86d912da5616" -dependencies = [ - "bitflags", - "futures-channel", - "gio", - "glib", - "libc", - "once_cell", - "soup3-sys", -] - -[[package]] -name = "soup3-sys" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "014bbeb1c4cdb30739dc181e8d98b7908f124d9555843afa89b5570aaf4ec62b" -dependencies = [ - "gio-sys", - "glib-sys", - "gobject-sys", - "libc", - "system-deps", -] - -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - -[[package]] -name = "state" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b8c4a4445d81357df8b1a650d0d0d6fbbbfe99d064aa5e02f3e4022061476d8" -dependencies = [ - "loom", -] - -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - -[[package]] -name = "string_cache" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f91138e76242f575eb1d3b38b4f1362f10d3a43f47d182a5b359af488a02293b" -dependencies = [ - "new_debug_unreachable", - "once_cell", - "parking_lot", - "phf_shared 0.10.0", - "precomputed-hash", - "serde", -] - -[[package]] -name = "string_cache_codegen" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bb30289b722be4ff74a408c3cc27edeaad656e06cb1fe8fa9231fa59c728988" -dependencies = [ - "phf_generator 0.10.0", - "phf_shared 0.10.0", - "proc-macro2", - "quote", -] - -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - -[[package]] -name = "swift-rs" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05e51d6f2b5fff4808614f429f8a7655ac8bcfe218185413f3a60c508482c2d6" -dependencies = [ - "base64", - "serde", - "serde_json", -] - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15e3fc8c0c74267e2df136e5e5fb656a464158aa57624053375eb9c8c6e25ae2" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "system-deps" -version = "6.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30c2de8a4d8f4b823d634affc9cd2a74ec98c53a756f317e529a48046cbf71f3" -dependencies = [ - "cfg-expr", - "heck", - "pkg-config", - "toml", - "version-compare", -] - -[[package]] -name = "tao" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b87728a671df8520c274fa9bed48d7384f5a965ef2fc364f01a942f6ff1ae6d2" -dependencies = [ - "bitflags", - "cairo-rs", - "cc", - "cocoa", - "core-foundation", - "core-graphics", - "crossbeam-channel", - "dispatch", - "gdk", - "gdk-pixbuf", - "gdk-sys", - "gdkwayland-sys", - "gdkx11-sys", - "gio", - "glib", - "glib-sys", - "gtk", - "image", - "instant", - "jni", - "lazy_static", - "libc", - "log", - "ndk", - "ndk-context", - "ndk-sys", - "objc", - "once_cell", - "parking_lot", - "png", - "raw-window-handle", - "scopeguard", - "serde", - "tao-macros", - "unicode-segmentation", - "url", - "uuid", - "windows", - "windows-implement", - "x11-dl", - "zbus", -] - -[[package]] -name = "tao-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b27a4bcc5eb524658234589bdffc7e7bfb996dbae6ce9393bfd39cb4159b445" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "target-lexicon" -version = "0.12.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df8e77cb757a61f51b947ec4a7e3646efd825b73561db1c232a8ccb639e611a0" - -[[package]] -name = "tauri" -version = "2.0.0-alpha.10" -source = "git+https://github.com/lucasfernog/tauri?branch=feat/ipc-custom-protocol#46e7d58fc1ec2265324606689e2b528e6b6b739d" -dependencies = [ - "anyhow", - "bytes", - "cocoa", - "dirs-next", - "embed_plist", - "futures-util", - "glib", - "glob", - "gtk", - "heck", - "http", - "jni", - "libc", - "log", - "objc", - "once_cell", - "percent-encoding", - "rand 0.8.5", - "raw-window-handle", - "reqwest", - "serde", - "serde_json", - "serde_repr", - "serialize-to-javascript", - "state", - "swift-rs", - "tauri-build", - "tauri-macros", - "tauri-runtime", - "tauri-runtime-wry", - "tauri-utils", - "thiserror", - "tokio", - "url", - "uuid", - "webkit2gtk", - "webview2-com", - "windows", -] - -[[package]] -name = "tauri-build" -version = "2.0.0-alpha.6" -source = "git+https://github.com/lucasfernog/tauri?branch=feat/ipc-custom-protocol#46e7d58fc1ec2265324606689e2b528e6b6b739d" -dependencies = [ - "anyhow", - "cargo_toml", - "heck", - "json-patch", - "plist", - "semver", - "serde", - "serde_json", - "swift-rs", - "tauri-utils", - "tauri-winres", - "walkdir", -] - -[[package]] -name = "tauri-codegen" -version = "2.0.0-alpha.6" -source = "git+https://github.com/lucasfernog/tauri?branch=feat/ipc-custom-protocol#46e7d58fc1ec2265324606689e2b528e6b6b739d" -dependencies = [ - "base64", - "brotli", - "ico", - "json-patch", - "plist", - "png", - "proc-macro2", - "quote", - "semver", - "serde", - "serde_json", - "sha2", - "tauri-utils", - "thiserror", - "time", - "url", - "uuid", - "walkdir", -] - -[[package]] -name = "tauri-macros" -version = "2.0.0-alpha.6" -source = "git+https://github.com/lucasfernog/tauri?branch=feat/ipc-custom-protocol#46e7d58fc1ec2265324606689e2b528e6b6b739d" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn 1.0.109", - "tauri-codegen", - "tauri-utils", -] - -[[package]] -name = "tauri-plugin-deep-link" -version = "2.0.0-alpha.0" -dependencies = [ - "log", - "serde", - "serde_json", - "tauri", - "tauri-build", - "thiserror", - "url", -] - -[[package]] -name = "tauri-runtime" -version = "0.13.0-alpha.6" -source = "git+https://github.com/lucasfernog/tauri?branch=feat/ipc-custom-protocol#46e7d58fc1ec2265324606689e2b528e6b6b739d" -dependencies = [ - "gtk", - "http", - "http-range", - "jni", - "rand 0.8.5", - "raw-window-handle", - "serde", - "serde_json", - "tauri-utils", - "thiserror", - "url", - "uuid", - "windows", -] - -[[package]] -name = "tauri-runtime-wry" -version = "0.13.0-alpha.6" -source = "git+https://github.com/lucasfernog/tauri?branch=feat/ipc-custom-protocol#46e7d58fc1ec2265324606689e2b528e6b6b739d" -dependencies = [ - "cocoa", - "gtk", - "jni", - "percent-encoding", - "rand 0.8.5", - "raw-window-handle", - "tauri-runtime", - "tauri-utils", - "uuid", - "webkit2gtk", - "webview2-com", - "windows", - "wry", -] - -[[package]] -name = "tauri-utils" -version = "2.0.0-alpha.6" -source = "git+https://github.com/lucasfernog/tauri?branch=feat/ipc-custom-protocol#46e7d58fc1ec2265324606689e2b528e6b6b739d" -dependencies = [ - "brotli", - "ctor", - "dunce", - "glob", - "heck", - "html5ever 0.26.0", - "infer", - "json-patch", - "kuchikiki", - "memchr", - "phf 0.10.1", - "proc-macro2", - "quote", - "semver", - "serde", - "serde_json", - "serde_with", - "thiserror", - "url", - "walkdir", - "windows", -] - -[[package]] -name = "tauri-winres" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5993dc129e544393574288923d1ec447c857f3f644187f4fbf7d9a875fbfc4fb" -dependencies = [ - "embed-resource", - "toml", -] - -[[package]] -name = "tempfile" -version = "3.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31c0432476357e58790aaa47a8efb0c5138f137343f3b5f23bd36a27e3b0a6d6" -dependencies = [ - "autocfg", - "cfg-if", - "fastrand", - "redox_syscall 0.3.5", - "rustix", - "windows-sys", -] - -[[package]] -name = "tendril" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d24a120c5fc464a3458240ee02c299ebcb9d67b5249c8848b09d639dca8d7bb0" -dependencies = [ - "futf", - "mac", - "utf-8", -] - -[[package]] -name = "thin-slice" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eaa81235c7058867fa8c0e7314f33dcce9c215f535d1913822a2b3f5e289f3c" - -[[package]] -name = "thiserror" -version = "1.0.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a35fc5b8971143ca348fa6df4f024d4d55264f3468c71ad1c2f365b0a4d58c42" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "463fe12d7993d3b327787537ce8dd4dfa058de32fc2b195ef3cde03dc4771e8f" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.25", -] - -[[package]] -name = "thread_local" -version = "1.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" -dependencies = [ - "cfg-if", - "once_cell", -] - -[[package]] -name = "time" -version = "0.3.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59e399c068f43a5d116fedaf73b203fa4f9c519f17e2b34f63221d3792f81446" -dependencies = [ - "itoa 1.0.8", - "serde", - "time-core", - "time-macros", -] - -[[package]] -name = "time-core" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" - -[[package]] -name = "time-macros" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96ba15a897f3c86766b757e5ac7221554c6750054d74d5b28844fce5fb36a6c4" -dependencies = [ - "time-core", -] - -[[package]] -name = "tinyvec" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" - -[[package]] -name = "tokio" -version = "1.29.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "532826ff75199d5833b9d2c5fe410f29235e25704ee5f0ef599fb51c21f4a4da" -dependencies = [ - "autocfg", - "backtrace", - "bytes", - "libc", - "mio", - "num_cpus", - "pin-project-lite", - "socket2", - "windows-sys", -] - -[[package]] -name = "tokio-util" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" -dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "pin-project-lite", - "tokio", - "tracing", -] - -[[package]] -name = "toml" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542" -dependencies = [ - "serde", - "serde_spanned", - "toml_datetime", - "toml_edit", -] - -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" -dependencies = [ - "serde", -] - -[[package]] -name = "toml_edit" -version = "0.19.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c500344a19072298cd05a7224b3c0c629348b78692bf48466c5238656e315a78" -dependencies = [ - "indexmap 2.0.0", - "serde", - "serde_spanned", - "toml_datetime", - "winnow", -] - -[[package]] -name = "tower-service" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" - -[[package]] -name = "tracing" -version = "0.1.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" -dependencies = [ - "cfg-if", - "pin-project-lite", - "tracing-attributes", - "tracing-core", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.25", -] - -[[package]] -name = "tracing-core" -version = "0.1.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" -dependencies = [ - "once_cell", - "valuable", -] - -[[package]] -name = "tracing-log" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" -dependencies = [ - "lazy_static", - "log", - "tracing-core", -] - -[[package]] -name = "tracing-subscriber" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" -dependencies = [ - "matchers", - "nu-ansi-term", - "once_cell", - "regex", - "sharded-slab", - "smallvec", - "thread_local", - "tracing", - "tracing-core", - "tracing-log", -] - -[[package]] -name = "treediff" -version = "4.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52984d277bdf2a751072b5df30ec0377febdb02f7696d64c2d7d54630bac4303" -dependencies = [ - "serde_json", -] - -[[package]] -name = "try-lock" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" - -[[package]] -name = "typenum" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" - -[[package]] -name = "uds_windows" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce65604324d3cce9b966701489fbd0cf318cb1f7bd9dd07ac9a4ee6fb791930d" -dependencies = [ - "tempfile", - "winapi", -] - -[[package]] -name = "unicode-bidi" -version = "0.3.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" - -[[package]] -name = "unicode-ident" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22049a19f4a68748a168c0fc439f9516686aa045927ff767eca0a85101fb6e73" - -[[package]] -name = "unicode-normalization" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" -dependencies = [ - "tinyvec", -] - -[[package]] -name = "unicode-segmentation" -version = "1.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" - -[[package]] -name = "url" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" -dependencies = [ - "form_urlencoded", - "idna", - "percent-encoding", - "serde", -] - -[[package]] -name = "utf-8" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" - -[[package]] -name = "uuid" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d023da39d1fde5a8a3fe1f3e01ca9632ada0a63e9797de55a879d6e2236277be" -dependencies = [ - "getrandom 0.2.10", -] - -[[package]] -name = "valuable" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" - -[[package]] -name = "version-compare" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "579a42fc0b8e0c63b76519a339be31bed574929511fa53c1a3acae26eb258f29" - -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "vswhom" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be979b7f07507105799e854203b470ff7c78a1639e330a58f183b5fea574608b" -dependencies = [ - "libc", - "vswhom-sys", -] - -[[package]] -name = "vswhom-sys" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3b17ae1f6c8a2b28506cd96d412eebf83b4a0ff2cbefeeb952f2f9dfa44ba18" -dependencies = [ - "cc", - "libc", -] - -[[package]] -name = "waker-fn" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" - -[[package]] -name = "walkdir" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" -dependencies = [ - "same-file", - "winapi-util", -] - -[[package]] -name = "want" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" -dependencies = [ - "try-lock", -] - -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "wasm-bindgen" -version = "0.2.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn 2.0.25", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-futures" -version = "0.4.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" -dependencies = [ - "cfg-if", - "js-sys", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.25", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" - -[[package]] -name = "wasm-streams" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bbae3363c08332cadccd13b67db371814cd214c2524020932f0804b8cf7c078" -dependencies = [ - "futures-util", - "js-sys", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", -] - -[[package]] -name = "web-sys" -version = "0.3.64" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "webkit2gtk" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ba4cce9085e0fb02575cfd45c328740dde78253cba516b1e8be2ca0f57bd8bf" -dependencies = [ - "bitflags", - "cairo-rs", - "gdk", - "gdk-sys", - "gio", - "gio-sys", - "glib", - "glib-sys", - "gobject-sys", - "gtk", - "gtk-sys", - "javascriptcore-rs", - "libc", - "once_cell", - "soup3", - "webkit2gtk-sys", -] - -[[package]] -name = "webkit2gtk-sys" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4489eb24e8cf0a3d0555fd3a8f7adec2a5ece34c1e7b7c9a62da7822fd40a59" -dependencies = [ - "bitflags", - "cairo-sys-rs", - "gdk-sys", - "gio-sys", - "glib-sys", - "gobject-sys", - "gtk-sys", - "javascriptcore-rs-sys", - "libc", - "pkg-config", - "soup3-sys", - "system-deps", -] - -[[package]] -name = "webview2-com" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79e563ffe8e84d42e43ffacbace8780c0244fc8910346f334613559d92e203ad" -dependencies = [ - "webview2-com-macros", - "webview2-com-sys", - "windows", - "windows-implement", - "windows-interface", -] - -[[package]] -name = "webview2-com-macros" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac1345798ecd8122468840bcdf1b95e5dc6d2206c5e4b0eafa078d061f59c9bc" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.25", -] - -[[package]] -name = "webview2-com-sys" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19d39576804304cf9ead192467ef47f7859a1a12fec3bd459d5ba34b8cd65ed5" -dependencies = [ - "regex", - "serde", - "serde_json", - "thiserror", - "windows", - "windows-bindgen", - "windows-metadata", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi", -] - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" -dependencies = [ - "windows-implement", - "windows-interface", - "windows-targets", -] - -[[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-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-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-metadata" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "422ee0e5f0e2cc372bb6addbfff9a8add712155cd743df9c15f6ab000f31432d" - -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-targets" -version = "0.48.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[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.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" - -[[package]] -name = "windows_i686_gnu" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" - -[[package]] -name = "windows_i686_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" - -[[package]] -name = "winnow" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81a2094c43cc94775293eaa0e499fbc30048a6d824ac82c0351a8c0bf9112529" -dependencies = [ - "memchr", -] - -[[package]] -name = "winreg" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" -dependencies = [ - "winapi", -] - -[[package]] -name = "winreg" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76a1a57ff50e9b408431e8f97d5456f2807f8eb2a2cd79b06068fc87f8ecf189" -dependencies = [ - "cfg-if", - "winapi", -] - -[[package]] -name = "wry" -version = "0.30.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "430d086d4626265e9427fe2908a06fb2e10ea2ff37d4a711eb9461b6ea3511dd" -dependencies = [ - "base64", - "block", - "cocoa", - "core-graphics", - "crossbeam-channel", - "dunce", - "gdk", - "gio", - "glib", - "gtk", - "html5ever 0.25.2", - "http", - "javascriptcore-rs", - "kuchiki", - "libc", - "log", - "objc", - "objc_id", - "once_cell", - "serde", - "serde_json", - "sha2", - "soup3", - "tao", - "thiserror", - "url", - "webkit2gtk", - "webkit2gtk-sys", - "webview2-com", - "windows", - "windows-implement", -] - -[[package]] -name = "x11" -version = "2.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "502da5464ccd04011667b11c435cb992822c2c0dbde1770c988480d312a0db2e" -dependencies = [ - "libc", - "pkg-config", -] - -[[package]] -name = "x11-dl" -version = "2.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38735924fedd5314a6e548792904ed8c6de6636285cb9fec04d5b1db85c1516f" -dependencies = [ - "libc", - "once_cell", - "pkg-config", -] - -[[package]] -name = "xdg-home" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2769203cd13a0c6015d515be729c526d041e9cf2c0cc478d57faee85f40c6dcd" -dependencies = [ - "nix", - "winapi", -] - -[[package]] -name = "zbus" -version = "3.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31de390a2d872e4cd04edd71b425e29853f786dc99317ed72d73d6fcf5ebb948" -dependencies = [ - "async-broadcast", - "async-executor", - "async-fs", - "async-io", - "async-lock", - "async-process", - "async-recursion", - "async-task", - "async-trait", - "blocking", - "byteorder", - "derivative", - "enumflags2", - "event-listener", - "futures-core", - "futures-sink", - "futures-util", - "hex", - "nix", - "once_cell", - "ordered-stream", - "rand 0.8.5", - "serde", - "serde_repr", - "sha1", - "static_assertions", - "tracing", - "uds_windows", - "winapi", - "xdg-home", - "zbus_macros", - "zbus_names", - "zvariant", -] - -[[package]] -name = "zbus_macros" -version = "3.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d1794a946878c0e807f55a397187c11fc7a038ba5d868e7db4f3bd7760bc9d" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "regex", - "syn 1.0.109", - "zvariant_utils", -] - -[[package]] -name = "zbus_names" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb80bb776dbda6e23d705cf0123c3b95df99c4ebeaec6c2599d4a5419902b4a9" -dependencies = [ - "serde", - "static_assertions", - "zvariant", -] - -[[package]] -name = "zvariant" -version = "3.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44b291bee0d960c53170780af148dca5fa260a63cdd24f1962fa82e03e53338c" -dependencies = [ - "byteorder", - "enumflags2", - "libc", - "serde", - "static_assertions", - "zvariant_derive", -] - -[[package]] -name = "zvariant_derive" -version = "3.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "934d7a7dfc310d6ee06c87ffe88ef4eca7d3e37bb251dece2ef93da8f17d8ecd" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 1.0.109", - "zvariant_utils", -] - -[[package]] -name = "zvariant_utils" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7234f0d811589db492d16893e3f21e8e2fd282e6d01b0cddee310322062cc200" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] diff --git a/plugins/deep-link/Cargo.toml b/plugins/deep-link/Cargo.toml index ed24e589..8dcdef04 100644 --- a/plugins/deep-link/Cargo.toml +++ b/plugins/deep-link/Cargo.toml @@ -1,29 +1,45 @@ [package] name = "tauri-plugin-deep-link" -version = "2.0.0-alpha.0" +version = "2.3.0" description = "Set your Tauri application as the default handler for an URL" authors = { workspace = true } license = { workspace = true } edition = { workspace = true } rust-version = { workspace = true } +repository = { workspace = true } links = "tauri-plugin-deep-link" [package.metadata.docs.rs] -features = [ "dox" ] -targets = [ "x86_64-linux-android" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] +targets = ["x86_64-linux-android"] + +[package.metadata.platforms.support] +windows = { level = "full", notes = "" } +linux = { level = "full", notes = "" } +macos = { level = "partial", notes = "Runtime deep link registration is not supported" } +android = { level = "partial", notes = "Runtime deep link registration is not supported" } +ios = { level = "partial", notes = "Runtime deep link registration is not supported" } [build-dependencies] serde = { workspace = true } serde_json = { workspace = true } -tauri-build = { workspace = true } +tauri-utils = { workspace = true } +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } serde_json = { workspace = true } tauri = { workspace = true } -log = { workspace = true } +tauri-utils = { workspace = true } +tracing = { workspace = true } thiserror = { workspace = true } -url = "2" +url = { workspace = true } + +[target."cfg(windows)".dependencies] +dunce = "1" +windows-registry = "0.5" +windows-result = "0.3" -[features] -dox = [ "tauri/dox" ] +[target."cfg(target_os = \"linux\")".dependencies] +rust-ini = "0.21" diff --git a/plugins/deep-link/README.md b/plugins/deep-link/README.md index d4f88339..61a36a80 100644 --- a/plugins/deep-link/README.md +++ b/plugins/deep-link/README.md @@ -1,10 +1,18 @@ -![plugin-deep-link](banner.png) +![plugin-deep-link](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/deep-link/banner.png) Set your Tauri application as the default handler for an URL. +| Platform | Supported | +| -------- | --------- | +| Linux | ✓ | +| Windows | ✓ | +| macOS | ✓ | +| Android | ✓ | +| iOS | ✓ | + ## Install -_This plugin requires a Rust version of at least **1.70**_ +_This plugin requires a Rust version of at least **1.77.2**_ There are three general methods of installation that we can recommend. @@ -18,7 +26,7 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] -tauri-plugin-deep-link = "2.0.0-alpha" +tauri-plugin-deep-link = "2.0.0" # alternatively with Git: tauri-plugin-deep-link = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -63,7 +71,7 @@ For [app links](https://developer.android.com/training/app-links#android-app-lin ] ``` -Where `$APP_BUNDLE_ID` is the value defined on `tauri.conf.json > tauri > bundle > identifier` with `-` replaced with `_` and `$CERT_FINGERPRINT` is a list of SHA256 fingerprints of your app's signing certificates, see [verify android applinks](https://developer.android.com/training/app-links/verify-android-applinks#web-assoc) for more information. +Where `$APP_BUNDLE_ID` is the value defined on `tauri.conf.json > identifier` with `-` replaced with `_` and `$CERT_FINGERPRINT` is a list of SHA256 fingerprints of your app's signing certificates, see [verify android applinks](https://developer.android.com/training/app-links/verify-android-applinks#web-assoc) for more information. ### iOS @@ -87,22 +95,35 @@ For [universal links](https://developer.apple.com/documentation/xcode/allowing-a } ``` -Where `$DEVELOPMENT_TEAM_ID` is the value defined on `tauri.conf.json > tauri > bundle > iOS > developmentTeam` or the `TAURI_APPLE_DEVELOPMENT_TEAM` environment variable and `$APP_BUNDLE_ID` is the value defined on `tauri.conf.json > tauri > bundle > identifier`. See [applinks.details](https://developer.apple.com/documentation/bundleresources/applinks/details) for more information. +Where `$DEVELOPMENT_TEAM_ID` is the value defined on `tauri.conf.json > bundle > iOS > developmentTeam` or the `APPLE_DEVELOPMENT_TEAM` environment variable and `$APP_BUNDLE_ID` is the value defined on `tauri.conf.json > identifier`. See [applinks.details](https://developer.apple.com/documentation/bundleresources/applinks/details) for more information. + +To verify if your domain has been properly configured to expose the app associations, you can run the following command: + +```sh +curl -v https://app-site-association.cdn-apple.com/a/v1/ +``` + +**The apple-app-site-association file must be served over HTTPS and the response must include the `Content-Type: application/json` header.** + +To quickly open an app link on the iOS simulator you can execute `xcrun simctl openurl booted `. See [supporting associated domains](https://developer.apple.com/documentation/xcode/supporting-associated-domains?language=objc) for more information. ## Configuration -Under `tauri.conf.json > plugins > deep-link`, configure the domains you want to associate with your application: +Under `tauri.conf.json > plugins > deep-link`, configure the domains (mobile) and schemes (desktop) you want to associate with your application: ```json { "plugins": { "deep-link": { - "domains": [ + "mobile": [ { "host": "your.website.com", "pathPrefix": ["/open"] }, { "host": "another.site.br" } - ] + ], + "desktop": { + "schemes": ["something", "my-tauri-app"] + } } } } @@ -112,7 +133,7 @@ Under `tauri.conf.json > plugins > deep-link`, configure the domains you want to First you need to register the core plugin with Tauri: -`src-tauri/src/main.rs` +`src-tauri/src/lib.rs` ```rust fn main() { @@ -126,12 +147,14 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import { onOpenUrl } from "@tauri-apps/plugin-deep-link"; +import { onOpenUrl } from '@tauri-apps/plugin-deep-link' await onOpenUrl((urls) => { - console.log('deep link:', urls); -}); + console.log('deep link:', urls) +}) ``` +Note that the Plugin will only emit events on macOS, iOS and Android. On Windows and Linux the OS will spawn a new instance of your app with the URL as a CLI argument. If you want your app to behave on Windows & Linux similar to the other platforms you can use the [single-instance](../single-instance/) plugin with the `deep-link` feature enabled. + ## Contributing PRs accepted. Please make sure to read the Contributing Guide before making a pull request. @@ -155,6 +178,22 @@ PRs accepted. Please make sure to read the Contributing Guide before making a pu +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + ## License Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. diff --git a/plugins/deep-link/SECURITY.md b/plugins/deep-link/SECURITY.md new file mode 100644 index 00000000..4f09bbac --- /dev/null +++ b/plugins/deep-link/SECURITY.md @@ -0,0 +1,23 @@ +# Security Policy + +**Do not report security vulnerabilities through public GitHub issues.** + +**Please use the [Private Vulnerability Disclosure](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) feature of GitHub.** + +Include as much of the following information: + +- Type of issue (e.g. improper input parsing, privilege escalation, etc.) +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- The distribution affected or used to help us with reproduction of the issue +- Step-by-step instructions to reproduce the issue +- Ideally a reproduction repository +- Impact of the issue, including how an attacker might exploit the issue + +We prefer to receive reports in English. + +## Contact + +Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). + +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/deep-link/android/build.gradle.kts b/plugins/deep-link/android/build.gradle.kts index 97bb133e..671ee8b7 100644 --- a/plugins/deep-link/android/build.gradle.kts +++ b/plugins/deep-link/android/build.gradle.kts @@ -5,11 +5,10 @@ plugins { android { namespace = "app.tauri.deep_link" - compileSdk = 32 + compileSdk = 34 defaultConfig { - minSdk = 24 - targetSdk = 32 + minSdk = 24 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles("consumer-rules.pro") diff --git a/plugins/deep-link/android/src/main/java/DeepLinkPlugin.kt b/plugins/deep-link/android/src/main/java/DeepLinkPlugin.kt index 4b52f7f3..db4e79af 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,19 @@ 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) - } */ - + // This command should not be added to the `build.rs` and exposed as it is only + // used internally from the rust backend. @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/api-iife.js b/plugins/deep-link/api-iife.js new file mode 100644 index 00000000..6d9e3e18 --- /dev/null +++ b/plugins/deep-link/api-iife.js @@ -0,0 +1 @@ +if("__TAURI__"in window){var __TAURI_PLUGIN_DEEP_LINK__=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 i(e,t,i){const a={kind:"Any"};return r("plugin:event|listen",{event:e,target:a,handler:n(t)}).then((n=>async()=>async function(e,n){await r("plugin:event|unlisten",{event:e,eventId:n})}(e,n)))}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_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_CREATED="tauri://window-created",e.WEBVIEW_CREATED="tauri://webview-created",e.DRAG_ENTER="tauri://drag-enter",e.DRAG_OVER="tauri://drag-over",e.DRAG_DROP="tauri://drag-drop",e.DRAG_LEAVE="tauri://drag-leave"}(t||(t={})),e.getCurrent=async function(){return await r("plugin:deep-link|get_current")},e.isRegistered=async function(e){return await r("plugin:deep-link|is_registered",{protocol:e})},e.onOpenUrl=async function(e){return await i("deep-link://new-url",(n=>{e(n.payload)}))},e.register=async function(e){return await r("plugin:deep-link|register",{protocol:e})},e.unregister=async function(e){return await r("plugin:deep-link|unregister",{protocol:e})},e}({});Object.defineProperty(window.__TAURI__,"deepLink",{value:__TAURI_PLUGIN_DEEP_LINK__})} diff --git a/plugins/deep-link/build.rs b/plugins/deep-link/build.rs index f3452087..418746b2 100644 --- a/plugins/deep-link/build.rs +++ b/plugins/deep-link/build.rs @@ -6,46 +6,73 @@ mod config; use config::{AssociatedDomain, Config}; +const COMMANDS: &[&str] = &["get_current", "register", "unregister", "is_registered"]; + // TODO: Consider using activity-alias in case users may have multiple activities in their app. -// TODO: Do we want to support the other path* configs too? fn intent_filter(domain: &AssociatedDomain) -> String { format!( r#" - - + {} {} + {} + {} + {} "#, + domain + .scheme + .iter() + .map(|scheme| format!(r#""#)) + .collect::>() + .join("\n "), domain.host, + domain + .path + .iter() + .map(|path| format!(r#""#)) + .collect::>() + .join("\n "), + domain + .path_pattern + .iter() + .map(|pattern| format!(r#""#)) + .collect::>() + .join("\n "), domain .path_prefix .iter() .map(|prefix| format!(r#""#)) .collect::>() - .join("\n ") + .join("\n "), + domain + .path_suffix + .iter() + .map(|suffix| format!(r#""#)) + .collect::>() + .join("\n "), ) } fn main() { - if let Err(error) = tauri_build::mobile::PluginBuilder::new() + let result = tauri_plugin::Builder::new(COMMANDS) + .global_api_script_path("./api-iife.js") .android_path("android") - .run() - { - println!("{error:#}"); - if !(cfg!(feature = "dox") && std::env::var("TARGET").unwrap().contains("android")) { - std::process::exit(1); - } + .try_build(); + + // when building documentation for Android the plugin build result is always Err() and is irrelevant to the crate documentation build + if !(cfg!(docsrs) && std::env::var("TARGET").unwrap().contains("android")) { + result.unwrap(); } - if let Some(config) = tauri_build::config::plugin_config::("deep-link") { - tauri_build::mobile::update_android_manifest( + if let Some(config) = tauri_plugin::plugin_config::("deep-link") { + tauri_plugin::mobile::update_android_manifest( "DEEP LINK PLUGIN", "activity", config - .domains + .mobile .iter() .map(intent_filter) .collect::>() @@ -55,11 +82,11 @@ fn main() { #[cfg(target_os = "macos")] { - tauri_build::mobile::update_entitlements(|entitlements| { + tauri_plugin::mobile::update_entitlements(|entitlements| { entitlements.insert( "com.apple.developer.associated-domains".into(), config - .domains + .mobile .into_iter() .map(|d| format!("applinks:{}", d.host).into()) .collect::>() diff --git a/plugins/deep-link/examples/app/.gitignore b/plugins/deep-link/examples/app/.gitignore index a547bf36..c9b61864 100644 --- a/plugins/deep-link/examples/app/.gitignore +++ b/plugins/deep-link/examples/app/.gitignore @@ -8,7 +8,6 @@ pnpm-debug.log* lerna-debug.log* node_modules -dist dist-ssr *.local @@ -22,3 +21,5 @@ dist-ssr *.njsproj *.sln *.sw? + +dist/ diff --git a/plugins/deep-link/examples/app/CHANGELOG.md b/plugins/deep-link/examples/app/CHANGELOG.md index b2295820..5a363c8e 100644 --- a/plugins/deep-link/examples/app/CHANGELOG.md +++ b/plugins/deep-link/examples/app/CHANGELOG.md @@ -1,5 +1,145 @@ # Changelog +## \[2.2.2] + +### Dependencies + +- Upgraded to `deep-link-js@2.3.0` + +## \[2.2.1] + +### Dependencies + +- Upgraded to `deep-link-js@2.2.1` + +## \[2.2.0] + +### Dependencies + +- Upgraded to `deep-link-js@2.1.0` + +## \[2.0.1] + +### Dependencies + +- Upgraded to `deep-link-js@2.0.1` + +## \[2.0.0] + +- [`e2c4dfb6`](https://github.com/tauri-apps/plugins-workspace/commit/e2c4dfb6af43e5dd8d9ceba232c315f5febd55c1) Update to tauri v2 stable release. + +### Dependencies + +- Upgraded to `deep-link-js@2.0.0` + +## \[2.0.0-rc.1] + +### Dependencies + +- Upgraded to `deep-link-js@2.0.0-rc.2` + +## \[2.0.0-rc.0] + +### Dependencies + +- Upgraded to `deep-link-js@2.0.0-rc.1` + +## \[2.0.0-beta.11] + +### Dependencies + +- Upgraded to `deep-link-js@2.0.0-rc.0` + +## \[2.0.0-beta.10] + +### Dependencies + +- Upgraded to `deep-link-js@2.0.0-beta.10` + +## \[2.0.0-beta.9] + +### Dependencies + +- Upgraded to `deep-link-js@2.0.0-beta.9` + +## \[2.0.0-beta.8] + +### Dependencies + +- Upgraded to `deep-link-js@2.0.0-beta.8` + +## \[2.0.0-beta.7] + +### Dependencies + +- Upgraded to `deep-link-js@2.0.0-beta.7` + +## \[2.0.0-beta.6] + +### Dependencies + +- Upgraded to `deep-link-js@2.0.0-beta.6` + +## \[2.0.0-beta.5] + +### Dependencies + +- Upgraded to `deep-link-js@2.0.0-beta.5` + +## \[2.0.0-beta.4] + +### Dependencies + +- Upgraded to `deep-link-js@2.0.0-beta.4` + +## \[2.0.0-beta.3] + +### Dependencies + +- Upgraded to `deep-link-js@2.0.0-beta.3` + +## \[2.0.0-beta.2] + +### Dependencies + +- Upgraded to `deep-link-js@2.0.0-beta.2` + +## \[2.0.0-beta.1] + +### Dependencies + +- Upgraded to `deep-link-js@2.0.0-beta.1` + +## \[2.0.0-beta.0] + +### Dependencies + +- Upgraded to `deep-link-js@2.0.0-beta.0` + +## \[0.0.1-alpha.4] + +### Dependencies + +- Upgraded to `deep-link-js@2.0.0-alpha.4` + +## \[0.0.1-alpha.3] + +### Dependencies + +- Upgraded to `deep-link-js@2.0.0-alpha.3` + +## \[0.0.1-alpha.2] + +### Dependencies + +- Upgraded to `deep-link-js@2.0.0-alpha.2` + +## \[0.0.1-alpha.1] + +### Dependencies + +- Upgraded to `deep-link-js@2.0.0-alpha.1` + ## \[0.0.1-alpha.0] ### Dependencies diff --git a/plugins/deep-link/examples/app/package.json b/plugins/deep-link/examples/app/package.json index 983a117f..34a43538 100644 --- a/plugins/deep-link/examples/app/package.json +++ b/plugins/deep-link/examples/app/package.json @@ -1,7 +1,7 @@ { "name": "deep-link-example", "private": true, - "version": "0.0.1-alpha.0", + "version": "2.2.2", "type": "module", "scripts": { "dev": "vite", @@ -10,13 +10,12 @@ "tauri": "tauri" }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.6", - "@tauri-apps/plugin-deep-link": "2.0.0-alpha.0" + "@tauri-apps/api": "2.5.0", + "@tauri-apps/plugin-deep-link": "2.3.0" }, "devDependencies": { - "@tauri-apps/cli": "2.0.0-alpha.16", - "internal-ip": "^8.0.0", - "typescript": "^5.2.2", - "vite": "^4.5.0" + "@tauri-apps/cli": "2.5.0", + "typescript": "^5.7.3", + "vite": "^6.2.6" } } diff --git a/plugins/deep-link/examples/app/src-tauri/.gitignore b/plugins/deep-link/examples/app/src-tauri/.gitignore index 821bbb6b..877b3f77 100644 --- a/plugins/deep-link/examples/app/src-tauri/.gitignore +++ b/plugins/deep-link/examples/app/src-tauri/.gitignore @@ -2,4 +2,6 @@ # will have compiled files and executables /target/ +/gen/schemas + .cargo \ No newline at end of file diff --git a/plugins/deep-link/examples/app/src-tauri/Cargo.toml b/plugins/deep-link/examples/app/src-tauri/Cargo.toml index d4d2effb..11e7c41f 100644 --- a/plugins/deep-link/examples/app/src-tauri/Cargo.toml +++ b/plugins/deep-link/examples/app/src-tauri/Cargo.toml @@ -6,7 +6,7 @@ authors = ["you"] license = "" repository = "" edition = "2021" -rust-version = "1.70" +rust-version = "1.77.2" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -19,11 +19,16 @@ tauri-build = { workspace = true } [dependencies] serde = { workspace = true } serde_json = { workspace = true } -tauri = { workspace = true } +tauri = { workspace = true, features = ["wry", "compression"] } tauri-plugin-deep-link = { path = "../../../" } +tauri-plugin-log = { path = "../../../../log" } +tauri-plugin-single-instance = { path = "../../../../single-instance", features = [ + "deep-link", +] } +log = "0.4" [features] -# this feature is used for production builds or when `devPath` points to the filesystem and the built-in dev server is disabled. +# this feature is used for production builds or when `devUrl` points to the filesystem and the built-in dev server is disabled. # If you use cargo directly instead of tauri's cli you can use this feature flag to switch between tauri's `dev` and `build` modes. # DO NOT REMOVE!! -custom-protocol = [ "tauri/custom-protocol" ] +prod = ["tauri/custom-protocol"] diff --git a/plugins/deep-link/examples/app/src-tauri/capabilities/app.json b/plugins/deep-link/examples/app/src-tauri/capabilities/app.json new file mode 100644 index 00000000..a4bc7b4c --- /dev/null +++ b/plugins/deep-link/examples/app/src-tauri/capabilities/app.json @@ -0,0 +1,11 @@ +{ + "$schema": "../gen/schemas/desktop-schema.json", + "identifier": "run-app-base", + "description": "Base permissions to run the app", + "windows": ["main"], + "permissions": [ + "core:default", + "deep-link:allow-get-current", + "deep-link:default" + ] +} diff --git a/plugins/deep-link/examples/app/src-tauri/gen/android/app/.gitignore b/plugins/deep-link/examples/app/src-tauri/gen/android/app/.gitignore index 6d888c10..1efb55bd 100644 --- a/plugins/deep-link/examples/app/src-tauri/gen/android/app/.gitignore +++ b/plugins/deep-link/examples/app/src-tauri/gen/android/app/.gitignore @@ -2,4 +2,5 @@ /src/main/jniLibs/**/*.so /src/main/assets/tauri.conf.json /tauri.build.gradle.kts -/proguard-tauri.pro \ No newline at end of file +/proguard-tauri.pro +/tauri.properties \ No newline at end of file diff --git a/plugins/deep-link/examples/app/src-tauri/gen/android/app/build.gradle.kts b/plugins/deep-link/examples/app/src-tauri/gen/android/app/build.gradle.kts index f26cb2a5..f434bbfb 100644 --- a/plugins/deep-link/examples/app/src-tauri/gen/android/app/build.gradle.kts +++ b/plugins/deep-link/examples/app/src-tauri/gen/android/app/build.gradle.kts @@ -1,19 +1,28 @@ +import java.util.Properties + plugins { id("com.android.application") id("org.jetbrains.kotlin.android") id("rust") } +val tauriProperties = Properties().apply { + val propFile = file("tauri.properties") + if (propFile.exists()) { + propFile.inputStream().use { load(it) } + } +} + android { - compileSdk = 33 + compileSdk = 34 namespace = "com.tauri.deep_link_example" defaultConfig { manifestPlaceholders["usesCleartextTraffic"] = "false" applicationId = "com.tauri.deep_link_example" minSdk = 24 - targetSdk = 33 - versionCode = 1 - versionName = "1.0" + targetSdk = 34 + versionCode = tauriProperties.getProperty("tauri.android.versionCode", "1").toInt() + versionName = tauriProperties.getProperty("tauri.android.versionName", "1.0") } buildTypes { getByName("debug") { @@ -39,6 +48,9 @@ android { kotlinOptions { jvmTarget = "1.8" } + buildFeatures { + buildConfig = true + } } rust { @@ -54,4 +66,4 @@ dependencies { androidTestImplementation("androidx.test.espresso:espresso-core:3.5.0") } -apply(from = "tauri.build.gradle.kts") +apply(from = "tauri.build.gradle.kts") \ No newline at end of file diff --git a/plugins/deep-link/examples/app/src-tauri/gen/android/app/src/main/AndroidManifest.xml b/plugins/deep-link/examples/app/src-tauri/gen/android/app/src/main/AndroidManifest.xml index 68c05a37..05265e32 100644 --- a/plugins/deep-link/examples/app/src-tauri/gen/android/app/src/main/AndroidManifest.xml +++ b/plugins/deep-link/examples/app/src-tauri/gen/android/app/src/main/AndroidManifest.xml @@ -1,6 +1,10 @@ + + + + + + diff --git a/plugins/deep-link/examples/app/src-tauri/gen/android/build.gradle.kts b/plugins/deep-link/examples/app/src-tauri/gen/android/build.gradle.kts index 5ce764e3..c5ef452a 100644 --- a/plugins/deep-link/examples/app/src-tauri/gen/android/build.gradle.kts +++ b/plugins/deep-link/examples/app/src-tauri/gen/android/build.gradle.kts @@ -4,8 +4,8 @@ buildscript { mavenCentral() } dependencies { - classpath("com.android.tools.build:gradle:8.0.0") - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21") + classpath("com.android.tools.build:gradle:8.5.1") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.25") } } diff --git a/plugins/deep-link/examples/app/src-tauri/gen/android/buildSrc/build.gradle.kts b/plugins/deep-link/examples/app/src-tauri/gen/android/buildSrc/build.gradle.kts index 099feff7..39e90b05 100644 --- a/plugins/deep-link/examples/app/src-tauri/gen/android/buildSrc/build.gradle.kts +++ b/plugins/deep-link/examples/app/src-tauri/gen/android/buildSrc/build.gradle.kts @@ -18,6 +18,6 @@ repositories { dependencies { compileOnly(gradleApi()) - implementation("com.android.tools.build:gradle:8.0.0") + implementation("com.android.tools.build:gradle:8.5.1") } diff --git a/plugins/deep-link/examples/app/src-tauri/gen/android/buildSrc/src/main/java/com/tauri/deep_link_example/kotlin/BuildTask.kt b/plugins/deep-link/examples/app/src-tauri/gen/android/buildSrc/src/main/java/com/tauri/deep_link_example/kotlin/BuildTask.kt index b9e83018..f9874825 100644 --- a/plugins/deep-link/examples/app/src-tauri/gen/android/buildSrc/src/main/java/com/tauri/deep_link_example/kotlin/BuildTask.kt +++ b/plugins/deep-link/examples/app/src-tauri/gen/android/buildSrc/src/main/java/com/tauri/deep_link_example/kotlin/BuildTask.kt @@ -1,7 +1,3 @@ -// Copyright 2019-2023 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - import java.io.File import org.apache.tools.ant.taskdefs.condition.Os import org.gradle.api.DefaultTask diff --git a/plugins/deep-link/examples/app/src-tauri/gen/android/buildSrc/src/main/java/com/tauri/deep_link_example/kotlin/RustPlugin.kt b/plugins/deep-link/examples/app/src-tauri/gen/android/buildSrc/src/main/java/com/tauri/deep_link_example/kotlin/RustPlugin.kt index cad2d877..4aa7fcaf 100644 --- a/plugins/deep-link/examples/app/src-tauri/gen/android/buildSrc/src/main/java/com/tauri/deep_link_example/kotlin/RustPlugin.kt +++ b/plugins/deep-link/examples/app/src-tauri/gen/android/buildSrc/src/main/java/com/tauri/deep_link_example/kotlin/RustPlugin.kt @@ -1,7 +1,3 @@ -// Copyright 2019-2023 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - import com.android.build.api.dsl.ApplicationExtension import org.gradle.api.DefaultTask import org.gradle.api.Plugin diff --git a/plugins/deep-link/examples/app/src-tauri/gen/android/gradle.properties b/plugins/deep-link/examples/app/src-tauri/gen/android/gradle.properties index 022338b7..2a7ec695 100644 --- a/plugins/deep-link/examples/app/src-tauri/gen/android/gradle.properties +++ b/plugins/deep-link/examples/app/src-tauri/gen/android/gradle.properties @@ -21,5 +21,4 @@ kotlin.code.style=official # resources declared in the library itself and none from the library's dependencies, # thereby reducing the size of the R class for that library android.nonTransitiveRClass=true -android.defaults.buildfeatures.buildconfig=true android.nonFinalResIds=false \ No newline at end of file diff --git a/plugins/deep-link/examples/app/src-tauri/gen/android/gradle/wrapper/gradle-wrapper.properties b/plugins/deep-link/examples/app/src-tauri/gen/android/gradle/wrapper/gradle-wrapper.properties index 40a43506..0df10d55 100644 --- a/plugins/deep-link/examples/app/src-tauri/gen/android/gradle/wrapper/gradle-wrapper.properties +++ b/plugins/deep-link/examples/app/src-tauri/gen/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Tue May 10 19:22:52 CST 2022 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/plugins/deep-link/examples/app/src-tauri/gen/android/gradlew b/plugins/deep-link/examples/app/src-tauri/gen/android/gradlew old mode 100644 new mode 100755 diff --git a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@1x.png b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@1x.png index f8b128e3..a6ac2a8c 100644 Binary files a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@1x.png and b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@1x.png differ diff --git a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@2x-1.png b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@2x-1.png index 6bbd9e3c..2869541f 100644 Binary files a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@2x-1.png and b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@2x-1.png differ diff --git a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@2x.png b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@2x.png index 6bbd9e3c..2869541f 100644 Binary files a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@2x.png and b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@2x.png differ diff --git a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@3x.png b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@3x.png index f702cc04..cf265a45 100644 Binary files a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@3x.png and b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@3x.png differ diff --git a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@1x.png b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@1x.png index c5e92f78..29c9746c 100644 Binary files a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@1x.png and b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@1x.png differ diff --git a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@2x-1.png b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@2x-1.png index 1c607d5c..a4e68c8d 100644 Binary files a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@2x-1.png and b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@2x-1.png differ diff --git a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@2x.png b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@2x.png index 1c607d5c..a4e68c8d 100644 Binary files a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@2x.png and b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@2x.png differ diff --git a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@3x.png b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@3x.png index 60e93a6a..e4adcbce 100644 Binary files a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@3x.png and b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@3x.png differ diff --git a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@1x.png b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@1x.png index 6bbd9e3c..2869541f 100644 Binary files a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@1x.png and b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@1x.png differ diff --git a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@2x-1.png b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@2x-1.png index 819410f9..a414e65b 100644 Binary files a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@2x-1.png and b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@2x-1.png differ diff --git a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@2x.png b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@2x.png index 819410f9..a414e65b 100644 Binary files a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@2x.png and b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@2x.png differ diff --git a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@3x.png b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@3x.png index e00ae5a6..a0807e5d 100644 Binary files a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@3x.png and b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@3x.png differ diff --git a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png index f5301f37..704c9291 100644 Binary files a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png and b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png differ diff --git a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-512x512@2x.png b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-512x512@2x.png deleted file mode 100644 index 5e9add73..00000000 Binary files a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-512x512@2x.png and /dev/null differ diff --git a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-60x60@2x.png b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-60x60@2x.png index e00ae5a6..a0807e5d 100644 Binary files a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-60x60@2x.png and b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-60x60@2x.png differ diff --git a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-60x60@3x.png b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-60x60@3x.png index 3546ca10..2a9fbc26 100644 Binary files a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-60x60@3x.png and b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-60x60@3x.png differ diff --git a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-76x76@1x.png b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-76x76@1x.png index d8367101..2cdf1848 100644 Binary files a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-76x76@1x.png and b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-76x76@1x.png differ diff --git a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-76x76@2x.png b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-76x76@2x.png index 29925f2a..4723e4b4 100644 Binary files a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-76x76@2x.png and b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-76x76@2x.png differ diff --git a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-83.5x83.5@2x.png b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-83.5x83.5@2x.png index dfd22619..f26fee45 100644 Binary files a/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-83.5x83.5@2x.png and b/plugins/deep-link/examples/app/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/AppIcon-83.5x83.5@2x.png differ diff --git a/plugins/deep-link/examples/app/src-tauri/gen/apple/ExportOptions.plist b/plugins/deep-link/examples/app/src-tauri/gen/apple/ExportOptions.plist index b69cf1de..0428a171 100644 --- a/plugins/deep-link/examples/app/src-tauri/gen/apple/ExportOptions.plist +++ b/plugins/deep-link/examples/app/src-tauri/gen/apple/ExportOptions.plist @@ -3,6 +3,6 @@ method - development + debugging diff --git a/plugins/deep-link/examples/app/src-tauri/gen/apple/LaunchScreen.storyboard b/plugins/deep-link/examples/app/src-tauri/gen/apple/LaunchScreen.storyboard new file mode 100644 index 00000000..dd79351e --- /dev/null +++ b/plugins/deep-link/examples/app/src-tauri/gen/apple/LaunchScreen.storyboard @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/deep-link/examples/app/src-tauri/gen/apple/deep-link-example.xcodeproj/project.pbxproj b/plugins/deep-link/examples/app/src-tauri/gen/apple/deep-link-example.xcodeproj/project.pbxproj index c2e4090c..450bd847 100644 --- a/plugins/deep-link/examples/app/src-tauri/gen/apple/deep-link-example.xcodeproj/project.pbxproj +++ b/plugins/deep-link/examples/app/src-tauri/gen/apple/deep-link-example.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 51; + objectVersion = 56; objects = { /* Begin PBXBuildFile section */ @@ -17,26 +17,28 @@ D01EC573029B7BEC701F6012 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6BDF5DBBA740DA7D86791DEC /* WebKit.framework */; }; D4D232DBB85C5C1594FACC3D /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = D99665C1C3247732C6BF25F4 /* main.mm */; }; D7A9EBD47413746EDE96BDF8 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B18865218362A4BE07527DBD /* CoreGraphics.framework */; }; - FBB3FE3EDDEAF717E61F2AD4 /* libdeep_link_example.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DCAEEC42BAB5E4A4757C89C2 /* libdeep_link_example.a */; }; + E26F7FA923DA1EABEE42B63A /* libapp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 403FB4BAE59F74EE98EF1EC6 /* libapp.a */; }; + E6992F2651B864B15ED14925 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1846ADCEDC2C208E1037ADC6 /* LaunchScreen.storyboard */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 1846ADCEDC2C208E1037ADC6 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = ""; }; 1C21C8B4A18EC7D0B5808C10 /* MetalKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MetalKit.framework; path = System/Library/Frameworks/MetalKit.framework; sourceTree = SDKROOT; }; - 1CAAFA750FD735A285DC1238 /* deep-link-example_iOS.app */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.application; path = "deep-link-example_iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 1CAAFA750FD735A285DC1238 /* deep-link-example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "deep-link-example.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 2F316D1CD78DD2E070DA5C17 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 3DD32303BEC377C10162CF69 /* bindings.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = bindings.h; sourceTree = ""; }; + 403FB4BAE59F74EE98EF1EC6 /* libapp.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libapp.a; sourceTree = ""; }; 486CAFD81CB14F9A2DF72FDF /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; - 4A33212233BFAA738F6A46FC /* lib.rs */ = {isa = PBXFileReference; path = lib.rs; sourceTree = ""; }; + 4A33212233BFAA738F6A46FC /* lib.rs */ = {isa = PBXFileReference; lastKnownFileType = text; path = lib.rs; sourceTree = ""; }; 4BDECB1ED2EEEB5A6A8B8372 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; 6BDF5DBBA740DA7D86791DEC /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; }; 8AB0099573FE8BF1DC82CDBA /* deep-link-example_iOS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "deep-link-example_iOS.entitlements"; sourceTree = ""; }; 9435FC7E183EA6260CE76637 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; - AEA78299D25FEC31E2988090 /* main.rs */ = {isa = PBXFileReference; path = main.rs; sourceTree = ""; }; + AEA78299D25FEC31E2988090 /* main.rs */ = {isa = PBXFileReference; lastKnownFileType = text; path = main.rs; sourceTree = ""; }; B005488D1B56B657AB52E28C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; B18865218362A4BE07527DBD /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; BF7ECB9AB55B71692A21D5F7 /* assets */ = {isa = PBXFileReference; lastKnownFileType = folder; path = assets; sourceTree = SOURCE_ROOT; }; D99665C1C3247732C6BF25F4 /* main.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = main.mm; sourceTree = ""; }; - DCAEEC42BAB5E4A4757C89C2 /* libdeep_link_example.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libdeep_link_example.a; sourceTree = ""; }; ED2B1BC06DFE0498ECDEEE51 /* Metal.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Metal.framework; path = System/Library/Frameworks/Metal.framework; sourceTree = SDKROOT; }; /* End PBXFileReference section */ @@ -45,7 +47,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - FBB3FE3EDDEAF717E61F2AD4 /* libdeep_link_example.a in Frameworks */, + E26F7FA923DA1EABEE42B63A /* libapp.a in Frameworks */, D7A9EBD47413746EDE96BDF8 /* CoreGraphics.framework in Frameworks */, 017AE826151E36372534A964 /* Metal.framework in Frameworks */, BC36958BBBA7FE61066213D7 /* MetalKit.framework in Frameworks */, @@ -81,6 +83,7 @@ children = ( BF7ECB9AB55B71692A21D5F7 /* assets */, 486CAFD81CB14F9A2DF72FDF /* Assets.xcassets */, + 1846ADCEDC2C208E1037ADC6 /* LaunchScreen.storyboard */, 7D12035C470ED9DAF55A709E /* deep-link-example_iOS */, 84EADC52DA26583ACE816A6D /* Externals */, 146BAF1D709F8A0FE5B07709 /* Sources */, @@ -94,7 +97,7 @@ isa = PBXGroup; children = ( B18865218362A4BE07527DBD /* CoreGraphics.framework */, - DCAEEC42BAB5E4A4757C89C2 /* libdeep_link_example.a */, + 403FB4BAE59F74EE98EF1EC6 /* libapp.a */, ED2B1BC06DFE0498ECDEEE51 /* Metal.framework */, 1C21C8B4A18EC7D0B5808C10 /* MetalKit.framework */, 9435FC7E183EA6260CE76637 /* QuartzCore.framework */, @@ -142,7 +145,7 @@ F9EEBB3248B74B1D6CDA4D84 /* Products */ = { isa = PBXGroup; children = ( - 1CAAFA750FD735A285DC1238 /* deep-link-example_iOS.app */, + 1CAAFA750FD735A285DC1238 /* deep-link-example.app */, ); name = Products; sourceTree = ""; @@ -165,7 +168,7 @@ ); name = "deep-link-example_iOS"; productName = "deep-link-example_iOS"; - productReference = 1CAAFA750FD735A285DC1238 /* deep-link-example_iOS.app */; + productReference = 1CAAFA750FD735A285DC1238 /* deep-link-example.app */; productType = "com.apple.product-type.application"; }; /* End PBXNativeTarget section */ @@ -174,15 +177,11 @@ BCB4BA6E81088C5B470E3436 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1200; - TargetAttributes = { - A1C635908C823A89928264CD = { - DevelopmentTeam = Q93MBH6S2F; - }; - }; + BuildIndependentTargetsInParallel = YES; + LastUpgradeCheck = 1430; }; buildConfigurationList = 8FCB58B8ADB9F9CB9ECE01FA /* Build configuration list for PBXProject "deep-link-example" */; - compatibilityVersion = "Xcode 11.0"; + compatibilityVersion = "Xcode 14.0"; developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( @@ -204,6 +203,7 @@ buildActionMask = 2147483647; files = ( 65A8D948440EDAA7F62BA1F4 /* Assets.xcassets in Resources */, + E6992F2651B864B15ED14925 /* LaunchScreen.storyboard in Resources */, C384FB77F116B05F8E642CA8 /* assets in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -225,8 +225,9 @@ outputFileListPaths = ( ); outputPaths = ( - "$(SRCROOT)/target/aarch64-apple-ios/${CONFIGURATION}/deps/libdeep_link_example.a", - "$(SRCROOT)/target/x86_64-apple-ios/${CONFIGURATION}/deps/libdeep_link_example.a", + "$(SRCROOT)/Externals/x86_64/${CONFIGURATION}/libapp.a", + "$(SRCROOT)/Externals/arm64/${CONFIGURATION}/libapp.a", + "$(SRCROOT)/Externals/arm64-sim/${CONFIGURATION}/libapp.a", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -320,8 +321,11 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = "deep-link-example_iOS/deep-link-example_iOS.entitlements"; CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = Q93MBH6S2F; ENABLE_BITCODE = NO; + "EXCLUDED_ARCHS[sdk=iphoneos*]" = "arm64-sim x86_64"; + "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\".\"", @@ -331,10 +335,28 @@ "$(inherited)", "@executable_path/Frameworks", ); - "LIBRARY_SEARCH_PATHS[arch=arm64-sim]" = "$(inherited) $(PROJECT_DIR)/Externals/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)"; - "LIBRARY_SEARCH_PATHS[arch=arm64]" = "$(inherited) $(PROJECT_DIR)/Externals/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)"; - "LIBRARY_SEARCH_PATHS[arch=x86_64]" = "$(inherited) $(PROJECT_DIR)/Externals/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)"; - PRODUCT_BUNDLE_IDENTIFIER = "com.tauri.deep-link-example"; + "LIBRARY_SEARCH_PATHS[arch=arm64-sim]" = ( + "$(inherited)", + "$(PROJECT_DIR)/Externals/arm64-sim/$(CONFIGURATION)", + "$(SDKROOT)/usr/lib/swift", + "$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)", + "$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)", + ); + "LIBRARY_SEARCH_PATHS[arch=arm64]" = ( + "$(inherited)", + "$(PROJECT_DIR)/Externals/arm64/$(CONFIGURATION)", + "$(SDKROOT)/usr/lib/swift", + "$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)", + "$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)", + ); + "LIBRARY_SEARCH_PATHS[arch=x86_64]" = ( + "$(inherited)", + "$(PROJECT_DIR)/Externals/x86_64/$(CONFIGURATION)", + "$(SDKROOT)/usr/lib/swift", + "$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)", + "$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.tauri.deep-link-example; PRODUCT_NAME = "deep-link-example"; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; @@ -409,8 +431,11 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = "deep-link-example_iOS/deep-link-example_iOS.entitlements"; CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = Q93MBH6S2F; ENABLE_BITCODE = NO; + "EXCLUDED_ARCHS[sdk=iphoneos*]" = "arm64-sim x86_64"; + "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\".\"", @@ -420,10 +445,28 @@ "$(inherited)", "@executable_path/Frameworks", ); - "LIBRARY_SEARCH_PATHS[arch=arm64-sim]" = "$(inherited) $(PROJECT_DIR)/Externals/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)"; - "LIBRARY_SEARCH_PATHS[arch=arm64]" = "$(inherited) $(PROJECT_DIR)/Externals/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)"; - "LIBRARY_SEARCH_PATHS[arch=x86_64]" = "$(inherited) $(PROJECT_DIR)/Externals/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)"; - PRODUCT_BUNDLE_IDENTIFIER = "com.tauri.deep-link-example"; + "LIBRARY_SEARCH_PATHS[arch=arm64-sim]" = ( + "$(inherited)", + "$(PROJECT_DIR)/Externals/arm64-sim/$(CONFIGURATION)", + "$(SDKROOT)/usr/lib/swift", + "$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)", + "$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)", + ); + "LIBRARY_SEARCH_PATHS[arch=arm64]" = ( + "$(inherited)", + "$(PROJECT_DIR)/Externals/arm64/$(CONFIGURATION)", + "$(SDKROOT)/usr/lib/swift", + "$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)", + "$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)", + ); + "LIBRARY_SEARCH_PATHS[arch=x86_64]" = ( + "$(inherited)", + "$(PROJECT_DIR)/Externals/x86_64/$(CONFIGURATION)", + "$(SDKROOT)/usr/lib/swift", + "$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)", + "$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.tauri.deep-link-example; PRODUCT_NAME = "deep-link-example"; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/plugins/deep-link/examples/app/src-tauri/gen/apple/deep-link-example.xcodeproj/xcshareddata/xcschemes/deep-link-example_iOS.xcscheme b/plugins/deep-link/examples/app/src-tauri/gen/apple/deep-link-example.xcodeproj/xcshareddata/xcschemes/deep-link-example_iOS.xcscheme index 7c19e933..a8fbc97e 100644 --- a/plugins/deep-link/examples/app/src-tauri/gen/apple/deep-link-example.xcodeproj/xcshareddata/xcschemes/deep-link-example_iOS.xcscheme +++ b/plugins/deep-link/examples/app/src-tauri/gen/apple/deep-link-example.xcodeproj/xcshareddata/xcschemes/deep-link-example_iOS.xcscheme @@ -1,6 +1,6 @@ CFBundleShortVersionString 0.0.0 CFBundleVersion - 0.0.0 + 0.1.0 LSRequiresIPhoneOS UILaunchStoryboardName @@ -41,4 +41,4 @@ UIInterfaceOrientationLandscapeRight - + \ No newline at end of file diff --git a/plugins/deep-link/examples/app/src-tauri/gen/apple/project.yml b/plugins/deep-link/examples/app/src-tauri/gen/apple/project.yml index d369b8dc..c924ca77 100644 --- a/plugins/deep-link/examples/app/src-tauri/gen/apple/project.yml +++ b/plugins/deep-link/examples/app/src-tauri/gen/apple/project.yml @@ -4,7 +4,7 @@ name: deep-link-example options: - bundleIdPrefix: com.tauri + bundleIdPrefix: com.tauri.deep-link-example deploymentTarget: iOS: 13.0 fileGroups: [../../src] @@ -40,6 +40,7 @@ targets: - path: assets buildPhase: resources type: folder + - path: LaunchScreen.storyboard info: path: deep-link-example_iOS/Info.plist properties: @@ -68,13 +69,15 @@ targets: ENABLE_BITCODE: false ARCHS: [arm64, arm64-sim] VALID_ARCHS: arm64 arm64-sim - LIBRARY_SEARCH_PATHS[arch=x86_64]: $(inherited) $(PROJECT_DIR)/Externals/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME) - LIBRARY_SEARCH_PATHS[arch=arm64]: $(inherited) $(PROJECT_DIR)/Externals/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME) - LIBRARY_SEARCH_PATHS[arch=arm64-sim]: $(inherited) $(PROJECT_DIR)/Externals/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME) + LIBRARY_SEARCH_PATHS[arch=x86_64]: $(inherited) $(PROJECT_DIR)/Externals/x86_64/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME) + LIBRARY_SEARCH_PATHS[arch=arm64]: $(inherited) $(PROJECT_DIR)/Externals/arm64/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME) + LIBRARY_SEARCH_PATHS[arch=arm64-sim]: $(inherited) $(PROJECT_DIR)/Externals/arm64-sim/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME) ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES: true + EXCLUDED_ARCHS[sdk=iphonesimulator*]: arm64 + EXCLUDED_ARCHS[sdk=iphoneos*]: arm64-sim x86_64 groups: [app] dependencies: - - framework: libdeep_link_example.a + - framework: libapp.a embed: false - sdk: CoreGraphics.framework - sdk: Metal.framework @@ -88,5 +91,6 @@ targets: name: Build Rust Code basedOnDependencyAnalysis: false outputFiles: - - $(SRCROOT)/target/aarch64-apple-ios/${CONFIGURATION}/deps/libdeep_link_example.a - - $(SRCROOT)/target/x86_64-apple-ios/${CONFIGURATION}/deps/libdeep_link_example.a + - $(SRCROOT)/Externals/x86_64/${CONFIGURATION}/libapp.a + - $(SRCROOT)/Externals/arm64/${CONFIGURATION}/libapp.a + - $(SRCROOT)/Externals/arm64-sim/${CONFIGURATION}/libapp.a diff --git a/plugins/deep-link/examples/app/src-tauri/server.js b/plugins/deep-link/examples/app/src-tauri/server.js index c8686631..24a6ac6f 100644 --- a/plugins/deep-link/examples/app/src-tauri/server.js +++ b/plugins/deep-link/examples/app/src-tauri/server.js @@ -2,30 +2,30 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import http from "http"; -import fs from "fs"; -import path from "path"; -import * as url from "url"; -const __dirname = url.fileURLToPath(new URL(".", import.meta.url)); +import http from 'http' +import fs from 'fs' +import path from 'path' +import * as url from 'url' +const __dirname = url.fileURLToPath(new URL('.', import.meta.url)) -const port = 8125; +const port = 8125 http .createServer(function (request, response) { - if (request.url === "/.well-known/apple-app-site-association") { + if (request.url === '/.well-known/apple-app-site-association') { // eslint-disable-next-line fs.readFile( - path.resolve(__dirname, "apple-app-site-association"), + path.resolve(__dirname, 'apple-app-site-association'), function (_error, content) { - response.writeHead(200); - response.end(content, "utf-8"); - }, - ); + response.writeHead(200) + response.end(content, 'utf-8') + } + ) } else { - response.writeHead(404); - response.end(); + response.writeHead(404) + response.end() } }) - .listen(port); + .listen(port) -console.log(`Server running at http://127.0.0.1:${port}/`); +console.log(`Server running at http://127.0.0.1:${port}/`) diff --git a/plugins/deep-link/examples/app/src-tauri/src/lib.rs b/plugins/deep-link/examples/app/src-tauri/src/lib.rs index 524f56cb..f85527d9 100644 --- a/plugins/deep-link/examples/app/src-tauri/src/lib.rs +++ b/plugins/deep-link/examples/app/src-tauri/src/lib.rs @@ -2,22 +2,45 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use tauri::Manager; +use tauri_plugin_deep_link::DeepLinkExt; // Learn more about Tauri commands at https://tauri.app/v1/guides/features/command #[tauri::command] fn greet(name: &str) -> String { - format!("Hello, {}! You've been greeted from Rust!", name) + format!("Hello, {name}! You've been greeted from Rust!") } #[cfg_attr(mobile, tauri::mobile_entry_point)] pub fn run() { - tauri::Builder::default() + #[allow(unused_mut)] + let mut builder = tauri::Builder::default(); + + #[cfg(desktop)] + { + builder = builder.plugin(tauri_plugin_single_instance::init(|_app, argv, _cwd| { + println!("single instance triggered: {argv:?}"); + })); + } + + builder .plugin(tauri_plugin_deep_link::init()) + .plugin( + tauri_plugin_log::Builder::default() + .level(log::LevelFilter::Info) + .build(), + ) .setup(|app| { - app.listen_global("deep-link://new-url", |url| { - dbg!(url); + // ensure deep links are registered on the system + // this is useful because AppImages requires additional setup to be available in the system + // and calling register() makes the deep links immediately available - without any user input + // additionally, we manually register on Windows on debug builds for development + #[cfg(any(target_os = "linux", all(debug_assertions, windows)))] + app.deep_link().register_all()?; + + app.deep_link().on_open_url(|event| { + dbg!(event.urls()); }); + Ok(()) }) .invoke_handler(tauri::generate_handler![greet]) diff --git a/plugins/deep-link/examples/app/src-tauri/tauri.conf.json b/plugins/deep-link/examples/app/src-tauri/tauri.conf.json index ef467e44..ac1c292b 100644 --- a/plugins/deep-link/examples/app/src-tauri/tauri.conf.json +++ b/plugins/deep-link/examples/app/src-tauri/tauri.conf.json @@ -1,49 +1,14 @@ { + "productName": "deep-link-example", + "version": "0.1.0", + "identifier": "com.tauri.deep-link-example", "build": { + "devUrl": "http://localhost:1420", + "frontendDist": "../dist", "beforeDevCommand": "pnpm dev", - "beforeBuildCommand": "pnpm build", - "devPath": "http://localhost:1420", - "distDir": "../dist", - "withGlobalTauri": false + "beforeBuildCommand": "pnpm build" }, - "package": { - "productName": "deep-link-example", - "version": "0.0.0" - }, - "tauri": { - "bundle": { - "active": true, - "category": "DeveloperTool", - "copyright": "", - "deb": { - "depends": [] - }, - "externalBin": [], - "icon": [ - "icons/32x32.png", - "icons/128x128.png", - "icons/128x128@2x.png", - "icons/icon.icns", - "icons/icon.ico" - ], - "identifier": "com.tauri.deep-link-example", - "longDescription": "", - "macOS": { - "entitlements": null, - "exceptionDomain": "", - "frameworks": [], - "providerShortName": null, - "signingIdentity": null - }, - "resources": [], - "shortDescription": "", - "targets": "all", - "windows": { - "certificateThumbprint": null, - "digestAlgorithm": "sha256", - "timestampUrl": "" - } - }, + "app": { "security": { "csp": null }, @@ -63,10 +28,29 @@ "hello": "world" }, "deep-link": { - "domains": [ - { "host": "fabianlars.de", "pathPrefix": ["/intent"] }, - { "host": "tauri.app" } - ] + "mobile": [ + { + "host": "fabianlars.de", + "pathPrefix": ["/intent"] + }, + { + "host": "tauri.app" + } + ], + "desktop": { + "schemes": ["fabianlars", "my-tauri-app"] + } } + }, + "bundle": { + "active": true, + "category": "DeveloperTool", + "icon": [ + "icons/32x32.png", + "icons/128x128.png", + "icons/128x128@2x.png", + "icons/icon.icns", + "icons/icon.ico" + ] } } diff --git a/plugins/deep-link/examples/app/src/main.ts b/plugins/deep-link/examples/app/src/main.ts index f87a6afd..550e0aaa 100644 --- a/plugins/deep-link/examples/app/src/main.ts +++ b/plugins/deep-link/examples/app/src/main.ts @@ -4,35 +4,35 @@ import { onOpenUrl, - getCurrent as getCurrentDeepLinkUrls, -} from "@tauri-apps/plugin-deep-link"; + getCurrent as getCurrentDeepLinkUrls +} from '@tauri-apps/plugin-deep-link' function handler(urls: string[]) { - console.log(urls); + console.log(urls) // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const updateIntentEl = document.querySelector("#event-intent")!; - updateIntentEl.textContent = JSON.stringify(urls); + const updateIntentEl = document.querySelector('#event-intent')! + updateIntentEl.textContent = JSON.stringify(urls) } -window.addEventListener("DOMContentLoaded", () => { - onOpenUrl(handler); +window.addEventListener('DOMContentLoaded', () => { + onOpenUrl(handler) - document.querySelector("#intent-form")?.addEventListener("submit", (e) => { - e.preventDefault(); + document.querySelector('#intent-form')?.addEventListener('submit', (e) => { + e.preventDefault() getCurrentDeepLinkUrls() .then((res) => { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const updateIntentEl = document.querySelector("#update-intent")!; - updateIntentEl.textContent = res ? JSON.stringify(res) : "none"; + const updateIntentEl = document.querySelector('#update-intent')! + updateIntentEl.textContent = res ? JSON.stringify(res) : 'none' }) - .catch(console.error); - }); + .catch(console.error) + }) getCurrentDeepLinkUrls() .then((res) => { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const initialIntentEl = document.querySelector("#initial-intent")!; - initialIntentEl.textContent = res ? JSON.stringify(res) : "none"; + const initialIntentEl = document.querySelector('#initial-intent')! + initialIntentEl.textContent = res ? JSON.stringify(res) : 'none' }) - .catch(console.error); -}); + .catch(console.error) +}) diff --git a/plugins/deep-link/examples/app/tsconfig.json b/plugins/deep-link/examples/app/tsconfig.json index 43d4bc70..c0f337a2 100644 --- a/plugins/deep-link/examples/app/tsconfig.json +++ b/plugins/deep-link/examples/app/tsconfig.json @@ -3,7 +3,7 @@ "target": "ESNext", "module": "ESNext", "lib": ["ESNext", "DOM"], - "moduleResolution": "Node", + "moduleResolution": "bundler", "strict": true, "sourceMap": true, "resolveJsonModule": true, diff --git a/plugins/deep-link/examples/app/vite.config.ts b/plugins/deep-link/examples/app/vite.config.ts index 4bf452bc..b54dc99a 100644 --- a/plugins/deep-link/examples/app/vite.config.ts +++ b/plugins/deep-link/examples/app/vite.config.ts @@ -2,40 +2,37 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { defineConfig } from "vite"; -import { internalIpV4 } from "internal-ip"; +import { defineConfig } from 'vite' -const mobile = - process.env.TAURI_PLATFORM === "android" || - process.env.TAURI_PLATFORM === "ios"; +const host = process.env.TAURI_DEV_HOST // https://vitejs.dev/config/ -export default defineConfig(async () => ({ +export default defineConfig({ // Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build` // prevent vite from obscuring rust errors clearScreen: false, // tauri expects a fixed port, fail if that port is not available server: { - host: mobile ? "0.0.0.0" : false, + host: host || false, port: 1420, - hmr: mobile + hmr: host ? { - protocol: "ws", - host: await internalIpV4(), - port: 1421, + protocol: 'ws', + host, + port: 1421 } : undefined, - strictPort: true, + strictPort: true }, // to make use of `TAURI_DEBUG` and other env variables // https://tauri.studio/v1/api/config#buildconfig.beforedevcommand - envPrefix: ["VITE_", "TAURI_"], + envPrefix: ['VITE_', 'TAURI_'], build: { // Tauri supports es2021 - target: process.env.TAURI_PLATFORM == "windows" ? "chrome105" : "safari13", + target: process.env.TAURI_PLATFORM == 'windows' ? 'chrome105' : 'safari13', // don't minify for debug builds - minify: !process.env.TAURI_DEBUG ? "esbuild" : false, + minify: !process.env.TAURI_DEBUG ? 'esbuild' : false, // produce sourcemaps for debug builds - sourcemap: !!process.env.TAURI_DEBUG, - }, -})); + sourcemap: !!process.env.TAURI_DEBUG + } +}) diff --git a/plugins/deep-link/guest-js/index.ts b/plugins/deep-link/guest-js/index.ts index f245f415..461bec8a 100644 --- a/plugins/deep-link/guest-js/index.ts +++ b/plugins/deep-link/guest-js/index.ts @@ -2,24 +2,104 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { invoke } from "@tauri-apps/api/primitives"; -import { UnlistenFn, listen } from "@tauri-apps/api/event"; +import { invoke } from '@tauri-apps/api/core' +import { type UnlistenFn, listen } from '@tauri-apps/api/event' +/** + * Get the current URLs that triggered the deep link. Use this on app load to check whether your app was started via a deep link. + * + * @example + * ```typescript + * import { getCurrent } from '@tauri-apps/plugin-deep-link'; + * const urls = await getCurrent(); + * ``` + * + * #### - **Windows / Linux**: This function reads the command line arguments and checks if there's only one value, which must be an URL with scheme matching one of the configured values. + * Note that you must manually check the arguments when registering deep link schemes dynamically with [`Self::register`]. + * Additionally, the deep link might have been provided as a CLI argument so you should check if its format matches what you expect.. + * + * @since 2.0.0 + */ export async function getCurrent(): Promise { - return await invoke("plugin:deep-link|get_current"); + return await invoke('plugin:deep-link|get_current') +} + +/** + * Register the app as the default handler for the specified protocol. + * + * @param protocol The name of the protocol without `://`. For example, if you want your app to handle `tauri://` links, call this method with `tauri` as the protocol. + * + * @example + * ```typescript + * import { register } from '@tauri-apps/plugin-deep-link'; + * await register("my-scheme"); + * ``` + * + * #### - **macOS / Android / iOS**: Unsupported. + * + * @since 2.0.0 + */ +export async function register(protocol: string): Promise { + return await invoke('plugin:deep-link|register', { protocol }) +} - // return await invoke("plugin:deep-link|get_current"); +/** + * Unregister the app as the default handler for the specified protocol. + * + * @param protocol The name of the protocol without `://`. + * + * @example + * ```typescript + * import { unregister } from '@tauri-apps/plugin-deep-link'; + * await unregister("my-scheme"); + * ``` + * + * #### - **macOS / Linux / Android / iOS**: Unsupported. + * + * @since 2.0.0 + */ +export async function unregister(protocol: string): Promise { + return await invoke('plugin:deep-link|unregister', { protocol }) } +/** + * Check whether the app is the default handler for the specified protocol. + * + * @param protocol The name of the protocol without `://`. + * + * @example + * ```typescript + * import { isRegistered } from '@tauri-apps/plugin-deep-link'; + * await isRegistered("my-scheme"); + * ``` + * + * #### - **macOS / Android / iOS**: Unsupported. + * + * @since 2.0.0 + */ +export async function isRegistered(protocol: string): Promise { + return await invoke('plugin:deep-link|is_registered', { protocol }) +} + +/** + * Helper function for the `deep-link://new-url` event to run a function each time the protocol is triggered while the app is running. Use `getCurrent` on app load to check whether your app was started via a deep link. + * + * @param protocol The name of the protocol without `://`. + * + * @example + * ```typescript + * import { onOpenUrl } from '@tauri-apps/plugin-deep-link'; + * await onOpenUrl((urls) => { console.log(urls) }); + * ``` + * + * #### - **Windows / Linux**: Unsupported without the single-instance plugin. The OS will spawn a new app instance passing the URL as a CLI argument. + * + * @since 2.0.0 + */ export async function onOpenUrl( - handler: (urls: string[]) => void, + handler: (urls: string[]) => void ): Promise { - const current = await getCurrent(); - if (current != null) { - handler(current); - } - - return await listen("deep-link://new-url", (event) => - handler(event.payload), - ); + return await listen('deep-link://new-url', (event) => { + handler(event.payload) + }) } diff --git a/plugins/deep-link/package.json b/plugins/deep-link/package.json index 19b79539..6e9e82d2 100644 --- a/plugins/deep-link/package.json +++ b/plugins/deep-link/package.json @@ -1,33 +1,30 @@ { "name": "@tauri-apps/plugin-deep-link", - "version": "2.0.0-alpha.0", + "version": "2.3.0", "description": "Set your Tauri application as the default handler for an URL", - "license": "MIT or APACHE-2.0", + "license": "MIT OR Apache-2.0", "authors": [ "Tauri Programme within The Commons Conservancy" ], + "repository": "https://github.com/tauri-apps/plugins-workspace", "type": "module", - "browser": "dist-js/index.min.js", - "module": "dist-js/index.mjs", - "types": "dist-js/index.d.ts", + "types": "./dist-js/index.d.ts", + "main": "./dist-js/index.cjs", + "module": "./dist-js/index.js", "exports": { - "import": "./dist-js/index.mjs", "types": "./dist-js/index.d.ts", - "browser": "./dist-js/index.min.js" + "import": "./dist-js/index.js", + "require": "./dist-js/index.cjs" }, "scripts": { "build": "rollup -c" }, "files": [ "dist-js", - "!dist-js/**/*.map", "README.md", "LICENSE" ], - "devDependencies": { - "tslib": "^2.5.0" - }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.9" + "@tauri-apps/api": "^2.0.0" } } diff --git a/plugins/deep-link/permissions/autogenerated/commands/get_current.toml b/plugins/deep-link/permissions/autogenerated/commands/get_current.toml new file mode 100644 index 00000000..e729de11 --- /dev/null +++ b/plugins/deep-link/permissions/autogenerated/commands/get_current.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-get-current" +description = "Enables the get_current command without any pre-configured scope." +commands.allow = ["get_current"] + +[[permission]] +identifier = "deny-get-current" +description = "Denies the get_current command without any pre-configured scope." +commands.deny = ["get_current"] diff --git a/plugins/deep-link/permissions/autogenerated/commands/is_registered.toml b/plugins/deep-link/permissions/autogenerated/commands/is_registered.toml new file mode 100644 index 00000000..2dd73ace --- /dev/null +++ b/plugins/deep-link/permissions/autogenerated/commands/is_registered.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-is-registered" +description = "Enables the is_registered command without any pre-configured scope." +commands.allow = ["is_registered"] + +[[permission]] +identifier = "deny-is-registered" +description = "Denies the is_registered command without any pre-configured scope." +commands.deny = ["is_registered"] diff --git a/plugins/deep-link/permissions/autogenerated/commands/register.toml b/plugins/deep-link/permissions/autogenerated/commands/register.toml new file mode 100644 index 00000000..4eec17dc --- /dev/null +++ b/plugins/deep-link/permissions/autogenerated/commands/register.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-register" +description = "Enables the register command without any pre-configured scope." +commands.allow = ["register"] + +[[permission]] +identifier = "deny-register" +description = "Denies the register command without any pre-configured scope." +commands.deny = ["register"] diff --git a/plugins/deep-link/permissions/autogenerated/commands/unregister.toml b/plugins/deep-link/permissions/autogenerated/commands/unregister.toml new file mode 100644 index 00000000..5d33c97c --- /dev/null +++ b/plugins/deep-link/permissions/autogenerated/commands/unregister.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-unregister" +description = "Enables the unregister command without any pre-configured scope." +commands.allow = ["unregister"] + +[[permission]] +identifier = "deny-unregister" +description = "Denies the unregister command without any pre-configured scope." +commands.deny = ["unregister"] diff --git a/plugins/deep-link/permissions/autogenerated/reference.md b/plugins/deep-link/permissions/autogenerated/reference.md new file mode 100644 index 00000000..a8ef1874 --- /dev/null +++ b/plugins/deep-link/permissions/autogenerated/reference.md @@ -0,0 +1,121 @@ +## Default Permission + +Allows reading the opened deep link via the get_current command + +#### This default permission set includes the following: + +- `allow-get-current` + +## Permission Table + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IdentifierDescription
+ +`deep-link:allow-get-current` + + + +Enables the get_current command without any pre-configured scope. + +
+ +`deep-link:deny-get-current` + + + +Denies the get_current command without any pre-configured scope. + +
+ +`deep-link:allow-is-registered` + + + +Enables the is_registered command without any pre-configured scope. + +
+ +`deep-link:deny-is-registered` + + + +Denies the is_registered command without any pre-configured scope. + +
+ +`deep-link:allow-register` + + + +Enables the register command without any pre-configured scope. + +
+ +`deep-link:deny-register` + + + +Denies the register command without any pre-configured scope. + +
+ +`deep-link:allow-unregister` + + + +Enables the unregister command without any pre-configured scope. + +
+ +`deep-link:deny-unregister` + + + +Denies the unregister command without any pre-configured scope. + +
diff --git a/plugins/deep-link/permissions/default.toml b/plugins/deep-link/permissions/default.toml new file mode 100644 index 00000000..0c3cf2c0 --- /dev/null +++ b/plugins/deep-link/permissions/default.toml @@ -0,0 +1,4 @@ +"$schema" = "schemas/schema.json" +[default] +description = "Allows reading the opened deep link via the get_current command" +permissions = ["allow-get-current"] diff --git a/plugins/deep-link/permissions/schemas/schema.json b/plugins/deep-link/permissions/schemas/schema.json new file mode 100644 index 00000000..c9fc2ceb --- /dev/null +++ b/plugins/deep-link/permissions/schemas/schema.json @@ -0,0 +1,354 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "PermissionFile", + "description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.", + "type": "object", + "properties": { + "default": { + "description": "The default permission set for the plugin", + "anyOf": [ + { + "$ref": "#/definitions/DefaultPermission" + }, + { + "type": "null" + } + ] + }, + "set": { + "description": "A list of permissions sets defined", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionSet" + } + }, + "permission": { + "description": "A list of inlined permissions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Permission" + } + } + }, + "definitions": { + "DefaultPermission": { + "description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.", + "type": "object", + "required": [ + "permissions" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "PermissionSet": { + "description": "A set of direct permissions grouped together under a new name.", + "type": "object", + "required": [ + "description", + "identifier", + "permissions" + ], + "properties": { + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does.", + "type": "string" + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionKind" + } + } + } + }, + "Permission": { + "description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.", + "type": "object", + "required": [ + "identifier" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri internal convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "commands": { + "description": "Allowed or denied commands when using this permission.", + "default": { + "allow": [], + "deny": [] + }, + "allOf": [ + { + "$ref": "#/definitions/Commands" + } + ] + }, + "scope": { + "description": "Allowed or denied scoped when using this permission.", + "allOf": [ + { + "$ref": "#/definitions/Scopes" + } + ] + }, + "platforms": { + "description": "Target platforms this permission applies. By default all platforms are affected by this permission.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Target" + } + } + } + }, + "Commands": { + "description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.", + "type": "object", + "properties": { + "allow": { + "description": "Allowed command.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "deny": { + "description": "Denied command, which takes priority.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "Scopes": { + "description": "An argument for fine grained behavior control of Tauri commands.\n\nIt can be of any serde serializable type and is used to allow or prevent certain actions inside a Tauri command. The configured scope is passed to the command and will be enforced by the command implementation.\n\n## Example\n\n```json { \"allow\": [{ \"path\": \"$HOME/**\" }], \"deny\": [{ \"path\": \"$HOME/secret.txt\" }] } ```", + "type": "object", + "properties": { + "allow": { + "description": "Data that defines what is allowed by the scope.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + }, + "deny": { + "description": "Data that defines what is denied by the scope. This should be prioritized by validation logic.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + } + } + }, + "Value": { + "description": "All supported ACL values.", + "anyOf": [ + { + "description": "Represents a null JSON value.", + "type": "null" + }, + { + "description": "Represents a [`bool`].", + "type": "boolean" + }, + { + "description": "Represents a valid ACL [`Number`].", + "allOf": [ + { + "$ref": "#/definitions/Number" + } + ] + }, + { + "description": "Represents a [`String`].", + "type": "string" + }, + { + "description": "Represents a list of other [`Value`]s.", + "type": "array", + "items": { + "$ref": "#/definitions/Value" + } + }, + { + "description": "Represents a map of [`String`] keys to [`Value`]s.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/Value" + } + } + ] + }, + "Number": { + "description": "A valid ACL number.", + "anyOf": [ + { + "description": "Represents an [`i64`].", + "type": "integer", + "format": "int64" + }, + { + "description": "Represents a [`f64`].", + "type": "number", + "format": "double" + } + ] + }, + "Target": { + "description": "Platform target.", + "oneOf": [ + { + "description": "MacOS.", + "type": "string", + "enum": [ + "macOS" + ] + }, + { + "description": "Windows.", + "type": "string", + "enum": [ + "windows" + ] + }, + { + "description": "Linux.", + "type": "string", + "enum": [ + "linux" + ] + }, + { + "description": "Android.", + "type": "string", + "enum": [ + "android" + ] + }, + { + "description": "iOS.", + "type": "string", + "enum": [ + "iOS" + ] + } + ] + }, + "PermissionKind": { + "type": "string", + "oneOf": [ + { + "description": "Enables the get_current command without any pre-configured scope.", + "type": "string", + "const": "allow-get-current", + "markdownDescription": "Enables the get_current command without any pre-configured scope." + }, + { + "description": "Denies the get_current command without any pre-configured scope.", + "type": "string", + "const": "deny-get-current", + "markdownDescription": "Denies the get_current command without any pre-configured scope." + }, + { + "description": "Enables the is_registered command without any pre-configured scope.", + "type": "string", + "const": "allow-is-registered", + "markdownDescription": "Enables the is_registered command without any pre-configured scope." + }, + { + "description": "Denies the is_registered command without any pre-configured scope.", + "type": "string", + "const": "deny-is-registered", + "markdownDescription": "Denies the is_registered command without any pre-configured scope." + }, + { + "description": "Enables the register command without any pre-configured scope.", + "type": "string", + "const": "allow-register", + "markdownDescription": "Enables the register command without any pre-configured scope." + }, + { + "description": "Denies the register command without any pre-configured scope.", + "type": "string", + "const": "deny-register", + "markdownDescription": "Denies the register command without any pre-configured scope." + }, + { + "description": "Enables the unregister command without any pre-configured scope.", + "type": "string", + "const": "allow-unregister", + "markdownDescription": "Enables the unregister command without any pre-configured scope." + }, + { + "description": "Denies the unregister command without any pre-configured scope.", + "type": "string", + "const": "deny-unregister", + "markdownDescription": "Denies the unregister command without any pre-configured scope." + }, + { + "description": "Allows reading the opened deep link via the get_current command\n#### This default permission set includes:\n\n- `allow-get-current`", + "type": "string", + "const": "default", + "markdownDescription": "Allows reading the opened deep link via the get_current command\n#### This default permission set includes:\n\n- `allow-get-current`" + } + ] + } + } +} \ No newline at end of file diff --git a/plugins/deep-link/rollup.config.js b/plugins/deep-link/rollup.config.js new file mode 100644 index 00000000..1f349ec8 --- /dev/null +++ b/plugins/deep-link/rollup.config.js @@ -0,0 +1,7 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import { createConfig } from '../../shared/rollup.config.js' + +export default createConfig() diff --git a/plugins/deep-link/rollup.config.mjs b/plugins/deep-link/rollup.config.mjs deleted file mode 100644 index 99a3dd31..00000000 --- a/plugins/deep-link/rollup.config.mjs +++ /dev/null @@ -1,11 +0,0 @@ -import { readFileSync } from "fs"; - -import { createConfig } from "../../shared/rollup.config.mjs"; - -export default createConfig({ - input: "guest-js/index.ts", - pkg: JSON.parse( - readFileSync(new URL("./package.json", import.meta.url), "utf8"), - ), - external: [/^@tauri-apps\/api/], -}); diff --git a/plugins/deep-link/src/api-iife.js b/plugins/deep-link/src/api-iife.js deleted file mode 100644 index ba2d5b23..00000000 --- a/plugins/deep-link/src/api-iife.js +++ /dev/null @@ -1 +0,0 @@ -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__})} diff --git a/plugins/deep-link/src/commands.rs b/plugins/deep-link/src/commands.rs index 4b228e4c..078adfb1 100644 --- a/plugins/deep-link/src/commands.rs +++ b/plugins/deep-link/src/commands.rs @@ -14,3 +14,33 @@ pub(crate) async fn get_current( ) -> Result>> { deep_link.get_current() } + +#[command] +pub(crate) async fn register( + _app: AppHandle, + _window: Window, + deep_link: State<'_, DeepLink>, + protocol: String, +) -> Result<()> { + deep_link.register(protocol) +} + +#[command] +pub(crate) async fn unregister( + _app: AppHandle, + _window: Window, + deep_link: State<'_, DeepLink>, + protocol: String, +) -> Result<()> { + deep_link.unregister(protocol) +} + +#[command] +pub(crate) async fn is_registered( + _app: AppHandle, + _window: Window, + deep_link: State<'_, DeepLink>, + protocol: String, +) -> Result { + deep_link.is_registered(protocol) +} diff --git a/plugins/deep-link/src/config.rs b/plugins/deep-link/src/config.rs index 80f0a4c0..88222a24 100644 --- a/plugins/deep-link/src/config.rs +++ b/plugins/deep-link/src/config.rs @@ -4,16 +4,30 @@ // This module is also imported in build.rs! -#![allow(dead_code)] - use serde::{Deserialize, Deserializer}; +use tauri_utils::config::DeepLinkProtocol; -#[derive(Deserialize)] +#[derive(Deserialize, Clone)] pub struct AssociatedDomain { + #[serde(default = "default_schemes")] + pub scheme: Vec, + #[serde(deserialize_with = "deserialize_associated_host")] pub host: String, + + #[serde(default)] + pub path: Vec, + #[serde(default, alias = "path-pattern", rename = "pathPattern")] + pub path_pattern: Vec, #[serde(default, alias = "path-prefix", rename = "pathPrefix")] pub path_prefix: Vec, + #[serde(default, alias = "path-suffix", rename = "pathSuffix")] + pub path_suffix: Vec, +} + +// TODO: Consider removing this in v3 +fn default_schemes() -> Vec { + vec!["https".to_string(), "http".to_string()] } fn deserialize_associated_host<'de, D>(deserializer: D) -> Result @@ -30,7 +44,51 @@ where } } -#[derive(Deserialize)] +#[derive(Deserialize, Clone)] pub struct Config { - pub domains: Vec, + /// Mobile requires `https://` urls. + #[serde(default)] + pub mobile: Vec, + /// Desktop requires urls starting with `://`. + /// These urls are also active in dev mode on Android. + #[allow(unused)] // Used in tauri-bundler + #[serde(default)] + pub desktop: DesktopProtocol, +} + +#[derive(Deserialize, Clone)] +#[serde(untagged)] +#[allow(unused)] // Used in tauri-bundler +pub enum DesktopProtocol { + One(DeepLinkProtocol), + List(Vec), +} + +impl Default for DesktopProtocol { + fn default() -> Self { + Self::List(Vec::new()) + } +} + +impl DesktopProtocol { + #[allow(dead_code)] + pub fn contains_scheme(&self, scheme: &String) -> bool { + match self { + Self::One(protocol) => protocol.schemes.contains(scheme), + Self::List(protocols) => protocols + .iter() + .any(|protocol| protocol.schemes.contains(scheme)), + } + } + + #[allow(dead_code)] + pub fn schemes(&self) -> Vec { + match self { + Self::One(protocol) => protocol.schemes.clone(), + Self::List(protocols) => protocols + .iter() + .flat_map(|protocol| protocol.schemes.clone()) + .collect(), + } + } } diff --git a/plugins/deep-link/src/error.rs b/plugins/deep-link/src/error.rs index 339e763b..88c71e8a 100644 --- a/plugins/deep-link/src/error.rs +++ b/plugins/deep-link/src/error.rs @@ -8,8 +8,21 @@ pub type Result = std::result::Result; #[derive(Debug, thiserror::Error)] pub enum Error { + #[error("unsupported platform")] + UnsupportedPlatform, #[error(transparent)] Io(#[from] std::io::Error), + #[error(transparent)] + Tauri(#[from] tauri::Error), + #[cfg(target_os = "windows")] + #[error(transparent)] + Windows(#[from] windows_result::Error), + #[cfg(target_os = "linux")] + #[error(transparent)] + Ini(#[from] ini::Error), + #[cfg(target_os = "linux")] + #[error(transparent)] + ParseIni(#[from] ini::ParseError), #[cfg(mobile)] #[error(transparent)] PluginInvoke(#[from] tauri::plugin::mobile::PluginInvokeError), diff --git a/plugins/deep-link/src/lib.rs b/plugins/deep-link/src/lib.rs index 597a7e26..d74864db 100644 --- a/plugins/deep-link/src/lib.rs +++ b/plugins/deep-link/src/lib.rs @@ -2,10 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use serde::de::DeserializeOwned; use tauri::{ plugin::{Builder, PluginApi, TauriPlugin}, - AppHandle, Manager, Runtime, + AppHandle, EventId, Listener, Manager, Runtime, }; mod commands; @@ -17,58 +16,79 @@ pub use error::{Error, Result}; #[cfg(target_os = "android")] const PLUGIN_IDENTIFIER: &str = "app.tauri.deep_link"; -fn init_deep_link( +fn init_deep_link( app: &AppHandle, - _api: PluginApi, + api: PluginApi>, ) -> crate::Result> { #[cfg(target_os = "android")] { - use tauri::ipc::{Channel, InvokeBody}; + let _api = api; + + use tauri::{ + ipc::{Channel, InvokeResponseBody}, + Emitter, + }; let handle = _api.register_android_plugin(PLUGIN_IDENTIFIER, "DeepLinkPlugin")?; + #[derive(serde::Deserialize)] + struct Event { + url: String, + } + let app_handle = app.clone(); handle.run_mobile_plugin::<()>( "setEventHandler", imp::EventHandler { handler: Channel::new(move |event| { - println!("got channel event: {:?}", &event); - let url = match event { - InvokeBody::Json(payload) => payload - .get("url") - .and_then(|v| v.as_str()) - .map(|s| s.to_owned()), + InvokeResponseBody::Json(payload) => { + serde_json::from_str::(&payload) + .ok() + .map(|payload| payload.url) + } _ => None, }; - let payload = vec![url]; - app_handle.trigger_global( - "deep-link://new-url", - Some(serde_json::to_string(&payload).unwrap()), - ); - let _ = app_handle.emit_all("deep-link://new-url", payload); + let _ = app_handle.emit("deep-link://new-url", vec![url]); + Ok(()) }), }, )?; - return Ok(DeepLink(handle)); + return Ok(DeepLink { + app: app.clone(), + plugin_handle: handle, + }); } - #[cfg(not(target_os = "android"))] - Ok(DeepLink { + #[cfg(target_os = "ios")] + return Ok(DeepLink { app: app.clone(), current: Default::default(), - }) + config: api.config().clone(), + }); + + #[cfg(desktop)] + { + let args = std::env::args(); + let deep_link = DeepLink { + app: app.clone(), + current: Default::default(), + config: api.config().clone(), + }; + deep_link.handle_cli_arguments(args); + + Ok(deep_link) + } } #[cfg(target_os = "android")] mod imp { - use tauri::{plugin::PluginHandle, Runtime}; + use tauri::{ipc::Channel, plugin::PluginHandle, AppHandle, Runtime}; use serde::{Deserialize, Serialize}; - use tauri::ipc::Channel; #[derive(Serialize)] #[serde(rename_all = "camelCase")] @@ -83,42 +103,355 @@ mod imp { } /// Access to the deep-link APIs. - pub struct DeepLink(pub(crate) PluginHandle); + pub struct DeepLink { + pub(crate) app: AppHandle, + pub(crate) plugin_handle: PluginHandle, + } impl DeepLink { - /// Get the current URLs that triggered the deep link. + /// Get the current URLs that triggered the deep link. Use this on app load to check whether your app was started via a deep link. + /// + /// ## Platform-specific: + /// + /// - **Windows / Linux**: This function reads the command line arguments and checks if there's only one value, which must be an URL with scheme matching one of the configured values. + /// Note that you must manually check the arguments when registering deep link schemes dynamically with [`Self::register`]. + /// Additionally, the deep link might have been provided as a CLI argument so you should check if its format matches what you expect. pub fn get_current(&self) -> crate::Result>> { - self.0 + self.plugin_handle .run_mobile_plugin::("getCurrent", ()) .map(|v| v.url.map(|url| vec![url])) .map_err(Into::into) } + + /// Register the app as the default handler for the specified protocol. + /// + /// - `protocol`: The name of the protocol without `://`. For example, if you want your app to handle `tauri://` links, call this method with `tauri` as the protocol. + /// + /// ## Platform-specific: + /// + /// - **macOS / Android / iOS**: Unsupported, will return [`Error::UnsupportedPlatform`](`crate::Error::UnsupportedPlatform`). + pub fn register>(&self, _protocol: S) -> crate::Result<()> { + Err(crate::Error::UnsupportedPlatform) + } + + /// Unregister the app as the default handler for the specified protocol. + /// + /// - `protocol`: The name of the protocol without `://`. + /// + /// ## Platform-specific: + /// + /// - **Linux**: Can only unregister the scheme if it was initially registered with [`register`](`Self::register`). May not work on older distros. + /// - **macOS / Android / iOS**: Unsupported, will return [`Error::UnsupportedPlatform`](`crate::Error::UnsupportedPlatform`). + pub fn unregister>(&self, _protocol: S) -> crate::Result<()> { + Err(crate::Error::UnsupportedPlatform) + } + + /// Check whether the app is the default handler for the specified protocol. + /// + /// - `protocol`: The name of the protocol without `://`. + /// + /// ## Platform-specific: + /// + /// - **macOS / Android / iOS**: Unsupported, will return [`Error::UnsupportedPlatform`](`crate::Error::UnsupportedPlatform`). + pub fn is_registered>(&self, _protocol: S) -> crate::Result { + Err(crate::Error::UnsupportedPlatform) + } } } #[cfg(not(target_os = "android"))] mod imp { use std::sync::Mutex; + #[cfg(target_os = "linux")] + use std::{ + fs::{create_dir_all, File}, + io::Write, + process::Command, + }; + #[cfg(target_os = "linux")] + use tauri::Manager; use tauri::{AppHandle, Runtime}; + #[cfg(windows)] + use windows_registry::{CLASSES_ROOT, CURRENT_USER, LOCAL_MACHINE}; /// Access to the deep-link APIs. pub struct DeepLink { - #[allow(dead_code)] pub(crate) app: AppHandle, pub(crate) current: Mutex>>, + pub(crate) config: Option, } impl DeepLink { - /// Get the current URLs that triggered the deep link. + /// Checks if the provided list of arguments (which should match [`std::env::args`]) + /// contains a deep link argument (for Linux and Windows). + /// + /// On Linux and Windows the deep links trigger a new app instance with the deep link URL as its only argument. + /// + /// This function does what it can to verify if the argument is actually a deep link, though it could also be a regular CLI argument. + /// To enhance its checks, we only match deep links against the schemes defined in the Tauri configuration + /// i.e. dynamic schemes WON'T be processed. + /// + /// This function updates the [`Self::get_current`] value and emits a `deep-link://new-url` event. + #[cfg(desktop)] + pub fn handle_cli_arguments, I: Iterator>(&self, mut args: I) { + use tauri::Emitter; + + let Some(config) = &self.config else { + return; + }; + + if cfg!(windows) || cfg!(target_os = "linux") { + args.next(); // bin name + let arg = args.next(); + + let maybe_deep_link = args.next().is_none(); // single argument + if !maybe_deep_link { + return; + } + + if let Some(url) = arg.and_then(|arg| arg.as_ref().parse::().ok()) { + if config.desktop.contains_scheme(&url.scheme().to_string()) { + let mut current = self.current.lock().unwrap(); + current.replace(vec![url.clone()]); + let _ = self.app.emit("deep-link://new-url", vec![url]); + } else if cfg!(debug_assertions) { + tracing::warn!("argument {url} does not match any configured deep link scheme; skipping it"); + } + } + } + } + + /// Get the current URLs that triggered the deep link. Use this on app load to check whether your app was started via a deep link. + /// + /// ## Platform-specific: + /// + /// - **Windows / Linux**: This function reads the command line arguments and checks if there's only one value, which must be an URL with scheme matching one of the configured values. + /// Note that you must manually check the arguments when registering deep link schemes dynamically with [`Self::register`]. + /// Additionally, the deep link might have been provided as a CLI argument so you should check if its format matches what you expect. pub fn get_current(&self) -> crate::Result>> { - Ok(self.current.lock().unwrap().clone()) + return Ok(self.current.lock().unwrap().clone()); + } + + /// Registers all schemes defined in the configuration file. + /// + /// This is useful to ensure the schemes are registered even if the user did not install the app properly + /// (e.g. an AppImage that was not properly registered with an AppImage launcher). + pub fn register_all(&self) -> crate::Result<()> { + let Some(config) = &self.config else { + return Ok(()); + }; + + for scheme in config.desktop.schemes() { + self.register(scheme)?; + } + + Ok(()) + } + + /// Register the app as the default handler for the specified protocol. + /// + /// - `protocol`: The name of the protocol without `://`. For example, if you want your app to handle `tauri://` links, call this method with `tauri` as the protocol. + /// + /// ## Platform-specific: + /// + /// - **macOS / Android / iOS**: Unsupported, will return [`Error::UnsupportedPlatform`](`crate::Error::UnsupportedPlatform`). + pub fn register>(&self, _protocol: S) -> crate::Result<()> { + #[cfg(windows)] + { + let protocol = _protocol.as_ref(); + let key_base = format!("Software\\Classes\\{protocol}"); + + let exe = dunce::simplified(&tauri::utils::platform::current_exe()?) + .display() + .to_string(); + + let key_reg = CURRENT_USER.create(&key_base)?; + key_reg.set_string("", format!("URL:{} protocol", self.app.config().identifier))?; + key_reg.set_string("URL Protocol", "")?; + + let icon_reg = CURRENT_USER.create(format!("{key_base}\\DefaultIcon"))?; + icon_reg.set_string("", format!("{exe},0"))?; + + let cmd_reg = CURRENT_USER.create(format!("{key_base}\\shell\\open\\command"))?; + + cmd_reg.set_string("", format!("\"{exe}\" \"%1\""))?; + + Ok(()) + } + + #[cfg(target_os = "linux")] + { + let bin = tauri::utils::platform::current_exe()?; + let file_name = format!( + "{}-handler.desktop", + bin.file_name().unwrap().to_string_lossy() + ); + let appimage = self.app.env().appimage; + let exec = appimage + .clone() + .unwrap_or_else(|| bin.into_os_string()) + .to_string_lossy() + .to_string(); + + let target = self.app.path().data_dir()?.join("applications"); + + create_dir_all(&target)?; + + let target_file = target.join(&file_name); + + let mime_type = format!("x-scheme-handler/{}", _protocol.as_ref()); + + if let Ok(mut desktop_file) = ini::Ini::load_from_file(&target_file) { + if let Some(section) = desktop_file.section_mut(Some("Desktop Entry")) { + let old_mimes = section.remove("MimeType"); + section.append( + "MimeType", + format!("{mime_type};{}", old_mimes.unwrap_or_default()), + ); + desktop_file.write_to_file(&target_file)?; + } + } else { + let mut file = File::create(target_file)?; + file.write_all( + format!( + include_str!("template.desktop"), + name = self + .app + .config() + .product_name + .clone() + .unwrap_or_else(|| file_name.clone()), + exec = exec, + mime_type = mime_type + ) + .as_bytes(), + )?; + } + + Command::new("update-desktop-database") + .arg(target) + .status()?; + + Command::new("xdg-mime") + .args(["default", &file_name, _protocol.as_ref()]) + .status()?; + + Ok(()) + } + + #[cfg(not(any(windows, target_os = "linux")))] + Err(crate::Error::UnsupportedPlatform) + } + + /// Unregister the app as the default handler for the specified protocol. + /// + /// - `protocol`: The name of the protocol without `://`. + /// + /// ## Platform-specific: + /// + /// - **Windows**: Requires admin rights if the protocol is registered on local machine + /// (this can happen when registered from the NSIS installer when the install mode is set to both or per machine) + /// - **Linux**: Can only unregister the scheme if it was initially registered with [`register`](`Self::register`). May not work on older distros. + /// - **macOS / Android / iOS**: Unsupported, will return [`Error::UnsupportedPlatform`](`crate::Error::UnsupportedPlatform`). + pub fn unregister>(&self, _protocol: S) -> crate::Result<()> { + #[cfg(windows)] + { + let protocol = _protocol.as_ref(); + let path = format!("Software\\Classes\\{protocol}"); + if LOCAL_MACHINE.open(&path).is_ok() { + LOCAL_MACHINE.remove_tree(&path)?; + } + if CURRENT_USER.open(&path).is_ok() { + CURRENT_USER.remove_tree(&path)?; + } + Ok(()) + } + + #[cfg(target_os = "linux")] + { + let mimeapps_path = self.app.path().config_dir()?.join("mimeapps.list"); + let mut mimeapps = ini::Ini::load_from_file(&mimeapps_path)?; + + let file_name = format!( + "{}-handler.desktop", + tauri::utils::platform::current_exe()? + .file_name() + .unwrap() + .to_string_lossy() + ); + + if let Some(section) = mimeapps.section_mut(Some("Default Applications")) { + let scheme = format!("x-scheme-handler/{}", _protocol.as_ref()); + + if section.get(&scheme).unwrap_or_default() == file_name { + section.remove(scheme); + } + } + + mimeapps.write_to_file(mimeapps_path)?; + + Ok(()) + } + + #[cfg(not(any(windows, target_os = "linux")))] + Err(crate::Error::UnsupportedPlatform) + } + + /// Check whether the app is the default handler for the specified protocol. + /// + /// - `protocol`: The name of the protocol without `://`. + /// + /// ## Platform-specific: + /// + /// - **macOS / Android / iOS**: Unsupported, will return [`Error::UnsupportedPlatform`](`crate::Error::UnsupportedPlatform`). + pub fn is_registered>(&self, _protocol: S) -> crate::Result { + #[cfg(windows)] + { + let protocol = _protocol.as_ref(); + let Ok(cmd_reg) = CLASSES_ROOT.open(format!("{protocol}\\shell\\open\\command")) + else { + return Ok(false); + }; + + let registered_cmd = cmd_reg.get_string("")?; + + let exe = dunce::simplified(&tauri::utils::platform::current_exe()?) + .display() + .to_string(); + + Ok(registered_cmd == format!("\"{exe}\" \"%1\"")) + } + #[cfg(target_os = "linux")] + { + let file_name = format!( + "{}-handler.desktop", + tauri::utils::platform::current_exe()? + .file_name() + .unwrap() + .to_string_lossy() + ); + + let output = Command::new("xdg-mime") + .args([ + "query", + "default", + &format!("x-scheme-handler/{}", _protocol.as_ref()), + ]) + .output()?; + + Ok(String::from_utf8_lossy(&output.stdout).contains(&file_name)) + } + + #[cfg(not(any(windows, target_os = "linux")))] + Err(crate::Error::UnsupportedPlatform) } } } pub use imp::DeepLink; +use url::Url; -/// Extensions to [`tauri::App`], [`tauri::AppHandle`] and [`tauri::Window`] to access the deep-link APIs. +/// Extensions to [`tauri::App`], [`tauri::AppHandle`], [`tauri::WebviewWindow`], [`tauri::Webview`] and [`tauri::Window`] to access the deep-link APIs. pub trait DeepLinkExt { fn deep_link(&self) -> &DeepLink; } @@ -129,11 +462,53 @@ impl> crate::DeepLinkExt for T { } } +/// Event that is triggered when the app was requested to open a new URL. +/// +/// Typed [`tauri::Event`]. +pub struct OpenUrlEvent { + id: EventId, + urls: Vec, +} + +impl OpenUrlEvent { + /// The event ID which can be used to stop listening to the event via [`tauri::Listener::unlisten`]. + pub fn id(&self) -> EventId { + self.id + } + + /// The event URLs. + pub fn urls(self) -> Vec { + self.urls + } +} + +impl DeepLink { + /// Helper function for the `deep-link://new-url` event to run a function each time the protocol is triggered while the app is running. + /// + /// Use `get_current` on app load to check whether your app was started via a deep link. + pub fn on_open_url(&self, f: F) -> EventId { + let event_id = self.app.listen("deep-link://new-url", move |event| { + if let Ok(urls) = serde_json::from_str(event.payload()) { + f(OpenUrlEvent { + id: event.id(), + urls, + }) + } + }); + + event_id + } +} + /// Initializes the plugin. pub fn init() -> TauriPlugin> { Builder::new("deep-link") - .js_init_script(include_str!("api-iife.js").to_string()) - .invoke_handler(tauri::generate_handler![commands::get_current]) + .invoke_handler(tauri::generate_handler![ + commands::get_current, + commands::register, + commands::unregister, + commands::is_registered + ]) .setup(|app, api| { app.manage(init_deep_link(app, api)?); Ok(()) @@ -141,7 +516,9 @@ 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); + use tauri::Emitter; + + let _ = _app.emit("deep-link://new-url", urls); _app.state::>() .current .lock() diff --git a/plugins/deep-link/src/template.desktop b/plugins/deep-link/src/template.desktop new file mode 100644 index 00000000..0fb89abb --- /dev/null +++ b/plugins/deep-link/src/template.desktop @@ -0,0 +1,7 @@ +[Desktop Entry] +Type=Application +Name={name} +Exec={exec} %u +Terminal=false +MimeType={mime_type} +NoDisplay=true \ No newline at end of file diff --git a/plugins/dialog/.gitignore b/plugins/dialog/.gitignore deleted file mode 100644 index 24ae1280..00000000 --- a/plugins/dialog/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.tauri diff --git a/plugins/dialog/CHANGELOG.md b/plugins/dialog/CHANGELOG.md index 56ee4c2d..e86fa202 100644 --- a/plugins/dialog/CHANGELOG.md +++ b/plugins/dialog/CHANGELOG.md @@ -1,5 +1,239 @@ # Changelog +## \[2.2.2] + +### Dependencies + +- Upgraded to `fs-js@2.3.0` + +## \[2.2.1] + +### Dependencies + +- Upgraded to `fs-js@2.2.1` + +## \[2.2.0] + +- [`3a79266b`](https://github.com/tauri-apps/plugins-workspace/commit/3a79266b8cf96a55b1ae6339d725567d45a44b1d) ([#2173](https://github.com/tauri-apps/plugins-workspace/pull/2173) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Bumped all plugins to `v2.2.0`. From now, the versions for the Rust and JavaScript packages of each plugin will be in sync with each other. + +### Dependencies + +- Upgraded to `fs-js@2.1.0` + +## \[2.0.2] + +### Dependencies + +- Upgraded to `fs-js@2.0.4` + +## \[2.0.4] + +- [`76f99ce9`](https://github.com/tauri-apps/plugins-workspace/commit/76f99ce999a2ff9e40235c1675e3eb6570b5e1e2) ([#2108](https://github.com/tauri-apps/plugins-workspace/pull/2108) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) The `Dialog` struct is now correctly exported, primarily to fix the documentation on `docs.rs`. + +### Dependencies + +- Upgraded to `fs@2.1.0` + +## \[2.0.3] + +### Dependencies + +- Upgraded to `fs@2.0.3` + +## \[2.0.1] + +- [`2302c2db`](https://github.com/tauri-apps/plugins-workspace/commit/2302c2db1c49673e61dcbda8cdb01b2c57e9ba6f) ([#1910](https://github.com/tauri-apps/plugins-workspace/pull/1910) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Fix `ask` and `confirm` not using system button texts +- [`aee14ed4`](https://github.com/tauri-apps/plugins-workspace/commit/aee14ed4261cdedc4ed7cc2686f01f437859a5c7) ([#1892](https://github.com/tauri-apps/plugins-workspace/pull/1892) by [@nashaofu](https://github.com/tauri-apps/plugins-workspace/../../nashaofu)) Set `save` dialog mime type from the `filters` extensions on Android. + +## \[2.0.1] + +- [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. + +### Dependencies + +- Upgraded to `fs@2.0.1` + +## \[2.0.0] + +- [`e2c4dfb6`](https://github.com/tauri-apps/plugins-workspace/commit/e2c4dfb6af43e5dd8d9ceba232c315f5febd55c1) Update to tauri v2 stable release. + +### Dependencies + +- Upgraded to `fs@2.0.0` + +## \[2.0.0-rc.8] + +- [`6bf1bd8d`](https://github.com/tauri-apps/plugins-workspace/commit/6bf1bd8d44bb95618590aa066e638509b014e0f9) ([#1805](https://github.com/tauri-apps/plugins-workspace/pull/1805) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Update rfd to 0.15 + +### Dependencies + +- Upgraded to `fs@2.0.0-rc.6` + +### breaking + +- [`04459afb`](https://github.com/tauri-apps/plugins-workspace/commit/04459afbb67aafa5cd57e6a148c2beb0a8d3e04a) ([#1842](https://github.com/tauri-apps/plugins-workspace/pull/1842) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Changed `MessageDialogBuilder::ok_button_label` and `MessageDialogBuilder::cancel_button_label` to `MessageDialogBuilder::buttons` which takes an enum now + +## \[2.0.0-rc.7] + +### Dependencies + +- Upgraded to `fs@2.0.0-rc.5` + +## \[2.0.0-rc.6] + +- [`2b898f07`](https://github.com/tauri-apps/plugins-workspace/commit/2b898f078688c57309ca17962bf02e665c406514) ([#1769](https://github.com/tauri-apps/plugins-workspace/pull/1769) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update Tauri scopes (asset protocol) when using the `open()` command to select directories. + +### Dependencies + +- Upgraded to `fs@2.0.0-rc.4` + +## \[2.0.0-rc.5] + +- [`a2fe5551`](https://github.com/tauri-apps/plugins-workspace/commit/a2fe55512f908dd11c814ce021d164f01677572a) ([#1727](https://github.com/tauri-apps/plugins-workspace/pull/1727) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Add utility methods on `FilePath` and `SafeFilePath` enums which are: + + - `path` + - `simplified` + - `into_path` +- [`a2fe5551`](https://github.com/tauri-apps/plugins-workspace/commit/a2fe55512f908dd11c814ce021d164f01677572a) ([#1727](https://github.com/tauri-apps/plugins-workspace/pull/1727) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Implement `Serialize`, `Deserialize`, `From`, `TryFrom` and `FromStr` traits for `FilePath` and `SafeFilePath` enums. +- [`a2fe5551`](https://github.com/tauri-apps/plugins-workspace/commit/a2fe55512f908dd11c814ce021d164f01677572a) ([#1727](https://github.com/tauri-apps/plugins-workspace/pull/1727) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Mark `Error` enum as `#[non_exhuastive]`. +- [`a2fe5551`](https://github.com/tauri-apps/plugins-workspace/commit/a2fe55512f908dd11c814ce021d164f01677572a) ([#1727](https://github.com/tauri-apps/plugins-workspace/pull/1727) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Add `SafeFilePath` enum. + +### Dependencies + +- Upgraded to `fs@2.0.0-rc.3` + +## \[2.0.0-rc.4] + +### Dependencies + +- Upgraded to `fs@2.0.0-rc.2` + +### breaking + +- [`0cb99bda`](https://github.com/tauri-apps/plugins-workspace/commit/0cb99bdaf11b5a9bb66b80bdf40b085d87c3066d) ([#1706](https://github.com/tauri-apps/plugins-workspace/pull/1706) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) If no filters are specified, the file picker dialog now defaults to a file selection instead of photos. + +### feat + +- [`feb1e93f`](https://github.com/tauri-apps/plugins-workspace/commit/feb1e93fcb9a913c002daa29e3b709f24b97c664) ([#1707](https://github.com/tauri-apps/plugins-workspace/pull/1707) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Implement `save` API on iOS. + +## \[2.0.0-rc.1] + +- [`448846b8`](https://github.com/tauri-apps/plugins-workspace/commit/448846b834d23df6e7c5dc66c5dd9aa0cb01846d) ([#1658](https://github.com/tauri-apps/plugins-workspace/pull/1658) by [@mikoto2000](https://github.com/tauri-apps/plugins-workspace/../../mikoto2000)) The `open` function now returns a string representing either the file path or URI instead of an object. + To read the file data, use the `fs` APIs. +- [`e2e97db5`](https://github.com/tauri-apps/plugins-workspace/commit/e2e97db51983267f5be84d4f6f0278d58834d1f5) ([#1701](https://github.com/tauri-apps/plugins-workspace/pull/1701) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri 2.0.0-rc.8 + +## \[2.0.0-rc.2] + +- [`b9147758`](https://github.com/tauri-apps/plugins-workspace/commit/b914775898c2bee7ceb20bd17ee595005cd17a64) ([#1679](https://github.com/tauri-apps/plugins-workspace/pull/1679) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Explicitly set a minimum macOS version for the Swift package. + +## \[2.0.0-rc.1] + +### feat + +- [`bc7eecf4`](https://github.com/tauri-apps/plugins-workspace/commit/bc7eecf4202e7d23b987440c1cbd2da0f68c8bef) ([#1657](https://github.com/tauri-apps/plugins-workspace/pull/1657) by [@mikoto2000](https://github.com/tauri-apps/plugins-workspace/../../mikoto2000)) Implement `save` API on Android. + +### changes + +- [`6b079cfd`](https://github.com/tauri-apps/plugins-workspace/commit/6b079cfdd107c94abc2c7300f6af00bac3ff4040) ([#1649](https://github.com/tauri-apps/plugins-workspace/pull/1649) by [@ahqsoftwares](https://github.com/tauri-apps/plugins-workspace/../../ahqsoftwares)) Remove targetSdk from build.kts files as it is deprecated and will be removed from DSL v9.0 + +## \[2.0.0-rc.0] + +- [`9887d1`](https://github.com/tauri-apps/plugins-workspace/commit/9887d14bd0e971c4c0f5c1188fc4005d3fc2e29e) Update to tauri RC. + +## \[2.0.0-beta.8] + +- [`99d6ac0f`](https://github.com/tauri-apps/plugins-workspace/commit/99d6ac0f9506a6a4a1aa59c728157190a7441af6) ([#1606](https://github.com/tauri-apps/plugins-workspace/pull/1606) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) The JS packages now specify the *minimum* `@tauri-apps/api` version instead of a single exact version. +- [`6de87966`](https://github.com/tauri-apps/plugins-workspace/commit/6de87966ecc00ad9d91c25be452f1f46bd2b7e1f) ([#1597](https://github.com/tauri-apps/plugins-workspace/pull/1597) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Update to tauri beta.25. + +## \[2.0.0-beta.7] + +- [`22a17980`](https://github.com/tauri-apps/plugins-workspace/commit/22a17980ff4f6f8c40adb1b8f4ffc6dae2fe7e30) ([#1537](https://github.com/tauri-apps/plugins-workspace/pull/1537) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri beta.24. + +## \[2.0.0-beta.6] + +- [`76daee7a`](https://github.com/tauri-apps/plugins-workspace/commit/76daee7aafece34de3092c86e531cf9eb1138989) ([#1512](https://github.com/tauri-apps/plugins-workspace/pull/1512) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Update to tauri beta.23. + +## \[2.0.0-beta.5] + +- [`9013854f`](https://github.com/tauri-apps/plugins-workspace/commit/9013854f42a49a230b9dbb9d02774765528a923f)([#1382](https://github.com/tauri-apps/plugins-workspace/pull/1382)) Update to tauri beta.22. + +## \[2.0.0-beta.4] + +- [`430bd6f4`](https://github.com/tauri-apps/plugins-workspace/commit/430bd6f4f379bee5d232ae6b098ae131db7f178a)([#1363](https://github.com/tauri-apps/plugins-workspace/pull/1363)) Update to tauri beta.20. + +## \[2.0.0-beta.3] + +- [`bd1ed590`](https://github.com/tauri-apps/plugins-workspace/commit/bd1ed5903ffcce5500310dac1e59e8c67674ef1e)([#1237](https://github.com/tauri-apps/plugins-workspace/pull/1237)) Update to tauri beta.17. + +## \[2.0.0-beta.6] + +- [`326df688`](https://github.com/tauri-apps/plugins-workspace/commit/326df6883998d416fc0837583ed972854628bb52)([#1236](https://github.com/tauri-apps/plugins-workspace/pull/1236)) Fixes command argument parsing on iOS. + +### Dependencies + +- Upgraded to `fs@2.0.0-beta.6` + +## \[2.0.0-beta.5] + +- [`bb51a41`](https://github.com/tauri-apps/plugins-workspace/commit/bb51a41d67ebf989e8aedf10c4b1a7f9514d1bdf)([#1168](https://github.com/tauri-apps/plugins-workspace/pull/1168)) **Breaking Change:** All apis that return paths to the frontend will now remove the `\\?\` UNC prefix on Windows. + +### Dependencies + +- Upgraded to `fs@2.0.0-beta.5` + +## \[2.0.0-beta.4] + +- [`4cd8112`](https://github.com/tauri-apps/plugins-workspace/commit/4cd81126fdf25e1847546f8fdbd924aa4bfeabb5)([#1056](https://github.com/tauri-apps/plugins-workspace/pull/1056)) Fixed an issue where dialogs on android would return the Content URI instead of the file path + +### Dependencies + +- Upgraded to `fs@2.0.0-beta.4` + +## \[2.0.0-beta.3] + +- [`35ea595`](https://github.com/tauri-apps/plugins-workspace/commit/35ea5956d060f0bdafd140f2541c607bb811805b)([#1073](https://github.com/tauri-apps/plugins-workspace/pull/1073)) Fixed an issue where the dialog apis panicked when they were called with no application windows open. +- [`a04ea2f`](https://github.com/tauri-apps/plugins-workspace/commit/a04ea2f38294d5a3987578283badc8eec87a7752)([#1071](https://github.com/tauri-apps/plugins-workspace/pull/1071)) The global API script is now only added to the binary when the `withGlobalTauri` config is true. + +### Dependencies + +- Upgraded to `fs@2.0.0-beta.3` + +## \[2.0.0-beta.2] + +- [`aa25c91`](https://github.com/tauri-apps/plugins-workspace/commit/aa25c91bb01e957872fb2b606a3acaf2f2c4ef3a)([#978](https://github.com/tauri-apps/plugins-workspace/pull/978)) Allow configuring `canCreateDirectories` for open and save dialogs on macOS, if not configured, it will be set to `true` by default. +- [`99bea25`](https://github.com/tauri-apps/plugins-workspace/commit/99bea2559c2c0648c2519c50a18cd124dacef57b)([#1005](https://github.com/tauri-apps/plugins-workspace/pull/1005)) Update to tauri beta.8. + +## \[2.0.0-beta.1] + +- [`569defb`](https://github.com/tauri-apps/plugins-workspace/commit/569defbe9492e38938554bb7bdc1be9151456d21) Update to tauri beta.4. + +## \[2.0.0-beta.0] + +- [`d198c01`](https://github.com/tauri-apps/plugins-workspace/commit/d198c014863ee260cb0de88a14b7fc4356ef7474)([#862](https://github.com/tauri-apps/plugins-workspace/pull/862)) Update to tauri beta. + +## \[2.0.0-alpha.7] + +### Dependencies + +- Upgraded to `fs@2.0.0-alpha.7` + +## \[2.0.0-alpha.5] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.13. + +## \[2.0.0-alpha.4] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.12. +- [`2e2c0a1`](https://github.com/tauri-apps/plugins-workspace/commit/2e2c0a1b958fcbc7de855ef1d305b11855f2eb8e)([#769](https://github.com/tauri-apps/plugins-workspace/pull/769)) Fix incorrect result for dialog messages. + +## \[2.0.0-alpha.3] + +- [`e438e0a`](https://github.com/tauri-apps/plugins-workspace/commit/e438e0a62d4b430a5159f05f13ecd397dd891a0d)([#676](https://github.com/tauri-apps/plugins-workspace/pull/676)) Update to @tauri-apps/api v2.0.0-alpha.11. + +## \[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.9. + ## \[2.0.0-alpha.2] - [`4e2cef9`](https://github.com/tauri-apps/plugins-workspace/commit/4e2cef9b702bbbb9cf4ee17de50791cb21f1b2a4)([#593](https://github.com/tauri-apps/plugins-workspace/pull/593)) Update to alpha.12. @@ -16,12 +250,3 @@ - [`717ae67`](https://github.com/tauri-apps/plugins-workspace/commit/717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! d6e80b)([#545](https://github.com/tauri-apps/plugins-workspace/pull/545)) Fixes docs.rs build by enabling the `tauri/dox` feature flag. -- [`d74fc0a`](https://github.com/tauri-apps/plugins-workspace/commit/d74fc0a097996e90a37be8f57d50b7d1f6ca616f)([#555](https://github.com/tauri-apps/plugins-workspace/pull/555)) Update to alpha.11. - -### Dependencies - -- Upgraded to `fs@2.0.0-alpha.1` - -## \[2.0.0-alpha.0] - -- [`717ae67`](https://github.com/tauri-apps/plugins-workspace/commit/717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! diff --git a/plugins/dialog/Cargo.toml b/plugins/dialog/Cargo.toml index fadb06c5..906cdeab 100644 --- a/plugins/dialog/Cargo.toml +++ b/plugins/dialog/Cargo.toml @@ -1,19 +1,31 @@ [package] name = "tauri-plugin-dialog" -version = "2.0.0-alpha.2" +version = "2.2.2" description = "Native system dialogs for opening and saving files along with message dialogs on your Tauri application." edition = { workspace = true } authors = { workspace = true } license = { workspace = true } rust-version = { workspace = true } +repository = { workspace = true } links = "tauri-plugin-dialog" [package.metadata.docs.rs] -features = [ "dox" ] -targets = [ - "x86_64-unknown-linux-gnu", - "x86_64-linux-android" -] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] +targets = ["x86_64-unknown-linux-gnu", "x86_64-linux-android"] + +[package.metadata.platforms.support] +windows = { level = "full", notes = "" } +linux = { level = "full", notes = "" } +macos = { level = "full", notes = "" } +android = { level = "partial", notes = "Does not support folder picker" } +ios = { level = "partial", notes = "Does not support folder picker" } + +[build-dependencies] +tauri-plugin = { workspace = true, features = ["build"] } + +[dev-dependencies] +tauri = { workspace = true, features = ["wry"] } [dependencies] serde = { workspace = true } @@ -21,17 +33,16 @@ serde_json = { workspace = true } tauri = { workspace = true } log = { workspace = true } thiserror = { workspace = true } -tauri-plugin-fs = { path = "../fs", version = "2.0.0-alpha.2" } +url = { workspace = true } +tauri-plugin-fs = { path = "../fs", version = "2.3.0" } -[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies] -glib = "0.16" +[target.'cfg(target_os = "ios")'.dependencies] +tauri = { workspace = true, features = ["wry"] } [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" ] } -raw-window-handle = "0.5" - -[build-dependencies] -tauri-build = { workspace = true } - -[features] -dox = [ "tauri/dox" ] +rfd = { version = "0.15", default-features = false, features = [ + "tokio", + "gtk3", + "common-controls-v6", +] } +raw-window-handle = "0.6" diff --git a/plugins/dialog/README.md b/plugins/dialog/README.md index d56a0f89..63d71767 100644 --- a/plugins/dialog/README.md +++ b/plugins/dialog/README.md @@ -2,9 +2,17 @@ Native system dialogs for opening and saving files along with message dialogs. +| Platform | Supported | +| -------- | --------- | +| Linux | ✓ | +| Windows | ✓ | +| macOS | ✓ | +| Android | ✓ | +| iOS | ✓ | + ## Install -_This plugin requires a Rust version of at least **1.70**_ +_This plugin requires a Rust version of at least **1.77.2**_ There are three general methods of installation that we can recommend. @@ -18,7 +26,7 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] -tauri-plugin-dialog = "2.0.0-alpha" +tauri-plugin-dialog = "2.0.0" # alternatively with Git: tauri-plugin-dialog = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -46,7 +54,7 @@ yarn add https://github.com/tauri-apps/tauri-plugin-dialog#v2 First you need to register the core plugin with Tauri: -`src-tauri/src/main.rs` +`src-tauri/src/lib.rs` ```rust fn main() { @@ -67,6 +75,22 @@ Afterwards all the plugin's APIs are available through the JavaScript guest bind PRs accepted. Please make sure to read the Contributing Guide before making a pull request. +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + ## License Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. diff --git a/plugins/dialog/SECURITY.md b/plugins/dialog/SECURITY.md new file mode 100644 index 00000000..4f09bbac --- /dev/null +++ b/plugins/dialog/SECURITY.md @@ -0,0 +1,23 @@ +# Security Policy + +**Do not report security vulnerabilities through public GitHub issues.** + +**Please use the [Private Vulnerability Disclosure](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) feature of GitHub.** + +Include as much of the following information: + +- Type of issue (e.g. improper input parsing, privilege escalation, etc.) +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- The distribution affected or used to help us with reproduction of the issue +- Step-by-step instructions to reproduce the issue +- Ideally a reproduction repository +- Impact of the issue, including how an attacker might exploit the issue + +We prefer to receive reports in English. + +## Contact + +Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). + +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/dialog/android/build.gradle.kts b/plugins/dialog/android/build.gradle.kts index a205eab1..e824cff9 100644 --- a/plugins/dialog/android/build.gradle.kts +++ b/plugins/dialog/android/build.gradle.kts @@ -5,11 +5,10 @@ plugins { android { namespace = "app.tauri.dialog" - compileSdk = 32 + compileSdk = 34 defaultConfig { - minSdk = 24 - targetSdk = 32 + minSdk = 24 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles("consumer-rules.pro") diff --git a/plugins/dialog/android/src/main/java/DialogPlugin.kt b/plugins/dialog/android/src/main/java/DialogPlugin.kt index 8806de6d..af0467d8 100644 --- a/plugins/dialog/android/src/main/java/DialogPlugin.kt +++ b/plugins/dialog/android/src/main/java/DialogPlugin.kt @@ -10,43 +10,56 @@ import android.content.Intent import android.net.Uri import android.os.Handler import android.os.Looper +import android.webkit.MimeTypeMap 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 +} + +@InvokeArg +class MessageOptions { + var title: String? = null + lateinit var message: String + var okButtonLabel: String? = null + var cancelButtonLabel: String? = null +} + +@InvokeArg +class SaveFileDialogOptions { + var fileName: String? = null + lateinit var filters: Array +} @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) - - var uniqueMimeType = true - var mimeKind: String? = null - for (mime in parsedTypes) { - val kind = mime.split("/")[0] - if (mimeKind == null) { - mimeKind = kind - } else if (mimeKind != kind) { - uniqueMimeType = false - } - } - - intent.type = if (uniqueMimeType) Intent.normalizeMimeType("$mimeKind/*") else "*/*" + setIntentMimeTypes(intent, parsedTypes) intent } else { val intent = Intent(Intent.ACTION_GET_CONTENT) @@ -55,7 +68,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 +81,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) invoke.resolve(callResult) } Activity.RESULT_CANCELED -> invoke.reject("File picker cancelled") @@ -84,82 +96,73 @@ class DialogPlugin(private val activity: Activity): Plugin(activity) { } } - private fun createPickFilesResult(data: Intent?, readData: Boolean): JSObject { + private fun createPickFilesResult(data: Intent?): JSObject { val callResult = JSObject() - val filesResultList: MutableList = ArrayList() if (data == null) { - callResult.put("files", JSArray.from(filesResultList)) + callResult.put("files", null) return callResult } - val uris: MutableList = ArrayList() + val uris: MutableList = ArrayList() if (data.clipData == null) { val uri: Uri? = data.data - uris.add(uri) + uris.add(uri?.toString()) } else { for (i in 0 until data.clipData!!.itemCount) { val uri: Uri = data.clipData!!.getItemAt(i).uri - uris.add(uri) + uris.add(uri.toString()) } } - for (i in uris.indices) { - val uri = uris[i] ?: continue - val fileResult = JSObject() - if (readData) { - fileResult.put("base64Data", FilePickerUtils.getDataFromUri(activity, uri)) - } - val duration = FilePickerUtils.getDurationFromUri(activity, uri) - if (duration != null) { - fileResult.put("duration", duration) - } - val resolution = FilePickerUtils.getHeightAndWidthFromUri(activity, uri) - if (resolution != null) { - fileResult.put("height", resolution.height) - fileResult.put("width", resolution.width) - } - fileResult.put("mimeType", FilePickerUtils.getMimeTypeFromUri(activity, uri)) - val modifiedAt = FilePickerUtils.getModifiedAtFromUri(activity, uri) - if (modifiedAt != null) { - fileResult.put("modifiedAt", modifiedAt) - } - fileResult.put("name", FilePickerUtils.getNameFromUri(activity, uri)) - fileResult.put("path", FilePickerUtils.getPathFromUri(uri)) - fileResult.put("size", FilePickerUtils.getSizeFromUri(activity, uri)) - filesResultList.add(fileResult) - } - callResult.put("files", JSArray.from(filesResultList.toTypedArray())) + callResult.put("files", JSArray.from(uris.toTypedArray())) 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 (ext in filter.extensions) { + if (ext.contains('/')) { + mimeTypes.add(if (ext == "text/csv") "text/comma-separated-values" else ext) + } else { + MimeTypeMap.getSingleton().getMimeTypeFromExtension(ext)?.let { + mimeTypes.add(it) + } } } - - mimeTypes.toTypedArray() - } catch (exception: JSONException) { - Logger.error("parseTypesOption failed.", exception) - null + } + return mimeTypes.toTypedArray() + } + + private fun setIntentMimeTypes(intent: Intent, mimeTypes: Array) { + if (mimeTypes.isNotEmpty()) { + var uniqueMimeKind = true + var mimeKind: String? = null + for (mime in mimeTypes) { + val kind = mime.split("/")[0] + if (mimeKind == null) { + mimeKind = kind + } else if (mimeKind != kind) { + uniqueMimeKind = false + } + } + + if (uniqueMimeKind) { + if (mimeTypes.size > 1) { + intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes) + intent.type = Intent.normalizeMimeType("$mimeKind/*") + } else { + intent.type = mimeTypes[0] + } + } else { + intent.type = "*/*" + } + } else { + intent.type = "*/*" } } @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,29 +180,73 @@ 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 - ) { dialog, _ -> - dialog.dismiss() - handler(false, false) - } .setOnCancelListener { dialog -> dialog.dismiss() handler(true, false) } + if (args.cancelButtonLabel != null) { + builder.setNegativeButton( args.cancelButtonLabel) { dialog, _ -> + dialog.dismiss() + handler(false, false) + } + } val dialog = builder.create() dialog.show() } } + + @Command + fun saveFileDialog(invoke: Invoke) { + try { + val args = invoke.parseArgs(SaveFileDialogOptions::class.java) + val parsedTypes = parseFiltersOption(args.filters) + + val intent = Intent(Intent.ACTION_CREATE_DOCUMENT) + setIntentMimeTypes(intent, parsedTypes) + + intent.addCategory(Intent.CATEGORY_OPENABLE) + intent.putExtra(Intent.EXTRA_TITLE, args.fileName ?: "") + startActivityForResult(invoke, intent, "saveFileDialogResult") + } catch (ex: Exception) { + val message = ex.message ?: "Failed to pick save file" + Logger.error(message) + invoke.reject(message) + } + } + + @ActivityCallback + fun saveFileDialogResult(invoke: Invoke, result: ActivityResult) { + try { + when (result.resultCode) { + Activity.RESULT_OK -> { + val callResult = JSObject() + val intent: Intent? = result.data + if (intent != null) { + val uri = intent.data + if (uri != null) { + callResult.put("file", uri.toString()) + } + } + invoke.resolve(callResult) + } + Activity.RESULT_CANCELED -> invoke.reject("File picker cancelled") + else -> invoke.reject("Failed to pick files") + } + } catch (ex: java.lang.Exception) { + val message = ex.message ?: "Failed to read file pick result" + Logger.error(message) + invoke.reject(message) + } + } } \ No newline at end of file diff --git a/plugins/dialog/android/src/main/java/FilePickerUtils.kt b/plugins/dialog/android/src/main/java/FilePickerUtils.kt index 5f0854a1..7029d4c6 100644 --- a/plugins/dialog/android/src/main/java/FilePickerUtils.kt +++ b/plugins/dialog/android/src/main/java/FilePickerUtils.kt @@ -4,10 +4,15 @@ package app.tauri.dialog + +import android.content.ContentUris +import android.database.Cursor +import android.provider.MediaStore import android.content.Context import android.graphics.BitmapFactory import android.media.MediaMetadataRetriever import android.net.Uri +import android.os.Environment import android.provider.DocumentsContract import android.provider.OpenableColumns import android.util.Base64 @@ -21,8 +26,40 @@ class FilePickerUtils { class FileResolution(var height: Int, var width: Int) companion object { - fun getPathFromUri(uri: Uri): String { - return uri.toString() + fun getPathFromUri(context: Context, uri: Uri): String? { + if (DocumentsContract.isDocumentUri(context, uri)) { + if (isExternalStorageDocument(uri)) { + val docId = DocumentsContract.getDocumentId(uri) + val split = docId.split(":") + return if ("primary".equals(split[0], ignoreCase = true)) { + "${Environment.getExternalStorageDirectory()}/${split[1]}" + } else { + null + } + } else if (isDownloadsDocument(uri)) { + val id = DocumentsContract.getDocumentId(uri) + val contentUri = ContentUris.withAppendedId( + Uri.parse("content://downloads/public_downloads"), java.lang.Long.valueOf(id)) + return getDataColumn(context, contentUri, null, null) + } else if (isMediaDocument(uri)) { + val docId = DocumentsContract.getDocumentId(uri) + val split = docId.split(":") + val contentUri: Uri? = when (split[0]) { + "image" -> MediaStore.Images.Media.EXTERNAL_CONTENT_URI + "video" -> MediaStore.Video.Media.EXTERNAL_CONTENT_URI + "audio" -> MediaStore.Audio.Media.EXTERNAL_CONTENT_URI + else -> null + } + val selection = "_id=?" + val selectionArgs = arrayOf(split[1]) + return getDataColumn(context, contentUri, selection, selectionArgs) + } + } else if ("content".equals(uri.scheme, ignoreCase = true)) { + return getDataColumn(context, uri, null, null) + } else if ("file".equals(uri.scheme, ignoreCase = true)) { + return uri.path + } + return null } fun getNameFromUri(context: Context, uri: Uri): String? { @@ -36,7 +73,7 @@ class FilePickerUtils { displayName = cursor.getString(columnIdx) cursor.close() } - if (displayName == null || displayName.isEmpty()) { + if (displayName.isNullOrEmpty()) { displayName = uri.lastPathSegment } return displayName @@ -162,4 +199,32 @@ class FilePickerUtils { return os.toByteArray() } } -} \ No newline at end of file +} + +private fun getDataColumn(context: Context, uri: Uri?, selection: String?, selectionArgs: Array?): String? { + var cursor: Cursor? = null + val column = "_data" + val projection = arrayOf(column) + try { + cursor = context.contentResolver.query(uri!!, projection, selection, selectionArgs, null) + if (cursor != null && cursor.moveToFirst()) { + val columnIndex = cursor.getColumnIndexOrThrow(column) + return cursor.getString(columnIndex) + } + } finally { + cursor?.close() + } + return null +} + +private fun isExternalStorageDocument(uri: Uri): Boolean { + return "com.android.externalstorage.documents" == uri.authority +} + +private fun isDownloadsDocument(uri: Uri): Boolean { + return "com.android.providers.downloads.documents" == uri.authority +} + +private fun isMediaDocument(uri: Uri): Boolean { + return "com.android.providers.media.documents" == uri.authority +} diff --git a/plugins/dialog/api-iife.js b/plugins/dialog/api-iife.js new file mode 100644 index 00000000..c2e0870c --- /dev/null +++ b/plugins/dialog/api-iife.js @@ -0,0 +1 @@ +if("__TAURI__"in window){var __TAURI_PLUGIN_DIALOG__=function(t){"use strict";async function n(t,n={},e){return window.__TAURI_INTERNALS__.invoke(t,n,e)}return"function"==typeof SuppressedError&&SuppressedError,t.ask=async function(t,e){const i="string"==typeof e?{title:e}:e;return await n("plugin:dialog|ask",{message:t.toString(),title:i?.title?.toString(),kind:i?.kind,yesButtonLabel:i?.okLabel?.toString(),noButtonLabel:i?.cancelLabel?.toString()})},t.confirm=async function(t,e){const i="string"==typeof e?{title:e}:e;return await n("plugin:dialog|confirm",{message:t.toString(),title:i?.title?.toString(),kind:i?.kind,okButtonLabel:i?.okLabel?.toString(),cancelButtonLabel:i?.cancelLabel?.toString()})},t.message=async function(t,e){const i="string"==typeof e?{title:e}:e;await n("plugin:dialog|message",{message:t.toString(),title:i?.title?.toString(),kind:i?.kind,okButtonLabel:i?.okLabel?.toString()})},t.open=async function(t={}){return"object"==typeof t&&Object.freeze(t),await n("plugin:dialog|open",{options:t})},t.save=async function(t={}){return"object"==typeof t&&Object.freeze(t),await n("plugin:dialog|save",{options:t})},t}({});Object.defineProperty(window.__TAURI__,"dialog",{value:__TAURI_PLUGIN_DIALOG__})} diff --git a/plugins/dialog/build.rs b/plugins/dialog/build.rs index ea12ef85..4b3bb871 100644 --- a/plugins/dialog/build.rs +++ b/plugins/dialog/build.rs @@ -2,16 +2,17 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT +const COMMANDS: &[&str] = &["open", "save", "message", "ask", "confirm"]; + fn main() { - if let Err(error) = tauri_build::mobile::PluginBuilder::new() + let result = tauri_plugin::Builder::new(COMMANDS) + .global_api_script_path("./api-iife.js") .android_path("android") .ios_path("ios") - .run() - { - 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")) { - std::process::exit(1); - } + .try_build(); + + // when building documentation for Android the plugin build result is always Err() and is irrelevant to the crate documentation build + if !(cfg!(docsrs) && std::env::var("TARGET").unwrap().contains("android")) { + result.unwrap(); } } diff --git a/plugins/dialog/guest-js/index.ts b/plugins/dialog/guest-js/index.ts index b0e01240..150be95a 100644 --- a/plugins/dialog/guest-js/index.ts +++ b/plugins/dialog/guest-js/index.ts @@ -2,19 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { invoke } from "@tauri-apps/api/primitives"; - -interface FileResponse { - base64Data?: string; - duration?: number; - height?: number; - width?: number; - mimeType?: string; - modifiedAt?: number; - name?: string; - path: string; - size: number; -} +import { invoke } from '@tauri-apps/api/core' /** * Extension filters for the file dialog. @@ -23,7 +11,7 @@ interface FileResponse { */ interface DialogFilter { /** Filter name. */ - name: string; + name: string /** * Extensions to filter, without a `.` prefix. * @example @@ -31,7 +19,7 @@ interface DialogFilter { * extensions: ['svg', 'png'] * ``` */ - extensions: string[]; + extensions: string[] } /** @@ -40,21 +28,30 @@ interface DialogFilter { * @since 2.0.0 */ interface OpenDialogOptions { - /** The title of the dialog window. */ - title?: string; + /** The title of the dialog window (desktop only). */ + title?: string /** The filters of the dialog. */ - filters?: DialogFilter[]; - /** Initial directory or file path. */ - defaultPath?: string; + filters?: DialogFilter[] + /** + * Initial directory or file path. + * If it's a directory path, the dialog interface will change to that folder. + * If it's not an existing directory, the file name will be set to the dialog's file name input and the dialog will be set to the parent folder. + * + * On mobile the file name is always used on the dialog's file name input. + * If not provided, Android uses `(invalid).txt` as default file name. + */ + defaultPath?: string /** Whether the dialog allows multiple selection or not. */ - multiple?: boolean; + multiple?: boolean /** Whether the dialog is a directory selection or not. */ - directory?: boolean; + directory?: boolean /** * If `directory` is true, indicates that it will be read recursively later. * Defines whether subdirectories will be allowed on the scope or not. */ - recursive?: boolean; + recursive?: boolean + /** Whether to allow creating directories in the dialog. Enabled by default. **macOS Only** */ + canCreateDirectories?: boolean } /** @@ -63,16 +60,21 @@ interface OpenDialogOptions { * @since 2.0.0 */ interface SaveDialogOptions { - /** The title of the dialog window. */ - title?: string; + /** The title of the dialog window (desktop only). */ + title?: string /** The filters of the dialog. */ - filters?: DialogFilter[]; + filters?: DialogFilter[] /** * Initial directory or file path. * If it's a directory path, the dialog interface will change to that folder. * If it's not an existing directory, the file name will be set to the dialog's file name input and the dialog will be set to the parent folder. + * + * On mobile the file name is always used on the dialog's file name input. + * If not provided, Android uses `(invalid).txt` as default file name. */ - defaultPath?: string; + defaultPath?: string + /** Whether to allow creating directories in the dialog. Enabled by default. **macOS Only** */ + canCreateDirectories?: boolean } /** @@ -80,36 +82,32 @@ interface SaveDialogOptions { */ interface MessageDialogOptions { /** The title of the dialog. Defaults to the app name. */ - title?: string; - /** The type of the dialog. Defaults to `info`. */ - type?: "info" | "warning" | "error"; + title?: string + /** The kind of the dialog. Defaults to `info`. */ + kind?: 'info' | 'warning' | 'error' /** The label of the confirm button. */ - okLabel?: string; + okLabel?: string } interface ConfirmDialogOptions { /** The title of the dialog. Defaults to the app name. */ - title?: string; - /** The type of the dialog. Defaults to `info`. */ - type?: "info" | "warning" | "error"; + title?: string + /** The kind of the dialog. Defaults to `info`. */ + kind?: 'info' | 'warning' | 'error' /** The label of the confirm button. */ - okLabel?: string; + okLabel?: string /** The label of the cancel button. */ - cancelLabel?: string; + cancelLabel?: string } -async function open( - options?: OpenDialogOptions & { multiple?: false; directory?: false }, -): Promise; -async function open( - options?: OpenDialogOptions & { multiple?: true; directory?: false }, -): Promise; -async function open( - options?: OpenDialogOptions & { multiple?: false; directory?: true }, -): Promise; -async function open( - options?: OpenDialogOptions & { multiple?: true; directory?: true }, -): Promise; +type OpenDialogReturn = T['directory'] extends true + ? T['multiple'] extends true + ? string[] | null + : string | null + : T['multiple'] extends true + ? string[] | null + : string | null + /** * Open a file/directory selection dialog. * @@ -162,14 +160,14 @@ async function open( * * @since 2.0.0 */ -async function open( - options: OpenDialogOptions = {}, -): Promise { - if (typeof options === "object") { - Object.freeze(options); +async function open( + options: T = {} as T +): Promise> { + if (typeof options === 'object') { + Object.freeze(options) } - return invoke("plugin:dialog|open", { options }); + return await invoke('plugin:dialog|open', { options }) } /** @@ -197,11 +195,11 @@ async function open( * @since 2.0.0 */ async function save(options: SaveDialogOptions = {}): Promise { - if (typeof options === "object") { - Object.freeze(options); + if (typeof options === 'object') { + Object.freeze(options) } - return invoke("plugin:dialog|save", { options }); + return await invoke('plugin:dialog|save', { options }) } /** @@ -210,7 +208,7 @@ async function save(options: SaveDialogOptions = {}): Promise { * ```typescript * import { message } from '@tauri-apps/plugin-dialog'; * await message('Tauri is awesome', 'Tauri'); - * await message('File not found', { title: 'Tauri', type: 'error' }); + * await message('File not found', { title: 'Tauri', kind: 'error' }); * ``` * * @param message The message to show. @@ -223,15 +221,15 @@ async function save(options: SaveDialogOptions = {}): Promise { */ async function message( message: string, - options?: string | MessageDialogOptions, + options?: string | MessageDialogOptions ): Promise { - const opts = typeof options === "string" ? { title: options } : options; - return invoke("plugin:dialog|message", { + const opts = typeof options === 'string' ? { title: options } : options + await invoke('plugin:dialog|message', { message: message.toString(), title: opts?.title?.toString(), - type_: opts?.type, - okButtonLabel: opts?.okLabel?.toString(), - }); + kind: opts?.kind, + okButtonLabel: opts?.okLabel?.toString() + }) } /** @@ -240,7 +238,7 @@ async function message( * ```typescript * import { ask } from '@tauri-apps/plugin-dialog'; * const yes = await ask('Are you sure?', 'Tauri'); - * const yes2 = await ask('This action cannot be reverted. Are you sure?', { title: 'Tauri', type: 'warning' }); + * const yes2 = await ask('This action cannot be reverted. Are you sure?', { title: 'Tauri', kind: 'warning' }); * ``` * * @param message The message to show. @@ -252,16 +250,16 @@ async function message( */ async function ask( message: string, - options?: string | ConfirmDialogOptions, + options?: string | ConfirmDialogOptions ): Promise { - const opts = typeof options === "string" ? { title: options } : options; - return invoke("plugin:dialog|ask", { + const opts = typeof options === 'string' ? { title: options } : options + return await invoke('plugin:dialog|ask', { message: message.toString(), title: opts?.title?.toString(), - type_: opts?.type, - okButtonLabel: opts?.okLabel?.toString() ?? "Yes", - cancelButtonLabel: opts?.cancelLabel?.toString() ?? "No", - }); + kind: opts?.kind, + yesButtonLabel: opts?.okLabel?.toString(), + noButtonLabel: opts?.cancelLabel?.toString() + }) } /** @@ -270,7 +268,7 @@ async function ask( * ```typescript * import { confirm } from '@tauri-apps/plugin-dialog'; * const confirmed = await confirm('Are you sure?', 'Tauri'); - * const confirmed2 = await confirm('This action cannot be reverted. Are you sure?', { title: 'Tauri', type: 'warning' }); + * const confirmed2 = await confirm('This action cannot be reverted. Are you sure?', { title: 'Tauri', kind: 'warning' }); * ``` * * @param message The message to show. @@ -282,24 +280,25 @@ async function ask( */ async function confirm( message: string, - options?: string | ConfirmDialogOptions, + options?: string | ConfirmDialogOptions ): Promise { - const opts = typeof options === "string" ? { title: options } : options; - return invoke("plugin:dialog|confirm", { + const opts = typeof options === 'string' ? { title: options } : options + return await invoke('plugin:dialog|confirm', { message: message.toString(), title: opts?.title?.toString(), - type_: opts?.type, - okButtonLabel: opts?.okLabel?.toString() ?? "Ok", - cancelButtonLabel: opts?.cancelLabel?.toString() ?? "Cancel", - }); + kind: opts?.kind, + okButtonLabel: opts?.okLabel?.toString(), + cancelButtonLabel: opts?.cancelLabel?.toString() + }) } export type { DialogFilter, OpenDialogOptions, + OpenDialogReturn, SaveDialogOptions, MessageDialogOptions, - ConfirmDialogOptions, -}; + ConfirmDialogOptions +} -export { open, save, message, ask, confirm }; +export { open, save, message, ask, confirm } diff --git a/plugins/dialog/guest-js/init.ts b/plugins/dialog/guest-js/init.ts index 22a18775..520a469a 100644 --- a/plugins/dialog/guest-js/init.ts +++ b/plugins/dialog/guest-js/init.ts @@ -2,17 +2,17 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { invoke } from "@tauri-apps/api/primitives"; +import { invoke } from '@tauri-apps/api/core' window.alert = function (message: string) { - invoke("plugin:dialog|message", { - message: message.toString(), - }); -}; + void invoke('plugin:dialog|message', { + message: message.toString() + }) +} // @ts-expect-error tauri does not have sync IPC :( -window.confirm = function (message: string) { - return invoke("plugin:dialog|confirm", { - message: message.toString(), - }); -}; +window.confirm = async function (message: string) { + return await invoke('plugin:dialog|confirm', { + message: message.toString() + }) +} diff --git a/plugins/dialog/ios/Package.swift b/plugins/dialog/ios/Package.swift index 45a58a43..f8983f14 100644 --- a/plugins/dialog/ios/Package.swift +++ b/plugins/dialog/ios/Package.swift @@ -6,28 +6,29 @@ import PackageDescription let package = Package( - name: "tauri-plugin-dialog", - platforms: [ - .iOS(.v13), - ], - products: [ - // Products define the executables and libraries a package produces, and make them visible to other packages. - .library( - name: "tauri-plugin-dialog", - type: .static, - targets: ["tauri-plugin-dialog"]), - ], - dependencies: [ - .package(name: "Tauri", path: "../.tauri/tauri-api") - ], - targets: [ - // Targets are the basic building blocks of a package. A target can define a module or a test suite. - // Targets can depend on other targets in this package, and on products in packages this package depends on. - .target( - name: "tauri-plugin-dialog", - dependencies: [ - .byName(name: "Tauri") - ], - path: "Sources") - ] + name: "tauri-plugin-dialog", + platforms: [ + .macOS(.v10_13), + .iOS(.v13), + ], + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .library( + name: "tauri-plugin-dialog", + type: .static, + targets: ["tauri-plugin-dialog"]) + ], + dependencies: [ + .package(name: "Tauri", path: "../.tauri/tauri-api") + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .target( + name: "tauri-plugin-dialog", + dependencies: [ + .byName(name: "Tauri") + ], + path: "Sources") + ] ) diff --git a/plugins/dialog/ios/Sources/DialogPlugin.swift b/plugins/dialog/ios/Sources/DialogPlugin.swift index ef1dff71..b3f7e7da 100644 --- a/plugins/dialog/ios/Sources/DialogPlugin.swift +++ b/plugins/dialog/ios/Sources/DialogPlugin.swift @@ -2,207 +2,237 @@ // 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 { + var title: String? + let message: String + var okButtonLabel: String? + var cancelButtonLabel: String? +} + +struct Filter: Decodable { + var extensions: [String]? +} + +struct FilePickerOptions: Decodable { + var multiple: Bool? + var filters: [Filter]? + var defaultPath: String? +} + +struct SaveFileDialogOptions: Decodable { + var fileName: String? + var defaultPath: String? } 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 onFilePickerResult: ((FilePickerEvent) -> Void)? = 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 = !parsedTypes.isEmpty + 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 + } + } + } + + onFilePickerResult = { (event: FilePickerEvent) -> Void in + switch event { + case .selected(let urls): + invoke.resolve(["files": urls]) + case .cancelled: + invoke.resolve(["files": nil]) + case .error(let error): + invoke.reject(error) + } + } + + if uniqueMimeType == true || isMedia { + DispatchQueue.main.async { + if #available(iOS 14, *) { + var configuration = PHPickerConfiguration(photoLibrary: PHPhotoLibrary.shared()) + configuration.selectionLimit = (args.multiple ?? false) ? 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) + if let defaultPath = args.defaultPath { + picker.directoryURL = URL(string: defaultPath) + } + picker.delegate = self.filePickerController + picker.allowsMultipleSelection = args.multiple ?? false + picker.modalPresentationStyle = .fullScreen + self.presentViewController(picker) + } + } + } + + @objc public func saveFileDialog(_ invoke: Invoke) throws { + let args = try invoke.parseArgs(SaveFileDialogOptions.self) + + // The Tauri save dialog API prompts the user to select a path where a file must be saved + // This behavior maps to the operating system interfaces on all platforms except iOS, + // which only exposes a mechanism to "move file `srcPath` to a location defined by the user" + // + // so we have to work around it by creating an empty file matching the requested `args.fileName`, + // and using it as `srcPath` for the operation - returning the path the user selected + // so the app dev can write to it later - matching cross platform behavior as mentioned above + let fileManager = FileManager.default + let srcFolder = fileManager.urls(for: .documentDirectory, in: .userDomainMask).first! + let srcPath = srcFolder.appendingPathComponent(args.fileName ?? "file") + if !fileManager.fileExists(atPath: srcPath.path) { + // the file contents must be actually provided by the tauri dev after the path is resolved by the save API + try "".write(to: srcPath, atomically: true, encoding: .utf8) + } + + onFilePickerResult = { (event: FilePickerEvent) -> Void in + switch event { + case .selected(let urls): + invoke.resolve(["file": urls.first!]) + case .cancelled: + invoke.resolve(["file": nil]) + case .error(let error): + invoke.reject(error) + } + } + + DispatchQueue.main.async { + let picker = UIDocumentPickerViewController(url: srcPath, in: .exportToService) + if let defaultPath = args.defaultPath { + picker.directoryURL = URL(string: defaultPath) } - } - - 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 + picker.delegate = self.filePickerController + picker.modalPresentationStyle = .fullScreen + self.presentViewController(picker) + } } - 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 presentViewController(_ viewControllerToPresent: UIViewController) { + self.manager.viewController?.present(viewControllerToPresent, animated: true, completion: nil) + } + + 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) { + self.onFilePickerResult?(event) + } - 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) + + let cancelButtonLabel = args.cancelButtonLabel ?? "" + if !cancelButtonLabel.isEmpty { + alert.addAction( + UIAlertAction( + title: cancelButtonLabel, style: UIAlertAction.Style.default, + handler: { (_) -> Void in + Logger.error("cancel") + + invoke.resolve([ + "value": false, + "cancelled": false, + ]) + })) + } + + let okButtonLabel = args.okButtonLabel ?? (cancelButtonLabel.isEmpty ? "OK" : "") + if !okButtonLabel.isEmpty { + alert.addAction( + UIAlertAction( + title: okButtonLabel, style: UIAlertAction.Style.default, + handler: { (_) -> Void in + Logger.error("ok") + + 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 b412c131..78b71623 100644 --- a/plugins/dialog/package.json +++ b/plugins/dialog/package.json @@ -1,32 +1,29 @@ { "name": "@tauri-apps/plugin-dialog", - "version": "2.0.0-alpha.1", - "license": "MIT or APACHE-2.0", + "version": "2.2.2", + "license": "MIT OR Apache-2.0", "authors": [ "Tauri Programme within The Commons Conservancy" ], + "repository": "https://github.com/tauri-apps/plugins-workspace", "type": "module", - "browser": "dist-js/index.min.js", - "module": "dist-js/index.mjs", - "types": "dist-js/index.d.ts", + "types": "./dist-js/index.d.ts", + "main": "./dist-js/index.cjs", + "module": "./dist-js/index.js", "exports": { - "import": "./dist-js/index.mjs", "types": "./dist-js/index.d.ts", - "browser": "./dist-js/index.min.js" + "import": "./dist-js/index.js", + "require": "./dist-js/index.cjs" }, "scripts": { "build": "rollup -c" }, "files": [ "dist-js", - "!dist-js/**/*.map", "README.md", "LICENSE" ], - "devDependencies": { - "tslib": "^2.4.1" - }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.9" + "@tauri-apps/api": "^2.0.0" } } diff --git a/plugins/dialog/permissions/autogenerated/commands/ask.toml b/plugins/dialog/permissions/autogenerated/commands/ask.toml new file mode 100644 index 00000000..4142c59f --- /dev/null +++ b/plugins/dialog/permissions/autogenerated/commands/ask.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-ask" +description = "Enables the ask command without any pre-configured scope." +commands.allow = ["ask"] + +[[permission]] +identifier = "deny-ask" +description = "Denies the ask command without any pre-configured scope." +commands.deny = ["ask"] diff --git a/plugins/dialog/permissions/autogenerated/commands/confirm.toml b/plugins/dialog/permissions/autogenerated/commands/confirm.toml new file mode 100644 index 00000000..a297d075 --- /dev/null +++ b/plugins/dialog/permissions/autogenerated/commands/confirm.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-confirm" +description = "Enables the confirm command without any pre-configured scope." +commands.allow = ["confirm"] + +[[permission]] +identifier = "deny-confirm" +description = "Denies the confirm command without any pre-configured scope." +commands.deny = ["confirm"] diff --git a/plugins/dialog/permissions/autogenerated/commands/message.toml b/plugins/dialog/permissions/autogenerated/commands/message.toml new file mode 100644 index 00000000..d386d91e --- /dev/null +++ b/plugins/dialog/permissions/autogenerated/commands/message.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-message" +description = "Enables the message command without any pre-configured scope." +commands.allow = ["message"] + +[[permission]] +identifier = "deny-message" +description = "Denies the message command without any pre-configured scope." +commands.deny = ["message"] diff --git a/plugins/dialog/permissions/autogenerated/commands/open.toml b/plugins/dialog/permissions/autogenerated/commands/open.toml new file mode 100644 index 00000000..4ea6dff1 --- /dev/null +++ b/plugins/dialog/permissions/autogenerated/commands/open.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-open" +description = "Enables the open command without any pre-configured scope." +commands.allow = ["open"] + +[[permission]] +identifier = "deny-open" +description = "Denies the open command without any pre-configured scope." +commands.deny = ["open"] diff --git a/plugins/dialog/permissions/autogenerated/commands/save.toml b/plugins/dialog/permissions/autogenerated/commands/save.toml new file mode 100644 index 00000000..d3e84220 --- /dev/null +++ b/plugins/dialog/permissions/autogenerated/commands/save.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-save" +description = "Enables the save command without any pre-configured scope." +commands.allow = ["save"] + +[[permission]] +identifier = "deny-save" +description = "Denies the save command without any pre-configured scope." +commands.deny = ["save"] diff --git a/plugins/dialog/permissions/autogenerated/reference.md b/plugins/dialog/permissions/autogenerated/reference.md new file mode 100644 index 00000000..246c7733 --- /dev/null +++ b/plugins/dialog/permissions/autogenerated/reference.md @@ -0,0 +1,159 @@ +## Default Permission + +This permission set configures the types of dialogs +available from the dialog plugin. + +#### Granted Permissions + +All dialog types are enabled. + + + + +#### This default permission set includes the following: + +- `allow-ask` +- `allow-confirm` +- `allow-message` +- `allow-save` +- `allow-open` + +## Permission Table + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IdentifierDescription
+ +`dialog:allow-ask` + + + +Enables the ask command without any pre-configured scope. + +
+ +`dialog:deny-ask` + + + +Denies the ask command without any pre-configured scope. + +
+ +`dialog:allow-confirm` + + + +Enables the confirm command without any pre-configured scope. + +
+ +`dialog:deny-confirm` + + + +Denies the confirm command without any pre-configured scope. + +
+ +`dialog:allow-message` + + + +Enables the message command without any pre-configured scope. + +
+ +`dialog:deny-message` + + + +Denies the message command without any pre-configured scope. + +
+ +`dialog:allow-open` + + + +Enables the open command without any pre-configured scope. + +
+ +`dialog:deny-open` + + + +Denies the open command without any pre-configured scope. + +
+ +`dialog:allow-save` + + + +Enables the save command without any pre-configured scope. + +
+ +`dialog:deny-save` + + + +Denies the save command without any pre-configured scope. + +
diff --git a/plugins/dialog/permissions/default.toml b/plugins/dialog/permissions/default.toml new file mode 100644 index 00000000..cc936d90 --- /dev/null +++ b/plugins/dialog/permissions/default.toml @@ -0,0 +1,20 @@ +"$schema" = "schemas/schema.json" + +[default] +description = """ +This permission set configures the types of dialogs +available from the dialog plugin. + +#### Granted Permissions + +All dialog types are enabled. + + +""" +permissions = [ + "allow-ask", + "allow-confirm", + "allow-message", + "allow-save", + "allow-open", +] diff --git a/plugins/dialog/permissions/schemas/schema.json b/plugins/dialog/permissions/schemas/schema.json new file mode 100644 index 00000000..b47417ec --- /dev/null +++ b/plugins/dialog/permissions/schemas/schema.json @@ -0,0 +1,366 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "PermissionFile", + "description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.", + "type": "object", + "properties": { + "default": { + "description": "The default permission set for the plugin", + "anyOf": [ + { + "$ref": "#/definitions/DefaultPermission" + }, + { + "type": "null" + } + ] + }, + "set": { + "description": "A list of permissions sets defined", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionSet" + } + }, + "permission": { + "description": "A list of inlined permissions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Permission" + } + } + }, + "definitions": { + "DefaultPermission": { + "description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.", + "type": "object", + "required": [ + "permissions" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "PermissionSet": { + "description": "A set of direct permissions grouped together under a new name.", + "type": "object", + "required": [ + "description", + "identifier", + "permissions" + ], + "properties": { + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does.", + "type": "string" + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionKind" + } + } + } + }, + "Permission": { + "description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.", + "type": "object", + "required": [ + "identifier" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri internal convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "commands": { + "description": "Allowed or denied commands when using this permission.", + "default": { + "allow": [], + "deny": [] + }, + "allOf": [ + { + "$ref": "#/definitions/Commands" + } + ] + }, + "scope": { + "description": "Allowed or denied scoped when using this permission.", + "allOf": [ + { + "$ref": "#/definitions/Scopes" + } + ] + }, + "platforms": { + "description": "Target platforms this permission applies. By default all platforms are affected by this permission.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Target" + } + } + } + }, + "Commands": { + "description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.", + "type": "object", + "properties": { + "allow": { + "description": "Allowed command.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "deny": { + "description": "Denied command, which takes priority.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "Scopes": { + "description": "An argument for fine grained behavior control of Tauri commands.\n\nIt can be of any serde serializable type and is used to allow or prevent certain actions inside a Tauri command. The configured scope is passed to the command and will be enforced by the command implementation.\n\n## Example\n\n```json { \"allow\": [{ \"path\": \"$HOME/**\" }], \"deny\": [{ \"path\": \"$HOME/secret.txt\" }] } ```", + "type": "object", + "properties": { + "allow": { + "description": "Data that defines what is allowed by the scope.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + }, + "deny": { + "description": "Data that defines what is denied by the scope. This should be prioritized by validation logic.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + } + } + }, + "Value": { + "description": "All supported ACL values.", + "anyOf": [ + { + "description": "Represents a null JSON value.", + "type": "null" + }, + { + "description": "Represents a [`bool`].", + "type": "boolean" + }, + { + "description": "Represents a valid ACL [`Number`].", + "allOf": [ + { + "$ref": "#/definitions/Number" + } + ] + }, + { + "description": "Represents a [`String`].", + "type": "string" + }, + { + "description": "Represents a list of other [`Value`]s.", + "type": "array", + "items": { + "$ref": "#/definitions/Value" + } + }, + { + "description": "Represents a map of [`String`] keys to [`Value`]s.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/Value" + } + } + ] + }, + "Number": { + "description": "A valid ACL number.", + "anyOf": [ + { + "description": "Represents an [`i64`].", + "type": "integer", + "format": "int64" + }, + { + "description": "Represents a [`f64`].", + "type": "number", + "format": "double" + } + ] + }, + "Target": { + "description": "Platform target.", + "oneOf": [ + { + "description": "MacOS.", + "type": "string", + "enum": [ + "macOS" + ] + }, + { + "description": "Windows.", + "type": "string", + "enum": [ + "windows" + ] + }, + { + "description": "Linux.", + "type": "string", + "enum": [ + "linux" + ] + }, + { + "description": "Android.", + "type": "string", + "enum": [ + "android" + ] + }, + { + "description": "iOS.", + "type": "string", + "enum": [ + "iOS" + ] + } + ] + }, + "PermissionKind": { + "type": "string", + "oneOf": [ + { + "description": "Enables the ask command without any pre-configured scope.", + "type": "string", + "const": "allow-ask", + "markdownDescription": "Enables the ask command without any pre-configured scope." + }, + { + "description": "Denies the ask command without any pre-configured scope.", + "type": "string", + "const": "deny-ask", + "markdownDescription": "Denies the ask command without any pre-configured scope." + }, + { + "description": "Enables the confirm command without any pre-configured scope.", + "type": "string", + "const": "allow-confirm", + "markdownDescription": "Enables the confirm command without any pre-configured scope." + }, + { + "description": "Denies the confirm command without any pre-configured scope.", + "type": "string", + "const": "deny-confirm", + "markdownDescription": "Denies the confirm command without any pre-configured scope." + }, + { + "description": "Enables the message command without any pre-configured scope.", + "type": "string", + "const": "allow-message", + "markdownDescription": "Enables the message command without any pre-configured scope." + }, + { + "description": "Denies the message command without any pre-configured scope.", + "type": "string", + "const": "deny-message", + "markdownDescription": "Denies the message command without any pre-configured scope." + }, + { + "description": "Enables the open command without any pre-configured scope.", + "type": "string", + "const": "allow-open", + "markdownDescription": "Enables the open command without any pre-configured scope." + }, + { + "description": "Denies the open command without any pre-configured scope.", + "type": "string", + "const": "deny-open", + "markdownDescription": "Denies the open command without any pre-configured scope." + }, + { + "description": "Enables the save command without any pre-configured scope.", + "type": "string", + "const": "allow-save", + "markdownDescription": "Enables the save command without any pre-configured scope." + }, + { + "description": "Denies the save command without any pre-configured scope.", + "type": "string", + "const": "deny-save", + "markdownDescription": "Denies the save command without any pre-configured scope." + }, + { + "description": "This permission set configures the types of dialogs\navailable from the dialog plugin.\n\n#### Granted Permissions\n\nAll dialog types are enabled.\n\n\n\n#### This default permission set includes:\n\n- `allow-ask`\n- `allow-confirm`\n- `allow-message`\n- `allow-save`\n- `allow-open`", + "type": "string", + "const": "default", + "markdownDescription": "This permission set configures the types of dialogs\navailable from the dialog plugin.\n\n#### Granted Permissions\n\nAll dialog types are enabled.\n\n\n\n#### This default permission set includes:\n\n- `allow-ask`\n- `allow-confirm`\n- `allow-message`\n- `allow-save`\n- `allow-open`" + } + ] + } + } +} \ No newline at end of file diff --git a/plugins/dialog/rollup.config.js b/plugins/dialog/rollup.config.js new file mode 100644 index 00000000..a7dbd4f6 --- /dev/null +++ b/plugins/dialog/rollup.config.js @@ -0,0 +1,22 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import { createConfig } from '../../shared/rollup.config.js' +import { nodeResolve } from '@rollup/plugin-node-resolve' +import typescript from '@rollup/plugin-typescript' +import terser from '@rollup/plugin-terser' + +export default createConfig({ + additionalConfigs: { + input: 'guest-js/init.ts', + output: { + file: 'src/init-iife.js', + format: 'iife' + }, + plugins: [typescript(), terser(), nodeResolve()], + onwarn: (warning) => { + throw Object.assign(new Error(), warning) + } + } +}) diff --git a/plugins/dialog/rollup.config.mjs b/plugins/dialog/rollup.config.mjs deleted file mode 100644 index d2a3cda6..00000000 --- a/plugins/dialog/rollup.config.mjs +++ /dev/null @@ -1,34 +0,0 @@ -import { readFileSync } from "fs"; - -import { createConfig } from "../../shared/rollup.config.mjs"; - -import typescript from "@rollup/plugin-typescript"; -import resolve from "@rollup/plugin-node-resolve"; -import terser from "@rollup/plugin-terser"; - -const config = createConfig({ - input: "guest-js/index.ts", - pkg: JSON.parse( - readFileSync(new URL("./package.json", import.meta.url), "utf8"), - ), - external: [/^@tauri-apps\/api/], -}); - -config.push({ - input: "guest-js/init.ts", - output: { - file: "src/init-iife.js", - format: "iife", - }, - plugins: [ - resolve(), - typescript({ - sourceMap: false, - declaration: false, - declarationDir: undefined, - }), - terser(), - ], -}); - -export default config; diff --git a/plugins/dialog/src/api-iife.js b/plugins/dialog/src/api-iife.js deleted file mode 100644 index 5fa71c3c..00000000 --- a/plugins/dialog/src/api-iife.js +++ /dev/null @@ -1 +0,0 @@ -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__})} diff --git a/plugins/dialog/src/commands.rs b/plugins/dialog/src/commands.rs index 8232eedf..c3caf027 100644 --- a/plugins/dialog/src/commands.rs +++ b/plugins/dialog/src/commands.rs @@ -8,17 +8,20 @@ use serde::{Deserialize, Serialize}; use tauri::{command, Manager, Runtime, State, Window}; use tauri_plugin_fs::FsExt; -use crate::{Dialog, FileDialogBuilder, FileResponse, MessageDialogKind, Result}; +use crate::{ + Dialog, FileDialogBuilder, FilePath, MessageDialogButtons, MessageDialogKind, Result, CANCEL, + NO, OK, YES, +}; #[derive(Serialize)] #[serde(untagged)] pub enum OpenResponse { #[cfg(desktop)] - Folders(Option>), + Folders(Option>), #[cfg(desktop)] - Folder(Option), - Files(Option>), - File(Option), + Folder(Option), + Files(Option>), + File(Option), } #[allow(dead_code)] @@ -51,6 +54,8 @@ pub struct OpenDialogOptions { #[serde(default)] #[cfg_attr(mobile, allow(dead_code))] recursive: bool, + /// Whether to allow creating directories in the dialog **macOS Only** + can_create_directories: Option, } /// The options for the save dialog API. @@ -65,12 +70,28 @@ pub struct SaveDialogOptions { filters: Vec, /// The initial path of the dialog. default_path: Option, + /// Whether to allow creating directories in the dialog **macOS Only** + can_create_directories: Option, } +#[cfg(mobile)] fn set_default_path( mut dialog_builder: FileDialogBuilder, default_path: PathBuf, ) -> FileDialogBuilder { + if let Some(file_name) = default_path.file_name() { + dialog_builder = dialog_builder.set_file_name(file_name.to_string_lossy()); + } + dialog_builder +} + +#[cfg(desktop)] +fn set_default_path( + mut dialog_builder: FileDialogBuilder, + default_path: PathBuf, +) -> FileDialogBuilder { + // we need to adjust the separator on Windows: https://github.com/tauri-apps/tauri/issues/8074 + let default_path: PathBuf = default_path.components().collect(); if default_path.is_file() || !default_path.exists() { if let (Some(parent), Some(file_name)) = (default_path.parent(), default_path.file_name()) { if parent.components().count() > 0 { @@ -98,11 +119,14 @@ pub(crate) async fn open( dialog_builder = dialog_builder.set_parent(&window); } if let Some(title) = options.title { - dialog_builder = dialog_builder.set_title(&title); + dialog_builder = dialog_builder.set_title(title); } if let Some(default_path) = options.default_path { dialog_builder = set_default_path(dialog_builder, default_path); } + if let Some(can) = options.can_create_directories { + dialog_builder = dialog_builder.set_can_create_directories(can); + } for filter in options.filters { let extensions: Vec<&str> = filter.extensions.iter().map(|s| &**s).collect(); dialog_builder = dialog_builder.add_filter(filter.name, &extensions); @@ -111,52 +135,67 @@ pub(crate) async fn open( let res = if options.directory { #[cfg(desktop)] { + let tauri_scope = window.state::(); + if options.multiple { let folders = dialog_builder.blocking_pick_folders(); if let Some(folders) = &folders { for folder in folders { - if let Some(s) = window.try_fs_scope() { - s.allow_directory(folder, options.recursive)?; + if let Ok(path) = folder.clone().into_path() { + if let Some(s) = window.try_fs_scope() { + s.allow_directory(&path, options.recursive)?; + } + tauri_scope.allow_directory(&path, options.directory)?; } } } - OpenResponse::Folders(folders) + OpenResponse::Folders( + folders.map(|folders| folders.into_iter().map(|p| p.simplified()).collect()), + ) } else { let folder = dialog_builder.blocking_pick_folder(); - if let Some(path) = &folder { - if let Some(s) = window.try_fs_scope() { - s.allow_directory(path, options.recursive)?; + if let Some(folder) = &folder { + if let Ok(path) = folder.clone().into_path() { + if let Some(s) = window.try_fs_scope() { + s.allow_directory(&path, options.recursive)?; + } + tauri_scope.allow_directory(&path, options.directory)?; } } - OpenResponse::Folder(folder) + OpenResponse::Folder(folder.map(|p| p.simplified())) } } #[cfg(mobile)] return Err(crate::Error::FolderPickerNotImplemented); } else if options.multiple { + let tauri_scope = window.state::(); + let files = dialog_builder.blocking_pick_files(); if let Some(files) = &files { for file in files { - if let Some(s) = window.try_fs_scope() { - s.allow_file(&file.path)?; + if let Ok(path) = file.clone().into_path() { + if let Some(s) = window.try_fs_scope() { + s.allow_file(&path)?; + } + + tauri_scope.allow_file(&path)?; } - window - .state::() - .allow_file(&file.path)?; } } - OpenResponse::Files(files) + OpenResponse::Files(files.map(|files| files.into_iter().map(|f| f.simplified()).collect())) } else { + let tauri_scope = window.state::(); let file = dialog_builder.blocking_pick_file(); + if let Some(file) = &file { - if let Some(s) = window.try_fs_scope() { - s.allow_file(&file.path)?; + if let Ok(path) = file.clone().into_path() { + if let Some(s) = window.try_fs_scope() { + s.allow_file(&path)?; + } + tauri_scope.allow_file(&path)?; } - window - .state::() - .allow_file(&file.path)?; } - OpenResponse::File(file) + OpenResponse::File(file.map(|f| f.simplified())) }; Ok(res) } @@ -167,37 +206,39 @@ pub(crate) async fn save( window: Window, dialog: State<'_, Dialog>, options: SaveDialogOptions, -) -> Result> { - #[cfg(mobile)] - return Err(crate::Error::FileSaveDialogNotImplemented); +) -> Result> { + let mut dialog_builder = dialog.file(); #[cfg(desktop)] { - let mut dialog_builder = dialog.file(); - #[cfg(any(windows, target_os = "macos"))] - { - dialog_builder = dialog_builder.set_parent(&window); - } - if let Some(title) = options.title { - dialog_builder = dialog_builder.set_title(&title); - } - if let Some(default_path) = options.default_path { - dialog_builder = set_default_path(dialog_builder, default_path); - } - for filter in options.filters { - let extensions: Vec<&str> = filter.extensions.iter().map(|s| &**s).collect(); - dialog_builder = dialog_builder.add_filter(filter.name, &extensions); - } + dialog_builder = dialog_builder.set_parent(&window); + } + if let Some(title) = options.title { + dialog_builder = dialog_builder.set_title(title); + } + if let Some(default_path) = options.default_path { + dialog_builder = set_default_path(dialog_builder, default_path); + } + if let Some(can) = options.can_create_directories { + dialog_builder = dialog_builder.set_can_create_directories(can); + } + for filter in options.filters { + let extensions: Vec<&str> = filter.extensions.iter().map(|s| &**s).collect(); + dialog_builder = dialog_builder.add_filter(filter.name, &extensions); + } - let path = dialog_builder.blocking_save_file(); - if let Some(p) = &path { + let tauri_scope = window.state::(); + + let path = dialog_builder.blocking_save_file(); + if let Some(p) = &path { + if let Ok(path) = p.clone().into_path() { if let Some(s) = window.try_fs_scope() { - s.allow_file(p)?; + s.allow_file(&path)?; } - window.state::().allow_file(p)?; + tauri_scope.allow_file(&path)?; } - - Ok(path) } + + Ok(path.map(|p| p.simplified())) } fn message_dialog( @@ -205,31 +246,24 @@ fn message_dialog( dialog: State<'_, Dialog>, title: Option, message: String, - type_: Option, - ok_button_label: Option, - cancel_button_label: Option, + kind: Option, + buttons: MessageDialogButtons, ) -> bool { let mut builder = dialog.message(message); + builder = builder.buttons(buttons); + if let Some(title) = title { builder = builder.title(title); } - #[cfg(any(windows, target_os = "macos"))] + #[cfg(desktop)] { builder = builder.parent(&window); } - if let Some(type_) = type_ { - builder = builder.kind(type_); - } - - if let Some(ok) = ok_button_label { - builder = builder.ok_button_label(ok); - } - - if let Some(cancel) = cancel_button_label { - builder = builder.cancel_button_label(cancel); + if let Some(kind) = kind { + builder = builder.kind(kind); } builder.blocking_show() @@ -241,7 +275,7 @@ pub(crate) async fn message( dialog: State<'_, Dialog>, title: Option, message: String, - type_: Option, + kind: Option, ok_button_label: Option, ) -> Result { Ok(message_dialog( @@ -249,9 +283,12 @@ pub(crate) async fn message( dialog, title, message, - type_, - ok_button_label, - None, + kind, + if let Some(ok_button_label) = ok_button_label { + MessageDialogButtons::OkCustom(ok_button_label) + } else { + MessageDialogButtons::Ok + }, )) } @@ -261,18 +298,26 @@ pub(crate) async fn ask( dialog: State<'_, Dialog>, title: Option, message: String, - type_: Option, - ok_button_label: Option, - cancel_button_label: Option, + kind: Option, + yes_button_label: Option, + no_button_label: Option, ) -> Result { Ok(message_dialog( window, dialog, title, message, - type_, - Some(ok_button_label.unwrap_or_else(|| "Yes".into())), - Some(cancel_button_label.unwrap_or_else(|| "No".into())), + kind, + if let Some(yes_button_label) = yes_button_label { + MessageDialogButtons::OkCancelCustom( + yes_button_label, + no_button_label.unwrap_or(NO.to_string()), + ) + } else if let Some(no_button_label) = no_button_label { + MessageDialogButtons::OkCancelCustom(YES.to_string(), no_button_label) + } else { + MessageDialogButtons::YesNo + }, )) } @@ -282,7 +327,7 @@ pub(crate) async fn confirm( dialog: State<'_, Dialog>, title: Option, message: String, - type_: Option, + kind: Option, ok_button_label: Option, cancel_button_label: Option, ) -> Result { @@ -291,8 +336,16 @@ pub(crate) async fn confirm( dialog, title, message, - type_, - Some(ok_button_label.unwrap_or_else(|| "Ok".into())), - Some(cancel_button_label.unwrap_or_else(|| "Cancel".into())), + kind, + if let Some(ok_button_label) = ok_button_label { + MessageDialogButtons::OkCancelCustom( + ok_button_label, + cancel_button_label.unwrap_or(CANCEL.to_string()), + ) + } else if let Some(cancel_button_label) = cancel_button_label { + MessageDialogButtons::OkCancelCustom(OK.to_string(), cancel_button_label) + } else { + MessageDialogButtons::OkCancel + }, )) } diff --git a/plugins/dialog/src/desktop.rs b/plugins/dialog/src/desktop.rs index 4cd02bcd..d1a3e8b2 100644 --- a/plugins/dialog/src/desktop.rs +++ b/plugins/dialog/src/desktop.rs @@ -8,25 +8,12 @@ //! to give results back. This is particularly useful when running dialogs from the main thread. //! When using on asynchronous contexts such as async commands, the [`blocking`] APIs are recommended. -use std::path::PathBuf; - -use raw_window_handle::{HasRawWindowHandle, RawWindowHandle}; +use raw_window_handle::{HasDisplayHandle, HasWindowHandle, RawDisplayHandle, RawWindowHandle}; +use rfd::{AsyncFileDialog, AsyncMessageDialog}; use serde::de::DeserializeOwned; use tauri::{plugin::PluginApi, AppHandle, Runtime}; -use crate::{models::*, FileDialogBuilder, MessageDialogBuilder}; - -const OK: &str = "Ok"; - -#[cfg(target_os = "linux")] -type FileDialog = rfd::FileDialog; -#[cfg(not(target_os = "linux"))] -type FileDialog = rfd::AsyncFileDialog; - -#[cfg(target_os = "linux")] -type MessageDialog = rfd::MessageDialog; -#[cfg(not(target_os = "linux"))] -type MessageDialog = rfd::AsyncMessageDialog; +use crate::{models::*, FileDialogBuilder, FilePath, MessageDialogBuilder, OK}; pub fn init( app: &AppHandle, @@ -51,52 +38,6 @@ impl Dialog { } } -#[cfg(not(target_os = "linux"))] -macro_rules! run_dialog { - ($e:expr, $h: ident) => {{ - std::thread::spawn(move || { - let response = tauri::async_runtime::block_on($e); - $h(response); - }); - }}; -} - -#[cfg(target_os = "linux")] -macro_rules! run_dialog { - ($e:expr, $h: ident) => {{ - std::thread::spawn(move || { - let context = glib::MainContext::default(); - context.invoke_with_priority(glib::PRIORITY_HIGH, move || { - let response = $e; - $h(response); - }); - }); - }}; -} - -#[cfg(not(target_os = "linux"))] -macro_rules! run_file_dialog { - ($e:expr, $h: ident) => {{ - std::thread::spawn(move || { - let response = tauri::async_runtime::block_on($e); - $h(response); - }); - }}; -} - -#[cfg(target_os = "linux")] -macro_rules! run_file_dialog { - ($e:expr, $h: ident) => {{ - std::thread::spawn(move || { - let context = glib::MainContext::default(); - context.invoke_with_priority(glib::PRIORITY_HIGH, move || { - let response = $e; - $h(response); - }); - }); - }}; -} - impl From for rfd::MessageLevel { fn from(kind: MessageDialogKind) -> Self { match kind { @@ -107,26 +48,49 @@ impl From for rfd::MessageLevel { } } -struct WindowHandle(RawWindowHandle); +#[derive(Debug)] +pub(crate) struct WindowHandle { + window_handle: RawWindowHandle, + display_handle: RawDisplayHandle, +} + +impl WindowHandle { + pub(crate) fn new(window_handle: RawWindowHandle, display_handle: RawDisplayHandle) -> Self { + Self { + window_handle, + display_handle, + } + } +} + +impl HasWindowHandle for WindowHandle { + fn window_handle( + &self, + ) -> Result, raw_window_handle::HandleError> { + Ok(unsafe { raw_window_handle::WindowHandle::borrow_raw(self.window_handle) }) + } +} -unsafe impl HasRawWindowHandle for WindowHandle { - fn raw_window_handle(&self) -> RawWindowHandle { - self.0 +impl HasDisplayHandle for WindowHandle { + fn display_handle( + &self, + ) -> Result, raw_window_handle::HandleError> { + Ok(unsafe { raw_window_handle::DisplayHandle::borrow_raw(self.display_handle) }) } } -impl From> for FileDialog { +impl From> for AsyncFileDialog { fn from(d: FileDialogBuilder) -> Self { - let mut builder = FileDialog::new(); + let mut builder = AsyncFileDialog::new(); if let Some(title) = d.title { - builder = builder.set_title(&title); + builder = builder.set_title(title); } if let Some(starting_directory) = d.starting_directory { builder = builder.set_directory(starting_directory); } if let Some(file_name) = d.file_name { - builder = builder.set_file_name(&file_name); + builder = builder.set_file_name(file_name); } for filter in d.filters { let v: Vec<&str> = filter.extensions.iter().map(|x| &**x).collect(); @@ -134,85 +98,113 @@ impl From> for FileDialog { } #[cfg(desktop)] if let Some(parent) = d.parent { - builder = builder.set_parent(&WindowHandle(parent)); + builder = builder.set_parent(&parent); } + builder = builder.set_can_create_directories(d.can_create_directories.unwrap_or(true)); + builder } } -impl From> for MessageDialog { +impl From for rfd::MessageButtons { + fn from(value: MessageDialogButtons) -> Self { + match value { + MessageDialogButtons::Ok => Self::Ok, + MessageDialogButtons::OkCancel => Self::OkCancel, + MessageDialogButtons::YesNo => Self::YesNo, + MessageDialogButtons::OkCustom(ok) => Self::OkCustom(ok), + MessageDialogButtons::OkCancelCustom(ok, cancel) => Self::OkCancelCustom(ok, cancel), + } + } +} + +impl From> for AsyncMessageDialog { fn from(d: MessageDialogBuilder) -> Self { - let mut dialog = MessageDialog::new() + let mut dialog = AsyncMessageDialog::new() .set_title(&d.title) .set_description(&d.message) - .set_level(d.kind.into()); - - let buttons = match (d.ok_button_label, d.cancel_button_label) { - (Some(ok), Some(cancel)) => Some(rfd::MessageButtons::OkCancelCustom(ok, cancel)), - (Some(ok), None) => Some(rfd::MessageButtons::OkCustom(ok)), - (None, Some(cancel)) => Some(rfd::MessageButtons::OkCancelCustom(OK.into(), cancel)), - (None, None) => None, - }; - if let Some(buttons) = buttons { - dialog = dialog.set_buttons(buttons); - } + .set_level(d.kind.into()) + .set_buttons(d.buttons.into()); if let Some(parent) = d.parent { - dialog = dialog.set_parent(&WindowHandle(parent)); + dialog = dialog.set_parent(&parent); } dialog } } -pub fn pick_file) + Send + 'static>( +pub fn pick_file) + Send + 'static>( dialog: FileDialogBuilder, f: F, ) { - #[cfg(not(target_os = "linux"))] - let f = |path: Option| f(path.map(|p| p.path().to_path_buf())); - run_file_dialog!(FileDialog::from(dialog).pick_file(), f) + let f = |path: Option| f(path.map(|p| p.path().to_path_buf().into())); + let handle = dialog.dialog.app_handle().to_owned(); + let _ = handle.run_on_main_thread(move || { + let dialog = AsyncFileDialog::from(dialog).pick_file(); + std::thread::spawn(move || f(tauri::async_runtime::block_on(dialog))); + }); } -pub fn pick_files>) + Send + 'static>( +pub fn pick_files>) + Send + 'static>( dialog: FileDialogBuilder, f: F, ) { - #[cfg(not(target_os = "linux"))] let f = |paths: Option>| { - f(paths.map(|list| list.into_iter().map(|p| p.path().to_path_buf()).collect())) + f(paths.map(|list| { + list.into_iter() + .map(|p| p.path().to_path_buf().into()) + .collect() + })) }; - run_file_dialog!(FileDialog::from(dialog).pick_files(), f) + let handle = dialog.dialog.app_handle().to_owned(); + let _ = handle.run_on_main_thread(move || { + let dialog = AsyncFileDialog::from(dialog).pick_files(); + std::thread::spawn(move || f(tauri::async_runtime::block_on(dialog))); + }); } -pub fn pick_folder) + Send + 'static>( +pub fn pick_folder) + Send + 'static>( dialog: FileDialogBuilder, f: F, ) { - #[cfg(not(target_os = "linux"))] - let f = |path: Option| f(path.map(|p| p.path().to_path_buf())); - run_file_dialog!(FileDialog::from(dialog).pick_folder(), f) + let f = |path: Option| f(path.map(|p| p.path().to_path_buf().into())); + let handle = dialog.dialog.app_handle().to_owned(); + let _ = handle.run_on_main_thread(move || { + let dialog = AsyncFileDialog::from(dialog).pick_folder(); + std::thread::spawn(move || f(tauri::async_runtime::block_on(dialog))); + }); } -pub fn pick_folders>) + Send + 'static>( +pub fn pick_folders>) + Send + 'static>( dialog: FileDialogBuilder, f: F, ) { - #[cfg(not(target_os = "linux"))] let f = |paths: Option>| { - f(paths.map(|list| list.into_iter().map(|p| p.path().to_path_buf()).collect())) + f(paths.map(|list| { + list.into_iter() + .map(|p| p.path().to_path_buf().into()) + .collect() + })) }; - run_file_dialog!(FileDialog::from(dialog).pick_folders(), f) + let handle = dialog.dialog.app_handle().to_owned(); + let _ = handle.run_on_main_thread(move || { + let dialog = AsyncFileDialog::from(dialog).pick_folders(); + std::thread::spawn(move || f(tauri::async_runtime::block_on(dialog))); + }); } -pub fn save_file) + Send + 'static>( +pub fn save_file) + Send + 'static>( dialog: FileDialogBuilder, f: F, ) { - #[cfg(not(target_os = "linux"))] - let f = |path: Option| f(path.map(|p| p.path().to_path_buf())); - run_file_dialog!(FileDialog::from(dialog).save_file(), f) + let f = |path: Option| f(path.map(|p| p.path().to_path_buf().into())); + let handle = dialog.dialog.app_handle().to_owned(); + let _ = handle.run_on_main_thread(move || { + let dialog = AsyncFileDialog::from(dialog).save_file(); + std::thread::spawn(move || f(tauri::async_runtime::block_on(dialog))); + }); } /// Shows a message dialog @@ -220,5 +212,24 @@ pub fn show_message_dialog( dialog: MessageDialogBuilder, f: F, ) { - run_dialog!(MessageDialog::from(dialog).show(), f); + use rfd::MessageDialogResult; + + let ok_label = match &dialog.buttons { + MessageDialogButtons::OkCustom(ok) => Some(ok.clone()), + MessageDialogButtons::OkCancelCustom(ok, _) => Some(ok.clone()), + _ => None, + }; + let f = move |res| { + f(match res { + MessageDialogResult::Ok | MessageDialogResult::Yes => true, + MessageDialogResult::Custom(s) => ok_label.map_or(s == OK, |ok_label| ok_label == s), + _ => false, + }); + }; + + let handle = dialog.dialog.app_handle().to_owned(); + let _ = handle.run_on_main_thread(move || { + let dialog = AsyncMessageDialog::from(dialog).show(); + std::thread::spawn(move || f(tauri::async_runtime::block_on(dialog))); + }); } diff --git a/plugins/dialog/src/error.rs b/plugins/dialog/src/error.rs index 069cd55c..0c3ed5b8 100644 --- a/plugins/dialog/src/error.rs +++ b/plugins/dialog/src/error.rs @@ -7,6 +7,7 @@ use serde::{ser::Serializer, Serialize}; pub type Result = std::result::Result; #[derive(Debug, thiserror::Error)] +#[non_exhaustive] pub enum Error { #[error(transparent)] Tauri(#[from] tauri::Error), @@ -18,9 +19,6 @@ pub enum Error { #[cfg(mobile)] #[error("Folder picker is not implemented on mobile")] FolderPickerNotImplemented, - #[cfg(mobile)] - #[error("File save dialog is not implemented on mobile")] - FileSaveDialogNotImplemented, #[error(transparent)] Fs(#[from] tauri_plugin_fs::Error), } diff --git a/plugins/dialog/src/init-iife.js b/plugins/dialog/src/init-iife.js index fcfd45ca..bcdf3f56 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=async function(i){return await n("plugin:dialog|confirm",{message:i.toString()})}}(); diff --git a/plugins/dialog/src/lib.rs b/plugins/dialog/src/lib.rs index 325ba92d..2ef1c1ea 100644 --- a/plugins/dialog/src/lib.rs +++ b/plugins/dialog/src/lib.rs @@ -2,8 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -//! [![](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/dialog/banner.png)](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/dialog) -//! //! Native system dialogs for opening and saving files along with message dialogs. #![doc( @@ -11,7 +9,7 @@ html_favicon_url = "https://github.com/tauri-apps/tauri/raw/dev/app-icon.png" )] -use serde::{Deserialize, Serialize}; +use serde::Serialize; use tauri::{ plugin::{Builder, TauriPlugin}, Manager, Runtime, @@ -24,6 +22,7 @@ use std::{ pub use models::*; +pub use tauri_plugin_fs::FilePath; #[cfg(desktop)] mod desktop; #[cfg(mobile)] @@ -40,6 +39,16 @@ use desktop::*; #[cfg(mobile)] use mobile::*; +#[cfg(desktop)] +pub use desktop::Dialog; +#[cfg(mobile)] +pub use mobile::Dialog; + +pub(crate) const OK: &str = "Ok"; +pub(crate) const CANCEL: &str = "Cancel"; +pub(crate) const YES: &str = "Yes"; +pub(crate) const NO: &str = "No"; + macro_rules! blocking_fn { ($self:ident, $fn:ident) => {{ let (tx, rx) = sync_channel(0); @@ -51,7 +60,7 @@ macro_rules! blocking_fn { }}; } -/// Extensions to [`tauri::App`], [`tauri::AppHandle`] and [`tauri::Window`] to access the dialog APIs. +/// Extensions to [`tauri::App`], [`tauri::AppHandle`], [`tauri::WebviewWindow`], [`tauri::Webview`] and [`tauri::Window`] to access the dialog APIs. pub trait DialogExt { fn dialog(&self) -> &Dialog; } @@ -63,6 +72,85 @@ impl> crate::DialogExt for T { } impl Dialog { + /// Create a new messaging dialog builder. + /// The dialog can optionally ask the user for confirmation or include an OK button. + /// + /// # Examples + /// + /// - Message dialog: + /// + /// ``` + /// use tauri_plugin_dialog::DialogExt; + /// + /// tauri::Builder::default() + /// .setup(|app| { + /// app + /// .dialog() + /// .message("Tauri is Awesome!") + /// .show(|_| { + /// println!("dialog closed"); + /// }); + /// Ok(()) + /// }); + /// ``` + /// + /// - Ask dialog: + /// + /// ``` + /// use tauri_plugin_dialog::{DialogExt, MessageDialogButtons}; + /// + /// tauri::Builder::default() + /// .setup(|app| { + /// app.dialog() + /// .message("Are you sure?") + /// .buttons(MessageDialogButtons::OkCancelCustom("Yes", "No")) + /// .show(|yes| { + /// println!("user said {}", if yes { "yes" } else { "no" }); + /// }); + /// Ok(()) + /// }); + /// ``` + /// + /// - Message dialog with OK button: + /// + /// ``` + /// use tauri_plugin_dialog::{DialogExt, MessageDialogButtons}; + /// + /// tauri::Builder::default() + /// .setup(|app| { + /// app.dialog() + /// .message("Job completed successfully") + /// .buttons(MessageDialogButtons::Ok) + /// .show(|_| { + /// println!("dialog closed"); + /// }); + /// Ok(()) + /// }); + /// ``` + /// + /// # `show` vs `blocking_show` + /// + /// The dialog builder includes two separate APIs for rendering the dialog: `show` and `blocking_show`. + /// The `show` function is asynchronous and takes a closure to be executed when the dialog is closed. + /// To block the current thread until the user acted on the dialog, you can use `blocking_show`, + /// but note that it cannot be executed on the main thread as it will freeze your application. + /// + /// ``` + /// use tauri_plugin_dialog::{DialogExt, MessageDialogButtons}; + /// + /// tauri::Builder::default() + /// .setup(|app| { + /// let handle = app.handle().clone(); + /// std::thread::spawn(move || { + /// let yes = handle.dialog() + /// .message("Are you sure?") + /// .buttons(MessageDialogButtons::OkCancelCustom("Yes", "No")) + /// .blocking_show(); + /// }); + /// + /// Ok(()) + /// }); + /// ``` pub fn message(&self, message: impl Into) -> MessageDialogBuilder { MessageDialogBuilder::new( self.clone(), @@ -71,6 +159,7 @@ impl Dialog { ) } + /// Creates a new builder for dialogs that lets the user select file(s) or folder(s). pub fn file(&self) -> FileDialogBuilder { FileDialogBuilder::new(self.clone()) } @@ -84,13 +173,7 @@ pub fn init() -> TauriPlugin { // Dialogs are implemented natively on Android #[cfg(not(target_os = "android"))] { - let mut init_script = include_str!("init-iife.js").to_string(); - init_script.push_str(include_str!("api-iife.js")); - builder = builder.js_init_script(init_script); - } - #[cfg(target_os = "android")] - { - builder = builder.js_init_script(include_str!("api-iife.js").to_string()); + builder = builder.js_init_script(include_str!("init-iife.js").to_string()); } builder @@ -119,10 +202,9 @@ pub struct MessageDialogBuilder { pub(crate) title: String, pub(crate) message: String, pub(crate) kind: MessageDialogKind, - pub(crate) ok_button_label: Option, - pub(crate) cancel_button_label: Option, + pub(crate) buttons: MessageDialogButtons, #[cfg(desktop)] - pub(crate) parent: Option, + pub(crate) parent: Option, } /// Payload for the message dialog mobile API. @@ -133,8 +215,8 @@ pub(crate) struct MessageDialogPayload<'a> { title: &'a String, message: &'a String, kind: &'a MessageDialogKind, - ok_button_label: &'a Option, - cancel_button_label: &'a Option, + ok_button_label: Option<&'a str>, + cancel_button_label: Option<&'a str>, } // raw window handle :( @@ -148,8 +230,7 @@ impl MessageDialogBuilder { title: title.into(), message: message.into(), kind: Default::default(), - ok_button_label: None, - cancel_button_label: None, + buttons: Default::default(), #[cfg(desktop)] parent: None, } @@ -157,12 +238,21 @@ impl MessageDialogBuilder { #[cfg(mobile)] pub(crate) fn payload(&self) -> MessageDialogPayload<'_> { + let (ok_button_label, cancel_button_label) = match &self.buttons { + MessageDialogButtons::Ok => (Some(OK), None), + MessageDialogButtons::OkCancel => (Some(OK), Some(CANCEL)), + MessageDialogButtons::YesNo => (Some(YES), Some(NO)), + MessageDialogButtons::OkCustom(ok) => (Some(ok.as_str()), Some(CANCEL)), + MessageDialogButtons::OkCancelCustom(ok, cancel) => { + (Some(ok.as_str()), Some(cancel.as_str())) + } + }; MessageDialogPayload { title: &self.title, message: &self.message, kind: &self.kind, - ok_button_label: &self.ok_button_label, - cancel_button_label: &self.cancel_button_label, + ok_button_label, + cancel_button_label, } } @@ -173,25 +263,25 @@ impl MessageDialogBuilder { } /// Set parent windows explicitly (optional) - /// - /// ## Platform-specific - /// - /// - **Linux:** Unsupported. #[cfg(desktop)] - pub fn parent(mut self, parent: &W) -> Self { - self.parent.replace(parent.raw_window_handle()); - self - } - - /// Sets the label for the OK button. - pub fn ok_button_label(mut self, label: impl Into) -> Self { - self.ok_button_label.replace(label.into()); + pub fn parent( + mut self, + parent: &W, + ) -> Self { + if let (Ok(window_handle), Ok(display_handle)) = + (parent.window_handle(), parent.display_handle()) + { + self.parent.replace(crate::desktop::WindowHandle::new( + window_handle.as_raw(), + display_handle.as_raw(), + )); + } self } - /// Sets the label for the Cancel button. - pub fn cancel_button_label(mut self, label: impl Into) -> Self { - self.cancel_button_label.replace(label.into()); + /// Sets the dialog buttons. + pub fn buttons(mut self, buttons: MessageDialogButtons) -> Self { + self.buttons = buttons; self } @@ -216,38 +306,6 @@ impl MessageDialogBuilder { blocking_fn!(self, show) } } - -#[derive(Debug, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct FileResponse { - pub base64_data: Option, - pub duration: Option, - pub height: Option, - pub width: Option, - pub mime_type: Option, - pub modified_at: Option, - pub name: Option, - pub path: PathBuf, - pub size: u64, -} - -impl FileResponse { - #[cfg(desktop)] - fn new(path: PathBuf) -> Self { - Self { - base64_data: None, - duration: None, - height: None, - width: None, - mime_type: None, - modified_at: None, - name: path.file_name().map(|f| f.to_string_lossy().into_owned()), - path, - size: 0, - } - } -} - #[derive(Debug, Serialize)] pub(crate) struct Filter { pub name: String, @@ -265,14 +323,16 @@ pub struct FileDialogBuilder { pub(crate) starting_directory: Option, pub(crate) file_name: Option, pub(crate) title: Option, + pub(crate) can_create_directories: Option, #[cfg(desktop)] - pub(crate) parent: Option, + pub(crate) parent: Option, } #[cfg(mobile)] #[derive(Serialize)] #[serde(rename_all = "camelCase")] pub(crate) struct FileDialogPayload<'a> { + file_name: &'a Option, filters: &'a Vec, multiple: bool, } @@ -289,6 +349,7 @@ impl FileDialogBuilder { starting_directory: None, file_name: None, title: None, + can_create_directories: None, #[cfg(desktop)] parent: None, } @@ -297,6 +358,7 @@ impl FileDialogBuilder { #[cfg(mobile)] pub(crate) fn payload(&self, multiple: bool) -> FileDialogPayload<'_> { FileDialogPayload { + file_name: &self.file_name, filters: &self.filters, multiple, } @@ -329,8 +391,20 @@ impl FileDialogBuilder { /// Sets the parent window of the dialog. #[cfg(desktop)] #[must_use] - pub fn set_parent(mut self, parent: &W) -> Self { - self.parent.replace(parent.raw_window_handle()); + pub fn set_parent< + W: raw_window_handle::HasWindowHandle + raw_window_handle::HasDisplayHandle, + >( + mut self, + parent: &W, + ) -> Self { + if let (Ok(window_handle), Ok(display_handle)) = + (parent.window_handle(), parent.display_handle()) + { + self.parent.replace(crate::desktop::WindowHandle::new( + window_handle.as_raw(), + display_handle.as_raw(), + )); + } self } @@ -341,6 +415,12 @@ impl FileDialogBuilder { self } + /// Set whether it should be possible to create new directories in the dialog. Enabled by default. **macOS only**. + pub fn set_can_create_directories(mut self, can: bool) -> Self { + self.can_create_directories.replace(can); + self + } + /// Shows the dialog to select a single file. /// This is not a blocking operation, /// and should be used when running on the main thread to avoid deadlocks with the event loop. @@ -349,21 +429,18 @@ impl FileDialogBuilder { /// /// # Examples /// - /// ```rust,no_run + /// ``` /// use tauri_plugin_dialog::DialogExt; /// tauri::Builder::default() - /// .build(tauri::generate_context!("test/tauri.conf.json")) - /// .expect("failed to build tauri app") - /// .run(|app, _event| { + /// .setup(|app| { /// app.dialog().file().pick_file(|file_path| { /// // do something with the optional file path here /// // the file path is `None` if the user closed the dialog - /// }) - /// }) + /// }); + /// Ok(()) + /// }); /// ``` - pub fn pick_file) + Send + 'static>(self, f: F) { - #[cfg(desktop)] - let f = |path: Option| f(path.map(FileResponse::new)); + pub fn pick_file) + Send + 'static>(self, f: F) { pick_file(self, f) } @@ -371,29 +448,44 @@ impl FileDialogBuilder { /// This is not a blocking operation, /// and should be used when running on the main thread to avoid deadlocks with the event loop. /// + /// # Reading the files + /// + /// The file paths cannot be read directly on Android as they are behind a content URI. + /// The recommended way to read the files is using the [`fs`](https://v2.tauri.app/plugin/file-system/) plugin: + /// + /// ``` + /// use tauri_plugin_dialog::DialogExt; + /// use tauri_plugin_fs::FsExt; + /// tauri::Builder::default() + /// .setup(|app| { + /// let handle = app.handle().clone(); + /// app.dialog().file().pick_file(move |file_path| { + /// let Some(path) = file_path else { return }; + /// let Ok(contents) = handle.fs().read_to_string(path) else { + /// eprintln!("failed to read file, "); + /// return; + /// }; + /// }); + /// Ok(()) + /// }); + /// ``` + /// + /// See for more information. + /// /// # Examples /// - /// ```rust,no_run + /// ``` /// use tauri_plugin_dialog::DialogExt; /// tauri::Builder::default() - /// .build(tauri::generate_context!("test/tauri.conf.json")) - /// .expect("failed to build tauri app") - /// .run(|app, _event| { + /// .setup(|app| { /// app.dialog().file().pick_files(|file_paths| { /// // do something with the optional file paths here /// // the file paths value is `None` if the user closed the dialog - /// }) - /// }) + /// }); + /// Ok(()) + /// }); /// ``` - pub fn pick_files>) + Send + 'static>(self, f: F) { - #[cfg(desktop)] - let f = |paths: Option>| { - f(paths.map(|p| { - p.into_iter() - .map(FileResponse::new) - .collect::>() - })) - }; + pub fn pick_files>) + Send + 'static>(self, f: F) { pick_files(self, f) } @@ -403,20 +495,19 @@ impl FileDialogBuilder { /// /// # Examples /// - /// ```rust,no_run + /// ``` /// use tauri_plugin_dialog::DialogExt; /// tauri::Builder::default() - /// .build(tauri::generate_context!("test/tauri.conf.json")) - /// .expect("failed to build tauri app") - /// .run(|app, _event| { + /// .setup(|app| { /// app.dialog().file().pick_folder(|folder_path| { /// // do something with the optional folder path here /// // the folder path is `None` if the user closed the dialog - /// }) - /// }) + /// }); + /// Ok(()) + /// }); /// ``` #[cfg(desktop)] - pub fn pick_folder) + Send + 'static>(self, f: F) { + pub fn pick_folder) + Send + 'static>(self, f: F) { pick_folder(self, f) } @@ -426,20 +517,19 @@ impl FileDialogBuilder { /// /// # Examples /// - /// ```rust,no_run + /// ``` /// use tauri_plugin_dialog::DialogExt; /// tauri::Builder::default() - /// .build(tauri::generate_context!("test/tauri.conf.json")) - /// .expect("failed to build tauri app") - /// .run(|app, _event| { + /// .setup(|app| { /// app.dialog().file().pick_folders(|file_paths| { /// // do something with the optional folder paths here /// // the folder paths value is `None` if the user closed the dialog - /// }) - /// }) + /// }); + /// Ok(()) + /// }); /// ``` #[cfg(desktop)] - pub fn pick_folders>) + Send + 'static>(self, f: F) { + pub fn pick_folders>) + Send + 'static>(self, f: F) { pick_folders(self, f) } @@ -450,20 +540,18 @@ impl FileDialogBuilder { /// /// # Examples /// - /// ```rust,no_run + /// ``` /// use tauri_plugin_dialog::DialogExt; /// tauri::Builder::default() - /// .build(tauri::generate_context!("test/tauri.conf.json")) - /// .expect("failed to build tauri app") - /// .run(|app, _event| { + /// .setup(|app| { /// app.dialog().file().save_file(|file_path| { /// // do something with the optional file path here /// // the file path is `None` if the user closed the dialog - /// }) - /// }) + /// }); + /// Ok(()) + /// }); /// ``` - #[cfg(desktop)] - pub fn save_file) + Send + 'static>(self, f: F) { + pub fn save_file) + Send + 'static>(self, f: F) { save_file(self, f) } } @@ -476,7 +564,7 @@ impl FileDialogBuilder { /// /// # Examples /// - /// ```rust,no_run + /// ``` /// use tauri_plugin_dialog::DialogExt; /// #[tauri::command] /// async fn my_command(app: tauri::AppHandle) { @@ -485,7 +573,7 @@ impl FileDialogBuilder { /// // the file path is `None` if the user closed the dialog /// } /// ``` - pub fn blocking_pick_file(self) -> Option { + pub fn blocking_pick_file(self) -> Option { blocking_fn!(self, pick_file) } @@ -495,7 +583,7 @@ impl FileDialogBuilder { /// /// # Examples /// - /// ```rust,no_run + /// ``` /// use tauri_plugin_dialog::DialogExt; /// #[tauri::command] /// async fn my_command(app: tauri::AppHandle) { @@ -504,7 +592,7 @@ impl FileDialogBuilder { /// // the file paths value is `None` if the user closed the dialog /// } /// ``` - pub fn blocking_pick_files(self) -> Option> { + pub fn blocking_pick_files(self) -> Option> { blocking_fn!(self, pick_files) } @@ -514,7 +602,7 @@ impl FileDialogBuilder { /// /// # Examples /// - /// ```rust,no_run + /// ``` /// use tauri_plugin_dialog::DialogExt; /// #[tauri::command] /// async fn my_command(app: tauri::AppHandle) { @@ -524,7 +612,7 @@ impl FileDialogBuilder { /// } /// ``` #[cfg(desktop)] - pub fn blocking_pick_folder(self) -> Option { + pub fn blocking_pick_folder(self) -> Option { blocking_fn!(self, pick_folder) } @@ -534,7 +622,7 @@ impl FileDialogBuilder { /// /// # Examples /// - /// ```rust,no_run + /// ``` /// use tauri_plugin_dialog::DialogExt; /// #[tauri::command] /// async fn my_command(app: tauri::AppHandle) { @@ -544,7 +632,7 @@ impl FileDialogBuilder { /// } /// ``` #[cfg(desktop)] - pub fn blocking_pick_folders(self) -> Option> { + pub fn blocking_pick_folders(self) -> Option> { blocking_fn!(self, pick_folders) } @@ -554,7 +642,7 @@ impl FileDialogBuilder { /// /// # Examples /// - /// ```rust,no_run + /// ``` /// use tauri_plugin_dialog::DialogExt; /// #[tauri::command] /// async fn my_command(app: tauri::AppHandle) { @@ -563,8 +651,7 @@ impl FileDialogBuilder { /// // the file path is `None` if the user closed the dialog /// } /// ``` - #[cfg(desktop)] - pub fn blocking_save_file(self) -> Option { + pub fn blocking_save_file(self) -> Option { blocking_fn!(self, save_file) } } diff --git a/plugins/dialog/src/mobile.rs b/plugins/dialog/src/mobile.rs index 289cbb7e..b73def4f 100644 --- a/plugins/dialog/src/mobile.rs +++ b/plugins/dialog/src/mobile.rs @@ -8,7 +8,7 @@ use tauri::{ AppHandle, Runtime, }; -use crate::{FileDialogBuilder, FileResponse, MessageDialogBuilder}; +use crate::{FileDialogBuilder, FilePath, MessageDialogBuilder}; #[cfg(target_os = "android")] const PLUGIN_IDENTIFIER: &str = "app.tauri.dialog"; @@ -46,10 +46,15 @@ impl Dialog { #[derive(Debug, Deserialize)] struct FilePickerResponse { - files: Vec, + files: Vec, } -pub fn pick_file) + Send + 'static>( +#[derive(Debug, Deserialize)] +struct SaveFileResponse { + file: FilePath, +} + +pub fn pick_file) + Send + 'static>( dialog: FileDialogBuilder, f: F, ) { @@ -66,7 +71,7 @@ pub fn pick_file) + Send + 'static>( }); } -pub fn pick_files>) + Send + 'static>( +pub fn pick_files>) + Send + 'static>( dialog: FileDialogBuilder, f: F, ) { @@ -83,6 +88,23 @@ pub fn pick_files>) + Send + 'sta }); } +pub fn save_file) + Send + 'static>( + dialog: FileDialogBuilder, + f: F, +) { + std::thread::spawn(move || { + let res = dialog + .dialog + .0 + .run_mobile_plugin::("saveFileDialog", dialog.payload(false)); + if let Ok(response) = res { + f(Some(response.file)) + } else { + f(None) + } + }); +} + #[derive(Debug, Deserialize)] struct ShowMessageDialogResponse { #[allow(dead_code)] diff --git a/plugins/dialog/src/models.rs b/plugins/dialog/src/models.rs index fa9224e1..d6452bce 100644 --- a/plugins/dialog/src/models.rs +++ b/plugins/dialog/src/models.rs @@ -49,3 +49,20 @@ impl Serialize for MessageDialogKind { } } } + +/// Set of button that will be displayed on the dialog +#[non_exhaustive] +#[derive(Debug, Default, Clone)] +pub enum MessageDialogButtons { + #[default] + /// A single `Ok` button with OS default dialog text + Ok, + /// 2 buttons `Ok` and `Cancel` with OS default dialog texts + OkCancel, + /// 2 buttons `Yes` and `No` with OS default dialog texts + YesNo, + /// A single `Ok` button with custom text + OkCustom(String), + /// 2 buttons `Ok` and `Cancel` with custom texts + OkCancelCustom(String, String), +} diff --git a/plugins/dialog/test/tauri.conf.json b/plugins/dialog/test/tauri.conf.json index 6b015c11..4d0ae021 100644 --- a/plugins/dialog/test/tauri.conf.json +++ b/plugins/dialog/test/tauri.conf.json @@ -1,15 +1,10 @@ { - "$schema": "../../../node_modules/.pnpm/@tauri-apps+cli@2.0.0-alpha.16/node_modules/@tauri-apps/cli/schema.json", + "identifier": "app.tauri.example", "build": { - "distDir": ".", - "devPath": "http://localhost:4000" + "frontendDist": ".", + "devUrl": "http://localhost:4000" }, - "tauri": { - "bundle": { - "identifier": "studio.tauri.example", - "active": true, - "icon": ["../../../examples/api/src-tauri/icons/icon.png"] - }, + "app": { "windows": [ { "title": "Tauri App" @@ -18,5 +13,9 @@ "security": { "csp": "default-src blob: data: filesystem: ws: wss: http: https: tauri: http://tauri.localhost 'unsafe-eval' 'unsafe-inline' 'self'" } + }, + "bundle": { + "active": true, + "icon": ["../../../examples/api/src-tauri/icons/icon.png"] } } diff --git a/plugins/fs/.gitignore b/plugins/fs/.gitignore deleted file mode 100644 index b512c09d..00000000 --- a/plugins/fs/.gitignore +++ /dev/null @@ -1 +0,0 @@ -node_modules \ No newline at end of file diff --git a/plugins/fs/CHANGELOG.md b/plugins/fs/CHANGELOG.md index c3abb184..85bff34c 100644 --- a/plugins/fs/CHANGELOG.md +++ b/plugins/fs/CHANGELOG.md @@ -1,5 +1,178 @@ # Changelog +## \[2.3.0] + +- [`dac4d537`](https://github.com/tauri-apps/plugins-workspace/commit/dac4d53724bb3430a00a3f0119857cba32a031e8) ([#2613](https://github.com/tauri-apps/plugins-workspace/pull/2613) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Reduce the overhead of `watch` and `unwatch` + +## \[2.2.1] + +### bug + +- [`831c35ff`](https://github.com/tauri-apps/plugins-workspace/commit/831c35ff3940e841fe4418bb4cb104038b03304b) ([#2550](https://github.com/tauri-apps/plugins-workspace/pull/2550)) Fix `writeFile` ReadableStream handling due to missing async iterator support on macOS platform + +## \[2.2.0] + +- [`3a79266b`](https://github.com/tauri-apps/plugins-workspace/commit/3a79266b8cf96a55b1ae6339d725567d45a44b1d) ([#2173](https://github.com/tauri-apps/plugins-workspace/pull/2173) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Bumped all plugins to `v2.2.0`. From now, the versions for the Rust and JavaScript packages of each plugin will be in sync with each other. + +## \[2.0.4] + +- [`77b85507`](https://github.com/tauri-apps/plugins-workspace/commit/77b855074aad612f2b28e6a3b5881fac767a05ae) ([#2171](https://github.com/tauri-apps/plugins-workspace/pull/2171) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Fixed docs.rs build. + +## \[2.0.3] + +- [`ed981027`](https://github.com/tauri-apps/plugins-workspace/commit/ed981027dd4fba7d0e2f836eb5db34d344388d73) ([#1962](https://github.com/tauri-apps/plugins-workspace/pull/1962) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Improve performance of `readTextFile` and `readTextFileLines` APIs +- [`3e78173d`](https://github.com/tauri-apps/plugins-workspace/commit/3e78173df9ce90aa3b19e1f36d1f8712c5020fb6) ([#2018](https://github.com/tauri-apps/plugins-workspace/pull/2018) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Fix `readDir` function failing to read directories that contain broken symlinks. +- [`5092ea5e`](https://github.com/tauri-apps/plugins-workspace/commit/5092ea5e89817c0550d09b0a4ad17bf1253b23df) ([#1964](https://github.com/tauri-apps/plugins-workspace/pull/1964) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Add support for using `ReadableStream` with `writeFile` API. + +## \[2.0.2] + +- [`77149dc4`](https://github.com/tauri-apps/plugins-workspace/commit/77149dc4320d26b413e4a6bbe82c654367c51b32) ([#1965](https://github.com/tauri-apps/plugins-workspace/pull/1965) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Fix `writeTextFile` converting UTF-8 characters (for example `äöü`) in the given path into replacement character (`�`) + +## \[2.0.3] + +- [`14cee64c`](https://github.com/tauri-apps/plugins-workspace/commit/14cee64c82a72655ae6a4ac0892736a2959dbda5) ([#1958](https://github.com/tauri-apps/plugins-workspace/pull/1958) by [@bWanShiTong](https://github.com/tauri-apps/plugins-workspace/../../bWanShiTong)) Fix compilation on targets with pointer width of `16` or `32` + +## \[2.0.1] + +- [`ae802456`](https://github.com/tauri-apps/plugins-workspace/commit/ae8024565f074f313084777c8b10d1b5e3bbe220) ([#1950](https://github.com/tauri-apps/plugins-workspace/pull/1950) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Improve performance of the `FileHandle.read` and `writeTextFile` APIs. + +## \[2.0.1] + +- [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. + +## \[2.0.0] + +- [`e2c4dfb6`](https://github.com/tauri-apps/plugins-workspace/commit/e2c4dfb6af43e5dd8d9ceba232c315f5febd55c1) Update to tauri v2 stable release. + +## \[2.0.0-rc.6] + +- [`fc9b189e`](https://github.com/tauri-apps/plugins-workspace/commit/fc9b189e83a29bd750714ec6336133c6eabdfa20) ([#1837](https://github.com/tauri-apps/plugins-workspace/pull/1837) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Fix failing to deserialize capability file when using an OS specific path in the scope that is not available on the current OS. + +## \[2.0.0-rc.5] + +- [`cc03ccf5`](https://github.com/tauri-apps/plugins-workspace/commit/cc03ccf5e0e4be8bbf50bbdebe957c84be7f779b) ([#1774](https://github.com/tauri-apps/plugins-workspace/pull/1774)) Fix `scope-app`, `scope-app-recursive` and `scope-index` not properly enabling the application paths. + +## \[2.0.0-rc.4] + +- [`9291e4d2`](https://github.com/tauri-apps/plugins-workspace/commit/9291e4d2caa31c883c71e55f2193bd8754d72f03) ([#1640](https://github.com/tauri-apps/plugins-workspace/pull/1640) by [@SRutile](https://github.com/tauri-apps/plugins-workspace/../../SRutile)) Support any UTF-8 character in the writeFile API. + +## \[2.0.0-rc.3] + +- [`a2fe5551`](https://github.com/tauri-apps/plugins-workspace/commit/a2fe55512f908dd11c814ce021d164f01677572a) ([#1727](https://github.com/tauri-apps/plugins-workspace/pull/1727) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Add utility methods on `FilePath` and `SafeFilePath` enums which are: + + - `path` + - `simplified` + - `into_path` +- [`a2fe5551`](https://github.com/tauri-apps/plugins-workspace/commit/a2fe55512f908dd11c814ce021d164f01677572a) ([#1727](https://github.com/tauri-apps/plugins-workspace/pull/1727) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Implement `Serialize`, `Deserialize`, `From`, `TryFrom` and `FromStr` traits for `FilePath` and `SafeFilePath` enums. +- [`a2fe5551`](https://github.com/tauri-apps/plugins-workspace/commit/a2fe55512f908dd11c814ce021d164f01677572a) ([#1727](https://github.com/tauri-apps/plugins-workspace/pull/1727) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Mark `Error` enum as `#[non_exhuastive]`. +- [`a2fe5551`](https://github.com/tauri-apps/plugins-workspace/commit/a2fe55512f908dd11c814ce021d164f01677572a) ([#1727](https://github.com/tauri-apps/plugins-workspace/pull/1727) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Add `SafeFilePath` enum. + +## \[2.0.0-rc.2] + +- [`f7280c88`](https://github.com/tauri-apps/plugins-workspace/commit/f7280c88309cdf1f2330574fec31e26e01e9cdbd) ([#1710](https://github.com/tauri-apps/plugins-workspace/pull/1710) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Fix can't use Windows paths like `C:/Users/UserName/file.txt` + +### bug + +- [`51819c60`](https://github.com/tauri-apps/plugins-workspace/commit/51819c601f863cbfbd11809a1c4cf9df5a20b1e0) ([#1708](https://github.com/tauri-apps/plugins-workspace/pull/1708) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Fixes `writeFile` command implementation on Android. + +## \[2.0.0-rc.2] + +- [`e2e97db5`](https://github.com/tauri-apps/plugins-workspace/commit/e2e97db51983267f5be84d4f6f0278d58834d1f5) ([#1701](https://github.com/tauri-apps/plugins-workspace/pull/1701) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri 2.0.0-rc.8 + +## \[2.0.0-rc.1] + +- [`5f689902`](https://github.com/tauri-apps/plugins-workspace/commit/5f68990297f2cefac4220649a469adb7fa94fe1b) ([#1645](https://github.com/tauri-apps/plugins-workspace/pull/1645) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update documentation. + +## \[2.0.0-rc.0] + +- [`9887d1`](https://github.com/tauri-apps/plugins-workspace/commit/9887d14bd0e971c4c0f5c1188fc4005d3fc2e29e) Update to tauri RC. + +## \[2.0.0-beta.8] + +- [`99d6ac0f`](https://github.com/tauri-apps/plugins-workspace/commit/99d6ac0f9506a6a4a1aa59c728157190a7441af6) ([#1606](https://github.com/tauri-apps/plugins-workspace/pull/1606) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) The JS packages now specify the *minimum* `@tauri-apps/api` version instead of a single exact version. +- [`6de87966`](https://github.com/tauri-apps/plugins-workspace/commit/6de87966ecc00ad9d91c25be452f1f46bd2b7e1f) ([#1597](https://github.com/tauri-apps/plugins-workspace/pull/1597) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Update to tauri beta.25. + +## \[2.0.0-beta.7] + +- [`22a17980`](https://github.com/tauri-apps/plugins-workspace/commit/22a17980ff4f6f8c40adb1b8f4ffc6dae2fe7e30) ([#1537](https://github.com/tauri-apps/plugins-workspace/pull/1537) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri beta.24. + +## \[2.0.0-beta.6] + +- [`76daee7a`](https://github.com/tauri-apps/plugins-workspace/commit/76daee7aafece34de3092c86e531cf9eb1138989) ([#1512](https://github.com/tauri-apps/plugins-workspace/pull/1512) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Update to tauri beta.23. + +## \[2.0.0-beta.5] + +- [`9013854f`](https://github.com/tauri-apps/plugins-workspace/commit/9013854f42a49a230b9dbb9d02774765528a923f)([#1382](https://github.com/tauri-apps/plugins-workspace/pull/1382)) Update to tauri beta.22. + +## \[2.0.0-beta.4] + +- [`430bd6f4`](https://github.com/tauri-apps/plugins-workspace/commit/430bd6f4f379bee5d232ae6b098ae131db7f178a)([#1363](https://github.com/tauri-apps/plugins-workspace/pull/1363)) Update to tauri beta.20. + +## \[2.0.0-beta.3] + +- [`bd1ed590`](https://github.com/tauri-apps/plugins-workspace/commit/bd1ed5903ffcce5500310dac1e59e8c67674ef1e)([#1237](https://github.com/tauri-apps/plugins-workspace/pull/1237)) Update to tauri beta.17. + +## \[2.0.0-beta.6] + +- [`b115fd22`](https://github.com/tauri-apps/plugins-workspace/commit/b115fd22e0da073f5d758c13474ec2106cf78163)([#1221](https://github.com/tauri-apps/plugins-workspace/pull/1221)) Fixes an issue that caused the app to freeze when the `dialog`, `fs`, and `persisted-scope` plugins were used together. + +## \[2.0.0-beta.5] + +- [`bb51a41`](https://github.com/tauri-apps/plugins-workspace/commit/bb51a41d67ebf989e8aedf10c4b1a7f9514d1bdf)([#1168](https://github.com/tauri-apps/plugins-workspace/pull/1168)) **Breaking Change:** All apis that return paths to the frontend will now remove the `\\?\` UNC prefix on Windows. +- [`e3d41f4`](https://github.com/tauri-apps/plugins-workspace/commit/e3d41f4011bd3ea3ce281bb38bbe31d3709f8e0f)([#1191](https://github.com/tauri-apps/plugins-workspace/pull/1191)) Internally use the webview scoped resources table instead of the app one, so other webviews can't access other webviews resources. +- [`e3d41f4`](https://github.com/tauri-apps/plugins-workspace/commit/e3d41f4011bd3ea3ce281bb38bbe31d3709f8e0f)([#1191](https://github.com/tauri-apps/plugins-workspace/pull/1191)) Update for tauri 2.0.0-beta.15. + +## \[2.0.0-beta.4] + +- [`9c2fb93`](https://github.com/tauri-apps/plugins-workspace/commit/9c2fb9306ecd3936a2aef56b3c012899036db098) Enhance the scope type to also allow a plain string representing the path to allow or deny. +- [`772f2bc`](https://github.com/tauri-apps/plugins-workspace/commit/772f2bc3495a4f83f1c3e538cbac6d29cbd7d5ef)([#1136](https://github.com/tauri-apps/plugins-workspace/pull/1136)) Update for tauri 2.0.0-beta.14. + +## \[2.0.0-beta.3] + +- [`cb96aa0`](https://github.com/tauri-apps/plugins-workspace/commit/cb96aa06277f7b864952827ec9fb1e74c8a1f761)([#1082](https://github.com/tauri-apps/plugins-workspace/pull/1082)) Fixes `watch` and `watchImmediate` which previously ignored the `baseDir` parameter. +- [`a04ea2f`](https://github.com/tauri-apps/plugins-workspace/commit/a04ea2f38294d5a3987578283badc8eec87a7752)([#1071](https://github.com/tauri-apps/plugins-workspace/pull/1071)) The global API script is now only added to the binary when the `withGlobalTauri` config is true. + +## \[2.0.0-beta.2] + +- [`7358102`](https://github.com/tauri-apps/plugins-workspace/commit/735810237e21504a027a65a7b3c25fd7e594288a)([#1029](https://github.com/tauri-apps/plugins-workspace/pull/1029)) Fix infinite loop on cargo build operations +- [`99bea25`](https://github.com/tauri-apps/plugins-workspace/commit/99bea2559c2c0648c2519c50a18cd124dacef57b)([#1005](https://github.com/tauri-apps/plugins-workspace/pull/1005)) Update to tauri beta.8. + +## \[2.0.0-beta.1] + +- [`569defb`](https://github.com/tauri-apps/plugins-workspace/commit/569defbe9492e38938554bb7bdc1be9151456d21) Update to tauri beta.4. + +## \[2.0.0-beta.0] + +- [`d198c01`](https://github.com/tauri-apps/plugins-workspace/commit/d198c014863ee260cb0de88a14b7fc4356ef7474)([#862](https://github.com/tauri-apps/plugins-workspace/pull/862)) Update to tauri beta. +- [`ea8eadc`](https://github.com/tauri-apps/plugins-workspace/commit/ea8eadce85b2e3e8eb7eb1a779fc3aa6c1201fa3)([#865](https://github.com/tauri-apps/plugins-workspace/pull/865)) Fix incorrect `create` option default value for `writeFile` and `writeTextFile` which didn't match documentation. +- [`61edbbe`](https://github.com/tauri-apps/plugins-workspace/commit/61edbbec0acda4213ed8684f75a973e8be123a52)([#885](https://github.com/tauri-apps/plugins-workspace/pull/885)) Replace `notify-debouncer-mini` with `notify-debouncer-full`. [(plugins-workspace#885)](https://github.com/tauri-apps/plugins-workspace/pull/885) + +## \[2.0.0-alpha.6] + +- [`85f8419`](https://github.com/tauri-apps/plugins-workspace/commit/85f841968200316958d707db0c39bb115f762471)([#848](https://github.com/tauri-apps/plugins-workspace/pull/848)) Fix `DebouncedEvent` type to correctly represent the actual type. +- [`c601230`](https://github.com/tauri-apps/plugins-workspace/commit/c60123093ddf725af7228494182fed697ff8b021)([#847](https://github.com/tauri-apps/plugins-workspace/pull/847)) Add `createNew` option for `writeFile` and `writeTextFile` to create the file if doesn't exist and fail if it does. +- [`c601230`](https://github.com/tauri-apps/plugins-workspace/commit/c60123093ddf725af7228494182fed697ff8b021)([#847](https://github.com/tauri-apps/plugins-workspace/pull/847)) Truncate files when using `writeFile` and `writeTextFile` with `append: false`. +- [`2e2fc8d`](https://github.com/tauri-apps/plugins-workspace/commit/2e2fc8de69dd8d282b66ec81561d57d8af802dc5)([#857](https://github.com/tauri-apps/plugins-workspace/pull/857)) Fix `invalid args id for command unwatch` error when trying to unwatch a previously watched file or directory. +- [`c601230`](https://github.com/tauri-apps/plugins-workspace/commit/c60123093ddf725af7228494182fed697ff8b021)([#847](https://github.com/tauri-apps/plugins-workspace/pull/847)) Fix panic when using `writeFile` or `writeTextFile` without passing an option object. + +## \[2.0.0-alpha.5] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.13. +- [`69a1fa0`](https://github.com/tauri-apps/plugins-workspace/commit/69a1fa099c3143b6e426492f1c9d9cfbe56d2209)([#751](https://github.com/tauri-apps/plugins-workspace/pull/751)) The `fs` plugin received a major overhaul to add new APIs and changed existing APIs to be closer to Node.js and Deno APIs. + +## \[2.0.0-alpha.4] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.12. +- [`88d260d`](https://github.com/tauri-apps/plugins-workspace/commit/88d260d90130f9df4b9ce00c1ad1bf1e4b30b1c0)([#744](https://github.com/tauri-apps/plugins-workspace/pull/744)) Add second argument to `exists` function to specify base directory. + +## \[2.0.0-alpha.3] + +- [`e438e0a`](https://github.com/tauri-apps/plugins-workspace/commit/e438e0a62d4b430a5159f05f13ecd397dd891a0d)([#676](https://github.com/tauri-apps/plugins-workspace/pull/676)) Update to @tauri-apps/api v2.0.0-alpha.11. + +## \[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.9. + ## \[2.0.0-alpha.2] - [`4e2cef9`](https://github.com/tauri-apps/plugins-workspace/commit/4e2cef9b702bbbb9cf4ee17de50791cb21f1b2a4)([#593](https://github.com/tauri-apps/plugins-workspace/pull/593)) Update to alpha.12. diff --git a/plugins/fs/Cargo.toml b/plugins/fs/Cargo.toml index 8f7f86a1..bd7a3cb5 100644 --- a/plugins/fs/Cargo.toml +++ b/plugins/fs/Cargo.toml @@ -1,24 +1,49 @@ [package] name = "tauri-plugin-fs" -version = "2.0.0-alpha.2" +version = "2.3.0" description = "Access the file system." authors = { workspace = true } license = { workspace = true } edition = { workspace = true } rust-version = { workspace = true } +repository = { workspace = true } +links = "tauri-plugin-fs" [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] + +[package.metadata.platforms.support] +windows = { level = "full", notes = "Apps installed via MSI or NSIS in `perMachine` and `both` mode require admin permissions for write access in `$RESOURCES` folder" } +linux = { level = "full", notes = "No write access to `$RESOURCES` folder" } +macos = { level = "full", notes = "No write access to `$RESOURCES` folder" } +android = { level = "partial", notes = "Access is restricted to Application folder by default" } +ios = { level = "partial", notes = "Access is restricted to Application folder by default" } + +[build-dependencies] +tauri-plugin = { workspace = true, features = ["build"] } +schemars = { workspace = true } +serde = { workspace = true } +toml = "0.8" +tauri-utils = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } +serde_json = { workspace = true } +serde_repr = "0.1" tauri = { workspace = true } thiserror = { workspace = true } +url = { workspace = true } anyhow = "1" -uuid = { version = "1", features = [ "v4" ] } -glob = "0.3" -notify = { version = "5", optional = true, features = [ "serde" ] } -notify-debouncer-mini = { version = "0.2.1", optional = true, features = [ "serde" ] } +glob = { workspace = true } +# TODO: Remove `serialization-compat-6` in v3 +notify = { version = "8", optional = true, features = [ + "serde", + "serialization-compat-6", +] } +notify-debouncer-full = { version = "0.5", optional = true } +dunce = { workspace = true } +percent-encoding = "2" [features] -watch = [ "notify", "notify-debouncer-mini" ] +watch = ["notify", "notify-debouncer-full"] diff --git a/plugins/fs/README.md b/plugins/fs/README.md index 29bd50f1..33031177 100644 --- a/plugins/fs/README.md +++ b/plugins/fs/README.md @@ -2,9 +2,17 @@ Access the file system. +| Platform | Supported | +| -------- | --------- | +| Linux | ✓ | +| Windows | ✓ | +| macOS | ✓ | +| Android | ✓ | +| iOS | ✓ | + ## Install -_This plugin requires a Rust version of at least **1.70**_ +_This plugin requires a Rust version of at least **1.77.2**_ There are three general methods of installation that we can recommend. @@ -18,7 +26,7 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] -tauri-plugin-fs = "2.0.0-alpha" +tauri-plugin-fs = "2.0.0" # alternatively with Git: tauri-plugin-fs = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -46,7 +54,7 @@ yarn add https://github.com/tauri-apps/tauri-plugin-fs#v2 First you need to register the core plugin with Tauri: -`src-tauri/src/main.rs` +`src-tauri/src/lib.rs` ```rust fn main() { @@ -60,15 +68,31 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import { metadata } from "@tauri-apps/plugin-fs"; +import { stat } from '@tauri-apps/plugin-fs' -await metadata("/path/to/file"); +await stat('/path/to/file') ``` ## Contributing PRs accepted. Please make sure to read the Contributing Guide before making a pull request. +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + ## License Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. diff --git a/plugins/fs/SECURITY.md b/plugins/fs/SECURITY.md new file mode 100644 index 00000000..838ed670 --- /dev/null +++ b/plugins/fs/SECURITY.md @@ -0,0 +1,49 @@ +# Security Policy + +**Do not report security vulnerabilities through public GitHub issues.** + +**Please use the [Private Vulnerability Disclosure](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) feature of GitHub.** + +Include as much of the following information: + +- Type of issue (e.g. improper input parsing, privilege escalation, etc.) +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- The distribution affected or used to help us with reproduction of the issue +- Step-by-step instructions to reproduce the issue +- Ideally a reproduction repository +- Impact of the issue, including how an attacker might exploit the issue + +We prefer to receive reports in English. + +## Contact + +Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). + +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). + +## Threat Model + +This plugin possibly allows access to the full filesystem available to the application process. +Depending on the operating system the access is already confined (android/ios) to only certain locations. +In other operating systems like Linux/MacOS/Windows it depends on the installation and packaging method but in most cases full +access is granted. + +To prevent exposure of sensitive locations and data this plugin can be scoped to only allow certain base directories +or only access to specific files or subdirectories. +This scoping effectively affects only calls made from the webviews/frontend code and calls made from rust can always circumvent +the restrictions imposed by the scope. + +The scope is defined at compile time in the used permissions but the user or application developer can grant or revoke access to specific files or folders at runtime by modifying the scope state through the runtime authority, if configured during plugin initialization. + +### Security Assumptions + +- The filesystem access is limited by user permissions +- The operating system filesystem access confinment works as documented +- The scoping mechanism of the Tauri `fs` commands work as intended and has no bypasses +- The user or application developer can grant or revoke access to specific files at runtime by modifying the scope + +#### Out Of Scope + +- Exploits in underlying filesystems +- Exploits in the underlying rust `std::fs` library diff --git a/plugins/deep-link/.gitignore b/plugins/fs/android/.gitignore similarity index 53% rename from plugins/deep-link/.gitignore rename to plugins/fs/android/.gitignore index 1b0b469d..c0f21ec2 100644 --- a/plugins/deep-link/.gitignore +++ b/plugins/fs/android/.gitignore @@ -1 +1,2 @@ +/build /.tauri diff --git a/plugins/fs/android/build.gradle.kts b/plugins/fs/android/build.gradle.kts new file mode 100644 index 00000000..575040aa --- /dev/null +++ b/plugins/fs/android/build.gradle.kts @@ -0,0 +1,45 @@ +plugins { + id("com.android.library") + id("org.jetbrains.kotlin.android") +} + +android { + namespace = "com.plugin.fs" + compileSdk = 34 + + defaultConfig { + minSdk = 21 + targetSdk = 34 + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles("consumer-rules.pro") + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = "1.8" + } +} + +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") + testImplementation("junit:junit:4.13.2") + androidTestImplementation("androidx.test.ext:junit:1.1.5") + androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") + implementation(project(":tauri-android")) +} diff --git a/plugins/fs/android/proguard-rules.pro b/plugins/fs/android/proguard-rules.pro new file mode 100644 index 00000000..481bb434 --- /dev/null +++ b/plugins/fs/android/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/plugins/fs/android/settings.gradle b/plugins/fs/android/settings.gradle new file mode 100644 index 00000000..d7782a40 --- /dev/null +++ b/plugins/fs/android/settings.gradle @@ -0,0 +1,31 @@ +pluginManagement { + repositories { + mavenCentral() + gradlePluginPortal() + google() + } + resolutionStrategy { + eachPlugin { + switch (requested.id.id) { + case "com.android.library": + useVersion("8.0.2") + break + case "org.jetbrains.kotlin.android": + useVersion("1.8.20") + break + } + } + } +} + +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + mavenCentral() + google() + + } +} + +include ':tauri-android' +project(':tauri-android').projectDir = new File('./.tauri/tauri-api') diff --git a/plugins/fs/android/src/androidTest/java/ExampleInstrumentedTest.kt b/plugins/fs/android/src/androidTest/java/ExampleInstrumentedTest.kt new file mode 100644 index 00000000..c3b473f7 --- /dev/null +++ b/plugins/fs/android/src/androidTest/java/ExampleInstrumentedTest.kt @@ -0,0 +1,28 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +package com.plugin.fs + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.plugin.fs", appContext.packageName) + } +} diff --git a/plugins/fs/android/src/main/AndroidManifest.xml b/plugins/fs/android/src/main/AndroidManifest.xml new file mode 100644 index 00000000..9a40236b --- /dev/null +++ b/plugins/fs/android/src/main/AndroidManifest.xml @@ -0,0 +1,3 @@ + + + diff --git a/plugins/fs/android/src/main/java/FsPlugin.kt b/plugins/fs/android/src/main/java/FsPlugin.kt new file mode 100644 index 00000000..877fbf4a --- /dev/null +++ b/plugins/fs/android/src/main/java/FsPlugin.kt @@ -0,0 +1,93 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +package com.plugin.fs + +import android.annotation.SuppressLint +import android.app.Activity +import android.content.res.AssetManager.ACCESS_BUFFER +import android.net.Uri +import android.os.ParcelFileDescriptor +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 java.io.File +import java.io.FileOutputStream +import java.io.IOException +import java.io.InputStream +import java.io.OutputStream + +@InvokeArg +class WriteTextFileArgs { + val uri: String = "" + val content: String = "" +} + +@InvokeArg +class GetFileDescriptorArgs { + lateinit var uri: String + lateinit var mode: String +} + +@TauriPlugin +class FsPlugin(private val activity: Activity): Plugin(activity) { + @SuppressLint("Recycle") + @Command + fun getFileDescriptor(invoke: Invoke) { + val args = invoke.parseArgs(GetFileDescriptorArgs::class.java) + + val res = JSObject() + + if (args.uri.startsWith(app.tauri.TAURI_ASSETS_DIRECTORY_URI)) { + val path = args.uri.substring(app.tauri.TAURI_ASSETS_DIRECTORY_URI.length) + try { + val fd = activity.assets.openFd(path).parcelFileDescriptor?.detachFd() + res.put("fd", fd) + } catch (e: IOException) { + // if the asset is compressed, we cannot open a file descriptor directly + // so we copy it to the cache and get a fd from there + // this is a lot faster than serializing the file and sending it as invoke response + // because on the Rust side we can leverage the custom protocol IPC and read the file directly + val cacheFile = File(activity.cacheDir, "_assets/$path") + cacheFile.parentFile?.mkdirs() + copyAsset(path, cacheFile) + + val fd = ParcelFileDescriptor.open(cacheFile, ParcelFileDescriptor.parseMode(args.mode)).detachFd() + res.put("fd", fd) + } + } else { + val fd = activity.contentResolver.openAssetFileDescriptor( + Uri.parse(args.uri), + args.mode + )?.parcelFileDescriptor?.detachFd() + res.put("fd", fd) + } + + invoke.resolve(res) + } + + @Throws(IOException::class) + private fun copy(input: InputStream, output: OutputStream) { + val buf = ByteArray(1024) + var len: Int + while ((input.read(buf).also { len = it }) > 0) { + output.write(buf, 0, len) + } + } + + @Throws(IOException::class) + private fun copyAsset(assetPath: String, cacheFile: File) { + val input = activity.assets.open(assetPath, ACCESS_BUFFER) + input.use { i -> + val output = FileOutputStream(cacheFile, false) + output.use { o -> + copy(i, o) + } + } + } +} + diff --git a/plugins/fs/android/src/test/java/ExampleUnitTest.kt b/plugins/fs/android/src/test/java/ExampleUnitTest.kt new file mode 100644 index 00000000..340839a5 --- /dev/null +++ b/plugins/fs/android/src/test/java/ExampleUnitTest.kt @@ -0,0 +1,21 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +package com.plugin.fs + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} diff --git a/plugins/fs/api-iife.js b/plugins/fs/api-iife.js new file mode 100644 index 00000000..02063a22 --- /dev/null +++ b/plugins/fs/api-iife.js @@ -0,0 +1 @@ +if("__TAURI__"in window){var __TAURI_PLUGIN_FS__=function(t){"use strict";function e(t,e,n,i){if("function"==typeof e||!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(t):i?i.value:e.get(t)}function n(t,e,n,i,o){if("function"==typeof e||!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,n),n}var i,o,r,a,s;"function"==typeof SuppressedError&&SuppressedError;const c="__TAURI_TO_IPC_KEY__";class f{constructor(t){i.set(this,void 0),o.set(this,0),r.set(this,[]),a.set(this,void 0),n(this,i,t||(()=>{})),this.id=function(t,e=!1){return window.__TAURI_INTERNALS__.transformCallback(t,e)}((t=>{const s=t.index;if("end"in t)return void(s==e(this,o,"f")?this.cleanupCallback():n(this,a,s));const c=t.message;if(s==e(this,o,"f")){for(e(this,i,"f").call(this,c),n(this,o,e(this,o,"f")+1);e(this,o,"f")in e(this,r,"f");){const t=e(this,r,"f")[e(this,o,"f")];e(this,i,"f").call(this,t),delete e(this,r,"f")[e(this,o,"f")],n(this,o,e(this,o,"f")+1)}e(this,o,"f")===e(this,a,"f")&&this.cleanupCallback()}else e(this,r,"f")[s]=c}))}cleanupCallback(){Reflect.deleteProperty(window,`_${this.id}`)}set onmessage(t){n(this,i,t)}get onmessage(){return e(this,i,"f")}[(i=new WeakMap,o=new WeakMap,r=new WeakMap,a=new WeakMap,c)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[c]()}}async function l(t,e={},n){return window.__TAURI_INTERNALS__.invoke(t,e,n)}class u{get rid(){return e(this,s,"f")}constructor(t){s.set(this,void 0),n(this,s,t)}async close(){return l("plugin:resources|close",{rid:this.rid})}}var p,w;function d(t){return{isFile:t.isFile,isDirectory:t.isDirectory,isSymlink:t.isSymlink,size:t.size,mtime:null!==t.mtime?new Date(t.mtime):null,atime:null!==t.atime?new Date(t.atime):null,birthtime:null!==t.birthtime?new Date(t.birthtime):null,readonly:t.readonly,fileAttributes:t.fileAttributes,dev:t.dev,ino:t.ino,mode:t.mode,nlink:t.nlink,uid:t.uid,gid:t.gid,rdev:t.rdev,blksize:t.blksize,blocks:t.blocks}}s=new WeakMap,t.BaseDirectory=void 0,(p=t.BaseDirectory||(t.BaseDirectory={}))[p.Audio=1]="Audio",p[p.Cache=2]="Cache",p[p.Config=3]="Config",p[p.Data=4]="Data",p[p.LocalData=5]="LocalData",p[p.Document=6]="Document",p[p.Download=7]="Download",p[p.Picture=8]="Picture",p[p.Public=9]="Public",p[p.Video=10]="Video",p[p.Resource=11]="Resource",p[p.Temp=12]="Temp",p[p.AppConfig=13]="AppConfig",p[p.AppData=14]="AppData",p[p.AppLocalData=15]="AppLocalData",p[p.AppCache=16]="AppCache",p[p.AppLog=17]="AppLog",p[p.Desktop=18]="Desktop",p[p.Executable=19]="Executable",p[p.Font=20]="Font",p[p.Home=21]="Home",p[p.Runtime=22]="Runtime",p[p.Template=23]="Template",t.SeekMode=void 0,(w=t.SeekMode||(t.SeekMode={}))[w.Start=0]="Start",w[w.Current=1]="Current",w[w.End=2]="End";class h extends u{async read(t){if(0===t.byteLength)return 0;const e=await l("plugin:fs|read",{rid:this.rid,len:t.byteLength}),n=function(t){const e=new Uint8ClampedArray(t),n=e.byteLength;let i=0;for(let t=0;tt instanceof URL?t.toString():t)),options:n,onEvent:o}),a=new L(r);return()=>{a.close()}}return t.FileHandle=h,t.copyFile=async function(t,e,n){if(t instanceof URL&&"file:"!==t.protocol||e instanceof URL&&"file:"!==e.protocol)throw new TypeError("Must be a file URL.");await l("plugin:fs|copy_file",{fromPath:t instanceof URL?t.toString():t,toPath:e instanceof URL?e.toString():e,options:n})},t.create=async function(t,e){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");const n=await l("plugin:fs|create",{path:t instanceof URL?t.toString():t,options:e});return new h(n)},t.exists=async function(t,e){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");return await l("plugin:fs|exists",{path:t instanceof URL?t.toString():t,options:e})},t.lstat=async function(t,e){return d(await l("plugin:fs|lstat",{path:t instanceof URL?t.toString():t,options:e}))},t.mkdir=async function(t,e){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");await l("plugin:fs|mkdir",{path:t instanceof URL?t.toString():t,options:e})},t.open=y,t.readDir=async function(t,e){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");return await l("plugin:fs|read_dir",{path:t instanceof URL?t.toString():t,options:e})},t.readFile=async function(t,e){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");const n=await l("plugin:fs|read_file",{path:t instanceof URL?t.toString():t,options:e});return n instanceof ArrayBuffer?new Uint8Array(n):Uint8Array.from(n)},t.readTextFile=async function(t,e){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");const n=await l("plugin:fs|read_text_file",{path:t instanceof URL?t.toString():t,options:e}),i=n instanceof ArrayBuffer?n:Uint8Array.from(n);return(new TextDecoder).decode(i)},t.readTextFileLines=async function(t,e){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");const n=t instanceof URL?t.toString():t;return await Promise.resolve({path:n,rid:null,async next(){null===this.rid&&(this.rid=await l("plugin:fs|read_text_file_lines",{path:n,options:e}));const t=await l("plugin:fs|read_text_file_lines_next",{rid:this.rid}),i=t instanceof ArrayBuffer?new Uint8Array(t):Uint8Array.from(t),o=1===i[i.byteLength-1];if(o)return this.rid=null,{value:null,done:o};return{value:(new TextDecoder).decode(i.slice(0,i.byteLength)),done:o}},[Symbol.asyncIterator](){return this}})},t.remove=async function(t,e){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");await l("plugin:fs|remove",{path:t instanceof URL?t.toString():t,options:e})},t.rename=async function(t,e,n){if(t instanceof URL&&"file:"!==t.protocol||e instanceof URL&&"file:"!==e.protocol)throw new TypeError("Must be a file URL.");await l("plugin:fs|rename",{oldPath:t instanceof URL?t.toString():t,newPath:e instanceof URL?e.toString():e,options:n})},t.size=async function(t){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");return await l("plugin:fs|size",{path:t instanceof URL?t.toString():t})},t.stat=async function(t,e){return d(await l("plugin:fs|stat",{path:t instanceof URL?t.toString():t,options:e}))},t.truncate=async function(t,e,n){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");await l("plugin:fs|truncate",{path:t instanceof URL?t.toString():t,len:e,options:n})},t.watch=async function(t,e,n){return await R(t,e,{delayMs:2e3,...n})},t.watchImmediate=async function(t,e,n){return await R(t,e,{...n,delayMs:void 0})},t.writeFile=async function(t,e,n){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");if(e instanceof ReadableStream){const i=await y(t,n),o=e.getReader();try{for(;;){const{done:t,value:e}=await o.read();if(t)break;await i.write(e)}}finally{o.releaseLock(),await i.close()}}else await l("plugin:fs|write_file",e,{headers:{path:encodeURIComponent(t instanceof URL?t.toString():t),options:JSON.stringify(n)}})},t.writeTextFile=async function(t,e,n){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");const i=new TextEncoder;await l("plugin:fs|write_text_file",i.encode(e),{headers:{path:encodeURIComponent(t instanceof URL?t.toString():t),options:JSON.stringify(n)}})},t}({});Object.defineProperty(window.__TAURI__,"fs",{value:__TAURI_PLUGIN_FS__})} diff --git a/plugins/fs/build.rs b/plugins/fs/build.rs new file mode 100644 index 00000000..47e27003 --- /dev/null +++ b/plugins/fs/build.rs @@ -0,0 +1,267 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use std::{ + fs::create_dir_all, + path::{Path, PathBuf}, +}; + +use tauri_utils::acl::manifest::PermissionFile; + +#[path = "src/scope.rs"] +#[allow(dead_code)] +mod scope; + +/// FS scope entry. +#[derive(schemars::JsonSchema)] +#[serde(untagged)] +#[allow(unused)] +enum FsScopeEntry { + /// A path that can be accessed by the webview when using the fs APIs. + /// FS scope path pattern. + /// + /// The pattern can start with a variable that resolves to a system base directory. + /// The variables are: `$AUDIO`, `$CACHE`, `$CONFIG`, `$DATA`, `$LOCALDATA`, `$DESKTOP`, + /// `$DOCUMENT`, `$DOWNLOAD`, `$EXE`, `$FONT`, `$HOME`, `$PICTURE`, `$PUBLIC`, `$RUNTIME`, + /// `$TEMPLATE`, `$VIDEO`, `$RESOURCE`, `$APP`, `$LOG`, `$TEMP`, `$APPCONFIG`, `$APPDATA`, + /// `$APPLOCALDATA`, `$APPCACHE`, `$APPLOG`. + Value(PathBuf), + Object { + /// A path that can be accessed by the webview when using the fs APIs. + /// + /// The pattern can start with a variable that resolves to a system base directory. + /// The variables are: `$AUDIO`, `$CACHE`, `$CONFIG`, `$DATA`, `$LOCALDATA`, `$DESKTOP`, + /// `$DOCUMENT`, `$DOWNLOAD`, `$EXE`, `$FONT`, `$HOME`, `$PICTURE`, `$PUBLIC`, `$RUNTIME`, + /// `$TEMPLATE`, `$VIDEO`, `$RESOURCE`, `$APP`, `$LOG`, `$TEMP`, `$APPCONFIG`, `$APPDATA`, + /// `$APPLOCALDATA`, `$APPCACHE`, `$APPLOG`. + path: PathBuf, + }, +} + +// Ensure `FsScopeEntry` and `scope::EntryRaw` is kept in sync +fn _f() { + match scope::EntryRaw::Value(PathBuf::new()) { + scope::EntryRaw::Value(path) => FsScopeEntry::Value(path), + scope::EntryRaw::Object { path } => FsScopeEntry::Object { path }, + }; + match FsScopeEntry::Value(PathBuf::new()) { + FsScopeEntry::Value(path) => scope::EntryRaw::Value(path), + FsScopeEntry::Object { path } => scope::EntryRaw::Object { path }, + }; +} + +const BASE_DIR_VARS: &[&str] = &[ + "AUDIO", + "CACHE", + "CONFIG", + "DATA", + "LOCALDATA", + "DESKTOP", + "DOCUMENT", + "DOWNLOAD", + "EXE", + "FONT", + "HOME", + "PICTURE", + "PUBLIC", + "RUNTIME", + "TEMPLATE", + "VIDEO", + "RESOURCE", + "LOG", + "TEMP", + "APPCONFIG", + "APPDATA", + "APPLOCALDATA", + "APPCACHE", + "APPLOG", +]; +const COMMANDS: &[(&str, &[&str])] = &[ + ("mkdir", &[]), + ("create", &[]), + ("copy_file", &[]), + ("remove", &[]), + ("rename", &[]), + ("truncate", &[]), + ("ftruncate", &[]), + ("write", &[]), + ("write_file", &["open", "write"]), + ("write_text_file", &[]), + ("read_dir", &[]), + ("read_file", &[]), + ("read", &[]), + ("open", &[]), + ("read_text_file", &[]), + ("read_text_file_lines", &["read_text_file_lines_next"]), + ("read_text_file_lines_next", &[]), + ("seek", &[]), + ("stat", &[]), + ("lstat", &[]), + ("fstat", &[]), + ("exists", &[]), + ("watch", &[]), + // TODO: Remove this in v3 + ("unwatch", &[]), + ("size", &[]), +]; + +fn main() { + let autogenerated = Path::new("permissions/autogenerated/"); + let base_dirs = &autogenerated.join("base-directories"); + + if !base_dirs.exists() { + create_dir_all(base_dirs).expect("unable to create autogenerated base directories dir"); + } + + for base_dir in BASE_DIR_VARS { + let upper = base_dir; + let lower = base_dir.to_lowercase(); + let toml = format!( + r###"# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +# Scopes Section +# This section contains scopes, which define file level access + +[[permission]] +identifier = "scope-{lower}-recursive" +description = "This scope permits recursive access to the complete `${upper}` folder, including sub directories and files." + +[[permission.scope.allow]] +path = "${upper}" +[[permission.scope.allow]] +path = "${upper}/**" + +[[permission]] +identifier = "scope-{lower}" +description = "This scope permits access to all files and list content of top level directories in the `${upper}` folder." + +[[permission.scope.allow]] +path = "${upper}" +[[permission.scope.allow]] +path = "${upper}/*" + +[[permission]] +identifier = "scope-{lower}-index" +description = "This scope permits to list all files and folders in the `${upper}`folder." + +[[permission.scope.allow]] +path = "${upper}" + +# Sets Section +# This section combines the scope elements with enablement of commands + +[[set]] +identifier = "allow-{lower}-read-recursive" +description = "This allows full recursive read access to the complete `${upper}` folder, files and subdirectories." +permissions = [ + "read-all", + "scope-{lower}-recursive" +] + +[[set]] +identifier = "allow-{lower}-write-recursive" +description = "This allows full recursive write access to the complete `${upper}` folder, files and subdirectories." +permissions = [ + "write-all", + "scope-{lower}-recursive" +] + +[[set]] +identifier = "allow-{lower}-read" +description = "This allows non-recursive read access to the `${upper}` folder." +permissions = [ + "read-all", + "scope-{lower}" +] + +[[set]] +identifier = "allow-{lower}-write" +description = "This allows non-recursive write access to the `${upper}` folder." +permissions = [ + "write-all", + "scope-{lower}" +] + +[[set]] +identifier = "allow-{lower}-meta-recursive" +description = "This allows full recursive read access to metadata of the `${upper}` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-{lower}-recursive" +] + +[[set]] +identifier = "allow-{lower}-meta" +description = "This allows non-recursive read access to metadata of the `${upper}` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-{lower}-index" +]"### + ); + + let permission_path = base_dirs.join(format!("{lower}.toml")); + if toml != std::fs::read_to_string(&permission_path).unwrap_or_default() { + std::fs::write(permission_path, toml) + .unwrap_or_else(|e| panic!("unable to autogenerate ${lower}: {e}")); + } + } + + tauri_plugin::Builder::new( + &COMMANDS + .iter() + // FIXME: https://docs.rs/crate/tauri-plugin-fs/2.1.0/builds/1571296 + .filter(|c| c.1.is_empty()) + .map(|c| c.0) + .collect::>(), + ) + .global_api_script_path("./api-iife.js") + .global_scope_schema(schemars::schema_for!(FsScopeEntry)) + .android_path("android") + .build(); + + // workaround to include nested permissions as `tauri_plugin` doesn't support it + let permissions_dir = autogenerated.join("commands"); + for (command, nested_commands) in COMMANDS { + if nested_commands.is_empty() { + continue; + } + + let permission_path = permissions_dir.join(format!("{command}.toml")); + + let content = std::fs::read_to_string(&permission_path) + .unwrap_or_else(|_| panic!("failed to read {command}.toml")); + + let mut permission_file = toml::from_str::(&content) + .unwrap_or_else(|_| panic!("failed to deserialize {command}.toml")); + + for p in permission_file + .permission + .iter_mut() + .filter(|p| p.identifier.starts_with("allow")) + { + for c in nested_commands.iter().map(|s| s.to_string()) { + if !p.commands.allow.contains(&c) { + p.commands.allow.push(c); + } + } + } + + let out = toml::to_string_pretty(&permission_file) + .unwrap_or_else(|_| panic!("failed to serialize {command}.toml")); + let out = format!( + r#"# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +{out}"# + ); + + if content != out { + std::fs::write(permission_path, out) + .unwrap_or_else(|_| panic!("failed to write {command}.toml")); + } + } +} diff --git a/plugins/fs/guest-js/index.ts b/plugins/fs/guest-js/index.ts index 1a5d78fc..b3e49e5c 100644 --- a/plugins/fs/guest-js/index.ts +++ b/plugins/fs/guest-js/index.ts @@ -7,566 +7,1132 @@ * * ## Security * - * This module prevents path traversal, not allowing absolute paths or parent dir components - * (i.e. "/usr/path/to/file" or "../path/to/file" paths are not allowed). - * Paths accessed with this API must be relative to one of the {@link BaseDirectory | base directories} - * so if you need access to arbitrary filesystem paths, you must write such logic on the core layer instead. + * This module prevents path traversal, not allowing parent directory accessors to be used + * (i.e. "/usr/path/to/../file" or "../path/to/file" paths are not allowed). + * Paths accessed with this API must be either relative to one of the {@link BaseDirectory | base directories} + * or created with the {@link https://v2.tauri.app/reference/javascript/api/namespacepath/ | path API}. * * The API has a scope configuration that forces you to restrict the paths that can be accessed using glob patterns. * - * The scope configuration is an array of glob patterns describing folder paths that are allowed. - * For instance, this scope configuration only allows accessing files on the - * *databases* folder of the {@link path.appDataDir | $APPDATA directory}: + * The scope configuration is an array of glob patterns describing file/directory paths that are allowed. + * For instance, this scope configuration allows **all** enabled `fs` APIs to (only) access files in the + * *databases* directory of the {@link https://v2.tauri.app/reference/javascript/api/namespacepath/#appdatadir | `$APPDATA` directory}: * ```json * { - * "plugins": { - * "fs": { - * "scope": ["$APPDATA/databases/*"] + * "permissions": [ + * { + * "identifier": "fs:scope", + * "allow": [{ "path": "$APPDATA/databases/*" }] * } - * } + * ] * } * ``` * - * Notice the use of the `$APPDATA` variable. The value is injected at runtime, resolving to the {@link path.appDataDir | app data directory}. + * Scopes can also be applied to specific `fs` APIs by using the API's identifier instead of `fs:scope`: + * ```json + * { + * "permissions": [ + * { + * "identifier": "fs:allow-exists", + * "allow": [{ "path": "$APPDATA/databases/*" }] + * } + * ] + * } + * ``` + * + * Notice the use of the `$APPDATA` variable. The value is injected at runtime, resolving to the {@link https://v2.tauri.app/reference/javascript/api/namespacepath/#appdatadir | app data directory}. + * * The available variables are: - * {@link path.appConfigDir | `$APPCONFIG`}, {@link path.appDataDir | `$APPDATA`}, {@link path.appLocalDataDir | `$APPLOCALDATA`}, - * {@link path.appCacheDir | `$APPCACHE`}, {@link path.appLogDir | `$APPLOG`}, - * {@link path.audioDir | `$AUDIO`}, {@link path.cacheDir | `$CACHE`}, {@link path.configDir | `$CONFIG`}, {@link path.dataDir | `$DATA`}, - * {@link path.localDataDir | `$LOCALDATA`}, {@link path.desktopDir | `$DESKTOP`}, {@link path.documentDir | `$DOCUMENT`}, - * {@link path.downloadDir | `$DOWNLOAD`}, {@link path.executableDir | `$EXE`}, {@link path.fontDir | `$FONT`}, {@link path.homeDir | `$HOME`}, - * {@link path.pictureDir | `$PICTURE`}, {@link path.publicDir | `$PUBLIC`}, {@link path.runtimeDir | `$RUNTIME`}, - * {@link path.templateDir | `$TEMPLATE`}, {@link path.videoDir | `$VIDEO`}, {@link path.resourceDir | `$RESOURCE`}, - * {@link os.tempdir | `$TEMP`}. + * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#appconfigdir | $APPCONFIG}, + * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#appdatadir | $APPDATA}, + * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#applocaldatadir | $APPLOCALDATA}, + * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#appcachedir | $APPCACHE}, + * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#applogdir | $APPLOG}, + * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#audiodir | $AUDIO}, + * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#cachedir | $CACHE}, + * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#configdir | $CONFIG}, + * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#datadir | $DATA}, + * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#localdatadir | $LOCALDATA}, + * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#desktopdir | $DESKTOP}, + * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#documentdir | $DOCUMENT}, + * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#downloaddir | $DOWNLOAD}, + * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#executabledir | $EXE}, + * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#fontdir | $FONT}, + * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#homedir | $HOME}, + * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#picturedir | $PICTURE}, + * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#publicdir | $PUBLIC}, + * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#runtimedir | $RUNTIME}, + * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#templatedir | $TEMPLATE}, + * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#videodir | $VIDEO}, + * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#resourcedir | $RESOURCE}, + * {@linkcode https://v2.tauri.app/reference/javascript/api/namespacepath/#tempdir | $TEMP}. * * Trying to execute any API with a URL not configured on the scope results in a promise rejection due to denied access. * - * Note that this scope applies to **all** APIs on this module. - * * @module */ -import { BaseDirectory } from "@tauri-apps/api/path"; +import { BaseDirectory } from '@tauri-apps/api/path' +import { Channel, invoke, Resource } from '@tauri-apps/api/core' -import { invoke } from "@tauri-apps/api/primitives"; - -interface Permissions { - /** - * `true` if these permissions describe a readonly (unwritable) file. - */ - readonly: boolean; - /** - * The underlying raw `st_mode` bits that contain the standard Unix permissions for this file. - */ - mode: number | undefined; +enum SeekMode { + Start = 0, + Current = 1, + End = 2 } /** - * Metadata information about a file. - * This structure is returned from the `metadata` function or method - * and represents known metadata about a file such as its permissions, size, modification times, etc. + * A FileInfo describes a file and is returned by `stat`, `lstat` or `fstat`. + * + * @since 2.0.0 */ -interface Metadata { +interface FileInfo { /** - * The last access time of this metadata. + * True if this is info for a regular file. Mutually exclusive to + * `FileInfo.isDirectory` and `FileInfo.isSymlink`. */ - accessedAt: Date; + isFile: boolean /** - * The creation time listed in this metadata. + * True if this is info for a regular directory. Mutually exclusive to + * `FileInfo.isFile` and `FileInfo.isSymlink`. */ - createdAt: Date; + isDirectory: boolean /** - * The last modification time listed in this metadata. + * True if this is info for a symlink. Mutually exclusive to + * `FileInfo.isFile` and `FileInfo.isDirectory`. */ - modifiedAt: Date; + isSymlink: boolean /** - * `true` if this metadata is for a directory. + * The size of the file, in bytes. */ - isDir: boolean; + size: number /** - * `true` if this metadata is for a regular file. + * The last modification time of the file. This corresponds to the `mtime` + * field from `stat` on Linux/Mac OS and `ftLastWriteTime` on Windows. This + * may not be available on all platforms. */ - isFile: boolean; + mtime: Date | null /** - * `true` if this metadata is for a symbolic link. + * The last access time of the file. This corresponds to the `atime` + * field from `stat` on Unix and `ftLastAccessTime` on Windows. This may not + * be available on all platforms. */ - isSymlink: boolean; + atime: Date | null /** - * The size of the file, in bytes, this metadata is for. + * The creation time of the file. This corresponds to the `birthtime` + * field from `stat` on Mac/BSD and `ftCreationTime` on Windows. This may + * not be available on all platforms. */ - size: number; + birthtime: Date | null + /** Whether this is a readonly (unwritable) file. */ + readonly: boolean /** - * The permissions of the file this metadata is for. + * This field contains the file system attribute information for a file + * or directory. For possible values and their descriptions, see + * {@link https://docs.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants | File Attribute Constants} in the Windows Dev Center + * + * #### Platform-specific + * + * - **macOS / Linux / Android / iOS:** Unsupported. */ - permissions: Permissions; + fileAttributes: number | null /** - * The ID of the device containing the file. Only available on Unix. + * ID of the device containing the file. + * + * #### Platform-specific + * + * - **Windows:** Unsupported. */ - dev: number | undefined; + dev: number | null /** - * The inode number. Only available on Unix. + * Inode number. + * + * #### Platform-specific + * + * - **Windows:** Unsupported. */ - ino: number | undefined; + ino: number | null /** - * The rights applied to this file. Only available on Unix. + * The underlying raw `st_mode` bits that contain the standard Unix + * permissions for this file/directory. + * + * #### Platform-specific + * + * - **Windows:** Unsupported. */ - mode: number | undefined; + mode: number | null /** - * The number of hard links pointing to this file. Only available on Unix. + * Number of hard links pointing to this file. + * + * #### Platform-specific + * + * - **Windows:** Unsupported. */ - nlink: number | undefined; + nlink: number | null /** - * The user ID of the owner of this file. Only available on Unix. + * User ID of the owner of this file. + * + * #### Platform-specific + * + * - **Windows:** Unsupported. */ - uid: number | undefined; + uid: number | null /** - * The group ID of the owner of this file. Only available on Unix. + * Group ID of the owner of this file. + * + * #### Platform-specific + * + * - **Windows:** Unsupported. */ - gid: number | undefined; + gid: number | null /** - * The device ID of this file (if it is a special one). Only available on Unix. + * Device ID of this file. + * + * #### Platform-specific + * + * - **Windows:** Unsupported. */ - rdev: number | undefined; + rdev: number | null /** - * The block size for filesystem I/O. Only available on Unix. + * Blocksize for filesystem I/O. + * + * #### Platform-specific + * + * - **Windows:** Unsupported. */ - blksize: number | undefined; + blksize: number | null /** - * The number of blocks allocated to the file, in 512-byte units. Only available on Unix. + * Number of blocks allocated to the file, in 512-byte units. + * + * #### Platform-specific + * + * - **Windows:** Unsupported. */ - blocks: number | undefined; + blocks: number | null } -interface BackendMetadata { - accessedAtMs: number; - createdAtMs: number; - modifiedAtMs: number; - isDir: boolean; - isFile: boolean; - isSymlink: boolean; - size: number; - permissions: Permissions; - dev: number | undefined; - ino: number | undefined; - mode: number | undefined; - nlink: number | undefined; - uid: number | undefined; - gid: number | undefined; - rdev: number | undefined; - blksize: number | undefined; - blocks: number | undefined; +interface UnparsedFileInfo { + isFile: boolean + isDirectory: boolean + isSymlink: boolean + size: number + mtime: number | null + atime: number | null + birthtime: number | null + readonly: boolean + fileAttributes: number + dev: number | null + ino: number | null + mode: number | null + nlink: number | null + uid: number | null + gid: number | null + rdev: number | null + blksize: number | null + blocks: number | null +} +function parseFileInfo(r: UnparsedFileInfo): FileInfo { + return { + isFile: r.isFile, + isDirectory: r.isDirectory, + isSymlink: r.isSymlink, + size: r.size, + mtime: r.mtime !== null ? new Date(r.mtime) : null, + atime: r.atime !== null ? new Date(r.atime) : null, + birthtime: r.birthtime !== null ? new Date(r.birthtime) : null, + readonly: r.readonly, + fileAttributes: r.fileAttributes, + dev: r.dev, + ino: r.ino, + mode: r.mode, + nlink: r.nlink, + uid: r.uid, + gid: r.gid, + rdev: r.rdev, + blksize: r.blksize, + blocks: r.blocks + } } -/** - * @since 2.0.0 - */ -interface FsOptions { - dir?: BaseDirectory; - // note that adding fields here needs a change in the writeBinaryFile check +// https://mstn.github.io/2018/06/08/fixed-size-arrays-in-typescript/ +type FixedSizeArray = ReadonlyArray & { + length: N +} + +// https://gist.github.com/zapthedingbat/38ebfbedd98396624e5b5f2ff462611d +/** Converts a big-endian eight byte array to number */ +function fromBytes(buffer: FixedSizeArray): number { + const bytes = new Uint8ClampedArray(buffer) + const size = bytes.byteLength + let x = 0 + for (let i = 0; i < size; i++) { + // eslint-disable-next-line security/detect-object-injection + const byte = bytes[i] + x *= 0x100 + x += byte + } + return x } /** + * The Tauri abstraction for reading and writing files. + * * @since 2.0.0 */ -interface FsDirOptions { - dir?: BaseDirectory; - recursive?: boolean; +class FileHandle extends Resource { + /** + * Reads up to `p.byteLength` bytes into `p`. It resolves to the number of + * bytes read (`0` < `n` <= `p.byteLength`) and rejects if any error + * encountered. Even if `read()` resolves to `n` < `p.byteLength`, it may + * use all of `p` as scratch space during the call. If some data is + * available but not `p.byteLength` bytes, `read()` conventionally resolves + * to what is available instead of waiting for more. + * + * When `read()` encounters end-of-file condition, it resolves to EOF + * (`null`). + * + * When `read()` encounters an error, it rejects with an error. + * + * Callers should always process the `n` > `0` bytes returned before + * considering the EOF (`null`). Doing so correctly handles I/O errors that + * happen after reading some bytes and also both of the allowed EOF + * behaviors. + * + * @example + * ```typescript + * import { open, BaseDirectory } from "@tauri-apps/plugin-fs" + * // if "$APPCONFIG/foo/bar.txt" contains the text "hello world": + * const file = await open("foo/bar.txt", { baseDir: BaseDirectory.AppConfig }); + * const buf = new Uint8Array(100); + * const numberOfBytesRead = await file.read(buf); // 11 bytes + * const text = new TextDecoder().decode(buf); // "hello world" + * await file.close(); + * ``` + * + * @since 2.0.0 + */ + async read(buffer: Uint8Array): Promise { + if (buffer.byteLength === 0) { + return 0 + } + + const data = await invoke('plugin:fs|read', { + rid: this.rid, + len: buffer.byteLength + }) + + // Rust side will never return an empty array for this command and + // ensure there is at least 8 elements there. + // + // This is an optimization to include the number of read bytes (as bigendian bytes) + // at the end of returned array to avoid serialization overhead of separate values. + const nread = fromBytes(data.slice(-8) as FixedSizeArray) + + const bytes = data instanceof ArrayBuffer ? new Uint8Array(data) : data + buffer.set(bytes.slice(0, bytes.length - 8)) + + return nread === 0 ? null : nread + } + + /** + * Seek sets the offset for the next `read()` or `write()` to offset, + * interpreted according to `whence`: `Start` means relative to the + * start of the file, `Current` means relative to the current offset, + * and `End` means relative to the end. Seek resolves to the new offset + * relative to the start of the file. + * + * Seeking to an offset before the start of the file is an error. Seeking to + * any positive offset is legal, but the behavior of subsequent I/O + * operations on the underlying object is implementation-dependent. + * It returns the number of cursor position. + * + * @example + * ```typescript + * import { open, SeekMode, BaseDirectory } from '@tauri-apps/plugin-fs'; + * + * // Given hello.txt pointing to file with "Hello world", which is 11 bytes long: + * const file = await open('hello.txt', { read: true, write: true, truncate: true, create: true, baseDir: BaseDirectory.AppLocalData }); + * await file.write(new TextEncoder().encode("Hello world")); + * + * // Seek 6 bytes from the start of the file + * console.log(await file.seek(6, SeekMode.Start)); // "6" + * // Seek 2 more bytes from the current position + * console.log(await file.seek(2, SeekMode.Current)); // "8" + * // Seek backwards 2 bytes from the end of the file + * console.log(await file.seek(-2, SeekMode.End)); // "9" (e.g. 11-2) + * + * await file.close(); + * ``` + * + * @since 2.0.0 + */ + async seek(offset: number, whence: SeekMode): Promise { + return await invoke('plugin:fs|seek', { + rid: this.rid, + offset, + whence + }) + } + + /** + * Returns a {@linkcode FileInfo } for this file. + * + * @example + * ```typescript + * import { open, BaseDirectory } from '@tauri-apps/plugin-fs'; + * const file = await open("file.txt", { read: true, baseDir: BaseDirectory.AppLocalData }); + * const fileInfo = await file.stat(); + * console.log(fileInfo.isFile); // true + * await file.close(); + * ``` + * + * @since 2.0.0 + */ + async stat(): Promise { + const res = await invoke('plugin:fs|fstat', { + rid: this.rid + }) + + return parseFileInfo(res) + } + + /** + * Truncates or extends this file, to reach the specified `len`. + * If `len` is not specified then the entire file contents are truncated. + * + * @example + * ```typescript + * import { open, BaseDirectory } from '@tauri-apps/plugin-fs'; + * + * // truncate the entire file + * const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.AppLocalData }); + * await file.truncate(); + * + * // truncate part of the file + * const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.AppLocalData }); + * await file.write(new TextEncoder().encode("Hello World")); + * await file.truncate(7); + * const data = new Uint8Array(32); + * await file.read(data); + * console.log(new TextDecoder().decode(data)); // Hello W + * await file.close(); + * ``` + * + * @since 2.0.0 + */ + async truncate(len?: number): Promise { + await invoke('plugin:fs|ftruncate', { + rid: this.rid, + len + }) + } + + /** + * Writes `data.byteLength` bytes from `data` to the underlying data stream. It + * resolves to the number of bytes written from `data` (`0` <= `n` <= + * `data.byteLength`) or reject with the error encountered that caused the + * write to stop early. `write()` must reject with a non-null error if + * would resolve to `n` < `data.byteLength`. `write()` must not modify the + * slice data, even temporarily. + * + * @example + * ```typescript + * import { open, write, BaseDirectory } from '@tauri-apps/plugin-fs'; + * const encoder = new TextEncoder(); + * const data = encoder.encode("Hello world"); + * const file = await open("bar.txt", { write: true, baseDir: BaseDirectory.AppLocalData }); + * const bytesWritten = await file.write(data); // 11 + * await file.close(); + * ``` + * + * @since 2.0.0 + */ + async write(data: Uint8Array): Promise { + return await invoke('plugin:fs|write', { + rid: this.rid, + data + }) + } } /** - * Options object used to write a UTF-8 string to a file. - * * @since 2.0.0 */ -interface FsTextFileOption { - /** Path to the file to write. */ - path: string; - /** The UTF-8 string to write to the file. */ - contents: string; +interface CreateOptions { + /** Base directory for `path` */ + baseDir?: BaseDirectory } -type BinaryFileContents = Iterable | ArrayLike | ArrayBuffer; - /** - * Options object used to write a binary data to a file. + * Creates a file if none exists or truncates an existing file and resolves to + * an instance of {@linkcode FileHandle }. + * + * @example + * ```typescript + * import { create, BaseDirectory } from "@tauri-apps/plugin-fs" + * const file = await create("foo/bar.txt", { baseDir: BaseDirectory.AppConfig }); + * await file.write(new TextEncoder().encode("Hello world")); + * await file.close(); + * ``` * * @since 2.0.0 */ -interface FsBinaryFileOption { - /** Path to the file to write. */ - path: string; - /** The byte array contents. */ - contents: BinaryFileContents; +async function create( + path: string | URL, + options?: CreateOptions +): Promise { + if (path instanceof URL && path.protocol !== 'file:') { + throw new TypeError('Must be a file URL.') + } + + const rid = await invoke('plugin:fs|create', { + path: path instanceof URL ? path.toString() : path, + options + }) + + return new FileHandle(rid) } /** * @since 2.0.0 */ -interface FileEntry { - path: string; +interface OpenOptions { + /** + * Sets the option for read access. This option, when `true`, means that the + * file should be read-able if opened. + */ + read?: boolean + /** + * Sets the option for write access. This option, when `true`, means that + * the file should be write-able if opened. If the file already exists, + * any write calls on it will overwrite its contents, by default without + * truncating it. + */ + write?: boolean + /** + * Sets the option for the append mode. This option, when `true`, means that + * writes will append to a file instead of overwriting previous contents. + * Note that setting `{ write: true, append: true }` has the same effect as + * setting only `{ append: true }`. + */ + append?: boolean + /** + * Sets the option for truncating a previous file. If a file is + * successfully opened with this option set it will truncate the file to `0` + * size if it already exists. The file must be opened with write access + * for truncate to work. + */ + truncate?: boolean /** - * Name of the directory/file - * can be null if the path terminates with `..` + * Sets the option to allow creating a new file, if one doesn't already + * exist at the specified path. Requires write or append access to be + * used. */ - name?: string; - /** Children of this entry if it's a directory; null otherwise */ - children?: FileEntry[]; + create?: boolean + /** + * Defaults to `false`. If set to `true`, no file, directory, or symlink is + * allowed to exist at the target location. Requires write or append + * access to be used. When createNew is set to `true`, create and truncate + * are ignored. + */ + createNew?: boolean + /** + * Permissions to use if creating the file (defaults to `0o666`, before + * the process's umask). + * Ignored on Windows. + */ + mode?: number + /** Base directory for `path` */ + baseDir?: BaseDirectory } /** - * Reads a file as an UTF-8 encoded string. + * Open a file and resolve to an instance of {@linkcode FileHandle}. The + * file does not need to previously exist if using the `create` or `createNew` + * open options. It is the callers responsibility to close the file when finished + * with it. + * * @example * ```typescript - * import { readTextFile, BaseDirectory } from '@tauri-apps/plugin-fs'; - * // Read the text file in the `$APPCONFIG/app.conf` path - * const contents = await readTextFile('app.conf', { dir: BaseDirectory.AppConfig }); + * import { open, BaseDirectory } from "@tauri-apps/plugin-fs" + * const file = await open("foo/bar.txt", { read: true, write: true, baseDir: BaseDirectory.AppLocalData }); + * // Do work with file + * await file.close(); * ``` * * @since 2.0.0 */ -async function readTextFile( - filePath: string, - options: FsOptions = {}, -): Promise { - return await invoke("plugin:fs|read_text_file", { - path: filePath, - options, - }); +async function open( + path: string | URL, + options?: OpenOptions +): Promise { + if (path instanceof URL && path.protocol !== 'file:') { + throw new TypeError('Must be a file URL.') + } + + const rid = await invoke('plugin:fs|open', { + path: path instanceof URL ? path.toString() : path, + options + }) + + return new FileHandle(rid) } /** - * Reads a file as byte array. + * @since 2.0.0 + */ +interface CopyFileOptions { + /** Base directory for `fromPath`. */ + fromPathBaseDir?: BaseDirectory + /** Base directory for `toPath`. */ + toPathBaseDir?: BaseDirectory +} + +/** + * Copies the contents and permissions of one file to another specified path, by default creating a new file if needed, else overwriting. * @example * ```typescript - * import { readBinaryFile, BaseDirectory } from '@tauri-apps/plugin-fs'; - * // Read the image file in the `$RESOURCEDIR/avatar.png` path - * const contents = await readBinaryFile('avatar.png', { dir: BaseDirectory.Resource }); + * import { copyFile, BaseDirectory } from '@tauri-apps/plugin-fs'; + * await copyFile('app.conf', 'app.conf.bk', { fromPathBaseDir: BaseDirectory.AppConfig, toPathBaseDir: BaseDirectory.AppConfig }); * ``` * * @since 2.0.0 */ -async function readBinaryFile( - filePath: string, - options: FsOptions = {}, -): Promise { - const arr = await invoke("plugin:fs|read_file", { - path: filePath, - options, - }); +async function copyFile( + fromPath: string | URL, + toPath: string | URL, + options?: CopyFileOptions +): Promise { + if ( + (fromPath instanceof URL && fromPath.protocol !== 'file:') + || (toPath instanceof URL && toPath.protocol !== 'file:') + ) { + throw new TypeError('Must be a file URL.') + } - return Uint8Array.from(arr); + await invoke('plugin:fs|copy_file', { + fromPath: fromPath instanceof URL ? fromPath.toString() : fromPath, + toPath: toPath instanceof URL ? toPath.toString() : toPath, + options + }) } /** - * Writes a UTF-8 text file. - * @example - * ```typescript - * import { writeTextFile, BaseDirectory } from '@tauri-apps/plugin-fs'; - * // Write a text file to the `$APPCONFIG/app.conf` path - * await writeTextFile('app.conf', 'file contents', { dir: BaseDirectory.AppConfig }); - * ``` - * * @since 2.0.0 */ -async function writeTextFile( - path: string, - contents: string, - options?: FsOptions, -): Promise; +interface MkdirOptions { + /** Permissions to use when creating the directory (defaults to `0o777`, before the process's umask). Ignored on Windows. */ + mode?: number + /** + * Defaults to `false`. If set to `true`, means that any intermediate directories will also be created (as with the shell command `mkdir -p`). + * */ + recursive?: boolean + /** Base directory for `path` */ + baseDir?: BaseDirectory +} /** - * Writes a UTF-8 text file. + * Creates a new directory with the specified path. * @example * ```typescript - * import { writeTextFile, BaseDirectory } from '@tauri-apps/plugin-fs'; - * // Write a text file to the `$APPCONFIG/app.conf` path - * await writeTextFile({ path: 'app.conf', contents: 'file contents' }, { dir: BaseDirectory.AppConfig }); + * import { mkdir, BaseDirectory } from '@tauri-apps/plugin-fs'; + * await mkdir('users', { baseDir: BaseDirectory.AppLocalData }); * ``` - * @returns A promise indicating the success or failure of the operation. * * @since 2.0.0 */ -async function writeTextFile( - file: FsTextFileOption, - options?: FsOptions, -): Promise; +async function mkdir( + path: string | URL, + options?: MkdirOptions +): Promise { + if (path instanceof URL && path.protocol !== 'file:') { + throw new TypeError('Must be a file URL.') + } + + await invoke('plugin:fs|mkdir', { + path: path instanceof URL ? path.toString() : path, + options + }) +} /** - * Writes a UTF-8 text file. + * @since 2.0.0 + */ +interface ReadDirOptions { + /** Base directory for `path` */ + baseDir?: BaseDirectory +} + +/** + * A disk entry which is either a file, a directory or a symlink. * - * @returns A promise indicating the success or failure of the operation. + * This is the result of the {@linkcode readDir}. * * @since 2.0.0 */ -async function writeTextFile( - path: string | FsTextFileOption, - contents?: string | FsOptions, - options?: FsOptions, -): Promise { - if (typeof options === "object") { - Object.freeze(options); - } - if (typeof path === "object") { - Object.freeze(path); - } +interface DirEntry { + /** The name of the entry (file name with extension or directory name). */ + name: string + /** Specifies whether this entry is a directory or not. */ + isDirectory: boolean + /** Specifies whether this entry is a file or not. */ + isFile: boolean + /** Specifies whether this entry is a symlink or not. */ + isSymlink: boolean +} - const file: FsTextFileOption = { path: "", contents: "" }; - let fileOptions: FsOptions | undefined = options; - if (typeof path === "string") { - file.path = path; - } else { - file.path = path.path; - file.contents = path.contents; +/** + * Reads the directory given by path and returns an array of `DirEntry`. + * @example + * ```typescript + * import { readDir, BaseDirectory } from '@tauri-apps/plugin-fs'; + * import { join } from '@tauri-apps/api/path'; + * const dir = "users" + * const entries = await readDir('users', { baseDir: BaseDirectory.AppLocalData }); + * processEntriesRecursively(dir, entries); + * async function processEntriesRecursively(parent, entries) { + * for (const entry of entries) { + * console.log(`Entry: ${entry.name}`); + * if (entry.isDirectory) { + * const dir = await join(parent, entry.name); + * processEntriesRecursively(dir, await readDir(dir, { baseDir: BaseDirectory.AppLocalData })) + * } + * } + * } + * ``` + * + * @since 2.0.0 + */ +async function readDir( + path: string | URL, + options?: ReadDirOptions +): Promise { + if (path instanceof URL && path.protocol !== 'file:') { + throw new TypeError('Must be a file URL.') } - if (typeof contents === "string") { - file.contents = contents ?? ""; - } else { - fileOptions = contents; - } + return await invoke('plugin:fs|read_dir', { + path: path instanceof URL ? path.toString() : path, + options + }) +} - return await invoke("plugin:fs|write_file", { - path: file.path, - contents: Array.from(new TextEncoder().encode(file.contents)), - options: fileOptions, - }); +/** + * @since 2.0.0 + */ +interface ReadFileOptions { + /** Base directory for `path` */ + baseDir?: BaseDirectory } /** - * Writes a byte array content to a file. + * Reads and resolves to the entire contents of a file as an array of bytes. + * TextDecoder can be used to transform the bytes to string if required. * @example * ```typescript - * import { writeBinaryFile, BaseDirectory } from '@tauri-apps/plugin-fs'; - * // Write a binary file to the `$APPDATA/avatar.png` path - * await writeBinaryFile('avatar.png', new Uint8Array([]), { dir: BaseDirectory.AppData }); + * import { readFile, BaseDirectory } from '@tauri-apps/plugin-fs'; + * const contents = await readFile('avatar.png', { baseDir: BaseDirectory.Resource }); * ``` * - * @param options Configuration object. - * @returns A promise indicating the success or failure of the operation. - * * @since 2.0.0 */ -async function writeBinaryFile( - path: string, - contents: BinaryFileContents, - options?: FsOptions, -): Promise; +async function readFile( + path: string | URL, + options?: ReadFileOptions +): Promise { + if (path instanceof URL && path.protocol !== 'file:') { + throw new TypeError('Must be a file URL.') + } + + const arr = await invoke('plugin:fs|read_file', { + path: path instanceof URL ? path.toString() : path, + options + }) + + return arr instanceof ArrayBuffer ? new Uint8Array(arr) : Uint8Array.from(arr) +} /** - * Writes a byte array content to a file. + * Reads and returns the entire contents of a file as UTF-8 string. * @example * ```typescript - * import { writeBinaryFile, BaseDirectory } from '@tauri-apps/plugin-fs'; - * // Write a binary file to the `$APPDATA/avatar.png` path - * await writeBinaryFile({ path: 'avatar.png', contents: new Uint8Array([]) }, { dir: BaseDirectory.AppData }); + * import { readTextFile, BaseDirectory } from '@tauri-apps/plugin-fs'; + * const contents = await readTextFile('app.conf', { baseDir: BaseDirectory.AppConfig }); * ``` * - * @param file The object containing the file path and contents. - * @param options Configuration object. - * @returns A promise indicating the success or failure of the operation. - * * @since 2.0.0 */ -async function writeBinaryFile( - file: FsBinaryFileOption, - options?: FsOptions, -): Promise; +async function readTextFile( + path: string | URL, + options?: ReadFileOptions +): Promise { + if (path instanceof URL && path.protocol !== 'file:') { + throw new TypeError('Must be a file URL.') + } + + const arr = await invoke('plugin:fs|read_text_file', { + path: path instanceof URL ? path.toString() : path, + options + }) + + const bytes = arr instanceof ArrayBuffer ? arr : Uint8Array.from(arr) + + return new TextDecoder().decode(bytes) +} /** - * Writes a byte array content to a file. - * - * @returns A promise indicating the success or failure of the operation. + * Returns an async {@linkcode AsyncIterableIterator} over the lines of a file as UTF-8 string. + * @example + * ```typescript + * import { readTextFileLines, BaseDirectory } from '@tauri-apps/plugin-fs'; + * const lines = await readTextFileLines('app.conf', { baseDir: BaseDirectory.AppConfig }); + * for await (const line of lines) { + * console.log(line); + * } + * ``` + * You could also call {@linkcode AsyncIterableIterator.next} to advance the + * iterator so you can lazily read the next line whenever you want. * * @since 2.0.0 */ -async function writeBinaryFile( - path: string | FsBinaryFileOption, - contents?: BinaryFileContents | FsOptions, - options?: FsOptions, -): Promise { - if (typeof options === "object") { - Object.freeze(options); - } - if (typeof path === "object") { - Object.freeze(path); +async function readTextFileLines( + path: string | URL, + options?: ReadFileOptions +): Promise> { + if (path instanceof URL && path.protocol !== 'file:') { + throw new TypeError('Must be a file URL.') } - const file: FsBinaryFileOption = { path: "", contents: [] }; - let fileOptions: FsOptions | undefined = options; - if (typeof path === "string") { - file.path = path; - } else { - file.path = path.path; - file.contents = path.contents; - } + const pathStr = path instanceof URL ? path.toString() : path - if (contents && "dir" in contents) { - fileOptions = contents; - } else if (typeof path === "string") { - // @ts-expect-error in this case `contents` is always a BinaryFileContents - file.contents = contents ?? []; - } + return await Promise.resolve({ + path: pathStr, + rid: null as number | null, + + async next(): Promise> { + if (this.rid === null) { + this.rid = await invoke('plugin:fs|read_text_file_lines', { + path: pathStr, + options + }) + } + + const arr = await invoke( + 'plugin:fs|read_text_file_lines_next', + { rid: this.rid } + ) + + const bytes = + arr instanceof ArrayBuffer ? new Uint8Array(arr) : Uint8Array.from(arr) + + // Rust side will never return an empty array for this command and + // ensure there is at least one elements there. + // + // This is an optimization to include whether we finished iteration or not (1 or 0) + // at the end of returned array to avoid serialization overhead of separate values. + const done = bytes[bytes.byteLength - 1] === 1 + + if (done) { + // a full iteration is over, reset rid for next iteration + this.rid = null + return { value: null, done } + } - return await invoke("plugin:fs|write_file", { - path: file.path, - contents: Array.from( - file.contents instanceof ArrayBuffer - ? new Uint8Array(file.contents) - : file.contents, - ), - options: fileOptions, - }); + const line = new TextDecoder().decode(bytes.slice(0, bytes.byteLength)) + + return { + value: line, + done + } + }, + + [Symbol.asyncIterator](): AsyncIterableIterator { + return this + } + }) } /** - * List directory files. + * @since 2.0.0 + */ +interface RemoveOptions { + /** Defaults to `false`. If set to `true`, path will be removed even if it's a non-empty directory. */ + recursive?: boolean + /** Base directory for `path` */ + baseDir?: BaseDirectory +} + +/** + * Removes the named file or directory. + * If the directory is not empty and the `recursive` option isn't set to true, the promise will be rejected. * @example * ```typescript - * import { readDir, BaseDirectory } from '@tauri-apps/plugin-fs'; - * // Reads the `$APPDATA/users` directory recursively - * const entries = await readDir('users', { dir: BaseDirectory.AppData, recursive: true }); - * - * function processEntries(entries) { - * for (const entry of entries) { - * console.log(`Entry: ${entry.path}`); - * if (entry.children) { - * processEntries(entry.children) - * } - * } - * } + * import { remove, BaseDirectory } from '@tauri-apps/plugin-fs'; + * await remove('users/file.txt', { baseDir: BaseDirectory.AppLocalData }); + * await remove('users', { baseDir: BaseDirectory.AppLocalData }); * ``` * * @since 2.0.0 */ -async function readDir( - dir: string, - options: FsDirOptions = {}, -): Promise { - return await invoke("plugin:fs|read_dir", { - path: dir, - options, - }); +async function remove( + path: string | URL, + options?: RemoveOptions +): Promise { + if (path instanceof URL && path.protocol !== 'file:') { + throw new TypeError('Must be a file URL.') + } + + await invoke('plugin:fs|remove', { + path: path instanceof URL ? path.toString() : path, + options + }) } /** - * Creates a directory. - * If one of the path's parent components doesn't exist - * and the `recursive` option isn't set to true, the promise will be rejected. + * @since 2.0.0 + */ +interface RenameOptions { + /** Base directory for `oldPath`. */ + oldPathBaseDir?: BaseDirectory + /** Base directory for `newPath`. */ + newPathBaseDir?: BaseDirectory +} + +/** + * Renames (moves) oldpath to newpath. Paths may be files or directories. + * If newpath already exists and is not a directory, rename() replaces it. + * OS-specific restrictions may apply when oldpath and newpath are in different directories. + * + * On Unix, this operation does not follow symlinks at either path. + * * @example * ```typescript - * import { createDir, BaseDirectory } from '@tauri-apps/plugin-fs'; - * // Create the `$APPDATA/users` directory - * await createDir('users', { dir: BaseDirectory.AppData, recursive: true }); + * import { rename, BaseDirectory } from '@tauri-apps/plugin-fs'; + * await rename('avatar.png', 'deleted.png', { oldPathBaseDir: BaseDirectory.App, newPathBaseDir: BaseDirectory.AppLocalData }); * ``` * - * @returns A promise indicating the success or failure of the operation. - * * @since 2.0.0 */ -async function createDir( - dir: string, - options: FsDirOptions = {}, +async function rename( + oldPath: string | URL, + newPath: string | URL, + options?: RenameOptions ): Promise { - return await invoke("plugin:fs|create_dir", { - path: dir, - options, - }); + if ( + (oldPath instanceof URL && oldPath.protocol !== 'file:') + || (newPath instanceof URL && newPath.protocol !== 'file:') + ) { + throw new TypeError('Must be a file URL.') + } + + await invoke('plugin:fs|rename', { + oldPath: oldPath instanceof URL ? oldPath.toString() : oldPath, + newPath: newPath instanceof URL ? newPath.toString() : newPath, + options + }) } /** - * Removes a directory. - * If the directory is not empty and the `recursive` option isn't set to true, the promise will be rejected. + * @since 2.0.0 + */ +interface StatOptions { + /** Base directory for `path`. */ + baseDir?: BaseDirectory +} + +/** + * Resolves to a {@linkcode FileInfo} for the specified `path`. Will always + * follow symlinks but will reject if the symlink points to a path outside of the scope. + * * @example * ```typescript - * import { removeDir, BaseDirectory } from '@tauri-apps/plugin-fs'; - * // Remove the directory `$APPDATA/users` - * await removeDir('users', { dir: BaseDirectory.AppData }); + * import { stat, BaseDirectory } from '@tauri-apps/plugin-fs'; + * const fileInfo = await stat("hello.txt", { baseDir: BaseDirectory.AppLocalData }); + * console.log(fileInfo.isFile); // true * ``` * - * @returns A promise indicating the success or failure of the operation. - * * @since 2.0.0 */ -async function removeDir( - dir: string, - options: FsDirOptions = {}, -): Promise { - return await invoke("plugin:fs|remove_dir", { - path: dir, - options, - }); +async function stat( + path: string | URL, + options?: StatOptions +): Promise { + const res = await invoke('plugin:fs|stat', { + path: path instanceof URL ? path.toString() : path, + options + }) + + return parseFileInfo(res) } /** - * Copies a file to a destination. + * Resolves to a {@linkcode FileInfo} for the specified `path`. If `path` is a + * symlink, information for the symlink will be returned instead of what it + * points to. + * * @example * ```typescript - * import { copyFile, BaseDirectory } from '@tauri-apps/plugin-fs'; - * // Copy the `$APPCONFIG/app.conf` file to `$APPCONFIG/app.conf.bk` - * await copyFile('app.conf', 'app.conf.bk', { dir: BaseDirectory.AppConfig }); + * import { lstat, BaseDirectory } from '@tauri-apps/plugin-fs'; + * const fileInfo = await lstat("hello.txt", { baseDir: BaseDirectory.AppLocalData }); + * console.log(fileInfo.isFile); // true * ``` * - * @returns A promise indicating the success or failure of the operation. - * * @since 2.0.0 */ -async function copyFile( - source: string, - destination: string, - options: FsOptions = {}, -): Promise { - return await invoke("plugin:fs|copy_file", { - source, - destination, - options, - }); +async function lstat( + path: string | URL, + options?: StatOptions +): Promise { + const res = await invoke('plugin:fs|lstat', { + path: path instanceof URL ? path.toString() : path, + options + }) + + return parseFileInfo(res) +} + +/** + * @since 2.0.0 + */ +interface TruncateOptions { + /** Base directory for `path`. */ + baseDir?: BaseDirectory } /** - * Removes a file. + * Truncates or extends the specified file, to reach the specified `len`. + * If `len` is `0` or not specified, then the entire file contents are truncated. + * * @example * ```typescript - * import { removeFile, BaseDirectory } from '@tauri-apps/plugin-fs'; - * // Remove the `$APPConfig/app.conf` file - * await removeFile('app.conf', { dir: BaseDirectory.AppConfig }); - * ``` + * import { truncate, readTextFile, writeTextFile, BaseDirectory } from '@tauri-apps/plugin-fs'; + * // truncate the entire file + * await truncate("my_file.txt", 0, { baseDir: BaseDirectory.AppLocalData }); * - * @returns A promise indicating the success or failure of the operation. + * // truncate part of the file + * const filePath = "file.txt"; + * await writeTextFile(filePath, "Hello World", { baseDir: BaseDirectory.AppLocalData }); + * await truncate(filePath, 7, { baseDir: BaseDirectory.AppLocalData }); + * const data = await readTextFile(filePath, { baseDir: BaseDirectory.AppLocalData }); + * console.log(data); // "Hello W" + * ``` * * @since 2.0.0 */ -async function removeFile( - file: string, - options: FsOptions = {}, +async function truncate( + path: string | URL, + len?: number, + options?: TruncateOptions ): Promise { - return await invoke("plugin:fs|remove_file", { - path: file, - options, - }); + if (path instanceof URL && path.protocol !== 'file:') { + throw new TypeError('Must be a file URL.') + } + + await invoke('plugin:fs|truncate', { + path: path instanceof URL ? path.toString() : path, + len, + options + }) +} + +/** + * @since 2.0.0 + */ +interface WriteFileOptions { + /** Defaults to `false`. If set to `true`, will append to a file instead of overwriting previous contents. */ + append?: boolean + /** Sets the option to allow creating a new file, if one doesn't already exist at the specified path (defaults to `true`). */ + create?: boolean + /** Sets the option to create a new file, failing if it already exists. */ + createNew?: boolean + /** File permissions. Ignored on Windows. */ + mode?: number + /** Base directory for `path` */ + baseDir?: BaseDirectory } /** - * Renames a file. + * Write `data` to the given `path`, by default creating a new file if needed, else overwriting. * @example * ```typescript - * import { renameFile, BaseDirectory } from '@tauri-apps/plugin-fs'; - * // Rename the `$APPDATA/avatar.png` file - * await renameFile('avatar.png', 'deleted.png', { dir: BaseDirectory.AppData }); - * ``` + * import { writeFile, BaseDirectory } from '@tauri-apps/plugin-fs'; * - * @returns A promise indicating the success or failure of the operation. + * let encoder = new TextEncoder(); + * let data = encoder.encode("Hello World"); + * await writeFile('file.txt', data, { baseDir: BaseDirectory.AppLocalData }); + * ``` * * @since 2.0.0 */ -async function renameFile( - oldPath: string, - newPath: string, - options: FsOptions = {}, +async function writeFile( + path: string | URL, + data: Uint8Array | ReadableStream, + options?: WriteFileOptions ): Promise { - return await invoke("plugin:fs|rename_file", { - oldPath, - newPath, - options, - }); + if (path instanceof URL && path.protocol !== 'file:') { + throw new TypeError('Must be a file URL.') + } + + if (data instanceof ReadableStream) { + const file = await open(path, options) + const reader = data.getReader() + + try { + while (true) { + const { done, value } = await reader.read() + if (done) break + await file.write(value) + } + } finally { + reader.releaseLock() + await file.close() + } + } else { + await invoke('plugin:fs|write_file', data, { + headers: { + path: encodeURIComponent(path instanceof URL ? path.toString() : path), + options: JSON.stringify(options) + } + }) + } +} + +/** + * Writes UTF-8 string `data` to the given `path`, by default creating a new file if needed, else overwriting. + @example + * ```typescript + * import { writeTextFile, BaseDirectory } from '@tauri-apps/plugin-fs'; + * + * await writeTextFile('file.txt', "Hello world", { baseDir: BaseDirectory.AppLocalData }); + * ``` + * + * @since 2.0.0 + */ +async function writeTextFile( + path: string | URL, + data: string, + options?: WriteFileOptions +): Promise { + if (path instanceof URL && path.protocol !== 'file:') { + throw new TypeError('Must be a file URL.') + } + + const encoder = new TextEncoder() + + await invoke('plugin:fs|write_text_file', encoder.encode(data), { + headers: { + path: encodeURIComponent(path instanceof URL ? path.toString() : path), + options: JSON.stringify(options) + } + }) +} + +/** + * @since 2.0.0 + */ +interface ExistsOptions { + /** Base directory for `path`. */ + baseDir?: BaseDirectory } /** @@ -575,59 +1141,253 @@ async function renameFile( * ```typescript * import { exists, BaseDirectory } from '@tauri-apps/plugin-fs'; * // Check if the `$APPDATA/avatar.png` file exists - * await exists('avatar.png', { dir: BaseDirectory.AppData }); + * await exists('avatar.png', { baseDir: BaseDirectory.AppData }); * ``` * * @since 2.0.0 */ -async function exists(path: string): Promise { - return await invoke("plugin:fs|exists", { path }); +async function exists( + path: string | URL, + options?: ExistsOptions +): Promise { + if (path instanceof URL && path.protocol !== 'file:') { + throw new TypeError('Must be a file URL.') + } + + return await invoke('plugin:fs|exists', { + path: path instanceof URL ? path.toString() : path, + options + }) +} + +/** + * @since 2.0.0 + */ +interface WatchOptions { + /** Watch a directory recursively */ + recursive?: boolean + /** Base directory for `path` */ + baseDir?: BaseDirectory +} + +/** + * @since 2.0.0 + */ +interface DebouncedWatchOptions extends WatchOptions { + /** Debounce delay */ + delayMs?: number +} + +/** + * @since 2.0.0 + */ +interface WatchEvent { + type: WatchEventKind + paths: string[] + attrs: unknown +} + +/** + * @since 2.0.0 + */ +type WatchEventKind = + | 'any' + | { access: WatchEventKindAccess } + | { create: WatchEventKindCreate } + | { modify: WatchEventKindModify } + | { remove: WatchEventKindRemove } + | 'other' + +/** + * @since 2.0.0 + */ +type WatchEventKindAccess = + | { kind: 'any' } + | { kind: 'close'; mode: 'any' | 'execute' | 'read' | 'write' | 'other' } + | { kind: 'open'; mode: 'any' | 'execute' | 'read' | 'write' | 'other' } + | { kind: 'other' } + +/** + * @since 2.0.0 + */ +type WatchEventKindCreate = + | { kind: 'any' } + | { kind: 'file' } + | { kind: 'folder' } + | { kind: 'other' } + +/** + * @since 2.0.0 + */ +type WatchEventKindModify = + | { kind: 'any' } + | { kind: 'data'; mode: 'any' | 'size' | 'content' | 'other' } + | { + kind: 'metadata' + mode: + | 'any' + | 'access-time' + | 'write-time' + | 'permissions' + | 'ownership' + | 'extended' + | 'other' + } + | { kind: 'rename'; mode: 'any' | 'to' | 'from' | 'both' | 'other' } + | { kind: 'other' } + +/** + * @since 2.0.0 + */ +type WatchEventKindRemove = + | { kind: 'any' } + | { kind: 'file' } + | { kind: 'folder' } + | { kind: 'other' } + +// TODO: Remove this in v3, return `Watcher` instead +/** + * @since 2.0.0 + */ +type UnwatchFn = () => void + +class Watcher extends Resource {} + +async function watchInternal( + paths: string | string[] | URL | URL[], + cb: (event: WatchEvent) => void, + options: DebouncedWatchOptions +): Promise { + const watchPaths = Array.isArray(paths) ? paths : [paths] + + for (const path of watchPaths) { + if (path instanceof URL && path.protocol !== 'file:') { + throw new TypeError('Must be a file URL.') + } + } + + const onEvent = new Channel() + onEvent.onmessage = cb + + const rid: number = await invoke('plugin:fs|watch', { + paths: watchPaths.map((p) => (p instanceof URL ? p.toString() : p)), + options, + onEvent + }) + + const watcher = new Watcher(rid) + + return () => { + void watcher.close() + } +} + +// TODO: Return `Watcher` instead in v3 +/** + * Watch changes (after a delay) on files or directories. + * + * @since 2.0.0 + */ +async function watch( + paths: string | string[] | URL | URL[], + cb: (event: WatchEvent) => void, + options?: DebouncedWatchOptions +): Promise { + return await watchInternal(paths, cb, { + delayMs: 2000, + ...options + }) } +// TODO: Return `Watcher` instead in v3 /** - * Returns the metadata for the given path. + * Watch changes on files or directories. * * @since 2.0.0 */ -async function metadata(path: string): Promise { - return await invoke("plugin:fs|metadata", { - path, - }).then((metadata) => { - const { accessedAtMs, createdAtMs, modifiedAtMs, ...data } = metadata; - return { - accessedAt: new Date(accessedAtMs), - createdAt: new Date(createdAtMs), - modifiedAt: new Date(modifiedAtMs), - ...data, - }; - }); +async function watchImmediate( + paths: string | string[] | URL | URL[], + cb: (event: WatchEvent) => void, + options?: WatchOptions +): Promise { + return await watchInternal(paths, cb, { + ...options, + delayMs: undefined + }) +} + +/** + * Get the size of a file or directory. For files, the `stat` functions can be used as well. + * + * If `path` is a directory, this function will recursively iterate over every file and every directory inside of `path` and therefore will be very time consuming if used on larger directories. + * + * @example + * ```typescript + * import { size, BaseDirectory } from '@tauri-apps/plugin-fs'; + * // Get the size of the `$APPDATA/tauri` directory. + * const dirSize = await size('tauri', { baseDir: BaseDirectory.AppData }); + * console.log(dirSize); // 1024 + * ``` + * + * @since 2.1.0 + */ +async function size(path: string | URL): Promise { + if (path instanceof URL && path.protocol !== 'file:') { + throw new TypeError('Must be a file URL.') + } + + return await invoke('plugin:fs|size', { + path: path instanceof URL ? path.toString() : path + }) } export type { - FsOptions, - FsDirOptions, - FsTextFileOption, - BinaryFileContents, - FsBinaryFileOption, - FileEntry, - Permissions, - Metadata, -}; + CreateOptions, + OpenOptions, + CopyFileOptions, + MkdirOptions, + DirEntry, + ReadDirOptions, + ReadFileOptions, + RemoveOptions, + RenameOptions, + StatOptions, + TruncateOptions, + WriteFileOptions, + ExistsOptions, + FileInfo, + WatchOptions, + DebouncedWatchOptions, + WatchEvent, + WatchEventKind, + WatchEventKindAccess, + WatchEventKindCreate, + WatchEventKindModify, + WatchEventKindRemove, + UnwatchFn +} export { BaseDirectory, - BaseDirectory as Dir, + FileHandle, + create, + open, + copyFile, + mkdir, + readDir, + readFile, readTextFile, - readBinaryFile, + readTextFileLines, + remove, + rename, + SeekMode, + stat, + lstat, + truncate, + writeFile, writeTextFile, - writeTextFile as writeFile, - writeBinaryFile, - readDir, - createDir, - removeDir, - copyFile, - removeFile, - renameFile, exists, - metadata, -}; + watch, + watchImmediate, + size +} diff --git a/plugins/fs/package.json b/plugins/fs/package.json index 4d5c5865..ce73027a 100644 --- a/plugins/fs/package.json +++ b/plugins/fs/package.json @@ -1,33 +1,30 @@ { "name": "@tauri-apps/plugin-fs", - "version": "2.0.0-alpha.1", + "version": "2.3.0", "description": "Access the file system.", - "license": "MIT or APACHE-2.0", + "license": "MIT OR Apache-2.0", "authors": [ "Tauri Programme within The Commons Conservancy" ], + "repository": "https://github.com/tauri-apps/plugins-workspace", "type": "module", - "browser": "dist-js/index.min.js", - "module": "dist-js/index.mjs", - "types": "dist-js/index.d.ts", + "types": "./dist-js/index.d.ts", + "main": "./dist-js/index.cjs", + "module": "./dist-js/index.js", "exports": { - "import": "./dist-js/index.mjs", "types": "./dist-js/index.d.ts", - "browser": "./dist-js/index.min.js" + "import": "./dist-js/index.js", + "require": "./dist-js/index.cjs" }, "scripts": { "build": "rollup -c" }, "files": [ "dist-js", - "!dist-js/**/*.map", "README.md", "LICENSE" ], - "devDependencies": { - "tslib": "^2.4.1" - }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.9" + "@tauri-apps/api": "^2.0.0" } } diff --git a/plugins/fs/permissions/app.toml b/plugins/fs/permissions/app.toml new file mode 100644 index 00000000..aeb0521b --- /dev/null +++ b/plugins/fs/permissions/app.toml @@ -0,0 +1,114 @@ +"$schema" = "schemas/schema.json" + +# Scopes Section +# This section contains scopes, which define file level access + +[[permission]] +identifier = "scope-app-recursive" +description = "This scope permits recursive access to the complete application folders, including sub directories and files." + +[[permission.scope.allow]] +path = "$APPCONFIG" +[[permission.scope.allow]] +path = "$APPCONFIG/**" + +[[permission.scope.allow]] +path = "$APPDATA" +[[permission.scope.allow]] +path = "$APPDATA/**" + +[[permission.scope.allow]] +path = "$APPLOCALDATA" +[[permission.scope.allow]] +path = "$APPLOCALDATA/**" + +[[permission.scope.allow]] +path = "$APPCACHE" +[[permission.scope.allow]] +path = "$APPCACHE/**" + +[[permission.scope.allow]] +path = "$APPLOG" +[[permission.scope.allow]] +path = "$APPLOG/**" + +[[permission]] +identifier = "scope-app" +description = "This scope permits access to all files and list content of top level directories in the application folders." + +[[permission.scope.allow]] +path = "$APPCONFIG" +[[permission.scope.allow]] +path = "$APPCONFIG/*" + +[[permission.scope.allow]] +path = "$APPDATA" +[[permission.scope.allow]] +path = "$APPDATA/*" + +[[permission.scope.allow]] +path = "$APPLOCALDATA" +[[permission.scope.allow]] +path = "$APPLOCALDATA/*" + +[[permission.scope.allow]] +path = "$APPCACHE" +[[permission.scope.allow]] +path = "$APPCACHE/*" + +[[permission.scope.allow]] +path = "$APPLOG" +[[permission.scope.allow]] +path = "$APPLOG/*" + +[[permission]] +identifier = "scope-app-index" +description = "This scope permits to list all files and folders in the application directories." + +[[permission.scope.allow]] +path = "$APPCONFIG" + +[[permission.scope.allow]] +path = "$APPDATA" + +[[permission.scope.allow]] +path = "$APPLOCALDATA" + +[[permission.scope.allow]] +path = "$APPCACHE" + +[[permission.scope.allow]] +path = "$APPLOG" + +# Sets Section +# This section combines the scope elements with enablement of commands + +[[set]] +identifier = "allow-app-read-recursive" +description = "This allows full recursive read access to the complete application folders, files and subdirectories." +permissions = ["read-all", "scope-app-recursive"] + +[[set]] +identifier = "allow-app-write-recursive" +description = "This allows full recursive write access to the complete application folders, files and subdirectories." +permissions = ["write-all", "scope-app-recursive"] + +[[set]] +identifier = "allow-app-read" +description = "This allows non-recursive read access to the application folders." +permissions = ["read-all", "scope-app"] + +[[set]] +identifier = "allow-app-write" +description = "This allows non-recursive write access to the application folders." +permissions = ["write-all", "scope-app"] + +[[set]] +identifier = "allow-app-meta-recursive" +description = "This allows full recursive read access to metadata of the application folders, including file listing and statistics." +permissions = ["read-meta", "scope-app-recursive"] + +[[set]] +identifier = "allow-app-meta" +description = "This allows non-recursive read access to metadata of the application folders, including file listing and statistics." +permissions = ["read-meta", "scope-app-index"] diff --git a/plugins/fs/permissions/autogenerated/base-directories/appcache.toml b/plugins/fs/permissions/autogenerated/base-directories/appcache.toml new file mode 100644 index 00000000..50e19efc --- /dev/null +++ b/plugins/fs/permissions/autogenerated/base-directories/appcache.toml @@ -0,0 +1,82 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +# Scopes Section +# This section contains scopes, which define file level access + +[[permission]] +identifier = "scope-appcache-recursive" +description = "This scope permits recursive access to the complete `$APPCACHE` folder, including sub directories and files." + +[[permission.scope.allow]] +path = "$APPCACHE" +[[permission.scope.allow]] +path = "$APPCACHE/**" + +[[permission]] +identifier = "scope-appcache" +description = "This scope permits access to all files and list content of top level directories in the `$APPCACHE` folder." + +[[permission.scope.allow]] +path = "$APPCACHE" +[[permission.scope.allow]] +path = "$APPCACHE/*" + +[[permission]] +identifier = "scope-appcache-index" +description = "This scope permits to list all files and folders in the `$APPCACHE`folder." + +[[permission.scope.allow]] +path = "$APPCACHE" + +# Sets Section +# This section combines the scope elements with enablement of commands + +[[set]] +identifier = "allow-appcache-read-recursive" +description = "This allows full recursive read access to the complete `$APPCACHE` folder, files and subdirectories." +permissions = [ + "read-all", + "scope-appcache-recursive" +] + +[[set]] +identifier = "allow-appcache-write-recursive" +description = "This allows full recursive write access to the complete `$APPCACHE` folder, files and subdirectories." +permissions = [ + "write-all", + "scope-appcache-recursive" +] + +[[set]] +identifier = "allow-appcache-read" +description = "This allows non-recursive read access to the `$APPCACHE` folder." +permissions = [ + "read-all", + "scope-appcache" +] + +[[set]] +identifier = "allow-appcache-write" +description = "This allows non-recursive write access to the `$APPCACHE` folder." +permissions = [ + "write-all", + "scope-appcache" +] + +[[set]] +identifier = "allow-appcache-meta-recursive" +description = "This allows full recursive read access to metadata of the `$APPCACHE` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-appcache-recursive" +] + +[[set]] +identifier = "allow-appcache-meta" +description = "This allows non-recursive read access to metadata of the `$APPCACHE` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-appcache-index" +] \ No newline at end of file diff --git a/plugins/fs/permissions/autogenerated/base-directories/appconfig.toml b/plugins/fs/permissions/autogenerated/base-directories/appconfig.toml new file mode 100644 index 00000000..ab136956 --- /dev/null +++ b/plugins/fs/permissions/autogenerated/base-directories/appconfig.toml @@ -0,0 +1,82 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +# Scopes Section +# This section contains scopes, which define file level access + +[[permission]] +identifier = "scope-appconfig-recursive" +description = "This scope permits recursive access to the complete `$APPCONFIG` folder, including sub directories and files." + +[[permission.scope.allow]] +path = "$APPCONFIG" +[[permission.scope.allow]] +path = "$APPCONFIG/**" + +[[permission]] +identifier = "scope-appconfig" +description = "This scope permits access to all files and list content of top level directories in the `$APPCONFIG` folder." + +[[permission.scope.allow]] +path = "$APPCONFIG" +[[permission.scope.allow]] +path = "$APPCONFIG/*" + +[[permission]] +identifier = "scope-appconfig-index" +description = "This scope permits to list all files and folders in the `$APPCONFIG`folder." + +[[permission.scope.allow]] +path = "$APPCONFIG" + +# Sets Section +# This section combines the scope elements with enablement of commands + +[[set]] +identifier = "allow-appconfig-read-recursive" +description = "This allows full recursive read access to the complete `$APPCONFIG` folder, files and subdirectories." +permissions = [ + "read-all", + "scope-appconfig-recursive" +] + +[[set]] +identifier = "allow-appconfig-write-recursive" +description = "This allows full recursive write access to the complete `$APPCONFIG` folder, files and subdirectories." +permissions = [ + "write-all", + "scope-appconfig-recursive" +] + +[[set]] +identifier = "allow-appconfig-read" +description = "This allows non-recursive read access to the `$APPCONFIG` folder." +permissions = [ + "read-all", + "scope-appconfig" +] + +[[set]] +identifier = "allow-appconfig-write" +description = "This allows non-recursive write access to the `$APPCONFIG` folder." +permissions = [ + "write-all", + "scope-appconfig" +] + +[[set]] +identifier = "allow-appconfig-meta-recursive" +description = "This allows full recursive read access to metadata of the `$APPCONFIG` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-appconfig-recursive" +] + +[[set]] +identifier = "allow-appconfig-meta" +description = "This allows non-recursive read access to metadata of the `$APPCONFIG` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-appconfig-index" +] \ No newline at end of file diff --git a/plugins/fs/permissions/autogenerated/base-directories/appdata.toml b/plugins/fs/permissions/autogenerated/base-directories/appdata.toml new file mode 100644 index 00000000..1b0931e2 --- /dev/null +++ b/plugins/fs/permissions/autogenerated/base-directories/appdata.toml @@ -0,0 +1,82 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +# Scopes Section +# This section contains scopes, which define file level access + +[[permission]] +identifier = "scope-appdata-recursive" +description = "This scope permits recursive access to the complete `$APPDATA` folder, including sub directories and files." + +[[permission.scope.allow]] +path = "$APPDATA" +[[permission.scope.allow]] +path = "$APPDATA/**" + +[[permission]] +identifier = "scope-appdata" +description = "This scope permits access to all files and list content of top level directories in the `$APPDATA` folder." + +[[permission.scope.allow]] +path = "$APPDATA" +[[permission.scope.allow]] +path = "$APPDATA/*" + +[[permission]] +identifier = "scope-appdata-index" +description = "This scope permits to list all files and folders in the `$APPDATA`folder." + +[[permission.scope.allow]] +path = "$APPDATA" + +# Sets Section +# This section combines the scope elements with enablement of commands + +[[set]] +identifier = "allow-appdata-read-recursive" +description = "This allows full recursive read access to the complete `$APPDATA` folder, files and subdirectories." +permissions = [ + "read-all", + "scope-appdata-recursive" +] + +[[set]] +identifier = "allow-appdata-write-recursive" +description = "This allows full recursive write access to the complete `$APPDATA` folder, files and subdirectories." +permissions = [ + "write-all", + "scope-appdata-recursive" +] + +[[set]] +identifier = "allow-appdata-read" +description = "This allows non-recursive read access to the `$APPDATA` folder." +permissions = [ + "read-all", + "scope-appdata" +] + +[[set]] +identifier = "allow-appdata-write" +description = "This allows non-recursive write access to the `$APPDATA` folder." +permissions = [ + "write-all", + "scope-appdata" +] + +[[set]] +identifier = "allow-appdata-meta-recursive" +description = "This allows full recursive read access to metadata of the `$APPDATA` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-appdata-recursive" +] + +[[set]] +identifier = "allow-appdata-meta" +description = "This allows non-recursive read access to metadata of the `$APPDATA` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-appdata-index" +] \ No newline at end of file diff --git a/plugins/fs/permissions/autogenerated/base-directories/applocaldata.toml b/plugins/fs/permissions/autogenerated/base-directories/applocaldata.toml new file mode 100644 index 00000000..a6e38a31 --- /dev/null +++ b/plugins/fs/permissions/autogenerated/base-directories/applocaldata.toml @@ -0,0 +1,82 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +# Scopes Section +# This section contains scopes, which define file level access + +[[permission]] +identifier = "scope-applocaldata-recursive" +description = "This scope permits recursive access to the complete `$APPLOCALDATA` folder, including sub directories and files." + +[[permission.scope.allow]] +path = "$APPLOCALDATA" +[[permission.scope.allow]] +path = "$APPLOCALDATA/**" + +[[permission]] +identifier = "scope-applocaldata" +description = "This scope permits access to all files and list content of top level directories in the `$APPLOCALDATA` folder." + +[[permission.scope.allow]] +path = "$APPLOCALDATA" +[[permission.scope.allow]] +path = "$APPLOCALDATA/*" + +[[permission]] +identifier = "scope-applocaldata-index" +description = "This scope permits to list all files and folders in the `$APPLOCALDATA`folder." + +[[permission.scope.allow]] +path = "$APPLOCALDATA" + +# Sets Section +# This section combines the scope elements with enablement of commands + +[[set]] +identifier = "allow-applocaldata-read-recursive" +description = "This allows full recursive read access to the complete `$APPLOCALDATA` folder, files and subdirectories." +permissions = [ + "read-all", + "scope-applocaldata-recursive" +] + +[[set]] +identifier = "allow-applocaldata-write-recursive" +description = "This allows full recursive write access to the complete `$APPLOCALDATA` folder, files and subdirectories." +permissions = [ + "write-all", + "scope-applocaldata-recursive" +] + +[[set]] +identifier = "allow-applocaldata-read" +description = "This allows non-recursive read access to the `$APPLOCALDATA` folder." +permissions = [ + "read-all", + "scope-applocaldata" +] + +[[set]] +identifier = "allow-applocaldata-write" +description = "This allows non-recursive write access to the `$APPLOCALDATA` folder." +permissions = [ + "write-all", + "scope-applocaldata" +] + +[[set]] +identifier = "allow-applocaldata-meta-recursive" +description = "This allows full recursive read access to metadata of the `$APPLOCALDATA` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-applocaldata-recursive" +] + +[[set]] +identifier = "allow-applocaldata-meta" +description = "This allows non-recursive read access to metadata of the `$APPLOCALDATA` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-applocaldata-index" +] \ No newline at end of file diff --git a/plugins/fs/permissions/autogenerated/base-directories/applog.toml b/plugins/fs/permissions/autogenerated/base-directories/applog.toml new file mode 100644 index 00000000..a979ce76 --- /dev/null +++ b/plugins/fs/permissions/autogenerated/base-directories/applog.toml @@ -0,0 +1,82 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +# Scopes Section +# This section contains scopes, which define file level access + +[[permission]] +identifier = "scope-applog-recursive" +description = "This scope permits recursive access to the complete `$APPLOG` folder, including sub directories and files." + +[[permission.scope.allow]] +path = "$APPLOG" +[[permission.scope.allow]] +path = "$APPLOG/**" + +[[permission]] +identifier = "scope-applog" +description = "This scope permits access to all files and list content of top level directories in the `$APPLOG` folder." + +[[permission.scope.allow]] +path = "$APPLOG" +[[permission.scope.allow]] +path = "$APPLOG/*" + +[[permission]] +identifier = "scope-applog-index" +description = "This scope permits to list all files and folders in the `$APPLOG`folder." + +[[permission.scope.allow]] +path = "$APPLOG" + +# Sets Section +# This section combines the scope elements with enablement of commands + +[[set]] +identifier = "allow-applog-read-recursive" +description = "This allows full recursive read access to the complete `$APPLOG` folder, files and subdirectories." +permissions = [ + "read-all", + "scope-applog-recursive" +] + +[[set]] +identifier = "allow-applog-write-recursive" +description = "This allows full recursive write access to the complete `$APPLOG` folder, files and subdirectories." +permissions = [ + "write-all", + "scope-applog-recursive" +] + +[[set]] +identifier = "allow-applog-read" +description = "This allows non-recursive read access to the `$APPLOG` folder." +permissions = [ + "read-all", + "scope-applog" +] + +[[set]] +identifier = "allow-applog-write" +description = "This allows non-recursive write access to the `$APPLOG` folder." +permissions = [ + "write-all", + "scope-applog" +] + +[[set]] +identifier = "allow-applog-meta-recursive" +description = "This allows full recursive read access to metadata of the `$APPLOG` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-applog-recursive" +] + +[[set]] +identifier = "allow-applog-meta" +description = "This allows non-recursive read access to metadata of the `$APPLOG` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-applog-index" +] \ No newline at end of file diff --git a/plugins/fs/permissions/autogenerated/base-directories/audio.toml b/plugins/fs/permissions/autogenerated/base-directories/audio.toml new file mode 100644 index 00000000..d66d68a2 --- /dev/null +++ b/plugins/fs/permissions/autogenerated/base-directories/audio.toml @@ -0,0 +1,82 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +# Scopes Section +# This section contains scopes, which define file level access + +[[permission]] +identifier = "scope-audio-recursive" +description = "This scope permits recursive access to the complete `$AUDIO` folder, including sub directories and files." + +[[permission.scope.allow]] +path = "$AUDIO" +[[permission.scope.allow]] +path = "$AUDIO/**" + +[[permission]] +identifier = "scope-audio" +description = "This scope permits access to all files and list content of top level directories in the `$AUDIO` folder." + +[[permission.scope.allow]] +path = "$AUDIO" +[[permission.scope.allow]] +path = "$AUDIO/*" + +[[permission]] +identifier = "scope-audio-index" +description = "This scope permits to list all files and folders in the `$AUDIO`folder." + +[[permission.scope.allow]] +path = "$AUDIO" + +# Sets Section +# This section combines the scope elements with enablement of commands + +[[set]] +identifier = "allow-audio-read-recursive" +description = "This allows full recursive read access to the complete `$AUDIO` folder, files and subdirectories." +permissions = [ + "read-all", + "scope-audio-recursive" +] + +[[set]] +identifier = "allow-audio-write-recursive" +description = "This allows full recursive write access to the complete `$AUDIO` folder, files and subdirectories." +permissions = [ + "write-all", + "scope-audio-recursive" +] + +[[set]] +identifier = "allow-audio-read" +description = "This allows non-recursive read access to the `$AUDIO` folder." +permissions = [ + "read-all", + "scope-audio" +] + +[[set]] +identifier = "allow-audio-write" +description = "This allows non-recursive write access to the `$AUDIO` folder." +permissions = [ + "write-all", + "scope-audio" +] + +[[set]] +identifier = "allow-audio-meta-recursive" +description = "This allows full recursive read access to metadata of the `$AUDIO` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-audio-recursive" +] + +[[set]] +identifier = "allow-audio-meta" +description = "This allows non-recursive read access to metadata of the `$AUDIO` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-audio-index" +] \ No newline at end of file diff --git a/plugins/fs/permissions/autogenerated/base-directories/cache.toml b/plugins/fs/permissions/autogenerated/base-directories/cache.toml new file mode 100644 index 00000000..814319eb --- /dev/null +++ b/plugins/fs/permissions/autogenerated/base-directories/cache.toml @@ -0,0 +1,82 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +# Scopes Section +# This section contains scopes, which define file level access + +[[permission]] +identifier = "scope-cache-recursive" +description = "This scope permits recursive access to the complete `$CACHE` folder, including sub directories and files." + +[[permission.scope.allow]] +path = "$CACHE" +[[permission.scope.allow]] +path = "$CACHE/**" + +[[permission]] +identifier = "scope-cache" +description = "This scope permits access to all files and list content of top level directories in the `$CACHE` folder." + +[[permission.scope.allow]] +path = "$CACHE" +[[permission.scope.allow]] +path = "$CACHE/*" + +[[permission]] +identifier = "scope-cache-index" +description = "This scope permits to list all files and folders in the `$CACHE`folder." + +[[permission.scope.allow]] +path = "$CACHE" + +# Sets Section +# This section combines the scope elements with enablement of commands + +[[set]] +identifier = "allow-cache-read-recursive" +description = "This allows full recursive read access to the complete `$CACHE` folder, files and subdirectories." +permissions = [ + "read-all", + "scope-cache-recursive" +] + +[[set]] +identifier = "allow-cache-write-recursive" +description = "This allows full recursive write access to the complete `$CACHE` folder, files and subdirectories." +permissions = [ + "write-all", + "scope-cache-recursive" +] + +[[set]] +identifier = "allow-cache-read" +description = "This allows non-recursive read access to the `$CACHE` folder." +permissions = [ + "read-all", + "scope-cache" +] + +[[set]] +identifier = "allow-cache-write" +description = "This allows non-recursive write access to the `$CACHE` folder." +permissions = [ + "write-all", + "scope-cache" +] + +[[set]] +identifier = "allow-cache-meta-recursive" +description = "This allows full recursive read access to metadata of the `$CACHE` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-cache-recursive" +] + +[[set]] +identifier = "allow-cache-meta" +description = "This allows non-recursive read access to metadata of the `$CACHE` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-cache-index" +] \ No newline at end of file diff --git a/plugins/fs/permissions/autogenerated/base-directories/config.toml b/plugins/fs/permissions/autogenerated/base-directories/config.toml new file mode 100644 index 00000000..59221045 --- /dev/null +++ b/plugins/fs/permissions/autogenerated/base-directories/config.toml @@ -0,0 +1,82 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +# Scopes Section +# This section contains scopes, which define file level access + +[[permission]] +identifier = "scope-config-recursive" +description = "This scope permits recursive access to the complete `$CONFIG` folder, including sub directories and files." + +[[permission.scope.allow]] +path = "$CONFIG" +[[permission.scope.allow]] +path = "$CONFIG/**" + +[[permission]] +identifier = "scope-config" +description = "This scope permits access to all files and list content of top level directories in the `$CONFIG` folder." + +[[permission.scope.allow]] +path = "$CONFIG" +[[permission.scope.allow]] +path = "$CONFIG/*" + +[[permission]] +identifier = "scope-config-index" +description = "This scope permits to list all files and folders in the `$CONFIG`folder." + +[[permission.scope.allow]] +path = "$CONFIG" + +# Sets Section +# This section combines the scope elements with enablement of commands + +[[set]] +identifier = "allow-config-read-recursive" +description = "This allows full recursive read access to the complete `$CONFIG` folder, files and subdirectories." +permissions = [ + "read-all", + "scope-config-recursive" +] + +[[set]] +identifier = "allow-config-write-recursive" +description = "This allows full recursive write access to the complete `$CONFIG` folder, files and subdirectories." +permissions = [ + "write-all", + "scope-config-recursive" +] + +[[set]] +identifier = "allow-config-read" +description = "This allows non-recursive read access to the `$CONFIG` folder." +permissions = [ + "read-all", + "scope-config" +] + +[[set]] +identifier = "allow-config-write" +description = "This allows non-recursive write access to the `$CONFIG` folder." +permissions = [ + "write-all", + "scope-config" +] + +[[set]] +identifier = "allow-config-meta-recursive" +description = "This allows full recursive read access to metadata of the `$CONFIG` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-config-recursive" +] + +[[set]] +identifier = "allow-config-meta" +description = "This allows non-recursive read access to metadata of the `$CONFIG` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-config-index" +] \ No newline at end of file diff --git a/plugins/fs/permissions/autogenerated/base-directories/data.toml b/plugins/fs/permissions/autogenerated/base-directories/data.toml new file mode 100644 index 00000000..a8428ca1 --- /dev/null +++ b/plugins/fs/permissions/autogenerated/base-directories/data.toml @@ -0,0 +1,82 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +# Scopes Section +# This section contains scopes, which define file level access + +[[permission]] +identifier = "scope-data-recursive" +description = "This scope permits recursive access to the complete `$DATA` folder, including sub directories and files." + +[[permission.scope.allow]] +path = "$DATA" +[[permission.scope.allow]] +path = "$DATA/**" + +[[permission]] +identifier = "scope-data" +description = "This scope permits access to all files and list content of top level directories in the `$DATA` folder." + +[[permission.scope.allow]] +path = "$DATA" +[[permission.scope.allow]] +path = "$DATA/*" + +[[permission]] +identifier = "scope-data-index" +description = "This scope permits to list all files and folders in the `$DATA`folder." + +[[permission.scope.allow]] +path = "$DATA" + +# Sets Section +# This section combines the scope elements with enablement of commands + +[[set]] +identifier = "allow-data-read-recursive" +description = "This allows full recursive read access to the complete `$DATA` folder, files and subdirectories." +permissions = [ + "read-all", + "scope-data-recursive" +] + +[[set]] +identifier = "allow-data-write-recursive" +description = "This allows full recursive write access to the complete `$DATA` folder, files and subdirectories." +permissions = [ + "write-all", + "scope-data-recursive" +] + +[[set]] +identifier = "allow-data-read" +description = "This allows non-recursive read access to the `$DATA` folder." +permissions = [ + "read-all", + "scope-data" +] + +[[set]] +identifier = "allow-data-write" +description = "This allows non-recursive write access to the `$DATA` folder." +permissions = [ + "write-all", + "scope-data" +] + +[[set]] +identifier = "allow-data-meta-recursive" +description = "This allows full recursive read access to metadata of the `$DATA` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-data-recursive" +] + +[[set]] +identifier = "allow-data-meta" +description = "This allows non-recursive read access to metadata of the `$DATA` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-data-index" +] \ No newline at end of file diff --git a/plugins/fs/permissions/autogenerated/base-directories/desktop.toml b/plugins/fs/permissions/autogenerated/base-directories/desktop.toml new file mode 100644 index 00000000..da369fa0 --- /dev/null +++ b/plugins/fs/permissions/autogenerated/base-directories/desktop.toml @@ -0,0 +1,82 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +# Scopes Section +# This section contains scopes, which define file level access + +[[permission]] +identifier = "scope-desktop-recursive" +description = "This scope permits recursive access to the complete `$DESKTOP` folder, including sub directories and files." + +[[permission.scope.allow]] +path = "$DESKTOP" +[[permission.scope.allow]] +path = "$DESKTOP/**" + +[[permission]] +identifier = "scope-desktop" +description = "This scope permits access to all files and list content of top level directories in the `$DESKTOP` folder." + +[[permission.scope.allow]] +path = "$DESKTOP" +[[permission.scope.allow]] +path = "$DESKTOP/*" + +[[permission]] +identifier = "scope-desktop-index" +description = "This scope permits to list all files and folders in the `$DESKTOP`folder." + +[[permission.scope.allow]] +path = "$DESKTOP" + +# Sets Section +# This section combines the scope elements with enablement of commands + +[[set]] +identifier = "allow-desktop-read-recursive" +description = "This allows full recursive read access to the complete `$DESKTOP` folder, files and subdirectories." +permissions = [ + "read-all", + "scope-desktop-recursive" +] + +[[set]] +identifier = "allow-desktop-write-recursive" +description = "This allows full recursive write access to the complete `$DESKTOP` folder, files and subdirectories." +permissions = [ + "write-all", + "scope-desktop-recursive" +] + +[[set]] +identifier = "allow-desktop-read" +description = "This allows non-recursive read access to the `$DESKTOP` folder." +permissions = [ + "read-all", + "scope-desktop" +] + +[[set]] +identifier = "allow-desktop-write" +description = "This allows non-recursive write access to the `$DESKTOP` folder." +permissions = [ + "write-all", + "scope-desktop" +] + +[[set]] +identifier = "allow-desktop-meta-recursive" +description = "This allows full recursive read access to metadata of the `$DESKTOP` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-desktop-recursive" +] + +[[set]] +identifier = "allow-desktop-meta" +description = "This allows non-recursive read access to metadata of the `$DESKTOP` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-desktop-index" +] \ No newline at end of file diff --git a/plugins/fs/permissions/autogenerated/base-directories/document.toml b/plugins/fs/permissions/autogenerated/base-directories/document.toml new file mode 100644 index 00000000..9feb4d0d --- /dev/null +++ b/plugins/fs/permissions/autogenerated/base-directories/document.toml @@ -0,0 +1,82 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +# Scopes Section +# This section contains scopes, which define file level access + +[[permission]] +identifier = "scope-document-recursive" +description = "This scope permits recursive access to the complete `$DOCUMENT` folder, including sub directories and files." + +[[permission.scope.allow]] +path = "$DOCUMENT" +[[permission.scope.allow]] +path = "$DOCUMENT/**" + +[[permission]] +identifier = "scope-document" +description = "This scope permits access to all files and list content of top level directories in the `$DOCUMENT` folder." + +[[permission.scope.allow]] +path = "$DOCUMENT" +[[permission.scope.allow]] +path = "$DOCUMENT/*" + +[[permission]] +identifier = "scope-document-index" +description = "This scope permits to list all files and folders in the `$DOCUMENT`folder." + +[[permission.scope.allow]] +path = "$DOCUMENT" + +# Sets Section +# This section combines the scope elements with enablement of commands + +[[set]] +identifier = "allow-document-read-recursive" +description = "This allows full recursive read access to the complete `$DOCUMENT` folder, files and subdirectories." +permissions = [ + "read-all", + "scope-document-recursive" +] + +[[set]] +identifier = "allow-document-write-recursive" +description = "This allows full recursive write access to the complete `$DOCUMENT` folder, files and subdirectories." +permissions = [ + "write-all", + "scope-document-recursive" +] + +[[set]] +identifier = "allow-document-read" +description = "This allows non-recursive read access to the `$DOCUMENT` folder." +permissions = [ + "read-all", + "scope-document" +] + +[[set]] +identifier = "allow-document-write" +description = "This allows non-recursive write access to the `$DOCUMENT` folder." +permissions = [ + "write-all", + "scope-document" +] + +[[set]] +identifier = "allow-document-meta-recursive" +description = "This allows full recursive read access to metadata of the `$DOCUMENT` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-document-recursive" +] + +[[set]] +identifier = "allow-document-meta" +description = "This allows non-recursive read access to metadata of the `$DOCUMENT` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-document-index" +] \ No newline at end of file diff --git a/plugins/fs/permissions/autogenerated/base-directories/download.toml b/plugins/fs/permissions/autogenerated/base-directories/download.toml new file mode 100644 index 00000000..8659e3ac --- /dev/null +++ b/plugins/fs/permissions/autogenerated/base-directories/download.toml @@ -0,0 +1,82 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +# Scopes Section +# This section contains scopes, which define file level access + +[[permission]] +identifier = "scope-download-recursive" +description = "This scope permits recursive access to the complete `$DOWNLOAD` folder, including sub directories and files." + +[[permission.scope.allow]] +path = "$DOWNLOAD" +[[permission.scope.allow]] +path = "$DOWNLOAD/**" + +[[permission]] +identifier = "scope-download" +description = "This scope permits access to all files and list content of top level directories in the `$DOWNLOAD` folder." + +[[permission.scope.allow]] +path = "$DOWNLOAD" +[[permission.scope.allow]] +path = "$DOWNLOAD/*" + +[[permission]] +identifier = "scope-download-index" +description = "This scope permits to list all files and folders in the `$DOWNLOAD`folder." + +[[permission.scope.allow]] +path = "$DOWNLOAD" + +# Sets Section +# This section combines the scope elements with enablement of commands + +[[set]] +identifier = "allow-download-read-recursive" +description = "This allows full recursive read access to the complete `$DOWNLOAD` folder, files and subdirectories." +permissions = [ + "read-all", + "scope-download-recursive" +] + +[[set]] +identifier = "allow-download-write-recursive" +description = "This allows full recursive write access to the complete `$DOWNLOAD` folder, files and subdirectories." +permissions = [ + "write-all", + "scope-download-recursive" +] + +[[set]] +identifier = "allow-download-read" +description = "This allows non-recursive read access to the `$DOWNLOAD` folder." +permissions = [ + "read-all", + "scope-download" +] + +[[set]] +identifier = "allow-download-write" +description = "This allows non-recursive write access to the `$DOWNLOAD` folder." +permissions = [ + "write-all", + "scope-download" +] + +[[set]] +identifier = "allow-download-meta-recursive" +description = "This allows full recursive read access to metadata of the `$DOWNLOAD` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-download-recursive" +] + +[[set]] +identifier = "allow-download-meta" +description = "This allows non-recursive read access to metadata of the `$DOWNLOAD` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-download-index" +] \ No newline at end of file diff --git a/plugins/fs/permissions/autogenerated/base-directories/exe.toml b/plugins/fs/permissions/autogenerated/base-directories/exe.toml new file mode 100644 index 00000000..94950e84 --- /dev/null +++ b/plugins/fs/permissions/autogenerated/base-directories/exe.toml @@ -0,0 +1,82 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +# Scopes Section +# This section contains scopes, which define file level access + +[[permission]] +identifier = "scope-exe-recursive" +description = "This scope permits recursive access to the complete `$EXE` folder, including sub directories and files." + +[[permission.scope.allow]] +path = "$EXE" +[[permission.scope.allow]] +path = "$EXE/**" + +[[permission]] +identifier = "scope-exe" +description = "This scope permits access to all files and list content of top level directories in the `$EXE` folder." + +[[permission.scope.allow]] +path = "$EXE" +[[permission.scope.allow]] +path = "$EXE/*" + +[[permission]] +identifier = "scope-exe-index" +description = "This scope permits to list all files and folders in the `$EXE`folder." + +[[permission.scope.allow]] +path = "$EXE" + +# Sets Section +# This section combines the scope elements with enablement of commands + +[[set]] +identifier = "allow-exe-read-recursive" +description = "This allows full recursive read access to the complete `$EXE` folder, files and subdirectories." +permissions = [ + "read-all", + "scope-exe-recursive" +] + +[[set]] +identifier = "allow-exe-write-recursive" +description = "This allows full recursive write access to the complete `$EXE` folder, files and subdirectories." +permissions = [ + "write-all", + "scope-exe-recursive" +] + +[[set]] +identifier = "allow-exe-read" +description = "This allows non-recursive read access to the `$EXE` folder." +permissions = [ + "read-all", + "scope-exe" +] + +[[set]] +identifier = "allow-exe-write" +description = "This allows non-recursive write access to the `$EXE` folder." +permissions = [ + "write-all", + "scope-exe" +] + +[[set]] +identifier = "allow-exe-meta-recursive" +description = "This allows full recursive read access to metadata of the `$EXE` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-exe-recursive" +] + +[[set]] +identifier = "allow-exe-meta" +description = "This allows non-recursive read access to metadata of the `$EXE` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-exe-index" +] \ No newline at end of file diff --git a/plugins/fs/permissions/autogenerated/base-directories/font.toml b/plugins/fs/permissions/autogenerated/base-directories/font.toml new file mode 100644 index 00000000..21840046 --- /dev/null +++ b/plugins/fs/permissions/autogenerated/base-directories/font.toml @@ -0,0 +1,82 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +# Scopes Section +# This section contains scopes, which define file level access + +[[permission]] +identifier = "scope-font-recursive" +description = "This scope permits recursive access to the complete `$FONT` folder, including sub directories and files." + +[[permission.scope.allow]] +path = "$FONT" +[[permission.scope.allow]] +path = "$FONT/**" + +[[permission]] +identifier = "scope-font" +description = "This scope permits access to all files and list content of top level directories in the `$FONT` folder." + +[[permission.scope.allow]] +path = "$FONT" +[[permission.scope.allow]] +path = "$FONT/*" + +[[permission]] +identifier = "scope-font-index" +description = "This scope permits to list all files and folders in the `$FONT`folder." + +[[permission.scope.allow]] +path = "$FONT" + +# Sets Section +# This section combines the scope elements with enablement of commands + +[[set]] +identifier = "allow-font-read-recursive" +description = "This allows full recursive read access to the complete `$FONT` folder, files and subdirectories." +permissions = [ + "read-all", + "scope-font-recursive" +] + +[[set]] +identifier = "allow-font-write-recursive" +description = "This allows full recursive write access to the complete `$FONT` folder, files and subdirectories." +permissions = [ + "write-all", + "scope-font-recursive" +] + +[[set]] +identifier = "allow-font-read" +description = "This allows non-recursive read access to the `$FONT` folder." +permissions = [ + "read-all", + "scope-font" +] + +[[set]] +identifier = "allow-font-write" +description = "This allows non-recursive write access to the `$FONT` folder." +permissions = [ + "write-all", + "scope-font" +] + +[[set]] +identifier = "allow-font-meta-recursive" +description = "This allows full recursive read access to metadata of the `$FONT` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-font-recursive" +] + +[[set]] +identifier = "allow-font-meta" +description = "This allows non-recursive read access to metadata of the `$FONT` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-font-index" +] \ No newline at end of file diff --git a/plugins/fs/permissions/autogenerated/base-directories/home.toml b/plugins/fs/permissions/autogenerated/base-directories/home.toml new file mode 100644 index 00000000..cbf48e2f --- /dev/null +++ b/plugins/fs/permissions/autogenerated/base-directories/home.toml @@ -0,0 +1,82 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +# Scopes Section +# This section contains scopes, which define file level access + +[[permission]] +identifier = "scope-home-recursive" +description = "This scope permits recursive access to the complete `$HOME` folder, including sub directories and files." + +[[permission.scope.allow]] +path = "$HOME" +[[permission.scope.allow]] +path = "$HOME/**" + +[[permission]] +identifier = "scope-home" +description = "This scope permits access to all files and list content of top level directories in the `$HOME` folder." + +[[permission.scope.allow]] +path = "$HOME" +[[permission.scope.allow]] +path = "$HOME/*" + +[[permission]] +identifier = "scope-home-index" +description = "This scope permits to list all files and folders in the `$HOME`folder." + +[[permission.scope.allow]] +path = "$HOME" + +# Sets Section +# This section combines the scope elements with enablement of commands + +[[set]] +identifier = "allow-home-read-recursive" +description = "This allows full recursive read access to the complete `$HOME` folder, files and subdirectories." +permissions = [ + "read-all", + "scope-home-recursive" +] + +[[set]] +identifier = "allow-home-write-recursive" +description = "This allows full recursive write access to the complete `$HOME` folder, files and subdirectories." +permissions = [ + "write-all", + "scope-home-recursive" +] + +[[set]] +identifier = "allow-home-read" +description = "This allows non-recursive read access to the `$HOME` folder." +permissions = [ + "read-all", + "scope-home" +] + +[[set]] +identifier = "allow-home-write" +description = "This allows non-recursive write access to the `$HOME` folder." +permissions = [ + "write-all", + "scope-home" +] + +[[set]] +identifier = "allow-home-meta-recursive" +description = "This allows full recursive read access to metadata of the `$HOME` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-home-recursive" +] + +[[set]] +identifier = "allow-home-meta" +description = "This allows non-recursive read access to metadata of the `$HOME` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-home-index" +] \ No newline at end of file diff --git a/plugins/fs/permissions/autogenerated/base-directories/localdata.toml b/plugins/fs/permissions/autogenerated/base-directories/localdata.toml new file mode 100644 index 00000000..90a8f48b --- /dev/null +++ b/plugins/fs/permissions/autogenerated/base-directories/localdata.toml @@ -0,0 +1,82 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +# Scopes Section +# This section contains scopes, which define file level access + +[[permission]] +identifier = "scope-localdata-recursive" +description = "This scope permits recursive access to the complete `$LOCALDATA` folder, including sub directories and files." + +[[permission.scope.allow]] +path = "$LOCALDATA" +[[permission.scope.allow]] +path = "$LOCALDATA/**" + +[[permission]] +identifier = "scope-localdata" +description = "This scope permits access to all files and list content of top level directories in the `$LOCALDATA` folder." + +[[permission.scope.allow]] +path = "$LOCALDATA" +[[permission.scope.allow]] +path = "$LOCALDATA/*" + +[[permission]] +identifier = "scope-localdata-index" +description = "This scope permits to list all files and folders in the `$LOCALDATA`folder." + +[[permission.scope.allow]] +path = "$LOCALDATA" + +# Sets Section +# This section combines the scope elements with enablement of commands + +[[set]] +identifier = "allow-localdata-read-recursive" +description = "This allows full recursive read access to the complete `$LOCALDATA` folder, files and subdirectories." +permissions = [ + "read-all", + "scope-localdata-recursive" +] + +[[set]] +identifier = "allow-localdata-write-recursive" +description = "This allows full recursive write access to the complete `$LOCALDATA` folder, files and subdirectories." +permissions = [ + "write-all", + "scope-localdata-recursive" +] + +[[set]] +identifier = "allow-localdata-read" +description = "This allows non-recursive read access to the `$LOCALDATA` folder." +permissions = [ + "read-all", + "scope-localdata" +] + +[[set]] +identifier = "allow-localdata-write" +description = "This allows non-recursive write access to the `$LOCALDATA` folder." +permissions = [ + "write-all", + "scope-localdata" +] + +[[set]] +identifier = "allow-localdata-meta-recursive" +description = "This allows full recursive read access to metadata of the `$LOCALDATA` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-localdata-recursive" +] + +[[set]] +identifier = "allow-localdata-meta" +description = "This allows non-recursive read access to metadata of the `$LOCALDATA` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-localdata-index" +] \ No newline at end of file diff --git a/plugins/fs/permissions/autogenerated/base-directories/log.toml b/plugins/fs/permissions/autogenerated/base-directories/log.toml new file mode 100644 index 00000000..d505a3ce --- /dev/null +++ b/plugins/fs/permissions/autogenerated/base-directories/log.toml @@ -0,0 +1,82 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +# Scopes Section +# This section contains scopes, which define file level access + +[[permission]] +identifier = "scope-log-recursive" +description = "This scope permits recursive access to the complete `$LOG` folder, including sub directories and files." + +[[permission.scope.allow]] +path = "$LOG" +[[permission.scope.allow]] +path = "$LOG/**" + +[[permission]] +identifier = "scope-log" +description = "This scope permits access to all files and list content of top level directories in the `$LOG` folder." + +[[permission.scope.allow]] +path = "$LOG" +[[permission.scope.allow]] +path = "$LOG/*" + +[[permission]] +identifier = "scope-log-index" +description = "This scope permits to list all files and folders in the `$LOG`folder." + +[[permission.scope.allow]] +path = "$LOG" + +# Sets Section +# This section combines the scope elements with enablement of commands + +[[set]] +identifier = "allow-log-read-recursive" +description = "This allows full recursive read access to the complete `$LOG` folder, files and subdirectories." +permissions = [ + "read-all", + "scope-log-recursive" +] + +[[set]] +identifier = "allow-log-write-recursive" +description = "This allows full recursive write access to the complete `$LOG` folder, files and subdirectories." +permissions = [ + "write-all", + "scope-log-recursive" +] + +[[set]] +identifier = "allow-log-read" +description = "This allows non-recursive read access to the `$LOG` folder." +permissions = [ + "read-all", + "scope-log" +] + +[[set]] +identifier = "allow-log-write" +description = "This allows non-recursive write access to the `$LOG` folder." +permissions = [ + "write-all", + "scope-log" +] + +[[set]] +identifier = "allow-log-meta-recursive" +description = "This allows full recursive read access to metadata of the `$LOG` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-log-recursive" +] + +[[set]] +identifier = "allow-log-meta" +description = "This allows non-recursive read access to metadata of the `$LOG` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-log-index" +] \ No newline at end of file diff --git a/plugins/fs/permissions/autogenerated/base-directories/picture.toml b/plugins/fs/permissions/autogenerated/base-directories/picture.toml new file mode 100644 index 00000000..6a760909 --- /dev/null +++ b/plugins/fs/permissions/autogenerated/base-directories/picture.toml @@ -0,0 +1,82 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +# Scopes Section +# This section contains scopes, which define file level access + +[[permission]] +identifier = "scope-picture-recursive" +description = "This scope permits recursive access to the complete `$PICTURE` folder, including sub directories and files." + +[[permission.scope.allow]] +path = "$PICTURE" +[[permission.scope.allow]] +path = "$PICTURE/**" + +[[permission]] +identifier = "scope-picture" +description = "This scope permits access to all files and list content of top level directories in the `$PICTURE` folder." + +[[permission.scope.allow]] +path = "$PICTURE" +[[permission.scope.allow]] +path = "$PICTURE/*" + +[[permission]] +identifier = "scope-picture-index" +description = "This scope permits to list all files and folders in the `$PICTURE`folder." + +[[permission.scope.allow]] +path = "$PICTURE" + +# Sets Section +# This section combines the scope elements with enablement of commands + +[[set]] +identifier = "allow-picture-read-recursive" +description = "This allows full recursive read access to the complete `$PICTURE` folder, files and subdirectories." +permissions = [ + "read-all", + "scope-picture-recursive" +] + +[[set]] +identifier = "allow-picture-write-recursive" +description = "This allows full recursive write access to the complete `$PICTURE` folder, files and subdirectories." +permissions = [ + "write-all", + "scope-picture-recursive" +] + +[[set]] +identifier = "allow-picture-read" +description = "This allows non-recursive read access to the `$PICTURE` folder." +permissions = [ + "read-all", + "scope-picture" +] + +[[set]] +identifier = "allow-picture-write" +description = "This allows non-recursive write access to the `$PICTURE` folder." +permissions = [ + "write-all", + "scope-picture" +] + +[[set]] +identifier = "allow-picture-meta-recursive" +description = "This allows full recursive read access to metadata of the `$PICTURE` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-picture-recursive" +] + +[[set]] +identifier = "allow-picture-meta" +description = "This allows non-recursive read access to metadata of the `$PICTURE` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-picture-index" +] \ No newline at end of file diff --git a/plugins/fs/permissions/autogenerated/base-directories/public.toml b/plugins/fs/permissions/autogenerated/base-directories/public.toml new file mode 100644 index 00000000..2e39abb4 --- /dev/null +++ b/plugins/fs/permissions/autogenerated/base-directories/public.toml @@ -0,0 +1,82 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +# Scopes Section +# This section contains scopes, which define file level access + +[[permission]] +identifier = "scope-public-recursive" +description = "This scope permits recursive access to the complete `$PUBLIC` folder, including sub directories and files." + +[[permission.scope.allow]] +path = "$PUBLIC" +[[permission.scope.allow]] +path = "$PUBLIC/**" + +[[permission]] +identifier = "scope-public" +description = "This scope permits access to all files and list content of top level directories in the `$PUBLIC` folder." + +[[permission.scope.allow]] +path = "$PUBLIC" +[[permission.scope.allow]] +path = "$PUBLIC/*" + +[[permission]] +identifier = "scope-public-index" +description = "This scope permits to list all files and folders in the `$PUBLIC`folder." + +[[permission.scope.allow]] +path = "$PUBLIC" + +# Sets Section +# This section combines the scope elements with enablement of commands + +[[set]] +identifier = "allow-public-read-recursive" +description = "This allows full recursive read access to the complete `$PUBLIC` folder, files and subdirectories." +permissions = [ + "read-all", + "scope-public-recursive" +] + +[[set]] +identifier = "allow-public-write-recursive" +description = "This allows full recursive write access to the complete `$PUBLIC` folder, files and subdirectories." +permissions = [ + "write-all", + "scope-public-recursive" +] + +[[set]] +identifier = "allow-public-read" +description = "This allows non-recursive read access to the `$PUBLIC` folder." +permissions = [ + "read-all", + "scope-public" +] + +[[set]] +identifier = "allow-public-write" +description = "This allows non-recursive write access to the `$PUBLIC` folder." +permissions = [ + "write-all", + "scope-public" +] + +[[set]] +identifier = "allow-public-meta-recursive" +description = "This allows full recursive read access to metadata of the `$PUBLIC` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-public-recursive" +] + +[[set]] +identifier = "allow-public-meta" +description = "This allows non-recursive read access to metadata of the `$PUBLIC` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-public-index" +] \ No newline at end of file diff --git a/plugins/fs/permissions/autogenerated/base-directories/resource.toml b/plugins/fs/permissions/autogenerated/base-directories/resource.toml new file mode 100644 index 00000000..53dfeb07 --- /dev/null +++ b/plugins/fs/permissions/autogenerated/base-directories/resource.toml @@ -0,0 +1,82 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +# Scopes Section +# This section contains scopes, which define file level access + +[[permission]] +identifier = "scope-resource-recursive" +description = "This scope permits recursive access to the complete `$RESOURCE` folder, including sub directories and files." + +[[permission.scope.allow]] +path = "$RESOURCE" +[[permission.scope.allow]] +path = "$RESOURCE/**" + +[[permission]] +identifier = "scope-resource" +description = "This scope permits access to all files and list content of top level directories in the `$RESOURCE` folder." + +[[permission.scope.allow]] +path = "$RESOURCE" +[[permission.scope.allow]] +path = "$RESOURCE/*" + +[[permission]] +identifier = "scope-resource-index" +description = "This scope permits to list all files and folders in the `$RESOURCE`folder." + +[[permission.scope.allow]] +path = "$RESOURCE" + +# Sets Section +# This section combines the scope elements with enablement of commands + +[[set]] +identifier = "allow-resource-read-recursive" +description = "This allows full recursive read access to the complete `$RESOURCE` folder, files and subdirectories." +permissions = [ + "read-all", + "scope-resource-recursive" +] + +[[set]] +identifier = "allow-resource-write-recursive" +description = "This allows full recursive write access to the complete `$RESOURCE` folder, files and subdirectories." +permissions = [ + "write-all", + "scope-resource-recursive" +] + +[[set]] +identifier = "allow-resource-read" +description = "This allows non-recursive read access to the `$RESOURCE` folder." +permissions = [ + "read-all", + "scope-resource" +] + +[[set]] +identifier = "allow-resource-write" +description = "This allows non-recursive write access to the `$RESOURCE` folder." +permissions = [ + "write-all", + "scope-resource" +] + +[[set]] +identifier = "allow-resource-meta-recursive" +description = "This allows full recursive read access to metadata of the `$RESOURCE` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-resource-recursive" +] + +[[set]] +identifier = "allow-resource-meta" +description = "This allows non-recursive read access to metadata of the `$RESOURCE` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-resource-index" +] \ No newline at end of file diff --git a/plugins/fs/permissions/autogenerated/base-directories/runtime.toml b/plugins/fs/permissions/autogenerated/base-directories/runtime.toml new file mode 100644 index 00000000..8dcc2a03 --- /dev/null +++ b/plugins/fs/permissions/autogenerated/base-directories/runtime.toml @@ -0,0 +1,82 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +# Scopes Section +# This section contains scopes, which define file level access + +[[permission]] +identifier = "scope-runtime-recursive" +description = "This scope permits recursive access to the complete `$RUNTIME` folder, including sub directories and files." + +[[permission.scope.allow]] +path = "$RUNTIME" +[[permission.scope.allow]] +path = "$RUNTIME/**" + +[[permission]] +identifier = "scope-runtime" +description = "This scope permits access to all files and list content of top level directories in the `$RUNTIME` folder." + +[[permission.scope.allow]] +path = "$RUNTIME" +[[permission.scope.allow]] +path = "$RUNTIME/*" + +[[permission]] +identifier = "scope-runtime-index" +description = "This scope permits to list all files and folders in the `$RUNTIME`folder." + +[[permission.scope.allow]] +path = "$RUNTIME" + +# Sets Section +# This section combines the scope elements with enablement of commands + +[[set]] +identifier = "allow-runtime-read-recursive" +description = "This allows full recursive read access to the complete `$RUNTIME` folder, files and subdirectories." +permissions = [ + "read-all", + "scope-runtime-recursive" +] + +[[set]] +identifier = "allow-runtime-write-recursive" +description = "This allows full recursive write access to the complete `$RUNTIME` folder, files and subdirectories." +permissions = [ + "write-all", + "scope-runtime-recursive" +] + +[[set]] +identifier = "allow-runtime-read" +description = "This allows non-recursive read access to the `$RUNTIME` folder." +permissions = [ + "read-all", + "scope-runtime" +] + +[[set]] +identifier = "allow-runtime-write" +description = "This allows non-recursive write access to the `$RUNTIME` folder." +permissions = [ + "write-all", + "scope-runtime" +] + +[[set]] +identifier = "allow-runtime-meta-recursive" +description = "This allows full recursive read access to metadata of the `$RUNTIME` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-runtime-recursive" +] + +[[set]] +identifier = "allow-runtime-meta" +description = "This allows non-recursive read access to metadata of the `$RUNTIME` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-runtime-index" +] \ No newline at end of file diff --git a/plugins/fs/permissions/autogenerated/base-directories/temp.toml b/plugins/fs/permissions/autogenerated/base-directories/temp.toml new file mode 100644 index 00000000..c08e1da2 --- /dev/null +++ b/plugins/fs/permissions/autogenerated/base-directories/temp.toml @@ -0,0 +1,82 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +# Scopes Section +# This section contains scopes, which define file level access + +[[permission]] +identifier = "scope-temp-recursive" +description = "This scope permits recursive access to the complete `$TEMP` folder, including sub directories and files." + +[[permission.scope.allow]] +path = "$TEMP" +[[permission.scope.allow]] +path = "$TEMP/**" + +[[permission]] +identifier = "scope-temp" +description = "This scope permits access to all files and list content of top level directories in the `$TEMP` folder." + +[[permission.scope.allow]] +path = "$TEMP" +[[permission.scope.allow]] +path = "$TEMP/*" + +[[permission]] +identifier = "scope-temp-index" +description = "This scope permits to list all files and folders in the `$TEMP`folder." + +[[permission.scope.allow]] +path = "$TEMP" + +# Sets Section +# This section combines the scope elements with enablement of commands + +[[set]] +identifier = "allow-temp-read-recursive" +description = "This allows full recursive read access to the complete `$TEMP` folder, files and subdirectories." +permissions = [ + "read-all", + "scope-temp-recursive" +] + +[[set]] +identifier = "allow-temp-write-recursive" +description = "This allows full recursive write access to the complete `$TEMP` folder, files and subdirectories." +permissions = [ + "write-all", + "scope-temp-recursive" +] + +[[set]] +identifier = "allow-temp-read" +description = "This allows non-recursive read access to the `$TEMP` folder." +permissions = [ + "read-all", + "scope-temp" +] + +[[set]] +identifier = "allow-temp-write" +description = "This allows non-recursive write access to the `$TEMP` folder." +permissions = [ + "write-all", + "scope-temp" +] + +[[set]] +identifier = "allow-temp-meta-recursive" +description = "This allows full recursive read access to metadata of the `$TEMP` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-temp-recursive" +] + +[[set]] +identifier = "allow-temp-meta" +description = "This allows non-recursive read access to metadata of the `$TEMP` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-temp-index" +] \ No newline at end of file diff --git a/plugins/fs/permissions/autogenerated/base-directories/template.toml b/plugins/fs/permissions/autogenerated/base-directories/template.toml new file mode 100644 index 00000000..ce39f773 --- /dev/null +++ b/plugins/fs/permissions/autogenerated/base-directories/template.toml @@ -0,0 +1,82 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +# Scopes Section +# This section contains scopes, which define file level access + +[[permission]] +identifier = "scope-template-recursive" +description = "This scope permits recursive access to the complete `$TEMPLATE` folder, including sub directories and files." + +[[permission.scope.allow]] +path = "$TEMPLATE" +[[permission.scope.allow]] +path = "$TEMPLATE/**" + +[[permission]] +identifier = "scope-template" +description = "This scope permits access to all files and list content of top level directories in the `$TEMPLATE` folder." + +[[permission.scope.allow]] +path = "$TEMPLATE" +[[permission.scope.allow]] +path = "$TEMPLATE/*" + +[[permission]] +identifier = "scope-template-index" +description = "This scope permits to list all files and folders in the `$TEMPLATE`folder." + +[[permission.scope.allow]] +path = "$TEMPLATE" + +# Sets Section +# This section combines the scope elements with enablement of commands + +[[set]] +identifier = "allow-template-read-recursive" +description = "This allows full recursive read access to the complete `$TEMPLATE` folder, files and subdirectories." +permissions = [ + "read-all", + "scope-template-recursive" +] + +[[set]] +identifier = "allow-template-write-recursive" +description = "This allows full recursive write access to the complete `$TEMPLATE` folder, files and subdirectories." +permissions = [ + "write-all", + "scope-template-recursive" +] + +[[set]] +identifier = "allow-template-read" +description = "This allows non-recursive read access to the `$TEMPLATE` folder." +permissions = [ + "read-all", + "scope-template" +] + +[[set]] +identifier = "allow-template-write" +description = "This allows non-recursive write access to the `$TEMPLATE` folder." +permissions = [ + "write-all", + "scope-template" +] + +[[set]] +identifier = "allow-template-meta-recursive" +description = "This allows full recursive read access to metadata of the `$TEMPLATE` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-template-recursive" +] + +[[set]] +identifier = "allow-template-meta" +description = "This allows non-recursive read access to metadata of the `$TEMPLATE` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-template-index" +] \ No newline at end of file diff --git a/plugins/fs/permissions/autogenerated/base-directories/video.toml b/plugins/fs/permissions/autogenerated/base-directories/video.toml new file mode 100644 index 00000000..df41abdc --- /dev/null +++ b/plugins/fs/permissions/autogenerated/base-directories/video.toml @@ -0,0 +1,82 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +# Scopes Section +# This section contains scopes, which define file level access + +[[permission]] +identifier = "scope-video-recursive" +description = "This scope permits recursive access to the complete `$VIDEO` folder, including sub directories and files." + +[[permission.scope.allow]] +path = "$VIDEO" +[[permission.scope.allow]] +path = "$VIDEO/**" + +[[permission]] +identifier = "scope-video" +description = "This scope permits access to all files and list content of top level directories in the `$VIDEO` folder." + +[[permission.scope.allow]] +path = "$VIDEO" +[[permission.scope.allow]] +path = "$VIDEO/*" + +[[permission]] +identifier = "scope-video-index" +description = "This scope permits to list all files and folders in the `$VIDEO`folder." + +[[permission.scope.allow]] +path = "$VIDEO" + +# Sets Section +# This section combines the scope elements with enablement of commands + +[[set]] +identifier = "allow-video-read-recursive" +description = "This allows full recursive read access to the complete `$VIDEO` folder, files and subdirectories." +permissions = [ + "read-all", + "scope-video-recursive" +] + +[[set]] +identifier = "allow-video-write-recursive" +description = "This allows full recursive write access to the complete `$VIDEO` folder, files and subdirectories." +permissions = [ + "write-all", + "scope-video-recursive" +] + +[[set]] +identifier = "allow-video-read" +description = "This allows non-recursive read access to the `$VIDEO` folder." +permissions = [ + "read-all", + "scope-video" +] + +[[set]] +identifier = "allow-video-write" +description = "This allows non-recursive write access to the `$VIDEO` folder." +permissions = [ + "write-all", + "scope-video" +] + +[[set]] +identifier = "allow-video-meta-recursive" +description = "This allows full recursive read access to metadata of the `$VIDEO` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-video-recursive" +] + +[[set]] +identifier = "allow-video-meta" +description = "This allows non-recursive read access to metadata of the `$VIDEO` folder, including file listing and statistics." +permissions = [ + "read-meta", + "scope-video-index" +] \ No newline at end of file diff --git a/plugins/fs/permissions/autogenerated/commands/copy_file.toml b/plugins/fs/permissions/autogenerated/commands/copy_file.toml new file mode 100644 index 00000000..61bedf9e --- /dev/null +++ b/plugins/fs/permissions/autogenerated/commands/copy_file.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-copy-file" +description = "Enables the copy_file command without any pre-configured scope." +commands.allow = ["copy_file"] + +[[permission]] +identifier = "deny-copy-file" +description = "Denies the copy_file command without any pre-configured scope." +commands.deny = ["copy_file"] diff --git a/plugins/fs/permissions/autogenerated/commands/create.toml b/plugins/fs/permissions/autogenerated/commands/create.toml new file mode 100644 index 00000000..6646cc6c --- /dev/null +++ b/plugins/fs/permissions/autogenerated/commands/create.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-create" +description = "Enables the create command without any pre-configured scope." +commands.allow = ["create"] + +[[permission]] +identifier = "deny-create" +description = "Denies the create command without any pre-configured scope." +commands.deny = ["create"] diff --git a/plugins/fs/permissions/autogenerated/commands/exists.toml b/plugins/fs/permissions/autogenerated/commands/exists.toml new file mode 100644 index 00000000..0eed148f --- /dev/null +++ b/plugins/fs/permissions/autogenerated/commands/exists.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-exists" +description = "Enables the exists command without any pre-configured scope." +commands.allow = ["exists"] + +[[permission]] +identifier = "deny-exists" +description = "Denies the exists command without any pre-configured scope." +commands.deny = ["exists"] diff --git a/plugins/fs/permissions/autogenerated/commands/fstat.toml b/plugins/fs/permissions/autogenerated/commands/fstat.toml new file mode 100644 index 00000000..30d28112 --- /dev/null +++ b/plugins/fs/permissions/autogenerated/commands/fstat.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-fstat" +description = "Enables the fstat command without any pre-configured scope." +commands.allow = ["fstat"] + +[[permission]] +identifier = "deny-fstat" +description = "Denies the fstat command without any pre-configured scope." +commands.deny = ["fstat"] diff --git a/plugins/fs/permissions/autogenerated/commands/ftruncate.toml b/plugins/fs/permissions/autogenerated/commands/ftruncate.toml new file mode 100644 index 00000000..6b54ffe0 --- /dev/null +++ b/plugins/fs/permissions/autogenerated/commands/ftruncate.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-ftruncate" +description = "Enables the ftruncate command without any pre-configured scope." +commands.allow = ["ftruncate"] + +[[permission]] +identifier = "deny-ftruncate" +description = "Denies the ftruncate command without any pre-configured scope." +commands.deny = ["ftruncate"] diff --git a/plugins/fs/permissions/autogenerated/commands/lstat.toml b/plugins/fs/permissions/autogenerated/commands/lstat.toml new file mode 100644 index 00000000..b224635b --- /dev/null +++ b/plugins/fs/permissions/autogenerated/commands/lstat.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-lstat" +description = "Enables the lstat command without any pre-configured scope." +commands.allow = ["lstat"] + +[[permission]] +identifier = "deny-lstat" +description = "Denies the lstat command without any pre-configured scope." +commands.deny = ["lstat"] diff --git a/plugins/fs/permissions/autogenerated/commands/mkdir.toml b/plugins/fs/permissions/autogenerated/commands/mkdir.toml new file mode 100644 index 00000000..58cdbbc7 --- /dev/null +++ b/plugins/fs/permissions/autogenerated/commands/mkdir.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-mkdir" +description = "Enables the mkdir command without any pre-configured scope." +commands.allow = ["mkdir"] + +[[permission]] +identifier = "deny-mkdir" +description = "Denies the mkdir command without any pre-configured scope." +commands.deny = ["mkdir"] diff --git a/plugins/fs/permissions/autogenerated/commands/open.toml b/plugins/fs/permissions/autogenerated/commands/open.toml new file mode 100644 index 00000000..4ea6dff1 --- /dev/null +++ b/plugins/fs/permissions/autogenerated/commands/open.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-open" +description = "Enables the open command without any pre-configured scope." +commands.allow = ["open"] + +[[permission]] +identifier = "deny-open" +description = "Denies the open command without any pre-configured scope." +commands.deny = ["open"] diff --git a/plugins/fs/permissions/autogenerated/commands/read.toml b/plugins/fs/permissions/autogenerated/commands/read.toml new file mode 100644 index 00000000..20fa10c6 --- /dev/null +++ b/plugins/fs/permissions/autogenerated/commands/read.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-read" +description = "Enables the read command without any pre-configured scope." +commands.allow = ["read"] + +[[permission]] +identifier = "deny-read" +description = "Denies the read command without any pre-configured scope." +commands.deny = ["read"] diff --git a/plugins/fs/permissions/autogenerated/commands/read_dir.toml b/plugins/fs/permissions/autogenerated/commands/read_dir.toml new file mode 100644 index 00000000..eef68eba --- /dev/null +++ b/plugins/fs/permissions/autogenerated/commands/read_dir.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-read-dir" +description = "Enables the read_dir command without any pre-configured scope." +commands.allow = ["read_dir"] + +[[permission]] +identifier = "deny-read-dir" +description = "Denies the read_dir command without any pre-configured scope." +commands.deny = ["read_dir"] diff --git a/plugins/fs/permissions/autogenerated/commands/read_file.toml b/plugins/fs/permissions/autogenerated/commands/read_file.toml new file mode 100644 index 00000000..b932b71a --- /dev/null +++ b/plugins/fs/permissions/autogenerated/commands/read_file.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-read-file" +description = "Enables the read_file command without any pre-configured scope." +commands.allow = ["read_file"] + +[[permission]] +identifier = "deny-read-file" +description = "Denies the read_file command without any pre-configured scope." +commands.deny = ["read_file"] diff --git a/plugins/fs/permissions/autogenerated/commands/read_text_file.toml b/plugins/fs/permissions/autogenerated/commands/read_text_file.toml new file mode 100644 index 00000000..7a25115d --- /dev/null +++ b/plugins/fs/permissions/autogenerated/commands/read_text_file.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-read-text-file" +description = "Enables the read_text_file command without any pre-configured scope." +commands.allow = ["read_text_file"] + +[[permission]] +identifier = "deny-read-text-file" +description = "Denies the read_text_file command without any pre-configured scope." +commands.deny = ["read_text_file"] diff --git a/plugins/fs/permissions/autogenerated/commands/read_text_file_lines.toml b/plugins/fs/permissions/autogenerated/commands/read_text_file_lines.toml new file mode 100644 index 00000000..84b4ebb2 --- /dev/null +++ b/plugins/fs/permissions/autogenerated/commands/read_text_file_lines.toml @@ -0,0 +1,22 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-read-text-file-lines" +description = "Enables the read_text_file_lines command without any pre-configured scope." + +[permission.commands] +allow = [ + "read_text_file_lines", + "read_text_file_lines_next", +] +deny = [] + +[[permission]] +identifier = "deny-read-text-file-lines" +description = "Denies the read_text_file_lines command without any pre-configured scope." + +[permission.commands] +allow = [] +deny = ["read_text_file_lines"] diff --git a/plugins/fs/permissions/autogenerated/commands/read_text_file_lines_next.toml b/plugins/fs/permissions/autogenerated/commands/read_text_file_lines_next.toml new file mode 100644 index 00000000..021ea37c --- /dev/null +++ b/plugins/fs/permissions/autogenerated/commands/read_text_file_lines_next.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-read-text-file-lines-next" +description = "Enables the read_text_file_lines_next command without any pre-configured scope." +commands.allow = ["read_text_file_lines_next"] + +[[permission]] +identifier = "deny-read-text-file-lines-next" +description = "Denies the read_text_file_lines_next command without any pre-configured scope." +commands.deny = ["read_text_file_lines_next"] diff --git a/plugins/fs/permissions/autogenerated/commands/remove.toml b/plugins/fs/permissions/autogenerated/commands/remove.toml new file mode 100644 index 00000000..9c9791eb --- /dev/null +++ b/plugins/fs/permissions/autogenerated/commands/remove.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-remove" +description = "Enables the remove command without any pre-configured scope." +commands.allow = ["remove"] + +[[permission]] +identifier = "deny-remove" +description = "Denies the remove command without any pre-configured scope." +commands.deny = ["remove"] diff --git a/plugins/fs/permissions/autogenerated/commands/rename.toml b/plugins/fs/permissions/autogenerated/commands/rename.toml new file mode 100644 index 00000000..91def18f --- /dev/null +++ b/plugins/fs/permissions/autogenerated/commands/rename.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-rename" +description = "Enables the rename command without any pre-configured scope." +commands.allow = ["rename"] + +[[permission]] +identifier = "deny-rename" +description = "Denies the rename command without any pre-configured scope." +commands.deny = ["rename"] diff --git a/plugins/fs/permissions/autogenerated/commands/seek.toml b/plugins/fs/permissions/autogenerated/commands/seek.toml new file mode 100644 index 00000000..cb21bdc3 --- /dev/null +++ b/plugins/fs/permissions/autogenerated/commands/seek.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-seek" +description = "Enables the seek command without any pre-configured scope." +commands.allow = ["seek"] + +[[permission]] +identifier = "deny-seek" +description = "Denies the seek command without any pre-configured scope." +commands.deny = ["seek"] diff --git a/plugins/fs/permissions/autogenerated/commands/size.toml b/plugins/fs/permissions/autogenerated/commands/size.toml new file mode 100644 index 00000000..8a0ea55c --- /dev/null +++ b/plugins/fs/permissions/autogenerated/commands/size.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-size" +description = "Enables the size command without any pre-configured scope." +commands.allow = ["size"] + +[[permission]] +identifier = "deny-size" +description = "Denies the size command without any pre-configured scope." +commands.deny = ["size"] diff --git a/plugins/fs/permissions/autogenerated/commands/stat.toml b/plugins/fs/permissions/autogenerated/commands/stat.toml new file mode 100644 index 00000000..56f751bc --- /dev/null +++ b/plugins/fs/permissions/autogenerated/commands/stat.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-stat" +description = "Enables the stat command without any pre-configured scope." +commands.allow = ["stat"] + +[[permission]] +identifier = "deny-stat" +description = "Denies the stat command without any pre-configured scope." +commands.deny = ["stat"] diff --git a/plugins/fs/permissions/autogenerated/commands/truncate.toml b/plugins/fs/permissions/autogenerated/commands/truncate.toml new file mode 100644 index 00000000..62fbb144 --- /dev/null +++ b/plugins/fs/permissions/autogenerated/commands/truncate.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-truncate" +description = "Enables the truncate command without any pre-configured scope." +commands.allow = ["truncate"] + +[[permission]] +identifier = "deny-truncate" +description = "Denies the truncate command without any pre-configured scope." +commands.deny = ["truncate"] diff --git a/plugins/fs/permissions/autogenerated/commands/unwatch.toml b/plugins/fs/permissions/autogenerated/commands/unwatch.toml new file mode 100644 index 00000000..3259e9a6 --- /dev/null +++ b/plugins/fs/permissions/autogenerated/commands/unwatch.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-unwatch" +description = "Enables the unwatch command without any pre-configured scope." +commands.allow = ["unwatch"] + +[[permission]] +identifier = "deny-unwatch" +description = "Denies the unwatch command without any pre-configured scope." +commands.deny = ["unwatch"] diff --git a/plugins/fs/permissions/autogenerated/commands/watch.toml b/plugins/fs/permissions/autogenerated/commands/watch.toml new file mode 100644 index 00000000..8dd1b577 --- /dev/null +++ b/plugins/fs/permissions/autogenerated/commands/watch.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-watch" +description = "Enables the watch command without any pre-configured scope." +commands.allow = ["watch"] + +[[permission]] +identifier = "deny-watch" +description = "Denies the watch command without any pre-configured scope." +commands.deny = ["watch"] diff --git a/plugins/fs/permissions/autogenerated/commands/write.toml b/plugins/fs/permissions/autogenerated/commands/write.toml new file mode 100644 index 00000000..73d1d387 --- /dev/null +++ b/plugins/fs/permissions/autogenerated/commands/write.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-write" +description = "Enables the write command without any pre-configured scope." +commands.allow = ["write"] + +[[permission]] +identifier = "deny-write" +description = "Denies the write command without any pre-configured scope." +commands.deny = ["write"] diff --git a/plugins/fs/permissions/autogenerated/commands/write_file.toml b/plugins/fs/permissions/autogenerated/commands/write_file.toml new file mode 100644 index 00000000..ea7d5136 --- /dev/null +++ b/plugins/fs/permissions/autogenerated/commands/write_file.toml @@ -0,0 +1,23 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-write-file" +description = "Enables the write_file command without any pre-configured scope." + +[permission.commands] +allow = [ + "write_file", + "open", + "write", +] +deny = [] + +[[permission]] +identifier = "deny-write-file" +description = "Denies the write_file command without any pre-configured scope." + +[permission.commands] +allow = [] +deny = ["write_file"] diff --git a/plugins/fs/permissions/autogenerated/commands/write_text_file.toml b/plugins/fs/permissions/autogenerated/commands/write_text_file.toml new file mode 100644 index 00000000..6b497a70 --- /dev/null +++ b/plugins/fs/permissions/autogenerated/commands/write_text_file.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-write-text-file" +description = "Enables the write_text_file command without any pre-configured scope." +commands.allow = ["write_text_file"] + +[[permission]] +identifier = "deny-write-text-file" +description = "Denies the write_text_file command without any pre-configured scope." +commands.deny = ["write_text_file"] diff --git a/plugins/fs/permissions/autogenerated/reference.md b/plugins/fs/permissions/autogenerated/reference.md new file mode 100644 index 00000000..35ef551f --- /dev/null +++ b/plugins/fs/permissions/autogenerated/reference.md @@ -0,0 +1,3780 @@ +## Default Permission + +This set of permissions describes the what kind of +file system access the `fs` plugin has enabled or denied by default. + +#### Granted Permissions + +This default permission set enables read access to the +application specific directories (AppConfig, AppData, AppLocalData, AppCache, +AppLog) and all files and sub directories created in it. +The location of these directories depends on the operating system, +where the application is run. + +In general these directories need to be manually created +by the application at runtime, before accessing files or folders +in it is possible. + +Therefore, it is also allowed to create all of these folders via +the `mkdir` command. + +#### Denied Permissions + +This default permission set prevents access to critical components +of the Tauri application by default. +On Windows the webview data folder access is denied. + + +#### This default permission set includes the following: + +- `create-app-specific-dirs` +- `read-app-specific-dirs-recursive` +- `deny-default` + +## Permission Table + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IdentifierDescription
+ +`fs:allow-app-read-recursive` + + + +This allows full recursive read access to the complete application folders, files and subdirectories. + +
+ +`fs:allow-app-write-recursive` + + + +This allows full recursive write access to the complete application folders, files and subdirectories. + +
+ +`fs:allow-app-read` + + + +This allows non-recursive read access to the application folders. + +
+ +`fs:allow-app-write` + + + +This allows non-recursive write access to the application folders. + +
+ +`fs:allow-app-meta-recursive` + + + +This allows full recursive read access to metadata of the application folders, including file listing and statistics. + +
+ +`fs:allow-app-meta` + + + +This allows non-recursive read access to metadata of the application folders, including file listing and statistics. + +
+ +`fs:scope-app-recursive` + + + +This scope permits recursive access to the complete application folders, including sub directories and files. + +
+ +`fs:scope-app` + + + +This scope permits access to all files and list content of top level directories in the application folders. + +
+ +`fs:scope-app-index` + + + +This scope permits to list all files and folders in the application directories. + +
+ +`fs:allow-appcache-read-recursive` + + + +This allows full recursive read access to the complete `$APPCACHE` folder, files and subdirectories. + +
+ +`fs:allow-appcache-write-recursive` + + + +This allows full recursive write access to the complete `$APPCACHE` folder, files and subdirectories. + +
+ +`fs:allow-appcache-read` + + + +This allows non-recursive read access to the `$APPCACHE` folder. + +
+ +`fs:allow-appcache-write` + + + +This allows non-recursive write access to the `$APPCACHE` folder. + +
+ +`fs:allow-appcache-meta-recursive` + + + +This allows full recursive read access to metadata of the `$APPCACHE` folder, including file listing and statistics. + +
+ +`fs:allow-appcache-meta` + + + +This allows non-recursive read access to metadata of the `$APPCACHE` folder, including file listing and statistics. + +
+ +`fs:scope-appcache-recursive` + + + +This scope permits recursive access to the complete `$APPCACHE` folder, including sub directories and files. + +
+ +`fs:scope-appcache` + + + +This scope permits access to all files and list content of top level directories in the `$APPCACHE` folder. + +
+ +`fs:scope-appcache-index` + + + +This scope permits to list all files and folders in the `$APPCACHE`folder. + +
+ +`fs:allow-appconfig-read-recursive` + + + +This allows full recursive read access to the complete `$APPCONFIG` folder, files and subdirectories. + +
+ +`fs:allow-appconfig-write-recursive` + + + +This allows full recursive write access to the complete `$APPCONFIG` folder, files and subdirectories. + +
+ +`fs:allow-appconfig-read` + + + +This allows non-recursive read access to the `$APPCONFIG` folder. + +
+ +`fs:allow-appconfig-write` + + + +This allows non-recursive write access to the `$APPCONFIG` folder. + +
+ +`fs:allow-appconfig-meta-recursive` + + + +This allows full recursive read access to metadata of the `$APPCONFIG` folder, including file listing and statistics. + +
+ +`fs:allow-appconfig-meta` + + + +This allows non-recursive read access to metadata of the `$APPCONFIG` folder, including file listing and statistics. + +
+ +`fs:scope-appconfig-recursive` + + + +This scope permits recursive access to the complete `$APPCONFIG` folder, including sub directories and files. + +
+ +`fs:scope-appconfig` + + + +This scope permits access to all files and list content of top level directories in the `$APPCONFIG` folder. + +
+ +`fs:scope-appconfig-index` + + + +This scope permits to list all files and folders in the `$APPCONFIG`folder. + +
+ +`fs:allow-appdata-read-recursive` + + + +This allows full recursive read access to the complete `$APPDATA` folder, files and subdirectories. + +
+ +`fs:allow-appdata-write-recursive` + + + +This allows full recursive write access to the complete `$APPDATA` folder, files and subdirectories. + +
+ +`fs:allow-appdata-read` + + + +This allows non-recursive read access to the `$APPDATA` folder. + +
+ +`fs:allow-appdata-write` + + + +This allows non-recursive write access to the `$APPDATA` folder. + +
+ +`fs:allow-appdata-meta-recursive` + + + +This allows full recursive read access to metadata of the `$APPDATA` folder, including file listing and statistics. + +
+ +`fs:allow-appdata-meta` + + + +This allows non-recursive read access to metadata of the `$APPDATA` folder, including file listing and statistics. + +
+ +`fs:scope-appdata-recursive` + + + +This scope permits recursive access to the complete `$APPDATA` folder, including sub directories and files. + +
+ +`fs:scope-appdata` + + + +This scope permits access to all files and list content of top level directories in the `$APPDATA` folder. + +
+ +`fs:scope-appdata-index` + + + +This scope permits to list all files and folders in the `$APPDATA`folder. + +
+ +`fs:allow-applocaldata-read-recursive` + + + +This allows full recursive read access to the complete `$APPLOCALDATA` folder, files and subdirectories. + +
+ +`fs:allow-applocaldata-write-recursive` + + + +This allows full recursive write access to the complete `$APPLOCALDATA` folder, files and subdirectories. + +
+ +`fs:allow-applocaldata-read` + + + +This allows non-recursive read access to the `$APPLOCALDATA` folder. + +
+ +`fs:allow-applocaldata-write` + + + +This allows non-recursive write access to the `$APPLOCALDATA` folder. + +
+ +`fs:allow-applocaldata-meta-recursive` + + + +This allows full recursive read access to metadata of the `$APPLOCALDATA` folder, including file listing and statistics. + +
+ +`fs:allow-applocaldata-meta` + + + +This allows non-recursive read access to metadata of the `$APPLOCALDATA` folder, including file listing and statistics. + +
+ +`fs:scope-applocaldata-recursive` + + + +This scope permits recursive access to the complete `$APPLOCALDATA` folder, including sub directories and files. + +
+ +`fs:scope-applocaldata` + + + +This scope permits access to all files and list content of top level directories in the `$APPLOCALDATA` folder. + +
+ +`fs:scope-applocaldata-index` + + + +This scope permits to list all files and folders in the `$APPLOCALDATA`folder. + +
+ +`fs:allow-applog-read-recursive` + + + +This allows full recursive read access to the complete `$APPLOG` folder, files and subdirectories. + +
+ +`fs:allow-applog-write-recursive` + + + +This allows full recursive write access to the complete `$APPLOG` folder, files and subdirectories. + +
+ +`fs:allow-applog-read` + + + +This allows non-recursive read access to the `$APPLOG` folder. + +
+ +`fs:allow-applog-write` + + + +This allows non-recursive write access to the `$APPLOG` folder. + +
+ +`fs:allow-applog-meta-recursive` + + + +This allows full recursive read access to metadata of the `$APPLOG` folder, including file listing and statistics. + +
+ +`fs:allow-applog-meta` + + + +This allows non-recursive read access to metadata of the `$APPLOG` folder, including file listing and statistics. + +
+ +`fs:scope-applog-recursive` + + + +This scope permits recursive access to the complete `$APPLOG` folder, including sub directories and files. + +
+ +`fs:scope-applog` + + + +This scope permits access to all files and list content of top level directories in the `$APPLOG` folder. + +
+ +`fs:scope-applog-index` + + + +This scope permits to list all files and folders in the `$APPLOG`folder. + +
+ +`fs:allow-audio-read-recursive` + + + +This allows full recursive read access to the complete `$AUDIO` folder, files and subdirectories. + +
+ +`fs:allow-audio-write-recursive` + + + +This allows full recursive write access to the complete `$AUDIO` folder, files and subdirectories. + +
+ +`fs:allow-audio-read` + + + +This allows non-recursive read access to the `$AUDIO` folder. + +
+ +`fs:allow-audio-write` + + + +This allows non-recursive write access to the `$AUDIO` folder. + +
+ +`fs:allow-audio-meta-recursive` + + + +This allows full recursive read access to metadata of the `$AUDIO` folder, including file listing and statistics. + +
+ +`fs:allow-audio-meta` + + + +This allows non-recursive read access to metadata of the `$AUDIO` folder, including file listing and statistics. + +
+ +`fs:scope-audio-recursive` + + + +This scope permits recursive access to the complete `$AUDIO` folder, including sub directories and files. + +
+ +`fs:scope-audio` + + + +This scope permits access to all files and list content of top level directories in the `$AUDIO` folder. + +
+ +`fs:scope-audio-index` + + + +This scope permits to list all files and folders in the `$AUDIO`folder. + +
+ +`fs:allow-cache-read-recursive` + + + +This allows full recursive read access to the complete `$CACHE` folder, files and subdirectories. + +
+ +`fs:allow-cache-write-recursive` + + + +This allows full recursive write access to the complete `$CACHE` folder, files and subdirectories. + +
+ +`fs:allow-cache-read` + + + +This allows non-recursive read access to the `$CACHE` folder. + +
+ +`fs:allow-cache-write` + + + +This allows non-recursive write access to the `$CACHE` folder. + +
+ +`fs:allow-cache-meta-recursive` + + + +This allows full recursive read access to metadata of the `$CACHE` folder, including file listing and statistics. + +
+ +`fs:allow-cache-meta` + + + +This allows non-recursive read access to metadata of the `$CACHE` folder, including file listing and statistics. + +
+ +`fs:scope-cache-recursive` + + + +This scope permits recursive access to the complete `$CACHE` folder, including sub directories and files. + +
+ +`fs:scope-cache` + + + +This scope permits access to all files and list content of top level directories in the `$CACHE` folder. + +
+ +`fs:scope-cache-index` + + + +This scope permits to list all files and folders in the `$CACHE`folder. + +
+ +`fs:allow-config-read-recursive` + + + +This allows full recursive read access to the complete `$CONFIG` folder, files and subdirectories. + +
+ +`fs:allow-config-write-recursive` + + + +This allows full recursive write access to the complete `$CONFIG` folder, files and subdirectories. + +
+ +`fs:allow-config-read` + + + +This allows non-recursive read access to the `$CONFIG` folder. + +
+ +`fs:allow-config-write` + + + +This allows non-recursive write access to the `$CONFIG` folder. + +
+ +`fs:allow-config-meta-recursive` + + + +This allows full recursive read access to metadata of the `$CONFIG` folder, including file listing and statistics. + +
+ +`fs:allow-config-meta` + + + +This allows non-recursive read access to metadata of the `$CONFIG` folder, including file listing and statistics. + +
+ +`fs:scope-config-recursive` + + + +This scope permits recursive access to the complete `$CONFIG` folder, including sub directories and files. + +
+ +`fs:scope-config` + + + +This scope permits access to all files and list content of top level directories in the `$CONFIG` folder. + +
+ +`fs:scope-config-index` + + + +This scope permits to list all files and folders in the `$CONFIG`folder. + +
+ +`fs:allow-data-read-recursive` + + + +This allows full recursive read access to the complete `$DATA` folder, files and subdirectories. + +
+ +`fs:allow-data-write-recursive` + + + +This allows full recursive write access to the complete `$DATA` folder, files and subdirectories. + +
+ +`fs:allow-data-read` + + + +This allows non-recursive read access to the `$DATA` folder. + +
+ +`fs:allow-data-write` + + + +This allows non-recursive write access to the `$DATA` folder. + +
+ +`fs:allow-data-meta-recursive` + + + +This allows full recursive read access to metadata of the `$DATA` folder, including file listing and statistics. + +
+ +`fs:allow-data-meta` + + + +This allows non-recursive read access to metadata of the `$DATA` folder, including file listing and statistics. + +
+ +`fs:scope-data-recursive` + + + +This scope permits recursive access to the complete `$DATA` folder, including sub directories and files. + +
+ +`fs:scope-data` + + + +This scope permits access to all files and list content of top level directories in the `$DATA` folder. + +
+ +`fs:scope-data-index` + + + +This scope permits to list all files and folders in the `$DATA`folder. + +
+ +`fs:allow-desktop-read-recursive` + + + +This allows full recursive read access to the complete `$DESKTOP` folder, files and subdirectories. + +
+ +`fs:allow-desktop-write-recursive` + + + +This allows full recursive write access to the complete `$DESKTOP` folder, files and subdirectories. + +
+ +`fs:allow-desktop-read` + + + +This allows non-recursive read access to the `$DESKTOP` folder. + +
+ +`fs:allow-desktop-write` + + + +This allows non-recursive write access to the `$DESKTOP` folder. + +
+ +`fs:allow-desktop-meta-recursive` + + + +This allows full recursive read access to metadata of the `$DESKTOP` folder, including file listing and statistics. + +
+ +`fs:allow-desktop-meta` + + + +This allows non-recursive read access to metadata of the `$DESKTOP` folder, including file listing and statistics. + +
+ +`fs:scope-desktop-recursive` + + + +This scope permits recursive access to the complete `$DESKTOP` folder, including sub directories and files. + +
+ +`fs:scope-desktop` + + + +This scope permits access to all files and list content of top level directories in the `$DESKTOP` folder. + +
+ +`fs:scope-desktop-index` + + + +This scope permits to list all files and folders in the `$DESKTOP`folder. + +
+ +`fs:allow-document-read-recursive` + + + +This allows full recursive read access to the complete `$DOCUMENT` folder, files and subdirectories. + +
+ +`fs:allow-document-write-recursive` + + + +This allows full recursive write access to the complete `$DOCUMENT` folder, files and subdirectories. + +
+ +`fs:allow-document-read` + + + +This allows non-recursive read access to the `$DOCUMENT` folder. + +
+ +`fs:allow-document-write` + + + +This allows non-recursive write access to the `$DOCUMENT` folder. + +
+ +`fs:allow-document-meta-recursive` + + + +This allows full recursive read access to metadata of the `$DOCUMENT` folder, including file listing and statistics. + +
+ +`fs:allow-document-meta` + + + +This allows non-recursive read access to metadata of the `$DOCUMENT` folder, including file listing and statistics. + +
+ +`fs:scope-document-recursive` + + + +This scope permits recursive access to the complete `$DOCUMENT` folder, including sub directories and files. + +
+ +`fs:scope-document` + + + +This scope permits access to all files and list content of top level directories in the `$DOCUMENT` folder. + +
+ +`fs:scope-document-index` + + + +This scope permits to list all files and folders in the `$DOCUMENT`folder. + +
+ +`fs:allow-download-read-recursive` + + + +This allows full recursive read access to the complete `$DOWNLOAD` folder, files and subdirectories. + +
+ +`fs:allow-download-write-recursive` + + + +This allows full recursive write access to the complete `$DOWNLOAD` folder, files and subdirectories. + +
+ +`fs:allow-download-read` + + + +This allows non-recursive read access to the `$DOWNLOAD` folder. + +
+ +`fs:allow-download-write` + + + +This allows non-recursive write access to the `$DOWNLOAD` folder. + +
+ +`fs:allow-download-meta-recursive` + + + +This allows full recursive read access to metadata of the `$DOWNLOAD` folder, including file listing and statistics. + +
+ +`fs:allow-download-meta` + + + +This allows non-recursive read access to metadata of the `$DOWNLOAD` folder, including file listing and statistics. + +
+ +`fs:scope-download-recursive` + + + +This scope permits recursive access to the complete `$DOWNLOAD` folder, including sub directories and files. + +
+ +`fs:scope-download` + + + +This scope permits access to all files and list content of top level directories in the `$DOWNLOAD` folder. + +
+ +`fs:scope-download-index` + + + +This scope permits to list all files and folders in the `$DOWNLOAD`folder. + +
+ +`fs:allow-exe-read-recursive` + + + +This allows full recursive read access to the complete `$EXE` folder, files and subdirectories. + +
+ +`fs:allow-exe-write-recursive` + + + +This allows full recursive write access to the complete `$EXE` folder, files and subdirectories. + +
+ +`fs:allow-exe-read` + + + +This allows non-recursive read access to the `$EXE` folder. + +
+ +`fs:allow-exe-write` + + + +This allows non-recursive write access to the `$EXE` folder. + +
+ +`fs:allow-exe-meta-recursive` + + + +This allows full recursive read access to metadata of the `$EXE` folder, including file listing and statistics. + +
+ +`fs:allow-exe-meta` + + + +This allows non-recursive read access to metadata of the `$EXE` folder, including file listing and statistics. + +
+ +`fs:scope-exe-recursive` + + + +This scope permits recursive access to the complete `$EXE` folder, including sub directories and files. + +
+ +`fs:scope-exe` + + + +This scope permits access to all files and list content of top level directories in the `$EXE` folder. + +
+ +`fs:scope-exe-index` + + + +This scope permits to list all files and folders in the `$EXE`folder. + +
+ +`fs:allow-font-read-recursive` + + + +This allows full recursive read access to the complete `$FONT` folder, files and subdirectories. + +
+ +`fs:allow-font-write-recursive` + + + +This allows full recursive write access to the complete `$FONT` folder, files and subdirectories. + +
+ +`fs:allow-font-read` + + + +This allows non-recursive read access to the `$FONT` folder. + +
+ +`fs:allow-font-write` + + + +This allows non-recursive write access to the `$FONT` folder. + +
+ +`fs:allow-font-meta-recursive` + + + +This allows full recursive read access to metadata of the `$FONT` folder, including file listing and statistics. + +
+ +`fs:allow-font-meta` + + + +This allows non-recursive read access to metadata of the `$FONT` folder, including file listing and statistics. + +
+ +`fs:scope-font-recursive` + + + +This scope permits recursive access to the complete `$FONT` folder, including sub directories and files. + +
+ +`fs:scope-font` + + + +This scope permits access to all files and list content of top level directories in the `$FONT` folder. + +
+ +`fs:scope-font-index` + + + +This scope permits to list all files and folders in the `$FONT`folder. + +
+ +`fs:allow-home-read-recursive` + + + +This allows full recursive read access to the complete `$HOME` folder, files and subdirectories. + +
+ +`fs:allow-home-write-recursive` + + + +This allows full recursive write access to the complete `$HOME` folder, files and subdirectories. + +
+ +`fs:allow-home-read` + + + +This allows non-recursive read access to the `$HOME` folder. + +
+ +`fs:allow-home-write` + + + +This allows non-recursive write access to the `$HOME` folder. + +
+ +`fs:allow-home-meta-recursive` + + + +This allows full recursive read access to metadata of the `$HOME` folder, including file listing and statistics. + +
+ +`fs:allow-home-meta` + + + +This allows non-recursive read access to metadata of the `$HOME` folder, including file listing and statistics. + +
+ +`fs:scope-home-recursive` + + + +This scope permits recursive access to the complete `$HOME` folder, including sub directories and files. + +
+ +`fs:scope-home` + + + +This scope permits access to all files and list content of top level directories in the `$HOME` folder. + +
+ +`fs:scope-home-index` + + + +This scope permits to list all files and folders in the `$HOME`folder. + +
+ +`fs:allow-localdata-read-recursive` + + + +This allows full recursive read access to the complete `$LOCALDATA` folder, files and subdirectories. + +
+ +`fs:allow-localdata-write-recursive` + + + +This allows full recursive write access to the complete `$LOCALDATA` folder, files and subdirectories. + +
+ +`fs:allow-localdata-read` + + + +This allows non-recursive read access to the `$LOCALDATA` folder. + +
+ +`fs:allow-localdata-write` + + + +This allows non-recursive write access to the `$LOCALDATA` folder. + +
+ +`fs:allow-localdata-meta-recursive` + + + +This allows full recursive read access to metadata of the `$LOCALDATA` folder, including file listing and statistics. + +
+ +`fs:allow-localdata-meta` + + + +This allows non-recursive read access to metadata of the `$LOCALDATA` folder, including file listing and statistics. + +
+ +`fs:scope-localdata-recursive` + + + +This scope permits recursive access to the complete `$LOCALDATA` folder, including sub directories and files. + +
+ +`fs:scope-localdata` + + + +This scope permits access to all files and list content of top level directories in the `$LOCALDATA` folder. + +
+ +`fs:scope-localdata-index` + + + +This scope permits to list all files and folders in the `$LOCALDATA`folder. + +
+ +`fs:allow-log-read-recursive` + + + +This allows full recursive read access to the complete `$LOG` folder, files and subdirectories. + +
+ +`fs:allow-log-write-recursive` + + + +This allows full recursive write access to the complete `$LOG` folder, files and subdirectories. + +
+ +`fs:allow-log-read` + + + +This allows non-recursive read access to the `$LOG` folder. + +
+ +`fs:allow-log-write` + + + +This allows non-recursive write access to the `$LOG` folder. + +
+ +`fs:allow-log-meta-recursive` + + + +This allows full recursive read access to metadata of the `$LOG` folder, including file listing and statistics. + +
+ +`fs:allow-log-meta` + + + +This allows non-recursive read access to metadata of the `$LOG` folder, including file listing and statistics. + +
+ +`fs:scope-log-recursive` + + + +This scope permits recursive access to the complete `$LOG` folder, including sub directories and files. + +
+ +`fs:scope-log` + + + +This scope permits access to all files and list content of top level directories in the `$LOG` folder. + +
+ +`fs:scope-log-index` + + + +This scope permits to list all files and folders in the `$LOG`folder. + +
+ +`fs:allow-picture-read-recursive` + + + +This allows full recursive read access to the complete `$PICTURE` folder, files and subdirectories. + +
+ +`fs:allow-picture-write-recursive` + + + +This allows full recursive write access to the complete `$PICTURE` folder, files and subdirectories. + +
+ +`fs:allow-picture-read` + + + +This allows non-recursive read access to the `$PICTURE` folder. + +
+ +`fs:allow-picture-write` + + + +This allows non-recursive write access to the `$PICTURE` folder. + +
+ +`fs:allow-picture-meta-recursive` + + + +This allows full recursive read access to metadata of the `$PICTURE` folder, including file listing and statistics. + +
+ +`fs:allow-picture-meta` + + + +This allows non-recursive read access to metadata of the `$PICTURE` folder, including file listing and statistics. + +
+ +`fs:scope-picture-recursive` + + + +This scope permits recursive access to the complete `$PICTURE` folder, including sub directories and files. + +
+ +`fs:scope-picture` + + + +This scope permits access to all files and list content of top level directories in the `$PICTURE` folder. + +
+ +`fs:scope-picture-index` + + + +This scope permits to list all files and folders in the `$PICTURE`folder. + +
+ +`fs:allow-public-read-recursive` + + + +This allows full recursive read access to the complete `$PUBLIC` folder, files and subdirectories. + +
+ +`fs:allow-public-write-recursive` + + + +This allows full recursive write access to the complete `$PUBLIC` folder, files and subdirectories. + +
+ +`fs:allow-public-read` + + + +This allows non-recursive read access to the `$PUBLIC` folder. + +
+ +`fs:allow-public-write` + + + +This allows non-recursive write access to the `$PUBLIC` folder. + +
+ +`fs:allow-public-meta-recursive` + + + +This allows full recursive read access to metadata of the `$PUBLIC` folder, including file listing and statistics. + +
+ +`fs:allow-public-meta` + + + +This allows non-recursive read access to metadata of the `$PUBLIC` folder, including file listing and statistics. + +
+ +`fs:scope-public-recursive` + + + +This scope permits recursive access to the complete `$PUBLIC` folder, including sub directories and files. + +
+ +`fs:scope-public` + + + +This scope permits access to all files and list content of top level directories in the `$PUBLIC` folder. + +
+ +`fs:scope-public-index` + + + +This scope permits to list all files and folders in the `$PUBLIC`folder. + +
+ +`fs:allow-resource-read-recursive` + + + +This allows full recursive read access to the complete `$RESOURCE` folder, files and subdirectories. + +
+ +`fs:allow-resource-write-recursive` + + + +This allows full recursive write access to the complete `$RESOURCE` folder, files and subdirectories. + +
+ +`fs:allow-resource-read` + + + +This allows non-recursive read access to the `$RESOURCE` folder. + +
+ +`fs:allow-resource-write` + + + +This allows non-recursive write access to the `$RESOURCE` folder. + +
+ +`fs:allow-resource-meta-recursive` + + + +This allows full recursive read access to metadata of the `$RESOURCE` folder, including file listing and statistics. + +
+ +`fs:allow-resource-meta` + + + +This allows non-recursive read access to metadata of the `$RESOURCE` folder, including file listing and statistics. + +
+ +`fs:scope-resource-recursive` + + + +This scope permits recursive access to the complete `$RESOURCE` folder, including sub directories and files. + +
+ +`fs:scope-resource` + + + +This scope permits access to all files and list content of top level directories in the `$RESOURCE` folder. + +
+ +`fs:scope-resource-index` + + + +This scope permits to list all files and folders in the `$RESOURCE`folder. + +
+ +`fs:allow-runtime-read-recursive` + + + +This allows full recursive read access to the complete `$RUNTIME` folder, files and subdirectories. + +
+ +`fs:allow-runtime-write-recursive` + + + +This allows full recursive write access to the complete `$RUNTIME` folder, files and subdirectories. + +
+ +`fs:allow-runtime-read` + + + +This allows non-recursive read access to the `$RUNTIME` folder. + +
+ +`fs:allow-runtime-write` + + + +This allows non-recursive write access to the `$RUNTIME` folder. + +
+ +`fs:allow-runtime-meta-recursive` + + + +This allows full recursive read access to metadata of the `$RUNTIME` folder, including file listing and statistics. + +
+ +`fs:allow-runtime-meta` + + + +This allows non-recursive read access to metadata of the `$RUNTIME` folder, including file listing and statistics. + +
+ +`fs:scope-runtime-recursive` + + + +This scope permits recursive access to the complete `$RUNTIME` folder, including sub directories and files. + +
+ +`fs:scope-runtime` + + + +This scope permits access to all files and list content of top level directories in the `$RUNTIME` folder. + +
+ +`fs:scope-runtime-index` + + + +This scope permits to list all files and folders in the `$RUNTIME`folder. + +
+ +`fs:allow-temp-read-recursive` + + + +This allows full recursive read access to the complete `$TEMP` folder, files and subdirectories. + +
+ +`fs:allow-temp-write-recursive` + + + +This allows full recursive write access to the complete `$TEMP` folder, files and subdirectories. + +
+ +`fs:allow-temp-read` + + + +This allows non-recursive read access to the `$TEMP` folder. + +
+ +`fs:allow-temp-write` + + + +This allows non-recursive write access to the `$TEMP` folder. + +
+ +`fs:allow-temp-meta-recursive` + + + +This allows full recursive read access to metadata of the `$TEMP` folder, including file listing and statistics. + +
+ +`fs:allow-temp-meta` + + + +This allows non-recursive read access to metadata of the `$TEMP` folder, including file listing and statistics. + +
+ +`fs:scope-temp-recursive` + + + +This scope permits recursive access to the complete `$TEMP` folder, including sub directories and files. + +
+ +`fs:scope-temp` + + + +This scope permits access to all files and list content of top level directories in the `$TEMP` folder. + +
+ +`fs:scope-temp-index` + + + +This scope permits to list all files and folders in the `$TEMP`folder. + +
+ +`fs:allow-template-read-recursive` + + + +This allows full recursive read access to the complete `$TEMPLATE` folder, files and subdirectories. + +
+ +`fs:allow-template-write-recursive` + + + +This allows full recursive write access to the complete `$TEMPLATE` folder, files and subdirectories. + +
+ +`fs:allow-template-read` + + + +This allows non-recursive read access to the `$TEMPLATE` folder. + +
+ +`fs:allow-template-write` + + + +This allows non-recursive write access to the `$TEMPLATE` folder. + +
+ +`fs:allow-template-meta-recursive` + + + +This allows full recursive read access to metadata of the `$TEMPLATE` folder, including file listing and statistics. + +
+ +`fs:allow-template-meta` + + + +This allows non-recursive read access to metadata of the `$TEMPLATE` folder, including file listing and statistics. + +
+ +`fs:scope-template-recursive` + + + +This scope permits recursive access to the complete `$TEMPLATE` folder, including sub directories and files. + +
+ +`fs:scope-template` + + + +This scope permits access to all files and list content of top level directories in the `$TEMPLATE` folder. + +
+ +`fs:scope-template-index` + + + +This scope permits to list all files and folders in the `$TEMPLATE`folder. + +
+ +`fs:allow-video-read-recursive` + + + +This allows full recursive read access to the complete `$VIDEO` folder, files and subdirectories. + +
+ +`fs:allow-video-write-recursive` + + + +This allows full recursive write access to the complete `$VIDEO` folder, files and subdirectories. + +
+ +`fs:allow-video-read` + + + +This allows non-recursive read access to the `$VIDEO` folder. + +
+ +`fs:allow-video-write` + + + +This allows non-recursive write access to the `$VIDEO` folder. + +
+ +`fs:allow-video-meta-recursive` + + + +This allows full recursive read access to metadata of the `$VIDEO` folder, including file listing and statistics. + +
+ +`fs:allow-video-meta` + + + +This allows non-recursive read access to metadata of the `$VIDEO` folder, including file listing and statistics. + +
+ +`fs:scope-video-recursive` + + + +This scope permits recursive access to the complete `$VIDEO` folder, including sub directories and files. + +
+ +`fs:scope-video` + + + +This scope permits access to all files and list content of top level directories in the `$VIDEO` folder. + +
+ +`fs:scope-video-index` + + + +This scope permits to list all files and folders in the `$VIDEO`folder. + +
+ +`fs:allow-copy-file` + + + +Enables the copy_file command without any pre-configured scope. + +
+ +`fs:deny-copy-file` + + + +Denies the copy_file command without any pre-configured scope. + +
+ +`fs:allow-create` + + + +Enables the create command without any pre-configured scope. + +
+ +`fs:deny-create` + + + +Denies the create command without any pre-configured scope. + +
+ +`fs:allow-exists` + + + +Enables the exists command without any pre-configured scope. + +
+ +`fs:deny-exists` + + + +Denies the exists command without any pre-configured scope. + +
+ +`fs:allow-fstat` + + + +Enables the fstat command without any pre-configured scope. + +
+ +`fs:deny-fstat` + + + +Denies the fstat command without any pre-configured scope. + +
+ +`fs:allow-ftruncate` + + + +Enables the ftruncate command without any pre-configured scope. + +
+ +`fs:deny-ftruncate` + + + +Denies the ftruncate command without any pre-configured scope. + +
+ +`fs:allow-lstat` + + + +Enables the lstat command without any pre-configured scope. + +
+ +`fs:deny-lstat` + + + +Denies the lstat command without any pre-configured scope. + +
+ +`fs:allow-mkdir` + + + +Enables the mkdir command without any pre-configured scope. + +
+ +`fs:deny-mkdir` + + + +Denies the mkdir command without any pre-configured scope. + +
+ +`fs:allow-open` + + + +Enables the open command without any pre-configured scope. + +
+ +`fs:deny-open` + + + +Denies the open command without any pre-configured scope. + +
+ +`fs:allow-read` + + + +Enables the read command without any pre-configured scope. + +
+ +`fs:deny-read` + + + +Denies the read command without any pre-configured scope. + +
+ +`fs:allow-read-dir` + + + +Enables the read_dir command without any pre-configured scope. + +
+ +`fs:deny-read-dir` + + + +Denies the read_dir command without any pre-configured scope. + +
+ +`fs:allow-read-file` + + + +Enables the read_file command without any pre-configured scope. + +
+ +`fs:deny-read-file` + + + +Denies the read_file command without any pre-configured scope. + +
+ +`fs:allow-read-text-file` + + + +Enables the read_text_file command without any pre-configured scope. + +
+ +`fs:deny-read-text-file` + + + +Denies the read_text_file command without any pre-configured scope. + +
+ +`fs:allow-read-text-file-lines` + + + +Enables the read_text_file_lines command without any pre-configured scope. + +
+ +`fs:deny-read-text-file-lines` + + + +Denies the read_text_file_lines command without any pre-configured scope. + +
+ +`fs:allow-read-text-file-lines-next` + + + +Enables the read_text_file_lines_next command without any pre-configured scope. + +
+ +`fs:deny-read-text-file-lines-next` + + + +Denies the read_text_file_lines_next command without any pre-configured scope. + +
+ +`fs:allow-remove` + + + +Enables the remove command without any pre-configured scope. + +
+ +`fs:deny-remove` + + + +Denies the remove command without any pre-configured scope. + +
+ +`fs:allow-rename` + + + +Enables the rename command without any pre-configured scope. + +
+ +`fs:deny-rename` + + + +Denies the rename command without any pre-configured scope. + +
+ +`fs:allow-seek` + + + +Enables the seek command without any pre-configured scope. + +
+ +`fs:deny-seek` + + + +Denies the seek command without any pre-configured scope. + +
+ +`fs:allow-size` + + + +Enables the size command without any pre-configured scope. + +
+ +`fs:deny-size` + + + +Denies the size command without any pre-configured scope. + +
+ +`fs:allow-stat` + + + +Enables the stat command without any pre-configured scope. + +
+ +`fs:deny-stat` + + + +Denies the stat command without any pre-configured scope. + +
+ +`fs:allow-truncate` + + + +Enables the truncate command without any pre-configured scope. + +
+ +`fs:deny-truncate` + + + +Denies the truncate command without any pre-configured scope. + +
+ +`fs:allow-unwatch` + + + +Enables the unwatch command without any pre-configured scope. + +
+ +`fs:deny-unwatch` + + + +Denies the unwatch command without any pre-configured scope. + +
+ +`fs:allow-watch` + + + +Enables the watch command without any pre-configured scope. + +
+ +`fs:deny-watch` + + + +Denies the watch command without any pre-configured scope. + +
+ +`fs:allow-write` + + + +Enables the write command without any pre-configured scope. + +
+ +`fs:deny-write` + + + +Denies the write command without any pre-configured scope. + +
+ +`fs:allow-write-file` + + + +Enables the write_file command without any pre-configured scope. + +
+ +`fs:deny-write-file` + + + +Denies the write_file command without any pre-configured scope. + +
+ +`fs:allow-write-text-file` + + + +Enables the write_text_file command without any pre-configured scope. + +
+ +`fs:deny-write-text-file` + + + +Denies the write_text_file command without any pre-configured scope. + +
+ +`fs:create-app-specific-dirs` + + + +This permissions allows to create the application specific directories. + + +
+ +`fs:deny-default` + + + +This denies access to dangerous Tauri relevant files and folders by default. + +
+ +`fs:deny-webview-data-linux` + + + +This denies read access to the +`$APPLOCALDATA` folder on linux as the webview data and configuration values are stored here. +Allowing access can lead to sensitive information disclosure and should be well considered. + +
+ +`fs:deny-webview-data-windows` + + + +This denies read access to the +`$APPLOCALDATA/EBWebView` folder on windows as the webview data and configuration values are stored here. +Allowing access can lead to sensitive information disclosure and should be well considered. + +
+ +`fs:read-all` + + + +This enables all read related commands without any pre-configured accessible paths. + +
+ +`fs:read-app-specific-dirs-recursive` + + + +This permission allows recursive read functionality on the application +specific base directories. + + +
+ +`fs:read-dirs` + + + +This enables directory read and file metadata related commands without any pre-configured accessible paths. + +
+ +`fs:read-files` + + + +This enables file read related commands without any pre-configured accessible paths. + +
+ +`fs:read-meta` + + + +This enables all index or metadata related commands without any pre-configured accessible paths. + +
+ +`fs:scope` + + + +An empty permission you can use to modify the global scope. + +
+ +`fs:write-all` + + + +This enables all write related commands without any pre-configured accessible paths. + +
+ +`fs:write-files` + + + +This enables all file write related commands without any pre-configured accessible paths. + +
diff --git a/plugins/fs/permissions/create-app-specific-dirs.toml b/plugins/fs/permissions/create-app-specific-dirs.toml new file mode 100644 index 00000000..7785cb13 --- /dev/null +++ b/plugins/fs/permissions/create-app-specific-dirs.toml @@ -0,0 +1,8 @@ +"$schema" = "schemas/schema.json" + +[[permission]] +identifier = "create-app-specific-dirs" +description = """ +This permissions allows to create the application specific directories. +""" +commands.allow = ["mkdir", "scope-app-index"] diff --git a/plugins/fs/permissions/default.toml b/plugins/fs/permissions/default.toml new file mode 100644 index 00000000..78836df7 --- /dev/null +++ b/plugins/fs/permissions/default.toml @@ -0,0 +1,33 @@ +"$schema" = "schemas/schema.json" + +[default] +description = """ +This set of permissions describes the what kind of +file system access the `fs` plugin has enabled or denied by default. + +#### Granted Permissions + +This default permission set enables read access to the +application specific directories (AppConfig, AppData, AppLocalData, AppCache, +AppLog) and all files and sub directories created in it. +The location of these directories depends on the operating system, +where the application is run. + +In general these directories need to be manually created +by the application at runtime, before accessing files or folders +in it is possible. + +Therefore, it is also allowed to create all of these folders via +the `mkdir` command. + +#### Denied Permissions + +This default permission set prevents access to critical components +of the Tauri application by default. +On Windows the webview data folder access is denied. +""" +permissions = [ + "create-app-specific-dirs", + "read-app-specific-dirs-recursive", + "deny-default", +] diff --git a/plugins/fs/permissions/deny-default.toml b/plugins/fs/permissions/deny-default.toml new file mode 100644 index 00000000..22d8186f --- /dev/null +++ b/plugins/fs/permissions/deny-default.toml @@ -0,0 +1,6 @@ +"$schema" = "schemas/schema.json" + +[[set]] +identifier = "deny-default" +description = "This denies access to dangerous Tauri relevant files and folders by default." +permissions = ["deny-webview-data-linux", "deny-webview-data-windows"] diff --git a/plugins/fs/permissions/deny-webview-data.toml b/plugins/fs/permissions/deny-webview-data.toml new file mode 100644 index 00000000..73712d95 --- /dev/null +++ b/plugins/fs/permissions/deny-webview-data.toml @@ -0,0 +1,19 @@ +"$schema" = "schemas/schema.json" + +[[permission]] +identifier = "deny-webview-data-linux" +description = """This denies read access to the +`$APPLOCALDATA` folder on linux as the webview data and configuration values are stored here. +Allowing access can lead to sensitive information disclosure and should be well considered.""" + +[[scope.deny]] +path = "$APPLOCALDATA/**" + +[[permission]] +identifier = "deny-webview-data-windows" +description = """This denies read access to the +`$APPLOCALDATA/EBWebView` folder on windows as the webview data and configuration values are stored here. +Allowing access can lead to sensitive information disclosure and should be well considered.""" + +[[scope.deny]] +path = "$APPLOCALDATA/EBWebView/**" diff --git a/plugins/fs/permissions/read-all.toml b/plugins/fs/permissions/read-all.toml new file mode 100644 index 00000000..d43af5e0 --- /dev/null +++ b/plugins/fs/permissions/read-all.toml @@ -0,0 +1,21 @@ +"$schema" = "schemas/schema.json" + +[[permission]] +identifier = "read-all" +description = "This enables all read related commands without any pre-configured accessible paths." +commands.allow = [ + "read_dir", + "read_file", + "read", + "open", + "read_text_file", + "read_text_file_lines", + "read_text_file_lines_next", + "seek", + "stat", + "lstat", + "fstat", + "exists", + "watch", + "unwatch", +] diff --git a/plugins/fs/permissions/read-app-specific-dirs-recursive.toml b/plugins/fs/permissions/read-app-specific-dirs-recursive.toml new file mode 100644 index 00000000..5342dbc0 --- /dev/null +++ b/plugins/fs/permissions/read-app-specific-dirs-recursive.toml @@ -0,0 +1,17 @@ +"$schema" = "schemas/schema.json" + +[[permission]] +identifier = "read-app-specific-dirs-recursive" +description = """ +This permission allows recursive read functionality on the application +specific base directories. +""" +commands.allow = [ + "read_dir", + "read_file", + "read_text_file", + "read_text_file_lines", + "read_text_file_lines_next", + "exists", + "scope-app-recursive", +] diff --git a/plugins/fs/permissions/read-dirs.toml b/plugins/fs/permissions/read-dirs.toml new file mode 100644 index 00000000..eb383632 --- /dev/null +++ b/plugins/fs/permissions/read-dirs.toml @@ -0,0 +1,6 @@ +"$schema" = "schemas/schema.json" + +[[permission]] +identifier = "read-dirs" +description = "This enables directory read and file metadata related commands without any pre-configured accessible paths." +commands.allow = ["read_dir", "stat", "lstat", "fstat", "exists"] diff --git a/plugins/fs/permissions/read-files.toml b/plugins/fs/permissions/read-files.toml new file mode 100644 index 00000000..f2685108 --- /dev/null +++ b/plugins/fs/permissions/read-files.toml @@ -0,0 +1,19 @@ +"$schema" = "schemas/schema.json" + +[[permission]] +identifier = "read-files" +description = "This enables file read related commands without any pre-configured accessible paths." +commands.allow = [ + "read_file", + "read", + "open", + "read_text_file", + "read_text_file_lines", + "read_text_file_lines_next", + "seek", + "stat", + "lstat", + "fstat", + "exists", + +] diff --git a/plugins/fs/permissions/read-meta.toml b/plugins/fs/permissions/read-meta.toml new file mode 100644 index 00000000..83024b0c --- /dev/null +++ b/plugins/fs/permissions/read-meta.toml @@ -0,0 +1,6 @@ +"$schema" = "schemas/schema.json" + +[[permission]] +identifier = "read-meta" +description = "This enables all index or metadata related commands without any pre-configured accessible paths." +commands.allow = ["read_dir", "stat", "lstat", "fstat", "exists", "size"] diff --git a/plugins/fs/permissions/schemas/schema.json b/plugins/fs/permissions/schemas/schema.json new file mode 100644 index 00000000..54c6798b --- /dev/null +++ b/plugins/fs/permissions/schemas/schema.json @@ -0,0 +1,2028 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "PermissionFile", + "description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.", + "type": "object", + "properties": { + "default": { + "description": "The default permission set for the plugin", + "anyOf": [ + { + "$ref": "#/definitions/DefaultPermission" + }, + { + "type": "null" + } + ] + }, + "set": { + "description": "A list of permissions sets defined", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionSet" + } + }, + "permission": { + "description": "A list of inlined permissions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Permission" + } + } + }, + "definitions": { + "DefaultPermission": { + "description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.", + "type": "object", + "required": [ + "permissions" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "PermissionSet": { + "description": "A set of direct permissions grouped together under a new name.", + "type": "object", + "required": [ + "description", + "identifier", + "permissions" + ], + "properties": { + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does.", + "type": "string" + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionKind" + } + } + } + }, + "Permission": { + "description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.", + "type": "object", + "required": [ + "identifier" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri internal convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "commands": { + "description": "Allowed or denied commands when using this permission.", + "default": { + "allow": [], + "deny": [] + }, + "allOf": [ + { + "$ref": "#/definitions/Commands" + } + ] + }, + "scope": { + "description": "Allowed or denied scoped when using this permission.", + "allOf": [ + { + "$ref": "#/definitions/Scopes" + } + ] + }, + "platforms": { + "description": "Target platforms this permission applies. By default all platforms are affected by this permission.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Target" + } + } + } + }, + "Commands": { + "description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.", + "type": "object", + "properties": { + "allow": { + "description": "Allowed command.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "deny": { + "description": "Denied command, which takes priority.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "Scopes": { + "description": "An argument for fine grained behavior control of Tauri commands.\n\nIt can be of any serde serializable type and is used to allow or prevent certain actions inside a Tauri command. The configured scope is passed to the command and will be enforced by the command implementation.\n\n## Example\n\n```json { \"allow\": [{ \"path\": \"$HOME/**\" }], \"deny\": [{ \"path\": \"$HOME/secret.txt\" }] } ```", + "type": "object", + "properties": { + "allow": { + "description": "Data that defines what is allowed by the scope.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + }, + "deny": { + "description": "Data that defines what is denied by the scope. This should be prioritized by validation logic.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + } + } + }, + "Value": { + "description": "All supported ACL values.", + "anyOf": [ + { + "description": "Represents a null JSON value.", + "type": "null" + }, + { + "description": "Represents a [`bool`].", + "type": "boolean" + }, + { + "description": "Represents a valid ACL [`Number`].", + "allOf": [ + { + "$ref": "#/definitions/Number" + } + ] + }, + { + "description": "Represents a [`String`].", + "type": "string" + }, + { + "description": "Represents a list of other [`Value`]s.", + "type": "array", + "items": { + "$ref": "#/definitions/Value" + } + }, + { + "description": "Represents a map of [`String`] keys to [`Value`]s.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/Value" + } + } + ] + }, + "Number": { + "description": "A valid ACL number.", + "anyOf": [ + { + "description": "Represents an [`i64`].", + "type": "integer", + "format": "int64" + }, + { + "description": "Represents a [`f64`].", + "type": "number", + "format": "double" + } + ] + }, + "Target": { + "description": "Platform target.", + "oneOf": [ + { + "description": "MacOS.", + "type": "string", + "enum": [ + "macOS" + ] + }, + { + "description": "Windows.", + "type": "string", + "enum": [ + "windows" + ] + }, + { + "description": "Linux.", + "type": "string", + "enum": [ + "linux" + ] + }, + { + "description": "Android.", + "type": "string", + "enum": [ + "android" + ] + }, + { + "description": "iOS.", + "type": "string", + "enum": [ + "iOS" + ] + } + ] + }, + "PermissionKind": { + "type": "string", + "oneOf": [ + { + "description": "This allows full recursive read access to the complete application folders, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-app-recursive`", + "type": "string", + "const": "allow-app-read-recursive", + "markdownDescription": "This allows full recursive read access to the complete application folders, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-app-recursive`" + }, + { + "description": "This allows full recursive write access to the complete application folders, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-app-recursive`", + "type": "string", + "const": "allow-app-write-recursive", + "markdownDescription": "This allows full recursive write access to the complete application folders, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-app-recursive`" + }, + { + "description": "This allows non-recursive read access to the application folders.\n#### This permission set includes:\n\n- `read-all`\n- `scope-app`", + "type": "string", + "const": "allow-app-read", + "markdownDescription": "This allows non-recursive read access to the application folders.\n#### This permission set includes:\n\n- `read-all`\n- `scope-app`" + }, + { + "description": "This allows non-recursive write access to the application folders.\n#### This permission set includes:\n\n- `write-all`\n- `scope-app`", + "type": "string", + "const": "allow-app-write", + "markdownDescription": "This allows non-recursive write access to the application folders.\n#### This permission set includes:\n\n- `write-all`\n- `scope-app`" + }, + { + "description": "This allows full recursive read access to metadata of the application folders, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-app-recursive`", + "type": "string", + "const": "allow-app-meta-recursive", + "markdownDescription": "This allows full recursive read access to metadata of the application folders, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-app-recursive`" + }, + { + "description": "This allows non-recursive read access to metadata of the application folders, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-app-index`", + "type": "string", + "const": "allow-app-meta", + "markdownDescription": "This allows non-recursive read access to metadata of the application folders, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-app-index`" + }, + { + "description": "This scope permits recursive access to the complete application folders, including sub directories and files.", + "type": "string", + "const": "scope-app-recursive", + "markdownDescription": "This scope permits recursive access to the complete application folders, including sub directories and files." + }, + { + "description": "This scope permits access to all files and list content of top level directories in the application folders.", + "type": "string", + "const": "scope-app", + "markdownDescription": "This scope permits access to all files and list content of top level directories in the application folders." + }, + { + "description": "This scope permits to list all files and folders in the application directories.", + "type": "string", + "const": "scope-app-index", + "markdownDescription": "This scope permits to list all files and folders in the application directories." + }, + { + "description": "This allows full recursive read access to the complete `$APPCACHE` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-appcache-recursive`", + "type": "string", + "const": "allow-appcache-read-recursive", + "markdownDescription": "This allows full recursive read access to the complete `$APPCACHE` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-appcache-recursive`" + }, + { + "description": "This allows full recursive write access to the complete `$APPCACHE` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-appcache-recursive`", + "type": "string", + "const": "allow-appcache-write-recursive", + "markdownDescription": "This allows full recursive write access to the complete `$APPCACHE` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-appcache-recursive`" + }, + { + "description": "This allows non-recursive read access to the `$APPCACHE` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-appcache`", + "type": "string", + "const": "allow-appcache-read", + "markdownDescription": "This allows non-recursive read access to the `$APPCACHE` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-appcache`" + }, + { + "description": "This allows non-recursive write access to the `$APPCACHE` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-appcache`", + "type": "string", + "const": "allow-appcache-write", + "markdownDescription": "This allows non-recursive write access to the `$APPCACHE` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-appcache`" + }, + { + "description": "This allows full recursive read access to metadata of the `$APPCACHE` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-appcache-recursive`", + "type": "string", + "const": "allow-appcache-meta-recursive", + "markdownDescription": "This allows full recursive read access to metadata of the `$APPCACHE` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-appcache-recursive`" + }, + { + "description": "This allows non-recursive read access to metadata of the `$APPCACHE` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-appcache-index`", + "type": "string", + "const": "allow-appcache-meta", + "markdownDescription": "This allows non-recursive read access to metadata of the `$APPCACHE` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-appcache-index`" + }, + { + "description": "This scope permits recursive access to the complete `$APPCACHE` folder, including sub directories and files.", + "type": "string", + "const": "scope-appcache-recursive", + "markdownDescription": "This scope permits recursive access to the complete `$APPCACHE` folder, including sub directories and files." + }, + { + "description": "This scope permits access to all files and list content of top level directories in the `$APPCACHE` folder.", + "type": "string", + "const": "scope-appcache", + "markdownDescription": "This scope permits access to all files and list content of top level directories in the `$APPCACHE` folder." + }, + { + "description": "This scope permits to list all files and folders in the `$APPCACHE`folder.", + "type": "string", + "const": "scope-appcache-index", + "markdownDescription": "This scope permits to list all files and folders in the `$APPCACHE`folder." + }, + { + "description": "This allows full recursive read access to the complete `$APPCONFIG` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-appconfig-recursive`", + "type": "string", + "const": "allow-appconfig-read-recursive", + "markdownDescription": "This allows full recursive read access to the complete `$APPCONFIG` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-appconfig-recursive`" + }, + { + "description": "This allows full recursive write access to the complete `$APPCONFIG` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-appconfig-recursive`", + "type": "string", + "const": "allow-appconfig-write-recursive", + "markdownDescription": "This allows full recursive write access to the complete `$APPCONFIG` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-appconfig-recursive`" + }, + { + "description": "This allows non-recursive read access to the `$APPCONFIG` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-appconfig`", + "type": "string", + "const": "allow-appconfig-read", + "markdownDescription": "This allows non-recursive read access to the `$APPCONFIG` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-appconfig`" + }, + { + "description": "This allows non-recursive write access to the `$APPCONFIG` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-appconfig`", + "type": "string", + "const": "allow-appconfig-write", + "markdownDescription": "This allows non-recursive write access to the `$APPCONFIG` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-appconfig`" + }, + { + "description": "This allows full recursive read access to metadata of the `$APPCONFIG` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-appconfig-recursive`", + "type": "string", + "const": "allow-appconfig-meta-recursive", + "markdownDescription": "This allows full recursive read access to metadata of the `$APPCONFIG` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-appconfig-recursive`" + }, + { + "description": "This allows non-recursive read access to metadata of the `$APPCONFIG` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-appconfig-index`", + "type": "string", + "const": "allow-appconfig-meta", + "markdownDescription": "This allows non-recursive read access to metadata of the `$APPCONFIG` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-appconfig-index`" + }, + { + "description": "This scope permits recursive access to the complete `$APPCONFIG` folder, including sub directories and files.", + "type": "string", + "const": "scope-appconfig-recursive", + "markdownDescription": "This scope permits recursive access to the complete `$APPCONFIG` folder, including sub directories and files." + }, + { + "description": "This scope permits access to all files and list content of top level directories in the `$APPCONFIG` folder.", + "type": "string", + "const": "scope-appconfig", + "markdownDescription": "This scope permits access to all files and list content of top level directories in the `$APPCONFIG` folder." + }, + { + "description": "This scope permits to list all files and folders in the `$APPCONFIG`folder.", + "type": "string", + "const": "scope-appconfig-index", + "markdownDescription": "This scope permits to list all files and folders in the `$APPCONFIG`folder." + }, + { + "description": "This allows full recursive read access to the complete `$APPDATA` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-appdata-recursive`", + "type": "string", + "const": "allow-appdata-read-recursive", + "markdownDescription": "This allows full recursive read access to the complete `$APPDATA` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-appdata-recursive`" + }, + { + "description": "This allows full recursive write access to the complete `$APPDATA` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-appdata-recursive`", + "type": "string", + "const": "allow-appdata-write-recursive", + "markdownDescription": "This allows full recursive write access to the complete `$APPDATA` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-appdata-recursive`" + }, + { + "description": "This allows non-recursive read access to the `$APPDATA` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-appdata`", + "type": "string", + "const": "allow-appdata-read", + "markdownDescription": "This allows non-recursive read access to the `$APPDATA` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-appdata`" + }, + { + "description": "This allows non-recursive write access to the `$APPDATA` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-appdata`", + "type": "string", + "const": "allow-appdata-write", + "markdownDescription": "This allows non-recursive write access to the `$APPDATA` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-appdata`" + }, + { + "description": "This allows full recursive read access to metadata of the `$APPDATA` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-appdata-recursive`", + "type": "string", + "const": "allow-appdata-meta-recursive", + "markdownDescription": "This allows full recursive read access to metadata of the `$APPDATA` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-appdata-recursive`" + }, + { + "description": "This allows non-recursive read access to metadata of the `$APPDATA` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-appdata-index`", + "type": "string", + "const": "allow-appdata-meta", + "markdownDescription": "This allows non-recursive read access to metadata of the `$APPDATA` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-appdata-index`" + }, + { + "description": "This scope permits recursive access to the complete `$APPDATA` folder, including sub directories and files.", + "type": "string", + "const": "scope-appdata-recursive", + "markdownDescription": "This scope permits recursive access to the complete `$APPDATA` folder, including sub directories and files." + }, + { + "description": "This scope permits access to all files and list content of top level directories in the `$APPDATA` folder.", + "type": "string", + "const": "scope-appdata", + "markdownDescription": "This scope permits access to all files and list content of top level directories in the `$APPDATA` folder." + }, + { + "description": "This scope permits to list all files and folders in the `$APPDATA`folder.", + "type": "string", + "const": "scope-appdata-index", + "markdownDescription": "This scope permits to list all files and folders in the `$APPDATA`folder." + }, + { + "description": "This allows full recursive read access to the complete `$APPLOCALDATA` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-applocaldata-recursive`", + "type": "string", + "const": "allow-applocaldata-read-recursive", + "markdownDescription": "This allows full recursive read access to the complete `$APPLOCALDATA` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-applocaldata-recursive`" + }, + { + "description": "This allows full recursive write access to the complete `$APPLOCALDATA` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-applocaldata-recursive`", + "type": "string", + "const": "allow-applocaldata-write-recursive", + "markdownDescription": "This allows full recursive write access to the complete `$APPLOCALDATA` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-applocaldata-recursive`" + }, + { + "description": "This allows non-recursive read access to the `$APPLOCALDATA` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-applocaldata`", + "type": "string", + "const": "allow-applocaldata-read", + "markdownDescription": "This allows non-recursive read access to the `$APPLOCALDATA` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-applocaldata`" + }, + { + "description": "This allows non-recursive write access to the `$APPLOCALDATA` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-applocaldata`", + "type": "string", + "const": "allow-applocaldata-write", + "markdownDescription": "This allows non-recursive write access to the `$APPLOCALDATA` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-applocaldata`" + }, + { + "description": "This allows full recursive read access to metadata of the `$APPLOCALDATA` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-applocaldata-recursive`", + "type": "string", + "const": "allow-applocaldata-meta-recursive", + "markdownDescription": "This allows full recursive read access to metadata of the `$APPLOCALDATA` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-applocaldata-recursive`" + }, + { + "description": "This allows non-recursive read access to metadata of the `$APPLOCALDATA` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-applocaldata-index`", + "type": "string", + "const": "allow-applocaldata-meta", + "markdownDescription": "This allows non-recursive read access to metadata of the `$APPLOCALDATA` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-applocaldata-index`" + }, + { + "description": "This scope permits recursive access to the complete `$APPLOCALDATA` folder, including sub directories and files.", + "type": "string", + "const": "scope-applocaldata-recursive", + "markdownDescription": "This scope permits recursive access to the complete `$APPLOCALDATA` folder, including sub directories and files." + }, + { + "description": "This scope permits access to all files and list content of top level directories in the `$APPLOCALDATA` folder.", + "type": "string", + "const": "scope-applocaldata", + "markdownDescription": "This scope permits access to all files and list content of top level directories in the `$APPLOCALDATA` folder." + }, + { + "description": "This scope permits to list all files and folders in the `$APPLOCALDATA`folder.", + "type": "string", + "const": "scope-applocaldata-index", + "markdownDescription": "This scope permits to list all files and folders in the `$APPLOCALDATA`folder." + }, + { + "description": "This allows full recursive read access to the complete `$APPLOG` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-applog-recursive`", + "type": "string", + "const": "allow-applog-read-recursive", + "markdownDescription": "This allows full recursive read access to the complete `$APPLOG` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-applog-recursive`" + }, + { + "description": "This allows full recursive write access to the complete `$APPLOG` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-applog-recursive`", + "type": "string", + "const": "allow-applog-write-recursive", + "markdownDescription": "This allows full recursive write access to the complete `$APPLOG` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-applog-recursive`" + }, + { + "description": "This allows non-recursive read access to the `$APPLOG` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-applog`", + "type": "string", + "const": "allow-applog-read", + "markdownDescription": "This allows non-recursive read access to the `$APPLOG` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-applog`" + }, + { + "description": "This allows non-recursive write access to the `$APPLOG` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-applog`", + "type": "string", + "const": "allow-applog-write", + "markdownDescription": "This allows non-recursive write access to the `$APPLOG` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-applog`" + }, + { + "description": "This allows full recursive read access to metadata of the `$APPLOG` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-applog-recursive`", + "type": "string", + "const": "allow-applog-meta-recursive", + "markdownDescription": "This allows full recursive read access to metadata of the `$APPLOG` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-applog-recursive`" + }, + { + "description": "This allows non-recursive read access to metadata of the `$APPLOG` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-applog-index`", + "type": "string", + "const": "allow-applog-meta", + "markdownDescription": "This allows non-recursive read access to metadata of the `$APPLOG` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-applog-index`" + }, + { + "description": "This scope permits recursive access to the complete `$APPLOG` folder, including sub directories and files.", + "type": "string", + "const": "scope-applog-recursive", + "markdownDescription": "This scope permits recursive access to the complete `$APPLOG` folder, including sub directories and files." + }, + { + "description": "This scope permits access to all files and list content of top level directories in the `$APPLOG` folder.", + "type": "string", + "const": "scope-applog", + "markdownDescription": "This scope permits access to all files and list content of top level directories in the `$APPLOG` folder." + }, + { + "description": "This scope permits to list all files and folders in the `$APPLOG`folder.", + "type": "string", + "const": "scope-applog-index", + "markdownDescription": "This scope permits to list all files and folders in the `$APPLOG`folder." + }, + { + "description": "This allows full recursive read access to the complete `$AUDIO` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-audio-recursive`", + "type": "string", + "const": "allow-audio-read-recursive", + "markdownDescription": "This allows full recursive read access to the complete `$AUDIO` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-audio-recursive`" + }, + { + "description": "This allows full recursive write access to the complete `$AUDIO` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-audio-recursive`", + "type": "string", + "const": "allow-audio-write-recursive", + "markdownDescription": "This allows full recursive write access to the complete `$AUDIO` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-audio-recursive`" + }, + { + "description": "This allows non-recursive read access to the `$AUDIO` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-audio`", + "type": "string", + "const": "allow-audio-read", + "markdownDescription": "This allows non-recursive read access to the `$AUDIO` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-audio`" + }, + { + "description": "This allows non-recursive write access to the `$AUDIO` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-audio`", + "type": "string", + "const": "allow-audio-write", + "markdownDescription": "This allows non-recursive write access to the `$AUDIO` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-audio`" + }, + { + "description": "This allows full recursive read access to metadata of the `$AUDIO` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-audio-recursive`", + "type": "string", + "const": "allow-audio-meta-recursive", + "markdownDescription": "This allows full recursive read access to metadata of the `$AUDIO` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-audio-recursive`" + }, + { + "description": "This allows non-recursive read access to metadata of the `$AUDIO` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-audio-index`", + "type": "string", + "const": "allow-audio-meta", + "markdownDescription": "This allows non-recursive read access to metadata of the `$AUDIO` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-audio-index`" + }, + { + "description": "This scope permits recursive access to the complete `$AUDIO` folder, including sub directories and files.", + "type": "string", + "const": "scope-audio-recursive", + "markdownDescription": "This scope permits recursive access to the complete `$AUDIO` folder, including sub directories and files." + }, + { + "description": "This scope permits access to all files and list content of top level directories in the `$AUDIO` folder.", + "type": "string", + "const": "scope-audio", + "markdownDescription": "This scope permits access to all files and list content of top level directories in the `$AUDIO` folder." + }, + { + "description": "This scope permits to list all files and folders in the `$AUDIO`folder.", + "type": "string", + "const": "scope-audio-index", + "markdownDescription": "This scope permits to list all files and folders in the `$AUDIO`folder." + }, + { + "description": "This allows full recursive read access to the complete `$CACHE` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-cache-recursive`", + "type": "string", + "const": "allow-cache-read-recursive", + "markdownDescription": "This allows full recursive read access to the complete `$CACHE` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-cache-recursive`" + }, + { + "description": "This allows full recursive write access to the complete `$CACHE` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-cache-recursive`", + "type": "string", + "const": "allow-cache-write-recursive", + "markdownDescription": "This allows full recursive write access to the complete `$CACHE` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-cache-recursive`" + }, + { + "description": "This allows non-recursive read access to the `$CACHE` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-cache`", + "type": "string", + "const": "allow-cache-read", + "markdownDescription": "This allows non-recursive read access to the `$CACHE` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-cache`" + }, + { + "description": "This allows non-recursive write access to the `$CACHE` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-cache`", + "type": "string", + "const": "allow-cache-write", + "markdownDescription": "This allows non-recursive write access to the `$CACHE` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-cache`" + }, + { + "description": "This allows full recursive read access to metadata of the `$CACHE` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-cache-recursive`", + "type": "string", + "const": "allow-cache-meta-recursive", + "markdownDescription": "This allows full recursive read access to metadata of the `$CACHE` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-cache-recursive`" + }, + { + "description": "This allows non-recursive read access to metadata of the `$CACHE` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-cache-index`", + "type": "string", + "const": "allow-cache-meta", + "markdownDescription": "This allows non-recursive read access to metadata of the `$CACHE` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-cache-index`" + }, + { + "description": "This scope permits recursive access to the complete `$CACHE` folder, including sub directories and files.", + "type": "string", + "const": "scope-cache-recursive", + "markdownDescription": "This scope permits recursive access to the complete `$CACHE` folder, including sub directories and files." + }, + { + "description": "This scope permits access to all files and list content of top level directories in the `$CACHE` folder.", + "type": "string", + "const": "scope-cache", + "markdownDescription": "This scope permits access to all files and list content of top level directories in the `$CACHE` folder." + }, + { + "description": "This scope permits to list all files and folders in the `$CACHE`folder.", + "type": "string", + "const": "scope-cache-index", + "markdownDescription": "This scope permits to list all files and folders in the `$CACHE`folder." + }, + { + "description": "This allows full recursive read access to the complete `$CONFIG` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-config-recursive`", + "type": "string", + "const": "allow-config-read-recursive", + "markdownDescription": "This allows full recursive read access to the complete `$CONFIG` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-config-recursive`" + }, + { + "description": "This allows full recursive write access to the complete `$CONFIG` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-config-recursive`", + "type": "string", + "const": "allow-config-write-recursive", + "markdownDescription": "This allows full recursive write access to the complete `$CONFIG` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-config-recursive`" + }, + { + "description": "This allows non-recursive read access to the `$CONFIG` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-config`", + "type": "string", + "const": "allow-config-read", + "markdownDescription": "This allows non-recursive read access to the `$CONFIG` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-config`" + }, + { + "description": "This allows non-recursive write access to the `$CONFIG` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-config`", + "type": "string", + "const": "allow-config-write", + "markdownDescription": "This allows non-recursive write access to the `$CONFIG` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-config`" + }, + { + "description": "This allows full recursive read access to metadata of the `$CONFIG` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-config-recursive`", + "type": "string", + "const": "allow-config-meta-recursive", + "markdownDescription": "This allows full recursive read access to metadata of the `$CONFIG` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-config-recursive`" + }, + { + "description": "This allows non-recursive read access to metadata of the `$CONFIG` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-config-index`", + "type": "string", + "const": "allow-config-meta", + "markdownDescription": "This allows non-recursive read access to metadata of the `$CONFIG` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-config-index`" + }, + { + "description": "This scope permits recursive access to the complete `$CONFIG` folder, including sub directories and files.", + "type": "string", + "const": "scope-config-recursive", + "markdownDescription": "This scope permits recursive access to the complete `$CONFIG` folder, including sub directories and files." + }, + { + "description": "This scope permits access to all files and list content of top level directories in the `$CONFIG` folder.", + "type": "string", + "const": "scope-config", + "markdownDescription": "This scope permits access to all files and list content of top level directories in the `$CONFIG` folder." + }, + { + "description": "This scope permits to list all files and folders in the `$CONFIG`folder.", + "type": "string", + "const": "scope-config-index", + "markdownDescription": "This scope permits to list all files and folders in the `$CONFIG`folder." + }, + { + "description": "This allows full recursive read access to the complete `$DATA` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-data-recursive`", + "type": "string", + "const": "allow-data-read-recursive", + "markdownDescription": "This allows full recursive read access to the complete `$DATA` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-data-recursive`" + }, + { + "description": "This allows full recursive write access to the complete `$DATA` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-data-recursive`", + "type": "string", + "const": "allow-data-write-recursive", + "markdownDescription": "This allows full recursive write access to the complete `$DATA` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-data-recursive`" + }, + { + "description": "This allows non-recursive read access to the `$DATA` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-data`", + "type": "string", + "const": "allow-data-read", + "markdownDescription": "This allows non-recursive read access to the `$DATA` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-data`" + }, + { + "description": "This allows non-recursive write access to the `$DATA` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-data`", + "type": "string", + "const": "allow-data-write", + "markdownDescription": "This allows non-recursive write access to the `$DATA` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-data`" + }, + { + "description": "This allows full recursive read access to metadata of the `$DATA` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-data-recursive`", + "type": "string", + "const": "allow-data-meta-recursive", + "markdownDescription": "This allows full recursive read access to metadata of the `$DATA` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-data-recursive`" + }, + { + "description": "This allows non-recursive read access to metadata of the `$DATA` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-data-index`", + "type": "string", + "const": "allow-data-meta", + "markdownDescription": "This allows non-recursive read access to metadata of the `$DATA` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-data-index`" + }, + { + "description": "This scope permits recursive access to the complete `$DATA` folder, including sub directories and files.", + "type": "string", + "const": "scope-data-recursive", + "markdownDescription": "This scope permits recursive access to the complete `$DATA` folder, including sub directories and files." + }, + { + "description": "This scope permits access to all files and list content of top level directories in the `$DATA` folder.", + "type": "string", + "const": "scope-data", + "markdownDescription": "This scope permits access to all files and list content of top level directories in the `$DATA` folder." + }, + { + "description": "This scope permits to list all files and folders in the `$DATA`folder.", + "type": "string", + "const": "scope-data-index", + "markdownDescription": "This scope permits to list all files and folders in the `$DATA`folder." + }, + { + "description": "This allows full recursive read access to the complete `$DESKTOP` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-desktop-recursive`", + "type": "string", + "const": "allow-desktop-read-recursive", + "markdownDescription": "This allows full recursive read access to the complete `$DESKTOP` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-desktop-recursive`" + }, + { + "description": "This allows full recursive write access to the complete `$DESKTOP` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-desktop-recursive`", + "type": "string", + "const": "allow-desktop-write-recursive", + "markdownDescription": "This allows full recursive write access to the complete `$DESKTOP` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-desktop-recursive`" + }, + { + "description": "This allows non-recursive read access to the `$DESKTOP` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-desktop`", + "type": "string", + "const": "allow-desktop-read", + "markdownDescription": "This allows non-recursive read access to the `$DESKTOP` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-desktop`" + }, + { + "description": "This allows non-recursive write access to the `$DESKTOP` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-desktop`", + "type": "string", + "const": "allow-desktop-write", + "markdownDescription": "This allows non-recursive write access to the `$DESKTOP` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-desktop`" + }, + { + "description": "This allows full recursive read access to metadata of the `$DESKTOP` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-desktop-recursive`", + "type": "string", + "const": "allow-desktop-meta-recursive", + "markdownDescription": "This allows full recursive read access to metadata of the `$DESKTOP` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-desktop-recursive`" + }, + { + "description": "This allows non-recursive read access to metadata of the `$DESKTOP` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-desktop-index`", + "type": "string", + "const": "allow-desktop-meta", + "markdownDescription": "This allows non-recursive read access to metadata of the `$DESKTOP` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-desktop-index`" + }, + { + "description": "This scope permits recursive access to the complete `$DESKTOP` folder, including sub directories and files.", + "type": "string", + "const": "scope-desktop-recursive", + "markdownDescription": "This scope permits recursive access to the complete `$DESKTOP` folder, including sub directories and files." + }, + { + "description": "This scope permits access to all files and list content of top level directories in the `$DESKTOP` folder.", + "type": "string", + "const": "scope-desktop", + "markdownDescription": "This scope permits access to all files and list content of top level directories in the `$DESKTOP` folder." + }, + { + "description": "This scope permits to list all files and folders in the `$DESKTOP`folder.", + "type": "string", + "const": "scope-desktop-index", + "markdownDescription": "This scope permits to list all files and folders in the `$DESKTOP`folder." + }, + { + "description": "This allows full recursive read access to the complete `$DOCUMENT` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-document-recursive`", + "type": "string", + "const": "allow-document-read-recursive", + "markdownDescription": "This allows full recursive read access to the complete `$DOCUMENT` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-document-recursive`" + }, + { + "description": "This allows full recursive write access to the complete `$DOCUMENT` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-document-recursive`", + "type": "string", + "const": "allow-document-write-recursive", + "markdownDescription": "This allows full recursive write access to the complete `$DOCUMENT` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-document-recursive`" + }, + { + "description": "This allows non-recursive read access to the `$DOCUMENT` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-document`", + "type": "string", + "const": "allow-document-read", + "markdownDescription": "This allows non-recursive read access to the `$DOCUMENT` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-document`" + }, + { + "description": "This allows non-recursive write access to the `$DOCUMENT` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-document`", + "type": "string", + "const": "allow-document-write", + "markdownDescription": "This allows non-recursive write access to the `$DOCUMENT` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-document`" + }, + { + "description": "This allows full recursive read access to metadata of the `$DOCUMENT` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-document-recursive`", + "type": "string", + "const": "allow-document-meta-recursive", + "markdownDescription": "This allows full recursive read access to metadata of the `$DOCUMENT` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-document-recursive`" + }, + { + "description": "This allows non-recursive read access to metadata of the `$DOCUMENT` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-document-index`", + "type": "string", + "const": "allow-document-meta", + "markdownDescription": "This allows non-recursive read access to metadata of the `$DOCUMENT` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-document-index`" + }, + { + "description": "This scope permits recursive access to the complete `$DOCUMENT` folder, including sub directories and files.", + "type": "string", + "const": "scope-document-recursive", + "markdownDescription": "This scope permits recursive access to the complete `$DOCUMENT` folder, including sub directories and files." + }, + { + "description": "This scope permits access to all files and list content of top level directories in the `$DOCUMENT` folder.", + "type": "string", + "const": "scope-document", + "markdownDescription": "This scope permits access to all files and list content of top level directories in the `$DOCUMENT` folder." + }, + { + "description": "This scope permits to list all files and folders in the `$DOCUMENT`folder.", + "type": "string", + "const": "scope-document-index", + "markdownDescription": "This scope permits to list all files and folders in the `$DOCUMENT`folder." + }, + { + "description": "This allows full recursive read access to the complete `$DOWNLOAD` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-download-recursive`", + "type": "string", + "const": "allow-download-read-recursive", + "markdownDescription": "This allows full recursive read access to the complete `$DOWNLOAD` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-download-recursive`" + }, + { + "description": "This allows full recursive write access to the complete `$DOWNLOAD` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-download-recursive`", + "type": "string", + "const": "allow-download-write-recursive", + "markdownDescription": "This allows full recursive write access to the complete `$DOWNLOAD` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-download-recursive`" + }, + { + "description": "This allows non-recursive read access to the `$DOWNLOAD` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-download`", + "type": "string", + "const": "allow-download-read", + "markdownDescription": "This allows non-recursive read access to the `$DOWNLOAD` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-download`" + }, + { + "description": "This allows non-recursive write access to the `$DOWNLOAD` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-download`", + "type": "string", + "const": "allow-download-write", + "markdownDescription": "This allows non-recursive write access to the `$DOWNLOAD` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-download`" + }, + { + "description": "This allows full recursive read access to metadata of the `$DOWNLOAD` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-download-recursive`", + "type": "string", + "const": "allow-download-meta-recursive", + "markdownDescription": "This allows full recursive read access to metadata of the `$DOWNLOAD` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-download-recursive`" + }, + { + "description": "This allows non-recursive read access to metadata of the `$DOWNLOAD` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-download-index`", + "type": "string", + "const": "allow-download-meta", + "markdownDescription": "This allows non-recursive read access to metadata of the `$DOWNLOAD` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-download-index`" + }, + { + "description": "This scope permits recursive access to the complete `$DOWNLOAD` folder, including sub directories and files.", + "type": "string", + "const": "scope-download-recursive", + "markdownDescription": "This scope permits recursive access to the complete `$DOWNLOAD` folder, including sub directories and files." + }, + { + "description": "This scope permits access to all files and list content of top level directories in the `$DOWNLOAD` folder.", + "type": "string", + "const": "scope-download", + "markdownDescription": "This scope permits access to all files and list content of top level directories in the `$DOWNLOAD` folder." + }, + { + "description": "This scope permits to list all files and folders in the `$DOWNLOAD`folder.", + "type": "string", + "const": "scope-download-index", + "markdownDescription": "This scope permits to list all files and folders in the `$DOWNLOAD`folder." + }, + { + "description": "This allows full recursive read access to the complete `$EXE` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-exe-recursive`", + "type": "string", + "const": "allow-exe-read-recursive", + "markdownDescription": "This allows full recursive read access to the complete `$EXE` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-exe-recursive`" + }, + { + "description": "This allows full recursive write access to the complete `$EXE` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-exe-recursive`", + "type": "string", + "const": "allow-exe-write-recursive", + "markdownDescription": "This allows full recursive write access to the complete `$EXE` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-exe-recursive`" + }, + { + "description": "This allows non-recursive read access to the `$EXE` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-exe`", + "type": "string", + "const": "allow-exe-read", + "markdownDescription": "This allows non-recursive read access to the `$EXE` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-exe`" + }, + { + "description": "This allows non-recursive write access to the `$EXE` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-exe`", + "type": "string", + "const": "allow-exe-write", + "markdownDescription": "This allows non-recursive write access to the `$EXE` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-exe`" + }, + { + "description": "This allows full recursive read access to metadata of the `$EXE` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-exe-recursive`", + "type": "string", + "const": "allow-exe-meta-recursive", + "markdownDescription": "This allows full recursive read access to metadata of the `$EXE` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-exe-recursive`" + }, + { + "description": "This allows non-recursive read access to metadata of the `$EXE` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-exe-index`", + "type": "string", + "const": "allow-exe-meta", + "markdownDescription": "This allows non-recursive read access to metadata of the `$EXE` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-exe-index`" + }, + { + "description": "This scope permits recursive access to the complete `$EXE` folder, including sub directories and files.", + "type": "string", + "const": "scope-exe-recursive", + "markdownDescription": "This scope permits recursive access to the complete `$EXE` folder, including sub directories and files." + }, + { + "description": "This scope permits access to all files and list content of top level directories in the `$EXE` folder.", + "type": "string", + "const": "scope-exe", + "markdownDescription": "This scope permits access to all files and list content of top level directories in the `$EXE` folder." + }, + { + "description": "This scope permits to list all files and folders in the `$EXE`folder.", + "type": "string", + "const": "scope-exe-index", + "markdownDescription": "This scope permits to list all files and folders in the `$EXE`folder." + }, + { + "description": "This allows full recursive read access to the complete `$FONT` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-font-recursive`", + "type": "string", + "const": "allow-font-read-recursive", + "markdownDescription": "This allows full recursive read access to the complete `$FONT` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-font-recursive`" + }, + { + "description": "This allows full recursive write access to the complete `$FONT` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-font-recursive`", + "type": "string", + "const": "allow-font-write-recursive", + "markdownDescription": "This allows full recursive write access to the complete `$FONT` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-font-recursive`" + }, + { + "description": "This allows non-recursive read access to the `$FONT` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-font`", + "type": "string", + "const": "allow-font-read", + "markdownDescription": "This allows non-recursive read access to the `$FONT` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-font`" + }, + { + "description": "This allows non-recursive write access to the `$FONT` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-font`", + "type": "string", + "const": "allow-font-write", + "markdownDescription": "This allows non-recursive write access to the `$FONT` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-font`" + }, + { + "description": "This allows full recursive read access to metadata of the `$FONT` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-font-recursive`", + "type": "string", + "const": "allow-font-meta-recursive", + "markdownDescription": "This allows full recursive read access to metadata of the `$FONT` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-font-recursive`" + }, + { + "description": "This allows non-recursive read access to metadata of the `$FONT` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-font-index`", + "type": "string", + "const": "allow-font-meta", + "markdownDescription": "This allows non-recursive read access to metadata of the `$FONT` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-font-index`" + }, + { + "description": "This scope permits recursive access to the complete `$FONT` folder, including sub directories and files.", + "type": "string", + "const": "scope-font-recursive", + "markdownDescription": "This scope permits recursive access to the complete `$FONT` folder, including sub directories and files." + }, + { + "description": "This scope permits access to all files and list content of top level directories in the `$FONT` folder.", + "type": "string", + "const": "scope-font", + "markdownDescription": "This scope permits access to all files and list content of top level directories in the `$FONT` folder." + }, + { + "description": "This scope permits to list all files and folders in the `$FONT`folder.", + "type": "string", + "const": "scope-font-index", + "markdownDescription": "This scope permits to list all files and folders in the `$FONT`folder." + }, + { + "description": "This allows full recursive read access to the complete `$HOME` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-home-recursive`", + "type": "string", + "const": "allow-home-read-recursive", + "markdownDescription": "This allows full recursive read access to the complete `$HOME` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-home-recursive`" + }, + { + "description": "This allows full recursive write access to the complete `$HOME` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-home-recursive`", + "type": "string", + "const": "allow-home-write-recursive", + "markdownDescription": "This allows full recursive write access to the complete `$HOME` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-home-recursive`" + }, + { + "description": "This allows non-recursive read access to the `$HOME` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-home`", + "type": "string", + "const": "allow-home-read", + "markdownDescription": "This allows non-recursive read access to the `$HOME` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-home`" + }, + { + "description": "This allows non-recursive write access to the `$HOME` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-home`", + "type": "string", + "const": "allow-home-write", + "markdownDescription": "This allows non-recursive write access to the `$HOME` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-home`" + }, + { + "description": "This allows full recursive read access to metadata of the `$HOME` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-home-recursive`", + "type": "string", + "const": "allow-home-meta-recursive", + "markdownDescription": "This allows full recursive read access to metadata of the `$HOME` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-home-recursive`" + }, + { + "description": "This allows non-recursive read access to metadata of the `$HOME` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-home-index`", + "type": "string", + "const": "allow-home-meta", + "markdownDescription": "This allows non-recursive read access to metadata of the `$HOME` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-home-index`" + }, + { + "description": "This scope permits recursive access to the complete `$HOME` folder, including sub directories and files.", + "type": "string", + "const": "scope-home-recursive", + "markdownDescription": "This scope permits recursive access to the complete `$HOME` folder, including sub directories and files." + }, + { + "description": "This scope permits access to all files and list content of top level directories in the `$HOME` folder.", + "type": "string", + "const": "scope-home", + "markdownDescription": "This scope permits access to all files and list content of top level directories in the `$HOME` folder." + }, + { + "description": "This scope permits to list all files and folders in the `$HOME`folder.", + "type": "string", + "const": "scope-home-index", + "markdownDescription": "This scope permits to list all files and folders in the `$HOME`folder." + }, + { + "description": "This allows full recursive read access to the complete `$LOCALDATA` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-localdata-recursive`", + "type": "string", + "const": "allow-localdata-read-recursive", + "markdownDescription": "This allows full recursive read access to the complete `$LOCALDATA` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-localdata-recursive`" + }, + { + "description": "This allows full recursive write access to the complete `$LOCALDATA` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-localdata-recursive`", + "type": "string", + "const": "allow-localdata-write-recursive", + "markdownDescription": "This allows full recursive write access to the complete `$LOCALDATA` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-localdata-recursive`" + }, + { + "description": "This allows non-recursive read access to the `$LOCALDATA` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-localdata`", + "type": "string", + "const": "allow-localdata-read", + "markdownDescription": "This allows non-recursive read access to the `$LOCALDATA` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-localdata`" + }, + { + "description": "This allows non-recursive write access to the `$LOCALDATA` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-localdata`", + "type": "string", + "const": "allow-localdata-write", + "markdownDescription": "This allows non-recursive write access to the `$LOCALDATA` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-localdata`" + }, + { + "description": "This allows full recursive read access to metadata of the `$LOCALDATA` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-localdata-recursive`", + "type": "string", + "const": "allow-localdata-meta-recursive", + "markdownDescription": "This allows full recursive read access to metadata of the `$LOCALDATA` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-localdata-recursive`" + }, + { + "description": "This allows non-recursive read access to metadata of the `$LOCALDATA` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-localdata-index`", + "type": "string", + "const": "allow-localdata-meta", + "markdownDescription": "This allows non-recursive read access to metadata of the `$LOCALDATA` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-localdata-index`" + }, + { + "description": "This scope permits recursive access to the complete `$LOCALDATA` folder, including sub directories and files.", + "type": "string", + "const": "scope-localdata-recursive", + "markdownDescription": "This scope permits recursive access to the complete `$LOCALDATA` folder, including sub directories and files." + }, + { + "description": "This scope permits access to all files and list content of top level directories in the `$LOCALDATA` folder.", + "type": "string", + "const": "scope-localdata", + "markdownDescription": "This scope permits access to all files and list content of top level directories in the `$LOCALDATA` folder." + }, + { + "description": "This scope permits to list all files and folders in the `$LOCALDATA`folder.", + "type": "string", + "const": "scope-localdata-index", + "markdownDescription": "This scope permits to list all files and folders in the `$LOCALDATA`folder." + }, + { + "description": "This allows full recursive read access to the complete `$LOG` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-log-recursive`", + "type": "string", + "const": "allow-log-read-recursive", + "markdownDescription": "This allows full recursive read access to the complete `$LOG` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-log-recursive`" + }, + { + "description": "This allows full recursive write access to the complete `$LOG` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-log-recursive`", + "type": "string", + "const": "allow-log-write-recursive", + "markdownDescription": "This allows full recursive write access to the complete `$LOG` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-log-recursive`" + }, + { + "description": "This allows non-recursive read access to the `$LOG` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-log`", + "type": "string", + "const": "allow-log-read", + "markdownDescription": "This allows non-recursive read access to the `$LOG` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-log`" + }, + { + "description": "This allows non-recursive write access to the `$LOG` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-log`", + "type": "string", + "const": "allow-log-write", + "markdownDescription": "This allows non-recursive write access to the `$LOG` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-log`" + }, + { + "description": "This allows full recursive read access to metadata of the `$LOG` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-log-recursive`", + "type": "string", + "const": "allow-log-meta-recursive", + "markdownDescription": "This allows full recursive read access to metadata of the `$LOG` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-log-recursive`" + }, + { + "description": "This allows non-recursive read access to metadata of the `$LOG` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-log-index`", + "type": "string", + "const": "allow-log-meta", + "markdownDescription": "This allows non-recursive read access to metadata of the `$LOG` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-log-index`" + }, + { + "description": "This scope permits recursive access to the complete `$LOG` folder, including sub directories and files.", + "type": "string", + "const": "scope-log-recursive", + "markdownDescription": "This scope permits recursive access to the complete `$LOG` folder, including sub directories and files." + }, + { + "description": "This scope permits access to all files and list content of top level directories in the `$LOG` folder.", + "type": "string", + "const": "scope-log", + "markdownDescription": "This scope permits access to all files and list content of top level directories in the `$LOG` folder." + }, + { + "description": "This scope permits to list all files and folders in the `$LOG`folder.", + "type": "string", + "const": "scope-log-index", + "markdownDescription": "This scope permits to list all files and folders in the `$LOG`folder." + }, + { + "description": "This allows full recursive read access to the complete `$PICTURE` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-picture-recursive`", + "type": "string", + "const": "allow-picture-read-recursive", + "markdownDescription": "This allows full recursive read access to the complete `$PICTURE` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-picture-recursive`" + }, + { + "description": "This allows full recursive write access to the complete `$PICTURE` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-picture-recursive`", + "type": "string", + "const": "allow-picture-write-recursive", + "markdownDescription": "This allows full recursive write access to the complete `$PICTURE` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-picture-recursive`" + }, + { + "description": "This allows non-recursive read access to the `$PICTURE` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-picture`", + "type": "string", + "const": "allow-picture-read", + "markdownDescription": "This allows non-recursive read access to the `$PICTURE` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-picture`" + }, + { + "description": "This allows non-recursive write access to the `$PICTURE` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-picture`", + "type": "string", + "const": "allow-picture-write", + "markdownDescription": "This allows non-recursive write access to the `$PICTURE` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-picture`" + }, + { + "description": "This allows full recursive read access to metadata of the `$PICTURE` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-picture-recursive`", + "type": "string", + "const": "allow-picture-meta-recursive", + "markdownDescription": "This allows full recursive read access to metadata of the `$PICTURE` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-picture-recursive`" + }, + { + "description": "This allows non-recursive read access to metadata of the `$PICTURE` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-picture-index`", + "type": "string", + "const": "allow-picture-meta", + "markdownDescription": "This allows non-recursive read access to metadata of the `$PICTURE` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-picture-index`" + }, + { + "description": "This scope permits recursive access to the complete `$PICTURE` folder, including sub directories and files.", + "type": "string", + "const": "scope-picture-recursive", + "markdownDescription": "This scope permits recursive access to the complete `$PICTURE` folder, including sub directories and files." + }, + { + "description": "This scope permits access to all files and list content of top level directories in the `$PICTURE` folder.", + "type": "string", + "const": "scope-picture", + "markdownDescription": "This scope permits access to all files and list content of top level directories in the `$PICTURE` folder." + }, + { + "description": "This scope permits to list all files and folders in the `$PICTURE`folder.", + "type": "string", + "const": "scope-picture-index", + "markdownDescription": "This scope permits to list all files and folders in the `$PICTURE`folder." + }, + { + "description": "This allows full recursive read access to the complete `$PUBLIC` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-public-recursive`", + "type": "string", + "const": "allow-public-read-recursive", + "markdownDescription": "This allows full recursive read access to the complete `$PUBLIC` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-public-recursive`" + }, + { + "description": "This allows full recursive write access to the complete `$PUBLIC` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-public-recursive`", + "type": "string", + "const": "allow-public-write-recursive", + "markdownDescription": "This allows full recursive write access to the complete `$PUBLIC` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-public-recursive`" + }, + { + "description": "This allows non-recursive read access to the `$PUBLIC` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-public`", + "type": "string", + "const": "allow-public-read", + "markdownDescription": "This allows non-recursive read access to the `$PUBLIC` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-public`" + }, + { + "description": "This allows non-recursive write access to the `$PUBLIC` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-public`", + "type": "string", + "const": "allow-public-write", + "markdownDescription": "This allows non-recursive write access to the `$PUBLIC` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-public`" + }, + { + "description": "This allows full recursive read access to metadata of the `$PUBLIC` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-public-recursive`", + "type": "string", + "const": "allow-public-meta-recursive", + "markdownDescription": "This allows full recursive read access to metadata of the `$PUBLIC` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-public-recursive`" + }, + { + "description": "This allows non-recursive read access to metadata of the `$PUBLIC` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-public-index`", + "type": "string", + "const": "allow-public-meta", + "markdownDescription": "This allows non-recursive read access to metadata of the `$PUBLIC` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-public-index`" + }, + { + "description": "This scope permits recursive access to the complete `$PUBLIC` folder, including sub directories and files.", + "type": "string", + "const": "scope-public-recursive", + "markdownDescription": "This scope permits recursive access to the complete `$PUBLIC` folder, including sub directories and files." + }, + { + "description": "This scope permits access to all files and list content of top level directories in the `$PUBLIC` folder.", + "type": "string", + "const": "scope-public", + "markdownDescription": "This scope permits access to all files and list content of top level directories in the `$PUBLIC` folder." + }, + { + "description": "This scope permits to list all files and folders in the `$PUBLIC`folder.", + "type": "string", + "const": "scope-public-index", + "markdownDescription": "This scope permits to list all files and folders in the `$PUBLIC`folder." + }, + { + "description": "This allows full recursive read access to the complete `$RESOURCE` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-resource-recursive`", + "type": "string", + "const": "allow-resource-read-recursive", + "markdownDescription": "This allows full recursive read access to the complete `$RESOURCE` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-resource-recursive`" + }, + { + "description": "This allows full recursive write access to the complete `$RESOURCE` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-resource-recursive`", + "type": "string", + "const": "allow-resource-write-recursive", + "markdownDescription": "This allows full recursive write access to the complete `$RESOURCE` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-resource-recursive`" + }, + { + "description": "This allows non-recursive read access to the `$RESOURCE` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-resource`", + "type": "string", + "const": "allow-resource-read", + "markdownDescription": "This allows non-recursive read access to the `$RESOURCE` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-resource`" + }, + { + "description": "This allows non-recursive write access to the `$RESOURCE` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-resource`", + "type": "string", + "const": "allow-resource-write", + "markdownDescription": "This allows non-recursive write access to the `$RESOURCE` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-resource`" + }, + { + "description": "This allows full recursive read access to metadata of the `$RESOURCE` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-resource-recursive`", + "type": "string", + "const": "allow-resource-meta-recursive", + "markdownDescription": "This allows full recursive read access to metadata of the `$RESOURCE` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-resource-recursive`" + }, + { + "description": "This allows non-recursive read access to metadata of the `$RESOURCE` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-resource-index`", + "type": "string", + "const": "allow-resource-meta", + "markdownDescription": "This allows non-recursive read access to metadata of the `$RESOURCE` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-resource-index`" + }, + { + "description": "This scope permits recursive access to the complete `$RESOURCE` folder, including sub directories and files.", + "type": "string", + "const": "scope-resource-recursive", + "markdownDescription": "This scope permits recursive access to the complete `$RESOURCE` folder, including sub directories and files." + }, + { + "description": "This scope permits access to all files and list content of top level directories in the `$RESOURCE` folder.", + "type": "string", + "const": "scope-resource", + "markdownDescription": "This scope permits access to all files and list content of top level directories in the `$RESOURCE` folder." + }, + { + "description": "This scope permits to list all files and folders in the `$RESOURCE`folder.", + "type": "string", + "const": "scope-resource-index", + "markdownDescription": "This scope permits to list all files and folders in the `$RESOURCE`folder." + }, + { + "description": "This allows full recursive read access to the complete `$RUNTIME` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-runtime-recursive`", + "type": "string", + "const": "allow-runtime-read-recursive", + "markdownDescription": "This allows full recursive read access to the complete `$RUNTIME` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-runtime-recursive`" + }, + { + "description": "This allows full recursive write access to the complete `$RUNTIME` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-runtime-recursive`", + "type": "string", + "const": "allow-runtime-write-recursive", + "markdownDescription": "This allows full recursive write access to the complete `$RUNTIME` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-runtime-recursive`" + }, + { + "description": "This allows non-recursive read access to the `$RUNTIME` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-runtime`", + "type": "string", + "const": "allow-runtime-read", + "markdownDescription": "This allows non-recursive read access to the `$RUNTIME` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-runtime`" + }, + { + "description": "This allows non-recursive write access to the `$RUNTIME` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-runtime`", + "type": "string", + "const": "allow-runtime-write", + "markdownDescription": "This allows non-recursive write access to the `$RUNTIME` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-runtime`" + }, + { + "description": "This allows full recursive read access to metadata of the `$RUNTIME` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-runtime-recursive`", + "type": "string", + "const": "allow-runtime-meta-recursive", + "markdownDescription": "This allows full recursive read access to metadata of the `$RUNTIME` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-runtime-recursive`" + }, + { + "description": "This allows non-recursive read access to metadata of the `$RUNTIME` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-runtime-index`", + "type": "string", + "const": "allow-runtime-meta", + "markdownDescription": "This allows non-recursive read access to metadata of the `$RUNTIME` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-runtime-index`" + }, + { + "description": "This scope permits recursive access to the complete `$RUNTIME` folder, including sub directories and files.", + "type": "string", + "const": "scope-runtime-recursive", + "markdownDescription": "This scope permits recursive access to the complete `$RUNTIME` folder, including sub directories and files." + }, + { + "description": "This scope permits access to all files and list content of top level directories in the `$RUNTIME` folder.", + "type": "string", + "const": "scope-runtime", + "markdownDescription": "This scope permits access to all files and list content of top level directories in the `$RUNTIME` folder." + }, + { + "description": "This scope permits to list all files and folders in the `$RUNTIME`folder.", + "type": "string", + "const": "scope-runtime-index", + "markdownDescription": "This scope permits to list all files and folders in the `$RUNTIME`folder." + }, + { + "description": "This allows full recursive read access to the complete `$TEMP` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-temp-recursive`", + "type": "string", + "const": "allow-temp-read-recursive", + "markdownDescription": "This allows full recursive read access to the complete `$TEMP` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-temp-recursive`" + }, + { + "description": "This allows full recursive write access to the complete `$TEMP` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-temp-recursive`", + "type": "string", + "const": "allow-temp-write-recursive", + "markdownDescription": "This allows full recursive write access to the complete `$TEMP` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-temp-recursive`" + }, + { + "description": "This allows non-recursive read access to the `$TEMP` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-temp`", + "type": "string", + "const": "allow-temp-read", + "markdownDescription": "This allows non-recursive read access to the `$TEMP` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-temp`" + }, + { + "description": "This allows non-recursive write access to the `$TEMP` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-temp`", + "type": "string", + "const": "allow-temp-write", + "markdownDescription": "This allows non-recursive write access to the `$TEMP` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-temp`" + }, + { + "description": "This allows full recursive read access to metadata of the `$TEMP` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-temp-recursive`", + "type": "string", + "const": "allow-temp-meta-recursive", + "markdownDescription": "This allows full recursive read access to metadata of the `$TEMP` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-temp-recursive`" + }, + { + "description": "This allows non-recursive read access to metadata of the `$TEMP` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-temp-index`", + "type": "string", + "const": "allow-temp-meta", + "markdownDescription": "This allows non-recursive read access to metadata of the `$TEMP` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-temp-index`" + }, + { + "description": "This scope permits recursive access to the complete `$TEMP` folder, including sub directories and files.", + "type": "string", + "const": "scope-temp-recursive", + "markdownDescription": "This scope permits recursive access to the complete `$TEMP` folder, including sub directories and files." + }, + { + "description": "This scope permits access to all files and list content of top level directories in the `$TEMP` folder.", + "type": "string", + "const": "scope-temp", + "markdownDescription": "This scope permits access to all files and list content of top level directories in the `$TEMP` folder." + }, + { + "description": "This scope permits to list all files and folders in the `$TEMP`folder.", + "type": "string", + "const": "scope-temp-index", + "markdownDescription": "This scope permits to list all files and folders in the `$TEMP`folder." + }, + { + "description": "This allows full recursive read access to the complete `$TEMPLATE` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-template-recursive`", + "type": "string", + "const": "allow-template-read-recursive", + "markdownDescription": "This allows full recursive read access to the complete `$TEMPLATE` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-template-recursive`" + }, + { + "description": "This allows full recursive write access to the complete `$TEMPLATE` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-template-recursive`", + "type": "string", + "const": "allow-template-write-recursive", + "markdownDescription": "This allows full recursive write access to the complete `$TEMPLATE` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-template-recursive`" + }, + { + "description": "This allows non-recursive read access to the `$TEMPLATE` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-template`", + "type": "string", + "const": "allow-template-read", + "markdownDescription": "This allows non-recursive read access to the `$TEMPLATE` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-template`" + }, + { + "description": "This allows non-recursive write access to the `$TEMPLATE` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-template`", + "type": "string", + "const": "allow-template-write", + "markdownDescription": "This allows non-recursive write access to the `$TEMPLATE` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-template`" + }, + { + "description": "This allows full recursive read access to metadata of the `$TEMPLATE` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-template-recursive`", + "type": "string", + "const": "allow-template-meta-recursive", + "markdownDescription": "This allows full recursive read access to metadata of the `$TEMPLATE` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-template-recursive`" + }, + { + "description": "This allows non-recursive read access to metadata of the `$TEMPLATE` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-template-index`", + "type": "string", + "const": "allow-template-meta", + "markdownDescription": "This allows non-recursive read access to metadata of the `$TEMPLATE` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-template-index`" + }, + { + "description": "This scope permits recursive access to the complete `$TEMPLATE` folder, including sub directories and files.", + "type": "string", + "const": "scope-template-recursive", + "markdownDescription": "This scope permits recursive access to the complete `$TEMPLATE` folder, including sub directories and files." + }, + { + "description": "This scope permits access to all files and list content of top level directories in the `$TEMPLATE` folder.", + "type": "string", + "const": "scope-template", + "markdownDescription": "This scope permits access to all files and list content of top level directories in the `$TEMPLATE` folder." + }, + { + "description": "This scope permits to list all files and folders in the `$TEMPLATE`folder.", + "type": "string", + "const": "scope-template-index", + "markdownDescription": "This scope permits to list all files and folders in the `$TEMPLATE`folder." + }, + { + "description": "This allows full recursive read access to the complete `$VIDEO` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-video-recursive`", + "type": "string", + "const": "allow-video-read-recursive", + "markdownDescription": "This allows full recursive read access to the complete `$VIDEO` folder, files and subdirectories.\n#### This permission set includes:\n\n- `read-all`\n- `scope-video-recursive`" + }, + { + "description": "This allows full recursive write access to the complete `$VIDEO` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-video-recursive`", + "type": "string", + "const": "allow-video-write-recursive", + "markdownDescription": "This allows full recursive write access to the complete `$VIDEO` folder, files and subdirectories.\n#### This permission set includes:\n\n- `write-all`\n- `scope-video-recursive`" + }, + { + "description": "This allows non-recursive read access to the `$VIDEO` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-video`", + "type": "string", + "const": "allow-video-read", + "markdownDescription": "This allows non-recursive read access to the `$VIDEO` folder.\n#### This permission set includes:\n\n- `read-all`\n- `scope-video`" + }, + { + "description": "This allows non-recursive write access to the `$VIDEO` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-video`", + "type": "string", + "const": "allow-video-write", + "markdownDescription": "This allows non-recursive write access to the `$VIDEO` folder.\n#### This permission set includes:\n\n- `write-all`\n- `scope-video`" + }, + { + "description": "This allows full recursive read access to metadata of the `$VIDEO` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-video-recursive`", + "type": "string", + "const": "allow-video-meta-recursive", + "markdownDescription": "This allows full recursive read access to metadata of the `$VIDEO` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-video-recursive`" + }, + { + "description": "This allows non-recursive read access to metadata of the `$VIDEO` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-video-index`", + "type": "string", + "const": "allow-video-meta", + "markdownDescription": "This allows non-recursive read access to metadata of the `$VIDEO` folder, including file listing and statistics.\n#### This permission set includes:\n\n- `read-meta`\n- `scope-video-index`" + }, + { + "description": "This scope permits recursive access to the complete `$VIDEO` folder, including sub directories and files.", + "type": "string", + "const": "scope-video-recursive", + "markdownDescription": "This scope permits recursive access to the complete `$VIDEO` folder, including sub directories and files." + }, + { + "description": "This scope permits access to all files and list content of top level directories in the `$VIDEO` folder.", + "type": "string", + "const": "scope-video", + "markdownDescription": "This scope permits access to all files and list content of top level directories in the `$VIDEO` folder." + }, + { + "description": "This scope permits to list all files and folders in the `$VIDEO`folder.", + "type": "string", + "const": "scope-video-index", + "markdownDescription": "This scope permits to list all files and folders in the `$VIDEO`folder." + }, + { + "description": "Enables the copy_file command without any pre-configured scope.", + "type": "string", + "const": "allow-copy-file", + "markdownDescription": "Enables the copy_file command without any pre-configured scope." + }, + { + "description": "Denies the copy_file command without any pre-configured scope.", + "type": "string", + "const": "deny-copy-file", + "markdownDescription": "Denies the copy_file command without any pre-configured scope." + }, + { + "description": "Enables the create command without any pre-configured scope.", + "type": "string", + "const": "allow-create", + "markdownDescription": "Enables the create command without any pre-configured scope." + }, + { + "description": "Denies the create command without any pre-configured scope.", + "type": "string", + "const": "deny-create", + "markdownDescription": "Denies the create command without any pre-configured scope." + }, + { + "description": "Enables the exists command without any pre-configured scope.", + "type": "string", + "const": "allow-exists", + "markdownDescription": "Enables the exists command without any pre-configured scope." + }, + { + "description": "Denies the exists command without any pre-configured scope.", + "type": "string", + "const": "deny-exists", + "markdownDescription": "Denies the exists command without any pre-configured scope." + }, + { + "description": "Enables the fstat command without any pre-configured scope.", + "type": "string", + "const": "allow-fstat", + "markdownDescription": "Enables the fstat command without any pre-configured scope." + }, + { + "description": "Denies the fstat command without any pre-configured scope.", + "type": "string", + "const": "deny-fstat", + "markdownDescription": "Denies the fstat command without any pre-configured scope." + }, + { + "description": "Enables the ftruncate command without any pre-configured scope.", + "type": "string", + "const": "allow-ftruncate", + "markdownDescription": "Enables the ftruncate command without any pre-configured scope." + }, + { + "description": "Denies the ftruncate command without any pre-configured scope.", + "type": "string", + "const": "deny-ftruncate", + "markdownDescription": "Denies the ftruncate command without any pre-configured scope." + }, + { + "description": "Enables the lstat command without any pre-configured scope.", + "type": "string", + "const": "allow-lstat", + "markdownDescription": "Enables the lstat command without any pre-configured scope." + }, + { + "description": "Denies the lstat command without any pre-configured scope.", + "type": "string", + "const": "deny-lstat", + "markdownDescription": "Denies the lstat command without any pre-configured scope." + }, + { + "description": "Enables the mkdir command without any pre-configured scope.", + "type": "string", + "const": "allow-mkdir", + "markdownDescription": "Enables the mkdir command without any pre-configured scope." + }, + { + "description": "Denies the mkdir command without any pre-configured scope.", + "type": "string", + "const": "deny-mkdir", + "markdownDescription": "Denies the mkdir command without any pre-configured scope." + }, + { + "description": "Enables the open command without any pre-configured scope.", + "type": "string", + "const": "allow-open", + "markdownDescription": "Enables the open command without any pre-configured scope." + }, + { + "description": "Denies the open command without any pre-configured scope.", + "type": "string", + "const": "deny-open", + "markdownDescription": "Denies the open command without any pre-configured scope." + }, + { + "description": "Enables the read command without any pre-configured scope.", + "type": "string", + "const": "allow-read", + "markdownDescription": "Enables the read command without any pre-configured scope." + }, + { + "description": "Denies the read command without any pre-configured scope.", + "type": "string", + "const": "deny-read", + "markdownDescription": "Denies the read command without any pre-configured scope." + }, + { + "description": "Enables the read_dir command without any pre-configured scope.", + "type": "string", + "const": "allow-read-dir", + "markdownDescription": "Enables the read_dir command without any pre-configured scope." + }, + { + "description": "Denies the read_dir command without any pre-configured scope.", + "type": "string", + "const": "deny-read-dir", + "markdownDescription": "Denies the read_dir command without any pre-configured scope." + }, + { + "description": "Enables the read_file command without any pre-configured scope.", + "type": "string", + "const": "allow-read-file", + "markdownDescription": "Enables the read_file command without any pre-configured scope." + }, + { + "description": "Denies the read_file command without any pre-configured scope.", + "type": "string", + "const": "deny-read-file", + "markdownDescription": "Denies the read_file command without any pre-configured scope." + }, + { + "description": "Enables the read_text_file command without any pre-configured scope.", + "type": "string", + "const": "allow-read-text-file", + "markdownDescription": "Enables the read_text_file command without any pre-configured scope." + }, + { + "description": "Denies the read_text_file command without any pre-configured scope.", + "type": "string", + "const": "deny-read-text-file", + "markdownDescription": "Denies the read_text_file command without any pre-configured scope." + }, + { + "description": "Enables the read_text_file_lines command without any pre-configured scope.", + "type": "string", + "const": "allow-read-text-file-lines", + "markdownDescription": "Enables the read_text_file_lines command without any pre-configured scope." + }, + { + "description": "Denies the read_text_file_lines command without any pre-configured scope.", + "type": "string", + "const": "deny-read-text-file-lines", + "markdownDescription": "Denies the read_text_file_lines command without any pre-configured scope." + }, + { + "description": "Enables the read_text_file_lines_next command without any pre-configured scope.", + "type": "string", + "const": "allow-read-text-file-lines-next", + "markdownDescription": "Enables the read_text_file_lines_next command without any pre-configured scope." + }, + { + "description": "Denies the read_text_file_lines_next command without any pre-configured scope.", + "type": "string", + "const": "deny-read-text-file-lines-next", + "markdownDescription": "Denies the read_text_file_lines_next command without any pre-configured scope." + }, + { + "description": "Enables the remove command without any pre-configured scope.", + "type": "string", + "const": "allow-remove", + "markdownDescription": "Enables the remove command without any pre-configured scope." + }, + { + "description": "Denies the remove command without any pre-configured scope.", + "type": "string", + "const": "deny-remove", + "markdownDescription": "Denies the remove command without any pre-configured scope." + }, + { + "description": "Enables the rename command without any pre-configured scope.", + "type": "string", + "const": "allow-rename", + "markdownDescription": "Enables the rename command without any pre-configured scope." + }, + { + "description": "Denies the rename command without any pre-configured scope.", + "type": "string", + "const": "deny-rename", + "markdownDescription": "Denies the rename command without any pre-configured scope." + }, + { + "description": "Enables the seek command without any pre-configured scope.", + "type": "string", + "const": "allow-seek", + "markdownDescription": "Enables the seek command without any pre-configured scope." + }, + { + "description": "Denies the seek command without any pre-configured scope.", + "type": "string", + "const": "deny-seek", + "markdownDescription": "Denies the seek command without any pre-configured scope." + }, + { + "description": "Enables the size command without any pre-configured scope.", + "type": "string", + "const": "allow-size", + "markdownDescription": "Enables the size command without any pre-configured scope." + }, + { + "description": "Denies the size command without any pre-configured scope.", + "type": "string", + "const": "deny-size", + "markdownDescription": "Denies the size command without any pre-configured scope." + }, + { + "description": "Enables the stat command without any pre-configured scope.", + "type": "string", + "const": "allow-stat", + "markdownDescription": "Enables the stat command without any pre-configured scope." + }, + { + "description": "Denies the stat command without any pre-configured scope.", + "type": "string", + "const": "deny-stat", + "markdownDescription": "Denies the stat command without any pre-configured scope." + }, + { + "description": "Enables the truncate command without any pre-configured scope.", + "type": "string", + "const": "allow-truncate", + "markdownDescription": "Enables the truncate command without any pre-configured scope." + }, + { + "description": "Denies the truncate command without any pre-configured scope.", + "type": "string", + "const": "deny-truncate", + "markdownDescription": "Denies the truncate command without any pre-configured scope." + }, + { + "description": "Enables the unwatch command without any pre-configured scope.", + "type": "string", + "const": "allow-unwatch", + "markdownDescription": "Enables the unwatch command without any pre-configured scope." + }, + { + "description": "Denies the unwatch command without any pre-configured scope.", + "type": "string", + "const": "deny-unwatch", + "markdownDescription": "Denies the unwatch command without any pre-configured scope." + }, + { + "description": "Enables the watch command without any pre-configured scope.", + "type": "string", + "const": "allow-watch", + "markdownDescription": "Enables the watch command without any pre-configured scope." + }, + { + "description": "Denies the watch command without any pre-configured scope.", + "type": "string", + "const": "deny-watch", + "markdownDescription": "Denies the watch command without any pre-configured scope." + }, + { + "description": "Enables the write command without any pre-configured scope.", + "type": "string", + "const": "allow-write", + "markdownDescription": "Enables the write command without any pre-configured scope." + }, + { + "description": "Denies the write command without any pre-configured scope.", + "type": "string", + "const": "deny-write", + "markdownDescription": "Denies the write command without any pre-configured scope." + }, + { + "description": "Enables the write_file command without any pre-configured scope.", + "type": "string", + "const": "allow-write-file", + "markdownDescription": "Enables the write_file command without any pre-configured scope." + }, + { + "description": "Denies the write_file command without any pre-configured scope.", + "type": "string", + "const": "deny-write-file", + "markdownDescription": "Denies the write_file command without any pre-configured scope." + }, + { + "description": "Enables the write_text_file command without any pre-configured scope.", + "type": "string", + "const": "allow-write-text-file", + "markdownDescription": "Enables the write_text_file command without any pre-configured scope." + }, + { + "description": "Denies the write_text_file command without any pre-configured scope.", + "type": "string", + "const": "deny-write-text-file", + "markdownDescription": "Denies the write_text_file command without any pre-configured scope." + }, + { + "description": "This permissions allows to create the application specific directories.\n", + "type": "string", + "const": "create-app-specific-dirs", + "markdownDescription": "This permissions allows to create the application specific directories.\n" + }, + { + "description": "This set of permissions describes the what kind of\nfile system access the `fs` plugin has enabled or denied by default.\n\n#### Granted Permissions\n\nThis default permission set enables read access to the\napplication specific directories (AppConfig, AppData, AppLocalData, AppCache,\nAppLog) and all files and sub directories created in it.\nThe location of these directories depends on the operating system,\nwhere the application is run.\n\nIn general these directories need to be manually created\nby the application at runtime, before accessing files or folders\nin it is possible.\n\nTherefore, it is also allowed to create all of these folders via\nthe `mkdir` command.\n\n#### Denied Permissions\n\nThis default permission set prevents access to critical components\nof the Tauri application by default.\nOn Windows the webview data folder access is denied.\n\n#### This default permission set includes:\n\n- `create-app-specific-dirs`\n- `read-app-specific-dirs-recursive`\n- `deny-default`", + "type": "string", + "const": "default", + "markdownDescription": "This set of permissions describes the what kind of\nfile system access the `fs` plugin has enabled or denied by default.\n\n#### Granted Permissions\n\nThis default permission set enables read access to the\napplication specific directories (AppConfig, AppData, AppLocalData, AppCache,\nAppLog) and all files and sub directories created in it.\nThe location of these directories depends on the operating system,\nwhere the application is run.\n\nIn general these directories need to be manually created\nby the application at runtime, before accessing files or folders\nin it is possible.\n\nTherefore, it is also allowed to create all of these folders via\nthe `mkdir` command.\n\n#### Denied Permissions\n\nThis default permission set prevents access to critical components\nof the Tauri application by default.\nOn Windows the webview data folder access is denied.\n\n#### This default permission set includes:\n\n- `create-app-specific-dirs`\n- `read-app-specific-dirs-recursive`\n- `deny-default`" + }, + { + "description": "This denies access to dangerous Tauri relevant files and folders by default.\n#### This permission set includes:\n\n- `deny-webview-data-linux`\n- `deny-webview-data-windows`", + "type": "string", + "const": "deny-default", + "markdownDescription": "This denies access to dangerous Tauri relevant files and folders by default.\n#### This permission set includes:\n\n- `deny-webview-data-linux`\n- `deny-webview-data-windows`" + }, + { + "description": "This denies read access to the\n`$APPLOCALDATA` folder on linux as the webview data and configuration values are stored here.\nAllowing access can lead to sensitive information disclosure and should be well considered.", + "type": "string", + "const": "deny-webview-data-linux", + "markdownDescription": "This denies read access to the\n`$APPLOCALDATA` folder on linux as the webview data and configuration values are stored here.\nAllowing access can lead to sensitive information disclosure and should be well considered." + }, + { + "description": "This denies read access to the\n`$APPLOCALDATA/EBWebView` folder on windows as the webview data and configuration values are stored here.\nAllowing access can lead to sensitive information disclosure and should be well considered.", + "type": "string", + "const": "deny-webview-data-windows", + "markdownDescription": "This denies read access to the\n`$APPLOCALDATA/EBWebView` folder on windows as the webview data and configuration values are stored here.\nAllowing access can lead to sensitive information disclosure and should be well considered." + }, + { + "description": "This enables all read related commands without any pre-configured accessible paths.", + "type": "string", + "const": "read-all", + "markdownDescription": "This enables all read related commands without any pre-configured accessible paths." + }, + { + "description": "This permission allows recursive read functionality on the application\nspecific base directories. \n", + "type": "string", + "const": "read-app-specific-dirs-recursive", + "markdownDescription": "This permission allows recursive read functionality on the application\nspecific base directories. \n" + }, + { + "description": "This enables directory read and file metadata related commands without any pre-configured accessible paths.", + "type": "string", + "const": "read-dirs", + "markdownDescription": "This enables directory read and file metadata related commands without any pre-configured accessible paths." + }, + { + "description": "This enables file read related commands without any pre-configured accessible paths.", + "type": "string", + "const": "read-files", + "markdownDescription": "This enables file read related commands without any pre-configured accessible paths." + }, + { + "description": "This enables all index or metadata related commands without any pre-configured accessible paths.", + "type": "string", + "const": "read-meta", + "markdownDescription": "This enables all index or metadata related commands without any pre-configured accessible paths." + }, + { + "description": "An empty permission you can use to modify the global scope.", + "type": "string", + "const": "scope", + "markdownDescription": "An empty permission you can use to modify the global scope." + }, + { + "description": "This enables all write related commands without any pre-configured accessible paths.", + "type": "string", + "const": "write-all", + "markdownDescription": "This enables all write related commands without any pre-configured accessible paths." + }, + { + "description": "This enables all file write related commands without any pre-configured accessible paths.", + "type": "string", + "const": "write-files", + "markdownDescription": "This enables all file write related commands without any pre-configured accessible paths." + } + ] + } + } +} \ No newline at end of file diff --git a/plugins/fs/permissions/scope.toml b/plugins/fs/permissions/scope.toml new file mode 100644 index 00000000..7e945aa8 --- /dev/null +++ b/plugins/fs/permissions/scope.toml @@ -0,0 +1,5 @@ +"$schema" = "schemas/schema.json" + +[[permission]] +identifier = "scope" +description = "An empty permission you can use to modify the global scope." diff --git a/plugins/fs/permissions/write-all.toml b/plugins/fs/permissions/write-all.toml new file mode 100644 index 00000000..c1802782 --- /dev/null +++ b/plugins/fs/permissions/write-all.toml @@ -0,0 +1,17 @@ +"$schema" = "schemas/schema.json" + +[[permission]] +identifier = "write-all" +description = "This enables all write related commands without any pre-configured accessible paths." +commands.allow = [ + "mkdir", + "create", + "copy_file", + "remove", + "rename", + "truncate", + "ftruncate", + "write", + "write_file", + "write_text_file", +] diff --git a/plugins/fs/permissions/write-files.toml b/plugins/fs/permissions/write-files.toml new file mode 100644 index 00000000..2d6aeffb --- /dev/null +++ b/plugins/fs/permissions/write-files.toml @@ -0,0 +1,16 @@ +"$schema" = "schemas/schema.json" + +[[permission]] +identifier = "write-files" +description = "This enables all file write related commands without any pre-configured accessible paths." +commands.allow = [ + "create", + "copy_file", + "remove", + "rename", + "truncate", + "ftruncate", + "write", + "write_file", + "write_text_file", +] diff --git a/plugins/fs/rollup.config.js b/plugins/fs/rollup.config.js new file mode 100644 index 00000000..1f349ec8 --- /dev/null +++ b/plugins/fs/rollup.config.js @@ -0,0 +1,7 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import { createConfig } from '../../shared/rollup.config.js' + +export default createConfig() diff --git a/plugins/fs/rollup.config.mjs b/plugins/fs/rollup.config.mjs deleted file mode 100644 index 99a3dd31..00000000 --- a/plugins/fs/rollup.config.mjs +++ /dev/null @@ -1,11 +0,0 @@ -import { readFileSync } from "fs"; - -import { createConfig } from "../../shared/rollup.config.mjs"; - -export default createConfig({ - input: "guest-js/index.ts", - pkg: JSON.parse( - readFileSync(new URL("./package.json", import.meta.url), "utf8"), - ), - external: [/^@tauri-apps\/api/], -}); diff --git a/plugins/fs/src/api-iife.js b/plugins/fs/src/api-iife.js deleted file mode 100644 index af959a33..00000000 --- a/plugins/fs/src/api-iife.js +++ /dev/null @@ -1 +0,0 @@ -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__})} diff --git a/plugins/fs/src/commands.rs b/plugins/fs/src/commands.rs index 59255796..bd1400ea 100644 --- a/plugins/fs/src/commands.rs +++ b/plugins/fs/src/commands.rs @@ -1,27 +1,28 @@ // Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// Copyright 2018-2023 the Deno authors. // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use crate::Scope; -use anyhow::Context; use serde::{Deserialize, Serialize, Serializer}; +use serde_repr::{Deserialize_repr, Serialize_repr}; use tauri::{ - path::{BaseDirectory, SafePathBuf}, - Manager, Runtime, Window, + ipc::{CommandScope, GlobalScope}, + path::BaseDirectory, + utils::config::FsScope, + Manager, Resource, ResourceId, Runtime, Webview, }; -#[cfg(unix)] -use std::os::unix::fs::{MetadataExt, PermissionsExt}; -#[cfg(windows)] -use std::os::windows::fs::MetadataExt; use std::{ - fs::{self, symlink_metadata, File}, - io::Write, + borrow::Cow, + fs::File, + io::{BufRead, BufReader, Read, Write}, path::{Path, PathBuf}, + str::FromStr, + sync::Mutex, time::{SystemTime, UNIX_EPOCH}, }; -use crate::{Error, FsExt, Result}; +use crate::{scope::Entry, Error, SafeFilePath}; #[derive(Debug, thiserror::Error)] pub enum CommandError { @@ -29,6 +30,29 @@ pub enum CommandError { Anyhow(#[from] anyhow::Error), #[error(transparent)] Plugin(#[from] Error), + #[error(transparent)] + Tauri(#[from] tauri::Error), + #[error(transparent)] + Json(#[from] serde_json::Error), + #[error(transparent)] + Io(#[from] std::io::Error), + #[error(transparent)] + UrlParseError(#[from] url::ParseError), + #[cfg(feature = "watch")] + #[error(transparent)] + Watcher(#[from] notify::Error), +} + +impl From for CommandError { + fn from(value: String) -> Self { + Self::Anyhow(anyhow::anyhow!(value)) + } +} + +impl From<&str> for CommandError { + fn from(value: &str) -> Self { + Self::Anyhow(anyhow::anyhow!(value.to_string())) + } } impl Serialize for CommandError { @@ -36,364 +60,1223 @@ impl Serialize for CommandError { where S: Serializer, { - serializer.serialize_str(self.to_string().as_ref()) + if let Self::Anyhow(err) = self { + serializer.serialize_str(format!("{err:#}").as_ref()) + } else { + serializer.serialize_str(self.to_string().as_ref()) + } } } -type CommandResult = std::result::Result; +pub type CommandResult = std::result::Result; -/// The options for the directory functions on the file system API. -#[derive(Debug, Clone, Deserialize)] -pub struct DirOperationOptions { - /// Whether the API should recursively perform the operation on the directory. - #[serde(default)] - pub recursive: bool, - /// The base directory of the operation. - /// The directory path of the BaseDirectory will be the prefix of the defined directory path. - pub dir: Option, +#[derive(Debug, Default, Clone, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct BaseOptions { + base_dir: Option, } -/// The options for the file functions on the file system API. -#[derive(Debug, Clone, Deserialize)] -pub struct FileOperationOptions { - /// The base directory of the operation. - /// The directory path of the BaseDirectory will be the prefix of the defined file path. - pub dir: Option, -} - -fn resolve_path( - window: &Window, - path: SafePathBuf, - dir: Option, -) -> Result { - let path = if let Some(dir) = dir { - window - .path() - .resolve(&path, dir) - .map_err(Error::CannotResolvePath)? - } else { - path.as_ref().to_path_buf() - }; - if window.fs_scope().is_allowed(&path) { - Ok(path) - } else { - Err(Error::PathForbidden(path)) - } +#[tauri::command] +pub fn create( + webview: Webview, + global_scope: GlobalScope, + command_scope: CommandScope, + path: SafeFilePath, + options: Option, +) -> CommandResult { + let resolved_path = resolve_path( + &webview, + &global_scope, + &command_scope, + path, + options.and_then(|o| o.base_dir), + )?; + let file = File::create(&resolved_path).map_err(|e| { + format!( + "failed to create file at path: {} with error: {e}", + resolved_path.display() + ) + })?; + let rid = webview.resources_table().add(StdFileResource::new(file)); + Ok(rid) +} + +#[derive(Debug, Default, Clone, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct OpenOptions { + #[serde(flatten)] + base: BaseOptions, + #[serde(flatten)] + options: crate::OpenOptions, } #[tauri::command] -pub fn read_file( - window: Window, - path: SafePathBuf, - options: Option, -) -> CommandResult> { - let resolved_path = resolve_path(&window, path, options.and_then(|o| o.dir))?; - fs::read(&resolved_path) - .with_context(|| format!("path: {}", resolved_path.display())) - .map_err(Into::into) +pub fn open( + webview: Webview, + global_scope: GlobalScope, + command_scope: CommandScope, + path: SafeFilePath, + options: Option, +) -> CommandResult { + let (file, _path) = resolve_file( + &webview, + &global_scope, + &command_scope, + path, + if let Some(opts) = options { + OpenOptions { + base: opts.base, + options: opts.options, + } + } else { + OpenOptions { + base: BaseOptions { base_dir: None }, + options: crate::OpenOptions { + read: true, + write: false, + truncate: false, + create: false, + create_new: false, + append: false, + mode: None, + custom_flags: None, + }, + } + }, + )?; + + let rid = webview.resources_table().add(StdFileResource::new(file)); + + Ok(rid) +} + +#[derive(Debug, Clone, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct CopyFileOptions { + from_path_base_dir: Option, + to_path_base_dir: Option, } #[tauri::command] -pub fn read_text_file( - window: Window, - path: SafePathBuf, - options: Option, -) -> CommandResult { - let resolved_path = resolve_path(&window, path, options.and_then(|o| o.dir))?; - fs::read_to_string(&resolved_path) - .with_context(|| format!("path: {}", resolved_path.display())) - .map_err(Into::into) +pub async fn copy_file( + webview: Webview, + global_scope: GlobalScope, + command_scope: CommandScope, + from_path: SafeFilePath, + to_path: SafeFilePath, + options: Option, +) -> CommandResult<()> { + let resolved_from_path = resolve_path( + &webview, + &global_scope, + &command_scope, + from_path, + options.as_ref().and_then(|o| o.from_path_base_dir), + )?; + let resolved_to_path = resolve_path( + &webview, + &global_scope, + &command_scope, + to_path, + options.as_ref().and_then(|o| o.to_path_base_dir), + )?; + std::fs::copy(&resolved_from_path, &resolved_to_path).map_err(|e| { + format!( + "failed to copy file from path: {}, to path: {} with error: {e}", + resolved_from_path.display(), + resolved_to_path.display() + ) + })?; + Ok(()) +} + +#[derive(Debug, Clone, Deserialize)] +pub struct MkdirOptions { + #[serde(flatten)] + base: BaseOptions, + #[allow(unused)] + mode: Option, + recursive: Option, } #[tauri::command] -pub fn write_file( - window: Window, - path: SafePathBuf, - contents: Vec, - options: Option, +pub fn mkdir( + webview: Webview, + global_scope: GlobalScope, + command_scope: CommandScope, + path: SafeFilePath, + options: Option, ) -> CommandResult<()> { - let resolved_path = resolve_path(&window, path, options.and_then(|o| o.dir))?; - File::create(&resolved_path) - .with_context(|| format!("path: {}", resolved_path.display())) + let resolved_path = resolve_path( + &webview, + &global_scope, + &command_scope, + path, + options.as_ref().and_then(|o| o.base.base_dir), + )?; + + let mut builder = std::fs::DirBuilder::new(); + builder.recursive(options.as_ref().and_then(|o| o.recursive).unwrap_or(false)); + + #[cfg(unix)] + { + use std::os::unix::fs::DirBuilderExt; + let mode = options.as_ref().and_then(|o| o.mode).unwrap_or(0o777) & 0o777; + builder.mode(mode); + } + + builder + .create(&resolved_path) + .map_err(|e| { + format!( + "failed to create directory at path: {} with error: {e}", + resolved_path.display() + ) + }) .map_err(Into::into) - .and_then(|mut f| { - f.write_all(&contents) - .map_err(|err| anyhow::anyhow!("{}", err)) - .map_err(Into::into) +} + +#[derive(Debug, Serialize)] +#[serde(rename_all = "camelCase")] +#[non_exhaustive] +pub struct DirEntry { + pub name: String, + pub is_directory: bool, + pub is_file: bool, + pub is_symlink: bool, +} + +#[tauri::command] +pub async fn read_dir( + webview: Webview, + global_scope: GlobalScope, + command_scope: CommandScope, + path: SafeFilePath, + options: Option, +) -> CommandResult> { + let resolved_path = resolve_path( + &webview, + &global_scope, + &command_scope, + path, + options.as_ref().and_then(|o| o.base_dir), + )?; + + let entries = std::fs::read_dir(&resolved_path).map_err(|e| { + format!( + "failed to read directory at path: {} with error: {e}", + resolved_path.display() + ) + })?; + + let entries = entries + .filter_map(|entry| { + let entry = entry.ok()?; + let name = entry.file_name().into_string().ok()?; + let metadata = entry.file_type(); + macro_rules! method_or_false { + ($method:ident) => { + if let Ok(metadata) = &metadata { + metadata.$method() + } else { + false + } + }; + } + Some(DirEntry { + name, + is_file: method_or_false!(is_file), + is_directory: method_or_false!(is_dir), + is_symlink: method_or_false!(is_symlink), + }) }) + .collect(); + + Ok(entries) } -#[derive(Clone, Copy)] -struct ReadDirOptions<'a> { - pub scope: Option<&'a Scope>, +#[tauri::command] +pub async fn read( + webview: Webview, + rid: ResourceId, + len: usize, +) -> CommandResult { + let mut data = vec![0; len]; + let file = webview.resources_table().get::(rid)?; + let nread = StdFileResource::with_lock(&file, |mut file| file.read(&mut data)) + .map_err(|e| format!("faied to read bytes from file with error: {e}"))?; + + // This is an optimization to include the number of read bytes (as bigendian bytes) + // at the end of returned vector so we can use `tauri::ipc::Response` + // and avoid serialization overhead of separate values. + #[cfg(target_pointer_width = "16")] + let nread = { + let nread = nread.to_be_bytes(); + let mut out = [0; 8]; + out[6..].copy_from_slice(&nread); + out + }; + #[cfg(target_pointer_width = "32")] + let nread = { + let nread = nread.to_be_bytes(); + let mut out = [0; 8]; + out[4..].copy_from_slice(&nread); + out + }; + #[cfg(target_pointer_width = "64")] + let nread = nread.to_be_bytes(); + + data.extend(nread); + + Ok(tauri::ipc::Response::new(data)) } -#[derive(Debug, Serialize)] -#[non_exhaustive] -pub struct DiskEntry { - /// The path to the entry. - pub path: PathBuf, - /// The name of the entry (file name with extension or directory name). - pub name: Option, - /// The children of this entry if it's a directory. - #[serde(skip_serializing_if = "Option::is_none")] - pub children: Option>, +#[tauri::command] +pub async fn read_file( + webview: Webview, + global_scope: GlobalScope, + command_scope: CommandScope, + path: SafeFilePath, + options: Option, +) -> CommandResult { + let (mut file, path) = resolve_file( + &webview, + &global_scope, + &command_scope, + path, + OpenOptions { + base: BaseOptions { + base_dir: options.as_ref().and_then(|o| o.base_dir), + }, + options: crate::OpenOptions { + read: true, + ..Default::default() + }, + }, + )?; + + let mut contents = Vec::new(); + + file.read_to_end(&mut contents).map_err(|e| { + format!( + "failed to read file as text at path: {} with error: {e}", + path.display() + ) + })?; + + Ok(tauri::ipc::Response::new(contents)) } -fn read_dir_with_options>( - path: P, - recursive: bool, - options: ReadDirOptions<'_>, -) -> Result> { - let mut files_and_dirs: Vec = vec![]; - for entry in fs::read_dir(path)? { - let path = entry?.path(); - let path_as_string = path.display().to_string(); - - if let Ok(flag) = path.metadata().map(|m| m.is_dir()) { - let is_symlink = symlink_metadata(&path).map(|md| md.is_symlink())?; - files_and_dirs.push(DiskEntry { - path: path.clone(), - children: if flag { - Some( - if recursive - && (!is_symlink - || options.scope.map(|s| s.is_allowed(&path)).unwrap_or(true)) - { - read_dir_with_options(&path_as_string, true, options)? - } else { - vec![] - }, - ) - } else { - None - }, - name: path - .file_name() - .map(|name| name.to_string_lossy()) - .map(|name| name.to_string()), - }); +// TODO, remove in v3, rely on `read_file` command instead +#[tauri::command] +pub async fn read_text_file( + webview: Webview, + global_scope: GlobalScope, + command_scope: CommandScope, + path: SafeFilePath, + options: Option, +) -> CommandResult { + read_file(webview, global_scope, command_scope, path, options).await +} + +#[tauri::command] +pub fn read_text_file_lines( + webview: Webview, + global_scope: GlobalScope, + command_scope: CommandScope, + path: SafeFilePath, + options: Option, +) -> CommandResult { + let resolved_path = resolve_path( + &webview, + &global_scope, + &command_scope, + path, + options.as_ref().and_then(|o| o.base_dir), + )?; + + let file = File::open(&resolved_path).map_err(|e| { + format!( + "failed to open file at path: {} with error: {e}", + resolved_path.display() + ) + })?; + + let lines = BufReader::new(file); + let rid = webview.resources_table().add(StdLinesResource::new(lines)); + + Ok(rid) +} + +#[tauri::command] +pub async fn read_text_file_lines_next( + webview: Webview, + rid: ResourceId, +) -> CommandResult { + let mut resource_table = webview.resources_table(); + let lines = resource_table.get::(rid)?; + + let ret = StdLinesResource::with_lock(&lines, |lines| -> CommandResult> { + // This is an optimization to include wether we finished iteration or not (1 or 0) + // at the end of returned vector so we can use `tauri::ipc::Response` + // and avoid serialization overhead of separate values. + match lines.next() { + Some(Ok(mut bytes)) => { + bytes.push(false as u8); + Ok(bytes) + } + Some(Err(_)) => Ok(vec![false as u8]), + None => { + resource_table.close(rid)?; + Ok(vec![true as u8]) + } } - } - Result::Ok(files_and_dirs) + }); + + ret.map(tauri::ipc::Response::new) +} + +#[derive(Debug, Clone, Deserialize)] +pub struct RemoveOptions { + #[serde(flatten)] + base: BaseOptions, + recursive: Option, } #[tauri::command] -pub fn read_dir( - window: Window, - path: SafePathBuf, - options: Option, -) -> CommandResult> { - let (recursive, dir) = if let Some(options_value) = options { - (options_value.recursive, options_value.dir) +pub fn remove( + webview: Webview, + global_scope: GlobalScope, + command_scope: CommandScope, + path: SafeFilePath, + options: Option, +) -> CommandResult<()> { + let resolved_path = resolve_path( + &webview, + &global_scope, + &command_scope, + path, + options.as_ref().and_then(|o| o.base.base_dir), + )?; + + let metadata = std::fs::symlink_metadata(&resolved_path).map_err(|e| { + format!( + "failed to get metadata of path: {} with error: {e}", + resolved_path.display() + ) + })?; + + let file_type = metadata.file_type(); + + // taken from deno source code: https://github.com/denoland/deno/blob/429759fe8b4207240709c240a8344d12a1e39566/runtime/ops/fs.rs#L728 + let res = if file_type.is_file() { + std::fs::remove_file(&resolved_path) + } else if options.as_ref().and_then(|o| o.recursive).unwrap_or(false) { + std::fs::remove_dir_all(&resolved_path) + } else if file_type.is_symlink() { + #[cfg(unix)] + { + std::fs::remove_file(&resolved_path) + } + #[cfg(not(unix))] + { + use std::os::windows::fs::MetadataExt; + const FILE_ATTRIBUTE_DIRECTORY: u32 = 0x00000010; + if metadata.file_attributes() & FILE_ATTRIBUTE_DIRECTORY != 0 { + std::fs::remove_dir(&resolved_path) + } else { + std::fs::remove_file(&resolved_path) + } + } + } else if file_type.is_dir() { + std::fs::remove_dir(&resolved_path) } else { - (false, None) + // pipes, sockets, etc... + std::fs::remove_file(&resolved_path) }; - let resolved_path = resolve_path(&window, path, dir)?; - read_dir_with_options( - &resolved_path, - recursive, - ReadDirOptions { - scope: Some(window.fs_scope()), - }, - ) - .with_context(|| format!("path: {}", resolved_path.display())) + + res.map_err(|e| { + format!( + "failed to remove path: {} with error: {e}", + resolved_path.display() + ) + }) .map_err(Into::into) } +#[derive(Debug, Clone, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct RenameOptions { + new_path_base_dir: Option, + old_path_base_dir: Option, +} + #[tauri::command] -pub fn copy_file( - window: Window, - source: SafePathBuf, - destination: SafePathBuf, - options: Option, +pub fn rename( + webview: Webview, + global_scope: GlobalScope, + command_scope: CommandScope, + old_path: SafeFilePath, + new_path: SafeFilePath, + options: Option, ) -> CommandResult<()> { - match options.and_then(|o| o.dir) { - Some(dir) => { - let src = resolve_path(&window, source, Some(dir))?; - let dest = resolve_path(&window, destination, Some(dir))?; - fs::copy(&src, &dest) - .with_context(|| format!("source: {}, dest: {}", src.display(), dest.display()))? - } - None => fs::copy(&source, &destination).with_context(|| { + let resolved_old_path = resolve_path( + &webview, + &global_scope, + &command_scope, + old_path, + options.as_ref().and_then(|o| o.old_path_base_dir), + )?; + let resolved_new_path = resolve_path( + &webview, + &global_scope, + &command_scope, + new_path, + options.as_ref().and_then(|o| o.new_path_base_dir), + )?; + std::fs::rename(&resolved_old_path, &resolved_new_path) + .map_err(|e| { format!( - "source: {}, dest: {}", - source.display(), - destination.display() + "failed to rename old path: {} to new path: {} with error: {e}", + resolved_old_path.display(), + resolved_new_path.display() ) - })?, - }; - Ok(()) + }) + .map_err(Into::into) +} + +#[derive(Serialize_repr, Deserialize_repr, Clone, Copy, Debug)] +#[repr(u16)] +pub enum SeekMode { + Start = 0, + Current = 1, + End = 2, } #[tauri::command] -pub fn create_dir( - window: Window, - path: SafePathBuf, - options: Option, -) -> CommandResult<()> { - let (recursive, dir) = if let Some(options_value) = options { - (options_value.recursive, options_value.dir) - } else { - (false, None) - }; - let resolved_path = resolve_path(&window, path, dir)?; - if recursive { - fs::create_dir_all(&resolved_path) - .with_context(|| format!("path: {}", resolved_path.display()))?; - } else { - fs::create_dir(&resolved_path) - .with_context(|| format!("path: {} (non recursive)", resolved_path.display()))?; +pub async fn seek( + webview: Webview, + rid: ResourceId, + offset: i64, + whence: SeekMode, +) -> CommandResult { + use std::io::{Seek, SeekFrom}; + let file = webview.resources_table().get::(rid)?; + StdFileResource::with_lock(&file, |mut file| { + file.seek(match whence { + SeekMode::Start => SeekFrom::Start(offset as u64), + SeekMode::Current => SeekFrom::Current(offset), + SeekMode::End => SeekFrom::End(offset), + }) + }) + .map_err(|e| format!("failed to seek file with error: {e}")) + .map_err(Into::into) +} + +#[cfg(target_os = "android")] +fn get_metadata std::io::Result>( + metadata_fn: F, + webview: &Webview, + global_scope: &GlobalScope, + command_scope: &CommandScope, + path: SafeFilePath, + options: Option, +) -> CommandResult { + match path { + SafeFilePath::Url(url) => { + let (file, path) = resolve_file( + webview, + global_scope, + command_scope, + SafeFilePath::Url(url), + OpenOptions { + base: BaseOptions { base_dir: None }, + options: crate::OpenOptions { + read: true, + ..Default::default() + }, + }, + )?; + file.metadata().map_err(|e| { + format!( + "failed to get metadata of path: {} with error: {e}", + path.display() + ) + .into() + }) + } + SafeFilePath::Path(p) => get_fs_metadata( + metadata_fn, + webview, + global_scope, + command_scope, + SafeFilePath::Path(p), + options, + ), } +} - Ok(()) +#[cfg(not(target_os = "android"))] +fn get_metadata std::io::Result>( + metadata_fn: F, + webview: &Webview, + global_scope: &GlobalScope, + command_scope: &CommandScope, + path: SafeFilePath, + options: Option, +) -> CommandResult { + get_fs_metadata( + metadata_fn, + webview, + global_scope, + command_scope, + path, + options, + ) +} + +fn get_fs_metadata std::io::Result>( + metadata_fn: F, + webview: &Webview, + global_scope: &GlobalScope, + command_scope: &CommandScope, + path: SafeFilePath, + options: Option, +) -> CommandResult { + let resolved_path = resolve_path( + webview, + global_scope, + command_scope, + path, + options.as_ref().and_then(|o| o.base_dir), + )?; + let metadata = metadata_fn(&resolved_path).map_err(|e| { + format!( + "failed to get metadata of path: {} with error: {e}", + resolved_path.display() + ) + })?; + Ok(metadata) +} + +#[tauri::command] +pub fn stat( + webview: Webview, + global_scope: GlobalScope, + command_scope: CommandScope, + path: SafeFilePath, + options: Option, +) -> CommandResult { + let metadata = get_metadata( + |p| std::fs::metadata(p), + &webview, + &global_scope, + &command_scope, + path, + options, + )?; + + Ok(get_stat(metadata)) +} + +#[tauri::command] +pub fn lstat( + webview: Webview, + global_scope: GlobalScope, + command_scope: CommandScope, + path: SafeFilePath, + options: Option, +) -> CommandResult { + let metadata = get_metadata( + |p| std::fs::symlink_metadata(p), + &webview, + &global_scope, + &command_scope, + path, + options, + )?; + Ok(get_stat(metadata)) } #[tauri::command] -pub fn remove_dir( - window: Window, - path: SafePathBuf, - options: Option, +pub fn fstat(webview: Webview, rid: ResourceId) -> CommandResult { + let file = webview.resources_table().get::(rid)?; + let metadata = StdFileResource::with_lock(&file, |file| file.metadata()) + .map_err(|e| format!("failed to get metadata of file with error: {e}"))?; + Ok(get_stat(metadata)) +} + +#[tauri::command] +pub async fn truncate( + webview: Webview, + global_scope: GlobalScope, + command_scope: CommandScope, + path: SafeFilePath, + len: Option, + options: Option, ) -> CommandResult<()> { - let (recursive, dir) = if let Some(options_value) = options { - (options_value.recursive, options_value.dir) - } else { - (false, None) - }; - let resolved_path = resolve_path(&window, path, dir)?; - if recursive { - fs::remove_dir_all(&resolved_path) - .with_context(|| format!("path: {}", resolved_path.display()))?; - } else { - fs::remove_dir(&resolved_path) - .with_context(|| format!("path: {} (non recursive)", resolved_path.display()))?; - } + let resolved_path = resolve_path( + &webview, + &global_scope, + &command_scope, + path, + options.as_ref().and_then(|o| o.base_dir), + )?; + let f = std::fs::OpenOptions::new() + .write(true) + .open(&resolved_path) + .map_err(|e| { + format!( + "failed to open file at path: {} with error: {e}", + resolved_path.display() + ) + })?; + f.set_len(len.unwrap_or(0)) + .map_err(|e| { + format!( + "failed to truncate file at path: {} with error: {e}", + resolved_path.display() + ) + }) + .map_err(Into::into) +} - Ok(()) +#[tauri::command] +pub async fn ftruncate( + webview: Webview, + rid: ResourceId, + len: Option, +) -> CommandResult<()> { + let file = webview.resources_table().get::(rid)?; + StdFileResource::with_lock(&file, |file| file.set_len(len.unwrap_or(0))) + .map_err(|e| format!("failed to truncate file with error: {e}")) + .map_err(Into::into) +} + +#[tauri::command] +pub async fn write( + webview: Webview, + rid: ResourceId, + data: Vec, +) -> CommandResult { + let file = webview.resources_table().get::(rid)?; + StdFileResource::with_lock(&file, |mut file| file.write(&data)) + .map_err(|e| format!("failed to write bytes to file with error: {e}")) + .map_err(Into::into) +} + +#[derive(Debug, Clone, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct WriteFileOptions { + #[serde(flatten)] + base: BaseOptions, + #[serde(default)] + append: bool, + #[serde(default = "default_create_value")] + create: bool, + #[serde(default)] + create_new: bool, + #[allow(unused)] + mode: Option, +} + +fn default_create_value() -> bool { + true } #[tauri::command] -pub fn remove_file( - window: Window, - path: SafePathBuf, - options: Option, +pub async fn write_file( + webview: Webview, + global_scope: GlobalScope, + command_scope: CommandScope, + request: tauri::ipc::Request<'_>, ) -> CommandResult<()> { - let resolved_path = resolve_path(&window, path, options.and_then(|o| o.dir))?; - fs::remove_file(&resolved_path) - .with_context(|| format!("path: {}", resolved_path.display()))?; - Ok(()) + let data = match request.body() { + tauri::ipc::InvokeBody::Raw(data) => Cow::Borrowed(data), + tauri::ipc::InvokeBody::Json(serde_json::Value::Array(data)) => Cow::Owned( + data.iter() + .flat_map(|v| v.as_number().and_then(|v| v.as_u64().map(|v| v as u8))) + .collect(), + ), + _ => return Err(anyhow::anyhow!("unexpected invoke body").into()), + }; + + let path = request + .headers() + .get("path") + .ok_or_else(|| anyhow::anyhow!("missing file path").into()) + .and_then(|p| { + percent_encoding::percent_decode(p.as_ref()) + .decode_utf8() + .map_err(|_| anyhow::anyhow!("path is not a valid UTF-8").into()) + }) + .and_then(|p| SafeFilePath::from_str(&p).map_err(CommandError::from))?; + let options: Option = request + .headers() + .get("options") + .and_then(|p| p.to_str().ok()) + .and_then(|opts| serde_json::from_str(opts).ok()); + + let (mut file, path) = resolve_file( + &webview, + &global_scope, + &command_scope, + path, + if let Some(opts) = options { + OpenOptions { + base: opts.base, + options: crate::OpenOptions { + read: false, + write: true, + create: opts.create, + truncate: !opts.append, + append: opts.append, + create_new: opts.create_new, + mode: opts.mode, + custom_flags: None, + }, + } + } else { + OpenOptions { + base: BaseOptions { base_dir: None }, + options: crate::OpenOptions { + read: false, + write: true, + truncate: true, + create: true, + create_new: false, + append: false, + mode: None, + custom_flags: None, + }, + } + }, + )?; + + file.write_all(&data) + .map_err(|e| { + format!( + "failed to write bytes to file at path: {} with error: {e}", + path.display() + ) + }) + .map_err(Into::into) } +// TODO, remove in v3, rely on `write_file` command instead #[tauri::command] -pub fn rename_file( - window: Window, - old_path: SafePathBuf, - new_path: SafePathBuf, - options: Option, +pub async fn write_text_file( + webview: Webview, + global_scope: GlobalScope, + command_scope: CommandScope, + request: tauri::ipc::Request<'_>, ) -> CommandResult<()> { - match options.and_then(|o| o.dir) { - Some(dir) => { - let old = resolve_path(&window, old_path, Some(dir))?; - let new = resolve_path(&window, new_path, Some(dir))?; - fs::rename(&old, &new) - .with_context(|| format!("old: {}, new: {}", old.display(), new.display()))? - } - None => fs::rename(&old_path, &new_path) - .with_context(|| format!("old: {}, new: {}", old_path.display(), new_path.display()))?, - } - Ok(()) + write_file(webview, global_scope, command_scope, request).await } #[tauri::command] pub fn exists( - window: Window, - path: SafePathBuf, - options: Option, + webview: Webview, + global_scope: GlobalScope, + command_scope: CommandScope, + path: SafeFilePath, + options: Option, ) -> CommandResult { - let resolved_path = resolve_path(&window, path, options.and_then(|o| o.dir))?; + let resolved_path = resolve_path( + &webview, + &global_scope, + &command_scope, + path, + options.as_ref().and_then(|o| o.base_dir), + )?; Ok(resolved_path.exists()) } -#[derive(Serialize)] -#[serde(rename_all = "camelCase")] -pub struct Permissions { - readonly: bool, - #[cfg(unix)] - mode: u32, +#[tauri::command] +pub async fn size( + webview: Webview, + global_scope: GlobalScope, + command_scope: CommandScope, + path: SafeFilePath, + options: Option, +) -> CommandResult { + let resolved_path = resolve_path( + &webview, + &global_scope, + &command_scope, + path, + options.as_ref().and_then(|o| o.base_dir), + )?; + + let metadata = resolved_path.metadata()?; + + if metadata.is_file() { + Ok(metadata.len()) + } else { + let size = get_dir_size(&resolved_path).map_err(|e| { + format!( + "failed to get size at path: {} with error: {e}", + resolved_path.display() + ) + })?; + + Ok(size) + } } -#[cfg(unix)] -#[derive(Serialize)] -#[serde(rename_all = "camelCase")] -pub struct UnixMetadata { - dev: u64, - ino: u64, - mode: u32, - nlink: u64, - uid: u32, - gid: u32, - rdev: u64, - blksize: u64, - blocks: u64, -} - -#[derive(Serialize)] +fn get_dir_size(path: &PathBuf) -> CommandResult { + let mut size = 0; + + for entry in std::fs::read_dir(path)? { + let entry = entry?; + let metadata = entry.metadata()?; + + if metadata.is_file() { + size += metadata.len(); + } else if metadata.is_dir() { + size += get_dir_size(&entry.path())?; + } + } + + Ok(size) +} + +#[cfg(not(target_os = "android"))] +pub fn resolve_file( + webview: &Webview, + global_scope: &GlobalScope, + command_scope: &CommandScope, + path: SafeFilePath, + open_options: OpenOptions, +) -> CommandResult<(File, PathBuf)> { + resolve_file_in_fs(webview, global_scope, command_scope, path, open_options) +} + +fn resolve_file_in_fs( + webview: &Webview, + global_scope: &GlobalScope, + command_scope: &CommandScope, + path: SafeFilePath, + open_options: OpenOptions, +) -> CommandResult<(File, PathBuf)> { + let path = resolve_path( + webview, + global_scope, + command_scope, + path, + open_options.base.base_dir, + )?; + + let file = std::fs::OpenOptions::from(open_options.options) + .open(&path) + .map_err(|e| { + format!( + "failed to open file at path: {} with error: {e}", + path.display() + ) + })?; + Ok((file, path)) +} + +#[cfg(target_os = "android")] +pub fn resolve_file( + webview: &Webview, + global_scope: &GlobalScope, + command_scope: &CommandScope, + path: SafeFilePath, + open_options: OpenOptions, +) -> CommandResult<(File, PathBuf)> { + use crate::FsExt; + + match path { + SafeFilePath::Url(url) => { + let path = url.as_str().into(); + let file = webview + .fs() + .open(SafeFilePath::Url(url), open_options.options)?; + Ok((file, path)) + } + SafeFilePath::Path(path) => resolve_file_in_fs( + webview, + global_scope, + command_scope, + SafeFilePath::Path(path), + open_options, + ), + } +} + +pub fn resolve_path( + webview: &Webview, + global_scope: &GlobalScope, + command_scope: &CommandScope, + path: SafeFilePath, + base_dir: Option, +) -> CommandResult { + let path = path.into_path()?; + let path = if let Some(base_dir) = base_dir { + webview.path().resolve(&path, base_dir)? + } else { + path + }; + + let fs_scope = webview.state::(); + + let scope = tauri::scope::fs::Scope::new( + webview, + &FsScope::Scope { + allow: global_scope + .allows() + .iter() + .filter_map(|e| e.path.clone()) + .chain(command_scope.allows().iter().filter_map(|e| e.path.clone())) + .collect(), + deny: global_scope + .denies() + .iter() + .filter_map(|e| e.path.clone()) + .chain(command_scope.denies().iter().filter_map(|e| e.path.clone())) + .collect(), + require_literal_leading_dot: fs_scope.require_literal_leading_dot, + }, + )?; + + let require_literal_leading_dot = fs_scope.require_literal_leading_dot.unwrap_or(cfg!(unix)); + + if is_forbidden(&fs_scope.scope, &path, require_literal_leading_dot) + || is_forbidden(&scope, &path, require_literal_leading_dot) + { + return Err(CommandError::Plugin(Error::PathForbidden(path))); + } + + if fs_scope.scope.is_allowed(&path) || scope.is_allowed(&path) { + Ok(path) + } else { + Err(CommandError::Plugin(Error::PathForbidden(path))) + } +} + +fn is_forbidden>( + scope: &tauri::fs::Scope, + path: P, + require_literal_leading_dot: bool, +) -> bool { + let path = path.as_ref(); + let path = if path.is_symlink() { + match std::fs::read_link(path) { + Ok(p) => p, + Err(_) => return false, + } + } else { + path.to_path_buf() + }; + let path = if !path.exists() { + crate::Result::Ok(path) + } else { + std::fs::canonicalize(path).map_err(Into::into) + }; + + if let Ok(path) = path { + let path: PathBuf = path.components().collect(); + scope.forbidden_patterns().iter().any(|p| { + p.matches_path_with( + &path, + glob::MatchOptions { + // this is needed so `/dir/*` doesn't match files within subdirectories such as `/dir/subdir/file.txt` + // see: + require_literal_separator: true, + require_literal_leading_dot, + ..Default::default() + }, + ) + }) + } else { + false + } +} + +struct StdFileResource(Mutex); + +impl StdFileResource { + fn new(file: File) -> Self { + Self(Mutex::new(file)) + } + + fn with_lock R>(&self, mut f: F) -> R { + let file = self.0.lock().unwrap(); + f(&file) + } +} + +impl Resource for StdFileResource {} + +/// Same as [std::io::Lines] but with bytes +struct LinesBytes(T); + +impl Iterator for LinesBytes { + type Item = std::io::Result>; + + fn next(&mut self) -> Option>> { + let mut buf = Vec::new(); + match self.0.read_until(b'\n', &mut buf) { + Ok(0) => None, + Ok(_n) => { + if buf.last() == Some(&b'\n') { + buf.pop(); + if buf.last() == Some(&b'\r') { + buf.pop(); + } + } + Some(Ok(buf)) + } + Err(e) => Some(Err(e)), + } + } +} + +struct StdLinesResource(Mutex>>); + +impl StdLinesResource { + fn new(lines: BufReader) -> Self { + Self(Mutex::new(LinesBytes(lines))) + } + + fn with_lock>) -> R>(&self, mut f: F) -> R { + let mut lines = self.0.lock().unwrap(); + f(&mut lines) + } +} + +impl Resource for StdLinesResource {} + +// taken from deno source code: https://github.com/denoland/deno/blob/ffffa2f7c44bd26aec5ae1957e0534487d099f48/runtime/ops/fs.rs#L913 +#[inline] +fn to_msec(maybe_time: std::result::Result) -> Option { + match maybe_time { + Ok(time) => { + let msec = time + .duration_since(UNIX_EPOCH) + .map(|t| t.as_millis() as u64) + .unwrap_or_else(|err| err.duration().as_millis() as u64); + Some(msec) + } + Err(_) => None, + } +} + +// taken from deno source code: https://github.com/denoland/deno/blob/ffffa2f7c44bd26aec5ae1957e0534487d099f48/runtime/ops/fs.rs#L926 +#[derive(Debug, Clone, Serialize)] #[serde(rename_all = "camelCase")] -pub struct Metadata { - accessed_at_ms: u64, - created_at_ms: u64, - modified_at_ms: u64, - is_dir: bool, +pub struct FileInfo { is_file: bool, + is_directory: bool, is_symlink: bool, size: u64, - permissions: Permissions, - #[cfg(unix)] - #[serde(flatten)] - unix: UnixMetadata, - #[cfg(windows)] - file_attributes: u32, + // In milliseconds, like JavaScript. Available on both Unix or Windows. + mtime: Option, + atime: Option, + birthtime: Option, + readonly: bool, + // Following are only valid under Windows. + file_attribues: Option, + // Following are only valid under Unix. + dev: Option, + ino: Option, + mode: Option, + nlink: Option, + uid: Option, + gid: Option, + rdev: Option, + blksize: Option, + blocks: Option, } -fn system_time_to_ms(time: std::io::Result) -> u64 { - time.map(|t| { - let duration_since_epoch = t.duration_since(UNIX_EPOCH).unwrap(); - duration_since_epoch.as_millis() as u64 - }) - .unwrap_or_default() -} +// taken from deno source code: https://github.com/denoland/deno/blob/ffffa2f7c44bd26aec5ae1957e0534487d099f48/runtime/ops/fs.rs#L950 +#[inline(always)] +fn get_stat(metadata: std::fs::Metadata) -> FileInfo { + // Unix stat member (number types only). 0 if not on unix. + macro_rules! usm { + ($member:ident) => {{ + #[cfg(unix)] + { + Some(metadata.$member()) + } + #[cfg(not(unix))] + { + None + } + }}; + } -#[tauri::command] -pub async fn metadata(path: PathBuf) -> Result { - let metadata = std::fs::metadata(path)?; - let file_type = metadata.file_type(); - let permissions = metadata.permissions(); - Ok(Metadata { - accessed_at_ms: system_time_to_ms(metadata.accessed()), - created_at_ms: system_time_to_ms(metadata.created()), - modified_at_ms: system_time_to_ms(metadata.modified()), - is_dir: file_type.is_dir(), - is_file: file_type.is_file(), - is_symlink: file_type.is_symlink(), + #[cfg(unix)] + use std::os::unix::fs::MetadataExt; + #[cfg(windows)] + use std::os::windows::fs::MetadataExt; + FileInfo { + is_file: metadata.is_file(), + is_directory: metadata.is_dir(), + is_symlink: metadata.file_type().is_symlink(), size: metadata.len(), - permissions: Permissions { - readonly: permissions.readonly(), - #[cfg(unix)] - mode: permissions.mode(), - }, - #[cfg(unix)] - unix: UnixMetadata { - dev: metadata.dev(), - ino: metadata.ino(), - mode: metadata.mode(), - nlink: metadata.nlink(), - uid: metadata.uid(), - gid: metadata.gid(), - rdev: metadata.rdev(), - blksize: metadata.blksize(), - blocks: metadata.blocks(), - }, + // In milliseconds, like JavaScript. Available on both Unix or Windows. + mtime: to_msec(metadata.modified()), + atime: to_msec(metadata.accessed()), + birthtime: to_msec(metadata.created()), + readonly: metadata.permissions().readonly(), + // Following are only valid under Windows. #[cfg(windows)] - file_attributes: metadata.file_attributes(), - }) + file_attribues: Some(metadata.file_attributes()), + #[cfg(not(windows))] + file_attribues: None, + // Following are only valid under Unix. + dev: usm!(dev), + ino: usm!(ino), + mode: usm!(mode), + nlink: usm!(nlink), + uid: usm!(uid), + gid: usm!(gid), + rdev: usm!(rdev), + blksize: usm!(blksize), + blocks: usm!(blocks), + } +} + +#[cfg(test)] +mod test { + use std::io::{BufRead, BufReader}; + + use super::LinesBytes; + + #[test] + fn safe_file_path_parse() { + use super::SafeFilePath; + + assert!(matches!( + serde_json::from_str::("\"C:/Users\""), + Ok(SafeFilePath::Path(_)) + )); + assert!(matches!( + serde_json::from_str::("\"file:///C:/Users\""), + Ok(SafeFilePath::Url(_)) + )); + } + + #[test] + fn test_lines_bytes() { + let base = String::from("line 1\nline2\nline 3\nline 4"); + let bytes = base.as_bytes(); + + let string1 = base.lines().collect::(); + let string2 = BufReader::new(bytes) + .lines() + .map_while(Result::ok) + .collect::(); + let string3 = LinesBytes(BufReader::new(bytes)) + .flatten() + .flat_map(String::from_utf8) + .collect::(); + + assert_eq!(string1, string2); + assert_eq!(string1, string3); + assert_eq!(string2, string3); + } } diff --git a/plugins/fs/src/config.rs b/plugins/fs/src/config.rs index f6c9b235..db3bae45 100644 --- a/plugins/fs/src/config.rs +++ b/plugins/fs/src/config.rs @@ -2,60 +2,18 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use std::path::PathBuf; - use serde::Deserialize; -#[derive(Debug, Deserialize)] +#[derive(Deserialize)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct Config { - pub scope: FsScope, -} - -/// Protocol scope definition. -/// It is a list of glob patterns that restrict the API access from the webview. -/// -/// Each pattern can start with a variable that resolves to a system base directory. -/// The variables are: `$AUDIO`, `$CACHE`, `$CONFIG`, `$DATA`, `$LOCALDATA`, `$DESKTOP`, -/// `$DOCUMENT`, `$DOWNLOAD`, `$EXE`, `$FONT`, `$HOME`, `$PICTURE`, `$PUBLIC`, `$RUNTIME`, -/// `$TEMPLATE`, `$VIDEO`, `$RESOURCE`, `$APP`, `$LOG`, `$TEMP`, `$APPCONFIG`, `$APPDATA`, -/// `$APPLOCALDATA`, `$APPCACHE`, `$APPLOG`. -#[derive(Debug, PartialEq, Eq, Clone, Deserialize)] -#[serde(untagged)] -pub enum FsScope { - /// A list of paths that are allowed by this scope. - AllowedPaths(Vec), - /// A complete scope configuration. - Scope { - /// A list of paths that are allowed by this scope. - #[serde(default)] - allow: Vec, - /// A list of paths that are not allowed by this scope. - /// This gets precedence over the [`Self::Scope::allow`] list. - #[serde(default)] - deny: Vec, - }, -} - -impl Default for FsScope { - fn default() -> Self { - Self::AllowedPaths(Vec::new()) - } -} - -impl FsScope { - /// The list of allowed paths. - pub fn allowed_paths(&self) -> &Vec { - match self { - Self::AllowedPaths(p) => p, - Self::Scope { allow, .. } => allow, - } - } - - /// The list of forbidden paths. - pub fn forbidden_paths(&self) -> Option<&Vec> { - match self { - Self::AllowedPaths(_) => None, - Self::Scope { deny, .. } => Some(deny), - } - } + /// Whether or not paths that contain components that start with a `.` + /// will require that `.` appears literally in the pattern; `*`, `?`, `**`, + /// or `[...]` will not match. This is useful because such files are + /// conventionally considered hidden on Unix systems and it might be + /// desirable to skip them when listing files. + /// + /// Defaults to `true` on Unix systems and `false` on Windows + // dotfiles are not supposed to be exposed by default on unix + pub require_literal_leading_dot: Option, } diff --git a/plugins/fs/src/desktop.rs b/plugins/fs/src/desktop.rs new file mode 100644 index 00000000..477c0537 --- /dev/null +++ b/plugins/fs/src/desktop.rs @@ -0,0 +1,35 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use std::path::PathBuf; + +use tauri::{AppHandle, Runtime}; + +use crate::{FilePath, OpenOptions}; + +pub struct Fs(pub(crate) AppHandle); + +fn path_or_err>(p: P) -> std::io::Result { + match p.into() { + FilePath::Path(p) => Ok(p), + FilePath::Url(u) if u.scheme() == "file" => u + .to_file_path() + .map_err(|_| std::io::Error::new(std::io::ErrorKind::InvalidInput, "invalid file URL")), + FilePath::Url(_) => Err(std::io::Error::new( + std::io::ErrorKind::InvalidInput, + "cannot use a URL to load files on desktop and iOS", + )), + } +} + +impl Fs { + pub fn open>( + &self, + path: P, + opts: OpenOptions, + ) -> std::io::Result { + let path = path_or_err(path)?; + std::fs::OpenOptions::from(opts).open(path) + } +} diff --git a/plugins/fs/src/error.rs b/plugins/fs/src/error.rs index effc017f..0c98e83f 100644 --- a/plugins/fs/src/error.rs +++ b/plugins/fs/src/error.rs @@ -7,13 +7,16 @@ use std::path::PathBuf; use serde::{Serialize, Serializer}; #[derive(Debug, thiserror::Error)] +#[non_exhaustive] pub enum Error { + #[error(transparent)] + Json(#[from] serde_json::Error), + #[error(transparent)] + Tauri(#[from] tauri::Error), #[error(transparent)] Io(#[from] std::io::Error), #[error("forbidden path: {0}")] PathForbidden(PathBuf), - #[error("failed to resolve path: {0}")] - CannotResolvePath(tauri::path::Error), /// Invalid glob pattern. #[error("invalid glob pattern: {0}")] GlobPattern(#[from] glob::PatternError), @@ -21,6 +24,13 @@ pub enum Error { #[cfg(feature = "watch")] #[error(transparent)] Watch(#[from] notify::Error), + #[cfg(target_os = "android")] + #[error(transparent)] + PluginInvoke(#[from] tauri::plugin::mobile::PluginInvokeError), + #[error("URL is not a valid path")] + InvalidPathUrl, + #[error("Unsafe PathBuf: {0}")] + UnsafePathBuf(&'static str), } impl Serialize for Error { diff --git a/plugins/fs/src/file_path.rs b/plugins/fs/src/file_path.rs new file mode 100644 index 00000000..6316a248 --- /dev/null +++ b/plugins/fs/src/file_path.rs @@ -0,0 +1,308 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use std::{ + convert::Infallible, + path::{Path, PathBuf}, + str::FromStr, +}; + +use serde::Serialize; +use tauri::path::SafePathBuf; + +use crate::{Error, Result}; + +/// Represents either a filesystem path or a URI pointing to a file +/// such as `file://` URIs or Android `content://` URIs. +#[derive(Debug, Serialize, Clone)] +#[serde(untagged)] +pub enum FilePath { + /// `file://` URIs or Android `content://` URIs. + Url(url::Url), + /// Regular [`PathBuf`] + Path(PathBuf), +} + +/// Represents either a safe filesystem path or a URI pointing to a file +/// such as `file://` URIs or Android `content://` URIs. +#[derive(Debug, Clone, Serialize)] +pub enum SafeFilePath { + /// `file://` URIs or Android `content://` URIs. + Url(url::Url), + /// Safe [`PathBuf`], see [`SafePathBuf``]. + Path(SafePathBuf), +} + +impl FilePath { + /// Get a reference to the contained [`Path`] if the variant is [`FilePath::Path`]. + /// + /// Use [`FilePath::into_path`] to try to convert the [`FilePath::Url`] variant as well. + #[inline] + pub fn as_path(&self) -> Option<&Path> { + match self { + Self::Url(_) => None, + Self::Path(p) => Some(p), + } + } + + /// Try to convert into [`PathBuf`] if possible. + /// + /// This calls [`Url::to_file_path`](url::Url::to_file_path) if the variant is [`FilePath::Url`], + /// otherwise returns the contained [PathBuf] as is. + #[inline] + pub fn into_path(self) -> Result { + match self { + Self::Url(url) => url.to_file_path().map_err(|_| Error::InvalidPathUrl), + Self::Path(p) => Ok(p), + } + } + + /// Takes the contained [`PathBuf`] if the variant is [`FilePath::Path`], + /// and when possible, converts Windows UNC paths to regular paths. + #[inline] + pub fn simplified(self) -> Self { + match self { + Self::Url(url) => Self::Url(url), + Self::Path(p) => Self::Path(dunce::simplified(&p).to_path_buf()), + } + } +} + +impl SafeFilePath { + /// Get a reference to the contained [`Path`] if the variant is [`SafeFilePath::Path`]. + /// + /// Use [`SafeFilePath::into_path`] to try to convert the [`SafeFilePath::Url`] variant as well. + #[inline] + pub fn as_path(&self) -> Option<&Path> { + match self { + Self::Url(_) => None, + Self::Path(p) => Some(p.as_ref()), + } + } + + /// Try to convert into [`PathBuf`] if possible. + /// + /// This calls [`Url::to_file_path`](url::Url::to_file_path) if the variant is [`SafeFilePath::Url`], + /// otherwise returns the contained [PathBuf] as is. + #[inline] + pub fn into_path(self) -> Result { + match self { + Self::Url(url) => url.to_file_path().map_err(|_| Error::InvalidPathUrl), + Self::Path(p) => Ok(p.as_ref().to_owned()), + } + } + + /// Takes the contained [`PathBuf`] if the variant is [`SafeFilePath::Path`], + /// and when possible, converts Windows UNC paths to regular paths. + #[inline] + pub fn simplified(self) -> Self { + match self { + Self::Url(url) => Self::Url(url), + Self::Path(p) => { + // Safe to unwrap since it was a safe file path already + Self::Path(SafePathBuf::new(dunce::simplified(p.as_ref()).to_path_buf()).unwrap()) + } + } + } +} + +impl std::fmt::Display for FilePath { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::Url(u) => u.fmt(f), + Self::Path(p) => p.display().fmt(f), + } + } +} + +impl std::fmt::Display for SafeFilePath { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::Url(u) => u.fmt(f), + Self::Path(p) => p.display().fmt(f), + } + } +} + +impl<'de> serde::Deserialize<'de> for FilePath { + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + struct FilePathVisitor; + + impl serde::de::Visitor<'_> for FilePathVisitor { + type Value = FilePath; + + fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { + formatter.write_str("a string representing an file URL or a path") + } + + fn visit_str(self, s: &str) -> std::result::Result + where + E: serde::de::Error, + { + FilePath::from_str(s).map_err(|e| { + serde::de::Error::invalid_value( + serde::de::Unexpected::Str(s), + &e.to_string().as_str(), + ) + }) + } + } + + deserializer.deserialize_str(FilePathVisitor) + } +} + +impl<'de> serde::Deserialize<'de> for SafeFilePath { + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + struct SafeFilePathVisitor; + + impl serde::de::Visitor<'_> for SafeFilePathVisitor { + type Value = SafeFilePath; + + fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { + formatter.write_str("a string representing an file URL or a path") + } + + fn visit_str(self, s: &str) -> std::result::Result + where + E: serde::de::Error, + { + SafeFilePath::from_str(s).map_err(|e| { + serde::de::Error::invalid_value( + serde::de::Unexpected::Str(s), + &e.to_string().as_str(), + ) + }) + } + } + + deserializer.deserialize_str(SafeFilePathVisitor) + } +} + +impl FromStr for FilePath { + type Err = Infallible; + fn from_str(s: &str) -> std::result::Result { + if let Ok(url) = url::Url::from_str(s) { + if url.scheme().len() != 1 { + return Ok(Self::Url(url)); + } + } + Ok(Self::Path(PathBuf::from(s))) + } +} + +impl FromStr for SafeFilePath { + type Err = Error; + fn from_str(s: &str) -> Result { + if let Ok(url) = url::Url::from_str(s) { + if url.scheme().len() != 1 { + return Ok(Self::Url(url)); + } + } + + SafePathBuf::new(s.into()) + .map(SafeFilePath::Path) + .map_err(Error::UnsafePathBuf) + } +} + +impl From for FilePath { + fn from(value: PathBuf) -> Self { + Self::Path(value) + } +} + +impl TryFrom for SafeFilePath { + type Error = Error; + fn try_from(value: PathBuf) -> Result { + SafePathBuf::new(value) + .map(SafeFilePath::Path) + .map_err(Error::UnsafePathBuf) + } +} + +impl From<&Path> for FilePath { + fn from(value: &Path) -> Self { + Self::Path(value.to_owned()) + } +} + +impl TryFrom<&Path> for SafeFilePath { + type Error = Error; + fn try_from(value: &Path) -> Result { + SafePathBuf::new(value.to_path_buf()) + .map(SafeFilePath::Path) + .map_err(Error::UnsafePathBuf) + } +} + +impl From<&PathBuf> for FilePath { + fn from(value: &PathBuf) -> Self { + Self::Path(value.to_owned()) + } +} + +impl TryFrom<&PathBuf> for SafeFilePath { + type Error = Error; + fn try_from(value: &PathBuf) -> Result { + SafePathBuf::new(value.to_owned()) + .map(SafeFilePath::Path) + .map_err(Error::UnsafePathBuf) + } +} + +impl From for FilePath { + fn from(value: url::Url) -> Self { + Self::Url(value) + } +} + +impl From for SafeFilePath { + fn from(value: url::Url) -> Self { + Self::Url(value) + } +} + +impl TryFrom for PathBuf { + type Error = Error; + fn try_from(value: FilePath) -> Result { + value.into_path() + } +} + +impl TryFrom for PathBuf { + type Error = Error; + fn try_from(value: SafeFilePath) -> Result { + value.into_path() + } +} + +impl From for FilePath { + fn from(value: SafeFilePath) -> Self { + match value { + SafeFilePath::Url(url) => FilePath::Url(url), + SafeFilePath::Path(p) => FilePath::Path(p.as_ref().to_owned()), + } + } +} + +impl TryFrom for SafeFilePath { + type Error = Error; + + fn try_from(value: FilePath) -> Result { + match value { + FilePath::Url(url) => Ok(SafeFilePath::Url(url)), + FilePath::Path(p) => SafePathBuf::new(p) + .map(SafeFilePath::Path) + .map_err(Error::UnsafePathBuf), + } + } +} diff --git a/plugins/fs/src/lib.rs b/plugins/fs/src/lib.rs index d2004168..bdc6b170 100644 --- a/plugins/fs/src/lib.rs +++ b/plugins/fs/src/lib.rs @@ -2,8 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -//! [![](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/fs/banner.png)](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/fs) -//! //! Access the file system. #![doc( @@ -11,79 +9,441 @@ html_favicon_url = "https://github.com/tauri-apps/tauri/raw/dev/app-icon.png" )] -use config::FsScope; +use std::io::Read; + +use serde::Deserialize; use tauri::{ + ipc::ScopeObject, plugin::{Builder as PluginBuilder, TauriPlugin}, - FileDropEvent, Manager, RunEvent, Runtime, WindowEvent, + utils::{acl::Value, config::FsScope}, + AppHandle, DragDropEvent, Manager, RunEvent, Runtime, WindowEvent, }; mod commands; mod config; +#[cfg(not(target_os = "android"))] +mod desktop; mod error; +mod file_path; +#[cfg(target_os = "android")] +mod mobile; +#[cfg(target_os = "android")] +mod models; mod scope; #[cfg(feature = "watch")] mod watcher; -pub use config::Config; +#[cfg(not(target_os = "android"))] +pub use desktop::Fs; +#[cfg(target_os = "android")] +pub use mobile::Fs; + pub use error::Error; -pub use scope::{Event as ScopeEvent, Scope}; + +pub use file_path::FilePath; +pub use file_path::SafeFilePath; type Result = std::result::Result; +#[derive(Debug, Default, Clone, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct OpenOptions { + #[serde(default = "default_true")] + read: bool, + #[serde(default)] + write: bool, + #[serde(default)] + append: bool, + #[serde(default)] + truncate: bool, + #[serde(default)] + create: bool, + #[serde(default)] + create_new: bool, + #[serde(default)] + #[allow(unused)] + mode: Option, + #[serde(default)] + #[allow(unused)] + custom_flags: Option, +} + +fn default_true() -> bool { + true +} + +impl From for std::fs::OpenOptions { + fn from(open_options: OpenOptions) -> Self { + let mut opts = std::fs::OpenOptions::new(); + + #[cfg(unix)] + { + use std::os::unix::fs::OpenOptionsExt; + if let Some(mode) = open_options.mode { + opts.mode(mode); + } + if let Some(flags) = open_options.custom_flags { + opts.custom_flags(flags); + } + } + + opts.read(open_options.read) + .write(open_options.write) + .create(open_options.create) + .append(open_options.append) + .truncate(open_options.truncate) + .create_new(open_options.create_new); + + opts + } +} + +impl OpenOptions { + /// Creates a blank new set of options ready for configuration. + /// + /// All options are initially set to `false`. + /// + /// # Examples + /// + /// ```no_run + /// use tauri_plugin_fs::OpenOptions; + /// + /// let mut options = OpenOptions::new(); + /// let file = options.read(true).open("foo.txt"); + /// ``` + #[must_use] + pub fn new() -> Self { + Self::default() + } + + /// Sets the option for read access. + /// + /// This option, when true, will indicate that the file should be + /// `read`-able if opened. + /// + /// # Examples + /// + /// ```no_run + /// use tauri_plugin_fs::OpenOptions; + /// + /// let file = OpenOptions::new().read(true).open("foo.txt"); + /// ``` + pub fn read(&mut self, read: bool) -> &mut Self { + self.read = read; + self + } + + /// Sets the option for write access. + /// + /// This option, when true, will indicate that the file should be + /// `write`-able if opened. + /// + /// If the file already exists, any write calls on it will overwrite its + /// contents, without truncating it. + /// + /// # Examples + /// + /// ```no_run + /// use tauri_plugin_fs::OpenOptions; + /// + /// let file = OpenOptions::new().write(true).open("foo.txt"); + /// ``` + pub fn write(&mut self, write: bool) -> &mut Self { + self.write = write; + self + } + + /// Sets the option for the append mode. + /// + /// This option, when true, means that writes will append to a file instead + /// of overwriting previous contents. + /// Note that setting `.write(true).append(true)` has the same effect as + /// setting only `.append(true)`. + /// + /// Append mode guarantees that writes will be positioned at the current end of file, + /// even when there are other processes or threads appending to the same file. This is + /// unlike [seek]\([SeekFrom]::[End]\(0)) followed by `write()`, which + /// has a race between seeking and writing during which another writer can write, with + /// our `write()` overwriting their data. + /// + /// Keep in mind that this does not necessarily guarantee that data appended by + /// different processes or threads does not interleave. The amount of data accepted a + /// single `write()` call depends on the operating system and file system. A + /// successful `write()` is allowed to write only part of the given data, so even if + /// you're careful to provide the whole message in a single call to `write()`, there + /// is no guarantee that it will be written out in full. If you rely on the filesystem + /// accepting the message in a single write, make sure that all data that belongs + /// together is written in one operation. This can be done by concatenating strings + /// before passing them to [`write()`]. + /// + /// If a file is opened with both read and append access, beware that after + /// opening, and after every write, the position for reading may be set at the + /// end of the file. So, before writing, save the current position (using + /// [Seek]::[stream_position]), and restore it before the next read. + /// + /// ## Note + /// + /// This function doesn't create the file if it doesn't exist. Use the + /// [`OpenOptions::create`] method to do so. + /// + /// [`write()`]: Write::write "io::Write::write" + /// [`flush()`]: Write::flush "io::Write::flush" + /// [stream_position]: Seek::stream_position "io::Seek::stream_position" + /// [seek]: Seek::seek "io::Seek::seek" + /// [Current]: SeekFrom::Current "io::SeekFrom::Current" + /// [End]: SeekFrom::End "io::SeekFrom::End" + /// + /// # Examples + /// + /// ```no_run + /// use tauri_plugin_fs::OpenOptions; + /// + /// let file = OpenOptions::new().append(true).open("foo.txt"); + /// ``` + pub fn append(&mut self, append: bool) -> &mut Self { + self.append = append; + self + } + + /// Sets the option for truncating a previous file. + /// + /// If a file is successfully opened with this option set it will truncate + /// the file to 0 length if it already exists. + /// + /// The file must be opened with write access for truncate to work. + /// + /// # Examples + /// + /// ```no_run + /// use tauri_plugin_fs::OpenOptions; + /// + /// let file = OpenOptions::new().write(true).truncate(true).open("foo.txt"); + /// ``` + pub fn truncate(&mut self, truncate: bool) -> &mut Self { + self.truncate = truncate; + self + } + + /// Sets the option to create a new file, or open it if it already exists. + /// + /// In order for the file to be created, [`OpenOptions::write`] or + /// [`OpenOptions::append`] access must be used. + /// + /// + /// # Examples + /// + /// ```no_run + /// use tauri_plugin_fs::OpenOptions; + /// + /// let file = OpenOptions::new().write(true).create(true).open("foo.txt"); + /// ``` + pub fn create(&mut self, create: bool) -> &mut Self { + self.create = create; + self + } + + /// Sets the option to create a new file, failing if it already exists. + /// + /// No file is allowed to exist at the target location, also no (dangling) symlink. In this + /// way, if the call succeeds, the file returned is guaranteed to be new. + /// If a file exists at the target location, creating a new file will fail with [`AlreadyExists`] + /// or another error based on the situation. See [`OpenOptions::open`] for a + /// non-exhaustive list of likely errors. + /// + /// This option is useful because it is atomic. Otherwise between checking + /// whether a file exists and creating a new one, the file may have been + /// created by another process (a TOCTOU race condition / attack). + /// + /// If `.create_new(true)` is set, [`.create()`] and [`.truncate()`] are + /// ignored. + /// + /// The file must be opened with write or append access in order to create + /// a new file. + /// + /// [`.create()`]: OpenOptions::create + /// [`.truncate()`]: OpenOptions::truncate + /// [`AlreadyExists`]: io::ErrorKind::AlreadyExists + /// + /// # Examples + /// + /// ```no_run + /// use tauri_plugin_fs::OpenOptions; + /// + /// let file = OpenOptions::new().write(true) + /// .create_new(true) + /// .open("foo.txt"); + /// ``` + pub fn create_new(&mut self, create_new: bool) -> &mut Self { + self.create_new = create_new; + self + } +} + +#[cfg(unix)] +impl std::os::unix::fs::OpenOptionsExt for OpenOptions { + fn custom_flags(&mut self, flags: i32) -> &mut Self { + self.custom_flags.replace(flags); + self + } + + fn mode(&mut self, mode: u32) -> &mut Self { + self.mode.replace(mode); + self + } +} + +impl OpenOptions { + #[cfg(target_os = "android")] + fn android_mode(&self) -> String { + let mut mode = String::new(); + + if self.read { + mode.push('r'); + } + if self.write { + mode.push('w'); + } + if self.truncate { + mode.push('t'); + } + if self.append { + mode.push('a'); + } + + mode + } +} + +impl Fs { + pub fn read_to_string>(&self, path: P) -> std::io::Result { + let mut s = String::new(); + self.open( + path, + OpenOptions { + read: true, + ..Default::default() + }, + )? + .read_to_string(&mut s)?; + Ok(s) + } + + pub fn read>(&self, path: P) -> std::io::Result> { + let mut buf = Vec::new(); + self.open( + path, + OpenOptions { + read: true, + ..Default::default() + }, + )? + .read_to_end(&mut buf)?; + Ok(buf) + } +} + +// implement ScopeObject here instead of in the scope module because it is also used on the build script +// and we don't want to add tauri as a build dependency +impl ScopeObject for scope::Entry { + type Error = Error; + fn deserialize( + app: &AppHandle, + raw: Value, + ) -> std::result::Result { + let path = serde_json::from_value(raw.into()).map(|raw| match raw { + scope::EntryRaw::Value(path) => path, + scope::EntryRaw::Object { path } => path, + })?; + + match app.path().parse(path) { + Ok(path) => Ok(Self { path: Some(path) }), + #[cfg(not(target_os = "android"))] + Err(tauri::Error::UnknownPath) => Ok(Self { path: None }), + Err(err) => Err(err.into()), + } + } +} + +pub(crate) struct Scope { + pub(crate) scope: tauri::fs::Scope, + pub(crate) require_literal_leading_dot: Option, +} + pub trait FsExt { - fn fs_scope(&self) -> &Scope; - fn try_fs_scope(&self) -> Option<&Scope>; + fn fs_scope(&self) -> tauri::fs::Scope; + fn try_fs_scope(&self) -> Option; + + /// Cross platform file system APIs that also support manipulating Android files. + fn fs(&self) -> &Fs; } impl> FsExt for T { - fn fs_scope(&self) -> &Scope { - self.state::().inner() + fn fs_scope(&self) -> tauri::fs::Scope { + self.state::().scope.clone() + } + + fn try_fs_scope(&self) -> Option { + self.try_state::().map(|s| s.scope.clone()) } - fn try_fs_scope(&self) -> Option<&Scope> { - self.try_state::().map(|s| s.inner()) + fn fs(&self) -> &Fs { + self.state::>().inner() } } -pub fn init() -> TauriPlugin> { - PluginBuilder::>::new("fs") - .js_init_script(include_str!("api-iife.js").to_string()) +pub fn init() -> TauriPlugin> { + PluginBuilder::>::new("fs") .invoke_handler(tauri::generate_handler![ + commands::create, + commands::open, + commands::copy_file, + commands::mkdir, + commands::read_dir, + commands::read, commands::read_file, commands::read_text_file, + commands::read_text_file_lines, + commands::read_text_file_lines_next, + commands::remove, + commands::rename, + commands::seek, + commands::stat, + commands::lstat, + commands::fstat, + commands::truncate, + commands::ftruncate, + commands::write, commands::write_file, - commands::read_dir, - commands::copy_file, - commands::create_dir, - commands::remove_dir, - commands::remove_file, - commands::rename_file, + commands::write_text_file, commands::exists, - commands::metadata, + commands::size, #[cfg(feature = "watch")] watcher::watch, - #[cfg(feature = "watch")] - watcher::unwatch ]) - .setup(|app: &tauri::AppHandle, api| { - let default_scope = FsScope::default(); - app.manage(Scope::new( - app, - api.config() + .setup(|app, api| { + let scope = Scope { + require_literal_leading_dot: api + .config() .as_ref() - .map(|c| &c.scope) - .unwrap_or(&default_scope), - )?); + .and_then(|c| c.require_literal_leading_dot), + scope: tauri::fs::Scope::new(app, &FsScope::default())?, + }; - #[cfg(feature = "watch")] - app.manage(watcher::WatcherCollection::default()); + #[cfg(target_os = "android")] + { + let fs = mobile::init(app, api)?; + app.manage(fs); + } + #[cfg(not(target_os = "android"))] + app.manage(Fs(app.clone())); + app.manage(scope); Ok(()) }) .on_event(|app, event| { if let RunEvent::WindowEvent { label: _, - event: WindowEvent::FileDrop(FileDropEvent::Dropped { paths, position: _ }), + event: WindowEvent::DragDrop(DragDropEvent::Drop { paths, position: _ }), .. } = event { @@ -92,7 +452,7 @@ pub fn init() -> TauriPlugin> { if path.is_file() { let _ = scope.allow_file(path); } else { - let _ = scope.allow_directory(path, false); + let _ = scope.allow_directory(path, true); } } } diff --git a/plugins/fs/src/mobile.rs b/plugins/fs/src/mobile.rs new file mode 100644 index 00000000..06422be6 --- /dev/null +++ b/plugins/fs/src/mobile.rs @@ -0,0 +1,96 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use serde::de::DeserializeOwned; +use tauri::{ + plugin::{PluginApi, PluginHandle}, + AppHandle, Runtime, +}; + +use crate::{models::*, FilePath, OpenOptions}; + +#[cfg(target_os = "android")] +const PLUGIN_IDENTIFIER: &str = "com.plugin.fs"; + +#[cfg(target_os = "ios")] +tauri::ios_plugin_binding!(init_plugin_fs); + +// initializes the Kotlin or Swift plugin classes +pub fn init( + _app: &AppHandle, + api: PluginApi, +) -> crate::Result> { + #[cfg(target_os = "android")] + let handle = api + .register_android_plugin(PLUGIN_IDENTIFIER, "FsPlugin") + .unwrap(); + #[cfg(target_os = "ios")] + let handle = api.register_ios_plugin(init_plugin_android - intent - send)?; + Ok(Fs(handle)) +} + +/// Access to the android-intent-send APIs. +pub struct Fs(PluginHandle); + +impl Fs { + pub fn open>( + &self, + path: P, + opts: OpenOptions, + ) -> std::io::Result { + match path.into() { + FilePath::Url(u) => self + .resolve_content_uri(u.to_string(), opts.android_mode()) + .map_err(|e| { + std::io::Error::new( + std::io::ErrorKind::Other, + format!("failed to open file: {e}"), + ) + }), + FilePath::Path(p) => { + // tauri::utils::platform::resources_dir() returns a PathBuf with the Android asset URI prefix + // we must resolve that file with the Android API + if p.strip_prefix(tauri::utils::platform::ANDROID_ASSET_PROTOCOL_URI_PREFIX) + .is_ok() + { + self.resolve_content_uri(p.to_string_lossy(), opts.android_mode()) + .map_err(|e| { + std::io::Error::new( + std::io::ErrorKind::Other, + format!("failed to open file: {e}"), + ) + }) + } else { + std::fs::OpenOptions::from(opts).open(p) + } + } + } + } + + #[cfg(target_os = "android")] + fn resolve_content_uri( + &self, + uri: impl Into, + mode: impl Into, + ) -> crate::Result { + #[cfg(target_os = "android")] + { + let result = self.0.run_mobile_plugin::( + "getFileDescriptor", + GetFileDescriptorPayload { + uri: uri.into(), + mode: mode.into(), + }, + )?; + if let Some(fd) = result.fd { + Ok(unsafe { + use std::os::fd::FromRawFd; + std::fs::File::from_raw_fd(fd) + }) + } else { + todo!() + } + } + } +} diff --git a/plugins/fs/src/models.rs b/plugins/fs/src/models.rs new file mode 100644 index 00000000..b9edc2cb --- /dev/null +++ b/plugins/fs/src/models.rs @@ -0,0 +1,18 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Default, Deserialize, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct GetFileDescriptorPayload { + pub uri: String, + pub mode: String, +} + +#[derive(Debug, Clone, Default, Deserialize, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct GetFileDescriptorResponse { + pub fd: Option, +} diff --git a/plugins/fs/src/scope.rs b/plugins/fs/src/scope.rs index 609506fc..7914706a 100644 --- a/plugins/fs/src/scope.rs +++ b/plugins/fs/src/scope.rs @@ -2,367 +2,18 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use std::{ - collections::{HashMap, HashSet}, - fmt, - path::{Path, PathBuf, MAIN_SEPARATOR}, - sync::{Arc, Mutex}, -}; +use std::path::PathBuf; -use crate::config::FsScope; -pub use glob::Pattern; -use uuid::Uuid; +use serde::Deserialize; -use crate::{Manager, Runtime}; - -/// Scope change event. -#[derive(Debug, Clone)] -pub enum Event { - /// A path has been allowed. - PathAllowed(PathBuf), - /// A path has been forbidden. - PathForbidden(PathBuf), -} - -type EventListener = Box; - -/// Scope for filesystem access. -#[derive(Clone)] -pub struct Scope { - allowed_patterns: Arc>>, - forbidden_patterns: Arc>>, - event_listeners: Arc>>, -} - -impl fmt::Debug for Scope { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("Scope") - .field( - "allowed_patterns", - &self - .allowed_patterns - .lock() - .unwrap() - .iter() - .map(|p| p.as_str()) - .collect::>(), - ) - .field( - "forbidden_patterns", - &self - .forbidden_patterns - .lock() - .unwrap() - .iter() - .map(|p| p.as_str()) - .collect::>(), - ) - .finish() - } -} - -fn push_pattern, F: Fn(&str) -> Result>( - list: &mut HashSet, - pattern: P, - f: F, -) -> crate::Result<()> { - let path: PathBuf = pattern.as_ref().components().collect(); - list.insert(f(&path.to_string_lossy())?); - #[cfg(windows)] - { - if let Ok(p) = std::fs::canonicalize(&path) { - list.insert(f(&p.to_string_lossy())?); - } else { - list.insert(f(&format!("\\\\?\\{}", path.display()))?); - } - } - Ok(()) -} - -impl Scope { - /// Creates a new scope from a `FsScope` configuration. - pub(crate) fn new>( - manager: &M, - scope: &FsScope, - ) -> crate::Result { - let mut allowed_patterns = HashSet::new(); - for path in scope.allowed_paths() { - if let Ok(path) = manager.path().parse(path) { - push_pattern(&mut allowed_patterns, path, Pattern::new)?; - } - } - - let mut forbidden_patterns = HashSet::new(); - if let Some(forbidden_paths) = scope.forbidden_paths() { - for path in forbidden_paths { - if let Ok(path) = manager.path().parse(path) { - push_pattern(&mut forbidden_patterns, path, Pattern::new)?; - } - } - } - - Ok(Self { - allowed_patterns: Arc::new(Mutex::new(allowed_patterns)), - forbidden_patterns: Arc::new(Mutex::new(forbidden_patterns)), - event_listeners: Default::default(), - }) - } - - /// The list of allowed patterns. - pub fn allowed_patterns(&self) -> HashSet { - self.allowed_patterns.lock().unwrap().clone() - } - - /// The list of forbidden patterns. - pub fn forbidden_patterns(&self) -> HashSet { - self.forbidden_patterns.lock().unwrap().clone() - } - - /// Listen to an event on this scope. - pub fn listen(&self, f: F) -> Uuid { - let id = Uuid::new_v4(); - self.event_listeners.lock().unwrap().insert(id, Box::new(f)); - id - } - - fn trigger(&self, event: Event) { - let listeners = self.event_listeners.lock().unwrap(); - let handlers = listeners.values(); - for listener in handlers { - listener(&event); - } - } - - /// Extend the allowed patterns with the given directory. - /// - /// After this function has been called, the frontend will be able to use the Tauri API to read - /// the directory and all of its files. If `recursive` is `true`, subdirectories will be accessible too. - pub fn allow_directory>(&self, path: P, recursive: bool) -> crate::Result<()> { - let path = path.as_ref(); - { - let mut list = self.allowed_patterns.lock().unwrap(); - - // allow the directory to be read - push_pattern(&mut list, path, escaped_pattern)?; - // allow its files and subdirectories to be read - push_pattern(&mut list, path, |p| { - escaped_pattern_with(p, if recursive { "**" } else { "*" }) - })?; - } - self.trigger(Event::PathAllowed(path.to_path_buf())); - Ok(()) - } - - /// Extend the allowed patterns with the given file path. - /// - /// After this function has been called, the frontend will be able to use the Tauri API to read the contents of this file. - pub fn allow_file>(&self, path: P) -> crate::Result<()> { - let path = path.as_ref(); - push_pattern( - &mut self.allowed_patterns.lock().unwrap(), - path, - escaped_pattern, - )?; - self.trigger(Event::PathAllowed(path.to_path_buf())); - Ok(()) - } - - /// Set the given directory path to be forbidden by this scope. - /// - /// **Note:** this takes precedence over allowed paths, so its access gets denied **always**. - pub fn forbid_directory>(&self, path: P, recursive: bool) -> crate::Result<()> { - let path = path.as_ref(); - { - let mut list = self.forbidden_patterns.lock().unwrap(); - - // allow the directory to be read - push_pattern(&mut list, path, escaped_pattern)?; - // allow its files and subdirectories to be read - push_pattern(&mut list, path, |p| { - escaped_pattern_with(p, if recursive { "**" } else { "*" }) - })?; - } - self.trigger(Event::PathForbidden(path.to_path_buf())); - Ok(()) - } - - /// Set the given file path to be forbidden by this scope. - /// - /// **Note:** this takes precedence over allowed paths, so its access gets denied **always**. - pub fn forbid_file>(&self, path: P) -> crate::Result<()> { - let path = path.as_ref(); - push_pattern( - &mut self.forbidden_patterns.lock().unwrap(), - path, - escaped_pattern, - )?; - self.trigger(Event::PathForbidden(path.to_path_buf())); - Ok(()) - } - - /// Determines if the given path is allowed on this scope. - pub fn is_allowed>(&self, path: P) -> bool { - let path = path.as_ref(); - let path = if !path.exists() { - crate::Result::Ok(path.to_path_buf()) - } else { - std::fs::canonicalize(path).map_err(Into::into) - }; - - if let Ok(path) = path { - let path: PathBuf = path.components().collect(); - let options = glob::MatchOptions { - // this is needed so `/dir/*` doesn't match files within subdirectories such as `/dir/subdir/file.txt` - // see: https://github.com/tauri-apps/tauri/security/advisories/GHSA-6mv3-wm7j-h4w5 - require_literal_separator: true, - // dotfiles are not supposed to be exposed by default - #[cfg(unix)] - require_literal_leading_dot: true, - ..Default::default() - }; - - let forbidden = self - .forbidden_patterns - .lock() - .unwrap() - .iter() - .any(|p| p.matches_path_with(&path, options)); - - if forbidden { - false - } else { - let allowed = self - .allowed_patterns - .lock() - .unwrap() - .iter() - .any(|p| p.matches_path_with(&path, options)); - allowed - } - } else { - false - } - } -} - -fn escaped_pattern(p: &str) -> Result { - Pattern::new(&glob::Pattern::escape(p)) -} - -fn escaped_pattern_with(p: &str, append: &str) -> Result { - Pattern::new(&format!( - "{}{}{append}", - glob::Pattern::escape(p), - MAIN_SEPARATOR - )) +#[derive(Debug)] +pub struct Entry { + pub path: Option, } -#[cfg(test)] -mod tests { - use super::Scope; - - fn new_scope() -> Scope { - Scope { - allowed_patterns: Default::default(), - forbidden_patterns: Default::default(), - event_listeners: Default::default(), - } - } - - #[test] - fn path_is_escaped() { - let scope = new_scope(); - #[cfg(unix)] - { - scope.allow_directory("/home/tauri/**", false).unwrap(); - assert!(scope.is_allowed("/home/tauri/**")); - assert!(scope.is_allowed("/home/tauri/**/file")); - assert!(!scope.is_allowed("/home/tauri/anyfile")); - } - #[cfg(windows)] - { - scope.allow_directory("C:\\home\\tauri\\**", false).unwrap(); - assert!(scope.is_allowed("C:\\home\\tauri\\**")); - assert!(scope.is_allowed("C:\\home\\tauri\\**\\file")); - assert!(!scope.is_allowed("C:\\home\\tauri\\anyfile")); - } - - let scope = new_scope(); - #[cfg(unix)] - { - scope.allow_file("/home/tauri/**").unwrap(); - assert!(scope.is_allowed("/home/tauri/**")); - assert!(!scope.is_allowed("/home/tauri/**/file")); - assert!(!scope.is_allowed("/home/tauri/anyfile")); - } - #[cfg(windows)] - { - scope.allow_file("C:\\home\\tauri\\**").unwrap(); - assert!(scope.is_allowed("C:\\home\\tauri\\**")); - assert!(!scope.is_allowed("C:\\home\\tauri\\**\\file")); - assert!(!scope.is_allowed("C:\\home\\tauri\\anyfile")); - } - - let scope = new_scope(); - #[cfg(unix)] - { - scope.allow_directory("/home/tauri", true).unwrap(); - scope.forbid_directory("/home/tauri/**", false).unwrap(); - assert!(!scope.is_allowed("/home/tauri/**")); - assert!(!scope.is_allowed("/home/tauri/**/file")); - assert!(scope.is_allowed("/home/tauri/**/inner/file")); - assert!(scope.is_allowed("/home/tauri/inner/folder/anyfile")); - assert!(scope.is_allowed("/home/tauri/anyfile")); - } - #[cfg(windows)] - { - scope.allow_directory("C:\\home\\tauri", true).unwrap(); - scope - .forbid_directory("C:\\home\\tauri\\**", false) - .unwrap(); - assert!(!scope.is_allowed("C:\\home\\tauri\\**")); - assert!(!scope.is_allowed("C:\\home\\tauri\\**\\file")); - assert!(scope.is_allowed("C:\\home\\tauri\\**\\inner\\file")); - assert!(scope.is_allowed("C:\\home\\tauri\\inner\\folder\\anyfile")); - assert!(scope.is_allowed("C:\\home\\tauri\\anyfile")); - } - - let scope = new_scope(); - #[cfg(unix)] - { - scope.allow_directory("/home/tauri", true).unwrap(); - scope.forbid_file("/home/tauri/**").unwrap(); - assert!(!scope.is_allowed("/home/tauri/**")); - assert!(scope.is_allowed("/home/tauri/**/file")); - assert!(scope.is_allowed("/home/tauri/**/inner/file")); - assert!(scope.is_allowed("/home/tauri/anyfile")); - } - #[cfg(windows)] - { - scope.allow_directory("C:\\home\\tauri", true).unwrap(); - scope.forbid_file("C:\\home\\tauri\\**").unwrap(); - assert!(!scope.is_allowed("C:\\home\\tauri\\**")); - assert!(scope.is_allowed("C:\\home\\tauri\\**\\file")); - assert!(scope.is_allowed("C:\\home\\tauri\\**\\inner\\file")); - assert!(scope.is_allowed("C:\\home\\tauri\\anyfile")); - } - - let scope = new_scope(); - #[cfg(unix)] - { - scope.allow_directory("/home/tauri", false).unwrap(); - assert!(scope.is_allowed("/home/tauri/**")); - assert!(!scope.is_allowed("/home/tauri/**/file")); - assert!(!scope.is_allowed("/home/tauri/**/inner/file")); - assert!(scope.is_allowed("/home/tauri/anyfile")); - } - #[cfg(windows)] - { - scope.allow_directory("C:\\home\\tauri", false).unwrap(); - assert!(scope.is_allowed("C:\\home\\tauri\\**")); - assert!(!scope.is_allowed("C:\\home\\tauri\\**\\file")); - assert!(!scope.is_allowed("C:\\home\\tauri\\**\\inner\\file")); - assert!(scope.is_allowed("C:\\home\\tauri\\anyfile")); - } - } +#[derive(Deserialize)] +#[serde(untagged)] +pub(crate) enum EntryRaw { + Value(PathBuf), + Object { path: PathBuf }, } diff --git a/plugins/fs/src/watcher.rs b/plugins/fs/src/watcher.rs index 8c2a36fb..89446b88 100644 --- a/plugins/fs/src/watcher.rs +++ b/plugins/fs/src/watcher.rs @@ -2,116 +2,102 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use notify::{Config, Event, RecommendedWatcher, RecursiveMode, Watcher}; -use notify_debouncer_mini::{new_debouncer, DebounceEventResult, Debouncer}; +use notify::{Config, RecommendedWatcher, RecursiveMode, Watcher}; +use notify_debouncer_full::{new_debouncer, DebouncedEvent, Debouncer, RecommendedCache}; use serde::Deserialize; -use tauri::{command, ipc::Channel, State}; - -use crate::Result; - -use std::{ - collections::HashMap, - path::PathBuf, - sync::{ - mpsc::{channel, Receiver}, - Mutex, - }, - thread::spawn, - time::Duration, +use tauri::{ + ipc::{Channel, CommandScope, GlobalScope}, + path::BaseDirectory, + Manager, Resource, ResourceId, Runtime, Webview, }; -type Id = u32; +use std::time::Duration; -#[derive(Default)] -pub struct WatcherCollection(Mutex)>>); +use crate::{ + commands::{resolve_path, CommandResult}, + scope::Entry, + SafeFilePath, +}; +#[allow(unused)] enum WatcherKind { - Debouncer(Debouncer), + Debouncer(Debouncer), Watcher(RecommendedWatcher), } -fn watch_raw(on_event: Channel, rx: Receiver>) { - spawn(move || { - while let Ok(event) = rx.recv() { - if let Ok(event) = event { - // TODO: Should errors be emitted too? - let _ = on_event.send(&event); - } - } - }); -} +impl Resource for WatcherKind {} -fn watch_debounced(on_event: Channel, rx: Receiver) { - spawn(move || { - while let Ok(event) = rx.recv() { - if let Ok(event) = event { - // TODO: Should errors be emitted too? - let _ = on_event.send(&event); - } - } - }); -} - -#[derive(Deserialize)] +#[derive(Clone, Deserialize)] #[serde(rename_all = "camelCase")] pub struct WatchOptions { - delay_ms: Option, + base_dir: Option, + #[serde(default)] recursive: bool, + delay_ms: Option, } -#[command] -pub async fn watch( - watchers: State<'_, WatcherCollection>, - id: Id, - paths: Vec, +#[tauri::command] +pub fn watch( + webview: Webview, + paths: Vec, options: WatchOptions, - on_event: Channel, -) -> Result<()> { - let mode = if options.recursive { + on_event: Channel, + global_scope: GlobalScope, + command_scope: CommandScope, +) -> CommandResult { + let resolved_paths = paths + .into_iter() + .map(|path| { + resolve_path( + &webview, + &global_scope, + &command_scope, + path, + options.base_dir, + ) + }) + .collect::>>()?; + + let recursive_mode = if options.recursive { RecursiveMode::Recursive } else { RecursiveMode::NonRecursive }; - let watcher = if let Some(delay) = options.delay_ms { - let (tx, rx) = channel(); - let mut debouncer = new_debouncer(Duration::from_millis(delay), None, tx)?; - let watcher = debouncer.watcher(); - for path in &paths { - watcher.watch(path, mode)?; + let watcher_kind = if let Some(delay) = options.delay_ms { + let mut debouncer = new_debouncer( + Duration::from_millis(delay), + None, + move |events: Result, Vec>| { + if let Ok(events) = events { + for event in events { + // TODO: Should errors be emitted too? + let _ = on_event.send(event.event); + } + } + }, + )?; + for path in &resolved_paths { + debouncer.watch(path, recursive_mode)?; } - watch_debounced(on_event, rx); WatcherKind::Debouncer(debouncer) } else { - let (tx, rx) = channel(); - let mut watcher = RecommendedWatcher::new(tx, Config::default())?; - for path in &paths { - watcher.watch(path, mode)?; + let mut watcher = RecommendedWatcher::new( + move |event| { + if let Ok(event) = event { + // TODO: Should errors be emitted too? + let _ = on_event.send(event); + } + }, + Config::default(), + )?; + for path in &resolved_paths { + watcher.watch(path, recursive_mode)?; } - watch_raw(on_event, rx); WatcherKind::Watcher(watcher) }; - watchers.0.lock().unwrap().insert(id, (watcher, paths)); + let rid = webview.resources_table().add(watcher_kind); - Ok(()) -} - -#[command] -pub async fn unwatch(watchers: State<'_, WatcherCollection>, id: Id) -> Result<()> { - if let Some((watcher, paths)) = watchers.0.lock().unwrap().remove(&id) { - match watcher { - WatcherKind::Debouncer(mut debouncer) => { - for path in paths { - debouncer.watcher().unwatch(&path)? - } - } - WatcherKind::Watcher(mut watcher) => { - for path in paths { - watcher.unwatch(&path)? - } - } - }; - } - Ok(()) + Ok(rid) } diff --git a/plugins/geolocation/CHANGELOG.md b/plugins/geolocation/CHANGELOG.md new file mode 100644 index 00000000..dbee2e7d --- /dev/null +++ b/plugins/geolocation/CHANGELOG.md @@ -0,0 +1,57 @@ +# Changelog + +## \[2.2.4] + +- [`a1b3fa27`](https://github.com/tauri-apps/plugins-workspace/commit/a1b3fa27f11022c9b6622b4fab12d93239eb05de) ([#2515](https://github.com/tauri-apps/plugins-workspace/pull/2515) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Re-exported the `Geolocation`, `Haptics`, `Notification`, and `Os` structs so that they show up on docs.rs. + +## \[2.2.3] + +- [`406e6f48`](https://github.com/tauri-apps/plugins-workspace/commit/406e6f484cdc13d35c50fb949f7489ca9eeccc44) ([#2323](https://github.com/tauri-apps/plugins-workspace/pull/2323) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Fixed an issue that caused build failures when the `haptics` or `geolocation` plugin was used without their `specta` feature flag enabled. + +## \[2.2.2] + +- [`c9c13a0f`](https://github.com/tauri-apps/plugins-workspace/commit/c9c13a0fe7cdaac223843f5ba33176252f8e22f5) ([#2316](https://github.com/tauri-apps/plugins-workspace/pull/2316) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) **Breaking change:** `specta` integration is now behind a `specta` feature flag like in Tauri. +- [`c9c13a0f`](https://github.com/tauri-apps/plugins-workspace/commit/c9c13a0fe7cdaac223843f5ba33176252f8e22f5) ([#2316](https://github.com/tauri-apps/plugins-workspace/pull/2316) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Unlock and widen `specta` version range to match Tauri. No API changes. + +## \[2.2.1] + +- [`fb67ab2b`](https://github.com/tauri-apps/plugins-workspace/commit/fb67ab2b926502bfc20d6b43fbdd156691ea8526) ([#2281](https://github.com/tauri-apps/plugins-workspace/pull/2281) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Added `specta-util` to fix a "dependency not found" compilation error. + +## \[2.2.0] + +- [`3a79266b`](https://github.com/tauri-apps/plugins-workspace/commit/3a79266b8cf96a55b1ae6339d725567d45a44b1d) ([#2173](https://github.com/tauri-apps/plugins-workspace/pull/2173) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Bumped all plugins to `v2.2.0`. From now, the versions for the Rust and JavaScript packages of each plugin will be in sync with each other. + +## \[2.0.1] + +- [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. + +## \[2.0.0] + +- [`e2c4dfb6`](https://github.com/tauri-apps/plugins-workspace/commit/e2c4dfb6af43e5dd8d9ceba232c315f5febd55c1) Update to tauri v2 stable release. + +## \[2.0.0-rc.2] + +- [`60765694`](https://github.com/tauri-apps/plugins-workspace/commit/60765694f54875e22b8eb70b1d2e32dbf0c585c7) ([#1773](https://github.com/tauri-apps/plugins-workspace/pull/1773) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update API to match other plugins. + +## \[2.0.0-rc.1] + +- [`e2e97db5`](https://github.com/tauri-apps/plugins-workspace/commit/e2e97db51983267f5be84d4f6f0278d58834d1f5) ([#1701](https://github.com/tauri-apps/plugins-workspace/pull/1701) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Use `PermissionState` from the `tauri` crate, which now also includes a "prompt with rationale" variant for Android (returned when your app must explain to the user why it needs the permission). +- [`e2e97db5`](https://github.com/tauri-apps/plugins-workspace/commit/e2e97db51983267f5be84d4f6f0278d58834d1f5) ([#1701](https://github.com/tauri-apps/plugins-workspace/pull/1701) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri 2.0.0-rc.8 + +## \[2.0.0-rc.2] + +- [`b9147758`](https://github.com/tauri-apps/plugins-workspace/commit/b914775898c2bee7ceb20bd17ee595005cd17a64) ([#1679](https://github.com/tauri-apps/plugins-workspace/pull/1679) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Explicitly set a minimum macOS version for the Swift package. + +## \[2.0.0-rc.1] + +- [`5d170a54`](https://github.com/tauri-apps/plugins-workspace/commit/5d170a5444982dcc14135f6f1fc3e5da359f0eb0) ([#1671](https://github.com/tauri-apps/plugins-workspace/pull/1671) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri 2.0.0-rc.3. + +### changes + +- [`6b079cfd`](https://github.com/tauri-apps/plugins-workspace/commit/6b079cfdd107c94abc2c7300f6af00bac3ff4040) ([#1649](https://github.com/tauri-apps/plugins-workspace/pull/1649) by [@ahqsoftwares](https://github.com/tauri-apps/plugins-workspace/../../ahqsoftwares)) Remove targetSdk from build.kts files as it is deprecated and will be removed from DSL v9.0 + +## \[2.0.0-rc.0] + +- [`9606089b`](https://github.com/tauri-apps/plugins-workspace/commit/9606089b2add4a17f80ed5a09d59ce94824bd672) ([#1599](https://github.com/tauri-apps/plugins-workspace/pull/1599)) Initial release. +- [`9887d1`](https://github.com/tauri-apps/plugins-workspace/commit/9887d14bd0e971c4c0f5c1188fc4005d3fc2e29e) Update to tauri RC. + tauri-apps/plugins-workspace/commit/9887d14bd0e971c4c0f5c1188fc4005d3fc2e29e) Update to tauri RC. diff --git a/plugins/geolocation/Cargo.toml b/plugins/geolocation/Cargo.toml new file mode 100644 index 00000000..7d01b526 --- /dev/null +++ b/plugins/geolocation/Cargo.toml @@ -0,0 +1,38 @@ +[package] +name = "tauri-plugin-geolocation" +description = "Get and track the device's current position" +version = "2.2.4" +edition = { workspace = true } +authors = { workspace = true } +license = { workspace = true } +repository = { workspace = true } +links = "tauri-plugin-geolocation" + +[package.metadata.docs.rs] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] +targets = ["x86_64-linux-android"] + +[package.metadata.platforms.support] +windows = { level = "none", notes = "" } +linux = { level = "none", notes = "" } +macos = { level = "none", notes = "" } +android = { level = "full", notes = "" } +ios = { level = "full", notes = "" } + +[build-dependencies] +tauri-plugin = { workspace = true, features = ["build"] } + +[dependencies] +serde = { workspace = true } +serde_json = { workspace = true } +tauri = { workspace = true } +log = { workspace = true } +thiserror = { workspace = true } +specta = { workspace = true, optional = true } + +[target.'cfg(target_os = "ios")'.dependencies] +tauri = { workspace = true, features = ["wry"] } + +[features] +specta = ["dep:specta", "tauri/specta"] diff --git a/plugins/geolocation/LICENSE.spdx b/plugins/geolocation/LICENSE.spdx new file mode 100644 index 00000000..cdd0df5a --- /dev/null +++ b/plugins/geolocation/LICENSE.spdx @@ -0,0 +1,20 @@ +SPDXVersion: SPDX-2.1 +DataLicense: CC0-1.0 +PackageName: tauri +DataFormat: SPDXRef-1 +PackageSupplier: Organization: The Tauri Programme in the Commons Conservancy +PackageHomePage: https://tauri.app +PackageLicenseDeclared: Apache-2.0 +PackageLicenseDeclared: MIT +PackageCopyrightText: 2019-2022, The Tauri Programme in the Commons Conservancy +PackageSummary: Tauri is a rust project that enables developers to make secure +and small desktop applications using a web frontend. + +PackageComment: The package includes the following libraries; see +Relationship information. + +Created: 2019-05-20T09:00:00Z +PackageDownloadLocation: git://github.com/tauri-apps/tauri +PackageDownloadLocation: git+https://github.com/tauri-apps/tauri.git +PackageDownloadLocation: git+ssh://github.com/tauri-apps/tauri.git +Creator: Person: Daniel Thompson-Yvetot \ No newline at end of file diff --git a/plugins/geolocation/LICENSE_APACHE-2.0 b/plugins/geolocation/LICENSE_APACHE-2.0 new file mode 100644 index 00000000..4947287f --- /dev/null +++ b/plugins/geolocation/LICENSE_APACHE-2.0 @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/plugins/geolocation/LICENSE_MIT b/plugins/geolocation/LICENSE_MIT new file mode 100644 index 00000000..4d754725 --- /dev/null +++ b/plugins/geolocation/LICENSE_MIT @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 - Present Tauri Apps Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/plugins/geolocation/README.md b/plugins/geolocation/README.md new file mode 100644 index 00000000..c7cb81fb --- /dev/null +++ b/plugins/geolocation/README.md @@ -0,0 +1,182 @@ +![geolocation](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/geolocation/banner.png) + +This plugin provides APIs for getting and tracking the device's current position, including information about altitude, heading, and speed (if available). + +| Platform | Supported | +| -------- | --------- | +| Linux | x | +| Windows | x | +| macOS | x | +| Android | ✓ | +| iOS | ✓ | + +## Install + +_This plugin requires a Rust version of at least **1.77.2**_ + +There are three general methods of installation that we can recommend. + +1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked) +2. Pull sources directly from Github using git tags / revision hashes (most secure) +3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use) + +Install the Core plugin by adding the following to your `Cargo.toml` file: + +`src-tauri/Cargo.toml` + +```toml +[dependencies] +tauri-plugin-geolocation = "2.0.0" +# alternatively with Git: +tauri-plugin-geolocation = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } +``` + +You can install the JavaScript Guest bindings using your preferred JavaScript package manager: + +> Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use. + + + +```sh +pnpm add @tauri-apps/plugin-geolocation +# or +npm add @tauri-apps/plugin-geolocation +# or +yarn add @tauri-apps/plugin-geolocation + +# alternatively with Git: +pnpm add https://github.com/tauri-apps/tauri-plugin-geolocation#v2 +# or +npm add https://github.com/tauri-apps/tauri-plugin-geolocation#v2 +# or +yarn add https://github.com/tauri-apps/tauri-plugin-geolocation#v2 +``` + +## Setting up + +### iOS + +Apple requires privacy descriptions to be specified in `Info.plist` for location information: + +- `NSLocationWhenInUseDescription` + +### Android + +This plugin automatically adds the following permissions to your `AndroidManifest.xml` file: + +```xml + + +``` + +If your app requires GPS functionality to function, **you** should add the following to your `AndroidManifest.xml` file: + +```xml + +``` + +The Google Play Store uses this property to decide whether it should show the app to devices without GPS capabilities. + +## Usage + +First you need to register the core plugin with Tauri: + +`src-tauri/src/lib.rs` + +```rust +fn main() { + tauri::Builder::default() + .plugin(tauri_plugin_geolocation::init()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} +``` + +Then, for instance, grant the plugin the permission to check or request permissions from the user and to read the device position + +`src-tauri/capabilities/default.json` + +```json + "permissions": [ + "core:default", + "geolocation:allow-check-permissions", + "geolocation:allow-request-permissions", + "geolocation:allow-get-current-position", + "geolocation:allow-watch-position", + ] +``` + +Afterwards all the plugin's APIs are available through the JavaScript guest bindings: + +```javascript +import { + checkPermissions, + requestPermissions, + getCurrentPosition, + watchPosition +} from '@tauri-apps/plugin-geolocation' + +let permissions = await checkPermissions() +if ( + permissions.location === 'prompt' + || permissions.location === 'prompt-with-rationale' +) { + permissions = await requestPermissions(['location']) +} + +if (permissions.location === 'granted') { + const pos = await getCurrentPosition() + + await watchPosition( + { enableHighAccuracy: true, timeout: 10000, maximumAge: 0 }, + (pos) => { + console.log(pos) + } + ) +} +``` + +## Contributing + +PRs accepted. Please make sure to read the Contributing Guide before making a pull request. + +## Contributed By + + + + + + + + +
+ + CrabNebula + + + + Rescue.co + +
+ +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + +## License + +Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. + +MIT or MIT/Apache 2.0 where applicable. diff --git a/plugins/geolocation/SECURITY.md b/plugins/geolocation/SECURITY.md new file mode 100644 index 00000000..4f09bbac --- /dev/null +++ b/plugins/geolocation/SECURITY.md @@ -0,0 +1,23 @@ +# Security Policy + +**Do not report security vulnerabilities through public GitHub issues.** + +**Please use the [Private Vulnerability Disclosure](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) feature of GitHub.** + +Include as much of the following information: + +- Type of issue (e.g. improper input parsing, privilege escalation, etc.) +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- The distribution affected or used to help us with reproduction of the issue +- Step-by-step instructions to reproduce the issue +- Ideally a reproduction repository +- Impact of the issue, including how an attacker might exploit the issue + +We prefer to receive reports in English. + +## Contact + +Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). + +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/notification/.gitignore b/plugins/geolocation/android/.gitignore similarity index 53% rename from plugins/notification/.gitignore rename to plugins/geolocation/android/.gitignore index 1b0b469d..c0f21ec2 100644 --- a/plugins/notification/.gitignore +++ b/plugins/geolocation/android/.gitignore @@ -1 +1,2 @@ +/build /.tauri diff --git a/plugins/geolocation/android/build.gradle.kts b/plugins/geolocation/android/build.gradle.kts new file mode 100644 index 00000000..18fba0f3 --- /dev/null +++ b/plugins/geolocation/android/build.gradle.kts @@ -0,0 +1,45 @@ +plugins { + id("com.android.library") + id("org.jetbrains.kotlin.android") +} + +android { + namespace = "app.tauri.geolocation" + compileSdk = 34 + + defaultConfig { + minSdk = 24 + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles("consumer-rules.pro") + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = "1.8" + } +} + +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.google.android.gms:play-services-location:21.3.0") + testImplementation("junit:junit:4.13.2") + androidTestImplementation("androidx.test.ext:junit:1.1.5") + androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") + implementation(project(":tauri-android")) +} diff --git a/plugins/geolocation/android/proguard-rules.pro b/plugins/geolocation/android/proguard-rules.pro new file mode 100644 index 00000000..481bb434 --- /dev/null +++ b/plugins/geolocation/android/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/plugins/geolocation/android/settings.gradle b/plugins/geolocation/android/settings.gradle new file mode 100644 index 00000000..14a752e4 --- /dev/null +++ b/plugins/geolocation/android/settings.gradle @@ -0,0 +1,2 @@ +include ':tauri-android' +project(':tauri-android').projectDir = new File('./.tauri/tauri-api') diff --git a/plugins/geolocation/android/src/androidTest/java/ExampleInstrumentedTest.kt b/plugins/geolocation/android/src/androidTest/java/ExampleInstrumentedTest.kt new file mode 100644 index 00000000..a301dc2d --- /dev/null +++ b/plugins/geolocation/android/src/androidTest/java/ExampleInstrumentedTest.kt @@ -0,0 +1,28 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +package app.tauri.geolocation + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("app.tauri.geolocation", appContext.packageName) + } +} diff --git a/plugins/geolocation/android/src/main/AndroidManifest.xml b/plugins/geolocation/android/src/main/AndroidManifest.xml new file mode 100644 index 00000000..a47edd1c --- /dev/null +++ b/plugins/geolocation/android/src/main/AndroidManifest.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/plugins/geolocation/android/src/main/java/Geolocation.kt b/plugins/geolocation/android/src/main/java/Geolocation.kt new file mode 100644 index 00000000..b16a4482 --- /dev/null +++ b/plugins/geolocation/android/src/main/java/Geolocation.kt @@ -0,0 +1,148 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +package app.tauri.geolocation + +import android.annotation.SuppressLint +import android.content.Context +import android.location.Location +import android.location.LocationManager +import android.os.SystemClock +import androidx.core.location.LocationManagerCompat +import app.tauri.Logger +import com.google.android.gms.common.ConnectionResult +import com.google.android.gms.common.GoogleApiAvailability +import com.google.android.gms.location.FusedLocationProviderClient +import com.google.android.gms.location.LocationCallback +import com.google.android.gms.location.LocationRequest +import com.google.android.gms.location.LocationResult +import com.google.android.gms.location.LocationServices +import com.google.android.gms.location.Priority + + +public class Geolocation(private val context: Context) { + private var fusedLocationClient: FusedLocationProviderClient? = null + private var locationCallback: LocationCallback? = null + + + fun isLocationServicesEnabled(): Boolean { + val lm = context.getSystemService(Context.LOCATION_SERVICE) as LocationManager + return LocationManagerCompat.isLocationEnabled(lm) + } + + @SuppressWarnings("MissingPermission") + fun sendLocation(enableHighAccuracy: Boolean, successCallback: (location: Location) -> Unit, errorCallback: (error: String) -> Unit) { + val resultCode = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context); + if (resultCode == ConnectionResult.SUCCESS) { + val lm = context.getSystemService(Context.LOCATION_SERVICE) as LocationManager + + if (this.isLocationServicesEnabled()) { + var networkEnabled = false + + try { + networkEnabled = lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER) + } catch (_: Exception) { + Logger.error("isProviderEnabled failed") + } + + val lowPrio = if (networkEnabled) Priority.PRIORITY_BALANCED_POWER_ACCURACY else Priority.PRIORITY_LOW_POWER + val prio = if (enableHighAccuracy) Priority.PRIORITY_HIGH_ACCURACY else lowPrio + + Logger.error(prio.toString()) + + LocationServices + .getFusedLocationProviderClient(context) + .getCurrentLocation(prio, null) + .addOnFailureListener { e -> e.message?.let { errorCallback(it) } } + .addOnSuccessListener { location -> + if (location == null) { + errorCallback("Location unavailable.") + } else { + successCallback(location) + } + } + } else { + errorCallback("Location disabled.") + } + } else { + errorCallback("Google Play Services unavailable.") + } + } + + @SuppressLint("MissingPermission") + fun requestLocationUpdates(enableHighAccuracy: Boolean, timeout: Long, successCallback: (location: Location) -> Unit, errorCallback: (error: String) -> Unit) { + val resultCode = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context); + if (resultCode == ConnectionResult.SUCCESS) { + clearLocationUpdates() + fusedLocationClient = LocationServices.getFusedLocationProviderClient(context) + + val lm = context.getSystemService(Context.LOCATION_SERVICE) as LocationManager + + if (this.isLocationServicesEnabled()) { + var networkEnabled = false + + try { + networkEnabled = lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER) + } catch (_: Exception) { + Logger.error("isProviderEnabled failed") + } + + val lowPrio = if (networkEnabled) Priority.PRIORITY_BALANCED_POWER_ACCURACY else Priority.PRIORITY_LOW_POWER + val prio = if (enableHighAccuracy) Priority.PRIORITY_HIGH_ACCURACY else lowPrio + + Logger.error(prio.toString()) + + val locationRequest = LocationRequest.Builder(10000) + .setMaxUpdateDelayMillis(timeout) + .setMinUpdateIntervalMillis(5000) + .setPriority(prio) + .build() + + locationCallback = + object : LocationCallback() { + override fun onLocationResult(locationResult: LocationResult) { + val lastLocation = locationResult.lastLocation + if (lastLocation == null) { + errorCallback("Location unavailable.") + } else { + successCallback(lastLocation) + } + } + } + + fusedLocationClient?.requestLocationUpdates(locationRequest, locationCallback!!, null) + } else { + errorCallback("Location disabled.") + } + } else { + errorCallback("Google Play Services not available.") + } + } + + fun clearLocationUpdates() { + if (locationCallback != null) { + fusedLocationClient?.removeLocationUpdates(locationCallback!!) + locationCallback = null + } + } + + @SuppressLint("MissingPermission") + fun getLastLocation(maximumAge: Long): Location? { + var lastLoc: Location? = null + val lm = context.getSystemService(Context.LOCATION_SERVICE) as LocationManager + + for (provider in lm.allProviders) { + val tmpLoc = lm.getLastKnownLocation(provider) + if (tmpLoc != null) { + val locationAge = SystemClock.elapsedRealtimeNanos() - tmpLoc.elapsedRealtimeNanos + val maxAgeNano = maximumAge * 1000000L + if (locationAge <= maxAgeNano && (lastLoc == null || lastLoc.elapsedRealtimeNanos > tmpLoc.elapsedRealtimeNanos)) { + lastLoc = tmpLoc + } + } + } + + return lastLoc + } +} \ No newline at end of file diff --git a/plugins/geolocation/android/src/main/java/GeolocationPlugin.kt b/plugins/geolocation/android/src/main/java/GeolocationPlugin.kt new file mode 100644 index 00000000..cf81f5e3 --- /dev/null +++ b/plugins/geolocation/android/src/main/java/GeolocationPlugin.kt @@ -0,0 +1,172 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +package app.tauri.geolocation + +import android.Manifest +import android.app.Activity +import android.location.Location +import android.os.Build +import android.webkit.WebView +import app.tauri.Logger +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 +import app.tauri.plugin.Channel +import app.tauri.plugin.Invoke +import app.tauri.plugin.JSObject +import app.tauri.plugin.Plugin + +@InvokeArg +class PositionOptions { + var enableHighAccuracy: Boolean = false + var maximumAge: Long = 0 + var timeout: Long = 10000 +} + +@InvokeArg +class WatchArgs { + var options: PositionOptions = PositionOptions() + lateinit var channel: Channel +} + +@InvokeArg +class ClearWatchArgs { + var channelId: Long = 0 +} + +// TODO: Plugin does not ask user to enable google location services (like gmaps does) + +private const val ALIAS_LOCATION: String = "location" +private const val ALIAS_COARSE_LOCATION: String = "coarseLocation" + +@TauriPlugin( + permissions = [ + Permission(strings = [ + Manifest.permission.ACCESS_FINE_LOCATION, + Manifest.permission.ACCESS_COARSE_LOCATION + ], + alias = ALIAS_LOCATION + ), + Permission(strings = [ + Manifest.permission.ACCESS_COARSE_LOCATION + ], + alias = ALIAS_COARSE_LOCATION + ) + ] +) +class GeolocationPlugin(private val activity: Activity): Plugin(activity) { + private lateinit var implementation: Geolocation + private var watchers = hashMapOf>() + + override fun load(webView: WebView) { + super.load(webView) + implementation = Geolocation(activity.applicationContext) + } + + override fun onPause() { + super.onPause() + // Clear all location updates on pause to avoid possible background location calls + implementation.clearLocationUpdates() + } + + override fun onResume() { + super.onResume() + // resume watchers + for ((watcher, args) in watchers.values) { + startWatch(watcher, args) + } + } + + @Command + override fun checkPermissions(invoke: Invoke) { + if (implementation.isLocationServicesEnabled()) { + super.checkPermissions(invoke) + } else { + invoke.reject("Location services are disabled.") + } + } + + @Command + override fun requestPermissions(invoke: Invoke) { + if (implementation.isLocationServicesEnabled()) { + super.requestPermissions(invoke) + } else { + invoke.reject("Location services are disabled.") + } + } + + @Command + fun getCurrentPosition(invoke: Invoke) { + val args = invoke.parseArgs(PositionOptions::class.java) + + val location = implementation.getLastLocation(args.maximumAge) + if (location != null) { + invoke.resolve(convertLocation(location)) + } else { + implementation.sendLocation(args.enableHighAccuracy, + { loc -> invoke.resolve(convertLocation(loc)) }, + { error -> invoke.reject(error) }) + } + } + + @PermissionCallback + private fun positionPermissionCallback(invoke: Invoke) { + val permissionsResultJSON = JSObject() + permissionsResultJSON.put("location", getPermissionState(ALIAS_LOCATION)) + permissionsResultJSON.put("coarseLocation", getPermissionState(ALIAS_COARSE_LOCATION)) + invoke.resolve(permissionsResultJSON) + } + + @Command + fun watchPosition(invoke: Invoke) { + val args = invoke.parseArgs(WatchArgs::class.java) + startWatch(invoke, args) + } + + private fun startWatch(invoke: Invoke, args: WatchArgs) { + implementation.requestLocationUpdates( + args.options.enableHighAccuracy, + args.options.timeout, + { location -> args.channel.send(convertLocation(location)) }, + { error -> args.channel.sendObject(error) }) + + watchers[args.channel.id] = Pair(invoke, args) + } + + @Command + fun clearWatch(invoke: Invoke) { + val args = invoke.parseArgs(ClearWatchArgs::class.java) + + watchers.remove(args.channelId) + + if (watchers.isEmpty()) { + implementation.clearLocationUpdates() + } + + invoke.resolve() + } + + private fun convertLocation(location: Location): JSObject { + val ret = JSObject() + val coords = JSObject() + + coords.put("latitude", location.latitude) + coords.put("longitude", location.longitude) + coords.put("accuracy", location.accuracy) + coords.put("altitude", location.altitude) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + coords.put("altitudeAccuracy", location.verticalAccuracyMeters) + } + coords.put("speed", location.speed) + coords.put("heading", location.bearing) + ret.put("timestamp", location.time) + ret.put("coords", coords) + + return ret + } +} diff --git a/plugins/geolocation/android/src/test/java/ExampleUnitTest.kt b/plugins/geolocation/android/src/test/java/ExampleUnitTest.kt new file mode 100644 index 00000000..03c99f7d --- /dev/null +++ b/plugins/geolocation/android/src/test/java/ExampleUnitTest.kt @@ -0,0 +1,21 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +package app.tauri.geolocation + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} diff --git a/plugins/geolocation/api-iife.js b/plugins/geolocation/api-iife.js new file mode 100644 index 00000000..1db79359 --- /dev/null +++ b/plugins/geolocation/api-iife.js @@ -0,0 +1 @@ +if("__TAURI__"in window){var __TAURI_PLUGIN_GEOLOCATION__=function(t){"use strict";function n(t,n,e,i){if("function"==typeof n||!n.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===e?i:"a"===e?i.call(t):i?i.value:n.get(t)}function e(t,n,e,i,s){if("function"==typeof n||!n.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n.set(t,e),e}var i,s,o,r;"function"==typeof SuppressedError&&SuppressedError;const a="__TAURI_TO_IPC_KEY__";class c{constructor(t){i.set(this,void 0),s.set(this,0),o.set(this,[]),r.set(this,void 0),e(this,i,t||(()=>{})),this.id=function(t,n=!1){return window.__TAURI_INTERNALS__.transformCallback(t,n)}((t=>{const a=t.index;if("end"in t)return void(a==n(this,s,"f")?this.cleanupCallback():e(this,r,a));const c=t.message;if(a==n(this,s,"f")){for(n(this,i,"f").call(this,c),e(this,s,n(this,s,"f")+1);n(this,s,"f")in n(this,o,"f");){const t=n(this,o,"f")[n(this,s,"f")];n(this,i,"f").call(this,t),delete n(this,o,"f")[n(this,s,"f")],e(this,s,n(this,s,"f")+1)}n(this,s,"f")===n(this,r,"f")&&this.cleanupCallback()}else n(this,o,"f")[a]=c}))}cleanupCallback(){Reflect.deleteProperty(window,`_${this.id}`)}set onmessage(t){e(this,i,t)}get onmessage(){return n(this,i,"f")}[(i=new WeakMap,s=new WeakMap,o=new WeakMap,r=new WeakMap,a)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[a]()}}async function _(t,n={},e){return window.__TAURI_INTERNALS__.invoke(t,n,e)}return t.checkPermissions=async function(){return await async function(t){return _(`plugin:${t}|check_permissions`)}("geolocation")},t.clearWatch=async function(t){await _("plugin:geolocation|clear_watch",{channelId:t})},t.getCurrentPosition=async function(t){return await _("plugin:geolocation|get_current_position",{options:t})},t.requestPermissions=async function(t){return await _("plugin:geolocation|request_permissions",{permissions:t})},t.watchPosition=async function(t,n){const e=new c;return e.onmessage=t=>{"string"==typeof t?n(null,t):n(t)},await _("plugin:geolocation|watch_position",{options:t,channel:e}),e.id},t}({});Object.defineProperty(window.__TAURI__,"geolocation",{value:__TAURI_PLUGIN_GEOLOCATION__})} diff --git a/plugins/geolocation/build.rs b/plugins/geolocation/build.rs new file mode 100644 index 00000000..b5249761 --- /dev/null +++ b/plugins/geolocation/build.rs @@ -0,0 +1,24 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +const COMMANDS: &[&str] = &[ + "get_current_position", + "watch_position", + "clear_watch", + "check_permissions", + "request_permissions", +]; + +fn main() { + let result = tauri_plugin::Builder::new(COMMANDS) + .global_api_script_path("./api-iife.js") + .android_path("android") + .ios_path("ios") + .try_build(); + + // when building documentation for Android the plugin build result is always Err() and is irrelevant to the crate documentation build + if !(cfg!(docsrs) && std::env::var("TARGET").unwrap().contains("android")) { + result.unwrap(); + } +} diff --git a/plugins/geolocation/contributors/crabnebula.svg b/plugins/geolocation/contributors/crabnebula.svg new file mode 100644 index 00000000..40e24131 --- /dev/null +++ b/plugins/geolocation/contributors/crabnebula.svg @@ -0,0 +1,31 @@ + \ No newline at end of file diff --git a/plugins/geolocation/contributors/rescue.png b/plugins/geolocation/contributors/rescue.png new file mode 100644 index 00000000..2b5916f4 Binary files /dev/null and b/plugins/geolocation/contributors/rescue.png differ diff --git a/plugins/geolocation/guest-js/index.ts b/plugins/geolocation/guest-js/index.ts new file mode 100644 index 00000000..8ef5c533 --- /dev/null +++ b/plugins/geolocation/guest-js/index.ts @@ -0,0 +1,138 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import { + Channel, + invoke, + PermissionState, + checkPermissions as checkPluginPermissions +} from '@tauri-apps/api/core' + +export type Coordinates = { + /** + * Latitude in decimal degrees. + */ + latitude: number + /** + * Longitude in decimal degrees. + */ + longitude: number + /** + * Accuracy level of the latitude and longitude coordinates in meters. + */ + accuracy: number + /** + * Accuracy level of the altitude coordinate in meters, if available. + * Available on all iOS versions and on Android 8 and above. + */ + altitudeAccuracy: number | null + /** + * The altitude the user is at, if available. + */ + altitude: number | null + speed: number | null + /** + * The heading the user is facing, if available. + */ + heading: number | null +} + +export type PermissionStatus = { + /** + * Permission state for the location alias. + * + * On Android it requests/checks both ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION permissions. + * + * On iOS it requests/checks location permissions. + */ + location: PermissionState + /** + * Permissions state for the coarseLoaction alias. + * + * On Android it requests/checks ACCESS_COARSE_LOCATION. + * + * On Android 12+, users can choose between Approximate location (ACCESS_COARSE_LOCATION) and Precise location (ACCESS_FINE_LOCATION). + * + * On iOS it will have the same value as the `location` alias. + */ + coarseLocation: PermissionState +} + +export type PermissionType = 'location' | 'coarseLocation' + +export type Position = { + /** + * Creation time for these coordinates. + */ + timestamp: number + /** + * The GPD coordinates along with the accuracy of the data. + */ + coords: Coordinates +} + +export type PositionOptions = { + /** + * High accuracy mode (such as GPS, if available) + * Will be ignored on Android 12+ if users didn't grant the ACCESS_FINE_LOCATION permission (`coarseLocation` permission). + */ + enableHighAccuracy: boolean + /** + * The maximum wait time in milliseconds for location updates. + * On Android the timeout gets ignored for getCurrentPosition. + * Ignored on iOS + */ + timeout: number + /** + * The maximum age in milliseconds of a possible cached position that is acceptable to return. + * Default: 0 + * Ignored on iOS + */ + maximumAge: number +} + +export async function watchPosition( + options: PositionOptions, + cb: (location: Position | null, error?: string) => void +): Promise { + const channel = new Channel() + channel.onmessage = (message) => { + if (typeof message === 'string') { + cb(null, message) + } else { + cb(message) + } + } + await invoke('plugin:geolocation|watch_position', { + options, + channel + }) + return channel.id +} + +export async function getCurrentPosition( + options?: PositionOptions +): Promise { + return await invoke('plugin:geolocation|get_current_position', { + options + }) +} + +export async function clearWatch(channelId: number): Promise { + await invoke('plugin:geolocation|clear_watch', { + channelId + }) +} + +export async function checkPermissions(): Promise { + return await checkPluginPermissions('geolocation') +} + +export async function requestPermissions( + permissions: PermissionType[] | null +): Promise { + return await invoke('plugin:geolocation|request_permissions', { + permissions + }) +} diff --git a/plugins/geolocation/ios/.gitignore b/plugins/geolocation/ios/.gitignore new file mode 100644 index 00000000..5922fdaa --- /dev/null +++ b/plugins/geolocation/ios/.gitignore @@ -0,0 +1,10 @@ +.DS_Store +/.build +/Packages +/*.xcodeproj +xcuserdata/ +DerivedData/ +.swiftpm/config/registries.json +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +.netrc +Package.resolved diff --git a/plugins/geolocation/ios/Package.swift b/plugins/geolocation/ios/Package.swift new file mode 100644 index 00000000..f8cfb73f --- /dev/null +++ b/plugins/geolocation/ios/Package.swift @@ -0,0 +1,34 @@ +// swift-tools-version:5.3 +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import PackageDescription + +let package = Package( + name: "tauri-plugin-geolocation", + platforms: [ + .macOS(.v10_13), + .iOS(.v13), + ], + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .library( + name: "tauri-plugin-geolocation", + type: .static, + targets: ["tauri-plugin-geolocation"]) + ], + dependencies: [ + .package(name: "Tauri", path: "../.tauri/tauri-api") + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .target( + name: "tauri-plugin-geolocation", + dependencies: [ + .byName(name: "Tauri") + ], + path: "Sources") + ] +) diff --git a/plugins/geolocation/ios/README.md b/plugins/geolocation/ios/README.md new file mode 100644 index 00000000..5612ac82 --- /dev/null +++ b/plugins/geolocation/ios/README.md @@ -0,0 +1,3 @@ +# Tauri Plugin Geolocation + +A description of this package. diff --git a/plugins/geolocation/ios/Sources/GeolocationPlugin.swift b/plugins/geolocation/ios/Sources/GeolocationPlugin.swift new file mode 100644 index 00000000..7a2b57a9 --- /dev/null +++ b/plugins/geolocation/ios/Sources/GeolocationPlugin.swift @@ -0,0 +1,250 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import CoreLocation +import SwiftRs +import Tauri +import UIKit +import WebKit + +class GetPositionArgs: Decodable { + var enableHighAccuracy: Bool? +} + +class WatchPositionArgs: Decodable { + let options: GetPositionArgs + let channel: Channel +} + +class ClearWatchArgs: Decodable { + let channelId: UInt32 +} + +class GeolocationPlugin: Plugin, CLLocationManagerDelegate { + private let locationManager = CLLocationManager() + private var isUpdatingLocation: Bool = false + private var permissionRequests: [Invoke] = [] + private var positionRequests: [Invoke] = [] + private var watcherChannels: [Channel] = [] + + override init() { + super.init() + locationManager.delegate = self + } + + // + // Tauri commands + // + + @objc public func getCurrentPosition(_ invoke: Invoke) throws { + let args = try invoke.parseArgs(GetPositionArgs.self) + + self.positionRequests.append(invoke) + + DispatchQueue.main.async { + if args.enableHighAccuracy == true { + self.locationManager.desiredAccuracy = kCLLocationAccuracyBest + } else { + self.locationManager.desiredAccuracy = kCLLocationAccuracyKilometer + } + + // TODO: Use the authorizationStatus instance property with locationManagerDidChangeAuthorization(_:) instead. + if CLLocationManager.authorizationStatus() == .notDetermined { + self.locationManager.requestWhenInUseAuthorization() + } else { + self.locationManager.requestLocation() + } + } + } + + @objc public func watchPosition(_ invoke: Invoke) throws { + let args = try invoke.parseArgs(WatchPositionArgs.self) + + self.watcherChannels.append(args.channel) + + DispatchQueue.main.async { + if args.options.enableHighAccuracy == true { + self.locationManager.desiredAccuracy = kCLLocationAccuracyBest + } else { + self.locationManager.desiredAccuracy = kCLLocationAccuracyKilometer + } + + // TODO: Use the authorizationStatus instance property with locationManagerDidChangeAuthorization(_:) instead. + if CLLocationManager.authorizationStatus() == .notDetermined { + self.locationManager.requestWhenInUseAuthorization() + } else { + self.locationManager.startUpdatingLocation() + self.isUpdatingLocation = true + } + } + + invoke.resolve() + } + + @objc public func clearWatch(_ invoke: Invoke) throws { + let args = try invoke.parseArgs(ClearWatchArgs.self) + + self.watcherChannels = self.watcherChannels.filter { $0.id != args.channelId } + + // TODO: capacitor plugin calls stopUpdating unconditionally + if self.watcherChannels.isEmpty { + self.stopUpdating() + } + + invoke.resolve() + } + + @objc override public func checkPermissions(_ invoke: Invoke) { + var status: String = "" + + if CLLocationManager.locationServicesEnabled() { + // TODO: Use the authorizationStatus instance property with locationManagerDidChangeAuthorization(_:) instead. + switch CLLocationManager.authorizationStatus() { + case .notDetermined: + status = "prompt" + case .restricted, .denied: + status = "denied" + case .authorizedAlways, .authorizedWhenInUse: + status = "granted" + @unknown default: + status = "prompt" + } + } else { + invoke.reject("Location services are not enabled.") + return + } + + let result = ["location": status, "coarseLocation": status] + + invoke.resolve(result) + } + + @objc override public func requestPermissions(_ invoke: Invoke) { + if CLLocationManager.locationServicesEnabled() { + // TODO: Use the authorizationStatus instance property with locationManagerDidChangeAuthorization(_:) instead. + if CLLocationManager.authorizationStatus() == .notDetermined { + self.permissionRequests.append(invoke) + + DispatchQueue.main.async { + self.locationManager.requestWhenInUseAuthorization() + } + } else { + checkPermissions(invoke) + } + } else { + invoke.reject("Location services are not enabled.") + } + } + + // + // Delegate methods + // + + public func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) { + Logger.error(error) + + let requests = self.positionRequests + self.permissionRequests + self.positionRequests.removeAll() + self.permissionRequests.removeAll() + + for request in requests { + request.reject(error.localizedDescription) + } + + for channel in self.watcherChannels { + do { + try channel.send(error.localizedDescription) + } catch { + Logger.error(error) + } + } + } + + public func locationManager( + _ manager: CLLocationManager, didUpdateLocations locations: [CLLocation] + ) { + // Respond to all getCurrentPosition() calls. + for request in self.positionRequests { + // The capacitor plugin uses locations.first but .last should be the most current one + // and i don't see a reason to use old locations + if let location = locations.last { + let result = convertLocation(location) + request.resolve(result) + } else { + request.reject("Location service returned an empty Location array.") + } + } + + for channel in self.watcherChannels { + // The capacitor plugin uses locations.first but .last should be the most recent one + // and i don't see a reason to use old locations + if let location = locations.last { + let result = convertLocation(location) + do { + try channel.send(result) + } catch { + Logger.error(error) + } + } else { + do { + try channel.send("Location service returned an empty Location array.") + } catch { + Logger.error(error) + } + } + } + } + + public func locationManager( + _ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus + ) { + let requests = self.permissionRequests + self.permissionRequests.removeAll() + + for request in requests { + checkPermissions(request) + } + + if !self.positionRequests.isEmpty { + self.locationManager.requestLocation() + } + + if !self.watcherChannels.isEmpty && !self.isUpdatingLocation { + self.locationManager.startUpdatingLocation() + self.isUpdatingLocation = true + } + } + + // + // Internal/Helper methods + // + + // TODO: Why is this pub in capacitor + private func stopUpdating() { + self.locationManager.stopUpdatingLocation() + self.isUpdatingLocation = false + } + + private func convertLocation(_ location: CLLocation) -> JsonObject { + var ret: JsonObject = [:] + var coords: JsonObject = [:] + + coords["latitude"] = location.coordinate.latitude + coords["longitude"] = location.coordinate.longitude + coords["accuracy"] = location.horizontalAccuracy + coords["altitude"] = location.altitude + coords["altitudeAccuracy"] = location.verticalAccuracy + coords["speed"] = location.speed + coords["heading"] = location.course + ret["timestamp"] = Int((location.timestamp.timeIntervalSince1970 * 1000)) + ret["coords"] = coords + + return ret + } +} + +@_cdecl("init_plugin_geolocation") +func initPlugin() -> Plugin { + return GeolocationPlugin() +} diff --git a/plugins/geolocation/ios/Tests/PluginTests/PluginTests.swift b/plugins/geolocation/ios/Tests/PluginTests/PluginTests.swift new file mode 100644 index 00000000..99992ce4 --- /dev/null +++ b/plugins/geolocation/ios/Tests/PluginTests/PluginTests.swift @@ -0,0 +1,12 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import XCTest +@testable import ExamplePlugin + +final class ExamplePluginTests: XCTestCase { + func testExample() throws { + let plugin = ExamplePlugin() + } +} diff --git a/plugins/geolocation/package.json b/plugins/geolocation/package.json new file mode 100644 index 00000000..0e3b09cb --- /dev/null +++ b/plugins/geolocation/package.json @@ -0,0 +1,29 @@ +{ + "name": "@tauri-apps/plugin-geolocation", + "version": "2.2.4", + "license": "MIT OR Apache-2.0", + "authors": [ + "Tauri Programme within The Commons Conservancy" + ], + "repository": "https://github.com/tauri-apps/plugins-workspace", + "type": "module", + "types": "./dist-js/index.d.ts", + "main": "./dist-js/index.cjs", + "module": "./dist-js/index.js", + "exports": { + "types": "./dist-js/index.d.ts", + "import": "./dist-js/index.js", + "require": "./dist-js/index.cjs" + }, + "scripts": { + "build": "rollup -c" + }, + "files": [ + "dist-js", + "README.md", + "LICENSE" + ], + "dependencies": { + "@tauri-apps/api": "^2.0.0" + } +} diff --git a/plugins/geolocation/permissions/autogenerated/commands/check_permissions.toml b/plugins/geolocation/permissions/autogenerated/commands/check_permissions.toml new file mode 100644 index 00000000..f5af08b1 --- /dev/null +++ b/plugins/geolocation/permissions/autogenerated/commands/check_permissions.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-check-permissions" +description = "Enables the check_permissions command without any pre-configured scope." +commands.allow = ["check_permissions"] + +[[permission]] +identifier = "deny-check-permissions" +description = "Denies the check_permissions command without any pre-configured scope." +commands.deny = ["check_permissions"] diff --git a/plugins/geolocation/permissions/autogenerated/commands/clear_permissions.toml b/plugins/geolocation/permissions/autogenerated/commands/clear_permissions.toml new file mode 100644 index 00000000..a3e6ab5c --- /dev/null +++ b/plugins/geolocation/permissions/autogenerated/commands/clear_permissions.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-clear-permissions" +description = "Enables the clear_permissions command without any pre-configured scope." +commands.allow = ["clear_permissions"] + +[[permission]] +identifier = "deny-clear-permissions" +description = "Denies the clear_permissions command without any pre-configured scope." +commands.deny = ["clear_permissions"] diff --git a/plugins/geolocation/permissions/autogenerated/commands/clear_watch.toml b/plugins/geolocation/permissions/autogenerated/commands/clear_watch.toml new file mode 100644 index 00000000..19fb5776 --- /dev/null +++ b/plugins/geolocation/permissions/autogenerated/commands/clear_watch.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-clear-watch" +description = "Enables the clear_watch command without any pre-configured scope." +commands.allow = ["clear_watch"] + +[[permission]] +identifier = "deny-clear-watch" +description = "Denies the clear_watch command without any pre-configured scope." +commands.deny = ["clear_watch"] diff --git a/plugins/geolocation/permissions/autogenerated/commands/get_current_position.toml b/plugins/geolocation/permissions/autogenerated/commands/get_current_position.toml new file mode 100644 index 00000000..fefb951b --- /dev/null +++ b/plugins/geolocation/permissions/autogenerated/commands/get_current_position.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-get-current-position" +description = "Enables the get_current_position command without any pre-configured scope." +commands.allow = ["get_current_position"] + +[[permission]] +identifier = "deny-get-current-position" +description = "Denies the get_current_position command without any pre-configured scope." +commands.deny = ["get_current_position"] diff --git a/plugins/geolocation/permissions/autogenerated/commands/request_permissions.toml b/plugins/geolocation/permissions/autogenerated/commands/request_permissions.toml new file mode 100644 index 00000000..02dcd627 --- /dev/null +++ b/plugins/geolocation/permissions/autogenerated/commands/request_permissions.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-request-permissions" +description = "Enables the request_permissions command without any pre-configured scope." +commands.allow = ["request_permissions"] + +[[permission]] +identifier = "deny-request-permissions" +description = "Denies the request_permissions command without any pre-configured scope." +commands.deny = ["request_permissions"] diff --git a/plugins/geolocation/permissions/autogenerated/commands/watch_position.toml b/plugins/geolocation/permissions/autogenerated/commands/watch_position.toml new file mode 100644 index 00000000..5878ba1a --- /dev/null +++ b/plugins/geolocation/permissions/autogenerated/commands/watch_position.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-watch-position" +description = "Enables the watch_position command without any pre-configured scope." +commands.allow = ["watch_position"] + +[[permission]] +identifier = "deny-watch-position" +description = "Denies the watch_position command without any pre-configured scope." +commands.deny = ["watch_position"] diff --git a/plugins/geolocation/permissions/autogenerated/reference.md b/plugins/geolocation/permissions/autogenerated/reference.md new file mode 100644 index 00000000..71d81a72 --- /dev/null +++ b/plugins/geolocation/permissions/autogenerated/reference.md @@ -0,0 +1,166 @@ + +## Permission Table + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IdentifierDescription
+ +`geolocation:allow-check-permissions` + + + +Enables the check_permissions command without any pre-configured scope. + +
+ +`geolocation:deny-check-permissions` + + + +Denies the check_permissions command without any pre-configured scope. + +
+ +`geolocation:allow-clear-permissions` + + + +Enables the clear_permissions command without any pre-configured scope. + +
+ +`geolocation:deny-clear-permissions` + + + +Denies the clear_permissions command without any pre-configured scope. + +
+ +`geolocation:allow-clear-watch` + + + +Enables the clear_watch command without any pre-configured scope. + +
+ +`geolocation:deny-clear-watch` + + + +Denies the clear_watch command without any pre-configured scope. + +
+ +`geolocation:allow-get-current-position` + + + +Enables the get_current_position command without any pre-configured scope. + +
+ +`geolocation:deny-get-current-position` + + + +Denies the get_current_position command without any pre-configured scope. + +
+ +`geolocation:allow-request-permissions` + + + +Enables the request_permissions command without any pre-configured scope. + +
+ +`geolocation:deny-request-permissions` + + + +Denies the request_permissions command without any pre-configured scope. + +
+ +`geolocation:allow-watch-position` + + + +Enables the watch_position command without any pre-configured scope. + +
+ +`geolocation:deny-watch-position` + + + +Denies the watch_position command without any pre-configured scope. + +
diff --git a/plugins/geolocation/permissions/schemas/schema.json b/plugins/geolocation/permissions/schemas/schema.json new file mode 100644 index 00000000..237b445d --- /dev/null +++ b/plugins/geolocation/permissions/schemas/schema.json @@ -0,0 +1,372 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "PermissionFile", + "description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.", + "type": "object", + "properties": { + "default": { + "description": "The default permission set for the plugin", + "anyOf": [ + { + "$ref": "#/definitions/DefaultPermission" + }, + { + "type": "null" + } + ] + }, + "set": { + "description": "A list of permissions sets defined", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionSet" + } + }, + "permission": { + "description": "A list of inlined permissions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Permission" + } + } + }, + "definitions": { + "DefaultPermission": { + "description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.", + "type": "object", + "required": [ + "permissions" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "PermissionSet": { + "description": "A set of direct permissions grouped together under a new name.", + "type": "object", + "required": [ + "description", + "identifier", + "permissions" + ], + "properties": { + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does.", + "type": "string" + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionKind" + } + } + } + }, + "Permission": { + "description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.", + "type": "object", + "required": [ + "identifier" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri internal convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "commands": { + "description": "Allowed or denied commands when using this permission.", + "default": { + "allow": [], + "deny": [] + }, + "allOf": [ + { + "$ref": "#/definitions/Commands" + } + ] + }, + "scope": { + "description": "Allowed or denied scoped when using this permission.", + "allOf": [ + { + "$ref": "#/definitions/Scopes" + } + ] + }, + "platforms": { + "description": "Target platforms this permission applies. By default all platforms are affected by this permission.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Target" + } + } + } + }, + "Commands": { + "description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.", + "type": "object", + "properties": { + "allow": { + "description": "Allowed command.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "deny": { + "description": "Denied command, which takes priority.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "Scopes": { + "description": "An argument for fine grained behavior control of Tauri commands.\n\nIt can be of any serde serializable type and is used to allow or prevent certain actions inside a Tauri command. The configured scope is passed to the command and will be enforced by the command implementation.\n\n## Example\n\n```json { \"allow\": [{ \"path\": \"$HOME/**\" }], \"deny\": [{ \"path\": \"$HOME/secret.txt\" }] } ```", + "type": "object", + "properties": { + "allow": { + "description": "Data that defines what is allowed by the scope.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + }, + "deny": { + "description": "Data that defines what is denied by the scope. This should be prioritized by validation logic.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + } + } + }, + "Value": { + "description": "All supported ACL values.", + "anyOf": [ + { + "description": "Represents a null JSON value.", + "type": "null" + }, + { + "description": "Represents a [`bool`].", + "type": "boolean" + }, + { + "description": "Represents a valid ACL [`Number`].", + "allOf": [ + { + "$ref": "#/definitions/Number" + } + ] + }, + { + "description": "Represents a [`String`].", + "type": "string" + }, + { + "description": "Represents a list of other [`Value`]s.", + "type": "array", + "items": { + "$ref": "#/definitions/Value" + } + }, + { + "description": "Represents a map of [`String`] keys to [`Value`]s.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/Value" + } + } + ] + }, + "Number": { + "description": "A valid ACL number.", + "anyOf": [ + { + "description": "Represents an [`i64`].", + "type": "integer", + "format": "int64" + }, + { + "description": "Represents a [`f64`].", + "type": "number", + "format": "double" + } + ] + }, + "Target": { + "description": "Platform target.", + "oneOf": [ + { + "description": "MacOS.", + "type": "string", + "enum": [ + "macOS" + ] + }, + { + "description": "Windows.", + "type": "string", + "enum": [ + "windows" + ] + }, + { + "description": "Linux.", + "type": "string", + "enum": [ + "linux" + ] + }, + { + "description": "Android.", + "type": "string", + "enum": [ + "android" + ] + }, + { + "description": "iOS.", + "type": "string", + "enum": [ + "iOS" + ] + } + ] + }, + "PermissionKind": { + "type": "string", + "oneOf": [ + { + "description": "Enables the check_permissions command without any pre-configured scope.", + "type": "string", + "const": "allow-check-permissions", + "markdownDescription": "Enables the check_permissions command without any pre-configured scope." + }, + { + "description": "Denies the check_permissions command without any pre-configured scope.", + "type": "string", + "const": "deny-check-permissions", + "markdownDescription": "Denies the check_permissions command without any pre-configured scope." + }, + { + "description": "Enables the clear_permissions command without any pre-configured scope.", + "type": "string", + "const": "allow-clear-permissions", + "markdownDescription": "Enables the clear_permissions command without any pre-configured scope." + }, + { + "description": "Denies the clear_permissions command without any pre-configured scope.", + "type": "string", + "const": "deny-clear-permissions", + "markdownDescription": "Denies the clear_permissions command without any pre-configured scope." + }, + { + "description": "Enables the clear_watch command without any pre-configured scope.", + "type": "string", + "const": "allow-clear-watch", + "markdownDescription": "Enables the clear_watch command without any pre-configured scope." + }, + { + "description": "Denies the clear_watch command without any pre-configured scope.", + "type": "string", + "const": "deny-clear-watch", + "markdownDescription": "Denies the clear_watch command without any pre-configured scope." + }, + { + "description": "Enables the get_current_position command without any pre-configured scope.", + "type": "string", + "const": "allow-get-current-position", + "markdownDescription": "Enables the get_current_position command without any pre-configured scope." + }, + { + "description": "Denies the get_current_position command without any pre-configured scope.", + "type": "string", + "const": "deny-get-current-position", + "markdownDescription": "Denies the get_current_position command without any pre-configured scope." + }, + { + "description": "Enables the request_permissions command without any pre-configured scope.", + "type": "string", + "const": "allow-request-permissions", + "markdownDescription": "Enables the request_permissions command without any pre-configured scope." + }, + { + "description": "Denies the request_permissions command without any pre-configured scope.", + "type": "string", + "const": "deny-request-permissions", + "markdownDescription": "Denies the request_permissions command without any pre-configured scope." + }, + { + "description": "Enables the watch_position command without any pre-configured scope.", + "type": "string", + "const": "allow-watch-position", + "markdownDescription": "Enables the watch_position command without any pre-configured scope." + }, + { + "description": "Denies the watch_position command without any pre-configured scope.", + "type": "string", + "const": "deny-watch-position", + "markdownDescription": "Denies the watch_position command without any pre-configured scope." + } + ] + } + } +} \ No newline at end of file diff --git a/plugins/geolocation/rollup.config.js b/plugins/geolocation/rollup.config.js new file mode 100644 index 00000000..1f349ec8 --- /dev/null +++ b/plugins/geolocation/rollup.config.js @@ -0,0 +1,7 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import { createConfig } from '../../shared/rollup.config.js' + +export default createConfig() diff --git a/plugins/geolocation/src/commands.rs b/plugins/geolocation/src/commands.rs new file mode 100644 index 00000000..d2cae848 --- /dev/null +++ b/plugins/geolocation/src/commands.rs @@ -0,0 +1,42 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use tauri::{command, ipc::Channel, AppHandle, Runtime}; + +use crate::{GeolocationExt, PermissionStatus, PermissionType, Position, PositionOptions, Result}; + +#[command] +pub(crate) async fn get_current_position( + app: AppHandle, + options: Option, +) -> Result { + app.geolocation().get_current_position(options) +} + +#[command] +pub(crate) async fn watch_position( + app: AppHandle, + options: PositionOptions, + channel: Channel, +) -> Result<()> { + app.geolocation().watch_position_inner(options, channel) +} + +#[command] +pub(crate) async fn clear_watch(app: AppHandle, channel_id: u32) -> Result<()> { + app.geolocation().clear_watch(channel_id) +} + +#[command] +pub(crate) async fn check_permissions(app: AppHandle) -> Result { + app.geolocation().check_permissions() +} + +#[command] +pub(crate) async fn request_permissions( + app: AppHandle, + permissions: Option>, +) -> Result { + app.geolocation().request_permissions(permissions) +} diff --git a/plugins/geolocation/src/desktop.rs b/plugins/geolocation/src/desktop.rs new file mode 100644 index 00000000..00da1fad --- /dev/null +++ b/plugins/geolocation/src/desktop.rs @@ -0,0 +1,95 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use serde::{de::DeserializeOwned, Serialize}; +use tauri::{ + ipc::{Channel, InvokeResponseBody}, + plugin::PluginApi, + AppHandle, Runtime, +}; + +use crate::models::*; + +pub fn init( + app: &AppHandle, + _api: PluginApi, +) -> crate::Result> { + Ok(Geolocation(app.clone())) +} + +/// Access to the geolocation APIs. +pub struct Geolocation(AppHandle); + +impl Geolocation { + pub fn get_current_position( + &self, + _options: Option, + ) -> crate::Result { + Ok(Position::default()) + } + + pub fn watch_position( + &self, + options: PositionOptions, + callback: F, + ) -> crate::Result { + let channel = Channel::new(move |event| { + let payload = match event { + InvokeResponseBody::Json(payload) => serde_json::from_str::(&payload) + .unwrap_or_else(|error| { + WatchEvent::Error(format!( + "Couldn't deserialize watch event payload: `{error}`" + )) + }), + _ => WatchEvent::Error("Unexpected watch event payload.".to_string()), + }; + + callback(payload); + + Ok(()) + }); + let id = channel.id(); + + self.watch_position_inner(options, channel)?; + + Ok(id) + } + + pub(crate) fn watch_position_inner( + &self, + _options: PositionOptions, + _callback_channel: Channel, + ) -> crate::Result<()> { + Ok(()) + } + + pub fn clear_watch(&self, _channel_id: u32) -> crate::Result<()> { + Ok(()) + } + + pub fn check_permissions(&self) -> crate::Result { + Ok(PermissionStatus::default()) + } + + pub fn request_permissions( + &self, + _permissions: Option>, + ) -> crate::Result { + Ok(PermissionStatus::default()) + } +} + +#[derive(Serialize)] +#[allow(unused)] // TODO: +struct WatchPayload { + options: PositionOptions, + channel: Channel, +} + +#[derive(Serialize)] +#[serde(rename_all = "camelCase")] +#[allow(unused)] // TODO: +struct ClearWatchPayload { + channel_id: u32, +} diff --git a/plugins/geolocation/src/error.rs b/plugins/geolocation/src/error.rs new file mode 100644 index 00000000..0fba5445 --- /dev/null +++ b/plugins/geolocation/src/error.rs @@ -0,0 +1,30 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use serde::{ser::Serializer, Serialize}; + +pub type Result = std::result::Result; + +// TODO: Improve Error handling (different typed errors instead of one (stringified) PluginInvokeError for all mobile errors) + +#[derive(Debug, thiserror::Error)] +#[cfg_attr(feature = "specta", derive(specta::Type))] +pub enum Error { + #[cfg(mobile)] + #[error(transparent)] + PluginInvoke( + #[cfg_attr(feature = "specta", serde(skip))] + #[from] + tauri::plugin::mobile::PluginInvokeError, + ), +} + +impl Serialize for Error { + fn serialize(&self, serializer: S) -> std::result::Result + where + S: Serializer, + { + serializer.serialize_str(self.to_string().as_ref()) + } +} diff --git a/plugins/geolocation/src/lib.rs b/plugins/geolocation/src/lib.rs new file mode 100644 index 00000000..588f96e3 --- /dev/null +++ b/plugins/geolocation/src/lib.rs @@ -0,0 +1,58 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use tauri::{ + plugin::{Builder, TauriPlugin}, + Manager, Runtime, +}; + +pub use models::*; + +#[cfg(desktop)] +mod desktop; +#[cfg(mobile)] +mod mobile; + +mod commands; +mod error; +mod models; + +pub use error::{Error, Result}; + +#[cfg(desktop)] +pub use desktop::Geolocation; +#[cfg(mobile)] +pub use mobile::Geolocation; + +/// Extensions to [`tauri::App`], [`tauri::AppHandle`], [`tauri::WebviewWindow`], [`tauri::Webview`] and [`tauri::Window`] to access the geolocation APIs. +pub trait GeolocationExt { + fn geolocation(&self) -> &Geolocation; +} + +impl> crate::GeolocationExt for T { + fn geolocation(&self) -> &Geolocation { + self.state::>().inner() + } +} + +/// Initializes the plugin. +pub fn init() -> TauriPlugin { + Builder::new("geolocation") + .invoke_handler(tauri::generate_handler![ + commands::get_current_position, + commands::watch_position, + commands::clear_watch, + commands::check_permissions, + commands::request_permissions + ]) + .setup(|app, api| { + #[cfg(mobile)] + let geolocation = mobile::init(app, api)?; + #[cfg(desktop)] + let geolocation = desktop::init(app, api)?; + app.manage(geolocation); + Ok(()) + }) + .build() +} diff --git a/plugins/geolocation/src/mobile.rs b/plugins/geolocation/src/mobile.rs new file mode 100644 index 00000000..48a3f5de --- /dev/null +++ b/plugins/geolocation/src/mobile.rs @@ -0,0 +1,119 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use serde::{de::DeserializeOwned, Serialize}; +use tauri::{ + ipc::{Channel, InvokeResponseBody}, + plugin::{PluginApi, PluginHandle}, + AppHandle, Runtime, +}; + +use crate::models::*; + +#[cfg(target_os = "android")] +const PLUGIN_IDENTIFIER: &str = "app.tauri.geolocation"; + +#[cfg(target_os = "ios")] +tauri::ios_plugin_binding!(init_plugin_geolocation); + +// initializes the Kotlin or Swift plugin classes +pub fn init( + _app: &AppHandle, + api: PluginApi, +) -> crate::Result> { + #[cfg(target_os = "android")] + let handle = api.register_android_plugin(PLUGIN_IDENTIFIER, "GeolocationPlugin")?; + #[cfg(target_os = "ios")] + let handle = api.register_ios_plugin(init_plugin_geolocation)?; + Ok(Geolocation(handle)) +} + +/// Access to the geolocation APIs. +pub struct Geolocation(PluginHandle); + +impl Geolocation { + pub fn get_current_position( + &self, + options: Option, + ) -> crate::Result { + // TODO: We may have to send over None if that's better on Android + self.0 + .run_mobile_plugin("getCurrentPosition", options.unwrap_or_default()) + .map_err(Into::into) + } + + /// Register a position watcher. This method returns an id to use in `clear_watch`. + pub fn watch_position( + &self, + options: PositionOptions, + callback: F, + ) -> crate::Result { + let channel = Channel::new(move |event| { + let payload = match event { + InvokeResponseBody::Json(payload) => serde_json::from_str::(&payload) + .unwrap_or_else(|error| { + WatchEvent::Error(format!( + "Couldn't deserialize watch event payload: `{error}`" + )) + }), + _ => WatchEvent::Error("Unexpected watch event payload.".to_string()), + }; + + callback(payload); + + Ok(()) + }); + let id = channel.id(); + + self.watch_position_inner(options, channel)?; + + Ok(id) + } + + pub(crate) fn watch_position_inner( + &self, + options: PositionOptions, + channel: Channel, + ) -> crate::Result<()> { + self.0 + .run_mobile_plugin("watchPosition", WatchPayload { options, channel }) + .map_err(Into::into) + } + + pub fn clear_watch(&self, channel_id: u32) -> crate::Result<()> { + self.0 + .run_mobile_plugin("clearWatch", ClearWatchPayload { channel_id }) + .map_err(Into::into) + } + + pub fn check_permissions(&self) -> crate::Result { + self.0 + .run_mobile_plugin("checkPermissions", ()) + .map_err(Into::into) + } + + pub fn request_permissions( + &self, + permissions: Option>, + ) -> crate::Result { + self.0 + .run_mobile_plugin( + "requestPermissions", + serde_json::json!({ "permissions": permissions }), + ) + .map_err(Into::into) + } +} + +#[derive(Serialize)] +struct WatchPayload { + options: PositionOptions, + channel: Channel, +} + +#[derive(Serialize)] +#[serde(rename_all = "camelCase")] +struct ClearWatchPayload { + channel_id: u32, +} diff --git a/plugins/geolocation/src/models.rs b/plugins/geolocation/src/models.rs new file mode 100644 index 00000000..c08bb27a --- /dev/null +++ b/plugins/geolocation/src/models.rs @@ -0,0 +1,96 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use serde::{Deserialize, Serialize}; +use tauri::plugin::PermissionState; + +#[derive(Debug, Clone, Default, Serialize, Deserialize)] +#[cfg_attr(feature = "specta", derive(specta::Type))] +#[serde(rename_all = "camelCase")] +pub struct PermissionStatus { + /// Permission state for the location alias. + /// + /// On Android it requests/checks both ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION permissions. + /// + /// On iOS it requests/checks location permissions. + pub location: PermissionState, + /// Permissions state for the coarseLoaction alias. + /// + /// On Android it requests/checks ACCESS_COARSE_LOCATION. + /// + /// On Android 12+, users can choose between Approximate location (ACCESS_COARSE_LOCATION) and Precise location (ACCESS_FINE_LOCATION). + /// + /// On iOS it will have the same value as the `location` alias. + pub coarse_location: PermissionState, +} + +#[derive(Debug, Clone, Default, Serialize, Deserialize)] +#[cfg_attr(feature = "specta", derive(specta::Type))] +#[serde(rename_all = "camelCase")] +pub struct PositionOptions { + /// High accuracy mode (such as GPS, if available) + /// Will be ignored on Android 12+ if users didn't grant the ACCESS_FINE_LOCATION permission. + pub enable_high_accuracy: bool, + /// The maximum wait time in milliseconds for location updates. + /// Default: 10000 + /// On Android the timeout gets ignored for getCurrentPosition. + /// Ignored on iOS. + // TODO: Handle Infinity and default to it. + // TODO: Should be u64+ but specta doesn't like that? + pub timeout: u32, + /// The maximum age in milliseconds of a possible cached position that is acceptable to return. + /// Default: 0 + /// Ignored on iOS. + // TODO: Handle Infinity. + // TODO: Should be u64+ but specta doesn't like that? + pub maximum_age: u32, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(feature = "specta", derive(specta::Type))] +#[serde(rename_all = "camelCase")] +pub enum PermissionType { + Location, + CoarseLocation, +} + +#[derive(Debug, Clone, Default, Serialize, Deserialize)] +#[cfg_attr(feature = "specta", derive(specta::Type))] +#[serde(rename_all = "camelCase")] +pub struct Coordinates { + /// Latitude in decimal degrees. + pub latitude: f64, + /// Longitude in decimal degrees. + pub longitude: f64, + /// Accuracy level of the latitude and longitude coordinates in meters. + pub accuracy: f64, + /// Accuracy level of the altitude coordinate in meters, if available. + /// Available on all iOS versions and on Android 8 and above. + pub altitude_accuracy: Option, + /// The altitude the user is at, if available. + pub altitude: Option, + // The speed the user is traveling, if available. + pub speed: Option, + /// The heading the user is facing, if available. + pub heading: Option, +} + +#[derive(Debug, Clone, Default, Serialize, Deserialize)] +#[cfg_attr(feature = "specta", derive(specta::Type))] +#[serde(rename_all = "camelCase")] +pub struct Position { + /// Creation time for these coordinates. + // TODO: Check if we're actually losing precision. + pub timestamp: u64, + /// The GPS coordinates along with the accuracy of the data. + pub coords: Coordinates, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(feature = "specta", derive(specta::Type))] +#[serde(untagged)] +pub enum WatchEvent { + Position(Position), + Error(String), +} diff --git a/plugins/geolocation/tsconfig.json b/plugins/geolocation/tsconfig.json new file mode 100644 index 00000000..5098169a --- /dev/null +++ b/plugins/geolocation/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.base.json", + "include": ["guest-js/*.ts"] +} diff --git a/plugins/global-shortcut/CHANGELOG.md b/plugins/global-shortcut/CHANGELOG.md index 3109c03f..a5f00024 100644 --- a/plugins/global-shortcut/CHANGELOG.md +++ b/plugins/global-shortcut/CHANGELOG.md @@ -1,5 +1,106 @@ # Changelog +## \[2.2.1] + +- [`494d1fea`](https://github.com/tauri-apps/plugins-workspace/commit/494d1fea137ffd60da98b25305c9d666df62cc63) ([#2684](https://github.com/tauri-apps/plugins-workspace/pull/2684) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Updated `global-hotkey` crate to `0.7` to fix a panic when trying to register a key combination which was already registered by another program. No API changes. + +## \[2.2.0] + +- [`3a79266b`](https://github.com/tauri-apps/plugins-workspace/commit/3a79266b8cf96a55b1ae6339d725567d45a44b1d) ([#2173](https://github.com/tauri-apps/plugins-workspace/pull/2173) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Bumped all plugins to `v2.2.0`. From now, the versions for the Rust and JavaScript packages of each plugin will be in sync with each other. + +## \[2.0.1] + +- [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. + +## \[2.0.0] + +- [`e2c4dfb6`](https://github.com/tauri-apps/plugins-workspace/commit/e2c4dfb6af43e5dd8d9ceba232c315f5febd55c1) Update to tauri v2 stable release. + +## \[2.0.0-rc.1] + +- [`e2e97db5`](https://github.com/tauri-apps/plugins-workspace/commit/e2e97db51983267f5be84d4f6f0278d58834d1f5) ([#1701](https://github.com/tauri-apps/plugins-workspace/pull/1701) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri 2.0.0-rc.8 + +## \[2.0.0-rc.1] + +- [`2c00c029`](https://github.com/tauri-apps/plugins-workspace/commit/2c00c0292c9127b81567de46691e8c0f73557261) ([#1630](https://github.com/tauri-apps/plugins-workspace/pull/1630) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Fixed an issue that caused multi-word IIFE names to not be formatted correctly. For example the `barcode-scanner` was defined as `window.__TAURI_PLUGIN_CLIPBOARDMANAGER__` instead of `window.__TAURI_PLUGIN_CLIPBOARD_MANAGER__`. + +## \[2.0.0-rc.0] + +- [`9887d1`](https://github.com/tauri-apps/plugins-workspace/commit/9887d14bd0e971c4c0f5c1188fc4005d3fc2e29e) Update to tauri RC. + +## \[2.0.0-beta.8] + +- [`99d6ac0f`](https://github.com/tauri-apps/plugins-workspace/commit/99d6ac0f9506a6a4a1aa59c728157190a7441af6) ([#1606](https://github.com/tauri-apps/plugins-workspace/pull/1606) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) The JS packages now specify the *minimum* `@tauri-apps/api` version instead of a single exact version. +- [`6de87966`](https://github.com/tauri-apps/plugins-workspace/commit/6de87966ecc00ad9d91c25be452f1f46bd2b7e1f) ([#1597](https://github.com/tauri-apps/plugins-workspace/pull/1597) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Update to tauri beta.25. + +## \[2.0.0-beta.7] + +- [`381a466d`](https://github.com/tauri-apps/plugins-workspace/commit/381a466db344e59a76b2a4d5785b2a0b64d4d373) ([#1117](https://github.com/tauri-apps/plugins-workspace/pull/1117) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Refactored the JS APIs: + + - Enhanced `register` and `unregister` to take either a single shortcut or an array. + - Removed `registerAll` instead use `register` with an array. +- [`22a17980`](https://github.com/tauri-apps/plugins-workspace/commit/22a17980ff4f6f8c40adb1b8f4ffc6dae2fe7e30) ([#1537](https://github.com/tauri-apps/plugins-workspace/pull/1537) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri beta.24. + +## \[2.0.0-beta.6] + +- [`76daee7a`](https://github.com/tauri-apps/plugins-workspace/commit/76daee7aafece34de3092c86e531cf9eb1138989) ([#1512](https://github.com/tauri-apps/plugins-workspace/pull/1512) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Update to tauri beta.23. + +## \[2.0.0-beta.5] + +- [`9013854f`](https://github.com/tauri-apps/plugins-workspace/commit/9013854f42a49a230b9dbb9d02774765528a923f)([#1382](https://github.com/tauri-apps/plugins-workspace/pull/1382)) Update to tauri beta.22. + +## \[2.0.0-beta.4] + +- [`430bd6f4`](https://github.com/tauri-apps/plugins-workspace/commit/430bd6f4f379bee5d232ae6b098ae131db7f178a)([#1363](https://github.com/tauri-apps/plugins-workspace/pull/1363)) Update to tauri beta.20. + +## \[2.0.0-beta.3] + +- [`9c7eb359`](https://github.com/tauri-apps/plugins-workspace/commit/9c7eb35967ad10659eb4976bd6f77d9d270bfeed)([#1244](https://github.com/tauri-apps/plugins-workspace/pull/1244)) Refactored APIs to introduce new pressed and released events: + + - Added `ShortcutEvent` and `ShortcutState` types in Rust. + - Changed the handler function passed to `GlobalShortcut::on_shortcut`, `GlobalShortcut::on_all_shortcuts` and `Builder::with_handler` to take a 3rd argument of type `ShortcutEvent`. + - Added `ShortcutEvent` interface in JS. + - Changed `ShortcutHandler` type alias (which affects the JS `register` and `registerAll` APIs) to take `ShortcutEvent` instead of a string. +- [`bd1ed590`](https://github.com/tauri-apps/plugins-workspace/commit/bd1ed5903ffcce5500310dac1e59e8c67674ef1e)([#1237](https://github.com/tauri-apps/plugins-workspace/pull/1237)) Update to tauri beta.17. + +## \[2.0.0-beta.3] + +- [`a04ea2f`](https://github.com/tauri-apps/plugins-workspace/commit/a04ea2f38294d5a3987578283badc8eec87a7752)([#1071](https://github.com/tauri-apps/plugins-workspace/pull/1071)) The global API script is now only added to the binary when the `withGlobalTauri` config is true. +- [`62dafda`](https://github.com/tauri-apps/plugins-workspace/commit/62dafda6526899b407a7c5a1bb269c5c0dfb2630)([#969](https://github.com/tauri-apps/plugins-workspace/pull/969)) **Breaking change** Refactored the plugin Rust APIs for better DX and flexibility: + + - Changed `Builder::with_handler` to be a method instead of a static method, it will also be triggered for any and all shortcuts even if the shortcut is registered through JS. + - Added `Builder::with_shortcut` and `Builder::with_shortcuts` to register shortcuts on the plugin builder. + - Added `on_shortcut` and `on_all_shortcuts` to register shortcuts with a handler. + +## \[2.0.0-beta.2] + +- [`99bea25`](https://github.com/tauri-apps/plugins-workspace/commit/99bea2559c2c0648c2519c50a18cd124dacef57b)([#1005](https://github.com/tauri-apps/plugins-workspace/pull/1005)) Update to tauri beta.8. + +## \[2.0.0-beta.1] + +- [`569defb`](https://github.com/tauri-apps/plugins-workspace/commit/569defbe9492e38938554bb7bdc1be9151456d21) Update to tauri beta.4. + +## \[2.0.0-beta.0] + +- [`d198c01`](https://github.com/tauri-apps/plugins-workspace/commit/d198c014863ee260cb0de88a14b7fc4356ef7474)([#862](https://github.com/tauri-apps/plugins-workspace/pull/862)) Update to tauri beta. +- [`d198c01`](https://github.com/tauri-apps/plugins-workspace/commit/d198c014863ee260cb0de88a14b7fc4356ef7474)([#862](https://github.com/tauri-apps/plugins-workspace/pull/862)) Add permissions. + +## \[2.0.0-alpha.5] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.13. + +## \[2.0.0-alpha.4] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.12. + +## \[2.0.0-alpha.3] + +- [`e438e0a`](https://github.com/tauri-apps/plugins-workspace/commit/e438e0a62d4b430a5159f05f13ecd397dd891a0d)([#676](https://github.com/tauri-apps/plugins-workspace/pull/676)) Update to @tauri-apps/api v2.0.0-alpha.11. + +## \[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.9. + ## \[2.0.0-alpha.2] - [`4e2cef9`](https://github.com/tauri-apps/plugins-workspace/commit/4e2cef9b702bbbb9cf4ee17de50791cb21f1b2a4)([#593](https://github.com/tauri-apps/plugins-workspace/pull/593)) Update to alpha.12. @@ -10,9 +111,4 @@ ## \[2.0.0-alpha.0] -- [`717ae67`](https://github.com/tauri-apps/plugins-workspace/commit/717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! - te to alpha.11. - -## \[2.0.0-alpha.0] - - [`717ae67`](https://github.com/tauri-apps/plugins-workspace/commit/717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! diff --git a/plugins/global-shortcut/Cargo.toml b/plugins/global-shortcut/Cargo.toml index 236ba171..033961a8 100644 --- a/plugins/global-shortcut/Cargo.toml +++ b/plugins/global-shortcut/Cargo.toml @@ -1,14 +1,27 @@ [package] name = "tauri-plugin-global-shortcut" -version = "2.0.0-alpha.2" +version = "2.2.1" description = "Register global hotkeys listeners on your Tauri application." edition = { workspace = true } authors = { workspace = true } license = { workspace = true } rust-version = { workspace = true } +repository = { workspace = true } +links = "tauri-plugin-global-shortcut" [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] + +[package.metadata.platforms.support] +windows = { level = "full", notes = "" } +linux = { level = "full", notes = "" } +macos = { level = "full", notes = "" } +android = { level = "none", notes = "" } +ios = { level = "none", notes = "" } + +[build-dependencies] +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } @@ -18,4 +31,4 @@ log = { workspace = true } thiserror = { workspace = true } [target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies] -global-hotkey = "0.2.1" +global-hotkey = { version = "0.7", features = ["serde"] } diff --git a/plugins/global-shortcut/README.md b/plugins/global-shortcut/README.md index 5ef53b59..53e7b19f 100644 --- a/plugins/global-shortcut/README.md +++ b/plugins/global-shortcut/README.md @@ -2,11 +2,17 @@ Register global shortcuts. -- Supported platforms: Windows, Linux and macOS. +| Platform | Supported | +| -------- | --------- | +| Linux | ✓ | +| Windows | ✓ | +| macOS | ✓ | +| Android | x | +| iOS | x | ## Install -_This plugin requires a Rust version of at least **1.70**_ +_This plugin requires a Rust version of at least **1.77.2**_ There are three general methods of installation that we can recommend. @@ -21,9 +27,9 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml # you can add the dependencies on the `[dependencies]` section if you do not target mobile [target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies] -tauri-plugin-global-shortcut = "2.0.0-alpha" +tauri-plugin-global-shortcut = "2.0.0" # alternatively with Git: -tauri-plugin-shortcut = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } +tauri-plugin-global-shortcut = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` You can install the JavaScript Guest bindings using your preferred JavaScript package manager: @@ -49,14 +55,34 @@ yarn add https://github.com/tauri-apps/tauri-plugin-global-shortcut#v2 First you need to register the core plugin with Tauri: -`src-tauri/src/main.rs` +`src-tauri/src/lib.rs` ```rust fn main() { tauri::Builder::default() .setup(|app| { #[cfg(desktop)] - app.handle().plugin(tauri_plugin_shortcut::init())?; + { + use tauri::Manager; + use tauri_plugin_global_shortcut::{Code, Modifiers, ShortcutState}; + + app.handle().plugin( + tauri_plugin_global_shortcut::Builder::new() + .with_shortcuts(["ctrl+d", "alt+space"])? + .with_handler(|app, shortcut, event| { + if event.state == ShortcutState::Pressed { + if shortcut.matches(Modifiers::CONTROL, Code::KeyD) { + let _ = app.emit("shortcut-event", "Ctrl+D triggered"); + } + if shortcut.matches(Modifiers::ALT, Code::Space) { + let _ = app.emit("shortcut-event", "Alt+Space triggered"); + } + } + }) + .build(), + )?; + } + Ok(()) }) .run(tauri::generate_context!()) @@ -64,16 +90,37 @@ fn main() { } ``` -Afterwards all the plugin's APIs are available through the JavaScript guest bindings: +Afterwards all the plugin's APIs are available through the JavaScript bindings: ```javascript - +import { register } from '@tauri-apps/plugin-global-shortcut' +await register('CommandOrControl+Shift+C', (event) => { + if (event.state === 'Pressed') { + console.log('Shortcut triggered') + } +}) ``` ## Contributing PRs accepted. Please make sure to read the Contributing Guide before making a pull request. +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + ## License Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. diff --git a/plugins/global-shortcut/SECURITY.md b/plugins/global-shortcut/SECURITY.md new file mode 100644 index 00000000..4f09bbac --- /dev/null +++ b/plugins/global-shortcut/SECURITY.md @@ -0,0 +1,23 @@ +# Security Policy + +**Do not report security vulnerabilities through public GitHub issues.** + +**Please use the [Private Vulnerability Disclosure](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) feature of GitHub.** + +Include as much of the following information: + +- Type of issue (e.g. improper input parsing, privilege escalation, etc.) +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- The distribution affected or used to help us with reproduction of the issue +- Step-by-step instructions to reproduce the issue +- Ideally a reproduction repository +- Impact of the issue, including how an attacker might exploit the issue + +We prefer to receive reports in English. + +## Contact + +Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). + +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/global-shortcut/api-iife.js b/plugins/global-shortcut/api-iife.js new file mode 100644 index 00000000..8d4ae006 --- /dev/null +++ b/plugins/global-shortcut/api-iife.js @@ -0,0 +1 @@ +if("__TAURI__"in window){var __TAURI_PLUGIN_GLOBAL_SHORTCUT__=function(t){"use strict";function e(t,e,s,i){if("function"==typeof e||!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?i:"a"===s?i.call(t):i?i.value:e.get(t)}function s(t,e,s,i,r){if("function"==typeof e||!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,s),s}var i,r,n,a;"function"==typeof SuppressedError&&SuppressedError;const o="__TAURI_TO_IPC_KEY__";class c{constructor(t){i.set(this,void 0),r.set(this,0),n.set(this,[]),a.set(this,void 0),s(this,i,t||(()=>{})),this.id=function(t,e=!1){return window.__TAURI_INTERNALS__.transformCallback(t,e)}((t=>{const o=t.index;if("end"in t)return void(o==e(this,r,"f")?this.cleanupCallback():s(this,a,o));const c=t.message;if(o==e(this,r,"f")){for(e(this,i,"f").call(this,c),s(this,r,e(this,r,"f")+1);e(this,r,"f")in e(this,n,"f");){const t=e(this,n,"f")[e(this,r,"f")];e(this,i,"f").call(this,t),delete e(this,n,"f")[e(this,r,"f")],s(this,r,e(this,r,"f")+1)}e(this,r,"f")===e(this,a,"f")&&this.cleanupCallback()}else e(this,n,"f")[o]=c}))}cleanupCallback(){Reflect.deleteProperty(window,`_${this.id}`)}set onmessage(t){s(this,i,t)}get onmessage(){return e(this,i,"f")}[(i=new WeakMap,r=new WeakMap,n=new WeakMap,a=new WeakMap,o)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[o]()}}async function u(t,e={},s){return window.__TAURI_INTERNALS__.invoke(t,e,s)}return t.isRegistered=async function(t){return await u("plugin:global-shortcut|is_registered",{shortcut:t})},t.register=async function(t,e){const s=new c;return s.onmessage=e,await u("plugin:global-shortcut|register",{shortcuts:Array.isArray(t)?t:[t],handler:s})},t.unregister=async function(t){return await u("plugin:global-shortcut|unregister",{shortcuts:Array.isArray(t)?t:[t]})},t.unregisterAll=async function(){return await u("plugin:global-shortcut|unregister_all",{})},t}({});Object.defineProperty(window.__TAURI__,"globalShortcut",{value:__TAURI_PLUGIN_GLOBAL_SHORTCUT__})} diff --git a/plugins/global-shortcut/build.rs b/plugins/global-shortcut/build.rs new file mode 100644 index 00000000..20b7b7f8 --- /dev/null +++ b/plugins/global-shortcut/build.rs @@ -0,0 +1,11 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +const COMMANDS: &[&str] = &["register", "unregister", "unregister_all", "is_registered"]; + +fn main() { + tauri_plugin::Builder::new(COMMANDS) + .global_api_script_path("./api-iife.js") + .build(); +} diff --git a/plugins/global-shortcut/guest-js/index.ts b/plugins/global-shortcut/guest-js/index.ts index 77e1cb62..13e8e50e 100644 --- a/plugins/global-shortcut/guest-js/index.ts +++ b/plugins/global-shortcut/guest-js/index.ts @@ -8,17 +8,38 @@ * @module */ -import { invoke, Channel } from "@tauri-apps/api/primitives"; +import { invoke, Channel } from '@tauri-apps/api/core' -export type ShortcutHandler = (shortcut: string) => void; +export interface ShortcutEvent { + shortcut: string + id: number + state: 'Released' | 'Pressed' +} + +export type ShortcutHandler = (event: ShortcutEvent) => void /** - * Register a global shortcut. + * Register a global shortcut or a list of shortcuts. + * + * The handler is called when any of the registered shortcuts are pressed by the user. + * + * If the shortcut is already taken by another application, the handler will not be triggered. + * Make sure the shortcut is as unique as possible while still taking user experience into consideration. + * * @example * ```typescript * import { register } from '@tauri-apps/plugin-global-shortcut'; - * await register('CommandOrControl+Shift+C', () => { - * console.log('Shortcut triggered'); + * + * // register a single hotkey + * await register('CommandOrControl+Shift+C', (event) => { + * if (event.state === "Pressed") { + * console.log('Shortcut triggered'); + * } + * }); + * + * // or register multiple hotkeys at once + * await register(['CommandOrControl+Shift+C', 'Alt+A'], (event) => { + * console.log(`Shortcut ${event.shortcut} triggered`); * }); * ``` * @@ -28,97 +49,75 @@ export type ShortcutHandler = (shortcut: string) => void; * @since 2.0.0 */ async function register( - shortcut: string, - handler: ShortcutHandler, + shortcuts: string | string[], + handler: ShortcutHandler ): Promise { - const h = new Channel(); - h.onmessage = handler; + const h = new Channel() + h.onmessage = handler - return await invoke("plugin:globalShortcut|register", { - shortcut, - handler: h, - }); + return await invoke('plugin:global-shortcut|register', { + shortcuts: Array.isArray(shortcuts) ? shortcuts : [shortcuts], + handler: h + }) } /** - * Register a collection of global shortcuts. + * Unregister a global shortcut or a list of shortcuts. + * * @example * ```typescript - * import { registerAll } from '@tauri-apps/plugin-global-shortcut'; - * await registerAll(['CommandOrControl+Shift+C', 'Ctrl+Alt+F12'], (shortcut) => { - * console.log(`Shortcut ${shortcut} triggered`); - * }); + * import { unregister } from '@tauri-apps/plugin-global-shortcut'; + * + * // unregister a single hotkey + * await unregister('CmdOrControl+Space'); + * + * // or unregister multiple hotkeys at the same time + * await unregister(['CmdOrControl+Space', 'Alt+A']); * ``` * - * @param shortcuts Array of shortcut definitions, modifiers and key separated by "+" e.g. CmdOrControl+Q - * @param handler Shortcut handler callback - takes the triggered shortcut as argument + * @param shortcut shortcut definition (modifiers and key separated by "+" e.g. CmdOrControl+Q), also accepts a list of shortcuts * * @since 2.0.0 */ -async function registerAll( - shortcuts: string[], - handler: ShortcutHandler, -): Promise { - const h = new Channel(); - h.onmessage = handler; - - return await invoke("plugin:globalShortcut|register_all", { - shortcuts, - handler: h, - }); +async function unregister(shortcuts: string | string[]): Promise { + return await invoke('plugin:global-shortcut|unregister', { + shortcuts: Array.isArray(shortcuts) ? shortcuts : [shortcuts] + }) } /** - * Determines whether the given shortcut is registered by this application or not. - * - * If the shortcut is registered by another application, it will still return `false`. + * Unregister all global shortcuts. * * @example * ```typescript - * import { isRegistered } from '@tauri-apps/plugin-global-shortcut'; - * const isRegistered = await isRegistered('CommandOrControl+P'); + * import { unregisterAll } from '@tauri-apps/plugin-global-shortcut'; + * await unregisterAll(); * ``` - * - * @param shortcut shortcut definition, modifiers and key separated by "+" e.g. CmdOrControl+Q - * * @since 2.0.0 */ -async function isRegistered(shortcut: string): Promise { - return await invoke("plugin:globalShortcut|is_registered", { - shortcut, - }); +async function unregisterAll(): Promise { + return await invoke('plugin:global-shortcut|unregister_all', {}) } /** - * Unregister a global shortcut. - * @example - * ```typescript - * import { unregister } from '@tauri-apps/plugin-global-shortcut'; - * await unregister('CmdOrControl+Space'); - * ``` + * Determines whether the given shortcut is registered by this application or not. * - * @param shortcut shortcut definition, modifiers and key separated by "+" e.g. CmdOrControl+Q + * If the shortcut is registered by another application, it will still return `false`. * - * @since 2.0.0 - */ -async function unregister(shortcut: string): Promise { - return await invoke("plugin:globalShortcut|unregister", { - shortcut, - }); -} - -/** - * Unregisters all shortcuts registered by the application. * @example * ```typescript - * import { unregisterAll } from '@tauri-apps/plugin-global-shortcut'; - * await unregisterAll(); + * import { isRegistered } from '@tauri-apps/plugin-global-shortcut'; + * const isRegistered = await isRegistered('CommandOrControl+P'); * ``` * + * @param shortcut shortcut definition, modifiers and key separated by "+" e.g. CmdOrControl+Q + * * @since 2.0.0 */ -async function unregisterAll(): Promise { - return await invoke("plugin:globalShortcut|unregister_all"); +async function isRegistered(shortcut: string): Promise { + return await invoke('plugin:global-shortcut|is_registered', { + shortcut + }) } -export { register, registerAll, isRegistered, unregister, unregisterAll }; +export { register, unregister, unregisterAll, isRegistered } diff --git a/plugins/global-shortcut/package.json b/plugins/global-shortcut/package.json index ceef698d..2cdf65b6 100644 --- a/plugins/global-shortcut/package.json +++ b/plugins/global-shortcut/package.json @@ -1,32 +1,29 @@ { "name": "@tauri-apps/plugin-global-shortcut", - "version": "2.0.0-alpha.1", - "license": "MIT or APACHE-2.0", + "version": "2.2.1", + "license": "MIT OR Apache-2.0", "authors": [ "Tauri Programme within The Commons Conservancy" ], + "repository": "https://github.com/tauri-apps/plugins-workspace", "type": "module", - "browser": "dist-js/index.min.js", - "module": "dist-js/index.mjs", - "types": "dist-js/index.d.ts", + "types": "./dist-js/index.d.ts", + "main": "./dist-js/index.cjs", + "module": "./dist-js/index.js", "exports": { - "import": "./dist-js/index.mjs", "types": "./dist-js/index.d.ts", - "browser": "./dist-js/index.min.js" + "import": "./dist-js/index.js", + "require": "./dist-js/index.cjs" }, "scripts": { "build": "rollup -c" }, "files": [ "dist-js", - "!dist-js/**/*.map", "README.md", "LICENSE" ], - "devDependencies": { - "tslib": "^2.4.1" - }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.9" + "@tauri-apps/api": "^2.0.0" } } diff --git a/plugins/global-shortcut/permissions/autogenerated/commands/is_registered.toml b/plugins/global-shortcut/permissions/autogenerated/commands/is_registered.toml new file mode 100644 index 00000000..2dd73ace --- /dev/null +++ b/plugins/global-shortcut/permissions/autogenerated/commands/is_registered.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-is-registered" +description = "Enables the is_registered command without any pre-configured scope." +commands.allow = ["is_registered"] + +[[permission]] +identifier = "deny-is-registered" +description = "Denies the is_registered command without any pre-configured scope." +commands.deny = ["is_registered"] diff --git a/plugins/global-shortcut/permissions/autogenerated/commands/register.toml b/plugins/global-shortcut/permissions/autogenerated/commands/register.toml new file mode 100644 index 00000000..4eec17dc --- /dev/null +++ b/plugins/global-shortcut/permissions/autogenerated/commands/register.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-register" +description = "Enables the register command without any pre-configured scope." +commands.allow = ["register"] + +[[permission]] +identifier = "deny-register" +description = "Denies the register command without any pre-configured scope." +commands.deny = ["register"] diff --git a/plugins/global-shortcut/permissions/autogenerated/commands/register_all.toml b/plugins/global-shortcut/permissions/autogenerated/commands/register_all.toml new file mode 100644 index 00000000..df5d0ecf --- /dev/null +++ b/plugins/global-shortcut/permissions/autogenerated/commands/register_all.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-register-all" +description = "Enables the register_all command without any pre-configured scope." +commands.allow = ["register_all"] + +[[permission]] +identifier = "deny-register-all" +description = "Denies the register_all command without any pre-configured scope." +commands.deny = ["register_all"] diff --git a/plugins/global-shortcut/permissions/autogenerated/commands/unregister.toml b/plugins/global-shortcut/permissions/autogenerated/commands/unregister.toml new file mode 100644 index 00000000..5d33c97c --- /dev/null +++ b/plugins/global-shortcut/permissions/autogenerated/commands/unregister.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-unregister" +description = "Enables the unregister command without any pre-configured scope." +commands.allow = ["unregister"] + +[[permission]] +identifier = "deny-unregister" +description = "Denies the unregister command without any pre-configured scope." +commands.deny = ["unregister"] diff --git a/plugins/global-shortcut/permissions/autogenerated/commands/unregister_all.toml b/plugins/global-shortcut/permissions/autogenerated/commands/unregister_all.toml new file mode 100644 index 00000000..12c12f8b --- /dev/null +++ b/plugins/global-shortcut/permissions/autogenerated/commands/unregister_all.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-unregister-all" +description = "Enables the unregister_all command without any pre-configured scope." +commands.allow = ["unregister_all"] + +[[permission]] +identifier = "deny-unregister-all" +description = "Denies the unregister_all command without any pre-configured scope." +commands.deny = ["unregister_all"] diff --git a/plugins/global-shortcut/permissions/autogenerated/reference.md b/plugins/global-shortcut/permissions/autogenerated/reference.md new file mode 100644 index 00000000..dedb1aef --- /dev/null +++ b/plugins/global-shortcut/permissions/autogenerated/reference.md @@ -0,0 +1,150 @@ +## Default Permission + +No features are enabled by default, as we believe +the shortcuts can be inherently dangerous and it is +application specific if specific shortcuts should be +registered or unregistered. + + +#### This default permission set includes the following: + + +## Permission Table + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IdentifierDescription
+ +`global-shortcut:allow-is-registered` + + + +Enables the is_registered command without any pre-configured scope. + +
+ +`global-shortcut:deny-is-registered` + + + +Denies the is_registered command without any pre-configured scope. + +
+ +`global-shortcut:allow-register` + + + +Enables the register command without any pre-configured scope. + +
+ +`global-shortcut:deny-register` + + + +Denies the register command without any pre-configured scope. + +
+ +`global-shortcut:allow-register-all` + + + +Enables the register_all command without any pre-configured scope. + +
+ +`global-shortcut:deny-register-all` + + + +Denies the register_all command without any pre-configured scope. + +
+ +`global-shortcut:allow-unregister` + + + +Enables the unregister command without any pre-configured scope. + +
+ +`global-shortcut:deny-unregister` + + + +Denies the unregister command without any pre-configured scope. + +
+ +`global-shortcut:allow-unregister-all` + + + +Enables the unregister_all command without any pre-configured scope. + +
+ +`global-shortcut:deny-unregister-all` + + + +Denies the unregister_all command without any pre-configured scope. + +
diff --git a/plugins/global-shortcut/permissions/default.toml b/plugins/global-shortcut/permissions/default.toml new file mode 100644 index 00000000..fd32c51e --- /dev/null +++ b/plugins/global-shortcut/permissions/default.toml @@ -0,0 +1,10 @@ +"$schema" = "schemas/schema.json" +[default] +description = """ +No features are enabled by default, as we believe +the shortcuts can be inherently dangerous and it is +application specific if specific shortcuts should be +registered or unregistered. +""" + +permissions = [] diff --git a/plugins/global-shortcut/permissions/schemas/schema.json b/plugins/global-shortcut/permissions/schemas/schema.json new file mode 100644 index 00000000..1224869c --- /dev/null +++ b/plugins/global-shortcut/permissions/schemas/schema.json @@ -0,0 +1,366 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "PermissionFile", + "description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.", + "type": "object", + "properties": { + "default": { + "description": "The default permission set for the plugin", + "anyOf": [ + { + "$ref": "#/definitions/DefaultPermission" + }, + { + "type": "null" + } + ] + }, + "set": { + "description": "A list of permissions sets defined", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionSet" + } + }, + "permission": { + "description": "A list of inlined permissions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Permission" + } + } + }, + "definitions": { + "DefaultPermission": { + "description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.", + "type": "object", + "required": [ + "permissions" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "PermissionSet": { + "description": "A set of direct permissions grouped together under a new name.", + "type": "object", + "required": [ + "description", + "identifier", + "permissions" + ], + "properties": { + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does.", + "type": "string" + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionKind" + } + } + } + }, + "Permission": { + "description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.", + "type": "object", + "required": [ + "identifier" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri internal convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "commands": { + "description": "Allowed or denied commands when using this permission.", + "default": { + "allow": [], + "deny": [] + }, + "allOf": [ + { + "$ref": "#/definitions/Commands" + } + ] + }, + "scope": { + "description": "Allowed or denied scoped when using this permission.", + "allOf": [ + { + "$ref": "#/definitions/Scopes" + } + ] + }, + "platforms": { + "description": "Target platforms this permission applies. By default all platforms are affected by this permission.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Target" + } + } + } + }, + "Commands": { + "description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.", + "type": "object", + "properties": { + "allow": { + "description": "Allowed command.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "deny": { + "description": "Denied command, which takes priority.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "Scopes": { + "description": "An argument for fine grained behavior control of Tauri commands.\n\nIt can be of any serde serializable type and is used to allow or prevent certain actions inside a Tauri command. The configured scope is passed to the command and will be enforced by the command implementation.\n\n## Example\n\n```json { \"allow\": [{ \"path\": \"$HOME/**\" }], \"deny\": [{ \"path\": \"$HOME/secret.txt\" }] } ```", + "type": "object", + "properties": { + "allow": { + "description": "Data that defines what is allowed by the scope.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + }, + "deny": { + "description": "Data that defines what is denied by the scope. This should be prioritized by validation logic.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + } + } + }, + "Value": { + "description": "All supported ACL values.", + "anyOf": [ + { + "description": "Represents a null JSON value.", + "type": "null" + }, + { + "description": "Represents a [`bool`].", + "type": "boolean" + }, + { + "description": "Represents a valid ACL [`Number`].", + "allOf": [ + { + "$ref": "#/definitions/Number" + } + ] + }, + { + "description": "Represents a [`String`].", + "type": "string" + }, + { + "description": "Represents a list of other [`Value`]s.", + "type": "array", + "items": { + "$ref": "#/definitions/Value" + } + }, + { + "description": "Represents a map of [`String`] keys to [`Value`]s.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/Value" + } + } + ] + }, + "Number": { + "description": "A valid ACL number.", + "anyOf": [ + { + "description": "Represents an [`i64`].", + "type": "integer", + "format": "int64" + }, + { + "description": "Represents a [`f64`].", + "type": "number", + "format": "double" + } + ] + }, + "Target": { + "description": "Platform target.", + "oneOf": [ + { + "description": "MacOS.", + "type": "string", + "enum": [ + "macOS" + ] + }, + { + "description": "Windows.", + "type": "string", + "enum": [ + "windows" + ] + }, + { + "description": "Linux.", + "type": "string", + "enum": [ + "linux" + ] + }, + { + "description": "Android.", + "type": "string", + "enum": [ + "android" + ] + }, + { + "description": "iOS.", + "type": "string", + "enum": [ + "iOS" + ] + } + ] + }, + "PermissionKind": { + "type": "string", + "oneOf": [ + { + "description": "Enables the is_registered command without any pre-configured scope.", + "type": "string", + "const": "allow-is-registered", + "markdownDescription": "Enables the is_registered command without any pre-configured scope." + }, + { + "description": "Denies the is_registered command without any pre-configured scope.", + "type": "string", + "const": "deny-is-registered", + "markdownDescription": "Denies the is_registered command without any pre-configured scope." + }, + { + "description": "Enables the register command without any pre-configured scope.", + "type": "string", + "const": "allow-register", + "markdownDescription": "Enables the register command without any pre-configured scope." + }, + { + "description": "Denies the register command without any pre-configured scope.", + "type": "string", + "const": "deny-register", + "markdownDescription": "Denies the register command without any pre-configured scope." + }, + { + "description": "Enables the register_all command without any pre-configured scope.", + "type": "string", + "const": "allow-register-all", + "markdownDescription": "Enables the register_all command without any pre-configured scope." + }, + { + "description": "Denies the register_all command without any pre-configured scope.", + "type": "string", + "const": "deny-register-all", + "markdownDescription": "Denies the register_all command without any pre-configured scope." + }, + { + "description": "Enables the unregister command without any pre-configured scope.", + "type": "string", + "const": "allow-unregister", + "markdownDescription": "Enables the unregister command without any pre-configured scope." + }, + { + "description": "Denies the unregister command without any pre-configured scope.", + "type": "string", + "const": "deny-unregister", + "markdownDescription": "Denies the unregister command without any pre-configured scope." + }, + { + "description": "Enables the unregister_all command without any pre-configured scope.", + "type": "string", + "const": "allow-unregister-all", + "markdownDescription": "Enables the unregister_all command without any pre-configured scope." + }, + { + "description": "Denies the unregister_all command without any pre-configured scope.", + "type": "string", + "const": "deny-unregister-all", + "markdownDescription": "Denies the unregister_all command without any pre-configured scope." + }, + { + "description": "No features are enabled by default, as we believe\nthe shortcuts can be inherently dangerous and it is\napplication specific if specific shortcuts should be\nregistered or unregistered.\n", + "type": "string", + "const": "default", + "markdownDescription": "No features are enabled by default, as we believe\nthe shortcuts can be inherently dangerous and it is\napplication specific if specific shortcuts should be\nregistered or unregistered.\n" + } + ] + } + } +} \ No newline at end of file diff --git a/plugins/global-shortcut/rollup.config.js b/plugins/global-shortcut/rollup.config.js new file mode 100644 index 00000000..1f349ec8 --- /dev/null +++ b/plugins/global-shortcut/rollup.config.js @@ -0,0 +1,7 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import { createConfig } from '../../shared/rollup.config.js' + +export default createConfig() diff --git a/plugins/global-shortcut/rollup.config.mjs b/plugins/global-shortcut/rollup.config.mjs deleted file mode 100644 index 99a3dd31..00000000 --- a/plugins/global-shortcut/rollup.config.mjs +++ /dev/null @@ -1,11 +0,0 @@ -import { readFileSync } from "fs"; - -import { createConfig } from "../../shared/rollup.config.mjs"; - -export default createConfig({ - input: "guest-js/index.ts", - pkg: JSON.parse( - readFileSync(new URL("./package.json", import.meta.url), "utf8"), - ), - external: [/^@tauri-apps\/api/], -}); diff --git a/plugins/global-shortcut/src/api-iife.js b/plugins/global-shortcut/src/api-iife.js deleted file mode 100644 index 3ff40c72..00000000 --- a/plugins/global-shortcut/src/api-iife.js +++ /dev/null @@ -1 +0,0 @@ -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__})} diff --git a/plugins/global-shortcut/src/error.rs b/plugins/global-shortcut/src/error.rs index 8157000c..37392b32 100644 --- a/plugins/global-shortcut/src/error.rs +++ b/plugins/global-shortcut/src/error.rs @@ -5,9 +5,14 @@ use serde::{Serialize, Serializer}; #[derive(Debug, thiserror::Error)] +#[non_exhaustive] pub enum Error { #[error("{0}")] GlobalHotkey(String), + #[error(transparent)] + RecvError(#[from] std::sync::mpsc::RecvError), + #[error(transparent)] + Tauri(#[from] tauri::Error), } impl Serialize for Error { @@ -24,3 +29,9 @@ impl From for Error { Self::GlobalHotkey(value.to_string()) } } + +impl From for Error { + fn from(value: global_hotkey::hotkey::HotKeyParseError) -> Self { + Self::GlobalHotkey(value.to_string()) + } +} diff --git a/plugins/global-shortcut/src/lib.rs b/plugins/global-shortcut/src/lib.rs index 1cb9d25c..450bb598 100644 --- a/plugins/global-shortcut/src/lib.rs +++ b/plugins/global-shortcut/src/lib.rs @@ -2,8 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -//! [![](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/global-shortcut/banner.png)](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/global-shortcut) -//! //! Register global shortcuts. //! //! - Supported platforms: Windows, Linux and macOS. @@ -20,34 +18,25 @@ use std::{ sync::{Arc, Mutex}, }; -pub use global_hotkey::hotkey::{Code, HotKey as Shortcut, Modifiers}; -use global_hotkey::{GlobalHotKeyEvent, GlobalHotKeyManager}; +use global_hotkey::GlobalHotKeyEvent; +pub use global_hotkey::{ + hotkey::{Code, HotKey as Shortcut, Modifiers}, + GlobalHotKeyEvent as ShortcutEvent, HotKeyState as ShortcutState, +}; +use serde::Serialize; use tauri::{ ipc::Channel, plugin::{Builder as PluginBuilder, TauriPlugin}, - AppHandle, Manager, Runtime, State, Window, + AppHandle, Manager, Runtime, State, }; mod error; pub use error::Error; type Result = std::result::Result; -type HotKeyId = u32; -type HandlerFn = Box, &Shortcut) + Send + Sync + 'static>; -enum ShortcutSource { - Ipc(Channel), - Rust, -} - -impl Clone for ShortcutSource { - fn clone(&self) -> Self { - match self { - Self::Ipc(channel) => Self::Ipc(channel.clone()), - Self::Rust => Self::Rust, - } - } -} +type HotKeyId = u32; +type HandlerFn = Box, &Shortcut, ShortcutEvent) + Send + Sync + 'static>; pub struct ShortcutWrapper(Shortcut); @@ -58,109 +47,183 @@ impl From for ShortcutWrapper { } impl TryFrom<&str> for ShortcutWrapper { - type Error = global_hotkey::Error; + type Error = global_hotkey::hotkey::HotKeyParseError; fn try_from(value: &str) -> std::result::Result { Shortcut::from_str(value).map(ShortcutWrapper) } } -struct RegisteredShortcut { - source: ShortcutSource, - shortcut: (Shortcut, Option), +struct RegisteredShortcut { + shortcut: Shortcut, + handler: Option>>, } +struct GlobalHotKeyManager(global_hotkey::GlobalHotKeyManager); + +/// SAFETY: we ensure it is run on main thread only +unsafe impl Send for GlobalHotKeyManager {} +/// SAFETY: we ensure it is run on main thread only +unsafe impl Sync for GlobalHotKeyManager {} + pub struct GlobalShortcut { #[allow(dead_code)] app: AppHandle, - manager: std::result::Result, - shortcuts: Arc>>, + manager: Arc, + shortcuts: Arc>>>, +} + +macro_rules! run_main_thread { + ($handle:expr, $manager:expr, |$m:ident| $ex:expr) => {{ + let (tx, rx) = std::sync::mpsc::channel(); + let manager = $manager.clone(); + let task = move || { + let f = |$m: &GlobalHotKeyManager| $ex; + let _ = tx.send(f(&*manager)); + }; + $handle.run_on_main_thread(task)?; + rx.recv()? + }}; } impl GlobalShortcut { - fn register_internal( + fn register_internal, &Shortcut, ShortcutEvent) + Send + Sync + 'static>( &self, - shortcut: (Shortcut, Option), - source: ShortcutSource, + shortcut: Shortcut, + handler: Option, ) -> Result<()> { - let id = shortcut.0.id(); - acquire_manager(&self.manager)?.register(shortcut.0)?; + let id = shortcut.id(); + let handler = handler.map(|h| Arc::new(Box::new(h) as HandlerFn)); + run_main_thread!(self.app, self.manager, |m| m.0.register(shortcut))?; self.shortcuts .lock() .unwrap() - .insert(id, RegisteredShortcut { source, shortcut }); + .insert(id, RegisteredShortcut { shortcut, handler }); Ok(()) } - fn register_all_internal)>>( - &self, - shortcuts: S, - source: ShortcutSource, - ) -> Result<()> { - let hotkeys = shortcuts - .into_iter() - .collect::)>>(); + fn register_multiple_internal(&self, shortcuts: S, handler: Option) -> Result<()> + where + S: IntoIterator, + F: Fn(&AppHandle, &Shortcut, ShortcutEvent) + Send + Sync + 'static, + { + let handler = handler.map(|h| Arc::new(Box::new(h) as HandlerFn)); - let manager = acquire_manager(&self.manager)?; - let mut shortcuts = self.shortcuts.lock().unwrap(); - for hotkey in hotkeys { - manager.register(hotkey.0)?; + let hotkeys = shortcuts.into_iter().collect::>(); + let mut shortcuts = self.shortcuts.lock().unwrap(); + for shortcut in hotkeys { + run_main_thread!(self.app, self.manager, |m| m.0.register(shortcut))?; shortcuts.insert( - hotkey.0.id(), + shortcut.id(), RegisteredShortcut { - source: source.clone(), - shortcut: hotkey, + shortcut, + handler: handler.clone(), }, ); } Ok(()) } +} - pub fn register>(&self, shortcut: S) -> Result<()> +impl GlobalShortcut { + /// Register a shortcut. + pub fn register(&self, shortcut: S) -> Result<()> where + S: TryInto, S::Error: std::error::Error, { - self.register_internal((try_into_shortcut(shortcut)?, None), ShortcutSource::Rust) + self.register_internal( + try_into_shortcut(shortcut)?, + None::, &Shortcut, ShortcutEvent)>, + ) } - pub fn register_all, S: IntoIterator>( - &self, - shortcuts: S, - ) -> Result<()> + /// Register a shortcut with a handler. + pub fn on_shortcut(&self, shortcut: S, handler: F) -> Result<()> + where + S: TryInto, + S::Error: std::error::Error, + F: Fn(&AppHandle, &Shortcut, ShortcutEvent) + Send + Sync + 'static, + { + self.register_internal(try_into_shortcut(shortcut)?, Some(handler)) + } + + /// Register multiple shortcuts. + pub fn register_multiple(&self, shortcuts: S) -> Result<()> where + S: IntoIterator, + T: TryInto, T::Error: std::error::Error, { let mut s = Vec::new(); for shortcut in shortcuts { - s.push((try_into_shortcut(shortcut)?, None)); + s.push(try_into_shortcut(shortcut)?); } - self.register_all_internal(s, ShortcutSource::Rust) + self.register_multiple_internal(s, None::, &Shortcut, ShortcutEvent)>) } + /// Register multiple shortcuts with a handler. + pub fn on_shortcuts(&self, shortcuts: S, handler: F) -> Result<()> + where + S: IntoIterator, + T: TryInto, + T::Error: std::error::Error, + F: Fn(&AppHandle, &Shortcut, ShortcutEvent) + Send + Sync + 'static, + { + let mut s = Vec::new(); + for shortcut in shortcuts { + s.push(try_into_shortcut(shortcut)?); + } + self.register_multiple_internal(s, Some(handler)) + } + + /// Unregister a shortcut pub fn unregister>(&self, shortcut: S) -> Result<()> where S::Error: std::error::Error, { - acquire_manager(&self.manager)? - .unregister(try_into_shortcut(shortcut)?) - .map_err(Into::into) + let shortcut = try_into_shortcut(shortcut)?; + run_main_thread!(self.app, self.manager, |m| m.0.unregister(shortcut))?; + self.shortcuts.lock().unwrap().remove(&shortcut.id()); + Ok(()) } - pub fn unregister_all, S: IntoIterator>( + /// Unregister multiple shortcuts. + pub fn unregister_multiple, S: IntoIterator>( &self, shortcuts: S, ) -> Result<()> where T::Error: std::error::Error, { - let mut s = Vec::new(); + let mut mapped_shortcuts = Vec::new(); for shortcut in shortcuts { - s.push(try_into_shortcut(shortcut)?); + mapped_shortcuts.push(try_into_shortcut(shortcut)?); + } + + { + let mapped_shortcuts = mapped_shortcuts.clone(); + #[rustfmt::skip] + run_main_thread!(self.app, self.manager, |m| m.0.unregister_all(&mapped_shortcuts))?; } - acquire_manager(&self.manager)? - .unregister_all(&s) - .map_err(Into::into) + + let mut shortcuts = self.shortcuts.lock().unwrap(); + for s in mapped_shortcuts { + shortcuts.remove(&s.id()); + } + + Ok(()) + } + + /// Unregister all registered shortcuts. + pub fn unregister_all(&self) -> Result<()> { + let mut shortcuts = self.shortcuts.lock().unwrap(); + let hotkeys = std::mem::take(&mut *shortcuts); + let hotkeys = hotkeys.values().map(|s| s.shortcut).collect::>(); + #[rustfmt::skip] + let res = run_main_thread!(self.app, self.manager, |m| m.0.unregister_all(hotkeys.as_slice())); + res.map_err(Into::into) } /// Determines whether the given shortcut is registered by this application or not. @@ -188,14 +251,6 @@ impl> GlobalShortcutExt for T { } } -fn acquire_manager( - manager: &std::result::Result, -) -> Result<&GlobalHotKeyManager> { - manager - .as_ref() - .map_err(|e| Error::GlobalHotkey(e.to_string())) -} - fn parse_shortcut>(shortcut: S) -> Result { shortcut.as_ref().parse().map_err(Into::into) } @@ -210,53 +265,63 @@ where .map_err(|e| Error::GlobalHotkey(e.to_string())) } -#[tauri::command] -fn register( - _window: Window, - global_shortcut: State<'_, GlobalShortcut>, +#[derive(Clone, Serialize)] +struct ShortcutJsEvent { shortcut: String, - handler: Channel, -) -> Result<()> { - global_shortcut.register_internal( - (parse_shortcut(&shortcut)?, Some(shortcut)), - ShortcutSource::Ipc(handler), - ) + id: u32, + state: ShortcutState, } #[tauri::command] -fn register_all( - _window: Window, +fn register( + _app: AppHandle, global_shortcut: State<'_, GlobalShortcut>, shortcuts: Vec, - handler: Channel, + handler: Channel, ) -> Result<()> { let mut hotkeys = Vec::new(); + + let mut shortcut_map = HashMap::new(); for shortcut in shortcuts { - hotkeys.push((parse_shortcut(&shortcut)?, Some(shortcut))); + let hotkey = parse_shortcut(&shortcut)?; + shortcut_map.insert(hotkey.id(), shortcut); + hotkeys.push(hotkey); } - global_shortcut.register_all_internal(hotkeys, ShortcutSource::Ipc(handler)) + + global_shortcut.register_multiple_internal( + hotkeys, + Some( + move |_app: &AppHandle, shortcut: &Shortcut, e: ShortcutEvent| { + let js_event = ShortcutJsEvent { + id: e.id, + state: e.state, + shortcut: shortcut.into_string(), + }; + let _ = handler.send(js_event); + }, + ), + ) } #[tauri::command] fn unregister( _app: AppHandle, global_shortcut: State<'_, GlobalShortcut>, - shortcut: String, + shortcuts: Vec, ) -> Result<()> { - global_shortcut.unregister(parse_shortcut(shortcut)?) + let mut hotkeys = Vec::new(); + for shortcut in shortcuts { + hotkeys.push(parse_shortcut(&shortcut)?); + } + global_shortcut.unregister_multiple(hotkeys) } #[tauri::command] fn unregister_all( _app: AppHandle, global_shortcut: State<'_, GlobalShortcut>, - shortcuts: Vec, ) -> Result<()> { - let mut hotkeys = Vec::new(); - for shortcut in shortcuts { - hotkeys.push(parse_shortcut(&shortcut)?); - } - global_shortcut.unregister_all(hotkeys) + global_shortcut.unregister_all() } #[tauri::command] @@ -269,12 +334,14 @@ fn is_registered( } pub struct Builder { + shortcuts: Vec, handler: Option>, } impl Default for Builder { fn default() -> Self { Self { + shortcuts: Vec::new(), handler: Default::default(), } } @@ -285,49 +352,81 @@ impl Builder { Self::default() } - pub fn with_handler, &Shortcut) + Send + Sync + 'static>( + /// Add a shortcut to be registerd. + pub fn with_shortcut(mut self, shortcut: T) -> Result + where + T: TryInto, + T::Error: std::error::Error, + { + self.shortcuts.push(try_into_shortcut(shortcut)?); + Ok(self) + } + + /// Add multiple shortcuts to be registerd. + pub fn with_shortcuts(mut self, shortcuts: S) -> Result + where + S: IntoIterator, + T: TryInto, + T::Error: std::error::Error, + { + for shortcut in shortcuts { + self.shortcuts.push(try_into_shortcut(shortcut)?); + } + + Ok(self) + } + + /// Specify a global shortcut handler that will be triggered for any and all shortcuts. + pub fn with_handler, &Shortcut, ShortcutEvent) + Send + Sync + 'static>( + mut self, handler: F, ) -> Self { - Self { - handler: Some(Box::new(handler)), - } + self.handler.replace(Box::new(handler)); + self } pub fn build(self) -> TauriPlugin { let handler = self.handler; - PluginBuilder::new("globalShortcut") - .js_init_script(include_str!("api-iife.js").to_string()) + let shortcuts = self.shortcuts; + PluginBuilder::new("global-shortcut") .invoke_handler(tauri::generate_handler![ register, - register_all, unregister, unregister_all, - is_registered + is_registered, ]) .setup(move |app, _api| { - let shortcuts = - Arc::new(Mutex::new(HashMap::::new())); + let manager = global_hotkey::GlobalHotKeyManager::new()?; + let mut store = HashMap::>::new(); + for shortcut in shortcuts { + manager.register(shortcut)?; + store.insert( + shortcut.id(), + RegisteredShortcut { + shortcut, + handler: None, + }, + ); + } + + let shortcuts = Arc::new(Mutex::new(store)); let shortcuts_ = shortcuts.clone(); let app_handle = app.clone(); GlobalHotKeyEvent::set_event_handler(Some(move |e: GlobalHotKeyEvent| { if let Some(shortcut) = shortcuts_.lock().unwrap().get(&e.id) { - match &shortcut.source { - ShortcutSource::Ipc(channel) => { - let _ = channel.send(&shortcut.shortcut.1); - } - ShortcutSource::Rust => { - if let Some(handler) = &handler { - handler(&app_handle, &shortcut.shortcut.0); - } - } + if let Some(handler) = &shortcut.handler { + handler(&app_handle, &shortcut.shortcut, e); + } + if let Some(handler) = &handler { + handler(&app_handle, &shortcut.shortcut, e); } } })); app.manage(GlobalShortcut { app: app.clone(), - manager: GlobalHotKeyManager::new(), + manager: Arc::new(GlobalHotKeyManager(manager)), shortcuts, }); Ok(()) diff --git a/plugins/haptics/CHANGELOG.md b/plugins/haptics/CHANGELOG.md new file mode 100644 index 00000000..aa3fbbd8 --- /dev/null +++ b/plugins/haptics/CHANGELOG.md @@ -0,0 +1,49 @@ +# Changelog + +## \[2.2.4] + +- [`a1b3fa27`](https://github.com/tauri-apps/plugins-workspace/commit/a1b3fa27f11022c9b6622b4fab12d93239eb05de) ([#2515](https://github.com/tauri-apps/plugins-workspace/pull/2515) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Re-exported the `Geolocation`, `Haptics`, `Notification`, and `Os` structs so that they show up on docs.rs. + +## \[2.2.3] + +- [`406e6f48`](https://github.com/tauri-apps/plugins-workspace/commit/406e6f484cdc13d35c50fb949f7489ca9eeccc44) ([#2323](https://github.com/tauri-apps/plugins-workspace/pull/2323) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Fixed an issue that caused build failures when the `haptics` or `geolocation` plugin was used without their `specta` feature flag enabled. + +## \[2.2.2] + +- [`c9c13a0f`](https://github.com/tauri-apps/plugins-workspace/commit/c9c13a0fe7cdaac223843f5ba33176252f8e22f5) ([#2316](https://github.com/tauri-apps/plugins-workspace/pull/2316) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) **Breaking change:** `specta` integration is now behind a `specta` feature flag like in Tauri. +- [`c9c13a0f`](https://github.com/tauri-apps/plugins-workspace/commit/c9c13a0fe7cdaac223843f5ba33176252f8e22f5) ([#2316](https://github.com/tauri-apps/plugins-workspace/pull/2316) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Unlock and widen `specta` version range to match Tauri. No API changes. + +## \[2.2.1] + +- [`fb67ab2b`](https://github.com/tauri-apps/plugins-workspace/commit/fb67ab2b926502bfc20d6b43fbdd156691ea8526) ([#2281](https://github.com/tauri-apps/plugins-workspace/pull/2281) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Added `specta-util` to fix a "dependency not found" compilation error. + +## \[2.2.0] + +- [`3a79266b`](https://github.com/tauri-apps/plugins-workspace/commit/3a79266b8cf96a55b1ae6339d725567d45a44b1d) ([#2173](https://github.com/tauri-apps/plugins-workspace/pull/2173) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Bumped all plugins to `v2.2.0`. From now, the versions for the Rust and JavaScript packages of each plugin will be in sync with each other. + +## \[2.0.1] + +- [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. + +## \[2.0.0] + +- [`e2c4dfb6`](https://github.com/tauri-apps/plugins-workspace/commit/e2c4dfb6af43e5dd8d9ceba232c315f5febd55c1) Update to tauri v2 stable release. + +## \[2.0.0-rc.1] + +- [`e2e97db5`](https://github.com/tauri-apps/plugins-workspace/commit/e2e97db51983267f5be84d4f6f0278d58834d1f5) ([#1701](https://github.com/tauri-apps/plugins-workspace/pull/1701) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri 2.0.0-rc.8 + +## \[2.0.0-rc.2] + +- [`b9147758`](https://github.com/tauri-apps/plugins-workspace/commit/b914775898c2bee7ceb20bd17ee595005cd17a64) ([#1679](https://github.com/tauri-apps/plugins-workspace/pull/1679) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Explicitly set a minimum macOS version for the Swift package. + +## \[2.0.0-rc.1] + +### changes + +- [`6b079cfd`](https://github.com/tauri-apps/plugins-workspace/commit/6b079cfdd107c94abc2c7300f6af00bac3ff4040) ([#1649](https://github.com/tauri-apps/plugins-workspace/pull/1649) by [@ahqsoftwares](https://github.com/tauri-apps/plugins-workspace/../../ahqsoftwares)) Remove targetSdk from build.kts files as it is deprecated and will be removed from DSL v9.0 + +## \[2.0.0-rc.0] + +- [`9606089b`](https://github.com/tauri-apps/plugins-workspace/commit/9606089b2add4a17f80ed5a09d59ce94824bd672) ([#1599](https://github.com/tauri-apps/plugins-workspace/pull/1599)) Initial release. +- [`9887d1`](https://github.com/tauri-apps/plugins-workspace/commit/9887d14bd0e971c4c0f5c1188fc4005d3fc2e29e) Update to tauri RC. diff --git a/plugins/haptics/Cargo.toml b/plugins/haptics/Cargo.toml new file mode 100644 index 00000000..34c80bab --- /dev/null +++ b/plugins/haptics/Cargo.toml @@ -0,0 +1,38 @@ +[package] +name = "tauri-plugin-haptics" +description = "Haptic feedback and vibrations on Android and iOS" +version = "2.2.4" +edition = { workspace = true } +authors = { workspace = true } +license = { workspace = true } +repository = { workspace = true } +links = "tauri-plugin-haptics" + +[package.metadata.docs.rs] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] +targets = ["x86_64-linux-android"] + +[package.metadata.platforms.support] +windows = { level = "none", notes = "" } +linux = { level = "none", notes = "" } +macos = { level = "none", notes = "" } +android = { level = "full", notes = "" } +ios = { level = "full", notes = "" } + +[build-dependencies] +tauri-plugin = { workspace = true, features = ["build"] } + +[dependencies] +serde = { workspace = true } +serde_json = { workspace = true } +tauri = { workspace = true } +log = { workspace = true } +thiserror = { workspace = true } +specta = { workspace = true, optional = true } + +[target.'cfg(target_os = "ios")'.dependencies] +tauri = { workspace = true, features = ["wry"] } + +[features] +specta = ["dep:specta", "tauri/specta"] diff --git a/plugins/haptics/LICENSE.spdx b/plugins/haptics/LICENSE.spdx new file mode 100644 index 00000000..cdd0df5a --- /dev/null +++ b/plugins/haptics/LICENSE.spdx @@ -0,0 +1,20 @@ +SPDXVersion: SPDX-2.1 +DataLicense: CC0-1.0 +PackageName: tauri +DataFormat: SPDXRef-1 +PackageSupplier: Organization: The Tauri Programme in the Commons Conservancy +PackageHomePage: https://tauri.app +PackageLicenseDeclared: Apache-2.0 +PackageLicenseDeclared: MIT +PackageCopyrightText: 2019-2022, The Tauri Programme in the Commons Conservancy +PackageSummary: Tauri is a rust project that enables developers to make secure +and small desktop applications using a web frontend. + +PackageComment: The package includes the following libraries; see +Relationship information. + +Created: 2019-05-20T09:00:00Z +PackageDownloadLocation: git://github.com/tauri-apps/tauri +PackageDownloadLocation: git+https://github.com/tauri-apps/tauri.git +PackageDownloadLocation: git+ssh://github.com/tauri-apps/tauri.git +Creator: Person: Daniel Thompson-Yvetot \ No newline at end of file diff --git a/plugins/haptics/LICENSE_APACHE-2.0 b/plugins/haptics/LICENSE_APACHE-2.0 new file mode 100644 index 00000000..4947287f --- /dev/null +++ b/plugins/haptics/LICENSE_APACHE-2.0 @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/plugins/haptics/LICENSE_MIT b/plugins/haptics/LICENSE_MIT new file mode 100644 index 00000000..4d754725 --- /dev/null +++ b/plugins/haptics/LICENSE_MIT @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 - Present Tauri Apps Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/plugins/haptics/README.md b/plugins/haptics/README.md new file mode 100644 index 00000000..44118812 --- /dev/null +++ b/plugins/haptics/README.md @@ -0,0 +1,144 @@ +![haptics](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/haptics/banner.png) + +Haptic feedback and vibrations on Android and iOS. + +There are no standards/requirements for vibration support on Android, so the `feedback` APIs may not work correctly on more affordable phones, including recently released ones. + +| Platform | Supported | +| -------- | --------- | +| Linux | x | +| Windows | x | +| macOS | x | +| Android | ✓ | +| iOS | ✓ | + +## Install + +_This plugin requires a Rust version of at least **1.77.2**_ + +There are three general methods of installation that we can recommend. + +1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked) +2. Pull sources directly from Github using git tags / revision hashes (most secure) +3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use) + +Install the Core plugin by adding the following to your `Cargo.toml` file: + +`src-tauri/Cargo.toml` + +```toml +[dependencies] +tauri-plugin-haptics = "2.0.0" +# alternatively with Git: +tauri-plugin-haptics = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } +``` + +You can install the JavaScript Guest bindings using your preferred JavaScript package manager: + +> Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use. + + + +```sh +pnpm add @tauri-apps/plugin-haptics +# or +npm add @tauri-apps/plugin-haptics +# or +yarn add @tauri-apps/plugin-haptics + +# alternatively with Git: +pnpm add https://github.com/tauri-apps/tauri-plugin-haptics#v2 +# or +npm add https://github.com/tauri-apps/tauri-plugin-haptics#v2 +# or +yarn add https://github.com/tauri-apps/tauri-plugin-haptics#v2 +``` + +## Usage + +First you need to register the core plugin with Tauri: + +`src-tauri/src/lib.rs` + +```rust +fn main() { + tauri::Builder::default() + .plugin(tauri_plugin_haptics::init()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} +``` + +Second, add the required permissions in the project: + +`src-tauri/capabilities/default.json` + +```json + "permissions": [ + "haptics:allow-impact-feedback", + "haptics:allow-notification-feedback", + "haptics:allow-selection-feedback", + "haptics:allow-vibrate" + ] +``` + +Afterwards all the plugin's APIs are available through the JavaScript guest bindings: + +```javascript +import { + vibrate, + impactFeedback, + notificationFeedback, + selectionFeedback +} from '@tauri-apps/plugin-haptics' + +await vibrate(1) +await impactFeedback('medium') +await notificationFeedback('warning') +await selectionFeedback() +``` + +## Contributing + +PRs accepted. Please make sure to read the Contributing Guide before making a pull request. + +## Contributed By + + + + + + + + +
+ + CrabNebula + + + + Rescue.co + +
+ +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + +## License + +Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. + +MIT or MIT/Apache 2.0 where applicable. diff --git a/plugins/haptics/SECURITY.md b/plugins/haptics/SECURITY.md new file mode 100644 index 00000000..4f09bbac --- /dev/null +++ b/plugins/haptics/SECURITY.md @@ -0,0 +1,23 @@ +# Security Policy + +**Do not report security vulnerabilities through public GitHub issues.** + +**Please use the [Private Vulnerability Disclosure](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) feature of GitHub.** + +Include as much of the following information: + +- Type of issue (e.g. improper input parsing, privilege escalation, etc.) +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- The distribution affected or used to help us with reproduction of the issue +- Step-by-step instructions to reproduce the issue +- Ideally a reproduction repository +- Impact of the issue, including how an attacker might exploit the issue + +We prefer to receive reports in English. + +## Contact + +Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). + +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/barcode-scanner/.gitignore b/plugins/haptics/android/.gitignore similarity index 53% rename from plugins/barcode-scanner/.gitignore rename to plugins/haptics/android/.gitignore index 1b0b469d..c0f21ec2 100644 --- a/plugins/barcode-scanner/.gitignore +++ b/plugins/haptics/android/.gitignore @@ -1 +1,2 @@ +/build /.tauri diff --git a/plugins/haptics/android/build.gradle.kts b/plugins/haptics/android/build.gradle.kts new file mode 100644 index 00000000..7de1d372 --- /dev/null +++ b/plugins/haptics/android/build.gradle.kts @@ -0,0 +1,45 @@ +plugins { + id("com.android.library") + id("org.jetbrains.kotlin.android") +} + +android { + namespace = "app.tauri.haptics" + compileSdk = 34 + + defaultConfig { + minSdk = 24 + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles("consumer-rules.pro") + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = "1.8" + } +} + +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") + implementation(project(":tauri-android")) +} diff --git a/plugins/haptics/android/proguard-rules.pro b/plugins/haptics/android/proguard-rules.pro new file mode 100644 index 00000000..481bb434 --- /dev/null +++ b/plugins/haptics/android/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/plugins/haptics/android/settings.gradle b/plugins/haptics/android/settings.gradle new file mode 100644 index 00000000..14a752e4 --- /dev/null +++ b/plugins/haptics/android/settings.gradle @@ -0,0 +1,2 @@ +include ':tauri-android' +project(':tauri-android').projectDir = new File('./.tauri/tauri-api') diff --git a/plugins/haptics/android/src/androidTest/java/ExampleInstrumentedTest.kt b/plugins/haptics/android/src/androidTest/java/ExampleInstrumentedTest.kt new file mode 100644 index 00000000..1b408ac8 --- /dev/null +++ b/plugins/haptics/android/src/androidTest/java/ExampleInstrumentedTest.kt @@ -0,0 +1,28 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +package app.tauri.haptics + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("app.tauri.haptics", appContext.packageName) + } +} diff --git a/plugins/haptics/android/src/main/AndroidManifest.xml b/plugins/haptics/android/src/main/AndroidManifest.xml new file mode 100644 index 00000000..042e61a7 --- /dev/null +++ b/plugins/haptics/android/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + diff --git a/plugins/haptics/android/src/main/java/HapticsPlugin.kt b/plugins/haptics/android/src/main/java/HapticsPlugin.kt new file mode 100644 index 00000000..5a6bf1b8 --- /dev/null +++ b/plugins/haptics/android/src/main/java/HapticsPlugin.kt @@ -0,0 +1,143 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +package app.tauri.haptics + +import android.app.Activity +import android.content.Context +import android.os.Build +import android.os.VibrationEffect +import android.os.Vibrator +import android.os.VibratorManager +import app.tauri.Logger +import app.tauri.annotation.Command +import app.tauri.annotation.InvokeArg +import app.tauri.annotation.TauriPlugin +import app.tauri.haptics.patterns.ImpactPatternHeavy +import app.tauri.haptics.patterns.ImpactPatternLight +import app.tauri.haptics.patterns.ImpactPatternMedium +import app.tauri.haptics.patterns.ImpactPatternRigid +import app.tauri.haptics.patterns.ImpactPatternSoft +import app.tauri.haptics.patterns.NotificationPatternError +import app.tauri.haptics.patterns.NotificationPatternSuccess +import app.tauri.haptics.patterns.NotificationPatternWarning +import app.tauri.haptics.patterns.Pattern +import app.tauri.haptics.patterns.SelectionPattern +import app.tauri.plugin.Invoke +import app.tauri.plugin.Plugin +import com.fasterxml.jackson.annotation.JsonProperty + +@InvokeArg +class HapticsOptions { + var duration: Long = 300 +} + +@InvokeArg +class NotificationFeedbackArgs { + val type: NotificationFeedbackType = NotificationFeedbackType.Success +} + +@InvokeArg +enum class NotificationFeedbackType { + @JsonProperty("success") + Success, + @JsonProperty("warning") + Warning, + @JsonProperty("error") + Error; + + fun into(): Pattern { + return when(this) { + Success -> NotificationPatternSuccess + Warning -> NotificationPatternWarning + Error -> NotificationPatternError + } + } +} + +@InvokeArg +class ImpactFeedbackArgs { + val style: ImpactFeedbackStyle = ImpactFeedbackStyle.Medium +} + +@InvokeArg +enum class ImpactFeedbackStyle { + @JsonProperty("light") + Light, + @JsonProperty("medium") + Medium, + @JsonProperty("heavy") + Heavy, + @JsonProperty("soft") + Soft, + @JsonProperty("rigid") + Rigid; + + fun into(): Pattern { + return when(this) { + Light -> ImpactPatternLight + Medium -> ImpactPatternMedium + Heavy -> ImpactPatternHeavy + Soft -> ImpactPatternSoft + Rigid -> ImpactPatternRigid + } + } +} + +@TauriPlugin +class HapticsPlugin(private val activity: Activity): Plugin(activity) { + private val vibrator: Vibrator = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { + val vibManager = activity.applicationContext.getSystemService(Context.VIBRATOR_MANAGER_SERVICE) as VibratorManager + vibManager.defaultVibrator + } else { + @Suppress("DEPRECATION") + activity.applicationContext.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator + } + + // + // TAURI COMMANDS + // + + @Command + fun vibrate(invoke: Invoke) { + val args = invoke.parseArgs(HapticsOptions::class.java) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + vibrator.vibrate(VibrationEffect.createOneShot(args.duration, VibrationEffect.DEFAULT_AMPLITUDE)) + } else { + vibrator.vibrate(args.duration) + } + invoke.resolve() + } + + @Command + fun impactFeedback(invoke: Invoke) { + val args = invoke.parseArgs(ImpactFeedbackArgs::class.java) + vibratePattern(args.style.into()) + invoke.resolve() + } + + @Command + fun notificationFeedback(invoke: Invoke) { + val args = invoke.parseArgs(NotificationFeedbackArgs::class.java) + vibratePattern(args.type.into()) + invoke.resolve() + } + + // TODO: Consider breaking this up into Start,Change,End like capacitor + @Command + fun selectionFeedback(invoke: Invoke) { + vibratePattern(SelectionPattern) + invoke.resolve() + } + + // INTERNAL FUNCTIONS + + private fun vibratePattern(pattern: Pattern) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + vibrator.vibrate(VibrationEffect.createWaveform(pattern.timings, pattern.amplitudes, -1)) + } else { + vibrator.vibrate(pattern.oldSDKPattern, -1) + } + } +} diff --git a/plugins/haptics/android/src/main/java/patterns/Impact.kt b/plugins/haptics/android/src/main/java/patterns/Impact.kt new file mode 100644 index 00000000..d40e750d --- /dev/null +++ b/plugins/haptics/android/src/main/java/patterns/Impact.kt @@ -0,0 +1,35 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +package app.tauri.haptics.patterns + +val ImpactPatternLight = Pattern( + longArrayOf(0, 50), + intArrayOf(0, 30), + longArrayOf(0, 20) +) + +val ImpactPatternMedium = Pattern( + longArrayOf(0, 43), + intArrayOf(0, 50), + longArrayOf(0, 43) +) + +val ImpactPatternHeavy = Pattern( + longArrayOf(0, 60), + intArrayOf(0, 70), + longArrayOf(0, 61) +) + +val ImpactPatternSoft = Pattern( + longArrayOf(0, 50), + intArrayOf(0, 30), + longArrayOf(0, 20) +) + +val ImpactPatternRigid = Pattern( + longArrayOf(0, 43), + intArrayOf(0, 50), + longArrayOf(0, 43) +) \ No newline at end of file diff --git a/plugins/haptics/android/src/main/java/patterns/Notification.kt b/plugins/haptics/android/src/main/java/patterns/Notification.kt new file mode 100644 index 00000000..2f70c23e --- /dev/null +++ b/plugins/haptics/android/src/main/java/patterns/Notification.kt @@ -0,0 +1,23 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +package app.tauri.haptics.patterns + +val NotificationPatternSuccess = Pattern( + longArrayOf(0, 40, 100, 40), + intArrayOf(0, 50, 0, 60), + longArrayOf(0, 40, 100, 40) +) + +val NotificationPatternWarning = Pattern( + longArrayOf(0, 40, 120, 60), + intArrayOf(0, 40, 0, 60), + longArrayOf(0, 40, 120, 60) +) + +val NotificationPatternError = Pattern( + longArrayOf(0, 60, 100, 40, 80, 50), + intArrayOf(0, 50, 0, 40, 0, 50), + longArrayOf(0, 60, 100, 40, 80, 50) +) diff --git a/plugins/haptics/android/src/main/java/patterns/Pattern.kt b/plugins/haptics/android/src/main/java/patterns/Pattern.kt new file mode 100644 index 00000000..5f99b02c --- /dev/null +++ b/plugins/haptics/android/src/main/java/patterns/Pattern.kt @@ -0,0 +1,11 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +package app.tauri.haptics.patterns + +class Pattern ( + val timings: LongArray, + val amplitudes: IntArray, + val oldSDKPattern: LongArray +) {} \ No newline at end of file diff --git a/plugins/haptics/android/src/main/java/patterns/Selection.kt b/plugins/haptics/android/src/main/java/patterns/Selection.kt new file mode 100644 index 00000000..02dce4c2 --- /dev/null +++ b/plugins/haptics/android/src/main/java/patterns/Selection.kt @@ -0,0 +1,11 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +package app.tauri.haptics.patterns + +val SelectionPattern = Pattern ( + timings = longArrayOf(0, 50), + amplitudes = intArrayOf(0, 30), + oldSDKPattern = longArrayOf(0, 70) +) \ No newline at end of file diff --git a/plugins/haptics/android/src/test/java/ExampleUnitTest.kt b/plugins/haptics/android/src/test/java/ExampleUnitTest.kt new file mode 100644 index 00000000..562188f0 --- /dev/null +++ b/plugins/haptics/android/src/test/java/ExampleUnitTest.kt @@ -0,0 +1,21 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +package app.tauri.haptics + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} diff --git a/plugins/haptics/api-iife.js b/plugins/haptics/api-iife.js new file mode 100644 index 00000000..5cccb15f --- /dev/null +++ b/plugins/haptics/api-iife.js @@ -0,0 +1 @@ +if("__TAURI__"in window){var __TAURI_PLUGIN_HAPTICS__=function(r){"use strict";async function t(r,t={},e){return window.__TAURI_INTERNALS__.invoke(r,t,e)}var e;"function"==typeof SuppressedError&&SuppressedError,function(r){r.WINDOW_RESIZED="tauri://resize",r.WINDOW_MOVED="tauri://move",r.WINDOW_CLOSE_REQUESTED="tauri://close-requested",r.WINDOW_DESTROYED="tauri://destroyed",r.WINDOW_FOCUS="tauri://focus",r.WINDOW_BLUR="tauri://blur",r.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",r.WINDOW_THEME_CHANGED="tauri://theme-changed",r.WINDOW_CREATED="tauri://window-created",r.WEBVIEW_CREATED="tauri://webview-created",r.DRAG_ENTER="tauri://drag-enter",r.DRAG_OVER="tauri://drag-over",r.DRAG_DROP="tauri://drag-drop",r.DRAG_LEAVE="tauri://drag-leave"}(e||(e={}));const a={async vibrate(r){try{return{status:"ok",data:await t("plugin:haptics|vibrate",{duration:r})}}catch(r){if(r instanceof Error)throw r;return{status:"error",error:r}}},async impactFeedback(r){try{return{status:"ok",data:await t("plugin:haptics|impact_feedback",{style:r})}}catch(r){if(r instanceof Error)throw r;return{status:"error",error:r}}},async notificationFeedback(r){try{return{status:"ok",data:await t("plugin:haptics|notification_feedback",{type:r})}}catch(r){if(r instanceof Error)throw r;return{status:"error",error:r}}},async selectionFeedback(){try{return{status:"ok",data:await t("plugin:haptics|selection_feedback")}}catch(r){if(r instanceof Error)throw r;return{status:"error",error:r}}}},{vibrate:i,impactFeedback:c,notificationFeedback:n,selectionFeedback:o}=a;return r.impactFeedback=c,r.notificationFeedback=n,r.selectionFeedback=o,r.vibrate=i,r}({});Object.defineProperty(window.__TAURI__,"haptics",{value:__TAURI_PLUGIN_HAPTICS__})} diff --git a/plugins/haptics/build.rs b/plugins/haptics/build.rs new file mode 100644 index 00000000..2556cb67 --- /dev/null +++ b/plugins/haptics/build.rs @@ -0,0 +1,23 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +const COMMANDS: &[&str] = &[ + "vibrate", + "impact_feedback", + "notification_feedback", + "selection_feedback", +]; + +fn main() { + let result = tauri_plugin::Builder::new(COMMANDS) + .global_api_script_path("./api-iife.js") + .android_path("android") + .ios_path("ios") + .try_build(); + + // when building documentation for Android the plugin build result is always Err() and is irrelevant to the crate documentation build + if !(cfg!(docsrs) && std::env::var("TARGET").unwrap().contains("android")) { + result.unwrap(); + } +} diff --git a/plugins/haptics/contributors/crabnebula.svg b/plugins/haptics/contributors/crabnebula.svg new file mode 100644 index 00000000..40e24131 --- /dev/null +++ b/plugins/haptics/contributors/crabnebula.svg @@ -0,0 +1,31 @@ + \ No newline at end of file diff --git a/plugins/haptics/contributors/rescue.png b/plugins/haptics/contributors/rescue.png new file mode 100644 index 00000000..2b5916f4 Binary files /dev/null and b/plugins/haptics/contributors/rescue.png differ diff --git a/plugins/haptics/guest-js/bindings.ts b/plugins/haptics/guest-js/bindings.ts new file mode 100644 index 00000000..d12920d8 --- /dev/null +++ b/plugins/haptics/guest-js/bindings.ts @@ -0,0 +1,140 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +// @ts-nocheck +// This file was generated by [tauri-specta](https://github.com/oscartbeaumont/tauri-specta). Do not edit this file manually. + +/** user-defined commands **/ + +export const commands = { + async vibrate(duration: number): Promise> { + try { + return { + status: 'ok', + data: await TAURI_INVOKE('plugin:haptics|vibrate', { duration }) + } + } catch (e) { + if (e instanceof Error) throw e + else return { status: 'error', error: e as any } + } + }, + async impactFeedback( + style: ImpactFeedbackStyle + ): Promise> { + try { + return { + status: 'ok', + data: await TAURI_INVOKE('plugin:haptics|impact_feedback', { style }) + } + } catch (e) { + if (e instanceof Error) throw e + else return { status: 'error', error: e as any } + } + }, + async notificationFeedback( + type: NotificationFeedbackType + ): Promise> { + try { + return { + status: 'ok', + data: await TAURI_INVOKE('plugin:haptics|notification_feedback', { + type + }) + } + } catch (e) { + if (e instanceof Error) throw e + else return { status: 'error', error: e as any } + } + }, + async selectionFeedback(): Promise> { + try { + return { + status: 'ok', + data: await TAURI_INVOKE('plugin:haptics|selection_feedback') + } + } catch (e) { + if (e instanceof Error) throw e + else return { status: 'error', error: e as any } + } + } +} + +/** user-defined events **/ + +/* export const events = __makeEvents__<{ + randomNumber: RandomNumber; +}>({ + randomNumber: "plugin:haptics:random-number", +}); */ + +/** user-defined statics **/ + +/** user-defined types **/ + +export type Error = never +export type ImpactFeedbackStyle = + | 'light' + | 'medium' + | 'heavy' + | 'soft' + | 'rigid' +export type NotificationFeedbackType = 'success' | 'warning' | 'error' +//export type RandomNumber = number; + +/** tauri-specta globals **/ + +import { invoke as TAURI_INVOKE } from '@tauri-apps/api/core' +import * as TAURI_API_EVENT from '@tauri-apps/api/event' +import { type WebviewWindow as __WebviewWindow__ } from '@tauri-apps/api/webviewWindow' + +type __EventObj__ = { + listen: ( + cb: TAURI_API_EVENT.EventCallback + ) => ReturnType> + once: ( + cb: TAURI_API_EVENT.EventCallback + ) => ReturnType> + emit: T extends null + ? (payload?: T) => ReturnType + : (payload: T) => ReturnType +} + +export type Result = + | { status: 'ok'; data: T } + | { status: 'error'; error: E } + +function __makeEvents__>( + mappings: Record +) { + return new Proxy( + {} as unknown as { + [K in keyof T]: __EventObj__ & { + (handle: __WebviewWindow__): __EventObj__ + } + }, + { + get: (_, event) => { + const name = mappings[event as keyof T] + + return new Proxy((() => {}) as any, { + apply: (_, __, [window]: [__WebviewWindow__]) => ({ + listen: (arg: any) => window.listen(name, arg), + once: (arg: any) => window.once(name, arg), + emit: (arg: any) => window.emit(name, arg) + }), + get: (_, command: keyof __EventObj__) => { + switch (command) { + case 'listen': + return (arg: any) => TAURI_API_EVENT.listen(name, arg) + case 'once': + return (arg: any) => TAURI_API_EVENT.once(name, arg) + case 'emit': + return (arg: any) => TAURI_API_EVENT.emit(name, arg) + } + } + }) + } + } + ) +} diff --git a/plugins/haptics/guest-js/index.ts b/plugins/haptics/guest-js/index.ts new file mode 100644 index 00000000..23485bdf --- /dev/null +++ b/plugins/haptics/guest-js/index.ts @@ -0,0 +1,18 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +/* eslint-disable @typescript-eslint/unbound-method */ + +import { commands } from './bindings' + +export const { + vibrate, + impactFeedback, + notificationFeedback, + selectionFeedback +} = commands + +export { ImpactFeedbackStyle, NotificationFeedbackType } from './bindings' + +// export { events }; diff --git a/plugins/haptics/ios/.gitignore b/plugins/haptics/ios/.gitignore new file mode 100644 index 00000000..5922fdaa --- /dev/null +++ b/plugins/haptics/ios/.gitignore @@ -0,0 +1,10 @@ +.DS_Store +/.build +/Packages +/*.xcodeproj +xcuserdata/ +DerivedData/ +.swiftpm/config/registries.json +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +.netrc +Package.resolved diff --git a/plugins/haptics/ios/Package.swift b/plugins/haptics/ios/Package.swift new file mode 100644 index 00000000..a64b9890 --- /dev/null +++ b/plugins/haptics/ios/Package.swift @@ -0,0 +1,34 @@ +// swift-tools-version:5.3 +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import PackageDescription + +let package = Package( + name: "tauri-plugin-haptics", + platforms: [ + .macOS(.v10_13), + .iOS(.v13), + ], + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .library( + name: "tauri-plugin-haptics", + type: .static, + targets: ["tauri-plugin-haptics"]) + ], + dependencies: [ + .package(name: "Tauri", path: "../.tauri/tauri-api") + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .target( + name: "tauri-plugin-haptics", + dependencies: [ + .byName(name: "Tauri") + ], + path: "Sources") + ] +) diff --git a/plugins/haptics/ios/README.md b/plugins/haptics/ios/README.md new file mode 100644 index 00000000..3f7138b5 --- /dev/null +++ b/plugins/haptics/ios/README.md @@ -0,0 +1,3 @@ +# Tauri Plugin Haptics + +A description of this package. diff --git a/plugins/haptics/ios/Sources/HapticsPlugin.swift b/plugins/haptics/ios/Sources/HapticsPlugin.swift new file mode 100644 index 00000000..96e3f275 --- /dev/null +++ b/plugins/haptics/ios/Sources/HapticsPlugin.swift @@ -0,0 +1,133 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import SwiftRs +import Tauri +import UIKit +import WebKit +import CoreHaptics +import AudioToolbox + +class ImpactFeedbackOptions: Decodable { + let style: ImpactFeedbackStyle +} + +enum ImpactFeedbackStyle: String, Decodable { + case light, medium, heavy, soft, rigid + + func into() -> UIImpactFeedbackGenerator.FeedbackStyle { + switch self { + case .light: + return .light + case .medium: + return .medium + case .heavy: + return .heavy + case .soft: + return .soft + case .rigid: + return .rigid + } + } +} + +class NotificationFeedbackOptions: Decodable { + let type: NotificationFeedbackType +} + +enum NotificationFeedbackType: String, Decodable { + case success, warning, error + + func into() -> UINotificationFeedbackGenerator.FeedbackType { + switch self { + case .success: + return .success + case .warning: + return .warning + case .error: + return .error + } + } +} + +class VibrateOptions: Decodable { + // TODO: Array + let duration: Double +} + +class HapticsPlugin: Plugin { + // + // Tauri commands + // + + @objc public func vibrate(_ invoke: Invoke) throws { + let args = try invoke.parseArgs(VibrateOptions.self) + if CHHapticEngine.capabilitiesForHardware().supportsHaptics { + do { + let engine = try CHHapticEngine() + try engine.start() + engine.resetHandler = { [] in + do { + try engine.start() + } catch { + AudioServicesPlayAlertSound(kSystemSoundID_Vibrate) + } + } + // TODO: Make some of this (or all) configurable? + let intensity: CHHapticEventParameter = CHHapticEventParameter(parameterID: .hapticIntensity, value: 1.0) + let sharpness: CHHapticEventParameter = CHHapticEventParameter(parameterID: .hapticSharpness, value: 1.0) + let continuousEvent = CHHapticEvent( + eventType: .hapticContinuous, + parameters: [intensity, sharpness], + relativeTime: 0.0, + duration: args.duration/1000 + ) + let pattern = try CHHapticPattern(events: [continuousEvent], parameters: []) + let player = try engine.makePlayer(with: pattern) + + try player.start(atTime: 0) + } catch { + AudioServicesPlayAlertSound(kSystemSoundID_Vibrate) + } + } else { + AudioServicesPlayAlertSound(kSystemSoundID_Vibrate) + } + + Logger.error("VIBRATE END") + + invoke.resolve() + } + + @objc public func impactFeedback(_ invoke: Invoke) throws { + let args = try invoke.parseArgs(ImpactFeedbackOptions.self) + let generator = UIImpactFeedbackGenerator(style: args.style.into()) + generator.prepare() + generator.impactOccurred() + + invoke.resolve() + } + + @objc public func notificationFeedback(_ invoke: Invoke) throws { + let args = try invoke.parseArgs(NotificationFeedbackOptions.self) + let generator = UINotificationFeedbackGenerator() + generator.prepare() + generator.notificationOccurred(args.type.into()) + + invoke.resolve() + } + + // TODO: Consider breaking this up into Start,Change,End like capacitor + @objc public func selectionFeedback(_ invoke: Invoke) throws { + let generator = UISelectionFeedbackGenerator() + generator.prepare() + generator.selectionChanged() + + invoke.resolve() + } +} + +@_cdecl("init_plugin_haptics") +func initPlugin() -> Plugin { + return HapticsPlugin() +} diff --git a/plugins/haptics/ios/Tests/PluginTests/PluginTests.swift b/plugins/haptics/ios/Tests/PluginTests/PluginTests.swift new file mode 100644 index 00000000..99992ce4 --- /dev/null +++ b/plugins/haptics/ios/Tests/PluginTests/PluginTests.swift @@ -0,0 +1,12 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import XCTest +@testable import ExamplePlugin + +final class ExamplePluginTests: XCTestCase { + func testExample() throws { + let plugin = ExamplePlugin() + } +} diff --git a/plugins/haptics/package.json b/plugins/haptics/package.json new file mode 100644 index 00000000..12c5b74b --- /dev/null +++ b/plugins/haptics/package.json @@ -0,0 +1,29 @@ +{ + "name": "@tauri-apps/plugin-haptics", + "version": "2.2.4", + "license": "MIT OR Apache-2.0", + "authors": [ + "Tauri Programme within The Commons Conservancy" + ], + "repository": "https://github.com/tauri-apps/plugins-workspace", + "type": "module", + "types": "./dist-js/index.d.ts", + "main": "./dist-js/index.cjs", + "module": "./dist-js/index.js", + "exports": { + "types": "./dist-js/index.d.ts", + "import": "./dist-js/index.js", + "require": "./dist-js/index.cjs" + }, + "scripts": { + "build": "rollup -c" + }, + "files": [ + "dist-js", + "README.md", + "LICENSE" + ], + "dependencies": { + "@tauri-apps/api": "^2.0.0" + } +} diff --git a/plugins/haptics/permissions/autogenerated/commands/impact_feedback.toml b/plugins/haptics/permissions/autogenerated/commands/impact_feedback.toml new file mode 100644 index 00000000..13fce392 --- /dev/null +++ b/plugins/haptics/permissions/autogenerated/commands/impact_feedback.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-impact-feedback" +description = "Enables the impact_feedback command without any pre-configured scope." +commands.allow = ["impact_feedback"] + +[[permission]] +identifier = "deny-impact-feedback" +description = "Denies the impact_feedback command without any pre-configured scope." +commands.deny = ["impact_feedback"] diff --git a/plugins/haptics/permissions/autogenerated/commands/notification_feedback.toml b/plugins/haptics/permissions/autogenerated/commands/notification_feedback.toml new file mode 100644 index 00000000..0c2782c5 --- /dev/null +++ b/plugins/haptics/permissions/autogenerated/commands/notification_feedback.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-notification-feedback" +description = "Enables the notification_feedback command without any pre-configured scope." +commands.allow = ["notification_feedback"] + +[[permission]] +identifier = "deny-notification-feedback" +description = "Denies the notification_feedback command without any pre-configured scope." +commands.deny = ["notification_feedback"] diff --git a/plugins/haptics/permissions/autogenerated/commands/selection_feedback.toml b/plugins/haptics/permissions/autogenerated/commands/selection_feedback.toml new file mode 100644 index 00000000..63e645d8 --- /dev/null +++ b/plugins/haptics/permissions/autogenerated/commands/selection_feedback.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-selection-feedback" +description = "Enables the selection_feedback command without any pre-configured scope." +commands.allow = ["selection_feedback"] + +[[permission]] +identifier = "deny-selection-feedback" +description = "Denies the selection_feedback command without any pre-configured scope." +commands.deny = ["selection_feedback"] diff --git a/plugins/haptics/permissions/autogenerated/commands/vibrate.toml b/plugins/haptics/permissions/autogenerated/commands/vibrate.toml new file mode 100644 index 00000000..4c2fe94e --- /dev/null +++ b/plugins/haptics/permissions/autogenerated/commands/vibrate.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-vibrate" +description = "Enables the vibrate command without any pre-configured scope." +commands.allow = ["vibrate"] + +[[permission]] +identifier = "deny-vibrate" +description = "Denies the vibrate command without any pre-configured scope." +commands.deny = ["vibrate"] diff --git a/plugins/haptics/permissions/autogenerated/reference.md b/plugins/haptics/permissions/autogenerated/reference.md new file mode 100644 index 00000000..c2d0dd5d --- /dev/null +++ b/plugins/haptics/permissions/autogenerated/reference.md @@ -0,0 +1,114 @@ + +## Permission Table + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IdentifierDescription
+ +`haptics:allow-impact-feedback` + + + +Enables the impact_feedback command without any pre-configured scope. + +
+ +`haptics:deny-impact-feedback` + + + +Denies the impact_feedback command without any pre-configured scope. + +
+ +`haptics:allow-notification-feedback` + + + +Enables the notification_feedback command without any pre-configured scope. + +
+ +`haptics:deny-notification-feedback` + + + +Denies the notification_feedback command without any pre-configured scope. + +
+ +`haptics:allow-selection-feedback` + + + +Enables the selection_feedback command without any pre-configured scope. + +
+ +`haptics:deny-selection-feedback` + + + +Denies the selection_feedback command without any pre-configured scope. + +
+ +`haptics:allow-vibrate` + + + +Enables the vibrate command without any pre-configured scope. + +
+ +`haptics:deny-vibrate` + + + +Denies the vibrate command without any pre-configured scope. + +
diff --git a/plugins/haptics/permissions/schemas/schema.json b/plugins/haptics/permissions/schemas/schema.json new file mode 100644 index 00000000..ed217dc4 --- /dev/null +++ b/plugins/haptics/permissions/schemas/schema.json @@ -0,0 +1,348 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "PermissionFile", + "description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.", + "type": "object", + "properties": { + "default": { + "description": "The default permission set for the plugin", + "anyOf": [ + { + "$ref": "#/definitions/DefaultPermission" + }, + { + "type": "null" + } + ] + }, + "set": { + "description": "A list of permissions sets defined", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionSet" + } + }, + "permission": { + "description": "A list of inlined permissions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Permission" + } + } + }, + "definitions": { + "DefaultPermission": { + "description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.", + "type": "object", + "required": [ + "permissions" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "PermissionSet": { + "description": "A set of direct permissions grouped together under a new name.", + "type": "object", + "required": [ + "description", + "identifier", + "permissions" + ], + "properties": { + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does.", + "type": "string" + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionKind" + } + } + } + }, + "Permission": { + "description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.", + "type": "object", + "required": [ + "identifier" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri internal convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "commands": { + "description": "Allowed or denied commands when using this permission.", + "default": { + "allow": [], + "deny": [] + }, + "allOf": [ + { + "$ref": "#/definitions/Commands" + } + ] + }, + "scope": { + "description": "Allowed or denied scoped when using this permission.", + "allOf": [ + { + "$ref": "#/definitions/Scopes" + } + ] + }, + "platforms": { + "description": "Target platforms this permission applies. By default all platforms are affected by this permission.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Target" + } + } + } + }, + "Commands": { + "description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.", + "type": "object", + "properties": { + "allow": { + "description": "Allowed command.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "deny": { + "description": "Denied command, which takes priority.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "Scopes": { + "description": "An argument for fine grained behavior control of Tauri commands.\n\nIt can be of any serde serializable type and is used to allow or prevent certain actions inside a Tauri command. The configured scope is passed to the command and will be enforced by the command implementation.\n\n## Example\n\n```json { \"allow\": [{ \"path\": \"$HOME/**\" }], \"deny\": [{ \"path\": \"$HOME/secret.txt\" }] } ```", + "type": "object", + "properties": { + "allow": { + "description": "Data that defines what is allowed by the scope.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + }, + "deny": { + "description": "Data that defines what is denied by the scope. This should be prioritized by validation logic.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + } + } + }, + "Value": { + "description": "All supported ACL values.", + "anyOf": [ + { + "description": "Represents a null JSON value.", + "type": "null" + }, + { + "description": "Represents a [`bool`].", + "type": "boolean" + }, + { + "description": "Represents a valid ACL [`Number`].", + "allOf": [ + { + "$ref": "#/definitions/Number" + } + ] + }, + { + "description": "Represents a [`String`].", + "type": "string" + }, + { + "description": "Represents a list of other [`Value`]s.", + "type": "array", + "items": { + "$ref": "#/definitions/Value" + } + }, + { + "description": "Represents a map of [`String`] keys to [`Value`]s.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/Value" + } + } + ] + }, + "Number": { + "description": "A valid ACL number.", + "anyOf": [ + { + "description": "Represents an [`i64`].", + "type": "integer", + "format": "int64" + }, + { + "description": "Represents a [`f64`].", + "type": "number", + "format": "double" + } + ] + }, + "Target": { + "description": "Platform target.", + "oneOf": [ + { + "description": "MacOS.", + "type": "string", + "enum": [ + "macOS" + ] + }, + { + "description": "Windows.", + "type": "string", + "enum": [ + "windows" + ] + }, + { + "description": "Linux.", + "type": "string", + "enum": [ + "linux" + ] + }, + { + "description": "Android.", + "type": "string", + "enum": [ + "android" + ] + }, + { + "description": "iOS.", + "type": "string", + "enum": [ + "iOS" + ] + } + ] + }, + "PermissionKind": { + "type": "string", + "oneOf": [ + { + "description": "Enables the impact_feedback command without any pre-configured scope.", + "type": "string", + "const": "allow-impact-feedback", + "markdownDescription": "Enables the impact_feedback command without any pre-configured scope." + }, + { + "description": "Denies the impact_feedback command without any pre-configured scope.", + "type": "string", + "const": "deny-impact-feedback", + "markdownDescription": "Denies the impact_feedback command without any pre-configured scope." + }, + { + "description": "Enables the notification_feedback command without any pre-configured scope.", + "type": "string", + "const": "allow-notification-feedback", + "markdownDescription": "Enables the notification_feedback command without any pre-configured scope." + }, + { + "description": "Denies the notification_feedback command without any pre-configured scope.", + "type": "string", + "const": "deny-notification-feedback", + "markdownDescription": "Denies the notification_feedback command without any pre-configured scope." + }, + { + "description": "Enables the selection_feedback command without any pre-configured scope.", + "type": "string", + "const": "allow-selection-feedback", + "markdownDescription": "Enables the selection_feedback command without any pre-configured scope." + }, + { + "description": "Denies the selection_feedback command without any pre-configured scope.", + "type": "string", + "const": "deny-selection-feedback", + "markdownDescription": "Denies the selection_feedback command without any pre-configured scope." + }, + { + "description": "Enables the vibrate command without any pre-configured scope.", + "type": "string", + "const": "allow-vibrate", + "markdownDescription": "Enables the vibrate command without any pre-configured scope." + }, + { + "description": "Denies the vibrate command without any pre-configured scope.", + "type": "string", + "const": "deny-vibrate", + "markdownDescription": "Denies the vibrate command without any pre-configured scope." + } + ] + } + } +} \ No newline at end of file diff --git a/plugins/haptics/rollup.config.js b/plugins/haptics/rollup.config.js new file mode 100644 index 00000000..1f349ec8 --- /dev/null +++ b/plugins/haptics/rollup.config.js @@ -0,0 +1,7 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import { createConfig } from '../../shared/rollup.config.js' + +export default createConfig() diff --git a/plugins/haptics/src/commands.rs b/plugins/haptics/src/commands.rs new file mode 100644 index 00000000..76f097c0 --- /dev/null +++ b/plugins/haptics/src/commands.rs @@ -0,0 +1,33 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use tauri::{command, AppHandle, Runtime}; + +use crate::{HapticsExt, ImpactFeedbackStyle, NotificationFeedbackType, Result}; + +#[command] +pub(crate) async fn vibrate(app: AppHandle, duration: u32) -> Result<()> { + app.haptics().vibrate(duration) +} + +#[command] +pub(crate) async fn impact_feedback( + app: AppHandle, + style: ImpactFeedbackStyle, +) -> Result<()> { + app.haptics().impact_feedback(style) +} + +#[command] +pub(crate) async fn notification_feedback( + app: AppHandle, + r#type: NotificationFeedbackType, +) -> Result<()> { + app.haptics().notification_feedback(r#type) +} + +#[command] +pub(crate) async fn selection_feedback(app: AppHandle) -> Result<()> { + app.haptics().selection_feedback() +} diff --git a/plugins/haptics/src/desktop.rs b/plugins/haptics/src/desktop.rs new file mode 100644 index 00000000..b04b7567 --- /dev/null +++ b/plugins/haptics/src/desktop.rs @@ -0,0 +1,36 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use serde::de::DeserializeOwned; +use tauri::{plugin::PluginApi, AppHandle, Runtime}; + +use crate::models::*; + +pub fn init( + app: &AppHandle, + _api: PluginApi, +) -> crate::Result> { + Ok(Haptics(app.clone())) +} + +/// Access to the haptics APIs. +pub struct Haptics(AppHandle); + +impl Haptics { + pub fn vibrate(&self, _duration: u32) -> crate::Result<()> { + Ok(()) + } + + pub fn impact_feedback(&self, _style: ImpactFeedbackStyle) -> crate::Result<()> { + Ok(()) + } + + pub fn notification_feedback(&self, _type: NotificationFeedbackType) -> crate::Result<()> { + Ok(()) + } + + pub fn selection_feedback(&self) -> crate::Result<()> { + Ok(()) + } +} diff --git a/plugins/haptics/src/error.rs b/plugins/haptics/src/error.rs new file mode 100644 index 00000000..0fba5445 --- /dev/null +++ b/plugins/haptics/src/error.rs @@ -0,0 +1,30 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use serde::{ser::Serializer, Serialize}; + +pub type Result = std::result::Result; + +// TODO: Improve Error handling (different typed errors instead of one (stringified) PluginInvokeError for all mobile errors) + +#[derive(Debug, thiserror::Error)] +#[cfg_attr(feature = "specta", derive(specta::Type))] +pub enum Error { + #[cfg(mobile)] + #[error(transparent)] + PluginInvoke( + #[cfg_attr(feature = "specta", serde(skip))] + #[from] + tauri::plugin::mobile::PluginInvokeError, + ), +} + +impl Serialize for Error { + fn serialize(&self, serializer: S) -> std::result::Result + where + S: Serializer, + { + serializer.serialize_str(self.to_string().as_ref()) + } +} diff --git a/plugins/haptics/src/lib.rs b/plugins/haptics/src/lib.rs new file mode 100644 index 00000000..31798743 --- /dev/null +++ b/plugins/haptics/src/lib.rs @@ -0,0 +1,57 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use tauri::{ + plugin::{Builder, TauriPlugin}, + Manager, Runtime, +}; + +pub use models::*; + +#[cfg(desktop)] +mod desktop; +#[cfg(mobile)] +mod mobile; + +mod commands; +mod error; +mod models; + +pub use error::{Error, Result}; + +#[cfg(desktop)] +pub use desktop::Haptics; +#[cfg(mobile)] +pub use mobile::Haptics; + +/// Extensions to [`tauri::App`], [`tauri::AppHandle`], [`tauri::WebviewWindow`], [`tauri::Webview`] and [`tauri::Window`] to access the haptics APIs. +pub trait HapticsExt { + fn haptics(&self) -> &Haptics; +} + +impl> crate::HapticsExt for T { + fn haptics(&self) -> &Haptics { + self.state::>().inner() + } +} + +/// Initializes the plugin. +pub fn init() -> TauriPlugin { + Builder::new("haptics") + .invoke_handler(tauri::generate_handler![ + commands::vibrate, + commands::impact_feedback, + commands::notification_feedback, + commands::selection_feedback + ]) + .setup(|app, api| { + #[cfg(mobile)] + let haptics = mobile::init(app, api)?; + #[cfg(desktop)] + let haptics = desktop::init(app, api)?; + app.manage(haptics); + Ok(()) + }) + .build() +} diff --git a/plugins/haptics/src/mobile.rs b/plugins/haptics/src/mobile.rs new file mode 100644 index 00000000..2b1e2036 --- /dev/null +++ b/plugins/haptics/src/mobile.rs @@ -0,0 +1,76 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use serde::{de::DeserializeOwned, Serialize}; +use tauri::{ + plugin::{PluginApi, PluginHandle}, + AppHandle, Runtime, +}; + +use crate::models::*; + +#[cfg(target_os = "android")] +const PLUGIN_IDENTIFIER: &str = "app.tauri.haptics"; + +#[cfg(target_os = "ios")] +tauri::ios_plugin_binding!(init_plugin_haptics); + +// initializes the Kotlin or Swift plugin classes +pub fn init( + _app: &AppHandle, + api: PluginApi, +) -> crate::Result> { + #[cfg(target_os = "android")] + let handle = api.register_android_plugin(PLUGIN_IDENTIFIER, "HapticsPlugin")?; + #[cfg(target_os = "ios")] + let handle = api.register_ios_plugin(init_plugin_haptics)?; + Ok(Haptics(handle)) +} + +/// Access to the haptics APIs. +pub struct Haptics(PluginHandle); + +impl Haptics { + pub fn vibrate(&self, duration: u32) -> crate::Result<()> { + self.0 + .run_mobile_plugin("vibrate", VibratePayload { duration }) + .map_err(Into::into) + } + + pub fn impact_feedback(&self, style: ImpactFeedbackStyle) -> crate::Result<()> { + self.0 + .run_mobile_plugin("impactFeedback", ImpactFeedbackPayload { style }) + .map_err(Into::into) + } + + pub fn notification_feedback(&self, r#type: NotificationFeedbackType) -> crate::Result<()> { + self.0 + .run_mobile_plugin( + "notificationFeedback", + NotificationFeedbackPayload { r#type }, + ) + .map_err(Into::into) + } + + pub fn selection_feedback(&self) -> crate::Result<()> { + self.0 + .run_mobile_plugin("selectionFeedback", ()) + .map_err(Into::into) + } +} + +#[derive(Serialize)] +struct VibratePayload { + duration: u32, +} + +#[derive(Serialize)] +struct ImpactFeedbackPayload { + style: ImpactFeedbackStyle, +} + +#[derive(Serialize)] +struct NotificationFeedbackPayload { + r#type: NotificationFeedbackType, +} diff --git a/plugins/haptics/src/models.rs b/plugins/haptics/src/models.rs new file mode 100644 index 00000000..50a1fb16 --- /dev/null +++ b/plugins/haptics/src/models.rs @@ -0,0 +1,36 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use serde::{Deserialize, Serialize}; +/* +#[derive(Debug, Clone, Default, Serialize, Deserialize)] +#[cfg_attr(feature = "specta", derive(specta::Type))] +#[serde(rename_all = "camelCase")] +pub struct HapticsOptions { + // TODO: support array to match web api + pub duration: u32, +} + */ + +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] +#[cfg_attr(feature = "specta", derive(specta::Type))] +#[serde(rename_all = "camelCase")] +pub enum ImpactFeedbackStyle { + Light, + #[default] + Medium, + Heavy, + Soft, + Rigid, +} + +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] +#[cfg_attr(feature = "specta", derive(specta::Type))] +#[serde(rename_all = "camelCase")] +pub enum NotificationFeedbackType { + #[default] + Success, + Warning, + Error, +} diff --git a/plugins/haptics/tsconfig.json b/plugins/haptics/tsconfig.json new file mode 100644 index 00000000..5098169a --- /dev/null +++ b/plugins/haptics/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.base.json", + "include": ["guest-js/*.ts"] +} diff --git a/plugins/http/CHANGELOG.md b/plugins/http/CHANGELOG.md index ef8f521d..83120cba 100644 --- a/plugins/http/CHANGELOG.md +++ b/plugins/http/CHANGELOG.md @@ -1,5 +1,238 @@ # Changelog +## \[2.4.4] + +- [`ff384cba`](https://github.com/tauri-apps/plugins-workspace/commit/ff384cbabe82ae715798a4ee49fd07ffcfbcdb5d) ([#2636](https://github.com/tauri-apps/plugins-workspace/pull/2636) by [@asomethings](https://github.com/tauri-apps/plugins-workspace/../../asomethings)) Properly handle responses with status code 204. + +### Dependencies + +- Upgraded to `fs-js@2.3.0` + +## \[2.4.3] + +- [`37c0477a`](https://github.com/tauri-apps/plugins-workspace/commit/37c0477afe926d326573f1827045875ce8bf8187) ([#2561](https://github.com/tauri-apps/plugins-workspace/pull/2561)) Add `zstd` cargo feature flag to enable `reqwest/zstd` flag. +- [`9ebbfb2e`](https://github.com/tauri-apps/plugins-workspace/commit/9ebbfb2e3ccef8e0f277a0c02fe6b399b41feeb6) ([#1978](https://github.com/tauri-apps/plugins-workspace/pull/1978)) Persist cookies to disk and load it on next app start. + +### Dependencies + +- Upgraded to `fs-js@2.2.1` + +## \[2.4.2] + +- [`a15eedf3`](https://github.com/tauri-apps/plugins-workspace/commit/a15eedf37854344f7ffbcb0d373d848563817011) ([#2535](https://github.com/tauri-apps/plugins-workspace/pull/2535) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Fix `fetch` occasionally throwing an error due to trying to close the underline stream twice. + +## \[2.4.1] + +- [`d3183aa9`](https://github.com/tauri-apps/plugins-workspace/commit/d3183aa99da7ca67e627394132ddeb3b85ccef06) ([#2522](https://github.com/tauri-apps/plugins-workspace/pull/2522) by [@adrieljss](https://github.com/tauri-apps/plugins-workspace/../../adrieljss)) Fix `fetch` blocking until the whole response is read even if it was a streaming response. + +## \[2.4.0] + +- [`cb38f54f`](https://github.com/tauri-apps/plugins-workspace/commit/cb38f54f4a4ef30995283cd82166c62da17bac44) ([#2479](https://github.com/tauri-apps/plugins-workspace/pull/2479) by [@adrieljss](https://github.com/tauri-apps/plugins-workspace/../../adrieljss)) Add stream support for HTTP stream responses. + +## \[2.3.0] + +- [`10513649`](https://github.com/tauri-apps/plugins-workspace/commit/105136494c5a5bf4b1f1cc06cc71815412d17ec8) ([#2204](https://github.com/tauri-apps/plugins-workspace/pull/2204) by [@RickeyWard](https://github.com/tauri-apps/plugins-workspace/../../RickeyWard)) Add `dangerous-settings` feature flag and new JS `danger` option to disable tls hostname/certificate validation. + +## \[2.2.0] + +- [`3a79266b`](https://github.com/tauri-apps/plugins-workspace/commit/3a79266b8cf96a55b1ae6339d725567d45a44b1d) ([#2173](https://github.com/tauri-apps/plugins-workspace/pull/2173) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Bumped all plugins to `v2.2.0`. From now, the versions for the Rust and JavaScript packages of each plugin will be in sync with each other. + +### Dependencies + +- Upgraded to `fs@2.2.0` + +## \[2.0.2] + +### Dependencies + +- Upgraded to `fs-js@2.0.4` + +## \[2.0.4] + +- [`a3b553dd`](https://github.com/tauri-apps/plugins-workspace/commit/a3b553ddb403771aa699362c4e69a064b7731da5) ([#2079](https://github.com/tauri-apps/plugins-workspace/pull/2079) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Add tracing logs for requestes and responses behind `tracing` feature flag. + +### Dependencies + +- Upgraded to `fs@2.1.0` + +## \[2.0.3] + +### Dependencies + +- Upgraded to `fs@2.0.3` + +## \[2.0.1] + +- [`cfd48b3b`](https://github.com/tauri-apps/plugins-workspace/commit/cfd48b3b2ec0fccfc162197518694ed59ceda22c) ([#1941](https://github.com/tauri-apps/plugins-workspace/pull/1941) by [@Nipsuli](https://github.com/tauri-apps/plugins-workspace/../../Nipsuli)) Allow skipping sending `Origin` header in HTTP requests by setting `Origin` header to an empty string when calling `fetch`. +- [`9b2840db`](https://github.com/tauri-apps/plugins-workspace/commit/9b2840db9464cf08db75806270e4441f0af81e5d) ([#1884](https://github.com/tauri-apps/plugins-workspace/pull/1884) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Retain headers order. + +## \[2.0.1] + +- [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. + +### Dependencies + +- Upgraded to `fs@2.0.1` + +## \[2.0.0] + +- [`e2c4dfb6`](https://github.com/tauri-apps/plugins-workspace/commit/e2c4dfb6af43e5dd8d9ceba232c315f5febd55c1) Update to tauri v2 stable release. + +### Dependencies + +- Upgraded to `fs@2.0.0` + +## \[2.0.0-rc.6] + +### Dependencies + +- Upgraded to `fs@2.0.0-rc.6` + +## \[2.0.0-rc.5] + +### Dependencies + +- Upgraded to `fs@2.0.0-rc.5` + +## \[2.0.0-rc.4] + +### Dependencies + +- Upgraded to `fs@2.0.0-rc.4` + +## \[2.0.0-rc.3] + +### Dependencies + +- Upgraded to `fs@2.0.0-rc.3` + +## \[2.0.0-rc.2] + +### Dependencies + +- Upgraded to `fs@2.0.0-rc.2` + +## \[2.0.0-rc.2] + +- [`e2e97db5`](https://github.com/tauri-apps/plugins-workspace/commit/e2e97db51983267f5be84d4f6f0278d58834d1f5) ([#1701](https://github.com/tauri-apps/plugins-workspace/pull/1701) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri 2.0.0-rc.8 + +## \[2.0.0-rc.1] + +- [`84f8bd5e`](https://github.com/tauri-apps/plugins-workspace/commit/84f8bd5e1ef22e664267380b5bbf756ebc5389c3) ([#1662](https://github.com/tauri-apps/plugins-workspace/pull/1662) by [@twlite](https://github.com/tauri-apps/plugins-workspace/../../twlite)) Fixed an issue with abort signal not aborting the fetch request. + +## \[2.0.0-rc.0] + +- [`9887d1`](https://github.com/tauri-apps/plugins-workspace/commit/9887d14bd0e971c4c0f5c1188fc4005d3fc2e29e) Update to tauri RC. + +### Dependencies + +- Upgraded to `fs@2.0.0-rc.0` + +## \[2.0.0-beta.9] + +- [`99d6ac0f`](https://github.com/tauri-apps/plugins-workspace/commit/99d6ac0f9506a6a4a1aa59c728157190a7441af6) ([#1606](https://github.com/tauri-apps/plugins-workspace/pull/1606) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) The JS packages now specify the *minimum* `@tauri-apps/api` version instead of a single exact version. +- [`6de87966`](https://github.com/tauri-apps/plugins-workspace/commit/6de87966ecc00ad9d91c25be452f1f46bd2b7e1f) ([#1597](https://github.com/tauri-apps/plugins-workspace/pull/1597) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Update to tauri beta.25. + +## \[2.0.0-beta.8] + +- [`ac9a25cc`](https://github.com/tauri-apps/plugins-workspace/commit/ac9a25cc12ee2b325f00212ba74316da3369bde5) ([#1395](https://github.com/tauri-apps/plugins-workspace/pull/1395) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Fix cancelling requests using `AbortSignal`. +- [`a6654932`](https://github.com/tauri-apps/plugins-workspace/commit/a66549329c60dea35e3a06a38c357e368c9053a1) ([#1526](https://github.com/tauri-apps/plugins-workspace/pull/1526) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Fix missing `Set-Cookie` headers in the response which meant `request.headers.getSetCookie()` always returned empty array. +- [`22a17980`](https://github.com/tauri-apps/plugins-workspace/commit/22a17980ff4f6f8c40adb1b8f4ffc6dae2fe7e30) ([#1537](https://github.com/tauri-apps/plugins-workspace/pull/1537) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri beta.24. + +## \[2.0.0-beta.7] + +- [`76daee7a`](https://github.com/tauri-apps/plugins-workspace/commit/76daee7aafece34de3092c86e531cf9eb1138989) ([#1512](https://github.com/tauri-apps/plugins-workspace/pull/1512) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Update to tauri beta.23. + +## \[2.0.0-beta.6] + +- [`0f739dbc`](https://github.com/tauri-apps/plugins-workspace/commit/0f739dbc483a1f091977cbe575c3862fd39f8cf1) ([#1392](https://github.com/tauri-apps/plugins-workspace/pull/1392) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Allow setting `Origin` header when `unsafe-headers` feature flag is active. + +## \[2.0.0-beta.5] + +- [`9013854f`](https://github.com/tauri-apps/plugins-workspace/commit/9013854f42a49a230b9dbb9d02774765528a923f)([#1382](https://github.com/tauri-apps/plugins-workspace/pull/1382)) Update to tauri beta.22. + +## \[2.0.0-beta.4] + +- [`9d7ae45b`](https://github.com/tauri-apps/plugins-workspace/commit/9d7ae45b0edf9b22c73e7d7c413a784bb35c3d77)([#1354](https://github.com/tauri-apps/plugins-workspace/pull/1354)) Include headers created by browser if not declared by user, which fixes missing headers like `Content-Type` when using `FormData`. +- [`430bd6f4`](https://github.com/tauri-apps/plugins-workspace/commit/430bd6f4f379bee5d232ae6b098ae131db7f178a)([#1363](https://github.com/tauri-apps/plugins-workspace/pull/1363)) Update to tauri beta.20. + +## \[2.0.0-beta.3] + +- [`bd1ed590`](https://github.com/tauri-apps/plugins-workspace/commit/bd1ed5903ffcce5500310dac1e59e8c67674ef1e)([#1237](https://github.com/tauri-apps/plugins-workspace/pull/1237)) Update to tauri beta.17. + +## \[2.0.0-beta.6] + +### Dependencies + +- Upgraded to `fs@2.0.0-beta.6` + +## \[2.0.0-beta.5] + +- [`500ff10`](https://github.com/tauri-apps/plugins-workspace/commit/500ff10fbd89fdfc73caf9d153029dad567b4ff1)([#1166](https://github.com/tauri-apps/plugins-workspace/pull/1166)) **Breaking change:** Removed the `default-tls` feature flag. The `rustls-tls`, `http2`, `macos-system-configuration`, and `charset` feature flags are now enabled by default. +- [`e3d41f4`](https://github.com/tauri-apps/plugins-workspace/commit/e3d41f4011bd3ea3ce281bb38bbe31d3709f8e0f)([#1191](https://github.com/tauri-apps/plugins-workspace/pull/1191)) Internally use the webview scoped resources table instead of the app one, so other webviews can't access other webviews resources. +- [`7e2fcc5`](https://github.com/tauri-apps/plugins-workspace/commit/7e2fcc5e74df7c3c718e40f75bfb0eafc7d69d8d)([#1146](https://github.com/tauri-apps/plugins-workspace/pull/1146)) Update dependencies to align with tauri 2.0.0-beta.14. +- [`e3d41f4`](https://github.com/tauri-apps/plugins-workspace/commit/e3d41f4011bd3ea3ce281bb38bbe31d3709f8e0f)([#1191](https://github.com/tauri-apps/plugins-workspace/pull/1191)) Update for tauri 2.0.0-beta.15. + +### Dependencies + +- Upgraded to `fs@2.0.0-beta.5` + +## \[2.0.0-beta.4] + +### Dependencies + +- Upgraded to `fs@2.0.0-beta.4` + +## \[2.0.0-beta.3] + +- [`c873e4d`](https://github.com/tauri-apps/plugins-workspace/commit/c873e4d6c74e759742f7c9a88e35cff10a75122a)([#1059](https://github.com/tauri-apps/plugins-workspace/pull/1059)) Fixes scope not allowing subpaths, query parameters and hash when those values are empty. +- [`a04ea2f`](https://github.com/tauri-apps/plugins-workspace/commit/a04ea2f38294d5a3987578283badc8eec87a7752)([#1071](https://github.com/tauri-apps/plugins-workspace/pull/1071)) The global API script is now only added to the binary when the `withGlobalTauri` config is true. +- [`753c7be`](https://github.com/tauri-apps/plugins-workspace/commit/753c7be0a6a78121d2e88ea0efc3040580c885b4)([#1050](https://github.com/tauri-apps/plugins-workspace/pull/1050)) Add `unsafe-headers` cargo feature flag to allow using [forbidden headers](https://fetch.spec.whatwg.org/#terminology-headers). + +### Dependencies + +- Upgraded to `fs@2.0.0-beta.3` + +## \[2.0.0-beta.2] + +- [`ae56b13`](https://github.com/tauri-apps/plugins-workspace/commit/ae56b13a4d49dbf922b8a0fbb0d557bb63c1d72b)([#983](https://github.com/tauri-apps/plugins-workspace/pull/983)) Allow `User-Agent` header to be set. +- [`99bea25`](https://github.com/tauri-apps/plugins-workspace/commit/99bea2559c2c0648c2519c50a18cd124dacef57b)([#1005](https://github.com/tauri-apps/plugins-workspace/pull/1005)) Update to tauri beta.8. + +## \[2.0.0-beta.1] + +- [`569defb`](https://github.com/tauri-apps/plugins-workspace/commit/569defbe9492e38938554bb7bdc1be9151456d21) Update to tauri beta.4. + +## \[2.0.0-beta.0] + +- [`d198c01`](https://github.com/tauri-apps/plugins-workspace/commit/d198c014863ee260cb0de88a14b7fc4356ef7474)([#862](https://github.com/tauri-apps/plugins-workspace/pull/862)) Update to tauri beta. +- [`1a34720`](https://github.com/tauri-apps/plugins-workspace/commit/1a347203a54eccc954749d11c4ee81fdd9a0cde7)([#858](https://github.com/tauri-apps/plugins-workspace/pull/858)) Fix http fetch client option init with parameter `connectTimeout` + +## \[2.0.0-alpha.9] + +### Dependencies + +- Upgraded to `fs@2.0.0-alpha.7` + +## \[2.0.0-alpha.6] + +- [`bfa87da`](https://github.com/tauri-apps/plugins-workspace/commit/bfa87da848f9f1da2abae3354eed632881eddf11)([#824](https://github.com/tauri-apps/plugins-workspace/pull/824)) Add `proxy` field to `fetch` options to configure proxy. + +## \[2.0.0-alpha.5] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.13. + +## \[2.0.0-alpha.4] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.12. + +## \[2.0.0-alpha.3] + +- [`e438e0a`](https://github.com/tauri-apps/plugins-workspace/commit/e438e0a62d4b430a5159f05f13ecd397dd891a0d)([#676](https://github.com/tauri-apps/plugins-workspace/pull/676)) Update to @tauri-apps/api v2.0.0-alpha.11. + +## \[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.9. + ## \[2.0.0-alpha.3] - [`2cb0fa7`](https://github.com/tauri-apps/plugins-workspace/commit/2cb0fa719b8b1f5ac07dada93520dbbcf637d64c)([#587](https://github.com/tauri-apps/plugins-workspace/pull/587)) Remove `cmd` property which breaks invoke call. diff --git a/plugins/http/Cargo.toml b/plugins/http/Cargo.toml index 49cb18b1..f3bdca36 100644 --- a/plugins/http/Cargo.toml +++ b/plugins/http/Cargo.toml @@ -1,44 +1,79 @@ [package] name = "tauri-plugin-http" -version = "2.0.0-alpha.3" +version = "2.4.4" description = "Access an HTTP client written in Rust." edition = { workspace = true } authors = { workspace = true } license = { workspace = true } rust-version = { workspace = true } +repository = { workspace = true } +links = "tauri-plugin-http" [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] + +[package.metadata.platforms.support] +windows = { level = "full", notes = "" } +linux = { level = "full", notes = "" } +macos = { level = "full", notes = "" } +android = { level = "full", notes = "" } +ios = { level = "full", notes = "" } + +[build-dependencies] +tauri-plugin = { workspace = true, features = ["build"] } +schemars = { workspace = true } +serde = { workspace = true } +url = { workspace = true } +urlpattern = "0.3" +regex = "1" [dependencies] serde = { workspace = true } serde_json = { workspace = true } tauri = { workspace = true } thiserror = { workspace = true } -tauri-plugin-fs = { path = "../fs", version = "2.0.0-alpha.2" } -glob = "0.3" -http = "0.2" -reqwest = { version = "0.11", default-features = false } -url = "2.4" +tokio = { version = "1", features = ["sync", "macros"] } +tauri-plugin-fs = { path = "../fs", version = "2.3.0" } +urlpattern = "0.3" +regex = "1" +http = "1" +reqwest = { version = "0.12", default-features = false } +url = { workspace = true } data-url = "0.3" +cookie_store = { version = "0.21.1", optional = true, features = ["serde"] } +bytes = { version = "1.9", optional = true } +tracing = { workspace = true, optional = true } [features] -multipart = [ "reqwest/multipart" ] -json = [ "reqwest/json" ] -stream = [ "reqwest/stream" ] -native-tls = [ "reqwest/native-tls" ] -native-tls-vendored = [ "reqwest/native-tls-vendored" ] -rustls-tls = [ "reqwest/rustls-tls" ] -default-tls = [ "reqwest/default-tls" ] -native-tls-alpn = [ "reqwest/native-tls-alpn" ] -rustls-tls-manual-roots = [ "reqwest/rustls-tls-manual-roots" ] -rustls-tls-webpki-roots = [ "reqwest/rustls-tls-webpki-roots" ] -rustls-tls-native-roots = [ "reqwest/rustls-tls-native-roots" ] -blocking = [ "reqwest/blocking" ] -cookies = [ "reqwest/cookies" ] -gzip = [ "reqwest/gzip" ] -brotli = [ "reqwest/brotli" ] -deflate = [ "reqwest/deflate" ] -trust-dns = [ "reqwest/trust-dns" ] -socks = [ "reqwest/socks" ] -http3 = [ "reqwest/http3" ] +default = [ + "rustls-tls", + "http2", + "charset", + "macos-system-configuration", + "cookies", +] +multipart = ["reqwest/multipart"] +json = ["reqwest/json"] +stream = ["reqwest/stream"] +native-tls = ["reqwest/native-tls"] +native-tls-vendored = ["reqwest/native-tls-vendored"] +native-tls-alpn = ["reqwest/native-tls-alpn"] +rustls-tls = ["reqwest/rustls-tls"] +rustls-tls-manual-roots = ["reqwest/rustls-tls-manual-roots"] +rustls-tls-webpki-roots = ["reqwest/rustls-tls-webpki-roots"] +rustls-tls-native-roots = ["reqwest/rustls-tls-native-roots"] +blocking = ["reqwest/blocking"] +cookies = ["reqwest/cookies", "dep:cookie_store", "dep:bytes"] +gzip = ["reqwest/gzip"] +brotli = ["reqwest/brotli"] +deflate = ["reqwest/deflate"] +zstd = ["reqwest/zstd"] +trust-dns = ["reqwest/trust-dns"] +socks = ["reqwest/socks"] +http2 = ["reqwest/http2"] +charset = ["reqwest/charset"] +macos-system-configuration = ["reqwest/macos-system-configuration"] +unsafe-headers = [] +tracing = ["dep:tracing"] +dangerous-settings = [] diff --git a/plugins/http/README.md b/plugins/http/README.md index b46b0e25..5c3cd9c2 100644 --- a/plugins/http/README.md +++ b/plugins/http/README.md @@ -2,9 +2,17 @@ Access the HTTP client written in Rust. +| Platform | Supported | +| -------- | --------- | +| Linux | ✓ | +| Windows | ✓ | +| macOS | ✓ | +| Android | ✓ | +| iOS | ✓ | + ## Install -_This plugin requires a Rust version of at least **1.70**_ +_This plugin requires a Rust version of at least **1.77.2**_ There are three general methods of installation that we can recommend. @@ -18,7 +26,7 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] -tauri-plugin-http = "2.0.0-alpha" +tauri-plugin-http = "2.0.0" # alternatively with Git: tauri-plugin-http = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -46,7 +54,7 @@ yarn add https://github.com/tauri-apps/tauri-plugin-http#v2 First you need to register the core plugin with Tauri: -`src-tauri/src/main.rs` +`src-tauri/src/lib.rs` ```rust fn main() { @@ -60,17 +68,33 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import { fetch } from "@tauri-apps/plugin-http"; -const response = await fetch("http://localhost:3003/users/2", { - method: "GET", - timeout: 30, -}); +import { fetch } from '@tauri-apps/plugin-http' +const response = await fetch('http://localhost:3003/users/2', { + method: 'GET', + timeout: 30 +}) ``` ## Contributing PRs accepted. Please make sure to read the Contributing Guide before making a pull request. +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + ## License Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. diff --git a/plugins/http/SECURITY.md b/plugins/http/SECURITY.md new file mode 100644 index 00000000..4f09bbac --- /dev/null +++ b/plugins/http/SECURITY.md @@ -0,0 +1,23 @@ +# Security Policy + +**Do not report security vulnerabilities through public GitHub issues.** + +**Please use the [Private Vulnerability Disclosure](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) feature of GitHub.** + +Include as much of the following information: + +- Type of issue (e.g. improper input parsing, privilege escalation, etc.) +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- The distribution affected or used to help us with reproduction of the issue +- Step-by-step instructions to reproduce the issue +- Ideally a reproduction repository +- Impact of the issue, including how an attacker might exploit the issue + +We prefer to receive reports in English. + +## Contact + +Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). + +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/http/api-iife.js b/plugins/http/api-iife.js new file mode 100644 index 00000000..70b99c24 --- /dev/null +++ b/plugins/http/api-iife.js @@ -0,0 +1 @@ +if("__TAURI__"in window){var __TAURI_PLUGIN_HTTP__=function(e){"use strict";function t(e,t,r,n){if("function"==typeof t||!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)}function r(e,t,r,n,s){if("function"==typeof t||!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,r),r}var n,s,i,a;"function"==typeof SuppressedError&&SuppressedError;const o="__TAURI_TO_IPC_KEY__";class c{constructor(e){n.set(this,void 0),s.set(this,0),i.set(this,[]),a.set(this,void 0),r(this,n,e||(()=>{})),this.id=function(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}((e=>{const o=e.index;if("end"in e)return void(o==t(this,s,"f")?this.cleanupCallback():r(this,a,o));const c=e.message;if(o==t(this,s,"f")){for(t(this,n,"f").call(this,c),r(this,s,t(this,s,"f")+1);t(this,s,"f")in t(this,i,"f");){const e=t(this,i,"f")[t(this,s,"f")];t(this,n,"f").call(this,e),delete t(this,i,"f")[t(this,s,"f")],r(this,s,t(this,s,"f")+1)}t(this,s,"f")===t(this,a,"f")&&this.cleanupCallback()}else t(this,i,"f")[o]=c}))}cleanupCallback(){Reflect.deleteProperty(window,`_${this.id}`)}set onmessage(e){r(this,n,e)}get onmessage(){return t(this,n,"f")}[(n=new WeakMap,s=new WeakMap,i=new WeakMap,a=new WeakMap,o)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[o]()}}async function d(e,t={},r){return window.__TAURI_INTERNALS__.invoke(e,t,r)}const h="Request cancelled";return e.fetch=async function(e,t){const r=t?.signal;if(r?.aborted)throw new Error(h);const n=t?.maxRedirections,s=t?.connectTimeout,i=t?.proxy,a=t?.danger;t&&(delete t.maxRedirections,delete t.connectTimeout,delete t.proxy,delete t.danger);const o=t?.headers?t.headers instanceof Headers?t.headers:new Headers(t.headers):new Headers,f=new Request(e,t),l=await f.arrayBuffer(),u=0!==l.byteLength?Array.from(new Uint8Array(l)):null;for(const[e,t]of f.headers)o.get(e)||o.set(e,t);const _=(o instanceof Headers?Array.from(o.entries()):Array.isArray(o)?o:Object.entries(o)).map((([e,t])=>[e,"string"==typeof t?t:t.toString()]));if(r?.aborted)throw new Error(h);const w=await d("plugin:http|fetch",{clientConfig:{method:f.method,url:f.url,headers:_,data:u,maxRedirections:n,connectTimeout:s,proxy:i,danger:a}}),p=()=>d("plugin:http|fetch_cancel",{rid:w});if(r?.aborted)throw p(),new Error(h);r?.addEventListener("abort",(()=>{p()}));const{status:y,statusText:m,url:b,headers:g,rid:T}=await d("plugin:http|fetch_send",{rid:w}),R=[101,103,204,205,304].includes(y)?null:new ReadableStream({start:e=>{const t=new c;t.onmessage=t=>{if(r?.aborted)return void e.error(h);const n=new Uint8Array(t),s=n[n.byteLength-1],i=n.slice(0,n.byteLength-1);1!=s?e.enqueue(i):e.close()},d("plugin:http|fetch_read_body",{rid:T,streamChannel:t}).catch((t=>{e.error(t)}))}}),A=new Response(R,{status:y,statusText:m});return Object.defineProperty(A,"url",{value:b}),Object.defineProperty(A,"headers",{value:new Headers(g)}),A},e}({});Object.defineProperty(window.__TAURI__,"http",{value:__TAURI_PLUGIN_HTTP__})} diff --git a/plugins/http/build.rs b/plugins/http/build.rs new file mode 100644 index 00000000..a4b802ad --- /dev/null +++ b/plugins/http/build.rs @@ -0,0 +1,67 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +#[path = "src/scope.rs"] +#[allow(dead_code)] +mod scope; + +const COMMANDS: &[&str] = &["fetch", "fetch_cancel", "fetch_send", "fetch_read_body"]; + +/// HTTP scope entry. +#[derive(schemars::JsonSchema)] +#[serde(untagged)] +#[allow(unused)] +enum HttpScopeEntry { + /// A URL that can be accessed by the webview when using the HTTP APIs. + /// Wildcards can be used following the URL pattern standard. + /// + /// See [the URL Pattern spec](https://urlpattern.spec.whatwg.org/) for more information. + /// + /// Examples: + /// + /// - "https://*" : allows all HTTPS origin on port 443 + /// + /// - "https://*:*" : allows all HTTPS origin on any port + /// + /// - "https://*.github.com/tauri-apps/tauri": allows any subdomain of "github.com" with the "tauri-apps/api" path + /// + /// - "https://myapi.service.com/users/*": allows access to any URLs that begins with "https://myapi.service.com/users/" + Value(String), + Object { + /// A URL that can be accessed by the webview when using the HTTP APIs. + /// Wildcards can be used following the URL pattern standard. + /// + /// See [the URL Pattern spec](https://urlpattern.spec.whatwg.org/) for more information. + /// + /// Examples: + /// + /// - "https://*" : allows all HTTPS origin on port 443 + /// + /// - "https://*:*" : allows all HTTPS origin on any port + /// + /// - "https://*.github.com/tauri-apps/tauri": allows any subdomain of "github.com" with the "tauri-apps/api" path + /// + /// - "https://myapi.service.com/users/*": allows access to any URLs that begins with "https://myapi.service.com/users/" + url: String, + }, +} + +// Ensure `HttpScopeEntry` and `scope::EntryRaw` is kept in sync +fn _f() { + match scope::EntryRaw::Value(String::new()) { + scope::EntryRaw::Value(url) => HttpScopeEntry::Value(url), + scope::EntryRaw::Object { url } => HttpScopeEntry::Object { url }, + }; + match HttpScopeEntry::Value(String::new()) { + HttpScopeEntry::Value(url) => scope::EntryRaw::Value(url), + HttpScopeEntry::Object { url } => scope::EntryRaw::Object { url }, + }; +} + +fn main() { + tauri_plugin::Builder::new(COMMANDS) + .global_api_script_path("./api-iife.js") + .global_scope_schema(schemars::schema_for!(HttpScopeEntry)) + .build(); +} diff --git a/plugins/http/guest-js/index.ts b/plugins/http/guest-js/index.ts index 27a2a151..4b38f8bf 100644 --- a/plugins/http/guest-js/index.ts +++ b/plugins/http/guest-js/index.ts @@ -7,16 +7,18 @@ * * ## Security * - * This API has a scope configuration that forces you to restrict the URLs and paths that can be accessed using glob patterns. + * This API has a scope configuration that forces you to restrict the URLs that can be accessed using glob patterns. * - * For instance, this scope configuration only allows making HTTP requests to the GitHub API for the `tauri-apps` organization: + * For instance, this scope configuration only allows making HTTP requests to all subdomains for `tauri.app` except for `https://private.tauri.app`: * ```json * { - * "plugins": { - * "http": { - * "scope": ["https://api.github.com/repos/tauri-apps/*"] + * "permissions": [ + * { + * "identifier": "http:default", + * "allow": [{ "url": "https://*.tauri.app" }], + * "deny": [{ "url": "https://private.tauri.app" }] * } - * } + * ] * } * ``` * Trying to execute any API with a URL not configured on the scope results in a promise rejection due to denied access. @@ -24,7 +26,46 @@ * @module */ -import { invoke } from "@tauri-apps/api/primitives"; +import { Channel, invoke } from '@tauri-apps/api/core' + +/** + * Configuration of a proxy that a Client should pass requests to. + * + * @since 2.0.0 + */ +export interface Proxy { + /** + * Proxy all traffic to the passed URL. + */ + all?: string | ProxyConfig + /** + * Proxy all HTTP traffic to the passed URL. + */ + http?: string | ProxyConfig + /** + * Proxy all HTTPS traffic to the passed URL. + */ + https?: string | ProxyConfig +} + +export interface ProxyConfig { + /** + * The URL of the proxy server. + */ + url: string + /** + * Set the `Proxy-Authorization` header using Basic auth. + */ + basicAuth?: { + username: string + password: string + } + /** + * A configuration for filtering out requests that shouldn't be proxied. + * Entries are expected to be comma-separated (whitespace between entries is ignored) + */ + noProxy?: string +} /** * Options to configure the Rust client used to make fetch requests @@ -36,11 +77,37 @@ export interface ClientOptions { * Defines the maximum number of redirects the client should follow. * If set to 0, no redirects will be followed. */ - maxRedirections?: number; + maxRedirections?: number /** Timeout in milliseconds */ - connectTimeout?: number; + connectTimeout?: number + /** + * Configuration of a proxy that a Client should pass requests to. + */ + proxy?: Proxy + /** + * Configuration for dangerous settings on the client such as disabling SSL verification. + */ + danger?: DangerousSettings +} + +/** + * Configuration for dangerous settings on the client such as disabling SSL verification. + * + * @since 2.3.0 + */ +export interface DangerousSettings { + /** + * Disables SSL verification. + */ + acceptInvalidCerts?: boolean + /** + * Disables hostname verification. + */ + acceptInvalidHostnames?: boolean } +const ERROR_REQUEST_CANCELLED = 'Request cancelled' + /** * Fetch a resource from the network. It returns a `Promise` that resolves to the * `Response` to that `Request`, whether it is successful or not. @@ -57,62 +124,162 @@ export interface ClientOptions { */ export async function fetch( input: URL | Request | string, - init?: RequestInit & ClientOptions, + init?: RequestInit & ClientOptions ): Promise { - const maxRedirections = init?.maxRedirections; - const connectTimeout = init?.maxRedirections; + // abort early here if needed + const signal = init?.signal + if (signal?.aborted) { + throw new Error(ERROR_REQUEST_CANCELLED) + } + + const maxRedirections = init?.maxRedirections + const connectTimeout = init?.connectTimeout + const proxy = init?.proxy + const danger = init?.danger // Remove these fields before creating the request if (init) { - delete init.maxRedirections; - delete init.connectTimeout; + delete init.maxRedirections + delete init.connectTimeout + delete init.proxy + delete init.danger } - const req = new Request(input, init); - const buffer = await req.arrayBuffer(); - const reqData = buffer.byteLength ? Array.from(new Uint8Array(buffer)) : null; - - const rid = await invoke("plugin:http|fetch", { - method: req.method, - url: req.url, - headers: Array.from(req.headers.entries()), - data: reqData, - maxRedirections, - connectTimeout, - }); - - req.signal.addEventListener("abort", () => { - invoke("plugin:http|fetch_cancel", { - rid, - }); - }); + const headers = init?.headers + ? init.headers instanceof Headers + ? init.headers + : new Headers(init.headers) + : new Headers() - interface FetchSendResponse { - status: number; - statusText: string; - headers: [[string, string]]; - url: string; + const req = new Request(input, init) + const buffer = await req.arrayBuffer() + const data = + buffer.byteLength !== 0 ? Array.from(new Uint8Array(buffer)) : null + + // append new headers created by the browser `Request` implementation, + // if not already declared by the caller of this function + for (const [key, value] of req.headers) { + if (!headers.get(key)) { + headers.set(key, value) + } + } + + const headersArray = + headers instanceof Headers + ? Array.from(headers.entries()) + : Array.isArray(headers) + ? headers + : Object.entries(headers) + + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment + const mappedHeaders: Array<[string, string]> = headersArray.map( + ([name, val]) => [ + name, + // we need to ensure we have all header values as strings + // eslint-disable-next-line + typeof val === 'string' ? val : (val as any).toString() + ] + ) + + // abort early here if needed + if (signal?.aborted) { + throw new Error(ERROR_REQUEST_CANCELLED) } - const { status, statusText, url, headers } = await invoke( - "plugin:http|fetch_send", - { - rid, - }, - ); + const rid = await invoke('plugin:http|fetch', { + clientConfig: { + method: req.method, + url: req.url, + headers: mappedHeaders, + data, + maxRedirections, + connectTimeout, + proxy, + danger + } + }) + + const abort = () => invoke('plugin:http|fetch_cancel', { rid }) + + // abort early here if needed + if (signal?.aborted) { + // we don't care about the result of this proimse + // eslint-disable-next-line @typescript-eslint/no-floating-promises + abort() + throw new Error(ERROR_REQUEST_CANCELLED) + } - const body = await invoke("plugin:http|fetch_read_body", { - rid, - }); + signal?.addEventListener('abort', () => void abort()) + + interface FetchSendResponse { + status: number + statusText: string + headers: [[string, string]] + url: string + rid: number + } - const res = new Response(new Uint8Array(body), { - headers, + const { status, statusText, - }); + url, + headers: responseHeaders, + rid: responseRid + } = await invoke('plugin:http|fetch_send', { + rid + }) + + // no body for 101, 103, 204, 205 and 304 + // see https://fetch.spec.whatwg.org/#null-body-status + const body = [101, 103, 204, 205, 304].includes(status) + ? null + : new ReadableStream({ + start: (controller) => { + const streamChannel = new Channel() + streamChannel.onmessage = (res: ArrayBuffer | number[]) => { + // close early if aborted + if (signal?.aborted) { + controller.error(ERROR_REQUEST_CANCELLED) + return + } + + const resUint8 = new Uint8Array(res) + const lastByte = resUint8[resUint8.byteLength - 1] + const actualRes = resUint8.slice(0, resUint8.byteLength - 1) + + // close when the signal to close (last byte is 1) is sent from the IPC. + if (lastByte == 1) { + controller.close() + return + } + + controller.enqueue(actualRes) + } + + // run a non-blocking body stream fetch + invoke('plugin:http|fetch_read_body', { + rid: responseRid, + streamChannel + }).catch((e) => { + controller.error(e) + }) + } + }) + + const res = new Response(body, { + status, + statusText + }) - // url is read only but seems like we can do this - Object.defineProperty(res, "url", { value: url }); + // Set `Response` properties that are ignored by the + // constructor, like url and some headers + // + // Since url and headers are read only properties + // this is the only way to set them. + Object.defineProperty(res, 'url', { value: url }) + Object.defineProperty(res, 'headers', { + value: new Headers(responseHeaders) + }) - return res; + return res } diff --git a/plugins/http/package.json b/plugins/http/package.json index 29ec4c1d..c1178af5 100644 --- a/plugins/http/package.json +++ b/plugins/http/package.json @@ -1,32 +1,29 @@ { "name": "@tauri-apps/plugin-http", - "version": "2.0.0-alpha.1", - "license": "MIT or APACHE-2.0", + "version": "2.4.4", + "license": "MIT OR Apache-2.0", "authors": [ "Tauri Programme within The Commons Conservancy" ], + "repository": "https://github.com/tauri-apps/plugins-workspace", "type": "module", - "browser": "dist-js/index.min.js", - "module": "dist-js/index.mjs", - "types": "dist-js/index.d.ts", + "types": "./dist-js/index.d.ts", + "main": "./dist-js/index.cjs", + "module": "./dist-js/index.js", "exports": { - "import": "./dist-js/index.mjs", "types": "./dist-js/index.d.ts", - "browser": "./dist-js/index.min.js" + "import": "./dist-js/index.js", + "require": "./dist-js/index.cjs" }, "scripts": { "build": "rollup -c" }, "files": [ "dist-js", - "!dist-js/**/*.map", "README.md", "LICENSE" ], - "devDependencies": { - "tslib": "^2.5.0" - }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.9" + "@tauri-apps/api": "^2.0.0" } } diff --git a/plugins/http/permissions/autogenerated/commands/fetch.toml b/plugins/http/permissions/autogenerated/commands/fetch.toml new file mode 100644 index 00000000..c4e068a7 --- /dev/null +++ b/plugins/http/permissions/autogenerated/commands/fetch.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-fetch" +description = "Enables the fetch command without any pre-configured scope." +commands.allow = ["fetch"] + +[[permission]] +identifier = "deny-fetch" +description = "Denies the fetch command without any pre-configured scope." +commands.deny = ["fetch"] diff --git a/plugins/http/permissions/autogenerated/commands/fetch_cancel.toml b/plugins/http/permissions/autogenerated/commands/fetch_cancel.toml new file mode 100644 index 00000000..70c1139b --- /dev/null +++ b/plugins/http/permissions/autogenerated/commands/fetch_cancel.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-fetch-cancel" +description = "Enables the fetch_cancel command without any pre-configured scope." +commands.allow = ["fetch_cancel"] + +[[permission]] +identifier = "deny-fetch-cancel" +description = "Denies the fetch_cancel command without any pre-configured scope." +commands.deny = ["fetch_cancel"] diff --git a/plugins/http/permissions/autogenerated/commands/fetch_read_body.toml b/plugins/http/permissions/autogenerated/commands/fetch_read_body.toml new file mode 100644 index 00000000..b5867e99 --- /dev/null +++ b/plugins/http/permissions/autogenerated/commands/fetch_read_body.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-fetch-read-body" +description = "Enables the fetch_read_body command without any pre-configured scope." +commands.allow = ["fetch_read_body"] + +[[permission]] +identifier = "deny-fetch-read-body" +description = "Denies the fetch_read_body command without any pre-configured scope." +commands.deny = ["fetch_read_body"] diff --git a/plugins/http/permissions/autogenerated/commands/fetch_send.toml b/plugins/http/permissions/autogenerated/commands/fetch_send.toml new file mode 100644 index 00000000..f6a55d28 --- /dev/null +++ b/plugins/http/permissions/autogenerated/commands/fetch_send.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-fetch-send" +description = "Enables the fetch_send command without any pre-configured scope." +commands.allow = ["fetch_send"] + +[[permission]] +identifier = "deny-fetch-send" +description = "Denies the fetch_send command without any pre-configured scope." +commands.deny = ["fetch_send"] diff --git a/plugins/http/permissions/autogenerated/reference.md b/plugins/http/permissions/autogenerated/reference.md new file mode 100644 index 00000000..a155fd62 --- /dev/null +++ b/plugins/http/permissions/autogenerated/reference.md @@ -0,0 +1,135 @@ +## Default Permission + +This permission set configures what kind of +fetch operations are available from the http plugin. + +This enables all fetch operations but does not +allow explicitly any origins to be fetched. This needs to +be manually configured before usage. + +#### Granted Permissions + +All fetch operations are enabled. + + + +#### This default permission set includes the following: + +- `allow-fetch` +- `allow-fetch-cancel` +- `allow-fetch-read-body` +- `allow-fetch-send` + +## Permission Table + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IdentifierDescription
+ +`http:allow-fetch` + + + +Enables the fetch command without any pre-configured scope. + +
+ +`http:deny-fetch` + + + +Denies the fetch command without any pre-configured scope. + +
+ +`http:allow-fetch-cancel` + + + +Enables the fetch_cancel command without any pre-configured scope. + +
+ +`http:deny-fetch-cancel` + + + +Denies the fetch_cancel command without any pre-configured scope. + +
+ +`http:allow-fetch-read-body` + + + +Enables the fetch_read_body command without any pre-configured scope. + +
+ +`http:deny-fetch-read-body` + + + +Denies the fetch_read_body command without any pre-configured scope. + +
+ +`http:allow-fetch-send` + + + +Enables the fetch_send command without any pre-configured scope. + +
+ +`http:deny-fetch-send` + + + +Denies the fetch_send command without any pre-configured scope. + +
diff --git a/plugins/http/permissions/default.toml b/plugins/http/permissions/default.toml new file mode 100644 index 00000000..b469536d --- /dev/null +++ b/plugins/http/permissions/default.toml @@ -0,0 +1,22 @@ +"$schema" = "schemas/schema.json" + +[default] +description = """ +This permission set configures what kind of +fetch operations are available from the http plugin. + +This enables all fetch operations but does not +allow explicitly any origins to be fetched. This needs to +be manually configured before usage. + +#### Granted Permissions + +All fetch operations are enabled. + +""" +permissions = [ + "allow-fetch", + "allow-fetch-cancel", + "allow-fetch-read-body", + "allow-fetch-send", +] diff --git a/plugins/http/permissions/schemas/schema.json b/plugins/http/permissions/schemas/schema.json new file mode 100644 index 00000000..ea774399 --- /dev/null +++ b/plugins/http/permissions/schemas/schema.json @@ -0,0 +1,354 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "PermissionFile", + "description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.", + "type": "object", + "properties": { + "default": { + "description": "The default permission set for the plugin", + "anyOf": [ + { + "$ref": "#/definitions/DefaultPermission" + }, + { + "type": "null" + } + ] + }, + "set": { + "description": "A list of permissions sets defined", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionSet" + } + }, + "permission": { + "description": "A list of inlined permissions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Permission" + } + } + }, + "definitions": { + "DefaultPermission": { + "description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.", + "type": "object", + "required": [ + "permissions" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "PermissionSet": { + "description": "A set of direct permissions grouped together under a new name.", + "type": "object", + "required": [ + "description", + "identifier", + "permissions" + ], + "properties": { + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does.", + "type": "string" + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionKind" + } + } + } + }, + "Permission": { + "description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.", + "type": "object", + "required": [ + "identifier" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri internal convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "commands": { + "description": "Allowed or denied commands when using this permission.", + "default": { + "allow": [], + "deny": [] + }, + "allOf": [ + { + "$ref": "#/definitions/Commands" + } + ] + }, + "scope": { + "description": "Allowed or denied scoped when using this permission.", + "allOf": [ + { + "$ref": "#/definitions/Scopes" + } + ] + }, + "platforms": { + "description": "Target platforms this permission applies. By default all platforms are affected by this permission.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Target" + } + } + } + }, + "Commands": { + "description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.", + "type": "object", + "properties": { + "allow": { + "description": "Allowed command.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "deny": { + "description": "Denied command, which takes priority.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "Scopes": { + "description": "An argument for fine grained behavior control of Tauri commands.\n\nIt can be of any serde serializable type and is used to allow or prevent certain actions inside a Tauri command. The configured scope is passed to the command and will be enforced by the command implementation.\n\n## Example\n\n```json { \"allow\": [{ \"path\": \"$HOME/**\" }], \"deny\": [{ \"path\": \"$HOME/secret.txt\" }] } ```", + "type": "object", + "properties": { + "allow": { + "description": "Data that defines what is allowed by the scope.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + }, + "deny": { + "description": "Data that defines what is denied by the scope. This should be prioritized by validation logic.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + } + } + }, + "Value": { + "description": "All supported ACL values.", + "anyOf": [ + { + "description": "Represents a null JSON value.", + "type": "null" + }, + { + "description": "Represents a [`bool`].", + "type": "boolean" + }, + { + "description": "Represents a valid ACL [`Number`].", + "allOf": [ + { + "$ref": "#/definitions/Number" + } + ] + }, + { + "description": "Represents a [`String`].", + "type": "string" + }, + { + "description": "Represents a list of other [`Value`]s.", + "type": "array", + "items": { + "$ref": "#/definitions/Value" + } + }, + { + "description": "Represents a map of [`String`] keys to [`Value`]s.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/Value" + } + } + ] + }, + "Number": { + "description": "A valid ACL number.", + "anyOf": [ + { + "description": "Represents an [`i64`].", + "type": "integer", + "format": "int64" + }, + { + "description": "Represents a [`f64`].", + "type": "number", + "format": "double" + } + ] + }, + "Target": { + "description": "Platform target.", + "oneOf": [ + { + "description": "MacOS.", + "type": "string", + "enum": [ + "macOS" + ] + }, + { + "description": "Windows.", + "type": "string", + "enum": [ + "windows" + ] + }, + { + "description": "Linux.", + "type": "string", + "enum": [ + "linux" + ] + }, + { + "description": "Android.", + "type": "string", + "enum": [ + "android" + ] + }, + { + "description": "iOS.", + "type": "string", + "enum": [ + "iOS" + ] + } + ] + }, + "PermissionKind": { + "type": "string", + "oneOf": [ + { + "description": "Enables the fetch command without any pre-configured scope.", + "type": "string", + "const": "allow-fetch", + "markdownDescription": "Enables the fetch command without any pre-configured scope." + }, + { + "description": "Denies the fetch command without any pre-configured scope.", + "type": "string", + "const": "deny-fetch", + "markdownDescription": "Denies the fetch command without any pre-configured scope." + }, + { + "description": "Enables the fetch_cancel command without any pre-configured scope.", + "type": "string", + "const": "allow-fetch-cancel", + "markdownDescription": "Enables the fetch_cancel command without any pre-configured scope." + }, + { + "description": "Denies the fetch_cancel command without any pre-configured scope.", + "type": "string", + "const": "deny-fetch-cancel", + "markdownDescription": "Denies the fetch_cancel command without any pre-configured scope." + }, + { + "description": "Enables the fetch_read_body command without any pre-configured scope.", + "type": "string", + "const": "allow-fetch-read-body", + "markdownDescription": "Enables the fetch_read_body command without any pre-configured scope." + }, + { + "description": "Denies the fetch_read_body command without any pre-configured scope.", + "type": "string", + "const": "deny-fetch-read-body", + "markdownDescription": "Denies the fetch_read_body command without any pre-configured scope." + }, + { + "description": "Enables the fetch_send command without any pre-configured scope.", + "type": "string", + "const": "allow-fetch-send", + "markdownDescription": "Enables the fetch_send command without any pre-configured scope." + }, + { + "description": "Denies the fetch_send command without any pre-configured scope.", + "type": "string", + "const": "deny-fetch-send", + "markdownDescription": "Denies the fetch_send command without any pre-configured scope." + }, + { + "description": "This permission set configures what kind of\nfetch operations are available from the http plugin.\n\nThis enables all fetch operations but does not\nallow explicitly any origins to be fetched. This needs to\nbe manually configured before usage.\n\n#### Granted Permissions\n\nAll fetch operations are enabled.\n\n\n#### This default permission set includes:\n\n- `allow-fetch`\n- `allow-fetch-cancel`\n- `allow-fetch-read-body`\n- `allow-fetch-send`", + "type": "string", + "const": "default", + "markdownDescription": "This permission set configures what kind of\nfetch operations are available from the http plugin.\n\nThis enables all fetch operations but does not\nallow explicitly any origins to be fetched. This needs to\nbe manually configured before usage.\n\n#### Granted Permissions\n\nAll fetch operations are enabled.\n\n\n#### This default permission set includes:\n\n- `allow-fetch`\n- `allow-fetch-cancel`\n- `allow-fetch-read-body`\n- `allow-fetch-send`" + } + ] + } + } +} \ No newline at end of file diff --git a/plugins/http/rollup.config.js b/plugins/http/rollup.config.js new file mode 100644 index 00000000..1f349ec8 --- /dev/null +++ b/plugins/http/rollup.config.js @@ -0,0 +1,7 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import { createConfig } from '../../shared/rollup.config.js' + +export default createConfig() diff --git a/plugins/http/rollup.config.mjs b/plugins/http/rollup.config.mjs deleted file mode 100644 index 99a3dd31..00000000 --- a/plugins/http/rollup.config.mjs +++ /dev/null @@ -1,11 +0,0 @@ -import { readFileSync } from "fs"; - -import { createConfig } from "../../shared/rollup.config.mjs"; - -export default createConfig({ - input: "guest-js/index.ts", - pkg: JSON.parse( - readFileSync(new URL("./package.json", import.meta.url), "utf8"), - ), - external: [/^@tauri-apps\/api/], -}); diff --git a/plugins/http/src/api-iife.js b/plugins/http/src/api-iife.js deleted file mode 100644 index e1d5d3c3..00000000 --- a/plugins/http/src/api-iife.js +++ /dev/null @@ -1 +0,0 @@ -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__})} diff --git a/plugins/http/src/commands.rs b/plugins/http/src/commands.rs index 898b180e..bb47444e 100644 --- a/plugins/http/src/commands.rs +++ b/plugins/http/src/commands.rs @@ -2,14 +2,68 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use std::{collections::HashMap, time::Duration}; +use std::{future::Future, pin::Pin, str::FromStr, sync::Arc, time::Duration}; -use http::{header, HeaderName, HeaderValue, Method, StatusCode}; -use reqwest::redirect::Policy; -use serde::Serialize; -use tauri::{command, AppHandle, Runtime}; +use http::{header, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; +use reqwest::{redirect::Policy, NoProxy}; +use serde::{Deserialize, Serialize}; +use tauri::{ + async_runtime::Mutex, + command, + ipc::{Channel, CommandScope, GlobalScope}, + Manager, ResourceId, ResourceTable, Runtime, State, Webview, +}; +use tokio::sync::oneshot::{channel, Receiver, Sender}; -use crate::{Error, FetchRequest, HttpExt, RequestId}; +use crate::{ + scope::{Entry, Scope}, + Error, Http, Result, +}; + +const HTTP_USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"),); + +struct ReqwestResponse(reqwest::Response); +impl tauri::Resource for ReqwestResponse {} + +type CancelableResponseResult = Result; +type CancelableResponseFuture = + Pin + Send + Sync>>; + +struct FetchRequest { + fut: Mutex, + abort_tx_rid: ResourceId, + abort_rx_rid: ResourceId, +} +impl tauri::Resource for FetchRequest {} + +struct AbortSender(Sender<()>); +impl tauri::Resource for AbortRecveiver {} + +impl AbortSender { + fn abort(self) { + let _ = self.0.send(()); + } +} + +struct AbortRecveiver(Receiver<()>); +impl tauri::Resource for AbortSender {} + +trait AddRequest { + fn add_request(&mut self, fut: CancelableResponseFuture) -> ResourceId; +} + +impl AddRequest for ResourceTable { + fn add_request(&mut self, fut: CancelableResponseFuture) -> ResourceId { + let (tx, rx) = channel::<()>(); + let (tx, rx) = (AbortSender(tx), AbortRecveiver(rx)); + let req = FetchRequest { + fut: Mutex::new(fut), + abort_tx_rid: self.add(tx), + abort_rx_rid: self.add(rx), + }; + self.add(req) + } +} #[derive(Serialize)] #[serde(rename_all = "camelCase")] @@ -18,27 +72,182 @@ pub struct FetchResponse { status_text: String, headers: Vec<(String, String)>, url: String, + rid: ResourceId, } -#[command] -pub async fn fetch( - app: AppHandle, +#[derive(Debug, Deserialize)] +#[serde(rename_all = "camelCase")] +#[allow(dead_code)] //feature flags shoudln't affect api +pub struct DangerousSettings { + accept_invalid_certs: bool, + accept_invalid_hostnames: bool, +} + +#[derive(Debug, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct ClientConfig { method: String, url: url::Url, headers: Vec<(String, String)>, data: Option>, connect_timeout: Option, max_redirections: Option, -) -> crate::Result { + proxy: Option, + danger: Option, +} + +#[derive(Debug, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct Proxy { + all: Option, + http: Option, + https: Option, +} + +#[derive(Debug, Deserialize)] +#[serde(rename_all = "camelCase")] +#[serde(untagged)] +pub enum UrlOrConfig { + Url(String), + Config(ProxyConfig), +} + +#[derive(Debug, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct ProxyConfig { + url: String, + basic_auth: Option, + no_proxy: Option, +} + +#[derive(Debug, Deserialize)] +pub struct BasicAuth { + username: String, + password: String, +} + +#[inline] +fn proxy_creator( + url_or_config: UrlOrConfig, + proxy_fn: fn(String) -> reqwest::Result, +) -> reqwest::Result { + match url_or_config { + UrlOrConfig::Url(url) => Ok(proxy_fn(url)?), + UrlOrConfig::Config(ProxyConfig { + url, + basic_auth, + no_proxy, + }) => { + let mut proxy = proxy_fn(url)?; + if let Some(basic_auth) = basic_auth { + proxy = proxy.basic_auth(&basic_auth.username, &basic_auth.password); + } + if let Some(no_proxy) = no_proxy { + proxy = proxy.no_proxy(NoProxy::from_string(&no_proxy)); + } + Ok(proxy) + } + } +} + +fn attach_proxy( + proxy: Proxy, + mut builder: reqwest::ClientBuilder, +) -> crate::Result { + let Proxy { all, http, https } = proxy; + + if let Some(all) = all { + let proxy = proxy_creator(all, reqwest::Proxy::all)?; + builder = builder.proxy(proxy); + } + + if let Some(http) = http { + let proxy = proxy_creator(http, reqwest::Proxy::http)?; + builder = builder.proxy(proxy); + } + + if let Some(https) = https { + let proxy = proxy_creator(https, reqwest::Proxy::https)?; + builder = builder.proxy(proxy); + } + + Ok(builder) +} + +#[command] +pub async fn fetch( + webview: Webview, + state: State<'_, Http>, + client_config: ClientConfig, + command_scope: CommandScope, + global_scope: GlobalScope, +) -> crate::Result { + let ClientConfig { + method, + url, + headers: headers_raw, + data, + connect_timeout, + max_redirections, + proxy, + danger, + } = client_config; + let scheme = url.scheme(); let method = Method::from_bytes(method.as_bytes())?; - let headers: HashMap = HashMap::from_iter(headers); + + let mut headers = HeaderMap::new(); + for (h, v) in headers_raw { + let name = HeaderName::from_str(&h)?; + #[cfg(not(feature = "unsafe-headers"))] + if is_unsafe_header(&name) { + #[cfg(debug_assertions)] + { + eprintln!("[\x1b[33mWARNING\x1b[0m] Skipping {name} header as it is a forbidden header per fetch spec https://fetch.spec.whatwg.org/#terminology-headers"); + eprintln!("[\x1b[33mWARNING\x1b[0m] if keeping the header is a desired behavior, you can enable `unsafe-headers` feature flag in your Cargo.toml"); + } + continue; + } + + headers.append(name, HeaderValue::from_str(&v)?); + } match scheme { "http" | "https" => { - if app.http().scope.is_allowed(&url) { + if Scope::new( + command_scope + .allows() + .iter() + .chain(global_scope.allows()) + .collect(), + command_scope + .denies() + .iter() + .chain(global_scope.denies()) + .collect(), + ) + .is_allowed(&url) + { let mut builder = reqwest::ClientBuilder::new(); + if let Some(danger_config) = danger { + #[cfg(not(feature = "dangerous-settings"))] + { + #[cfg(debug_assertions)] + { + eprintln!("[\x1b[33mWARNING\x1b[0m] using dangerous settings requires `dangerous-settings` feature flag in your Cargo.toml"); + } + let _ = danger_config; + return Err(Error::DangerousSettings); + } + #[cfg(feature = "dangerous-settings")] + { + builder = builder + .danger_accept_invalid_certs(danger_config.accept_invalid_certs) + .danger_accept_invalid_hostnames(danger_config.accept_invalid_hostnames) + } + } + if let Some(timeout) = connect_timeout { builder = builder.connect_timeout(Duration::from_millis(timeout)); } @@ -51,44 +260,64 @@ pub async fn fetch( }); } - let mut request = builder.build()?.request(method.clone(), url); + if let Some(proxy_config) = proxy { + builder = attach_proxy(proxy_config, builder)?; + } - for (key, value) in &headers { - let name = HeaderName::from_bytes(key.as_bytes())?; - let v = HeaderValue::from_bytes(value.as_bytes())?; - if !matches!(name, header::HOST | header::CONTENT_LENGTH) { - request = request.header(name, v); - } + #[cfg(feature = "cookies")] + { + builder = builder.cookie_provider(state.cookies_jar.clone()); } + let mut request = builder.build()?.request(method.clone(), url); + // POST and PUT requests should always have a 0 length content-length, // if there is no body. https://fetch.spec.whatwg.org/#http-network-or-cache-fetch if data.is_none() && matches!(method, Method::POST | Method::PUT) { - request = request.header(header::CONTENT_LENGTH, HeaderValue::from(0)); + headers.append(header::CONTENT_LENGTH, HeaderValue::from_str("0")?); } - if headers.contains_key(header::RANGE.as_str()) { + if headers.contains_key(header::RANGE) { // https://fetch.spec.whatwg.org/#http-network-or-cache-fetch step 18 // If httpRequest’s header list contains `Range`, then append (`Accept-Encoding`, `identity`) - request = request.header( - header::ACCEPT_ENCODING, - HeaderValue::from_static("identity"), - ); + headers.append(header::ACCEPT_ENCODING, HeaderValue::from_str("identity")?); } - if !headers.contains_key(header::USER_AGENT.as_str()) { - request = request.header(header::USER_AGENT, HeaderValue::from_static("tauri")); + if !headers.contains_key(header::USER_AGENT) { + headers.append(header::USER_AGENT, HeaderValue::from_str(HTTP_USER_AGENT)?); + } + + // ensure we have an Origin header set + if cfg!(not(feature = "unsafe-headers")) || !headers.contains_key(header::ORIGIN) { + if let Ok(url) = webview.url() { + headers.append( + header::ORIGIN, + HeaderValue::from_str(&url.origin().ascii_serialization())?, + ); + } } + // In case empty origin is passed, remove it. Some services do not like Origin header + // so this way we can remove it in explicit way. The default behaviour is still to set it + if cfg!(feature = "unsafe-headers") + && headers.get(header::ORIGIN) == Some(&HeaderValue::from_static("")) + { + headers.remove(header::ORIGIN); + }; + if let Some(data) = data { request = request.body(data); } - let http_state = app.http(); - let rid = http_state.next_id(); - let fut = async move { Ok(request.send().await.map_err(Into::into)) }; - let mut request_table = http_state.requests.lock().await; - request_table.insert(rid, FetchRequest::new(Box::pin(fut))); + request = request.headers(headers); + + #[cfg(feature = "tracing")] + tracing::trace!("{:?}", request); + + let fut = async move { request.send().await.map_err(Into::into) }; + + let mut resources_table = webview.resources_table(); + let rid = resources_table.add_request(Box::pin(fut)); Ok(rid) } else { @@ -107,11 +336,12 @@ pub async fn fetch( .header(header::CONTENT_TYPE, data_url.mime_type().to_string()) .body(reqwest::Body::from(body))?; - let http_state = app.http(); - let rid = http_state.next_id(); - let fut = async move { Ok(Ok(reqwest::Response::from(response))) }; - let mut request_table = http_state.requests.lock().await; - request_table.insert(rid, FetchRequest::new(Box::pin(fut))); + #[cfg(feature = "tracing")] + tracing::trace!("{:?}", response); + + let fut = async move { Ok(reqwest::Response::from(response)) }; + let mut resources_table = webview.resources_table(); + let rid = resources_table.add_request(Box::pin(fut)); Ok(rid) } _ => Err(Error::SchemeNotSupport(scheme.to_string())), @@ -119,30 +349,46 @@ pub async fn fetch( } #[command] -pub async fn fetch_cancel(app: AppHandle, rid: RequestId) -> crate::Result<()> { - let mut request_table = app.http().requests.lock().await; - let req = request_table - .get_mut(&rid) - .ok_or(Error::InvalidRequestId(rid))?; - *req = FetchRequest::new(Box::pin(async { Err(Error::RequestCanceled) })); +pub fn fetch_cancel(webview: Webview, rid: ResourceId) -> crate::Result<()> { + let mut resources_table = webview.resources_table(); + let req = resources_table.get::(rid)?; + let abort_tx = resources_table.take::(req.abort_tx_rid)?; + if let Some(abort_tx) = Arc::into_inner(abort_tx) { + abort_tx.abort(); + } Ok(()) } #[command] pub async fn fetch_send( - app: AppHandle, - rid: RequestId, + webview: Webview, + rid: ResourceId, ) -> crate::Result { - let mut request_table = app.http().requests.lock().await; - let req = request_table - .remove(&rid) - .ok_or(Error::InvalidRequestId(rid))?; - - let res = match req.0.lock().await.as_mut().await { - Ok(Ok(res)) => res, - Ok(Err(e)) | Err(e) => return Err(e), + let (req, abort_rx) = { + let mut resources_table = webview.resources_table(); + let req = resources_table.get::(rid)?; + let abort_rx = resources_table.take::(req.abort_rx_rid)?; + (req, abort_rx) + }; + + let Some(abort_rx) = Arc::into_inner(abort_rx) else { + return Err(Error::RequestCanceled); + }; + + let mut fut = req.fut.lock().await; + + let res = tokio::select! { + res = fut.as_mut() => res?, + _ = abort_rx.0 => { + let mut resources_table = webview.resources_table(); + resources_table.close(rid)?; + return Err(Error::RequestCanceled); + } }; + #[cfg(feature = "tracing")] + tracing::trace!("{:?}", res); + let status = res.status(); let url = res.url().to_string(); let mut headers = Vec::new(); @@ -153,25 +399,71 @@ pub async fn fetch_send( )); } - app.http().responses.lock().await.insert(rid, res); + let mut resources_table = webview.resources_table(); + let rid = resources_table.add(ReqwestResponse(res)); Ok(FetchResponse { status: status.as_u16(), status_text: status.canonical_reason().unwrap_or_default().to_string(), headers, url, + rid, }) } #[command] -pub(crate) async fn fetch_read_body( - app: AppHandle, - rid: RequestId, -) -> crate::Result { - let mut response_table = app.http().responses.lock().await; - let res = response_table - .remove(&rid) - .ok_or(Error::InvalidRequestId(rid))?; - - Ok(tauri::ipc::Response::new(res.bytes().await?.to_vec())) +pub async fn fetch_read_body( + webview: Webview, + rid: ResourceId, + stream_channel: Channel, +) -> crate::Result<()> { + let res = { + let mut resources_table = webview.resources_table(); + resources_table.take::(rid)? + }; + + let mut res = Arc::into_inner(res).unwrap().0; + + // send response through IPC channel + while let Some(chunk) = res.chunk().await? { + let mut chunk = chunk.to_vec(); + // append 0 to indicate we are not done yet + chunk.push(0); + stream_channel.send(tauri::ipc::InvokeResponseBody::Raw(chunk))?; + } + + // send 1 to indicate we are done + stream_channel.send(tauri::ipc::InvokeResponseBody::Raw(vec![1]))?; + + Ok(()) +} + +// forbidden headers per fetch spec https://fetch.spec.whatwg.org/#terminology-headers +#[cfg(not(feature = "unsafe-headers"))] +fn is_unsafe_header(header: &HeaderName) -> bool { + matches!( + *header, + header::ACCEPT_CHARSET + | header::ACCEPT_ENCODING + | header::ACCESS_CONTROL_REQUEST_HEADERS + | header::ACCESS_CONTROL_REQUEST_METHOD + | header::CONNECTION + | header::CONTENT_LENGTH + | header::COOKIE + | header::DATE + | header::DNT + | header::EXPECT + | header::HOST + | header::ORIGIN + | header::REFERER + | header::SET_COOKIE + | header::TE + | header::TRAILER + | header::TRANSFER_ENCODING + | header::UPGRADE + | header::VIA + ) || { + let lower = header.as_str().to_lowercase(); + lower.starts_with("proxy-") || lower.starts_with("sec-") + } } diff --git a/plugins/http/src/config.rs b/plugins/http/src/config.rs deleted file mode 100644 index e4ac882b..00000000 --- a/plugins/http/src/config.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2019-2023 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - -use serde::Deserialize; - -#[derive(Deserialize)] -pub struct Config { - pub scope: HttpAllowlistScope, -} - -/// HTTP API scope definition. -/// It is a list of URLs that can be accessed by the webview when using the HTTP APIs. -/// The scoped URL is matched against the request URL using a glob pattern. -/// -/// Examples: -/// - "https://*" or "https://**" : allows all HTTPS urls -/// - "https://*.github.com/tauri-apps/tauri": allows any subdomain of "github.com" with the "tauri-apps/api" path -/// - "https://myapi.service.com/users/*": allows access to any URLs that begins with "https://myapi.service.com/users/" -#[allow(rustdoc::bare_urls)] -#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize)] -pub struct HttpAllowlistScope(pub Vec); diff --git a/plugins/http/src/error.rs b/plugins/http/src/error.rs index 457b3382..ef8de0c5 100644 --- a/plugins/http/src/error.rs +++ b/plugins/http/src/error.rs @@ -5,8 +5,6 @@ use serde::{Serialize, Serializer}; use url::Url; -use crate::RequestId; - #[derive(Debug, thiserror::Error)] pub enum Error { #[error(transparent)] @@ -39,10 +37,12 @@ pub enum Error { DataUrlError, #[error("failed to decode data url into bytes")] DataUrlDecodeError, - #[error("invalid request id: {0}")] - InvalidRequestId(RequestId), + #[error(transparent)] + Tauri(#[from] tauri::Error), #[error(transparent)] Utf8(#[from] std::string::FromUtf8Error), + #[error("dangerous settings used but are not enabled")] + DangerousSettings, } impl Serialize for Error { diff --git a/plugins/http/src/lib.rs b/plugins/http/src/lib.rs index 7bf9217b..5acc2b47 100644 --- a/plugins/http/src/lib.rs +++ b/plugins/http/src/lib.rs @@ -2,93 +2,89 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -//! [![](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/http/banner.png)](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/http) -//! //! Access the HTTP client written in Rust. -use std::sync::atomic::AtomicU32; -use std::{collections::HashMap, future::Future, pin::Pin}; - pub use reqwest; -use reqwest::Response; -use tauri::async_runtime::Mutex; use tauri::{ plugin::{Builder, TauriPlugin}, - AppHandle, Manager, Runtime, + Manager, Runtime, }; -use crate::config::{Config, HttpAllowlistScope}; pub use error::{Error, Result}; mod commands; -mod config; mod error; +#[cfg(feature = "cookies")] +mod reqwest_cookie_store; mod scope; -type RequestId = u32; -type CancelableResponseResult = Result>; -type CancelableResponseFuture = - Pin + Send + Sync>>; -type RequestTable = HashMap; -type ResponseTable = HashMap; +#[cfg(feature = "cookies")] +const COOKIES_FILENAME: &str = ".cookies"; -struct FetchRequest(Mutex); -impl FetchRequest { - fn new(f: CancelableResponseFuture) -> Self { - Self(Mutex::new(f)) - } +pub(crate) struct Http { + #[cfg(feature = "cookies")] + cookies_jar: std::sync::Arc, } -struct Http { - #[allow(dead_code)] - app: AppHandle, - scope: scope::Scope, - current_id: AtomicU32, - requests: Mutex, - responses: Mutex, -} +pub fn init() -> TauriPlugin { + Builder::::new("http") + .setup(|app, _| { + #[cfg(feature = "cookies")] + let cookies_jar = { + use crate::reqwest_cookie_store::*; + use std::fs::File; + use std::io::BufReader; -impl Http { - fn next_id(&self) -> RequestId { - self.current_id - .fetch_add(1, std::sync::atomic::Ordering::Relaxed) - } -} + let cache_dir = app.path().app_cache_dir()?; + std::fs::create_dir_all(&cache_dir)?; -trait HttpExt { - fn http(&self) -> &Http; -} + let path = cache_dir.join(COOKIES_FILENAME); + let file = File::options() + .create(true) + .append(true) + .read(true) + .open(&path)?; -impl> HttpExt for T { - fn http(&self) -> &Http { - self.state::>().inner() - } -} + let reader = BufReader::new(file); + CookieStoreMutex::load(path.clone(), reader).unwrap_or_else(|_e| { + #[cfg(feature = "tracing")] + tracing::warn!( + "failed to load cookie store: {_e}, falling back to empty store" + ); + CookieStoreMutex::new(path, Default::default()) + }) + }; + + let state = Http { + #[cfg(feature = "cookies")] + cookies_jar: std::sync::Arc::new(cookies_jar), + }; + + app.manage(state); -pub fn init() -> TauriPlugin> { - Builder::>::new("http") - .js_init_script(include_str!("api-iife.js").to_string()) + Ok(()) + }) + .on_event(|app, event| { + #[cfg(feature = "cookies")] + if let tauri::RunEvent::Exit = event { + let state = app.state::(); + + match state.cookies_jar.request_save() { + Ok(rx) => { + let _ = rx.recv(); + } + Err(_e) => { + #[cfg(feature = "tracing")] + tracing::error!("failed to save cookie jar: {_e}"); + } + } + } + }) .invoke_handler(tauri::generate_handler![ commands::fetch, commands::fetch_cancel, commands::fetch_send, - commands::fetch_read_body, + commands::fetch_read_body ]) - .setup(|app, api| { - let default_scope = HttpAllowlistScope::default(); - app.manage(Http { - app: app.clone(), - current_id: 0.into(), - requests: Default::default(), - responses: Default::default(), - scope: scope::Scope::new( - api.config() - .as_ref() - .map(|c| &c.scope) - .unwrap_or(&default_scope), - ), - }); - Ok(()) - }) .build() } diff --git a/plugins/http/src/reqwest_cookie_store.rs b/plugins/http/src/reqwest_cookie_store.rs new file mode 100644 index 00000000..6a7c0186 --- /dev/null +++ b/plugins/http/src/reqwest_cookie_store.rs @@ -0,0 +1,133 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +// taken from https://github.com/pfernie/reqwest_cookie_store/blob/2ec4afabcd55e24d3afe3f0626ee6dc97bed938d/src/lib.rs + +use std::{ + path::PathBuf, + sync::{mpsc::Receiver, Mutex}, +}; + +use cookie_store::{CookieStore, RawCookie, RawCookieParseError}; +use reqwest::header::HeaderValue; + +fn set_cookies( + cookie_store: &mut CookieStore, + cookie_headers: &mut dyn Iterator, + url: &url::Url, +) { + let cookies = cookie_headers.filter_map(|val| { + std::str::from_utf8(val.as_bytes()) + .map_err(RawCookieParseError::from) + .and_then(RawCookie::parse) + .map(|c| c.into_owned()) + .ok() + }); + cookie_store.store_response_cookies(cookies, url); +} + +fn cookies(cookie_store: &CookieStore, url: &url::Url) -> Option { + let s = cookie_store + .get_request_values(url) + .map(|(name, value)| format!("{}={}", name, value)) + .collect::>() + .join("; "); + + if s.is_empty() { + return None; + } + + HeaderValue::from_maybe_shared(bytes::Bytes::from(s)).ok() +} + +/// A [`cookie_store::CookieStore`] wrapped internally by a [`std::sync::Mutex`], suitable for use in +/// async/concurrent contexts. +#[derive(Debug)] +pub struct CookieStoreMutex { + pub path: PathBuf, + store: Mutex, + save_task: Mutex>, +} + +impl CookieStoreMutex { + /// Create a new [`CookieStoreMutex`] from an existing [`cookie_store::CookieStore`]. + pub fn new(path: PathBuf, cookie_store: CookieStore) -> CookieStoreMutex { + CookieStoreMutex { + path, + store: Mutex::new(cookie_store), + save_task: Default::default(), + } + } + + pub fn load( + path: PathBuf, + reader: R, + ) -> cookie_store::Result { + cookie_store::serde::load(reader, |c| serde_json::from_str(c)) + .map(|store| CookieStoreMutex::new(path, store)) + } + + fn cookies_to_str(&self) -> Result { + let mut cookies = Vec::new(); + for cookie in self + .store + .lock() + .expect("poisoned cookie jar mutex") + .iter_unexpired() + { + if cookie.is_persistent() { + cookies.push(cookie.clone()); + } + } + serde_json::to_string(&cookies) + } + + pub fn request_save(&self) -> cookie_store::Result> { + let cookie_str = self.cookies_to_str()?; + let path = self.path.clone(); + let (tx, rx) = std::sync::mpsc::channel(); + let task = tauri::async_runtime::spawn(async move { + match tokio::fs::write(&path, &cookie_str).await { + Ok(()) => { + let _ = tx.send(()); + } + Err(_e) => { + #[cfg(feature = "tracing")] + tracing::error!("failed to save cookie jar: {_e}"); + } + } + }); + self.save_task + .lock() + .unwrap() + .replace(CancellableTask(task)); + Ok(rx) + } +} + +impl reqwest::cookie::CookieStore for CookieStoreMutex { + fn set_cookies(&self, cookie_headers: &mut dyn Iterator, url: &url::Url) { + set_cookies(&mut self.store.lock().unwrap(), cookie_headers, url); + + // try to persist cookies immediately asynchronously + if let Err(_e) = self.request_save() { + #[cfg(feature = "tracing")] + tracing::error!("failed to save cookie jar: {_e}"); + } + } + + fn cookies(&self, url: &url::Url) -> Option { + let store = self.store.lock().unwrap(); + cookies(&store, url) + } +} + +#[derive(Debug)] +struct CancellableTask(tauri::async_runtime::JoinHandle<()>); + +impl Drop for CancellableTask { + fn drop(&mut self) { + self.0.abort(); + } +} diff --git a/plugins/http/src/scope.rs b/plugins/http/src/scope.rs index 00ef7e08..2123f215 100644 --- a/plugins/http/src/scope.rs +++ b/plugins/http/src/scope.rs @@ -2,91 +2,230 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use glob::Pattern; -use reqwest::Url; +use std::sync::Arc; -use crate::config::HttpAllowlistScope; +use serde::{Deserialize, Deserializer}; +use url::Url; +use urlpattern::{UrlPattern, UrlPatternMatchInput}; + +#[allow(rustdoc::bare_urls)] +#[derive(Debug)] +pub struct Entry { + pub url: UrlPattern, +} + +fn parse_url_pattern(s: &str) -> Result { + let mut init = urlpattern::UrlPatternInit::parse_constructor_string::(s, None)?; + if init.search.as_ref().map(|p| p.is_empty()).unwrap_or(true) { + init.search.replace("*".to_string()); + } + if init.hash.as_ref().map(|p| p.is_empty()).unwrap_or(true) { + init.hash.replace("*".to_string()); + } + if init + .pathname + .as_ref() + .map(|p| p.is_empty() || p == "/") + .unwrap_or(true) + { + init.pathname.replace("*".to_string()); + } + UrlPattern::parse(init, Default::default()) +} + +#[derive(Deserialize)] +#[serde(untagged)] +pub(crate) enum EntryRaw { + Value(String), + Object { url: String }, +} + +impl<'de> Deserialize<'de> for Entry { + fn deserialize(deserializer: D) -> std::result::Result + where + D: Deserializer<'de>, + { + EntryRaw::deserialize(deserializer).and_then(|raw| { + let url = match raw { + EntryRaw::Value(url) => url, + EntryRaw::Object { url } => url, + }; + Ok(Entry { + url: parse_url_pattern(&url).map_err(|e| { + serde::de::Error::custom(format!("`{}` is not a valid URL pattern: {e}", url)) + })?, + }) + }) + } +} /// Scope for filesystem access. -#[derive(Debug, Clone)] -pub struct Scope { - allowed_urls: Vec, +#[derive(Debug)] +pub struct Scope<'a> { + allowed: Vec<&'a Arc>, + denied: Vec<&'a Arc>, } -impl Scope { +impl<'a> Scope<'a> { /// Creates a new scope from the scope configuration. - pub(crate) fn new(scope: &HttpAllowlistScope) -> Self { - Self { - allowed_urls: scope - .0 - .iter() - .map(|url| { - glob::Pattern::new(url).unwrap_or_else(|_| { - panic!("scoped URL is not a valid glob pattern: `{url}`") - }) - }) - .collect(), - } + pub(crate) fn new(allowed: Vec<&'a Arc>, denied: Vec<&'a Arc>) -> Self { + Self { allowed, denied } } /// Determines if the given URL is allowed on this scope. pub fn is_allowed(&self, url: &Url) -> bool { - self.allowed_urls.iter().any(|allowed| { - allowed.matches(url.as_str()) - || allowed.matches(url.as_str().strip_suffix('/').unwrap_or_default()) - }) + let denied = self.denied.iter().any(|entry| { + entry + .url + .test(UrlPatternMatchInput::Url(url.clone())) + .unwrap_or_default() + }); + if denied { + false + } else { + self.allowed.iter().any(|entry| { + entry + .url + .test(UrlPatternMatchInput::Url(url.clone())) + .unwrap_or_default() + }) + } } } #[cfg(test)] mod tests { - use crate::config::HttpAllowlistScope; + use std::{str::FromStr, sync::Arc}; + + use super::Entry; + + impl FromStr for Entry { + type Err = urlpattern::quirks::Error; + + fn from_str(s: &str) -> Result { + let pattern = super::parse_url_pattern(s)?; + Ok(Self { url: pattern }) + } + } + + #[test] + fn denied_takes_precedence() { + let allow = Arc::new("http://localhost:8080/file.png".parse().unwrap()); + let deny = Arc::new("http://localhost:8080/*".parse().unwrap()); + let scope = super::Scope::new(vec![&allow], vec![&deny]); + assert!(!scope.is_allowed(&"http://localhost:8080/file.png".parse().unwrap())); + assert!(!scope.is_allowed(&"http://localhost:8080?framework=tauri".parse().unwrap())); + } #[test] - fn is_allowed() { + fn fixed_url() { // plain URL - let scope = super::Scope::new(&HttpAllowlistScope(vec!["http://localhost:8080" - .parse() - .unwrap()])); + let entry = Arc::new("http://localhost:8080".parse().unwrap()); + let scope = super::Scope::new(vec![&entry], Vec::new()); assert!(scope.is_allowed(&"http://localhost:8080".parse().unwrap())); assert!(scope.is_allowed(&"http://localhost:8080/".parse().unwrap())); + assert!(scope.is_allowed(&"http://localhost:8080/file".parse().unwrap())); + assert!(scope.is_allowed(&"http://localhost:8080/path/to/asset.png".parse().unwrap())); + assert!(scope.is_allowed(&"http://localhost:8080/path/list?limit=50".parse().unwrap())); - assert!(!scope.is_allowed(&"http://localhost:8080/file".parse().unwrap())); - assert!(!scope.is_allowed(&"http://localhost:8080/path/to/asset.png".parse().unwrap())); assert!(!scope.is_allowed(&"https://localhost:8080".parse().unwrap())); assert!(!scope.is_allowed(&"http://localhost:8081".parse().unwrap())); assert!(!scope.is_allowed(&"http://local:8080".parse().unwrap())); + } + #[test] + fn fixed_path() { // URL with fixed path - let scope = super::Scope::new(&HttpAllowlistScope(vec!["http://localhost:8080/file.png" - .parse() - .unwrap()])); + let entry = Arc::new("http://localhost:8080/file.png".parse().unwrap()); + let scope = super::Scope::new(vec![&entry], Vec::new()); assert!(scope.is_allowed(&"http://localhost:8080/file.png".parse().unwrap())); + assert!(scope.is_allowed(&"http://localhost:8080/file.png?q=1".parse().unwrap())); assert!(!scope.is_allowed(&"http://localhost:8080".parse().unwrap())); assert!(!scope.is_allowed(&"http://localhost:8080/file".parse().unwrap())); assert!(!scope.is_allowed(&"http://localhost:8080/file.png/other.jpg".parse().unwrap())); + } - // URL with glob pattern - let scope = super::Scope::new(&HttpAllowlistScope(vec!["http://localhost:8080/*.png" - .parse() - .unwrap()])); + #[test] + fn pattern_wildcard() { + let entry = Arc::new("http://localhost:8080/*.png".parse().unwrap()); + let scope = super::Scope::new(vec![&entry], Vec::new()); assert!(scope.is_allowed(&"http://localhost:8080/file.png".parse().unwrap())); + assert!(scope.is_allowed(&"http://localhost:8080/file.png#head".parse().unwrap())); assert!(scope.is_allowed(&"http://localhost:8080/assets/file.png".parse().unwrap())); + assert!(scope.is_allowed( + &"http://localhost:8080/assets/file.png?width=100&height=200" + .parse() + .unwrap() + )); assert!(!scope.is_allowed(&"http://localhost:8080/file.jpeg".parse().unwrap())); + } - let scope = super::Scope::new(&HttpAllowlistScope(vec!["http://*".parse().unwrap()])); + #[test] + fn domain_wildcard() { + let entry = Arc::new("http://*".parse().unwrap()); + let scope = super::Scope::new(vec![&entry], Vec::new()); assert!(scope.is_allowed(&"http://something.else".parse().unwrap())); + assert!(scope.is_allowed(&"http://something.else#tauri".parse().unwrap())); assert!(scope.is_allowed(&"http://something.else/path/to/file".parse().unwrap())); + assert!(scope.is_allowed(&"http://something.else?rel=tauri".parse().unwrap())); + assert!(scope.is_allowed( + &"http://something.else/path/to/file.mp4?start=500" + .parse() + .unwrap() + )); + assert!(!scope.is_allowed(&"https://something.else".parse().unwrap())); - let scope = super::Scope::new(&HttpAllowlistScope(vec!["http://**".parse().unwrap()])); + let entry = Arc::new("http://*/*".parse().unwrap()); + let scope = super::Scope::new(vec![&entry], Vec::new()); + + assert!(scope.is_allowed(&"http://something.else".parse().unwrap())); + assert!(scope.is_allowed(&"http://something.else/path/to/file".parse().unwrap())); + } + + #[test] + fn scheme_wildcard() { + let entry = Arc::new("*://*".parse().unwrap()); + let scope = super::Scope::new(vec![&entry], Vec::new()); + + assert!(scope.is_allowed(&"http://something.else".parse().unwrap())); + assert!(scope.is_allowed(&"http://something.else/path/to/file".parse().unwrap())); + assert!(scope.is_allowed(&"file://path".parse().unwrap())); + assert!(scope.is_allowed(&"file://path/to/file".parse().unwrap())); + assert!(scope.is_allowed(&"https://something.else".parse().unwrap())); + assert!(scope.is_allowed(&"https://something.else?x=1#frag".parse().unwrap())); + + let entry = Arc::new("*://*/*".parse().unwrap()); + let scope = super::Scope::new(vec![&entry], Vec::new()); assert!(scope.is_allowed(&"http://something.else".parse().unwrap())); assert!(scope.is_allowed(&"http://something.else/path/to/file".parse().unwrap())); + assert!(scope.is_allowed(&"file://path/to/file".parse().unwrap())); + assert!(scope.is_allowed(&"https://something.else".parse().unwrap())); + } + + #[test] + fn validate_query() { + let entry = Arc::new("https://tauri.app/path?x=*".parse().unwrap()); + let scope = super::Scope::new(vec![&entry], Vec::new()); + + assert!(scope.is_allowed(&"https://tauri.app/path?x=5".parse().unwrap())); + + assert!(!scope.is_allowed(&"https://tauri.app/path?y=5".parse().unwrap())); + } + + #[test] + fn validate_hash() { + let entry = Arc::new("https://tauri.app/path#frame*".parse().unwrap()); + let scope = super::Scope::new(vec![&entry], Vec::new()); + + assert!(scope.is_allowed(&"https://tauri.app/path#frame".parse().unwrap())); + + assert!(!scope.is_allowed(&"https://tauri.app/path#work".parse().unwrap())); } } diff --git a/plugins/localhost/CHANGELOG.md b/plugins/localhost/CHANGELOG.md index c7a91c82..f2b15a89 100644 --- a/plugins/localhost/CHANGELOG.md +++ b/plugins/localhost/CHANGELOG.md @@ -1,5 +1,88 @@ # Changelog +## \[2.2.0] + +- [`3a79266b`](https://github.com/tauri-apps/plugins-workspace/commit/3a79266b8cf96a55b1ae6339d725567d45a44b1d) ([#2173](https://github.com/tauri-apps/plugins-workspace/pull/2173) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Bumped all plugins to `v2.2.0`. From now, the versions for the Rust and JavaScript packages of each plugin will be in sync with each other. + +## \[2.1.0] + +- [`3449dd5a`](https://github.com/tauri-apps/plugins-workspace/commit/3449dd5a8f6d12fee8d6389c034fe47e19d72bcd) ([#1982](https://github.com/tauri-apps/plugins-workspace/pull/1982) by [@arihav](https://github.com/tauri-apps/plugins-workspace/../../arihav)) Add custom host binding to allow external access + +## \[2.0.1] + +- [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. + +## \[2.0.0] + +- [`e2c4dfb6`](https://github.com/tauri-apps/plugins-workspace/commit/e2c4dfb6af43e5dd8d9ceba232c315f5febd55c1) Update to tauri v2 stable release. + +## \[2.0.0-rc.1] + +- [`e2e97db5`](https://github.com/tauri-apps/plugins-workspace/commit/e2e97db51983267f5be84d4f6f0278d58834d1f5) ([#1701](https://github.com/tauri-apps/plugins-workspace/pull/1701) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri 2.0.0-rc.8 + +## \[2.0.0-rc.0] + +- [`9887d1`](https://github.com/tauri-apps/plugins-workspace/commit/9887d14bd0e971c4c0f5c1188fc4005d3fc2e29e) Update to tauri RC. + +## \[2.0.0-beta.9] + +- [`e847cedc`](https://github.com/tauri-apps/plugins-workspace/commit/e847cedc1f46f3e7a2ad81ea579b620bc5b992d7) ([#1402](https://github.com/tauri-apps/plugins-workspace/pull/1402) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Use no default features on tauri for all plugins so that consumers can use `default-features = false` on tauri, note that this will still enable wry feature on iOS +- [`6de87966`](https://github.com/tauri-apps/plugins-workspace/commit/6de87966ecc00ad9d91c25be452f1f46bd2b7e1f) ([#1597](https://github.com/tauri-apps/plugins-workspace/pull/1597) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Update to tauri beta.25. + +## \[2.0.0-beta.8] + +- [`22a17980`](https://github.com/tauri-apps/plugins-workspace/commit/22a17980ff4f6f8c40adb1b8f4ffc6dae2fe7e30) ([#1537](https://github.com/tauri-apps/plugins-workspace/pull/1537) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri beta.24. + +## \[2.0.0-beta.7] + +- [`76daee7a`](https://github.com/tauri-apps/plugins-workspace/commit/76daee7aafece34de3092c86e531cf9eb1138989) ([#1512](https://github.com/tauri-apps/plugins-workspace/pull/1512) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Update to tauri beta.23. + +## \[2.0.0-beta.6] + +- [`9013854f`](https://github.com/tauri-apps/plugins-workspace/commit/9013854f42a49a230b9dbb9d02774765528a923f)([#1382](https://github.com/tauri-apps/plugins-workspace/pull/1382)) Update to tauri beta.22. + +## \[2.0.0-beta.5] + +- [`430bd6f4`](https://github.com/tauri-apps/plugins-workspace/commit/430bd6f4f379bee5d232ae6b098ae131db7f178a)([#1363](https://github.com/tauri-apps/plugins-workspace/pull/1363)) Update to tauri beta.20. + +## \[2.0.0-beta.4] + +- [`bd1ed590`](https://github.com/tauri-apps/plugins-workspace/commit/bd1ed5903ffcce5500310dac1e59e8c67674ef1e)([#1237](https://github.com/tauri-apps/plugins-workspace/pull/1237)) Update to tauri beta.17. + +## \[2.0.0-beta.3] + +- [`a04ea2f`](https://github.com/tauri-apps/plugins-workspace/commit/a04ea2f38294d5a3987578283badc8eec87a7752)([#1071](https://github.com/tauri-apps/plugins-workspace/pull/1071)) The global API script is now only added to the binary when the `withGlobalTauri` config is true. + +## \[2.0.0-beta.2] + +- [`99bea25`](https://github.com/tauri-apps/plugins-workspace/commit/99bea2559c2c0648c2519c50a18cd124dacef57b)([#1005](https://github.com/tauri-apps/plugins-workspace/pull/1005)) Update to tauri beta.8. + +## \[2.0.0-beta.1] + +- [`14f381a`](https://github.com/tauri-apps/plugins-workspace/commit/14f381acf8fe690acecc676922c6f05939b95734) Update MSRV to 1.75. +- [`569defb`](https://github.com/tauri-apps/plugins-workspace/commit/569defbe9492e38938554bb7bdc1be9151456d21) Update to tauri beta.4. + +## \[2.0.0-beta.0] + +- [`d198c01`](https://github.com/tauri-apps/plugins-workspace/commit/d198c014863ee260cb0de88a14b7fc4356ef7474)([#862](https://github.com/tauri-apps/plugins-workspace/pull/862)) Update to tauri beta. +- [`d198c01`](https://github.com/tauri-apps/plugins-workspace/commit/d198c014863ee260cb0de88a14b7fc4356ef7474)([#862](https://github.com/tauri-apps/plugins-workspace/pull/862)) Add permissions. + +## \[2.0.0-alpha.6] + +- [`2cf8faa`](https://github.com/tauri-apps/plugins-workspace/commit/2cf8faa3e149af55eb86e5aba8ebfc54210ca703)([#839](https://github.com/tauri-apps/plugins-workspace/pull/839)) Update to tauri@alpha.20. + +## \[2.0.0-alpha.5] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to tauri@alpha.18. + +## \[2.0.0-alpha.4] + +- [`e438e0a`](https://github.com/tauri-apps/plugins-workspace/commit/e438e0a62d4b430a5159f05f13ecd397dd891a0d)([#676](https://github.com/tauri-apps/plugins-workspace/pull/676)) Update to tauri@alpha.17. + +## \[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 MSRV to 1.75. + ## \[2.0.0-alpha.2] - [`4e2cef9`](https://github.com/tauri-apps/plugins-workspace/commit/4e2cef9b702bbbb9cf4ee17de50791cb21f1b2a4)([#593](https://github.com/tauri-apps/plugins-workspace/pull/593)) Update to alpha.12. diff --git a/plugins/localhost/Cargo.toml b/plugins/localhost/Cargo.toml index 4147cd1b..34ee7ee6 100644 --- a/plugins/localhost/Cargo.toml +++ b/plugins/localhost/Cargo.toml @@ -1,14 +1,23 @@ [package] name = "tauri-plugin-localhost" -version = "2.0.0-alpha.2" +version = "2.2.0" description = "Expose your apps assets through a localhost server instead of the default custom protocol." authors = { workspace = true } license = { workspace = true } edition = { workspace = true } rust-version = { workspace = true } +repository = { workspace = true } [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] + +[package.metadata.platforms.support] +windows = { level = "full", notes = "" } +linux = { level = "full", notes = "" } +macos = { level = "full", notes = "" } +android = { level = "none", notes = "" } +ios = { level = "none", notes = "" } [dependencies] serde = { workspace = true } @@ -17,4 +26,4 @@ tauri = { workspace = true } log = { workspace = true } thiserror = { workspace = true } tiny_http = "0.12" -http = "0.2" +http = "1" diff --git a/plugins/localhost/README.md b/plugins/localhost/README.md index 9eb24df5..dc0d98d2 100644 --- a/plugins/localhost/README.md +++ b/plugins/localhost/README.md @@ -2,11 +2,19 @@ Expose your apps assets through a localhost server instead of the default custom protocol. +| Platform | Supported | +| -------- | --------- | +| Linux | ✓ | +| Windows | ✓ | +| macOS | ✓ | +| Android | ✓ | +| iOS | ✓ | + > Note: This plugins brings considerable security risks and you should only use it if you know what your are doing. If in doubt, use the default custom protocol implementation. ## Install -_This plugin requires a Rust version of at least **1.70**_ +_This plugin requires a Rust version of at least **1.77.2**_ There are three general methods of installation that we can recommend. @@ -21,7 +29,7 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] portpicker = "0.1" # used in the example to pick a random free port -tauri-plugin-localhost = "2.0.0-alpha" +tauri-plugin-localhost = "2.0.0" # alternatively with Git: tauri-plugin-localhost = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -30,7 +38,7 @@ tauri-plugin-localhost = { git = "https://github.com/tauri-apps/plugins-workspac First you need to register the core plugin with Tauri: -`src-tauri/src/main.rs` +`src-tauri/src/lib.rs` ```rust use tauri::{Manager, window::WindowBuilder, WindowUrl}; @@ -42,7 +50,7 @@ fn main() { .plugin(tauri_plugin_localhost::Builder::new(port).build()) .setup(move |app| { app.ipc_scope().configure_remote_access( - RemoteDomainAccessScope::new(format!("localhost:{}", port)) + RemoteDomainAccessScope::new("localhost") .add_window("main") ); @@ -61,6 +69,22 @@ fn main() { PRs accepted. Please make sure to read the Contributing Guide before making a pull request. +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + ## License Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. diff --git a/plugins/localhost/SECURITY.md b/plugins/localhost/SECURITY.md new file mode 100644 index 00000000..4f09bbac --- /dev/null +++ b/plugins/localhost/SECURITY.md @@ -0,0 +1,23 @@ +# Security Policy + +**Do not report security vulnerabilities through public GitHub issues.** + +**Please use the [Private Vulnerability Disclosure](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) feature of GitHub.** + +Include as much of the following information: + +- Type of issue (e.g. improper input parsing, privilege escalation, etc.) +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- The distribution affected or used to help us with reproduction of the issue +- Step-by-step instructions to reproduce the issue +- Ideally a reproduction repository +- Impact of the issue, including how an attacker might exploit the issue + +We prefer to receive reports in English. + +## Contact + +Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). + +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/localhost/src/lib.rs b/plugins/localhost/src/lib.rs index c0b42a29..5b00087f 100644 --- a/plugins/localhost/src/lib.rs +++ b/plugins/localhost/src/lib.rs @@ -2,8 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -//! [![](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/localhost/banner.png)](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/localhost) -//! //! Expose your apps assets through a localhost server instead of the default custom protocol. //! //! **Note: This plugins brings considerable security risks and you should only use it if you know what your are doing. If in doubt, use the default custom protocol implementation.** @@ -46,6 +44,7 @@ type OnRequest = Option>; pub struct Builder { port: u16, + host: Option, on_request: OnRequest, } @@ -53,10 +52,17 @@ impl Builder { pub fn new(port: u16) -> Self { Self { port, + host: None, on_request: None, } } + // Change the host the plugin binds to. Defaults to `localhost`. + pub fn host>(mut self, host: H) -> Self { + self.host = Some(host.into()); + self + } + pub fn on_request( mut self, f: F, @@ -67,6 +73,7 @@ impl Builder { pub fn build(mut self) -> TauriPlugin { let port = self.port; + let host = self.host.unwrap_or("localhost".to_string()); let on_request = self.on_request.take(); PluginBuilder::new("localhost") @@ -74,7 +81,7 @@ impl Builder { let asset_resolver = app.asset_resolver(); std::thread::spawn(move || { let server = - Server::http(&format!("localhost:{port}")).expect("Unable to spawn server"); + Server::http(format!("{host}:{port}")).expect("Unable to spawn server"); for req in server.incoming_requests() { let path = req .url() @@ -102,16 +109,6 @@ impl Builder { on_request(&request, &mut response); } - #[cfg(target_os = "linux")] - if let Some(response_csp) = - response.headers.get("Content-Security-Policy") - { - let html = String::from_utf8_lossy(&asset.bytes); - let body = - html.replacen(tauri::utils::html::CSP_TOKEN, response_csp, 1); - asset.bytes = body.as_bytes().to_vec(); - } - let mut resp = HttpResponse::from_data(asset.bytes); for (header, value) in response.headers { if let Ok(h) = Header::from_bytes(header.as_bytes(), value) { diff --git a/plugins/log/.gitignore b/plugins/log/.gitignore deleted file mode 100644 index 28fd5eff..00000000 --- a/plugins/log/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -node_modules -/.tauri diff --git a/plugins/log/CHANGELOG.md b/plugins/log/CHANGELOG.md index 3109c03f..210df69b 100644 --- a/plugins/log/CHANGELOG.md +++ b/plugins/log/CHANGELOG.md @@ -1,5 +1,138 @@ # Changelog +## \[2.4.0] + +- [`c9b21f6f`](https://github.com/tauri-apps/plugins-workspace/commit/c9b21f6f4345806eff5f495885f20dea0082b7d7) ([#2625](https://github.com/tauri-apps/plugins-workspace/pull/2625) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Export the `LogLevel` type. +- [`9629c2f4`](https://github.com/tauri-apps/plugins-workspace/commit/9629c2f4f90a56b5c2d265d1d13d3af40fc0c525) ([#2600](https://github.com/tauri-apps/plugins-workspace/pull/2600) by [@exoego](https://github.com/tauri-apps/plugins-workspace/../../exoego)) Adds a new varient `TargetKind::Dispatch` that allows you to construct arbitrary log targets +- [`686a839c`](https://github.com/tauri-apps/plugins-workspace/commit/686a839c96fae1b0334f2df9dc76ca5cdbe00dbe) ([#2626](https://github.com/tauri-apps/plugins-workspace/pull/2626) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Fix iOS app stuck when using the iOS Simulator and the log plugin due to a deadlock when calling os_log too early. + +### feat + +- [`60fc35d3`](https://github.com/tauri-apps/plugins-workspace/commit/60fc35d35cccaf1654eceb4446ecf0f89dc15502) ([#2576](https://github.com/tauri-apps/plugins-workspace/pull/2576) by [@3lpsy](https://github.com/tauri-apps/plugins-workspace/../../3lpsy)) Add a `tracing` feature to the `log` plugin that emits log messages to the `tracing` system. + +## \[2.3.1] + +- [`1bb1ced5`](https://github.com/tauri-apps/plugins-workspace/commit/1bb1ced53820127204aa7adf57510c1cbce55e12) ([#2524](https://github.com/tauri-apps/plugins-workspace/pull/2524) by [@elwerene](https://github.com/tauri-apps/plugins-workspace/../../elwerene)) enable TargetKind::LogDir on mobile + +## \[2.3.0] + +### feat + +- [`02481501`](https://github.com/tauri-apps/plugins-workspace/commit/024815018fbc63a37afc716796a454925aa7d25e) ([#2377](https://github.com/tauri-apps/plugins-workspace/pull/2377) by [@3lpsy](https://github.com/tauri-apps/plugins-workspace/../../3lpsy)) Add a `is_skip_logger` flag to the Log Plugin `Builder` struct, a `skip_logger()` method to the Builder, and logic to avoid acquiring (creating) a logger and attaching it to the global logger. Since acquire_logger is pub, a `LoggerNotInitialized` is added and returned if it's called when the `is_skip_looger` flag is set. Overall, this feature permits a user to avoid calling `attach_logger` which can only be called once in a program's lifetime and allows the user to control the logger returned from `logger()`. Additionally, it also will allow users to generate multiple Tauri Mock apps in test suites that run and parallel and have the `log` plugin attached (assuming they use `skip_logger()`). + +## \[2.2.3] + +- [`1a984659`](https://github.com/tauri-apps/plugins-workspace/commit/1a9846599b6a71faf330845847a30f6bf9735898) ([#2469](https://github.com/tauri-apps/plugins-workspace/pull/2469) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Update `objc2` crate to 0.6. No user facing changes. + +## \[2.2.2] + +- [`6b4c3917`](https://github.com/tauri-apps/plugins-workspace/commit/6b4c3917389f4bc489d03b48a837557ac0584175) ([#2401](https://github.com/tauri-apps/plugins-workspace/pull/2401) by [@Seishiin](https://github.com/tauri-apps/plugins-workspace/../../Seishiin)) Fix timezone_strategy overwriting previously set LogLevels. + +## \[2.2.1] + +- [`784a54a3`](https://github.com/tauri-apps/plugins-workspace/commit/784a54a39094dfbaaa8dd123eb083c04dc6c3bb2) ([#2344](https://github.com/tauri-apps/plugins-workspace/pull/2344) by [@madsmtm](https://github.com/tauri-apps/plugins-workspace/../../madsmtm)) Use `objc2` instead of `objc`. + +## \[2.2.0] + +- [`3a79266b`](https://github.com/tauri-apps/plugins-workspace/commit/3a79266b8cf96a55b1ae6339d725567d45a44b1d) ([#2173](https://github.com/tauri-apps/plugins-workspace/pull/2173) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Bumped all plugins to `v2.2.0`. From now, the versions for the Rust and JavaScript packages of each plugin will be in sync with each other. + +## \[2.0.2] + +- [`69d508ee`](https://github.com/tauri-apps/plugins-workspace/commit/69d508ee6910ae4064f2398fbacb803b3944d6a8) ([#2157](https://github.com/tauri-apps/plugins-workspace/pull/2157) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Make log functions omit caller location when failed to parse it instead of throwing + +## \[2.0.1] + +- [`371a2f73`](https://github.com/tauri-apps/plugins-workspace/commit/371a2f7361e0b91cf66f1287ffb18b34414a6cb8) ([#2021](https://github.com/tauri-apps/plugins-workspace/pull/2021) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Make webview log target more consistent that it always starts with `webview` + +## \[2.0.2] + +- [`606fa08d`](https://github.com/tauri-apps/plugins-workspace/commit/606fa08dae1acd074b961fb360623f4c86f13ee8) ([#1997](https://github.com/tauri-apps/plugins-workspace/pull/1997) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) **Potentially breaking:** Updated `fern` from 0.6 to 0.7. This is technically a breaking change because `fern` is re-exported in `tauri-plugin-log`. + +## \[2.0.1] + +- [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. + +## \[2.0.0] + +- [`e2c4dfb6`](https://github.com/tauri-apps/plugins-workspace/commit/e2c4dfb6af43e5dd8d9ceba232c315f5febd55c1) Update to tauri v2 stable release. + +## \[2.0.0-rc.1] + +- [`e2e97db5`](https://github.com/tauri-apps/plugins-workspace/commit/e2e97db51983267f5be84d4f6f0278d58834d1f5) ([#1701](https://github.com/tauri-apps/plugins-workspace/pull/1701) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri 2.0.0-rc.8 + +## \[2.0.0-rc.1] + +- [`b9147758`](https://github.com/tauri-apps/plugins-workspace/commit/b914775898c2bee7ceb20bd17ee595005cd17a64) ([#1679](https://github.com/tauri-apps/plugins-workspace/pull/1679) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Explicitly set a minimum macOS version for the Swift package. + +## \[2.0.0-rc.0] + +- [`9887d1`](https://github.com/tauri-apps/plugins-workspace/commit/9887d14bd0e971c4c0f5c1188fc4005d3fc2e29e) Update to tauri RC. + +## \[2.0.0-beta.9] + +- [`99d6ac0f`](https://github.com/tauri-apps/plugins-workspace/commit/99d6ac0f9506a6a4a1aa59c728157190a7441af6) ([#1606](https://github.com/tauri-apps/plugins-workspace/pull/1606) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) The JS packages now specify the *minimum* `@tauri-apps/api` version instead of a single exact version. +- [`6de87966`](https://github.com/tauri-apps/plugins-workspace/commit/6de87966ecc00ad9d91c25be452f1f46bd2b7e1f) ([#1597](https://github.com/tauri-apps/plugins-workspace/pull/1597) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Update to tauri beta.25. + +## \[2.0.0-beta.9] + +- [`20a1d24e`](https://github.com/tauri-apps/plugins-workspace/commit/20a1d24ee004e77c2d12a0e20d258ce120216ed1) ([#1579](https://github.com/tauri-apps/plugins-workspace/pull/1579) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Added `Builder::split` which returns the raw logger implementation so you can pipe to other loggers such as `multi_log` or `tauri-plugin-devtools`. + +## \[2.0.0-beta.8] + +- [`22a17980`](https://github.com/tauri-apps/plugins-workspace/commit/22a17980ff4f6f8c40adb1b8f4ffc6dae2fe7e30) ([#1537](https://github.com/tauri-apps/plugins-workspace/pull/1537) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri beta.24. + +## \[2.0.0-beta.7] + +- [`76daee7a`](https://github.com/tauri-apps/plugins-workspace/commit/76daee7aafece34de3092c86e531cf9eb1138989) ([#1512](https://github.com/tauri-apps/plugins-workspace/pull/1512) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Update to tauri beta.23. + +## \[2.0.0-beta.6] + +- [`9013854f`](https://github.com/tauri-apps/plugins-workspace/commit/9013854f42a49a230b9dbb9d02774765528a923f)([#1382](https://github.com/tauri-apps/plugins-workspace/pull/1382)) Update to tauri beta.22. + +## \[2.0.0-beta.5] + +- [`430bd6f4`](https://github.com/tauri-apps/plugins-workspace/commit/430bd6f4f379bee5d232ae6b098ae131db7f178a)([#1363](https://github.com/tauri-apps/plugins-workspace/pull/1363)) Update to tauri beta.20. + +## \[2.0.0-beta.4] + +- [`bd1ed590`](https://github.com/tauri-apps/plugins-workspace/commit/bd1ed5903ffcce5500310dac1e59e8c67674ef1e)([#1237](https://github.com/tauri-apps/plugins-workspace/pull/1237)) Update to tauri beta.17. + +## \[2.0.0-beta.3] + +- [`ed46dca`](https://github.com/tauri-apps/plugins-workspace/commit/ed46dca74ff3947dbbcb26a7b571c129bf925698) Added `attachLogger` helper function to register a function that should be called for each log entry. + +## \[2.0.0-beta.3] + +- [`a04ea2f`](https://github.com/tauri-apps/plugins-workspace/commit/a04ea2f38294d5a3987578283badc8eec87a7752)([#1071](https://github.com/tauri-apps/plugins-workspace/pull/1071)) The global API script is now only added to the binary when the `withGlobalTauri` config is true. + +## \[2.0.0-beta.2] + +- [`99bea25`](https://github.com/tauri-apps/plugins-workspace/commit/99bea2559c2c0648c2519c50a18cd124dacef57b)([#1005](https://github.com/tauri-apps/plugins-workspace/pull/1005)) Update to tauri beta.8. + +## \[2.0.0-beta.1] + +- [`569defb`](https://github.com/tauri-apps/plugins-workspace/commit/569defbe9492e38938554bb7bdc1be9151456d21) Update to tauri beta.4. + +## \[2.0.0-beta.0] + +- [`d198c01`](https://github.com/tauri-apps/plugins-workspace/commit/d198c014863ee260cb0de88a14b7fc4356ef7474)([#862](https://github.com/tauri-apps/plugins-workspace/pull/862)) Update to tauri beta. + +## \[2.0.0-alpha.5] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.13. + +## \[2.0.0-alpha.4] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.12. + +## \[2.0.0-alpha.3] + +- [`e438e0a`](https://github.com/tauri-apps/plugins-workspace/commit/e438e0a62d4b430a5159f05f13ecd397dd891a0d)([#676](https://github.com/tauri-apps/plugins-workspace/pull/676)) Update to @tauri-apps/api v2.0.0-alpha.11. + +## \[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.9. + ## \[2.0.0-alpha.2] - [`4e2cef9`](https://github.com/tauri-apps/plugins-workspace/commit/4e2cef9b702bbbb9cf4ee17de50791cb21f1b2a4)([#593](https://github.com/tauri-apps/plugins-workspace/pull/593)) Update to alpha.12. @@ -10,9 +143,4 @@ ## \[2.0.0-alpha.0] -- [`717ae67`](https://github.com/tauri-apps/plugins-workspace/commit/717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! - te to alpha.11. - -## \[2.0.0-alpha.0] - - [`717ae67`](https://github.com/tauri-apps/plugins-workspace/commit/717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! diff --git a/plugins/log/Cargo.toml b/plugins/log/Cargo.toml index 36da3706..4303e68f 100644 --- a/plugins/log/Cargo.toml +++ b/plugins/log/Cargo.toml @@ -1,35 +1,51 @@ [package] name = "tauri-plugin-log" -version = "2.0.0-alpha.2" +version = "2.4.0" description = "Configurable logging for your Tauri app." authors = { workspace = true } license = { workspace = true } edition = { workspace = true } rust-version = { workspace = true } +repository = { workspace = true } +links = "tauri-plugin-log" [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] + +[package.metadata.platforms.support] +windows = { level = "full", notes = "" } +linux = { level = "full", notes = "" } +macos = { level = "full", notes = "" } +android = { level = "full", notes = "" } +ios = { level = "full", notes = "" } [build-dependencies] -tauri-build = { workspace = true } +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } serde_json = { workspace = true } tauri = { workspace = true } +thiserror = { workspace = true } serde_repr = "0.1" -byte-unit = "4.0" -log = { workspace = true, features = [ "kv_unstable" ] } -time = { version = "0.3", features = [ "formatting", "local-offset", "parsing" ] } -fern = "0.6" +byte-unit = "5" +log = { workspace = true, features = ["kv_unstable"] } +time = { version = "0.3", features = ["formatting", "local-offset", "macros", "parsing"] } +fern = "0.7" +tracing = { workspace = true, optional = true } [target."cfg(target_os = \"android\")".dependencies] -android_logger = "0.11" +android_logger = "0.15" [target."cfg(target_os = \"ios\")".dependencies] -swift-rs = "1.0.1" -objc = "0.2" -cocoa = "0.24" +swift-rs = "1" +objc2 = "0.6" +objc2-foundation = { version = "0.3", default-features = false, features = [ + "std", + "NSString", +] } [features] -colored = [ "fern/colored" ] +colored = ["fern/colored"] +tracing = ["dep:tracing"] diff --git a/plugins/log/README.md b/plugins/log/README.md index e1fea786..462bdab9 100644 --- a/plugins/log/README.md +++ b/plugins/log/README.md @@ -2,9 +2,17 @@ Configurable logging for your Tauri app. +| Platform | Supported | +| -------- | --------- | +| Linux | ✓ | +| Windows | ✓ | +| macOS | ✓ | +| Android | ✓ | +| iOS | ✓ | + ## Install -_This plugin requires a Rust version of at least **1.70**_ +_This plugin requires a Rust version of at least **1.77.2**_ There are three general methods of installation that we can recommend. @@ -18,12 +26,14 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] -tauri-plugin-log = "2.0.0-alpha" +tauri-plugin-log = "2.0.0" # alternatively with Git: tauri-plugin-log = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` -You can install the JavaScript Guest bindings using your preferred JavaScript package manager: +If you want the single instance mechanism to only trigger for semver compatible instances of your apps, for example if you expect users to have multiple installations of your app installed, you can add `features = ["semver"]` to the dependency declaration in `Cargo.toml`. + +Then you can install the JavaScript Guest bindings using your preferred JavaScript package manager: > Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use. @@ -44,19 +54,35 @@ yarn add https://github.com/tauri-apps/tauri-plugin-log#v2 ## Usage -First you need to register the core plugin with Tauri: +First, you should enable the `log:default` capability: + +```json +{ + "$schema": "../gen/schemas/desktop-schema.json", + "identifier": "default", + "description": "Capability for the main window", + "windows": ["main"], + "permissions": [ + "core:default", + "opener:default", + "log:default" # add this! + ] +} +``` + +Then, you need to register the core plugin with Tauri: -`src-tauri/src/main.rs` +`src-tauri/src/lib.rs` ```rust -use tauri_plugin_log::{LogTarget}; +use tauri_plugin_log::{Target, TargetKind}; fn main() { tauri::Builder::default() - .plugin(tauri_plugin_log::Builder::default().targets([ - LogTarget::LogDir, - LogTarget::Stdout, - LogTarget::Webview, + .plugin(tauri_plugin_log::Builder::new().targets([ + Target::new(TargetKind::Stdout), + Target::new(TargetKind::LogDir { file_name: None }), + Target::new(TargetKind::Webview), ]).build()) .run(tauri::generate_context!()) .expect("error while running tauri application"); @@ -66,17 +92,17 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import { trace, info, error, attachConsole } from "@tauri-apps/plugin-log"; +import { trace, info, error, attachConsole } from '@tauri-apps/plugin-log' -// with LogTarget::Webview enabled this function will print logs to the browser console -const detach = await attachConsole(); +// with TargetKind::Webview enabled this function will print logs to the browser console +const detach = await attachConsole() -trace("Trace"); -info("Info"); -error("Error"); +trace('Trace') +info('Info') +error('Error') // detach the browser console from the log stream -detach(); +detach() ``` To log from rust code, add the log crate to your `Cargo.toml`: @@ -92,6 +118,22 @@ Now, you can use the macros provided by the log crate to log messages from your PRs accepted. Please make sure to read the Contributing Guide before making a pull request. +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + ## License Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. diff --git a/plugins/log/SECURITY.md b/plugins/log/SECURITY.md new file mode 100644 index 00000000..d013f6a6 --- /dev/null +++ b/plugins/log/SECURITY.md @@ -0,0 +1,56 @@ +# Security Policy + +**Do not report security vulnerabilities through public GitHub issues.** + +**Please use the [Private Vulnerability Disclosure](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) feature of GitHub.** + +Include as much of the following information: + +- Type of issue (e.g. improper input parsing, privilege escalation, etc.) +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- The distribution affected or used to help us with reproduction of the issue +- Step-by-step instructions to reproduce the issue +- Ideally a reproduction repository +- Impact of the issue, including how an attacker might exploit the issue + +We prefer to receive reports in English. + +## Contact + +Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). + +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). + +## Threat Model + +### Security Assumptions + +- The log file interpreting applications are hardened, as input is not sanitized +- No log events in the rust core are leaked to the frontend unless explicitly configured to output to the `TargetKind::Webview` component +- The log events generated in the frontend can be accessed from everywhere in the frontend +- There is no secret censoring inbuilt and developers need to take care of what they log in their application + +### Threats + +#### Secret Leakage + +One possible threat you need to consider when using this plugin is that secrets +in logs can theoretically be leaked when the application's frontend gets compromised. + +For this threat to be possible all of the following requirements need to be fulfilled: + +- `TargetKind::Webview` enabled OR secrets stem from frontend logs +- Frontend application is compromised via something like XSS (cross-site-scripting) OR logs are directly exposed +- Logs contain secrets or sensitive information + +If these requirements are not met, the leakage should not be possible. + +#### Out Of Scope + +- Any exploits on the log viewer/file viewer accessing the logs + +## Best Practices + +Do not log secrets or sensitive values in your logging and ensure that the upstream crates are not leaking such values in their logging events. +Ensure that logs are sanitized or trusted before opening them with third party tools. diff --git a/plugins/log/api-iife.js b/plugins/log/api-iife.js new file mode 100644 index 00000000..c94f2aab --- /dev/null +++ b/plugins/log/api-iife.js @@ -0,0 +1 @@ +if("__TAURI__"in window){var __TAURI_PLUGIN_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){const t={kind:"Any"};return r("plugin:event|listen",{event:e,target:t,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){const o=function(e){if(e){if(!e.startsWith("Error")){const n=e.split("\n").map((e=>e.split("@"))).filter((([e,n])=>e.length>0&&"[native code]"!==n));return n[2]?.filter((e=>e.length>0)).join("@")}{const n=e.split("\n"),r=n[3]?.trim();if(!r)return;const a=/at\s+(?.*?)\s+\((?.*?):(?\d+):(?\d+)\)/,o=r.match(a);if(o){const{functionName:e,fileName:n,lineNumber:r,columnNumber:a}=o.groups;return`${e}@${n}:${r}:${a}`}{const e=/at\s+(?.*?):(?\d+):(?\d+)/,n=r.match(e);if(n){const{fileName:e,lineNumber:r,columnNumber:a}=n.groups;return`@${e}:${r}:${a}`}}}}}((new Error).stack),{file:t,line:i,keyValues:l}=a??{};await r("plugin:log|log",{level:e,message:n,location:o,file:t,line:i,keyValues:l})}async function l(e){return await t("log://log",(n=>{const{level:r}=n.payload;let{message:a}=n.payload;a=a.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,""),e({message:a,level:r})}))}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_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_CREATED="tauri://window-created",e.WEBVIEW_CREATED="tauri://webview-created",e.DRAG_ENTER="tauri://drag-enter",e.DRAG_OVER="tauri://drag-over",e.DRAG_DROP="tauri://drag-drop",e.DRAG_LEAVE="tauri://drag-leave"}(a||(a={})),e.LogLevel=void 0,(o=e.LogLevel||(e.LogLevel={}))[o.Trace=1]="Trace",o[o.Debug=2]="Debug",o[o.Info=3]="Info",o[o.Warn=4]="Warn",o[o.Error=5]="Error",e.attachConsole=async function(){return await l((({level:n,message:r})=>{switch(n){case e.LogLevel.Trace:console.log(r);break;case e.LogLevel.Debug:console.debug(r);break;case e.LogLevel.Info:console.info(r);break;case e.LogLevel.Warn:console.warn(r);break;case e.LogLevel.Error:console.error(r);break;default:throw new Error(`unknown log level ${n}`)}}))},e.attachLogger=l,e.debug=async function(n,r){await i(e.LogLevel.Debug,n,r)},e.error=async function(n,r){await i(e.LogLevel.Error,n,r)},e.info=async function(n,r){await i(e.LogLevel.Info,n,r)},e.trace=async function(n,r){await i(e.LogLevel.Trace,n,r)},e.warn=async function(n,r){await i(e.LogLevel.Warn,n,r)},e}({});Object.defineProperty(window.__TAURI__,"log",{value:__TAURI_PLUGIN_LOG__})} diff --git a/plugins/log/build.rs b/plugins/log/build.rs index e499a5e5..5969c1e9 100644 --- a/plugins/log/build.rs +++ b/plugins/log/build.rs @@ -2,14 +2,11 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use std::process::exit; +const COMMANDS: &[&str] = &["log"]; fn main() { - if let Err(error) = tauri_build::mobile::PluginBuilder::new() + tauri_plugin::Builder::new(COMMANDS) + .global_api_script_path("./api-iife.js") .ios_path("ios") - .run() - { - println!("{error:#}"); - exit(1); - } + .build(); } diff --git a/plugins/log/guest-js/index.ts b/plugins/log/guest-js/index.ts index 0f901203..93022a97 100644 --- a/plugins/log/guest-js/index.ts +++ b/plugins/log/guest-js/index.ts @@ -2,17 +2,16 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { listen, UnlistenFn } from "@tauri-apps/api/event"; +import { invoke } from '@tauri-apps/api/core' +import { listen, type UnlistenFn, type Event } from '@tauri-apps/api/event' -import { invoke } from "@tauri-apps/api/primitives"; - -export type LogOptions = { - file?: string; - line?: number; - keyValues?: Record; -}; +export interface LogOptions { + file?: string + line?: number + keyValues?: Record +} -enum LogLevel { +export enum LogLevel { /** * The "trace" level. * @@ -42,35 +41,92 @@ enum LogLevel { * * Designates very serious errors. */ - Error, + Error +} + +function getCallerLocation(stack?: string) { + if (!stack) { + return + } + + if (stack.startsWith('Error')) { + // Assume it's Chromium V8 + // + // Error + // at baz (filename.js:10:15) + // at bar (filename.js:6:3) + // at foo (filename.js:2:3) + // at filename.js:13:1 + + const lines = stack.split('\n') + // Find the third line (caller's caller of the current location) + const callerLine = lines[3]?.trim() + if (!callerLine) { + return + } + + const regex = + /at\s+(?.*?)\s+\((?.*?):(?\d+):(?\d+)\)/ + const match = callerLine.match(regex) + + if (match) { + const { functionName, fileName, lineNumber, columnNumber } = + match.groups as { + functionName: string + fileName: string + lineNumber: string + columnNumber: string + } + return `${functionName}@${fileName}:${lineNumber}:${columnNumber}` + } else { + // Handle cases where the regex does not match (e.g., last line without function name) + const regexNoFunction = + /at\s+(?.*?):(?\d+):(?\d+)/ + const matchNoFunction = callerLine.match(regexNoFunction) + if (matchNoFunction) { + const { fileName, lineNumber, columnNumber } = + matchNoFunction.groups as { + fileName: string + lineNumber: string + columnNumber: string + } + return `@${fileName}:${lineNumber}:${columnNumber}` + } + } + } else { + // Assume it's Webkit JavaScriptCore, example: + // + // baz@filename.js:10:24 + // bar@filename.js:6:6 + // foo@filename.js:2:6 + // global code@filename.js:13:4 + + const traces = stack.split('\n').map((line) => line.split('@')) + const filtered = traces.filter(([name, location]) => { + return name.length > 0 && location !== '[native code]' + }) + // Find the third line (caller's caller of the current location) + return filtered[2]?.filter((v) => v.length > 0).join('@') + } } async function log( level: LogLevel, message: string, - options?: LogOptions, + options?: LogOptions ): Promise { - const traces = new Error().stack?.split("\n").map((line) => line.split("@")); + const location = getCallerLocation(new Error().stack) - const filtered = traces?.filter(([name, location]) => { - return name.length > 0 && location !== "[native code]"; - }); + const { file, line, keyValues } = options ?? {} - const { file, line, keyValues } = options ?? {}; - - let location = filtered?.[0]?.filter((v) => v.length > 0).join("@"); - if (location === "Error") { - location = "webview::unknown"; - } - - await invoke("plugin:log|log", { + await invoke('plugin:log|log', { level, message, location, file, line, - keyValues, - }); + keyValues + }) } /** @@ -91,9 +147,9 @@ async function log( */ export async function error( message: string, - options?: LogOptions, + options?: LogOptions ): Promise { - await log(LogLevel.Error, message, options); + await log(LogLevel.Error, message, options) } /** @@ -113,9 +169,9 @@ export async function error( */ export async function warn( message: string, - options?: LogOptions, + options?: LogOptions ): Promise { - await log(LogLevel.Warn, message, options); + await log(LogLevel.Warn, message, options) } /** @@ -135,9 +191,9 @@ export async function warn( */ export async function info( message: string, - options?: LogOptions, + options?: LogOptions ): Promise { - await log(LogLevel.Info, message, options); + await log(LogLevel.Info, message, options) } /** @@ -157,9 +213,9 @@ export async function info( */ export async function debug( message: string, - options?: LogOptions, + options?: LogOptions ): Promise { - await log(LogLevel.Debug, message, options); + await log(LogLevel.Debug, message, options) } /** @@ -179,47 +235,66 @@ export async function debug( */ export async function trace( message: string, - options?: LogOptions, + options?: LogOptions ): Promise { - await log(LogLevel.Trace, message, options); + await log(LogLevel.Trace, message, options) } interface RecordPayload { - level: LogLevel; - message: string; + level: LogLevel + message: string } -export async function attachConsole(): Promise { - return await listen("log://log", (event) => { - const payload = event.payload as RecordPayload; +type LoggerFn = (fn: RecordPayload) => void + +/** + * Attaches a listener for the log, and calls the passed function for each log entry. + * @param fn + * + * @returns a function to cancel the listener. + */ +export async function attachLogger(fn: LoggerFn): Promise { + return await listen('log://log', (event: Event) => { + const { level } = event.payload + let { message } = event.payload // Strip ANSI escape codes - const message = payload.message.replace( + message = message.replace( // TODO: Investigate security/detect-unsafe-regex // eslint-disable-next-line no-control-regex, security/detect-unsafe-regex /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, - "", - ); + '' + ) + fn({ message, level }) + }) +} - switch (payload.level) { +/** + * Attaches a listener that writes log entries to the console as they come in. + * + * @returns a function to cancel the listener. + */ +export async function attachConsole(): Promise { + return await attachLogger(({ level, message }: RecordPayload) => { + switch (level) { case LogLevel.Trace: - console.log(message); - break; + console.log(message) + break case LogLevel.Debug: - console.debug(message); - break; + console.debug(message) + break case LogLevel.Info: - console.info(message); - break; + console.info(message) + break case LogLevel.Warn: - console.warn(message); - break; + console.warn(message) + break case LogLevel.Error: - console.error(message); - break; + console.error(message) + break default: // eslint-disable-next-line @typescript-eslint/restrict-template-expressions - throw new Error(`unknown log level ${payload.level}`); + throw new Error(`unknown log level ${level}`) } - }); + }) } diff --git a/plugins/log/ios/Package.swift b/plugins/log/ios/Package.swift index 4afbbbdb..1571f22e 100644 --- a/plugins/log/ios/Package.swift +++ b/plugins/log/ios/Package.swift @@ -6,28 +6,29 @@ import PackageDescription let package = Package( - name: "tauri-plugin-log", - platforms: [ - .iOS(.v11), - ], - products: [ - // Products define the executables and libraries a package produces, and make them visible to other packages. - .library( - name: "tauri-plugin-log", - type: .static, - targets: ["tauri-plugin-log"]), - ], - dependencies: [ - .package(name: "Tauri", path: "../.tauri/tauri-api") - ], - targets: [ - // Targets are the basic building blocks of a package. A target can define a module or a test suite. - // Targets can depend on other targets in this package, and on products in packages this package depends on. - .target( - name: "tauri-plugin-log", - dependencies: [ - .byName(name: "Tauri") - ], - path: "Sources") - ] + name: "tauri-plugin-log", + platforms: [ + .macOS(.v10_13), + .iOS(.v11), + ], + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .library( + name: "tauri-plugin-log", + type: .static, + targets: ["tauri-plugin-log"]) + ], + dependencies: [ + .package(name: "Tauri", path: "../.tauri/tauri-api") + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .target( + name: "tauri-plugin-log", + dependencies: [ + .byName(name: "Tauri") + ], + path: "Sources") + ] ) diff --git a/plugins/log/ios/Sources/LogPlugin.swift b/plugins/log/ios/Sources/LogPlugin.swift index cefdc858..e21b4bab 100644 --- a/plugins/log/ios/Sources/LogPlugin.swift +++ b/plugins/log/ios/Sources/LogPlugin.swift @@ -2,16 +2,41 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import UIKit -import Tauri import SwiftRs +import Tauri +import UIKit + +#if targetEnvironment(simulator) + var logReady = false +#else + var logReady = true +#endif @_cdecl("tauri_log") func log(level: Int, message: NSString) { - switch level { - case 1: Logger.debug(message as String) - case 2: Logger.info(message as String) - case 3: Logger.error(message as String) - default: break - } + if logReady { + os_log(level, message) + } else { + dispatch_log(level, message) + } +} + +func dispatch_log(_ level: Int, _ message: NSString) { + // delay logging when the logger isn't immediately available + // in some cases when using the simulator the app would hang when calling os_log too soon + // better be safe here and wait a few seconds than actually freeze the app in dev mode + // in production this isn't a problem + DispatchQueue.main.asyncAfter(deadline: .now() + 2) { + os_log(level, message) + logReady = true + } +} + +func os_log(_ level: Int, _ message: NSString) { + switch level { + case 1: Logger.debug(message as String) + case 2: Logger.info(message as String) + case 3: Logger.error(message as String) + default: break + } } diff --git a/plugins/log/package.json b/plugins/log/package.json index fe6dd3da..9130ca88 100644 --- a/plugins/log/package.json +++ b/plugins/log/package.json @@ -1,33 +1,30 @@ { "name": "@tauri-apps/plugin-log", - "version": "2.0.0-alpha.1", + "version": "2.4.0", "description": "Configurable logging for your Tauri app.", - "license": "MIT or APACHE-2.0", + "license": "MIT OR Apache-2.0", "authors": [ "Tauri Programme within The Commons Conservancy" ], + "repository": "https://github.com/tauri-apps/plugins-workspace", "type": "module", - "browser": "dist-js/index.min.js", - "module": "dist-js/index.mjs", - "types": "dist-js/index.d.ts", + "types": "./dist-js/index.d.ts", + "main": "./dist-js/index.cjs", + "module": "./dist-js/index.js", "exports": { - "import": "./dist-js/index.mjs", "types": "./dist-js/index.d.ts", - "browser": "./dist-js/index.min.js" + "import": "./dist-js/index.js", + "require": "./dist-js/index.cjs" }, "scripts": { "build": "rollup -c" }, "files": [ "dist-js", - "!dist-js/**/*.map", "README.md", "LICENSE" ], - "devDependencies": { - "tslib": "2.6.0" - }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.9" + "@tauri-apps/api": "^2.0.0" } } diff --git a/plugins/log/permissions/autogenerated/commands/log.toml b/plugins/log/permissions/autogenerated/commands/log.toml new file mode 100644 index 00000000..ba36eff5 --- /dev/null +++ b/plugins/log/permissions/autogenerated/commands/log.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-log" +description = "Enables the log command without any pre-configured scope." +commands.allow = ["log"] + +[[permission]] +identifier = "deny-log" +description = "Denies the log command without any pre-configured scope." +commands.deny = ["log"] diff --git a/plugins/log/permissions/autogenerated/reference.md b/plugins/log/permissions/autogenerated/reference.md new file mode 100644 index 00000000..57d6c9f3 --- /dev/null +++ b/plugins/log/permissions/autogenerated/reference.md @@ -0,0 +1,43 @@ +## Default Permission + +Allows the log command + +#### This default permission set includes the following: + +- `allow-log` + +## Permission Table + + + + + + + + + + + + + + + + + +
IdentifierDescription
+ +`log:allow-log` + + + +Enables the log command without any pre-configured scope. + +
+ +`log:deny-log` + + + +Denies the log command without any pre-configured scope. + +
diff --git a/plugins/log/permissions/default.toml b/plugins/log/permissions/default.toml new file mode 100644 index 00000000..b2cb7c3a --- /dev/null +++ b/plugins/log/permissions/default.toml @@ -0,0 +1,4 @@ +"$schema" = "schemas/schema.json" +[default] +description = "Allows the log command" +permissions = ["allow-log"] diff --git a/plugins/log/permissions/schemas/schema.json b/plugins/log/permissions/schemas/schema.json new file mode 100644 index 00000000..cfee7e75 --- /dev/null +++ b/plugins/log/permissions/schemas/schema.json @@ -0,0 +1,318 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "PermissionFile", + "description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.", + "type": "object", + "properties": { + "default": { + "description": "The default permission set for the plugin", + "anyOf": [ + { + "$ref": "#/definitions/DefaultPermission" + }, + { + "type": "null" + } + ] + }, + "set": { + "description": "A list of permissions sets defined", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionSet" + } + }, + "permission": { + "description": "A list of inlined permissions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Permission" + } + } + }, + "definitions": { + "DefaultPermission": { + "description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.", + "type": "object", + "required": [ + "permissions" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "PermissionSet": { + "description": "A set of direct permissions grouped together under a new name.", + "type": "object", + "required": [ + "description", + "identifier", + "permissions" + ], + "properties": { + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does.", + "type": "string" + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionKind" + } + } + } + }, + "Permission": { + "description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.", + "type": "object", + "required": [ + "identifier" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri internal convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "commands": { + "description": "Allowed or denied commands when using this permission.", + "default": { + "allow": [], + "deny": [] + }, + "allOf": [ + { + "$ref": "#/definitions/Commands" + } + ] + }, + "scope": { + "description": "Allowed or denied scoped when using this permission.", + "allOf": [ + { + "$ref": "#/definitions/Scopes" + } + ] + }, + "platforms": { + "description": "Target platforms this permission applies. By default all platforms are affected by this permission.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Target" + } + } + } + }, + "Commands": { + "description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.", + "type": "object", + "properties": { + "allow": { + "description": "Allowed command.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "deny": { + "description": "Denied command, which takes priority.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "Scopes": { + "description": "An argument for fine grained behavior control of Tauri commands.\n\nIt can be of any serde serializable type and is used to allow or prevent certain actions inside a Tauri command. The configured scope is passed to the command and will be enforced by the command implementation.\n\n## Example\n\n```json { \"allow\": [{ \"path\": \"$HOME/**\" }], \"deny\": [{ \"path\": \"$HOME/secret.txt\" }] } ```", + "type": "object", + "properties": { + "allow": { + "description": "Data that defines what is allowed by the scope.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + }, + "deny": { + "description": "Data that defines what is denied by the scope. This should be prioritized by validation logic.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + } + } + }, + "Value": { + "description": "All supported ACL values.", + "anyOf": [ + { + "description": "Represents a null JSON value.", + "type": "null" + }, + { + "description": "Represents a [`bool`].", + "type": "boolean" + }, + { + "description": "Represents a valid ACL [`Number`].", + "allOf": [ + { + "$ref": "#/definitions/Number" + } + ] + }, + { + "description": "Represents a [`String`].", + "type": "string" + }, + { + "description": "Represents a list of other [`Value`]s.", + "type": "array", + "items": { + "$ref": "#/definitions/Value" + } + }, + { + "description": "Represents a map of [`String`] keys to [`Value`]s.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/Value" + } + } + ] + }, + "Number": { + "description": "A valid ACL number.", + "anyOf": [ + { + "description": "Represents an [`i64`].", + "type": "integer", + "format": "int64" + }, + { + "description": "Represents a [`f64`].", + "type": "number", + "format": "double" + } + ] + }, + "Target": { + "description": "Platform target.", + "oneOf": [ + { + "description": "MacOS.", + "type": "string", + "enum": [ + "macOS" + ] + }, + { + "description": "Windows.", + "type": "string", + "enum": [ + "windows" + ] + }, + { + "description": "Linux.", + "type": "string", + "enum": [ + "linux" + ] + }, + { + "description": "Android.", + "type": "string", + "enum": [ + "android" + ] + }, + { + "description": "iOS.", + "type": "string", + "enum": [ + "iOS" + ] + } + ] + }, + "PermissionKind": { + "type": "string", + "oneOf": [ + { + "description": "Enables the log command without any pre-configured scope.", + "type": "string", + "const": "allow-log", + "markdownDescription": "Enables the log command without any pre-configured scope." + }, + { + "description": "Denies the log command without any pre-configured scope.", + "type": "string", + "const": "deny-log", + "markdownDescription": "Denies the log command without any pre-configured scope." + }, + { + "description": "Allows the log command\n#### This default permission set includes:\n\n- `allow-log`", + "type": "string", + "const": "default", + "markdownDescription": "Allows the log command\n#### This default permission set includes:\n\n- `allow-log`" + } + ] + } + } +} \ No newline at end of file diff --git a/plugins/log/rollup.config.js b/plugins/log/rollup.config.js new file mode 100644 index 00000000..1f349ec8 --- /dev/null +++ b/plugins/log/rollup.config.js @@ -0,0 +1,7 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import { createConfig } from '../../shared/rollup.config.js' + +export default createConfig() diff --git a/plugins/log/rollup.config.mjs b/plugins/log/rollup.config.mjs deleted file mode 100644 index 99a3dd31..00000000 --- a/plugins/log/rollup.config.mjs +++ /dev/null @@ -1,11 +0,0 @@ -import { readFileSync } from "fs"; - -import { createConfig } from "../../shared/rollup.config.mjs"; - -export default createConfig({ - input: "guest-js/index.ts", - pkg: JSON.parse( - readFileSync(new URL("./package.json", import.meta.url), "utf8"), - ), - external: [/^@tauri-apps\/api/], -}); diff --git a/plugins/log/src/api-iife.js b/plugins/log/src/api-iife.js deleted file mode 100644 index 12b8c9e2..00000000 --- a/plugins/log/src/api-iife.js +++ /dev/null @@ -1 +0,0 @@ -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__})} diff --git a/plugins/log/src/lib.rs b/plugins/log/src/lib.rs index c4454e82..de5c5d54 100644 --- a/plugins/log/src/lib.rs +++ b/plugins/log/src/lib.rs @@ -2,8 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -//! [![](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/log/banner.png)](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/log) -//! //! Logging for Tauri applications. #![doc( @@ -28,39 +26,15 @@ use tauri::{ plugin::{self, TauriPlugin}, Manager, Runtime, }; +use tauri::{AppHandle, Emitter}; +use time::{macros::format_description, OffsetDateTime}; pub use fern; -use time::OffsetDateTime; -pub const WEBVIEW_TARGET: &str = "Webview"; +pub const WEBVIEW_TARGET: &str = "webview"; #[cfg(target_os = "ios")] mod ios { - use cocoa::base::id; - use objc::*; - - const UTF8_ENCODING: usize = 4; - pub struct NSString(pub id); - - impl NSString { - pub fn new(s: &str) -> Self { - // Safety: objc runtime calls are unsafe - NSString(unsafe { - let ns_string: id = msg_send![class!(NSString), alloc]; - let ns_string: id = msg_send![ns_string, - initWithBytes:s.as_ptr() - length:s.len() - encoding:UTF8_ENCODING]; - - // The thing is allocated in rust, the thing must be set to autorelease in rust to relinquish control - // or it can not be released correctly in OC runtime - let _: () = msg_send![ns_string, autorelease]; - - ns_string - }) - } - } - swift_rs::swift!(pub fn tauri_log( level: u8, message: *const std::ffi::c_void )); @@ -75,6 +49,20 @@ const DEFAULT_LOG_TARGETS: [Target; 2] = [ ]; const LOG_DATE_FORMAT: &str = "[year]-[month]-[day]_[hour]-[minute]-[second]"; +#[derive(Debug, thiserror::Error)] +pub enum Error { + #[error(transparent)] + Tauri(#[from] tauri::Error), + #[error(transparent)] + Io(#[from] std::io::Error), + #[error(transparent)] + TimeFormat(#[from] time::error::Format), + #[error(transparent)] + InvalidFormatDescription(#[from] time::error::InvalidFormatDescription), + #[error("Internal logger disabled and cannot be acquired or attached")] + LoggerNotInitialized, +} + /// An enum representing the available verbosity levels of the logger. /// /// It is very similar to the [`log::Level`], but serializes to unsigned ints instead of strings. @@ -128,11 +116,11 @@ impl From for LogLevel { } pub enum RotationStrategy { - // Will keep all the logs, renaming them to include the date + /// Will keep all the logs, renaming them to include the date. KeepAll, - // Will only keep the most recent log up to its maximal size + /// Will only keep the most recent log up to its maximal size. KeepOne, - // Will keep some of the most recent logs, renaming them to include the date. + /// Will keep some of the most recent logs, renaming them to include the date. KeepSome(usize), } @@ -172,20 +160,25 @@ pub enum TargetKind { path: PathBuf, file_name: Option, }, - /// Write logs to the OS specififc logs directory. + /// Write logs to the OS specific logs directory. /// /// ### Platform-specific /// - /// |Platform | Value | Example | - /// | ------- | --------------------------------------------- | ---------------------------------------------- | - /// | Linux | `{configDir}/{bundleIdentifier}` | `/home/alice/.config/com.tauri.dev` | - /// | macOS | `{homeDir}/Library/Logs/{bundleIdentifier}` | `/Users/Alice/Library/Logs/com.tauri.dev` | - /// | Windows | `{configDir}/{bundleIdentifier}` | `C:\Users\Alice\AppData\Roaming\com.tauri.dev` | + /// |Platform | Value | Example | + /// | --------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------- | + /// | Linux | `$XDG_DATA_HOME/{bundleIdentifier}/logs` or `$HOME/.local/share/{bundleIdentifier}/logs` | `/home/alice/.local/share/com.tauri.dev/logs` | + /// | macOS/iOS | `{homeDir}/Library/Logs/{bundleIdentifier}` | `/Users/Alice/Library/Logs/com.tauri.dev` | + /// | Windows | `{FOLDERID_LocalAppData}/{bundleIdentifier}/logs` | `C:\Users\Alice\AppData\Local\com.tauri.dev\logs` | + /// | Android | `{ConfigDir}/logs` | `/data/data/com.tauri.dev/files/logs` | LogDir { file_name: Option }, /// Forward logs to the webview (via the `log://log` event). /// /// This requires the webview to subscribe to log events, via this plugins `attachConsole` function. Webview, + /// Send logs to a [`fern::Dispatch`] + /// + /// You can use this to construct arbitrary log targets. + Dispatch(fern::Dispatch), } /// A log target. @@ -213,6 +206,38 @@ impl Target { } } +// Target becomes default and location is added as a parameter +#[cfg(feature = "tracing")] +fn emit_trace( + level: log::Level, + message: &String, + location: Option<&str>, + file: Option<&str>, + line: Option, + kv: &HashMap<&str, &str>, +) { + macro_rules! emit_event { + ($level:expr) => { + tracing::event!( + target: WEBVIEW_TARGET, + $level, + message = %message, + location = location, + file, + line, + ?kv + ) + }; + } + match level { + log::Level::Error => emit_event!(tracing::Level::ERROR), + log::Level::Warn => emit_event!(tracing::Level::WARN), + log::Level::Info => emit_event!(tracing::Level::INFO), + log::Level::Debug => emit_event!(tracing::Level::DEBUG), + log::Level::Trace => emit_event!(tracing::Level::TRACE), + } +} + #[tauri::command] fn log( level: LogLevel, @@ -222,22 +247,16 @@ fn log( line: Option, key_values: Option>, ) { - let location = location.unwrap_or("webview"); - let level = log::Level::from(level); - let metadata = log::MetadataBuilder::new() - .level(level) - .target(WEBVIEW_TARGET) - .build(); + let target = if let Some(location) = location { + format!("{WEBVIEW_TARGET}:{location}") + } else { + WEBVIEW_TARGET.to_string() + }; let mut builder = RecordBuilder::new(); - builder - .level(level) - .metadata(metadata) - .target(location) - .file(file) - .line(line); + builder.level(level).target(&target).file(file).line(line); let key_values = key_values.unwrap_or_default(); let mut kv = HashMap::new(); @@ -245,6 +264,8 @@ fn log( kv.insert(k.as_str(), v.as_str()); } builder.key_values(&kv); + #[cfg(feature = "tracing")] + emit_trace(level, &message, location, file, line, &kv); logger().log(&builder.args(format_args!("{message}")).build()); } @@ -255,14 +276,13 @@ pub struct Builder { timezone_strategy: TimezoneStrategy, max_file_size: u128, targets: Vec, + is_skip_logger: bool, } impl Default for Builder { fn default() -> Self { #[cfg(desktop)] - let format = - time::format_description::parse("[[[year]-[month]-[day]][[[hour]:[minute]:[second]]") - .unwrap(); + let format = format_description!("[[[year]-[month]-[day]][[[hour]:[minute]:[second]]"); let dispatch = fern::Dispatch::new().format(move |out, message, record| { out.finish( #[cfg(mobile)] @@ -283,6 +303,7 @@ impl Default for Builder { timezone_strategy: DEFAULT_TIMEZONE_STRATEGY, max_file_size: DEFAULT_MAX_FILE_SIZE, targets: DEFAULT_LOG_TARGETS.into(), + is_skip_logger: false, } } } @@ -300,10 +321,8 @@ impl Builder { pub fn timezone_strategy(mut self, timezone_strategy: TimezoneStrategy) -> Self { self.timezone_strategy = timezone_strategy.clone(); - let format = - time::format_description::parse("[[[year]-[month]-[day]][[[hour]:[minute]:[second]]") - .unwrap(); - self.dispatch = fern::Dispatch::new().format(move |out, message, record| { + let format = format_description!("[[[year]-[month]-[day]][[[hour]:[minute]:[second]]"); + self.dispatch = self.dispatch.format(move |out, message, record| { out.finish(format_args!( "{}[{}][{}] {}", timezone_strategy.get_now().format(&format).unwrap(), @@ -364,16 +383,31 @@ impl Builder { self } - /// Adds a collection of targets to the logger. + /// Skip the creation and global registration of a logger + /// + /// If you wish to use your own global logger, you must call `skip_logger` so that the plugin does not attempt to set a second global logger. In this configuration, no logger will be created and the plugin's `log` command will rely on the result of `log::logger()`. You will be responsible for configuring the logger yourself and any included targets will be ignored. If ever initializing the plugin multiple times, such as if registering the plugin while testing, call this method to avoid panicking when registering multiple loggers. For interacting with `tracing`, you can leverage the `tracing-log` logger to forward logs to `tracing` or enable the `tracing` feature for this plugin to emit events directly to the tracing system. Both scenarios require calling this method. + /// ```rust + /// static LOGGER: SimpleLogger = SimpleLogger; + /// + /// log::set_logger(&SimpleLogger)?; + /// log::set_max_level(LevelFilter::Info); + /// tauri_plugin_log::Builder::new() + /// .skip_logger(); + /// ``` + pub fn skip_logger(mut self) -> Self { + self.is_skip_logger = true; + self + } + + /// Replaces the targets of the logger. /// /// ```rust /// use tauri_plugin_log::{Target, TargetKind, WEBVIEW_TARGET}; /// tauri_plugin_log::Builder::new() - /// .clear_targets() /// .targets([ /// Target::new(TargetKind::Webview), - /// Target::new(TargetKind::LogDir { file_name: Some("webview".into()) }).filter(|metadata| metadata.target() == WEBVIEW_TARGET), - /// Target::new(TargetKind::LogDir { file_name: Some("rust".into()) }).filter(|metadata| metadata.target() != WEBVIEW_TARGET), + /// Target::new(TargetKind::LogDir { file_name: Some("webview".into()) }).filter(|metadata| metadata.target().starts_with(WEBVIEW_TARGET)), + /// Target::new(TargetKind::LogDir { file_name: Some("rust".into()) }).filter(|metadata| !metadata.target().starts_with(WEBVIEW_TARGET)), /// ]); /// ``` pub fn targets(mut self, targets: impl IntoIterator) -> Self { @@ -383,9 +417,7 @@ impl Builder { #[cfg(feature = "colored")] pub fn with_colors(self, colors: fern::colors::ColoredLevelConfig) -> Self { - let format = - time::format_description::parse("[[[year]-[month]-[day]][[[hour]:[minute]:[second]]") - .unwrap(); + let format = format_description!("[[[year]-[month]-[day]][[[hour]:[minute]:[second]]"); let timezone_strategy = self.timezone_strategy.clone(); self.format(move |out, message, record| { @@ -399,112 +431,163 @@ impl Builder { }) } - pub fn build(mut self) -> TauriPlugin { - plugin::Builder::new("log") - .js_init_script(include_str!("api-iife.js").to_string()) - .invoke_handler(tauri::generate_handler![log]) - .setup(move |app_handle, _api| { - let app_name = &app_handle.package_info().name; + fn acquire_logger( + app_handle: &AppHandle, + mut dispatch: fern::Dispatch, + rotation_strategy: RotationStrategy, + timezone_strategy: TimezoneStrategy, + max_file_size: u128, + targets: Vec, + ) -> Result<(log::LevelFilter, Box), Error> { + let app_name = &app_handle.package_info().name; + + // setup targets + for target in targets { + let mut target_dispatch = fern::Dispatch::new(); + for filter in target.filters { + target_dispatch = target_dispatch.filter(filter); + } - // setup targets - for target in self.targets { - let mut target_dispatch = fern::Dispatch::new(); - for filter in target.filters { - target_dispatch = target_dispatch.filter(filter); + let logger = match target.kind { + #[cfg(target_os = "android")] + TargetKind::Stdout | TargetKind::Stderr => fern::Output::call(android_logger::log), + #[cfg(target_os = "ios")] + TargetKind::Stdout | TargetKind::Stderr => fern::Output::call(move |record| { + let message = format!("{}", record.args()); + unsafe { + ios::tauri_log( + match record.level() { + log::Level::Trace | log::Level::Debug => 1, + log::Level::Info => 2, + log::Level::Warn | log::Level::Error => 3, + }, + // The string is allocated in rust, so we must + // autorelease it rust to give it to the Swift + // runtime. + objc2::rc::Retained::autorelease_ptr( + objc2_foundation::NSString::from_str(message.as_str()), + ) as _, + ); + } + }), + #[cfg(desktop)] + TargetKind::Stdout => std::io::stdout().into(), + #[cfg(desktop)] + TargetKind::Stderr => std::io::stderr().into(), + TargetKind::Folder { path, file_name } => { + if !path.exists() { + fs::create_dir_all(&path)?; } - let logger = match target.kind { - #[cfg(target_os = "android")] - TargetKind::Stdout | TargetKind::Stderr => { - fern::Output::call(android_logger::log) - } - #[cfg(target_os = "ios")] - TargetKind::Stdout | TargetKind::Stderr => { - fern::Output::call(move |record| { - let message = format!("{}", record.args()); - unsafe { - ios::tauri_log( - match record.level() { - log::Level::Trace | log::Level::Debug => 1, - log::Level::Info => 2, - log::Level::Warn | log::Level::Error => 3, - }, - ios::NSString::new(message.as_str()).0 as _, - ); - } - }) - } - #[cfg(desktop)] - TargetKind::Stdout => std::io::stdout().into(), - #[cfg(desktop)] - TargetKind::Stderr => std::io::stderr().into(), - TargetKind::Folder { path, file_name } => { - if !path.exists() { - fs::create_dir_all(&path).unwrap(); - } + fern::log_file(get_log_file_path( + &path, + file_name.as_deref().unwrap_or(app_name), + &rotation_strategy, + &timezone_strategy, + max_file_size, + )?)? + .into() + } + TargetKind::LogDir { file_name } => { + let path = app_handle.path().app_log_dir()?; + if !path.exists() { + fs::create_dir_all(&path)?; + } - fern::log_file(get_log_file_path( - &path, - file_name.as_deref().unwrap_or(app_name), - &self.rotation_strategy, - &self.timezone_strategy, - self.max_file_size, - )?)? - .into() - } - #[cfg(mobile)] - TargetKind::LogDir { .. } => continue, - #[cfg(desktop)] - TargetKind::LogDir { file_name } => { - let path = app_handle.path().app_log_dir().unwrap(); - if !path.exists() { - fs::create_dir_all(&path).unwrap(); - } + fern::log_file(get_log_file_path( + &path, + file_name.as_deref().unwrap_or(app_name), + &rotation_strategy, + &timezone_strategy, + max_file_size, + )?)? + .into() + } + TargetKind::Webview => { + let app_handle = app_handle.clone(); + + fern::Output::call(move |record| { + let payload = RecordPayload { + message: record.args().to_string(), + level: record.level().into(), + }; + let app_handle = app_handle.clone(); + tauri::async_runtime::spawn(async move { + let _ = app_handle.emit("log://log", payload); + }); + }) + } + TargetKind::Dispatch(dispatch) => dispatch.into(), + }; + target_dispatch = target_dispatch.chain(logger); - fern::log_file(get_log_file_path( - &path, - file_name.as_deref().unwrap_or(app_name), - &self.rotation_strategy, - &self.timezone_strategy, - self.max_file_size, - )?)? - .into() - } - TargetKind::Webview => { - let app_handle = app_handle.clone(); - - fern::Output::call(move |record| { - let payload = RecordPayload { - message: record.args().to_string(), - level: record.level().into(), - }; - let app_handle = app_handle.clone(); - tauri::async_runtime::spawn(async move { - app_handle.emit_all("log://log", payload).unwrap(); - }); - }) - } - }; - target_dispatch = target_dispatch.chain(logger); + dispatch = dispatch.chain(target_dispatch); + } - self.dispatch = self.dispatch.chain(target_dispatch); - } + Ok(dispatch.into_log()) + } - self.dispatch.apply()?; + fn plugin_builder() -> plugin::Builder { + plugin::Builder::new("log").invoke_handler(tauri::generate_handler![log]) + } + #[allow(clippy::type_complexity)] + pub fn split( + self, + app_handle: &AppHandle, + ) -> Result<(TauriPlugin, log::LevelFilter, Box), Error> { + if self.is_skip_logger { + return Err(Error::LoggerNotInitialized); + } + let plugin = Self::plugin_builder(); + let (max_level, log) = Self::acquire_logger( + app_handle, + self.dispatch, + self.rotation_strategy, + self.timezone_strategy, + self.max_file_size, + self.targets, + )?; + + Ok((plugin.build(), max_level, log)) + } + + pub fn build(self) -> TauriPlugin { + Self::plugin_builder() + .setup(move |app_handle, _api| { + if !self.is_skip_logger { + let (max_level, log) = Self::acquire_logger( + app_handle, + self.dispatch, + self.rotation_strategy, + self.timezone_strategy, + self.max_file_size, + self.targets, + )?; + attach_logger(max_level, log)?; + } Ok(()) }) .build() } } +/// Attaches the given logger +pub fn attach_logger( + max_level: log::LevelFilter, + log: Box, +) -> Result<(), log::SetLoggerError> { + log::set_boxed_logger(log)?; + log::set_max_level(max_level); + Ok(()) +} fn rename_file_to_dated( path: &impl AsRef, dir: &impl AsRef, file_name: &str, timezone_strategy: &TimezoneStrategy, -) -> Result<(), Box> { +) -> Result<(), Error> { let to = dir.as_ref().join(format!( "{}_{}.log", file_name, @@ -533,7 +616,7 @@ fn get_log_file_path( rotation_strategy: &RotationStrategy, timezone_strategy: &TimezoneStrategy, max_file_size: u128, -) -> Result> { +) -> Result { let path = dir.as_ref().join(format!("{file_name}.log")); if path.exists() { @@ -549,9 +632,11 @@ fn get_log_file_path( let entry = entry.ok()?; let path = entry.path(); let old_file_name = path.file_name()?.to_string_lossy().into_owned(); - if old_file_name.starts_with(&file_name) { - let date = - old_file_name.strip_prefix(&file_name)?.strip_prefix("_")?.strip_suffix(".log")?; + if old_file_name.starts_with(file_name) { + let date = old_file_name + .strip_prefix(file_name)? + .strip_prefix("_")? + .strip_suffix(".log")?; Some((path, date.to_string())) } else { None diff --git a/plugins/mirrors.txt b/plugins/mirrors.txt index 73f0816e..d346da18 100644 --- a/plugins/mirrors.txt +++ b/plugins/mirrors.txt @@ -1,4 +1,3 @@ -authenticator autostart cli clipboard-manager diff --git a/plugins/nfc/CHANGELOG.md b/plugins/nfc/CHANGELOG.md new file mode 100644 index 00000000..132ae5cc --- /dev/null +++ b/plugins/nfc/CHANGELOG.md @@ -0,0 +1,83 @@ +# Changelog + +## \[2.2.0] + +- [`3a79266b`](https://github.com/tauri-apps/plugins-workspace/commit/3a79266b8cf96a55b1ae6339d725567d45a44b1d) ([#2173](https://github.com/tauri-apps/plugins-workspace/pull/2173) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Bumped all plugins to `v2.2.0`. From now, the versions for the Rust and JavaScript packages of each plugin will be in sync with each other. + +## \[2.0.1] + +- [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. + +## \[2.0.0] + +- [`e2c4dfb6`](https://github.com/tauri-apps/plugins-workspace/commit/e2c4dfb6af43e5dd8d9ceba232c315f5febd55c1) Update to tauri v2 stable release. + +## \[2.0.0-rc.1] + +- [`e2e97db5`](https://github.com/tauri-apps/plugins-workspace/commit/e2e97db51983267f5be84d4f6f0278d58834d1f5) ([#1701](https://github.com/tauri-apps/plugins-workspace/pull/1701) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri 2.0.0-rc.8 + +## \[2.0.0-rc.2] + +- [`b9147758`](https://github.com/tauri-apps/plugins-workspace/commit/b914775898c2bee7ceb20bd17ee595005cd17a64) ([#1679](https://github.com/tauri-apps/plugins-workspace/pull/1679) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Explicitly set a minimum macOS version for the Swift package. + +## \[2.0.0-rc.1] + +### changes + +- [`6b079cfd`](https://github.com/tauri-apps/plugins-workspace/commit/6b079cfdd107c94abc2c7300f6af00bac3ff4040) ([#1649](https://github.com/tauri-apps/plugins-workspace/pull/1649) by [@ahqsoftwares](https://github.com/tauri-apps/plugins-workspace/../../ahqsoftwares)) Remove targetSdk from build.kts files as it is deprecated and will be removed from DSL v9.0 + +## \[2.0.0-rc.0] + +- [`9887d1`](https://github.com/tauri-apps/plugins-workspace/commit/9887d14bd0e971c4c0f5c1188fc4005d3fc2e29e) Update to tauri RC. + +## \[2.0.0-beta.8] + +- [`99d6ac0f`](https://github.com/tauri-apps/plugins-workspace/commit/99d6ac0f9506a6a4a1aa59c728157190a7441af6) ([#1606](https://github.com/tauri-apps/plugins-workspace/pull/1606) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) The JS packages now specify the *minimum* `@tauri-apps/api` version instead of a single exact version. +- [`6de87966`](https://github.com/tauri-apps/plugins-workspace/commit/6de87966ecc00ad9d91c25be452f1f46bd2b7e1f) ([#1597](https://github.com/tauri-apps/plugins-workspace/pull/1597) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Update to tauri beta.25. + +## \[2.0.0-beta.7] + +- [`22a17980`](https://github.com/tauri-apps/plugins-workspace/commit/22a17980ff4f6f8c40adb1b8f4ffc6dae2fe7e30) ([#1537](https://github.com/tauri-apps/plugins-workspace/pull/1537) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri beta.24. + +## \[2.0.0-beta.6] + +- [`76daee7a`](https://github.com/tauri-apps/plugins-workspace/commit/76daee7aafece34de3092c86e531cf9eb1138989) ([#1512](https://github.com/tauri-apps/plugins-workspace/pull/1512) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Update to tauri beta.23. + +## \[2.0.0-beta.5] + +- [`9013854f`](https://github.com/tauri-apps/plugins-workspace/commit/9013854f42a49a230b9dbb9d02774765528a923f)([#1382](https://github.com/tauri-apps/plugins-workspace/pull/1382)) Update to tauri beta.22. + +## \[2.0.0-beta.4] + +- [`430bd6f4`](https://github.com/tauri-apps/plugins-workspace/commit/430bd6f4f379bee5d232ae6b098ae131db7f178a)([#1363](https://github.com/tauri-apps/plugins-workspace/pull/1363)) Update to tauri beta.20. + +## \[2.0.0-beta.3] + +- [`bd1ed590`](https://github.com/tauri-apps/plugins-workspace/commit/bd1ed5903ffcce5500310dac1e59e8c67674ef1e)([#1237](https://github.com/tauri-apps/plugins-workspace/pull/1237)) Update to tauri beta.17. + +## \[2.0.0-beta.3] + +- [`a04ea2f`](https://github.com/tauri-apps/plugins-workspace/commit/a04ea2f38294d5a3987578283badc8eec87a7752)([#1071](https://github.com/tauri-apps/plugins-workspace/pull/1071)) The global API script is now only added to the binary when the `withGlobalTauri` config is true. + +## \[2.0.0-beta.2] + +- [`99bea25`](https://github.com/tauri-apps/plugins-workspace/commit/99bea2559c2c0648c2519c50a18cd124dacef57b)([#1005](https://github.com/tauri-apps/plugins-workspace/pull/1005)) Update to tauri beta.8. + +## \[2.0.0-beta.1] + +- [`569defb`](https://github.com/tauri-apps/plugins-workspace/commit/569defbe9492e38938554bb7bdc1be9151456d21) Update to tauri beta.4. + +## \[2.0.0-beta.0] + +- [`d198c01`](https://github.com/tauri-apps/plugins-workspace/commit/d198c014863ee260cb0de88a14b7fc4356ef7474)([#862](https://github.com/tauri-apps/plugins-workspace/pull/862)) Update to tauri beta. +- [`d198c01`](https://github.com/tauri-apps/plugins-workspace/commit/d198c014863ee260cb0de88a14b7fc4356ef7474)([#862](https://github.com/tauri-apps/plugins-workspace/pull/862)) Add permissions. + +## \[2.0.0-alpha.0] + +- [`fe79adb`](https://github.com/tauri-apps/plugins-workspace/commit/fe79adb5c7febd0e912efb5581264d671709fbb0)([#830](https://github.com/tauri-apps/plugins-workspace/pull/830)) Initial release. + commit/fe79adb5c7febd0e912efb5581264d671709fbb0)([#830](https://github.com/tauri-apps/plugins-workspace/pull/830)) Initial release. + 30]\(https://github.com/tauri-apps/plugins-workspace/pull/830)) Initial release. + commit/fe79adb5c7febd0e912efb5581264d671709fbb0)([#830](https://github.com/tauri-apps/plugins-workspace/pull/830)) Initial release. + . + commit/fe79adb5c7febd0e912efb5581264d671709fbb0)([#830](https://github.com/tauri-apps/plugins-workspace/pull/830)) Initial release. + ithub.com/tauri-apps/plugins-workspace/pull/830)) Initial release. diff --git a/plugins/nfc/Cargo.toml b/plugins/nfc/Cargo.toml new file mode 100644 index 00000000..56cc218b --- /dev/null +++ b/plugins/nfc/Cargo.toml @@ -0,0 +1,32 @@ +[package] +name = "tauri-plugin-nfc" +version = "2.2.0" +description = "Read and write NFC tags on Android and iOS." +edition = { workspace = true } +authors = { workspace = true } +license = { workspace = true } +repository = { workspace = true } +links = "tauri-plugin-nfc" + +[package.metadata.docs.rs] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] +targets = ["x86_64-linux-android"] + +[package.metadata.platforms.support] +windows = { level = "none", notes = "" } +linux = { level = "none", notes = "" } +macos = { level = "none", notes = "" } +android = { level = "full", notes = "" } +ios = { level = "full", notes = "" } + +[build-dependencies] +tauri-plugin = { workspace = true, features = ["build"] } + +[dependencies] +serde = { workspace = true } +serde_json = { workspace = true } +tauri = { workspace = true } +log = { workspace = true } +thiserror = { workspace = true } +serde_repr = "0.1" diff --git a/plugins/nfc/LICENSE.spdx b/plugins/nfc/LICENSE.spdx new file mode 100644 index 00000000..cdd0df5a --- /dev/null +++ b/plugins/nfc/LICENSE.spdx @@ -0,0 +1,20 @@ +SPDXVersion: SPDX-2.1 +DataLicense: CC0-1.0 +PackageName: tauri +DataFormat: SPDXRef-1 +PackageSupplier: Organization: The Tauri Programme in the Commons Conservancy +PackageHomePage: https://tauri.app +PackageLicenseDeclared: Apache-2.0 +PackageLicenseDeclared: MIT +PackageCopyrightText: 2019-2022, The Tauri Programme in the Commons Conservancy +PackageSummary: Tauri is a rust project that enables developers to make secure +and small desktop applications using a web frontend. + +PackageComment: The package includes the following libraries; see +Relationship information. + +Created: 2019-05-20T09:00:00Z +PackageDownloadLocation: git://github.com/tauri-apps/tauri +PackageDownloadLocation: git+https://github.com/tauri-apps/tauri.git +PackageDownloadLocation: git+ssh://github.com/tauri-apps/tauri.git +Creator: Person: Daniel Thompson-Yvetot \ No newline at end of file diff --git a/plugins/nfc/LICENSE_APACHE-2.0 b/plugins/nfc/LICENSE_APACHE-2.0 new file mode 100644 index 00000000..4947287f --- /dev/null +++ b/plugins/nfc/LICENSE_APACHE-2.0 @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/plugins/nfc/LICENSE_MIT b/plugins/nfc/LICENSE_MIT new file mode 100644 index 00000000..4d754725 --- /dev/null +++ b/plugins/nfc/LICENSE_MIT @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 - Present Tauri Apps Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/plugins/nfc/README.md b/plugins/nfc/README.md new file mode 100644 index 00000000..1f8ceb6b --- /dev/null +++ b/plugins/nfc/README.md @@ -0,0 +1,121 @@ +![NFC](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/nfc/banner.png) + +Read and write NFC tags on Android and iOS. + +| Platform | Supported | +| -------- | --------- | +| Linux | x | +| Windows | x | +| macOS | x | +| Android | ✓ | +| iOS | ✓ | + +## Install + +_This plugin requires a Rust version of at least **1.65**_ + +There are three general methods of installation that we can recommend. + +1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked) +2. Pull sources directly from Github using git tags / revision hashes (most secure) +3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use) + +Install the Core plugin by adding the following to your `Cargo.toml` file: + +`src-tauri/Cargo.toml` + +```toml +[dependencies] +tauri-plugin-nfc = "2.0.0" +# alternatively with Git: +tauri-plugin-nfc = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } +``` + +You can install the JavaScript Guest bindings using your preferred JavaScript package manager: + +> Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use. + + + +```sh +pnpm add @tauri-apps/plugin-nfc +# or +npm add @tauri-apps/plugin-nfc +# or +yarn add @tauri-apps/plugin-nfc + +# alternatively with Git: +pnpm add https://github.com/tauri-apps/tauri-plugin-nfc#v2 +# or +npm add https://github.com/tauri-apps/tauri-plugin-nfc#v2 +# or +yarn add https://github.com/tauri-apps/tauri-plugin-nfc#v2 +``` + +## Usage + +First you need to register the core plugin with Tauri: + +`src-tauri/src/lib.rs` + +```rust +fn main() { + tauri::Builder::default() + .plugin(tauri_plugin_nfc::init()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} +``` + +Afterwards all the plugin's APIs are available through the JavaScript guest bindings: + +```javascript +import { scan, textRecord, write } from '@tauri-apps/plugin-nfc' +await scan({ type: 'tag', keepSessionAlive: true }) +await write([textRecord('Tauri is awesome!')]) +``` + +## Contributing + +PRs accepted. Please make sure to read the Contributing Guide before making a pull request. + +## Contributed By + + + + + + + + +
+ + CrabNebula + + + + Impierce + +
+ +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + +## License + +Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. + +MIT or MIT/Apache 2.0 where applicable. diff --git a/plugins/nfc/SECURITY.md b/plugins/nfc/SECURITY.md new file mode 100644 index 00000000..4f09bbac --- /dev/null +++ b/plugins/nfc/SECURITY.md @@ -0,0 +1,23 @@ +# Security Policy + +**Do not report security vulnerabilities through public GitHub issues.** + +**Please use the [Private Vulnerability Disclosure](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) feature of GitHub.** + +Include as much of the following information: + +- Type of issue (e.g. improper input parsing, privilege escalation, etc.) +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- The distribution affected or used to help us with reproduction of the issue +- Step-by-step instructions to reproduce the issue +- Ideally a reproduction repository +- Impact of the issue, including how an attacker might exploit the issue + +We prefer to receive reports in English. + +## Contact + +Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). + +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/nfc/android/.gitignore b/plugins/nfc/android/.gitignore new file mode 100644 index 00000000..c0f21ec2 --- /dev/null +++ b/plugins/nfc/android/.gitignore @@ -0,0 +1,2 @@ +/build +/.tauri diff --git a/plugins/nfc/android/build.gradle.kts b/plugins/nfc/android/build.gradle.kts new file mode 100644 index 00000000..595f9173 --- /dev/null +++ b/plugins/nfc/android/build.gradle.kts @@ -0,0 +1,45 @@ +plugins { + id("com.android.library") + id("org.jetbrains.kotlin.android") +} + +android { + namespace = "app.tauri.nfc" + compileSdk = 34 + + defaultConfig { + minSdk = 24 + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles("consumer-rules.pro") + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = "1.8" + } +} + +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") + implementation(project(":tauri-android")) +} diff --git a/plugins/nfc/android/proguard-rules.pro b/plugins/nfc/android/proguard-rules.pro new file mode 100644 index 00000000..481bb434 --- /dev/null +++ b/plugins/nfc/android/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/plugins/nfc/android/settings.gradle b/plugins/nfc/android/settings.gradle new file mode 100644 index 00000000..14a752e4 --- /dev/null +++ b/plugins/nfc/android/settings.gradle @@ -0,0 +1,2 @@ +include ':tauri-android' +project(':tauri-android').projectDir = new File('./.tauri/tauri-api') diff --git a/plugins/nfc/android/src/androidTest/java/ExampleInstrumentedTest.kt b/plugins/nfc/android/src/androidTest/java/ExampleInstrumentedTest.kt new file mode 100644 index 00000000..f0f7b66e --- /dev/null +++ b/plugins/nfc/android/src/androidTest/java/ExampleInstrumentedTest.kt @@ -0,0 +1,28 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +package app.tauri.nfc + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("app.tauri.nfc", appContext.packageName) + } +} diff --git a/plugins/nfc/android/src/main/AndroidManifest.xml b/plugins/nfc/android/src/main/AndroidManifest.xml new file mode 100644 index 00000000..7603a356 --- /dev/null +++ b/plugins/nfc/android/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + diff --git a/plugins/nfc/android/src/main/java/NfcPlugin.kt b/plugins/nfc/android/src/main/java/NfcPlugin.kt new file mode 100644 index 00000000..4deaab44 --- /dev/null +++ b/plugins/nfc/android/src/main/java/NfcPlugin.kt @@ -0,0 +1,519 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +package app.tauri.nfc + +import android.app.Activity +import android.app.PendingIntent +import android.content.Intent +import android.content.IntentFilter +import android.nfc.NdefMessage +import android.nfc.NdefRecord +import android.nfc.NfcAdapter +import android.nfc.Tag +import android.nfc.tech.Ndef +import android.nfc.tech.NdefFormatable +import android.os.Build +import android.os.Parcelable +import android.os.PatternMatcher +import android.webkit.WebView +import app.tauri.Logger +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 com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.core.JsonParser +import com.fasterxml.jackson.databind.DeserializationContext +import com.fasterxml.jackson.databind.JsonDeserializer +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import org.json.JSONArray +import java.io.IOException +import kotlin.concurrent.thread + +sealed class NfcAction { + object Read : NfcAction() + data class Write(val message: NdefMessage) : NfcAction() +} + +@InvokeArg +class UriFilter { + var scheme: String? = null + var host: String? = null + var pathPrefix: String? = null +} + +@InvokeArg +enum class TechKind(@JsonValue val value: String) { + IsoDep("IsoDep"), + MifareClassic("MifareClassic"), + MifareUltralight("MifareUltralight"), + Ndef("Ndef"), + NdefFormatable("NdefFormatable"), + NfcA("NfcA"), + NfcB("NfcB"), + NfcBarcode("NfcBarcode"), + NfcF("NfcF"), + NfcV("NfcV"); + + fun className(): String { + return when (this) { + IsoDep -> { + android.nfc.tech.IsoDep::class.java.name + } + MifareClassic -> { + android.nfc.tech.MifareClassic::class.java.name + } + MifareUltralight -> { + android.nfc.tech.MifareUltralight::class.java.name + } + Ndef -> { + android.nfc.tech.Ndef::class.java.name + } + NdefFormatable -> { + android.nfc.tech.NdefFormatable::class.java.name + } + NfcA -> { + android.nfc.tech.NfcA::class.java.name + } + NfcB -> { + android.nfc.tech.NfcB::class.java.name + } + NfcBarcode -> { + android.nfc.tech.NfcBarcode::class.java.name + } + NfcF -> { + android.nfc.tech.NfcF::class.java.name + } + NfcV -> { + android.nfc.tech.NfcV::class.java.name + } + } + } +} + +private fun addDataFilters(intentFilter: IntentFilter, uri: UriFilter?, mimeType: String?) { + uri?.let { it -> { + it.scheme?.let { + intentFilter.addDataScheme(it) + } + it.host?.let { + intentFilter.addDataAuthority(it, null) + } + it.pathPrefix?.let { + intentFilter.addDataPath(it, PatternMatcher.PATTERN_PREFIX) + } + }} + mimeType?.let { + intentFilter.addDataType(it) + } +} + +@InvokeArg +@JsonDeserialize(using = ScanKindDeserializer::class) +sealed class ScanKind { + @JsonDeserialize + class Tag: ScanKind() { + var mimeType: String? = null + var uri: UriFilter? = null + } + @JsonDeserialize + class Ndef: ScanKind() { + var mimeType: String? = null + var uri: UriFilter? = null + var techLists: Array>? = null + } + + fun filters(): Array? { + return when (this) { + is Tag -> { + val intentFilter = IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED) + addDataFilters(intentFilter, uri, mimeType) + arrayOf(intentFilter) + } + is Ndef -> { + val intentFilter = IntentFilter(if (techLists == null) NfcAdapter.ACTION_NDEF_DISCOVERED else NfcAdapter.ACTION_TECH_DISCOVERED) + addDataFilters(intentFilter, uri, mimeType) + arrayOf(intentFilter) + } + } + } + + fun techLists(): Array>? { + return when (this) { + is Tag -> null + is Ndef -> { + techLists?.let { + val techs = mutableListOf>() + for (techList in it) { + val list = mutableListOf() + for (tech in techList) { + list.add(tech.className()) + } + techs.add(list.toTypedArray()) + } + techs.toTypedArray() + } ?: run { + null + } + } + } + } +} + +internal class ScanKindDeserializer: JsonDeserializer() { + override fun deserialize( + jsonParser: JsonParser, + deserializationContext: DeserializationContext + ): ScanKind { + val node: JsonNode = jsonParser.codec.readTree(jsonParser) + node.get("tag")?.let { + return jsonParser.codec.treeToValue(it, ScanKind.Tag::class.java) + } ?: node.get("ndef")?.let { + return jsonParser.codec.treeToValue(it, ScanKind.Ndef::class.java) + } ?: run { + throw Error("unknown scan kind $node") + } + } +} + +@InvokeArg +class ScanOptions { + lateinit var kind: ScanKind + var keepSessionAlive: Boolean = false +} + +@InvokeArg +class NDEFRecordData { + var format: Short = 0 + var kind: ByteArray = ByteArray(0) + var id: ByteArray = ByteArray(0) + var payload: ByteArray = ByteArray(0) +} + +@InvokeArg +class WriteOptions { + var kind: ScanKind? = null + lateinit var records: Array +} + +class Session( + val action: NfcAction, + val invoke: Invoke, + val keepAlive: Boolean, + var tag: Tag? = null, + val filters: Array? = null, + val techLists: Array>? = null +) + +@TauriPlugin +class NfcPlugin(private val activity: Activity) : Plugin(activity) { + private lateinit var webView: WebView + + private var nfcAdapter: NfcAdapter? = null + private var session: Session? = null + + override fun load(webView: WebView) { + super.load(webView) + this.webView = webView + this.nfcAdapter = NfcAdapter.getDefaultAdapter(activity.applicationContext) + } + + override fun onNewIntent(intent: Intent) { + Logger.info("NFC", "onNewIntent") + super.onNewIntent(intent) + + val extraTag = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + intent.getParcelableExtra(NfcAdapter.EXTRA_TAG, Tag::class.java) + } else { + @Suppress("DEPRECATION") + intent.getParcelableExtra(NfcAdapter.EXTRA_TAG) + } + + extraTag?.let { tag -> + session?.let { + if (it.keepAlive) { + it.tag = tag + } + } + + when (session?.action) { + is NfcAction.Read -> readTag(tag, intent) + is NfcAction.Write -> thread { + if (session?.action is NfcAction.Write) { + try { + writeTag(tag, (session?.action as NfcAction.Write).message) + session?.invoke?.resolve() + } catch (e: Exception) { + session?.invoke?.reject(e.toString()) + } finally { + if (this.session?.keepAlive != true) { + this.session = null + disableNFCInForeground() + } + } + } + } + + else -> {} + } + } + + } + + override fun onPause() { + disableNFCInForeground() + super.onPause() + Logger.info("NFC", "onPause") + } + + override fun onResume() { + super.onResume() + Logger.info("NFC", "onResume") + session?.let { + enableNFCInForeground(it.filters, it.techLists) + } + } + + private fun isAvailable(): Pair { + val available: Boolean + var errorReason: String? = null + + if (this.nfcAdapter === null) { + available = false + errorReason = "Device does not have NFC capabilities" + } else if (this.nfcAdapter?.isEnabled == false) { + available = false + errorReason = "NFC is disabled in device settings" + } else { + available = true + } + + return Pair(available, errorReason) + } + + @Command + fun isAvailable(invoke: Invoke) { + val ret = JSObject() + ret.put("available", isAvailable().first) + invoke.resolve(ret) + } + + @Command + fun scan(invoke: Invoke) { + val status = isAvailable() + if (!status.first) { + invoke.reject("NFC unavailable: " + status.second) + return + } + + val args = invoke.parseArgs(ScanOptions::class.java) + + val filters = args.kind.filters() + val techLists = args.kind.techLists() + enableNFCInForeground(filters, techLists) + + session = Session(NfcAction.Read, invoke, args.keepSessionAlive, null, filters, techLists) + } + + @Command + fun write(invoke: Invoke) { + val status = isAvailable() + if (!status.first) { + invoke.reject("NFC unavailable: " + status.second) + return + } + + val args = invoke.parseArgs(WriteOptions::class.java) + + val ndefRecords: MutableList = ArrayList() + for (record in args.records) { + ndefRecords.add(NdefRecord(record.format, record.kind, record.id, record.payload)) + } + + val message = NdefMessage(ndefRecords.toTypedArray()) + + session?.let { session -> + session.tag?.let { + try { + writeTag(it, message) + invoke.resolve() + } catch (e: Exception) { + invoke.reject(e.toString()) + } finally { + if (this.session?.keepAlive != true) { + this.session = null + disableNFCInForeground() + } + } + } ?: run { + invoke.reject("connected tag not found, please wait for it to be available and then call write()") + } + } ?: run { + args.kind?.let { kind -> { + val filters = kind.filters() + val techLists = kind.techLists() + enableNFCInForeground(filters, techLists) + session = Session(NfcAction.Write(message), invoke, true, null, filters, techLists) + Logger.warn("NFC", "Write Mode Enabled") + }} ?: run { + invoke.reject("Missing `kind` for write") + } + + } + } + + private fun readTag(tag: Tag, intent: Intent) { + try { + val rawMessages = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES, Parcelable::class.java) + } else { + @Suppress("DEPRECATION") + intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES) + } + + when (intent.action) { + NfcAdapter.ACTION_NDEF_DISCOVERED -> { + // For some reason this one never triggers. + Logger.info("NFC", "new NDEF intent") + readTagInner(tag, rawMessages) + } + NfcAdapter.ACTION_TECH_DISCOVERED -> { + // For some reason this always triggers instead of NDEF_DISCOVERED even though we set ndef filters right now + Logger.info("NFC", "new TECH intent") + // TODO: handle different techs. Don't assume ndef. + readTagInner(tag, rawMessages) + } + NfcAdapter.ACTION_TAG_DISCOVERED -> { + // This should never trigger when an app handles NDEF and TECH + // TODO: Don't assume ndef. + readTagInner(tag, rawMessages) + } + } + } catch (e: Exception) { + session?.invoke?.reject("failed to read tag", e) + } finally { + if (this.session?.keepAlive != true) { + this.session = null + } + // TODO this crashes? disableNFCInForeground() + } + } + + private fun readTagInner(tag: Tag?, rawMessages: Array?) { + val ndefMessage = rawMessages?.get(0) as NdefMessage? + + val records = ndefMessage?.records ?: arrayOf() + + val jsonRecords = Array(records.size) { i -> recordToJson(records[i]) } + + val ret = JSObject() + if (tag !== null) { + ret.put("id", fromU8Array(tag.id)) + // TODO There's also ndef.type which returns the ndef spec type which may be interesting to know too? + ret.put("kind", JSArray.from(tag.techList)) + } + ret.put("records", JSArray.from(jsonRecords)) + + session?.invoke?.resolve(ret) + } + + private fun writeTag(tag: Tag, message: NdefMessage) { + // This should return tags that are already in ndef format + val ndefTag = Ndef.get(tag) + if (ndefTag !== null) { + // We have to connect first to check maxSize. + try { + ndefTag.connect() + } catch (e: IOException) { + throw Exception("Couldn't connect to NFC tag", e) + } + + if (ndefTag.maxSize < message.toByteArray().size) { + throw Exception("The message is too large for the provided NFC tag") + } else if (!ndefTag.isWritable) { + throw Exception("NFC tag is read-only") + } else { + try { + ndefTag.writeNdefMessage(message) + } catch (e: Exception) { + throw Exception("Couldn't write message to NFC tag", e) + } + } + + try { + ndefTag.close() + } catch (e: IOException) { + Logger.error("failed to close tag", e) + } + + return + } + + // This should cover tags that are not yet in ndef format but can be converted + val ndefFormatableTag = NdefFormatable.get(tag) + if (ndefFormatableTag !== null) { + try { + ndefFormatableTag.connect() + ndefFormatableTag.format(message) + } catch (e: Exception) { + throw Exception("Couldn't format tag as Ndef", e) + } + + try { + ndefFormatableTag.close() + } catch (e: IOException) { + Logger.error("failed to close tag", e) + } + + return + } + + // if we get to this line, the tag was neither Ndef nor NdefFormatable compatible + throw Exception("Tag doesn't support Ndef format") + } + + // TODO: Use ReaderMode instead of ForegroundDispatch + private fun enableNFCInForeground(filters: Array?, techLists: Array>?) { + val flag = + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE else PendingIntent.FLAG_UPDATE_CURRENT + val pendingIntent = PendingIntent.getActivity( + activity, 0, + Intent( + activity, + activity.javaClass + ).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), + flag + ) + + nfcAdapter?.enableForegroundDispatch(activity, pendingIntent, filters, techLists) + } + + private fun disableNFCInForeground() { + activity.runOnUiThread { + nfcAdapter?.disableForegroundDispatch(activity) + } + } +} + +private fun fromU8Array(byteArray: ByteArray): JSONArray { + val json = JSONArray() + for (byte in byteArray) { + json.put(byte) + } + return json +} + +private fun recordToJson(record: NdefRecord): JSObject { + val json = JSObject() + json.put("tnf", record.tnf) + json.put("kind", fromU8Array(record.type)) + json.put("id", fromU8Array(record.id)) + json.put("payload", fromU8Array(record.payload)) + return json +} \ No newline at end of file diff --git a/plugins/nfc/android/src/main/res/xml/nfc_tech_filter.xml b/plugins/nfc/android/src/main/res/xml/nfc_tech_filter.xml new file mode 100644 index 00000000..994905a6 --- /dev/null +++ b/plugins/nfc/android/src/main/res/xml/nfc_tech_filter.xml @@ -0,0 +1,13 @@ + + + android.nfc.tech.IsoDep + android.nfc.tech.NfcA + android.nfc.tech.NfcB + android.nfc.tech.NfcF + android.nfc.tech.NfcV + android.nfc.tech.Ndef + android.nfc.tech.NdefFormatable + android.nfc.tech.MifareClassic + android.nfc.tech.MifareUltralight + + diff --git a/plugins/nfc/android/src/test/java/ExampleUnitTest.kt b/plugins/nfc/android/src/test/java/ExampleUnitTest.kt new file mode 100644 index 00000000..2af426f8 --- /dev/null +++ b/plugins/nfc/android/src/test/java/ExampleUnitTest.kt @@ -0,0 +1,21 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +package app.tauri.nfc + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} diff --git a/plugins/nfc/api-iife.js b/plugins/nfc/api-iife.js new file mode 100644 index 00000000..5939782f --- /dev/null +++ b/plugins/nfc/api-iife.js @@ -0,0 +1 @@ +if("__TAURI__"in window){var __TAURI_PLUGIN_NFC__=function(n){"use strict";async function e(n,e={},t){return window.__TAURI_INTERNALS__.invoke(n,e,t)}"function"==typeof SuppressedError&&SuppressedError;const t=[84],r=[85];var o,c;function a(n,e,t,r){return{format:n,kind:"string"==typeof e?Array.from((new TextEncoder).encode(e)):e,id:"string"==typeof t?Array.from((new TextEncoder).encode(t)):t,payload:"string"==typeof r?Array.from((new TextEncoder).encode(r)):r}}n.TechKind=void 0,(o=n.TechKind||(n.TechKind={}))[o.IsoDep=0]="IsoDep",o[o.MifareClassic=1]="MifareClassic",o[o.MifareUltralight=2]="MifareUltralight",o[o.Ndef=3]="Ndef",o[o.NdefFormatable=4]="NdefFormatable",o[o.NfcA=5]="NfcA",o[o.NfcB=6]="NfcB",o[o.NfcBarcode=7]="NfcBarcode",o[o.NfcF=8]="NfcF",o[o.NfcV=9]="NfcV",n.NFCTypeNameFormat=void 0,(c=n.NFCTypeNameFormat||(n.NFCTypeNameFormat={}))[c.Empty=0]="Empty",c[c.NfcWellKnown=1]="NfcWellKnown",c[c.Media=2]="Media",c[c.AbsoluteURI=3]="AbsoluteURI",c[c.NfcExternal=4]="NfcExternal",c[c.Unknown=5]="Unknown",c[c.Unchanged=6]="Unchanged";const i=["","http://www.","https://www.","http://","https://","tel:","mailto:","ftp://anonymous:anonymous@","ftp://ftp.","ftps://","sftp://","smb://","nfs://","ftp://","dav://","news:","telnet://","imap:","rtsp://","urn:","pop:","sip:","sips:","tftp:","btspp://","btl2cap://","btgoep://","tcpobex://","irdaobex://","file://","urn:epc:id:","urn:epc:tag:","urn:epc:pat:","urn:epc:raw:","urn:epc:","urn:nfc:"];function f(n){const{type:e,...t}=n;return{[e]:t}}return n.RTD_TEXT=t,n.RTD_URI=r,n.isAvailable=async function(){return await e("plugin:nfc|is_available")},n.record=a,n.scan=async function(n,t){return await e("plugin:nfc|scan",{kind:f(n),...t})},n.textRecord=function(e,r,o="en"){const c=Array.from((new TextEncoder).encode(o+e));return c.unshift(o.length),a(n.NFCTypeNameFormat.NfcWellKnown,t,r??[],c)},n.uriRecord=function(e,t){return a(n.NFCTypeNameFormat.NfcWellKnown,r,t??[],function(n){let e="";i.slice(1).forEach((function(t){0!==e.length&&"urn:"!==e||0!==n.indexOf(t)||(e=t)})),0===e.length&&(e="");const t=Array.from((new TextEncoder).encode(n.slice(e.length))),r=i.indexOf(e);return t.unshift(r),t}(e))},n.write=async function(n,t){const{kind:r,...o}=t??{};r&&(o.kind=f(r)),await e("plugin:nfc|write",{records:n,...o})},n}({});Object.defineProperty(window.__TAURI__,"nfc",{value:__TAURI_PLUGIN_NFC__})} diff --git a/plugins/nfc/build.rs b/plugins/nfc/build.rs new file mode 100644 index 00000000..bdcd84bf --- /dev/null +++ b/plugins/nfc/build.rs @@ -0,0 +1,45 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +const COMMANDS: &[&str] = &["is_available", "write", "scan"]; + +fn main() { + let result = tauri_plugin::Builder::new(COMMANDS) + .global_api_script_path("./api-iife.js") + .android_path("android") + .ios_path("ios") + .try_build(); + + // when building documentation for Android the plugin build result is always Err() and is irrelevant to the crate documentation build + if !(cfg!(docsrs) && std::env::var("TARGET").unwrap().contains("android")) { + result.unwrap(); + } + + // TODO: triple check if this can reference the plugin's xml as it expects rn + // TODO: This has to be configurable if we want to support handling nfc tags when the app is not open. + tauri_plugin::mobile::update_android_manifest( + "NFC PLUGIN", + "activity", + r#" + + + + + + + + + + + + + + +"# + .to_string(), + ) + .expect("failed to rewrite AndroidManifest.xml"); +} diff --git a/plugins/nfc/contributors/crabnebula.svg b/plugins/nfc/contributors/crabnebula.svg new file mode 100644 index 00000000..a9bb4609 --- /dev/null +++ b/plugins/nfc/contributors/crabnebula.svg @@ -0,0 +1,31 @@ + \ No newline at end of file diff --git a/plugins/nfc/contributors/impierce.svg b/plugins/nfc/contributors/impierce.svg new file mode 100644 index 00000000..9d2a510b --- /dev/null +++ b/plugins/nfc/contributors/impierce.svg @@ -0,0 +1,21 @@ + \ No newline at end of file diff --git a/plugins/nfc/guest-js/index.ts b/plugins/nfc/guest-js/index.ts new file mode 100644 index 00000000..051a1841 --- /dev/null +++ b/plugins/nfc/guest-js/index.ts @@ -0,0 +1,273 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import { invoke } from '@tauri-apps/api/core' + +export const RTD_TEXT = [0x54] // "T" +export const RTD_URI = [0x55] // "U" + +export interface UriFilter { + scheme?: string + host?: string + pathPrefix?: string +} + +export enum TechKind { + IsoDep, + MifareClassic, + MifareUltralight, + Ndef, + NdefFormatable, + NfcA, + NfcB, + NfcBarcode, + NfcF, + NfcV +} + +export type ScanKind = + | { + type: 'tag' + uri?: UriFilter + mimeType?: string + } + | { + type: 'ndef' + uri?: UriFilter + mimeType?: string + /** + * Each of the tech-lists is considered independently and the activity is considered a match if + * any single tech-list matches the tag that was discovered. + * This provides AND and OR semantics for filtering desired techs. + * + * See for more information. + * + * Examples + * + * ```ts + * import type { TechKind } from "@tauri-apps/plugin-nfc" + * + * const techLists = [ + * // capture anything using NfcF + * [TechKind.NfcF], + * // capture all MIFARE Classics with NDEF payloads + * [TechKind.NfcA, TechKind.MifareClassic, TechKind.Ndef] + * ] + * ``` + */ + techLists?: TechKind[][] + } + +export interface ScanOptions { + keepSessionAlive?: boolean + /** Message displayed in the UI. iOS only. */ + message?: string + /** Message displayed in the UI when the message has been read. iOS only. */ + successMessage?: string +} + +export interface WriteOptions { + kind?: ScanKind + /** Message displayed in the UI when reading the tag. iOS only. */ + message?: string + /** Message displayed in the UI when the tag has been read. iOS only. */ + successfulReadMessage?: string + /** Message displayed in the UI when the message has been written. iOS only. */ + successMessage?: string +} + +export enum NFCTypeNameFormat { + Empty = 0, + NfcWellKnown = 1, + Media = 2, + AbsoluteURI = 3, + NfcExternal = 4, + Unknown = 5, + Unchanged = 6 +} + +export interface TagRecord { + tnf: NFCTypeNameFormat + kind: number[] + id: number[] + payload: number[] +} + +export interface Tag { + id: number[] + kind: string[] + records: TagRecord[] +} + +export interface NFCRecord { + format: NFCTypeNameFormat + kind: number[] + id: number[] + payload: number[] +} + +export function record( + format: NFCTypeNameFormat, + kind: string | number[], + id: string | number[], + payload: string | number[] +): NFCRecord { + return { + format, + kind: + typeof kind === 'string' + ? Array.from(new TextEncoder().encode(kind)) + : kind, + id: typeof id === 'string' ? Array.from(new TextEncoder().encode(id)) : id, + payload: + typeof payload === 'string' + ? Array.from(new TextEncoder().encode(payload)) + : payload + } +} + +export function textRecord( + text: string, + id?: string | number[], + language: string = 'en' +): NFCRecord { + const payload = Array.from(new TextEncoder().encode(language + text)) + payload.unshift(language.length) + return record(NFCTypeNameFormat.NfcWellKnown, RTD_TEXT, id ?? [], payload) +} + +const protocols = [ + '', + 'http://www.', + 'https://www.', + 'http://', + 'https://', + 'tel:', + 'mailto:', + 'ftp://anonymous:anonymous@', + 'ftp://ftp.', + 'ftps://', + 'sftp://', + 'smb://', + 'nfs://', + 'ftp://', + 'dav://', + 'news:', + 'telnet://', + 'imap:', + 'rtsp://', + 'urn:', + 'pop:', + 'sip:', + 'sips:', + 'tftp:', + 'btspp://', + 'btl2cap://', + 'btgoep://', + 'tcpobex://', + 'irdaobex://', + 'file://', + 'urn:epc:id:', + 'urn:epc:tag:', + 'urn:epc:pat:', + 'urn:epc:raw:', + 'urn:epc:', + 'urn:nfc:' +] + +function encodeURI(uri: string): number[] { + let prefix = '' + + protocols.slice(1).forEach(function (protocol) { + if ( + (prefix.length === 0 || prefix === 'urn:') + && uri.indexOf(protocol) === 0 + ) { + prefix = protocol + } + }) + + if (prefix.length === 0) { + prefix = '' + } + + const encoded = Array.from(new TextEncoder().encode(uri.slice(prefix.length))) + const protocolCode = protocols.indexOf(prefix) + // prepend protocol code + encoded.unshift(protocolCode) + + return encoded +} + +export function uriRecord(uri: string, id?: string | number[]): NFCRecord { + return record( + NFCTypeNameFormat.NfcWellKnown, + RTD_URI, + id ?? [], + encodeURI(uri) + ) +} + +function mapScanKind(kind: ScanKind): Record { + const { type: scanKind, ...kindOptions } = kind + return { [scanKind]: kindOptions } +} + +/** + * Scans an NFC tag. + * + * ```javascript + * import { scan } from "@tauri-apps/plugin-nfc"; + * await scan({ type: "tag" }); + * ``` + * + * See for more information. + * + * @param kind + * @param options + * @returns + */ +export async function scan( + kind: ScanKind, + options?: ScanOptions +): Promise { + return await invoke('plugin:nfc|scan', { + kind: mapScanKind(kind), + ...options + }) +} + +/** + * Write to an NFC tag. + * + * ```javascript + * import { uriRecord, write } from "@tauri-apps/plugin-nfc"; + * await write([uriRecord("https://tauri.app")], { kind: { type: "ndef" } }); + * ``` + * + * If you did not previously call {@link scan} with {@link ScanOptions.keepSessionAlive} set to true, + * it will first scan the tag then write to it. + * + * @param records + * @param options + * @returns + */ +export async function write( + records: NFCRecord[], + options?: WriteOptions +): Promise { + const { kind, ...opts } = options ?? {} + if (kind) { + // @ts-expect-error map the property + opts.kind = mapScanKind(kind) + } + await invoke('plugin:nfc|write', { + records, + ...opts + }) +} + +export async function isAvailable(): Promise { + return await invoke('plugin:nfc|is_available') +} diff --git a/plugins/nfc/ios/.gitignore b/plugins/nfc/ios/.gitignore new file mode 100644 index 00000000..5922fdaa --- /dev/null +++ b/plugins/nfc/ios/.gitignore @@ -0,0 +1,10 @@ +.DS_Store +/.build +/Packages +/*.xcodeproj +xcuserdata/ +DerivedData/ +.swiftpm/config/registries.json +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +.netrc +Package.resolved diff --git a/plugins/nfc/ios/Package.swift b/plugins/nfc/ios/Package.swift new file mode 100644 index 00000000..a028db7d --- /dev/null +++ b/plugins/nfc/ios/Package.swift @@ -0,0 +1,34 @@ +// swift-tools-version:5.3 +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import PackageDescription + +let package = Package( + name: "tauri-plugin-nfc", + platforms: [ + .macOS(.v10_13), + .iOS(.v13), + ], + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .library( + name: "tauri-plugin-nfc", + type: .static, + targets: ["tauri-plugin-nfc"]) + ], + dependencies: [ + .package(name: "Tauri", path: "../.tauri/tauri-api") + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .target( + name: "tauri-plugin-nfc", + dependencies: [ + .byName(name: "Tauri") + ], + path: "Sources") + ] +) diff --git a/plugins/nfc/ios/README.md b/plugins/nfc/ios/README.md new file mode 100644 index 00000000..88a429b7 --- /dev/null +++ b/plugins/nfc/ios/README.md @@ -0,0 +1,3 @@ +# Tauri Plugin Nfc + +A description of this package. diff --git a/plugins/nfc/ios/Sources/NfcPlugin.swift b/plugins/nfc/ios/Sources/NfcPlugin.swift new file mode 100644 index 00000000..58d69a84 --- /dev/null +++ b/plugins/nfc/ios/Sources/NfcPlugin.swift @@ -0,0 +1,521 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +// https://developer.apple.com/documentation/corenfc/building_an_nfc_tag-reader_app + +import CoreNFC +import SwiftRs +import Tauri +import UIKit +import WebKit + +enum ScanKind: Decodable { + case ndef, tag +} + +struct ScanOptions: Decodable { + let kind: ScanKind + var keepSessionAlive: Bool? + var message: String? + var successMessage: String? +} + +struct NDEFRecord: Decodable { + var format: UInt8? + var kind: [UInt8]? + var identifier: [UInt8]? + var payload: [UInt8]? +} + +struct WriteOptions: Decodable { + var kind: ScanKind? + let records: [NDEFRecord] + var message: String? + var successMessage: String? + var successfulReadMessage: String? +} + +enum TagProcessMode { + case write(message: NFCNDEFMessage) + case read +} + +class Session { + let nfcSession: NFCReaderSession? + let invoke: Invoke + var keepAlive: Bool + let tagProcessMode: TagProcessMode + var tagStatus: NFCNDEFStatus? + var tag: NFCNDEFTag? + let successfulReadMessage: String? + let successfulWriteAlertMessage: String? + + init( + nfcSession: NFCReaderSession?, + invoke: Invoke, + keepAlive: Bool, + tagProcessMode: TagProcessMode, + successfulReadMessage: String?, + successfulWriteAlertMessage: String? + ) { + self.nfcSession = nfcSession + self.invoke = invoke + self.keepAlive = keepAlive + self.tagProcessMode = tagProcessMode + self.successfulReadMessage = successfulReadMessage + self.successfulWriteAlertMessage = successfulWriteAlertMessage + } +} + +class NfcStatus { + let available: Bool + let errorReason: String? + + init(available: Bool, errorReason: String?) { + self.available = available + self.errorReason = errorReason + } +} + +class NfcPlugin: Plugin, NFCTagReaderSessionDelegate, NFCNDEFReaderSessionDelegate { + var session: Session? + var status: NfcStatus! + + public override func load(webview: WKWebView) { + var available = false + var errorReason: String? + + let entry = Bundle.main.infoDictionary?["NFCReaderUsageDescription"] as? String + + if entry == nil || entry?.count == 0 { + errorReason = "missing NFCReaderUsageDescription configuration on the Info.plist file" + } else if !NFCNDEFReaderSession.readingAvailable { + errorReason = + "NFC tag reading unavailable, make sure the Near-Field Communication capability on Xcode is enabled and the device supports NFC tag reading" + } else { + available = true + } + + if let error = errorReason { + Logger.error("\(error)") + } + + self.status = NfcStatus(available: available, errorReason: errorReason) + } + + func tagReaderSessionDidBecomeActive( + _ session: NFCTagReaderSession + ) { + Logger.info("tagReaderSessionDidBecomeActive") + } + + func tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) { + let tag = tags.first! + + session.connect( + to: tag, + completionHandler: { [self] (error) in + if let error = error { + self.closeSession(session, error: "cannot connect to tag: \(error)") + + } else { + let ndefTag: NFCNDEFTag + switch tag { + case let .feliCa(tag): + ndefTag = tag as NFCNDEFTag + break + case let .miFare(tag): + ndefTag = tag as NFCNDEFTag + break + case let .iso15693(tag): + ndefTag = tag as NFCNDEFTag + break + case let .iso7816(tag): + ndefTag = tag as NFCNDEFTag + break + default: + return + } + + self.processTag( + session: session, tag: ndefTag, metadata: tagMetadata(tag), + mode: self.session!.tagProcessMode) + } + } + ) + } + + func tagReaderSession(_ session: NFCTagReaderSession, didInvalidateWithError error: Error) { + Logger.error("Tag reader session error \(error)") + self.session?.invoke.reject("session invalidated with error: \(error)") + } + + func readerSession(_ session: NFCNDEFReaderSession, didDetectNDEFs messages: [NFCNDEFMessage]) { + let message = messages.first! + // TODO: do we really need this hook? + self.session?.invoke.resolve(["records": ndefMessageRecords(message)]) + } + + func readerSession(_ session: NFCNDEFReaderSession, didDetect tags: [NFCNDEFTag]) { + let tag = tags.first! + + session.connect( + to: tag, + completionHandler: { [self] (error) in + if let error = error { + self.closeSession(session, error: "cannot connect to tag: \(error)") + + } else { + var metadata: JsonObject = [:] + if tag.isKind(of: NFCFeliCaTag.self) { + metadata["kind"] = ["FeliCa"] + metadata["id"] = nil + } else if let t = tag as? NFCMiFareTag { + metadata["kind"] = ["MiFare"] + metadata["id"] = byteArrayFromData(t.identifier) + } else if let t = tag as? NFCISO15693Tag { + metadata["kind"] = ["ISO15693"] + metadata["id"] = byteArrayFromData(t.identifier) + } else if let t = tag as? NFCISO7816Tag { + metadata["kind"] = ["ISO7816Compatible"] + metadata["id"] = byteArrayFromData(t.identifier) + } + + self.processTag( + session: session, tag: tag, metadata: metadata, + mode: self.session!.tagProcessMode) + } + } + ) + + } + + func readerSession(_ session: NFCNDEFReaderSession, didInvalidateWithError error: Error) { + if (error as NSError).code + == NFCReaderError.Code.readerSessionInvalidationErrorFirstNDEFTagRead.rawValue + { + // not an error because we're using invalidateAfterFirstRead: true + Logger.debug("readerSessionInvalidationErrorFirstNDEFTagRead") + } else { + Logger.error("NDEF reader session error \(error)") + self.session?.invoke.reject("session invalidated with error: \(error)") + } + } + + private func tagMetadata(_ tag: NFCTag) -> JsonObject { + var metadata: JsonObject = [:] + + switch tag { + case .feliCa: + metadata["kind"] = ["FeliCa"] + metadata["id"] = [] + break + case let .miFare(tag): + metadata["kind"] = ["MiFare"] + metadata["id"] = byteArrayFromData(tag.identifier) + break + case let .iso15693(tag): + metadata["kind"] = ["ISO15693"] + metadata["id"] = byteArrayFromData(tag.identifier) + break + case let .iso7816(tag): + metadata["kind"] = ["ISO7816Compatible"] + metadata["id"] = byteArrayFromData(tag.identifier) + break + default: + metadata["kind"] = ["Unknown"] + metadata["id"] = [] + break + } + + return metadata + } + + private func closeSession(_ session: NFCReaderSession) { + session.invalidate() + self.session = nil + } + + private func closeSession(_ session: NFCReaderSession, error: String) { + session.invalidate(errorMessage: error) + self.session = nil + } + + private func processTag( + session: NFCReaderSession, tag: T, metadata: JsonObject, mode: TagProcessMode + ) { + tag.queryNDEFStatus(completionHandler: { + [self] (status, capacity, error) in + if let error = error { + self.closeSession(session, error: "cannot connect to tag: \(error)") + } else { + switch mode { + case .write(let message): + self.writeNDEFTag( + session: session, status: status, tag: tag, message: message, + alertMessage: self.session?.successfulWriteAlertMessage) + break + case .read: + if self.session?.keepAlive == true { + self.session!.tagStatus = status + self.session!.tag = tag + } + self.readNDEFTag( + session: session, status: status, tag: tag, metadata: metadata, + alertMessage: self.session?.successfulReadMessage) + break + } + } + }) + } + + private func writeNDEFTag( + session: NFCReaderSession, status: NFCNDEFStatus, tag: T, message: NFCNDEFMessage, + alertMessage: String? + ) { + switch status { + case .notSupported: + self.closeSession(session, error: "Tag is not an NDEF-formatted tag") + break + case .readOnly: + self.closeSession(session, error: "Read only tag") + break + case .readWrite: + if let currentSession = self.session { + tag.writeNDEF( + message, + completionHandler: { (error) in + if let error = error { + self.closeSession(session, error: "cannot write to tag: \(error)") + } else { + if let message = alertMessage { + session.alertMessage = message + } + currentSession.invoke.resolve() + + self.closeSession(session) + + } + }) + } + break + default: + return + } + } + + private func readNDEFTag( + session: NFCReaderSession, status: NFCNDEFStatus, tag: T, metadata m: JsonObject, + alertMessage: String? + ) { + var metadata: JsonObject = [:] + metadata.merge(m) { (_, new) in new } + + switch status { + case .notSupported: + self.resolveInvoke(message: nil, metadata: metadata) + self.closeSession(session) + return + case .readOnly: + metadata["readOnly"] = true + break + case .readWrite: + metadata["readOnly"] = false + break + default: + break + } + + tag.readNDEF(completionHandler: { + [self] (message, error) in + if let error = error { + let code = (error as NSError).code + if code != 403 { + self.closeSession(session, error: "Failed to read: \(error)") + return + } + } + + if let message = alertMessage { + session.alertMessage = message + } + self.resolveInvoke(message: message, metadata: metadata) + + if self.session?.keepAlive != true { + self.closeSession(session) + } + }) + } + + private func resolveInvoke(message: NFCNDEFMessage?, metadata: JsonObject) { + var data: JsonObject = [:] + + data.merge(metadata) { (_, new) in new } + + if let message = message { + data["records"] = ndefMessageRecords(message) + } else { + data["records"] = [] + } + + self.session?.invoke.resolve(data) + } + + private func ndefMessageRecords(_ message: NFCNDEFMessage) -> [JsonObject] { + var records: [JsonObject] = [] + for record in message.records { + var recordJson: JsonObject = [:] + recordJson["tnf"] = record.typeNameFormat.rawValue + recordJson["kind"] = byteArrayFromData(record.type) + recordJson["id"] = byteArrayFromData(record.identifier) + recordJson["payload"] = byteArrayFromData(record.payload) + + records.append(recordJson) + } + + return records + } + + private func byteArrayFromData(_ data: Data) -> [UInt8] { + var arr: [UInt8] = [] + for b in data { + arr.append(b) + } + return arr + } + + private func dataFromByteArray(_ array: [UInt8]) -> Data { + var data = Data(capacity: array.count) + + data.append(contentsOf: array) + + return data + } + + @objc func isAvailable(_ invoke: Invoke) { + invoke.resolve([ + "available": self.status.available + ]) + } + + @objc public func write(_ invoke: Invoke) throws { + if !self.status.available { + invoke.reject("NFC reading unavailable: \(self.status.errorReason ?? "")") + return + } + + let args = try invoke.parseArgs(WriteOptions.self) + + var ndefPayloads = [NFCNDEFPayload]() + + for record in args.records { + ndefPayloads.append( + NFCNDEFPayload( + format: NFCTypeNameFormat(rawValue: record.format ?? 0) ?? .unknown, + type: dataFromByteArray(record.kind ?? []), + identifier: dataFromByteArray(record.identifier ?? []), + payload: dataFromByteArray(record.payload ?? []) + ) + ) + } + + if let session = self.session { + if let nfcSession = session.nfcSession, let tagStatus = session.tagStatus, + let tag = session.tag + { + session.keepAlive = false + self.writeNDEFTag( + session: nfcSession, status: tagStatus, tag: tag, + message: NFCNDEFMessage(records: ndefPayloads), + alertMessage: args.successMessage + ) + } else { + invoke.reject( + "connected tag not found, please wait for it to be available and then call write()") + } + } else { + self.startScanSession( + invoke: invoke, + kind: args.kind ?? .ndef, + keepAlive: true, + invalidateAfterFirstRead: false, + tagProcessMode: .write( + message: NFCNDEFMessage(records: ndefPayloads) + ), + alertMessage: args.message, + successfulReadMessage: args.successfulReadMessage, + successfulWriteAlertMessage: args.successMessage + ) + } + } + + @objc public func scan(_ invoke: Invoke) throws { + if !self.status.available { + invoke.reject("NFC reading unavailable: \(self.status.errorReason ?? "")") + return + } + + let args = try invoke.parseArgs(ScanOptions.self) + + self.startScanSession( + invoke: invoke, + kind: args.kind, + keepAlive: args.keepSessionAlive ?? false, + invalidateAfterFirstRead: true, + tagProcessMode: .read, + alertMessage: args.message, + successfulReadMessage: args.successMessage, + successfulWriteAlertMessage: nil + ) + } + + private func startScanSession( + invoke: Invoke, + kind: ScanKind, + keepAlive: Bool, + invalidateAfterFirstRead: Bool, + tagProcessMode: TagProcessMode, + alertMessage: String?, + successfulReadMessage: String?, + successfulWriteAlertMessage: String? + ) { + let nfcSession: NFCReaderSession? + + switch kind { + case .tag: + nfcSession = NFCTagReaderSession( + pollingOption: [.iso14443, .iso15693], + delegate: self, + queue: DispatchQueue.main + ) + break + case .ndef: + nfcSession = NFCNDEFReaderSession( + delegate: self, + queue: DispatchQueue.main, + invalidateAfterFirstRead: invalidateAfterFirstRead + ) + break + } + + if let message = alertMessage { + nfcSession?.alertMessage = message + } + nfcSession?.begin() + + self.session = Session( + nfcSession: nfcSession, + invoke: invoke, + keepAlive: keepAlive, + tagProcessMode: tagProcessMode, + successfulReadMessage: successfulReadMessage, + successfulWriteAlertMessage: successfulWriteAlertMessage + ) + } +} + +@_cdecl("init_plugin_nfc") +func initPlugin() -> Plugin { + return NfcPlugin() +} diff --git a/plugins/nfc/ios/Tests/PluginTests/PluginTests.swift b/plugins/nfc/ios/Tests/PluginTests/PluginTests.swift new file mode 100644 index 00000000..99992ce4 --- /dev/null +++ b/plugins/nfc/ios/Tests/PluginTests/PluginTests.swift @@ -0,0 +1,12 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import XCTest +@testable import ExamplePlugin + +final class ExamplePluginTests: XCTestCase { + func testExample() throws { + let plugin = ExamplePlugin() + } +} diff --git a/plugins/nfc/package.json b/plugins/nfc/package.json new file mode 100644 index 00000000..c4852e51 --- /dev/null +++ b/plugins/nfc/package.json @@ -0,0 +1,30 @@ +{ + "name": "@tauri-apps/plugin-nfc", + "version": "2.2.0", + "license": "MIT OR Apache-2.0", + "authors": [ + "Tauri Programme within The Commons Conservancy" + ], + "repository": "https://github.com/tauri-apps/plugins-workspace", + "type": "module", + "types": "./dist-js/index.d.ts", + "main": "./dist-js/index.cjs", + "module": "./dist-js/index.js", + "exports": { + "types": "./dist-js/index.d.ts", + "import": "./dist-js/index.js", + "require": "./dist-js/index.cjs" + }, + "scripts": { + "build": "rollup -c" + }, + "files": [ + "dist-js", + "!dist-js/**/*.map", + "README.md", + "LICENSE" + ], + "dependencies": { + "@tauri-apps/api": "^2.0.0" + } +} diff --git a/plugins/nfc/permissions/autogenerated/commands/is_available.toml b/plugins/nfc/permissions/autogenerated/commands/is_available.toml new file mode 100644 index 00000000..6f49c5ab --- /dev/null +++ b/plugins/nfc/permissions/autogenerated/commands/is_available.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-is-available" +description = "Enables the is_available command without any pre-configured scope." +commands.allow = ["is_available"] + +[[permission]] +identifier = "deny-is-available" +description = "Denies the is_available command without any pre-configured scope." +commands.deny = ["is_available"] diff --git a/plugins/nfc/permissions/autogenerated/commands/scan.toml b/plugins/nfc/permissions/autogenerated/commands/scan.toml new file mode 100644 index 00000000..efa621dd --- /dev/null +++ b/plugins/nfc/permissions/autogenerated/commands/scan.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-scan" +description = "Enables the scan command without any pre-configured scope." +commands.allow = ["scan"] + +[[permission]] +identifier = "deny-scan" +description = "Denies the scan command without any pre-configured scope." +commands.deny = ["scan"] diff --git a/plugins/nfc/permissions/autogenerated/commands/write.toml b/plugins/nfc/permissions/autogenerated/commands/write.toml new file mode 100644 index 00000000..73d1d387 --- /dev/null +++ b/plugins/nfc/permissions/autogenerated/commands/write.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-write" +description = "Enables the write command without any pre-configured scope." +commands.allow = ["write"] + +[[permission]] +identifier = "deny-write" +description = "Denies the write command without any pre-configured scope." +commands.deny = ["write"] diff --git a/plugins/nfc/permissions/autogenerated/reference.md b/plugins/nfc/permissions/autogenerated/reference.md new file mode 100644 index 00000000..6148cf2c --- /dev/null +++ b/plugins/nfc/permissions/autogenerated/reference.md @@ -0,0 +1,105 @@ +## Default Permission + +This permission set configures what kind of +operations are available from the nfc plugin. + +#### Granted Permissions + +Checking if the NFC functionality is available +and scanning nearby tags is allowed. +Writing to tags needs to be manually enabled. + + + +#### This default permission set includes the following: + +- `allow-is-available` +- `allow-scan` + +## Permission Table + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IdentifierDescription
+ +`nfc:allow-is-available` + + + +Enables the is_available command without any pre-configured scope. + +
+ +`nfc:deny-is-available` + + + +Denies the is_available command without any pre-configured scope. + +
+ +`nfc:allow-scan` + + + +Enables the scan command without any pre-configured scope. + +
+ +`nfc:deny-scan` + + + +Denies the scan command without any pre-configured scope. + +
+ +`nfc:allow-write` + + + +Enables the write command without any pre-configured scope. + +
+ +`nfc:deny-write` + + + +Denies the write command without any pre-configured scope. + +
diff --git a/plugins/nfc/permissions/default.toml b/plugins/nfc/permissions/default.toml new file mode 100644 index 00000000..d69c7f1b --- /dev/null +++ b/plugins/nfc/permissions/default.toml @@ -0,0 +1,15 @@ +"$schema" = "schemas/schema.json" + +[default] +description = """ +This permission set configures what kind of +operations are available from the nfc plugin. + +#### Granted Permissions + +Checking if the NFC functionality is available +and scanning nearby tags is allowed. +Writing to tags needs to be manually enabled. + +""" +permissions = ["allow-is-available", "allow-scan"] diff --git a/plugins/nfc/permissions/schemas/schema.json b/plugins/nfc/permissions/schemas/schema.json new file mode 100644 index 00000000..8a018e26 --- /dev/null +++ b/plugins/nfc/permissions/schemas/schema.json @@ -0,0 +1,342 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "PermissionFile", + "description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.", + "type": "object", + "properties": { + "default": { + "description": "The default permission set for the plugin", + "anyOf": [ + { + "$ref": "#/definitions/DefaultPermission" + }, + { + "type": "null" + } + ] + }, + "set": { + "description": "A list of permissions sets defined", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionSet" + } + }, + "permission": { + "description": "A list of inlined permissions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Permission" + } + } + }, + "definitions": { + "DefaultPermission": { + "description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.", + "type": "object", + "required": [ + "permissions" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "PermissionSet": { + "description": "A set of direct permissions grouped together under a new name.", + "type": "object", + "required": [ + "description", + "identifier", + "permissions" + ], + "properties": { + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does.", + "type": "string" + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionKind" + } + } + } + }, + "Permission": { + "description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.", + "type": "object", + "required": [ + "identifier" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri internal convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "commands": { + "description": "Allowed or denied commands when using this permission.", + "default": { + "allow": [], + "deny": [] + }, + "allOf": [ + { + "$ref": "#/definitions/Commands" + } + ] + }, + "scope": { + "description": "Allowed or denied scoped when using this permission.", + "allOf": [ + { + "$ref": "#/definitions/Scopes" + } + ] + }, + "platforms": { + "description": "Target platforms this permission applies. By default all platforms are affected by this permission.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Target" + } + } + } + }, + "Commands": { + "description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.", + "type": "object", + "properties": { + "allow": { + "description": "Allowed command.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "deny": { + "description": "Denied command, which takes priority.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "Scopes": { + "description": "An argument for fine grained behavior control of Tauri commands.\n\nIt can be of any serde serializable type and is used to allow or prevent certain actions inside a Tauri command. The configured scope is passed to the command and will be enforced by the command implementation.\n\n## Example\n\n```json { \"allow\": [{ \"path\": \"$HOME/**\" }], \"deny\": [{ \"path\": \"$HOME/secret.txt\" }] } ```", + "type": "object", + "properties": { + "allow": { + "description": "Data that defines what is allowed by the scope.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + }, + "deny": { + "description": "Data that defines what is denied by the scope. This should be prioritized by validation logic.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + } + } + }, + "Value": { + "description": "All supported ACL values.", + "anyOf": [ + { + "description": "Represents a null JSON value.", + "type": "null" + }, + { + "description": "Represents a [`bool`].", + "type": "boolean" + }, + { + "description": "Represents a valid ACL [`Number`].", + "allOf": [ + { + "$ref": "#/definitions/Number" + } + ] + }, + { + "description": "Represents a [`String`].", + "type": "string" + }, + { + "description": "Represents a list of other [`Value`]s.", + "type": "array", + "items": { + "$ref": "#/definitions/Value" + } + }, + { + "description": "Represents a map of [`String`] keys to [`Value`]s.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/Value" + } + } + ] + }, + "Number": { + "description": "A valid ACL number.", + "anyOf": [ + { + "description": "Represents an [`i64`].", + "type": "integer", + "format": "int64" + }, + { + "description": "Represents a [`f64`].", + "type": "number", + "format": "double" + } + ] + }, + "Target": { + "description": "Platform target.", + "oneOf": [ + { + "description": "MacOS.", + "type": "string", + "enum": [ + "macOS" + ] + }, + { + "description": "Windows.", + "type": "string", + "enum": [ + "windows" + ] + }, + { + "description": "Linux.", + "type": "string", + "enum": [ + "linux" + ] + }, + { + "description": "Android.", + "type": "string", + "enum": [ + "android" + ] + }, + { + "description": "iOS.", + "type": "string", + "enum": [ + "iOS" + ] + } + ] + }, + "PermissionKind": { + "type": "string", + "oneOf": [ + { + "description": "Enables the is_available command without any pre-configured scope.", + "type": "string", + "const": "allow-is-available", + "markdownDescription": "Enables the is_available command without any pre-configured scope." + }, + { + "description": "Denies the is_available command without any pre-configured scope.", + "type": "string", + "const": "deny-is-available", + "markdownDescription": "Denies the is_available command without any pre-configured scope." + }, + { + "description": "Enables the scan command without any pre-configured scope.", + "type": "string", + "const": "allow-scan", + "markdownDescription": "Enables the scan command without any pre-configured scope." + }, + { + "description": "Denies the scan command without any pre-configured scope.", + "type": "string", + "const": "deny-scan", + "markdownDescription": "Denies the scan command without any pre-configured scope." + }, + { + "description": "Enables the write command without any pre-configured scope.", + "type": "string", + "const": "allow-write", + "markdownDescription": "Enables the write command without any pre-configured scope." + }, + { + "description": "Denies the write command without any pre-configured scope.", + "type": "string", + "const": "deny-write", + "markdownDescription": "Denies the write command without any pre-configured scope." + }, + { + "description": "This permission set configures what kind of\noperations are available from the nfc plugin.\n\n#### Granted Permissions\n\nChecking if the NFC functionality is available\nand scanning nearby tags is allowed.\nWriting to tags needs to be manually enabled.\n\n\n#### This default permission set includes:\n\n- `allow-is-available`\n- `allow-scan`", + "type": "string", + "const": "default", + "markdownDescription": "This permission set configures what kind of\noperations are available from the nfc plugin.\n\n#### Granted Permissions\n\nChecking if the NFC functionality is available\nand scanning nearby tags is allowed.\nWriting to tags needs to be manually enabled.\n\n\n#### This default permission set includes:\n\n- `allow-is-available`\n- `allow-scan`" + } + ] + } + } +} \ No newline at end of file diff --git a/plugins/nfc/rollup.config.js b/plugins/nfc/rollup.config.js new file mode 100644 index 00000000..1f349ec8 --- /dev/null +++ b/plugins/nfc/rollup.config.js @@ -0,0 +1,7 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import { createConfig } from '../../shared/rollup.config.js' + +export default createConfig() diff --git a/plugins/nfc/src/error.rs b/plugins/nfc/src/error.rs new file mode 100644 index 00000000..339e763b --- /dev/null +++ b/plugins/nfc/src/error.rs @@ -0,0 +1,25 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use serde::{ser::Serializer, Serialize}; + +pub type Result = std::result::Result; + +#[derive(Debug, thiserror::Error)] +pub enum Error { + #[error(transparent)] + Io(#[from] std::io::Error), + #[cfg(mobile)] + #[error(transparent)] + PluginInvoke(#[from] tauri::plugin::mobile::PluginInvokeError), +} + +impl Serialize for Error { + fn serialize(&self, serializer: S) -> std::result::Result + where + S: Serializer, + { + serializer.serialize_str(self.to_string().as_ref()) + } +} diff --git a/plugins/nfc/src/lib.rs b/plugins/nfc/src/lib.rs new file mode 100644 index 00000000..d8708c1d --- /dev/null +++ b/plugins/nfc/src/lib.rs @@ -0,0 +1,83 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +#![cfg(mobile)] + +use serde::{Deserialize, Serialize}; +use tauri::{ + plugin::{Builder, PluginHandle, TauriPlugin}, + Manager, Runtime, +}; + +pub use models::*; + +mod error; +mod models; + +pub use error::{Error, Result}; + +#[cfg(target_os = "android")] +const PLUGIN_IDENTIFIER: &str = "app.tauri.nfc"; + +#[cfg(target_os = "ios")] +tauri::ios_plugin_binding!(init_plugin_nfc); + +/// Access to the nfc APIs. +pub struct Nfc(PluginHandle); + +#[derive(Deserialize)] +struct IsAvailableResponse { + available: bool, +} + +#[derive(Serialize)] +struct WriteRequest { + records: Vec, +} + +impl Nfc { + pub fn is_available(&self) -> crate::Result { + self.0 + .run_mobile_plugin::("isAvailable", ()) + .map(|r| r.available) + .map_err(Into::into) + } + + pub fn scan(&self, payload: ScanRequest) -> crate::Result { + self.0 + .run_mobile_plugin("scan", payload) + .map_err(Into::into) + } + + pub fn write(&self, records: Vec) -> crate::Result<()> { + self.0 + .run_mobile_plugin("write", WriteRequest { records }) + .map_err(Into::into) + } +} + +/// Extensions to [`tauri::App`], [`tauri::AppHandle`], [`tauri::WebviewWindow`], [`tauri::Webview`] and [`tauri::Window`] to access the NFC APIs. +pub trait NfcExt { + fn nfc(&self) -> &Nfc; +} + +impl> crate::NfcExt for T { + fn nfc(&self) -> &Nfc { + self.state::>().inner() + } +} + +/// Initializes the plugin. +pub fn init() -> TauriPlugin { + Builder::new("nfc") + .setup(|app, api| { + #[cfg(target_os = "android")] + let handle = api.register_android_plugin(PLUGIN_IDENTIFIER, "NfcPlugin")?; + #[cfg(target_os = "ios")] + let handle = api.register_ios_plugin(init_plugin_nfc)?; + app.manage(Nfc(handle)); + Ok(()) + }) + .build() +} diff --git a/plugins/nfc/src/mobile.rs b/plugins/nfc/src/mobile.rs new file mode 100644 index 00000000..cf34d45e --- /dev/null +++ b/plugins/nfc/src/mobile.rs @@ -0,0 +1,11 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use serde::de::DeserializeOwned; +use tauri::{ + plugin::{PluginApi, PluginHandle}, + AppHandle, Runtime, +}; + +use crate::models::*; diff --git a/plugins/nfc/src/models.rs b/plugins/nfc/src/models.rs new file mode 100644 index 00000000..eb05cf7a --- /dev/null +++ b/plugins/nfc/src/models.rs @@ -0,0 +1,119 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use serde::{Deserialize, Serialize, Serializer}; +use std::fmt::Display; + +#[derive(Serialize)] +#[serde(rename_all = "camelCase")] +pub struct ScanRequest { + pub kind: ScanKind, + pub keep_session_alive: bool, +} + +#[derive(Serialize)] +#[serde(rename_all = "camelCase")] +pub struct NfcRecord { + pub format: NFCTypeNameFormat, + pub kind: Vec, + pub id: Vec, + pub payload: Vec, +} + +#[derive(serde_repr::Deserialize_repr, serde_repr::Serialize_repr)] +#[repr(u8)] +pub enum NFCTypeNameFormat { + Empty = 0, + NfcWellKnown = 1, + Media = 2, + AbsoluteURI = 3, + NfcExternal = 4, + Unknown = 5, + Unchanged = 6, +} + +#[derive(Deserialize)] +pub struct NfcTagRecord { + pub tnf: NFCTypeNameFormat, + pub kind: Vec, + pub id: Vec, + pub payload: Vec, +} + +#[derive(Deserialize)] +pub struct NfcTag { + pub id: String, + pub kind: String, + pub records: Vec, +} + +#[derive(Deserialize)] +pub struct ScanResponse { + pub tag: NfcTag, +} + +#[derive(Debug, Default, Serialize)] +pub struct UriFilter { + scheme: Option, + host: Option, + path_prefix: Option, +} + +#[derive(Debug)] +pub enum TechKind { + IsoDep, + MifareClassic, + MifareUltralight, + Ndef, + NdefFormatable, + NfcA, + NfcB, + NfcBarcode, + NfcF, + NfcV, +} + +impl Display for TechKind { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "{}", + match self { + Self::IsoDep => "IsoDep", + Self::MifareClassic => "MifareClassic", + Self::MifareUltralight => "MifareUltralight", + Self::Ndef => "Ndef", + Self::NdefFormatable => "NdefFormatable", + Self::NfcA => "NfcA", + Self::NfcB => "NfcB", + Self::NfcBarcode => "NfcBarcode", + Self::NfcF => "NfcF", + Self::NfcV => "NfcV", + } + ) + } +} + +impl Serialize for TechKind { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_str(&self.to_string()) + } +} + +#[derive(Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub enum ScanKind { + Ndef { + mime_type: Option, + uri: Option, + tech_list: Option>>, + }, + Tag { + mime_type: Option, + uri: Option, + }, +} diff --git a/plugins/nfc/tsconfig.json b/plugins/nfc/tsconfig.json new file mode 100644 index 00000000..5098169a --- /dev/null +++ b/plugins/nfc/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.base.json", + "include": ["guest-js/*.ts"] +} diff --git a/plugins/notification/CHANGELOG.md b/plugins/notification/CHANGELOG.md index e9f3407b..42efb6ab 100644 --- a/plugins/notification/CHANGELOG.md +++ b/plugins/notification/CHANGELOG.md @@ -1,22 +1,132 @@ # Changelog +## \[2.2.2] + +- [`a1b3fa27`](https://github.com/tauri-apps/plugins-workspace/commit/a1b3fa27f11022c9b6622b4fab12d93239eb05de) ([#2515](https://github.com/tauri-apps/plugins-workspace/pull/2515) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Re-exported the `Geolocation`, `Haptics`, `Notification`, and `Os` structs so that they show up on docs.rs. + +## \[2.2.1] + +- [`da5c59e2`](https://github.com/tauri-apps/plugins-workspace/commit/da5c59e2fe879d177e3cfd52fcacce85440423cb) ([#2271](https://github.com/tauri-apps/plugins-workspace/pull/2271) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Updated `zbus` dependency to version 5. No API changes. + +## \[2.2.0] + +- [`3a79266b`](https://github.com/tauri-apps/plugins-workspace/commit/3a79266b8cf96a55b1ae6339d725567d45a44b1d) ([#2173](https://github.com/tauri-apps/plugins-workspace/pull/2173) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Bumped all plugins to `v2.2.0`. From now, the versions for the Rust and JavaScript packages of each plugin will be in sync with each other. + +## \[2.0.1] + +- [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. + +## \[2.0.0] + +- [`e2c4dfb6`](https://github.com/tauri-apps/plugins-workspace/commit/e2c4dfb6af43e5dd8d9ceba232c315f5febd55c1) Update to tauri v2 stable release. + +## \[2.0.0-rc.5] + +- [`fb85e5dd`](https://github.com/tauri-apps/plugins-workspace/commit/fb85e5dd76688f3ae836890160f9bde843b70167) ([#1785](https://github.com/tauri-apps/plugins-workspace/pull/1785)) Update to tauri 2.0.0-rc.12. + +## \[2.0.0-rc.4] + +- [`3d301c65`](https://github.com/tauri-apps/plugins-workspace/commit/3d301c654e6f5e7f343e0e0cbb57648002e98f04) ([#1737](https://github.com/tauri-apps/plugins-workspace/pull/1737) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) The notification body is now optional on iOS to match the other platforms. + +## \[2.0.0-rc.1] + +- [`e2e97db5`](https://github.com/tauri-apps/plugins-workspace/commit/e2e97db51983267f5be84d4f6f0278d58834d1f5) ([#1701](https://github.com/tauri-apps/plugins-workspace/pull/1701) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Use `PermissionState` from the `tauri` crate, which now also includes a "prompt with rationale" variant for Android (returned when your app must explain to the user why it needs the permission). +- [`e2e97db5`](https://github.com/tauri-apps/plugins-workspace/commit/e2e97db51983267f5be84d4f6f0278d58834d1f5) ([#1701](https://github.com/tauri-apps/plugins-workspace/pull/1701) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) **Breaking change**: The permission type when using the API is now `'granted' | 'denied' | 'prompt' | 'prompt-with-rationale'` instead of `'granted' | 'denied' | 'default'` for consistency with Rust types. When using the `window.Notification` API the type is unchanged to match the Web API type. +- [`e2e97db5`](https://github.com/tauri-apps/plugins-workspace/commit/e2e97db51983267f5be84d4f6f0278d58834d1f5) ([#1701](https://github.com/tauri-apps/plugins-workspace/pull/1701) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri 2.0.0-rc.8 + +## \[2.0.0-rc.2] + +- [`b9147758`](https://github.com/tauri-apps/plugins-workspace/commit/b914775898c2bee7ceb20bd17ee595005cd17a64) ([#1679](https://github.com/tauri-apps/plugins-workspace/pull/1679) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Explicitly set a minimum macOS version for the Swift package. + +## \[2.0.0-rc.1] + +### changes + +- [`6b079cfd`](https://github.com/tauri-apps/plugins-workspace/commit/6b079cfdd107c94abc2c7300f6af00bac3ff4040) ([#1649](https://github.com/tauri-apps/plugins-workspace/pull/1649) by [@ahqsoftwares](https://github.com/tauri-apps/plugins-workspace/../../ahqsoftwares)) Remove targetSdk from build.kts files as it is deprecated and will be removed from DSL v9.0 + +## \[2.0.0-rc.0] + +- [`9887d1`](https://github.com/tauri-apps/plugins-workspace/commit/9887d14bd0e971c4c0f5c1188fc4005d3fc2e29e) Update to tauri RC. + +## \[2.0.0-beta.8] + +- [`99d6ac0f`](https://github.com/tauri-apps/plugins-workspace/commit/99d6ac0f9506a6a4a1aa59c728157190a7441af6) ([#1606](https://github.com/tauri-apps/plugins-workspace/pull/1606) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) The JS packages now specify the *minimum* `@tauri-apps/api` version instead of a single exact version. +- [`6de87966`](https://github.com/tauri-apps/plugins-workspace/commit/6de87966ecc00ad9d91c25be452f1f46bd2b7e1f) ([#1597](https://github.com/tauri-apps/plugins-workspace/pull/1597) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Update to tauri beta.25. + +## \[2.0.0-beta.11] + +- [`725ff429`](https://github.com/tauri-apps/plugins-workspace/commit/725ff4295e56df9c30c099813bd64b96fe61b945) ([#1556](https://github.com/tauri-apps/plugins-workspace/pull/1556) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Fixed an issue that caused the `notification` plugin's initialization script to cause the WebView on Windows to throw a `STATUS_ACCESS_VIOLATION` error on remote websites. + +## \[2.0.0-beta.7] + +- [`22a17980`](https://github.com/tauri-apps/plugins-workspace/commit/22a17980ff4f6f8c40adb1b8f4ffc6dae2fe7e30) ([#1537](https://github.com/tauri-apps/plugins-workspace/pull/1537) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri beta.24. + +## \[2.0.0-beta.6] + +- [`76daee7a`](https://github.com/tauri-apps/plugins-workspace/commit/76daee7aafece34de3092c86e531cf9eb1138989) ([#1512](https://github.com/tauri-apps/plugins-workspace/pull/1512) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Update to tauri beta.23. + +## \[2.0.0-beta.8] + +- [`3779fb50`](https://github.com/tauri-apps/plugins-workspace/commit/3779fb50634fba4d7e7eb0bfecc2216349b9d64d) ([#1432](https://github.com/tauri-apps/plugins-workspace/pull/1432) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Use notify_rust from crates.io instead of local fork. + +## \[2.0.0-beta.5] + +- [`9013854f`](https://github.com/tauri-apps/plugins-workspace/commit/9013854f42a49a230b9dbb9d02774765528a923f)([#1382](https://github.com/tauri-apps/plugins-workspace/pull/1382)) Update to tauri beta.22. + +## \[2.0.0-beta.4] + +- [`430bd6f4`](https://github.com/tauri-apps/plugins-workspace/commit/430bd6f4f379bee5d232ae6b098ae131db7f178a)([#1363](https://github.com/tauri-apps/plugins-workspace/pull/1363)) Update to tauri beta.20. + +## \[2.0.0-beta.3] + +- [`bd1ed590`](https://github.com/tauri-apps/plugins-workspace/commit/bd1ed5903ffcce5500310dac1e59e8c67674ef1e)([#1237](https://github.com/tauri-apps/plugins-workspace/pull/1237)) Update to tauri beta.17. + +## \[2.0.0-beta.4] + +- [`326df688`](https://github.com/tauri-apps/plugins-workspace/commit/326df6883998d416fc0837583ed972854628bb52)([#1236](https://github.com/tauri-apps/plugins-workspace/pull/1236)) Fixes command argument parsing on iOS. + +## \[2.0.0-beta.3] + +- [`a04ea2f`](https://github.com/tauri-apps/plugins-workspace/commit/a04ea2f38294d5a3987578283badc8eec87a7752)([#1071](https://github.com/tauri-apps/plugins-workspace/pull/1071)) The global API script is now only added to the binary when the `withGlobalTauri` config is true. +- [`62ce5df`](https://github.com/tauri-apps/plugins-workspace/commit/62ce5df52ca3c86786e711ef193a206e7b0dc0cf)([#1096](https://github.com/tauri-apps/plugins-workspace/pull/1096)) Fix development mode check to set the app ID on macOS. + +## \[2.0.0-beta.2] + +- [`99bea25`](https://github.com/tauri-apps/plugins-workspace/commit/99bea2559c2c0648c2519c50a18cd124dacef57b)([#1005](https://github.com/tauri-apps/plugins-workspace/pull/1005)) Update to tauri beta.8. + +## \[2.0.0-beta.1] + +- [`569defb`](https://github.com/tauri-apps/plugins-workspace/commit/569defbe9492e38938554bb7bdc1be9151456d21) Update to tauri beta.4. + +## \[2.0.0-beta.0] + +- [`d198c01`](https://github.com/tauri-apps/plugins-workspace/commit/d198c014863ee260cb0de88a14b7fc4356ef7474)([#862](https://github.com/tauri-apps/plugins-workspace/pull/862)) Update to tauri beta. +- [`1b1d795`](https://github.com/tauri-apps/plugins-workspace/commit/1b1d795b5866e5524a9a9925f0fb7b2f8e3e3675)([#874](https://github.com/tauri-apps/plugins-workspace/pull/874)) Export the missing `Schedule` class. +- [`8dea78a`](https://github.com/tauri-apps/plugins-workspace/commit/8dea78ac7dcb502159e66bad464094696aa257d4)([#909](https://github.com/tauri-apps/plugins-workspace/pull/909)) Fixes deserialization and implementation bugs with scheduled notifications on Android. + +## \[2.0.0-alpha.5] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.13. + +## \[2.0.0-alpha.4] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.12. + ## \[2.0.0-alpha.3] -- [`4e2cef9`](https://github.com/tauri-apps/plugins-workspace/commit/4e2cef9b702bbbb9cf4ee17de50791cb21f1b2a4)([#593](https://github.com/tauri-apps/plugins-workspace/pull/593)) Update to alpha.12. +- [`e438e0a`](https://github.com/tauri-apps/plugins-workspace/commit/e438e0a62d4b430a5159f05f13ecd397dd891a0d)([#676](https://github.com/tauri-apps/plugins-workspace/pull/676)) Update to @tauri-apps/api v2.0.0-alpha.11. -## \[2.0.0-alpha.1] +## \[2.0.0-alpha.2] -- [`d74fc0a`](https://github.com/tauri-apps/plugins-workspace/commit/d74fc0a097996e90a37be8f57d50b7d1f6ca616f)([#555](https://github.com/tauri-apps/plugins-workspace/pull/555)) Update to alpha.11. +- [`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.1] +## \[2.0.0-alpha.3] -- [`d8b4aca`](https://github.com/tauri-apps/plugins-workspace/commit/d8b4aca69f628b170804ecb982e2c319d026ef47)([#414](https://github.com/tauri-apps/plugins-workspace/pull/414)) Use `window.__TAURI_INVOKE__` instead of `window.__TAURI__` in init.js, fixes usage in apps without `withGlobalTauri` enabled. -- [`7d71ad4`](https://github.com/tauri-apps/plugins-workspace/commit/7d71ad4e587bcf47ea34645f5b226945e487b765) Play a default sound when showing a notification on Windows. +- [`4e2cef9`](https://github.com/tauri-apps/plugins-workspace/commit/4e2cef9b702bbbb9cf4ee17de50791cb21f1b2a4)([#593](https://github.com/tauri-apps/plugins-workspace/pull/593)) Update to alpha.12. -## \[2.0.0-alpha.0] +## \[2.0.0-alpha.1] -- [`717ae67`](https://github.com/tauri-apps/plugins-workspace/commit/717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! - ub.com/tauri-apps/plugins-workspace/pull/555)) Update to alpha.11. +- [`d74fc0a`](https://github.com/tauri-apps/plugins-workspace/commit/d74fc0a097996e90a37be8f57d50b7d1f6ca616f)([#555](https://github.com/tauri-apps/plugins-workspace/pull/555)) Update to alpha.11. ## \[2.0.0-alpha.1] diff --git a/plugins/notification/Cargo.toml b/plugins/notification/Cargo.toml index 13306565..bca17c09 100644 --- a/plugins/notification/Cargo.toml +++ b/plugins/notification/Cargo.toml @@ -1,22 +1,28 @@ [package] name = "tauri-plugin-notification" -version = "2.0.0-alpha.3" +version = "2.2.2" description = "Send desktop and mobile notifications on your Tauri application." edition = { workspace = true } authors = { workspace = true } license = { workspace = true } rust-version = { workspace = true } +repository = { workspace = true } links = "tauri-plugin-notification" [package.metadata.docs.rs] -features = [ "dox" ] -targets = [ - "x86_64-unknown-linux-gnu", - "x86_64-linux-android" -] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] +targets = ["x86_64-unknown-linux-gnu", "x86_64-linux-android"] + +[package.metadata.platforms.support] +windows = { level = "full", notes = "Only works for installed apps. Shows powershell name & icon in development." } +linux = { level = "full", notes = "" } +macos = { level = "full", notes = "" } +android = { level = "full", notes = "" } +ios = { level = "full", notes = "" } [build-dependencies] -tauri-build = { workspace = true } +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } @@ -25,16 +31,24 @@ tauri = { workspace = true } log = { workspace = true } thiserror = { workspace = true } rand = "0.8" -time = { version = "0.3", features = [ "serde", "parsing", "formatting" ] } -url = { version = "2", features = [ "serde" ] } +time = { version = "0.3", features = ["serde", "parsing", "formatting"] } +url = { version = "2", features = ["serde"] } serde_repr = "0.1" -[target."cfg(any(target_os = \"macos\", windows, target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies] -notify-rust = "4.5" +[target.'cfg(target_os = "ios")'.dependencies] +tauri = { workspace = true, features = ["wry"] } [target."cfg(windows)".dependencies] -win7-notifications = { version = "0.3.1", optional = true } +win7-notifications = { version = "0.4.5", optional = true } +windows-version = { version = "0.1", optional = true } + +[target."cfg(any(target_os = \"macos\", windows, target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies] +notify-rust = "4.11" + +[dev-dependencies] +color-backtrace = "0.7" +ctor = "0.2" +maplit = "1" [features] -windows7-compat = [ "win7-notifications" ] -dox = [ "tauri/dox" ] +windows7-compat = ["win7-notifications", "windows-version"] diff --git a/plugins/notification/README.md b/plugins/notification/README.md index 616f47c6..04632493 100644 --- a/plugins/notification/README.md +++ b/plugins/notification/README.md @@ -2,9 +2,17 @@ Send message notifications (brief auto-expiring OS window element) to your user. Can also be used with the Notification Web API. +| Platform | Supported | +| -------- | --------- | +| Linux | ✓ | +| Windows | ✓ | +| macOS | ✓ | +| Android | ✓ | +| iOS | ✓ | + ## Install -_This plugin requires a Rust version of at least **1.70**_ +_This plugin requires a Rust version of at least **1.77.2**_ There are three general methods of installation that we can recommend. @@ -18,7 +26,7 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] -tauri-plugin-notification = "2.0.0-alpha" +tauri-plugin-notification = "2.0.0" # alternatively with Git: tauri-plugin-notification = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -46,7 +54,7 @@ yarn add https://github.com/tauri-apps/tauri-plugin-notification#v2 First you need to register the core plugin with Tauri: -`src-tauri/src/main.rs` +`src-tauri/src/lib.rs` ```rust fn main() { @@ -57,16 +65,65 @@ fn main() { } ``` +Then you need to add the permissions to your capabilities file: + +`src-tauri/capabilities/main.json` + +```json +{ + ... + "permissions": [ + ... + "notification:default" + ], + ... +} +``` + Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript +import { + isPermissionGranted, + requestPermission, + sendNotification +} from '@tauri-apps/plugin-notification' + +async function checkPermission() { + if (!(await isPermissionGranted())) { + return (await requestPermission()) === 'granted' + } + return true +} +export async function enqueueNotification(title, body) { + if (!(await checkPermission())) { + return + } + sendNotification({ title, body }) +} ``` ## Contributing PRs accepted. Please make sure to read the Contributing Guide before making a pull request. +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + ## License Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. diff --git a/plugins/notification/SECURITY.md b/plugins/notification/SECURITY.md new file mode 100644 index 00000000..4f09bbac --- /dev/null +++ b/plugins/notification/SECURITY.md @@ -0,0 +1,23 @@ +# Security Policy + +**Do not report security vulnerabilities through public GitHub issues.** + +**Please use the [Private Vulnerability Disclosure](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) feature of GitHub.** + +Include as much of the following information: + +- Type of issue (e.g. improper input parsing, privilege escalation, etc.) +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- The distribution affected or used to help us with reproduction of the issue +- Step-by-step instructions to reproduce the issue +- Ideally a reproduction repository +- Impact of the issue, including how an attacker might exploit the issue + +We prefer to receive reports in English. + +## Contact + +Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). + +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/notification/android/build.gradle.kts b/plugins/notification/android/build.gradle.kts index 7d961104..0ac990e4 100644 --- a/plugins/notification/android/build.gradle.kts +++ b/plugins/notification/android/build.gradle.kts @@ -5,11 +5,10 @@ plugins { android { namespace = "app.tauri.notification" - compileSdk = 33 + compileSdk = 34 defaultConfig { - minSdk = 24 - targetSdk = 33 + minSdk = 24 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles("consumer-rules.pro") @@ -38,6 +37,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 28ccac30..c49808ee 100644 --- a/plugins/notification/android/src/main/AndroidManifest.xml +++ b/plugins/notification/android/src/main/AndroidManifest.xml @@ -4,7 +4,7 @@ @@ -14,6 +14,7 @@ - - - + + + + \ No newline at end of file diff --git a/plugins/notification/android/src/main/java/ChannelManager.kt b/plugins/notification/android/src/main/java/ChannelManager.kt index 2ae740e5..206f340a 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 9076fa8f..bf10f3dc 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 @@ -90,80 +80,16 @@ class Notification { return null } - 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 d50d0fe9..00000000 --- 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 2b6043dc..3ead3152 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 args = invoke.parseArgs(BatchArgs::class.java) - val notifications: MutableList = - ArrayList(notificationArray.length()) - val notificationsInput: List = try { - notificationArray.toList() - } catch (e: JSONException) { - invoke.reject("Provided notification format is invalid") - return - } - - for (jsonNotification in notificationsInput) { - val notification = Notification.fromJson(jsonNotification) - notifications.add(notification) - } + val ids = manager.schedule(args.notifications) + notificationStorage.appendNotifications(args.notifications) - val ids = manager.schedule(notifications) - notificationStorage.appendNotifications(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 @@ -253,7 +268,7 @@ class NotificationPlugin(private val activity: Activity): Plugin(activity) { @PermissionCallback private fun permissionsCallback(invoke: Invoke) { val permissionsResultJSON = JSObject() - permissionsResultJSON.put("display", getPermissionState()) + permissionsResultJSON.put("permissionState", getPermissionState()) invoke.resolve(permissionsResultJSON) } diff --git a/plugins/notification/android/src/main/java/NotificationSchedule.kt b/plugins/notification/android/src/main/java/NotificationSchedule.kt index 64c83486..316ff909 100644 --- a/plugins/notification/android/src/main/java/NotificationSchedule.kt +++ b/plugins/notification/android/src/main/java/NotificationSchedule.kt @@ -6,7 +6,20 @@ package app.tauri.notification import android.annotation.SuppressLint import android.text.format.DateUtils -import app.tauri.plugin.JSObject +import com.fasterxml.jackson.annotation.JsonFormat +import com.fasterxml.jackson.annotation.JsonProperty +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.deser.std.StdDeserializer +import com.fasterxml.jackson.databind.ser.std.StdSerializer +import java.io.IOException import java.text.SimpleDateFormat import java.util.Calendar import java.util.Date @@ -15,7 +28,22 @@ import java.util.TimeZone const val JS_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" enum class NotificationInterval { - Year, Month, TwoWeeks, Week, Day, Hour, Minute, Second + @JsonProperty("year") + Year, + @JsonProperty("month") + Month, + @JsonProperty("twoWeeks") + TwoWeeks, + @JsonProperty("week") + Week, + @JsonProperty("day") + Day, + @JsonProperty("hour") + Hour, + @JsonProperty("minute") + Minute, + @JsonProperty("second") + Second } fun getIntervalTime(interval: NotificationInterval, count: Int): Long { @@ -33,70 +61,102 @@ 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() + @JsonDeserialize + class At: NotificationSchedule() { + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = JS_DATE_FORMAT) + lateinit var date: Date + var repeating: Boolean = false + var allowWhileIdle: Boolean = false + } + @JsonDeserialize + class Interval: NotificationSchedule() { + lateinit var interval: DateMatch + var allowWhileIdle: Boolean = false + } + @JsonDeserialize + class Every: NotificationSchedule() { + lateinit var interval: NotificationInterval + var count: Int = 0 + var allowWhileIdle: Boolean = false + } + + 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") - } + jgen.writeEndObject() } - "Interval" -> { - val dateMatch = onFromJson(payload) - kind = ScheduleKind.Interval(dateMatch) - } - "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() } } - 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 4d55a9a4..bceb985d 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) { + if (request.schedule != null) { 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 2f948069..a8912739 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) @@ -211,12 +212,12 @@ class TauriNotificationManager( createActionIntents(notification, mBuilder) // notificationId is a unique int for each notification that you must define val buildNotification = mBuilder.build() - if (notification.isScheduled) { + if (notification.schedule != null) { triggerScheduledNotification(buildNotification, notification) } 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()) } } @@ -473,7 +473,7 @@ class TimedNotificationPublisher : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager - val notification = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + val notification = if (SDK_INT >= Build.VERSION_CODES.TIRAMISU) { intent.getParcelableExtra( NOTIFICATION_KEY, android.app.Notification::class.java @@ -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/api-iife.js b/plugins/notification/api-iife.js new file mode 100644 index 00000000..5ece60e8 --- /dev/null +++ b/plugins/notification/api-iife.js @@ -0,0 +1 @@ +if("__TAURI__"in window){var __TAURI_PLUGIN_NOTIFICATION__=function(i){"use strict";function t(i,t,n,e){if("function"==typeof t||!t.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?e:"a"===n?e.call(i):e?e.value:t.get(i)}function n(i,t,n,e,a){if("function"==typeof t||!t.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(i,n),n}var e,a,o,r;"function"==typeof SuppressedError&&SuppressedError;const c="__TAURI_TO_IPC_KEY__";class s{constructor(i){e.set(this,void 0),a.set(this,0),o.set(this,[]),r.set(this,void 0),n(this,e,i||(()=>{})),this.id=function(i,t=!1){return window.__TAURI_INTERNALS__.transformCallback(i,t)}((i=>{const c=i.index;if("end"in i)return void(c==t(this,a,"f")?this.cleanupCallback():n(this,r,c));const s=i.message;if(c==t(this,a,"f")){for(t(this,e,"f").call(this,s),n(this,a,t(this,a,"f")+1);t(this,a,"f")in t(this,o,"f");){const i=t(this,o,"f")[t(this,a,"f")];t(this,e,"f").call(this,i),delete t(this,o,"f")[t(this,a,"f")],n(this,a,t(this,a,"f")+1)}t(this,a,"f")===t(this,r,"f")&&this.cleanupCallback()}else t(this,o,"f")[c]=s}))}cleanupCallback(){Reflect.deleteProperty(window,`_${this.id}`)}set onmessage(i){n(this,e,i)}get onmessage(){return t(this,e,"f")}[(e=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakMap,c)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[c]()}}class l{constructor(i,t,n){this.plugin=i,this.event=t,this.channelId=n}async unregister(){return f(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}}async function u(i,t,n){const e=new s(n);return f(`plugin:${i}|registerListener`,{event:t,handler:e}).then((()=>new l(i,t,e.id)))}async function f(i,t={},n){return window.__TAURI_INTERNALS__.invoke(i,t,n)}var h,d,w;i.ScheduleEvery=void 0,(h=i.ScheduleEvery||(i.ScheduleEvery={})).Year="year",h.Month="month",h.TwoWeeks="twoWeeks",h.Week="week",h.Day="day",h.Hour="hour",h.Minute="minute",h.Second="second";return i.Importance=void 0,(d=i.Importance||(i.Importance={}))[d.None=0]="None",d[d.Min=1]="Min",d[d.Low=2]="Low",d[d.Default=3]="Default",d[d.High=4]="High",i.Visibility=void 0,(w=i.Visibility||(i.Visibility={}))[w.Secret=-1]="Secret",w[w.Private=0]="Private",w[w.Public=1]="Public",i.Schedule=class{static at(i,t=!1,n=!1){return{at:{date:i,repeating:t,allowWhileIdle:n},interval:void 0,every:void 0}}static interval(i,t=!1){return{at:void 0,interval:{interval:i,allowWhileIdle:t},every:void 0}}static every(i,t,n=!1){return{at:void 0,interval:void 0,every:{interval:i,count:t,allowWhileIdle:n}}}},i.active=async function(){return await f("plugin:notification|get_active")},i.cancel=async function(i){await f("plugin:notification|cancel",{notifications:i})},i.cancelAll=async function(){await f("plugin:notification|cancel")},i.channels=async function(){return await f("plugin:notification|listChannels")},i.createChannel=async function(i){await f("plugin:notification|create_channel",{...i})},i.isPermissionGranted=async function(){return"default"!==window.Notification.permission?await Promise.resolve("granted"===window.Notification.permission):await f("plugin:notification|is_permission_granted")},i.onAction=async function(i){return await u("notification","actionPerformed",i)},i.onNotificationReceived=async function(i){return await u("notification","notification",i)},i.pending=async function(){return await f("plugin:notification|get_pending")},i.registerActionTypes=async function(i){await f("plugin:notification|register_action_types",{types:i})},i.removeActive=async function(i){await f("plugin:notification|remove_active",{notifications:i})},i.removeAllActive=async function(){await f("plugin:notification|remove_active")},i.removeChannel=async function(i){await f("plugin:notification|delete_channel",{id:i})},i.requestPermission=async function(){return await window.Notification.requestPermission()},i.sendNotification=function(i){"string"==typeof i?new window.Notification(i):new window.Notification(i.title,i)},i}({});Object.defineProperty(window.__TAURI__,"notification",{value:__TAURI_PLUGIN_NOTIFICATION__})} diff --git a/plugins/notification/build.rs b/plugins/notification/build.rs index ea12ef85..4b24c755 100644 --- a/plugins/notification/build.rs +++ b/plugins/notification/build.rs @@ -2,16 +2,34 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT +const COMMANDS: &[&str] = &[ + "notify", + "request_permission", + "is_permission_granted", + "register_action_types", + "register_listener", + "cancel", + "get_pending", + "remove_active", + "get_active", + "check_permissions", + "show", + "batch", + "list_channels", + "delete_channel", + "create_channel", + "permission_state", +]; + fn main() { - if let Err(error) = tauri_build::mobile::PluginBuilder::new() + let result = tauri_plugin::Builder::new(COMMANDS) + .global_api_script_path("./api-iife.js") .android_path("android") .ios_path("ios") - .run() - { - 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")) { - std::process::exit(1); - } + .try_build(); + + // when building documentation for Android the plugin build result is always Err() and is irrelevant to the crate documentation build + if !(cfg!(docsrs) && std::env::var("TARGET").unwrap().contains("android")) { + result.unwrap(); } } diff --git a/plugins/notification/guest-js/index.ts b/plugins/notification/guest-js/index.ts index 16ecca7e..9f81a1e1 100644 --- a/plugins/notification/guest-js/index.ts +++ b/plugins/notification/guest-js/index.ts @@ -11,9 +11,11 @@ import { invoke, - PluginListener, - addPluginListener, -} from "@tauri-apps/api/primitives"; + type PluginListener, + addPluginListener +} from '@tauri-apps/api/core' + +export type { PermissionState } from '@tauri-apps/api/core' /** * Options to send a notification. @@ -24,54 +26,54 @@ interface Options { /** * The notification identifier to reference this object later. Must be a 32-bit integer. */ - id?: number; + id?: number /** * Identifier of the {@link Channel} that deliveres this notification. * * If the channel does not exist, the notification won't fire. * Make sure the channel exists with {@link listChannels} and {@link createChannel}. */ - channelId?: string; + channelId?: string /** * Notification title. */ - title: string; + title: string /** * Optional notification body. * */ - body?: string; + body?: string /** * Schedule this notification to fire on a later time or a fixed interval. */ - schedule?: Schedule; + schedule?: Schedule /** * Multiline text. * Changes the notification style to big text. * Cannot be used with `inboxLines`. */ - largeBody?: string; + largeBody?: string /** * Detail text for the notification with `largeBody`, `inboxLines` or `groupSummary`. */ - summary?: string; + summary?: string /** * Defines an action type for this notification. */ - actionTypeId?: string; + actionTypeId?: string /** * Identifier used to group multiple notifications. * * https://developer.apple.com/documentation/usernotifications/unmutablenotificationcontent/1649872-threadidentifier */ - group?: string; + group?: string /** * Instructs the system that this notification is the summary of a group on Android. */ - groupSummary?: boolean; + groupSummary?: boolean /** * The sound resource name. Only available on mobile. */ - sound?: string; + sound?: string /** * List of lines to add to the notification. * Changes the notification style to inbox. @@ -79,31 +81,31 @@ interface Options { * * Only supports up to 5 lines. */ - inboxLines?: string[]; + inboxLines?: string[] /** * Notification icon. * * On Android the icon must be placed in the app's `res/drawable` folder. */ - icon?: string; + icon?: string /** * Notification large icon (Android). * * The icon must be placed in the app's `res/drawable` folder. */ - largeIcon?: string; + largeIcon?: string /** * Icon color on Android. */ - iconColor?: string; + iconColor?: string /** * Notification attachments. */ - attachments?: Attachment[]; + attachments?: Attachment[] /** * Extra payload to store in the notification. */ - extra?: { [key: string]: unknown }; + extra?: Record /** * If true, the notification cannot be dismissed by the user on Android. * @@ -111,29 +113,29 @@ interface Options { * It is typically used to indicate a background task that is pending (e.g. a file download) * or the user is engaged with (e.g. playing music). */ - ongoing?: boolean; + ongoing?: boolean /** * Automatically cancel the notification when the user clicks on it. */ - autoCancel?: boolean; + autoCancel?: boolean /** * Changes the notification presentation to be silent on iOS (no badge, no sound, not listed). */ - silent?: boolean; + silent?: boolean /** * Notification visibility. */ - visibility?: Visibility; + visibility?: Visibility /** * Sets the number of items this notification represents on Android. */ - number?: number; + number?: number } -type ScheduleInterval = { - year?: number; - month?: number; - day?: number; +interface ScheduleInterval { + year?: number + month?: number + day?: number /** * 1 - Sunday * 2 - Monday @@ -143,64 +145,79 @@ type ScheduleInterval = { * 6 - Friday * 7 - Saturday */ - weekday?: number; - hour?: number; - minute?: number; - second?: number; -}; + weekday?: number + hour?: number + minute?: number + second?: number +} 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: { - date: Date; - repeating: boolean; - }; - } - | { - kind: "Interval"; - data: ScheduleInterval; - } - | { - kind: "Every"; - data: { - interval: ScheduleEvery; - }; - }; - class Schedule { - kind: string; - data: unknown; - - private constructor(schedule: ScheduleData) { - this.kind = schedule.kind; - this.data = schedule.data; - } - - static at(date: Date, repeating = false) { - return new Schedule({ kind: "At", data: { date, repeating } }); + at: + | { + date: Date + repeating: boolean + allowWhileIdle: boolean + } + | undefined + + interval: + | { + interval: ScheduleInterval + allowWhileIdle: boolean + } + | undefined + + every: + | { + interval: ScheduleEvery + count: number + allowWhileIdle: boolean + } + | undefined + + static at(date: Date, repeating = false, allowWhileIdle = false): Schedule { + return { + at: { date, repeating, allowWhileIdle }, + interval: undefined, + every: undefined + } } - static interval(interval: ScheduleInterval) { - return new Schedule({ kind: "Interval", data: interval }); + static interval( + interval: ScheduleInterval, + allowWhileIdle = false + ): Schedule { + return { + at: undefined, + interval: { interval, allowWhileIdle }, + every: undefined + } } - static every(kind: ScheduleEvery) { - return new Schedule({ kind: "Every", data: { interval: kind } }); + static every( + kind: ScheduleEvery, + count: number, + allowWhileIdle = false + ): Schedule { + return { + at: undefined, + interval: undefined, + every: { interval: kind, count, allowWhileIdle } + } } } @@ -209,58 +226,58 @@ class Schedule { */ interface Attachment { /** Attachment identifier. */ - id: string; + id: string /** Attachment URL. Accepts the `asset` and `file` protocols. */ - url: string; + url: string } interface Action { - id: string; - title: string; - requiresAuthentication?: boolean; - foreground?: boolean; - destructive?: boolean; - input?: boolean; - inputButtonTitle?: string; - inputPlaceholder?: string; + id: string + title: string + requiresAuthentication?: boolean + foreground?: boolean + destructive?: boolean + input?: boolean + inputButtonTitle?: string + inputPlaceholder?: string } interface ActionType { /** * The identifier of this action type */ - id: string; + id: string /** * The list of associated actions */ - actions: Action[]; - hiddenPreviewsBodyPlaceholder?: string; - customDismissAction?: boolean; - allowInCarPlay?: boolean; - hiddenPreviewsShowTitle?: boolean; - hiddenPreviewsShowSubtitle?: boolean; + actions: Action[] + hiddenPreviewsBodyPlaceholder?: string + customDismissAction?: boolean + allowInCarPlay?: boolean + hiddenPreviewsShowTitle?: boolean + hiddenPreviewsShowSubtitle?: boolean } interface PendingNotification { - id: number; - title?: string; - body?: string; - schedule: Schedule; + id: number + title?: string + body?: string + schedule: Schedule } interface ActiveNotification { - id: number; - tag?: string; - title?: string; - body?: string; - group?: string; - groupSummary: boolean; - data: Record; - extra: Record; - attachments: Attachment[]; - actionTypeId?: string; - schedule?: Schedule; - sound?: string; + id: number + tag?: string + title?: string + body?: string + group?: string + groupSummary: boolean + data: Record + extra: Record + attachments: Attachment[] + actionTypeId?: string + schedule?: Schedule + sound?: string } enum Importance { @@ -268,30 +285,27 @@ enum Importance { Min, Low, Default, - High, + High } enum Visibility { Secret = -1, Private, - Public, + Public } interface Channel { - id: string; - name: string; - description?: string; - sound?: string; - lights?: boolean; - lightColor?: string; - vibration?: boolean; - importance?: Importance; - visibility?: Visibility; + id: string + name: string + description?: string + sound?: string + lights?: boolean + lightColor?: string + vibration?: boolean + importance?: Importance + visibility?: Visibility } -/** Possible permission values. */ -type Permission = "granted" | "denied" | "default"; - /** * Checks if the permission to send notifications is granted. * @example @@ -303,10 +317,10 @@ type Permission = "granted" | "denied" | "default"; * @since 2.0.0 */ async function isPermissionGranted(): Promise { - if (window.Notification.permission !== "default") { - return Promise.resolve(window.Notification.permission === "granted"); + if (window.Notification.permission !== 'default') { + return await Promise.resolve(window.Notification.permission === 'granted') } - return invoke("plugin:notification|is_permission_granted"); + return await invoke('plugin:notification|is_permission_granted') } /** @@ -325,8 +339,8 @@ async function isPermissionGranted(): Promise { * * @since 2.0.0 */ -async function requestPermission(): Promise { - return window.Notification.requestPermission(); +async function requestPermission(): Promise { + return await window.Notification.requestPermission() } /** @@ -348,12 +362,10 @@ async function requestPermission(): Promise { * @since 2.0.0 */ function sendNotification(options: Options | string): void { - if (typeof options === "string") { - // eslint-disable-next-line no-new - new window.Notification(options); + if (typeof options === 'string') { + new window.Notification(options) } else { - // eslint-disable-next-line no-new - new window.Notification(options.title, options); + new window.Notification(options.title, options) } } @@ -377,7 +389,7 @@ function sendNotification(options: Options | string): void { * @since 2.0.0 */ async function registerActionTypes(types: ActionType[]): Promise { - return invoke("plugin:notification|register_action_types", { types }); + await invoke('plugin:notification|register_action_types', { types }) } /** @@ -394,7 +406,7 @@ async function registerActionTypes(types: ActionType[]): Promise { * @since 2.0.0 */ async function pending(): Promise { - return invoke("plugin:notification|get_pending"); + return await invoke('plugin:notification|get_pending') } /** @@ -411,7 +423,7 @@ async function pending(): Promise { * @since 2.0.0 */ async function cancel(notifications: number[]): Promise { - return invoke("plugin:notification|cancel", { notifications }); + await invoke('plugin:notification|cancel', { notifications }) } /** @@ -428,7 +440,7 @@ async function cancel(notifications: number[]): Promise { * @since 2.0.0 */ async function cancelAll(): Promise { - return invoke("plugin:notification|cancel"); + await invoke('plugin:notification|cancel') } /** @@ -445,7 +457,7 @@ async function cancelAll(): Promise { * @since 2.0.0 */ async function active(): Promise { - return invoke("plugin:notification|get_active"); + return await invoke('plugin:notification|get_active') } /** @@ -461,8 +473,10 @@ async function active(): Promise { * * @since 2.0.0 */ -async function removeActive(notifications: number[]): Promise { - return invoke("plugin:notification|remove_active", { notifications }); +async function removeActive( + notifications: Array<{ id: number; tag?: string }> +): Promise { + await invoke('plugin:notification|remove_active', { notifications }) } /** @@ -479,11 +493,11 @@ async function removeActive(notifications: number[]): Promise { * @since 2.0.0 */ async function removeAllActive(): Promise { - return invoke("plugin:notification|remove_active"); + await invoke('plugin:notification|remove_active') } /** - * Removes all active notifications. + * Creates a notification channel. * * @example * ```typescript @@ -503,7 +517,7 @@ async function removeAllActive(): Promise { * @since 2.0.0 */ async function createChannel(channel: Channel): Promise { - return invoke("plugin:notification|create_channel", { ...channel }); + await invoke('plugin:notification|create_channel', { ...channel }) } /** @@ -520,7 +534,7 @@ async function createChannel(channel: Channel): Promise { * @since 2.0.0 */ async function removeChannel(id: string): Promise { - return invoke("plugin:notification|delete_channel", { id }); + await invoke('plugin:notification|delete_channel', { id }) } /** @@ -537,31 +551,31 @@ async function removeChannel(id: string): Promise { * @since 2.0.0 */ async function channels(): Promise { - return invoke("plugin:notification|getActive"); + return await invoke('plugin:notification|listChannels') } async function onNotificationReceived( - cb: (notification: Options) => void, + cb: (notification: Options) => void ): Promise { - return addPluginListener("notification", "notification", cb); + return await addPluginListener('notification', 'notification', cb) } async function onAction( - cb: (notification: Options) => void, + cb: (notification: Options) => void ): Promise { - return addPluginListener("notification", "actionPerformed", cb); + return await addPluginListener('notification', 'actionPerformed', cb) } export type { Attachment, Options, - Permission, Action, ActionType, PendingNotification, ActiveNotification, Channel, -}; + ScheduleInterval +} export { Importance, @@ -581,4 +595,6 @@ export { channels, onNotificationReceived, onAction, -}; + Schedule, + ScheduleEvery +} diff --git a/plugins/notification/guest-js/init.ts b/plugins/notification/guest-js/init.ts index 7296ea12..42d65fd9 100644 --- a/plugins/notification/guest-js/init.ts +++ b/plugins/notification/guest-js/init.ts @@ -2,82 +2,89 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { invoke } from "@tauri-apps/api/primitives"; -import type { Options } from "./index"; +import { invoke } from '@tauri-apps/api/core' +import type { PermissionState } from '@tauri-apps/api/core' +import type { Options } from './index' +;(function () { + let permissionSettable = false + let permissionValue = 'default' -(function () { - let permissionSettable = false; - let permissionValue = "default"; - - function isPermissionGranted() { - if (window.Notification.permission !== "default") { - return Promise.resolve(window.Notification.permission === "granted"); + async function isPermissionGranted(): Promise { + // @ts-expect-error __TEMPLATE_windows__ will be replaced in rust before it's injected. + if (window.Notification.permission !== 'default' || __TEMPLATE_windows__) { + return await Promise.resolve(window.Notification.permission === 'granted') } - return invoke("plugin:notification|is_permission_granted"); + return await invoke('plugin:notification|is_permission_granted') } - function setNotificationPermission(value: "granted" | "denied" | "default") { - permissionSettable = true; + function setNotificationPermission(value: NotificationPermission): void { + permissionSettable = true // @ts-expect-error we can actually set this value on the webview - window.Notification.permission = value; - permissionSettable = false; + window.Notification.permission = value + permissionSettable = false } - function requestPermission() { - return invoke<"prompt" | "default" | "granted" | "denied">( - "plugin:notification|request_permission", + async function requestPermission(): Promise { + return await invoke( + 'plugin:notification|request_permission' ).then((permission) => { setNotificationPermission( - permission === "prompt" ? "default" : permission, - ); - return permission; - }); + permission === 'prompt' || permission === 'prompt-with-rationale' + ? 'default' + : permission + ) + return permission + }) } - function sendNotification(options: string | Options) { - if (typeof options === "object") { - Object.freeze(options); + async function sendNotification(options: string | Options): Promise { + if (typeof options === 'object') { + Object.freeze(options) } - return invoke("plugin:notification|notify", { + await invoke('plugin:notification|notify', { options: - typeof options === "string" + typeof options === 'string' ? { - title: options, + title: options } - : options, - }); + : options + }) } // @ts-expect-error unfortunately we can't implement the whole type, so we overwrite it with our own version window.Notification = function (title, options) { - const opts = options || {}; - sendNotification( + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment + const opts = options || {} + void sendNotification( + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument Object.assign(opts, { - title, - }), - ); - }; + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment + title + }) + ) + } // @ts-expect-error tauri does not have sync IPC :( - window.Notification.requestPermission = requestPermission; + window.Notification.requestPermission = requestPermission - Object.defineProperty(window.Notification, "permission", { + Object.defineProperty(window.Notification, 'permission', { enumerable: true, get: () => permissionValue, set: (v) => { if (!permissionSettable) { - throw new Error("Readonly property"); + throw new Error('Readonly property') } - permissionValue = v; - }, - }); + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment + permissionValue = v + } + }) - isPermissionGranted().then(function (response) { + void isPermissionGranted().then(function (response) { if (response === null) { - setNotificationPermission("default"); + setNotificationPermission('default') } else { - setNotificationPermission(response ? "granted" : "denied"); + setNotificationPermission(response ? 'granted' : 'denied') } - }); -})(); + }) +})() diff --git a/plugins/notification/ios/Package.swift b/plugins/notification/ios/Package.swift index 1a2c4801..bbd6df9e 100644 --- a/plugins/notification/ios/Package.swift +++ b/plugins/notification/ios/Package.swift @@ -1,35 +1,34 @@ -// 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 - - import PackageDescription let package = Package( - name: "tauri-plugin-notification", - platforms: [ - .iOS(.v13), - ], - products: [ - // Products define the executables and libraries a package produces, and make them visible to other packages. - .library( - name: "tauri-plugin-notification", - type: .static, - targets: ["tauri-plugin-notification"]), - ], - dependencies: [ - .package(name: "Tauri", path: "../.tauri/tauri-api") - ], - targets: [ - // Targets are the basic building blocks of a package. A target can define a module or a test suite. - // Targets can depend on other targets in this package, and on products in packages this package depends on. - .target( - name: "tauri-plugin-notification", - dependencies: [ - .byName(name: "Tauri") - ], - path: "Sources") - ] + name: "tauri-plugin-notification", + platforms: [ + .macOS(.v10_13), + .iOS(.v13), + ], + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .library( + name: "tauri-plugin-notification", + type: .static, + targets: ["tauri-plugin-notification"]) + ], + dependencies: [ + .package(name: "Tauri", path: "../.tauri/tauri-api") + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .target( + name: "tauri-plugin-notification", + dependencies: [ + .byName(name: "Tauri") + ], + path: "Sources") + ] ) diff --git a/plugins/notification/ios/Sources/Notification.swift b/plugins/notification/ios/Sources/Notification.swift index e6f0d077..adba05ec 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,58 @@ 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.body = NSString.localizedUserNotificationString( - forKey: body, - arguments: nil) + content.title = NSString.localizedUserNotificationString( + forKey: notification.title, arguments: nil) + if let body = notification.body { + content.body = NSString.localizedUserNotificationString( + forKey: 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 +93,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 +133,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 +156,6 @@ func handleScheduledNotification(_ schedule: JSObject) throws return UNTimeIntervalNotificationTrigger( timeInterval: repeatDateInterval.duration, repeats: true) } - - default: - return nil } return nil @@ -209,30 +164,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 +197,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 ae37ffc3..f796e03a 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 ?? false { + 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 ?? false { return .foreground } - if destructive { + if action.destructive ?? false { return .destructive } - if requiresAuthentication { + if action.requiresAuthentication ?? false { 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 ?? false { return .customDismissAction } - if carPlay { + if type.allowInCarPlay ?? false { return .allowInCarPlay } - if hiddenPreviewsShowTitle { + if type.hiddenPreviewsShowTitle ?? false { return .hiddenPreviewsShowTitle } - if hiddenPreviewsShowSubtitle { + if type.hiddenPreviewsShowSubtitle ?? false { return .hiddenPreviewsShowSubtitle } diff --git a/plugins/notification/ios/Sources/NotificationHandler.swift b/plugins/notification/ios/Sources/NotificationHandler.swift index ac569bdf..1bf134b6 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 ?? false { 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 183b4dd5..81a585bf 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 2f431c73..6d8391bc 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 { + var year: Int? + var month: Int? + var day: Int? + var weekday: Int? + var hour: Int? + var minute: Int? + var 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]? + var schedule: NotificationSchedule? + var attachments: [NotificationAttachment]? + var sound: String? + var group: String? + var actionTypeId: String? + var summary: String? + var silent: Bool? +} + +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? + var foreground: Bool? + var destructive: Bool? + var input: Bool? + var inputButtonTitle: String? + var inputPlaceholder: String? +} + +struct ActionType: Decodable { + let id: String + let actions: [Action] + var hiddenPreviewsBodyPlaceholder: String? + var customDismissAction: Bool? + var allowInCarPlay: Bool? + var hiddenPreviewsShowTitle: Bool? + var hiddenPreviewsShowSubtitle: Bool? + var 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 c1c0058e..07c04d5c 100644 --- a/plugins/notification/package.json +++ b/plugins/notification/package.json @@ -1,32 +1,29 @@ { "name": "@tauri-apps/plugin-notification", - "version": "2.0.0-alpha.1", - "license": "MIT or APACHE-2.0", + "version": "2.2.2", + "license": "MIT OR Apache-2.0", "authors": [ "Tauri Programme within The Commons Conservancy" ], + "repository": "https://github.com/tauri-apps/plugins-workspace", "type": "module", - "browser": "dist-js/index.min.js", - "module": "dist-js/index.mjs", - "types": "dist-js/index.d.ts", + "types": "./dist-js/index.d.ts", + "main": "./dist-js/index.cjs", + "module": "./dist-js/index.js", "exports": { - "import": "./dist-js/index.mjs", "types": "./dist-js/index.d.ts", - "browser": "./dist-js/index.min.js" + "import": "./dist-js/index.js", + "require": "./dist-js/index.cjs" }, "scripts": { "build": "rollup -c" }, "files": [ "dist-js", - "!dist-js/**/*.map", "README.md", "LICENSE" ], - "devDependencies": { - "tslib": "^2.4.1" - }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.9" + "@tauri-apps/api": "^2.0.0" } } diff --git a/plugins/notification/permissions/autogenerated/commands/batch.toml b/plugins/notification/permissions/autogenerated/commands/batch.toml new file mode 100644 index 00000000..c52cc16d --- /dev/null +++ b/plugins/notification/permissions/autogenerated/commands/batch.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-batch" +description = "Enables the batch command without any pre-configured scope." +commands.allow = ["batch"] + +[[permission]] +identifier = "deny-batch" +description = "Denies the batch command without any pre-configured scope." +commands.deny = ["batch"] diff --git a/plugins/notification/permissions/autogenerated/commands/cancel.toml b/plugins/notification/permissions/autogenerated/commands/cancel.toml new file mode 100644 index 00000000..91efeaa0 --- /dev/null +++ b/plugins/notification/permissions/autogenerated/commands/cancel.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-cancel" +description = "Enables the cancel command without any pre-configured scope." +commands.allow = ["cancel"] + +[[permission]] +identifier = "deny-cancel" +description = "Denies the cancel command without any pre-configured scope." +commands.deny = ["cancel"] diff --git a/plugins/notification/permissions/autogenerated/commands/check_permissions.toml b/plugins/notification/permissions/autogenerated/commands/check_permissions.toml new file mode 100644 index 00000000..f5af08b1 --- /dev/null +++ b/plugins/notification/permissions/autogenerated/commands/check_permissions.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-check-permissions" +description = "Enables the check_permissions command without any pre-configured scope." +commands.allow = ["check_permissions"] + +[[permission]] +identifier = "deny-check-permissions" +description = "Denies the check_permissions command without any pre-configured scope." +commands.deny = ["check_permissions"] diff --git a/plugins/notification/permissions/autogenerated/commands/create_channel.toml b/plugins/notification/permissions/autogenerated/commands/create_channel.toml new file mode 100644 index 00000000..2c931474 --- /dev/null +++ b/plugins/notification/permissions/autogenerated/commands/create_channel.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-create-channel" +description = "Enables the create_channel command without any pre-configured scope." +commands.allow = ["create_channel"] + +[[permission]] +identifier = "deny-create-channel" +description = "Denies the create_channel command without any pre-configured scope." +commands.deny = ["create_channel"] diff --git a/plugins/notification/permissions/autogenerated/commands/delete_channel.toml b/plugins/notification/permissions/autogenerated/commands/delete_channel.toml new file mode 100644 index 00000000..0adaf2bb --- /dev/null +++ b/plugins/notification/permissions/autogenerated/commands/delete_channel.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-delete-channel" +description = "Enables the delete_channel command without any pre-configured scope." +commands.allow = ["delete_channel"] + +[[permission]] +identifier = "deny-delete-channel" +description = "Denies the delete_channel command without any pre-configured scope." +commands.deny = ["delete_channel"] diff --git a/plugins/notification/permissions/autogenerated/commands/get_active.toml b/plugins/notification/permissions/autogenerated/commands/get_active.toml new file mode 100644 index 00000000..b841eb85 --- /dev/null +++ b/plugins/notification/permissions/autogenerated/commands/get_active.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-get-active" +description = "Enables the get_active command without any pre-configured scope." +commands.allow = ["get_active"] + +[[permission]] +identifier = "deny-get-active" +description = "Denies the get_active command without any pre-configured scope." +commands.deny = ["get_active"] diff --git a/plugins/notification/permissions/autogenerated/commands/get_pending.toml b/plugins/notification/permissions/autogenerated/commands/get_pending.toml new file mode 100644 index 00000000..f3bae7a8 --- /dev/null +++ b/plugins/notification/permissions/autogenerated/commands/get_pending.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-get-pending" +description = "Enables the get_pending command without any pre-configured scope." +commands.allow = ["get_pending"] + +[[permission]] +identifier = "deny-get-pending" +description = "Denies the get_pending command without any pre-configured scope." +commands.deny = ["get_pending"] diff --git a/plugins/notification/permissions/autogenerated/commands/is_permission_granted.toml b/plugins/notification/permissions/autogenerated/commands/is_permission_granted.toml new file mode 100644 index 00000000..5faa73f3 --- /dev/null +++ b/plugins/notification/permissions/autogenerated/commands/is_permission_granted.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-is-permission-granted" +description = "Enables the is_permission_granted command without any pre-configured scope." +commands.allow = ["is_permission_granted"] + +[[permission]] +identifier = "deny-is-permission-granted" +description = "Denies the is_permission_granted command without any pre-configured scope." +commands.deny = ["is_permission_granted"] diff --git a/plugins/notification/permissions/autogenerated/commands/list_channels.toml b/plugins/notification/permissions/autogenerated/commands/list_channels.toml new file mode 100644 index 00000000..cb20cd57 --- /dev/null +++ b/plugins/notification/permissions/autogenerated/commands/list_channels.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-list-channels" +description = "Enables the list_channels command without any pre-configured scope." +commands.allow = ["list_channels"] + +[[permission]] +identifier = "deny-list-channels" +description = "Denies the list_channels command without any pre-configured scope." +commands.deny = ["list_channels"] diff --git a/plugins/notification/permissions/autogenerated/commands/notify.toml b/plugins/notification/permissions/autogenerated/commands/notify.toml new file mode 100644 index 00000000..7d6d46c2 --- /dev/null +++ b/plugins/notification/permissions/autogenerated/commands/notify.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-notify" +description = "Enables the notify command without any pre-configured scope." +commands.allow = ["notify"] + +[[permission]] +identifier = "deny-notify" +description = "Denies the notify command without any pre-configured scope." +commands.deny = ["notify"] diff --git a/plugins/notification/permissions/autogenerated/commands/permission_state.toml b/plugins/notification/permissions/autogenerated/commands/permission_state.toml new file mode 100644 index 00000000..dddcd86f --- /dev/null +++ b/plugins/notification/permissions/autogenerated/commands/permission_state.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-permission-state" +description = "Enables the permission_state command without any pre-configured scope." +commands.allow = ["permission_state"] + +[[permission]] +identifier = "deny-permission-state" +description = "Denies the permission_state command without any pre-configured scope." +commands.deny = ["permission_state"] diff --git a/plugins/notification/permissions/autogenerated/commands/register_action_types.toml b/plugins/notification/permissions/autogenerated/commands/register_action_types.toml new file mode 100644 index 00000000..cb5aa89f --- /dev/null +++ b/plugins/notification/permissions/autogenerated/commands/register_action_types.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-register-action-types" +description = "Enables the register_action_types command without any pre-configured scope." +commands.allow = ["register_action_types"] + +[[permission]] +identifier = "deny-register-action-types" +description = "Denies the register_action_types command without any pre-configured scope." +commands.deny = ["register_action_types"] diff --git a/plugins/notification/permissions/autogenerated/commands/register_listener.toml b/plugins/notification/permissions/autogenerated/commands/register_listener.toml new file mode 100644 index 00000000..48363c0d --- /dev/null +++ b/plugins/notification/permissions/autogenerated/commands/register_listener.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-register-listener" +description = "Enables the register_listener command without any pre-configured scope." +commands.allow = ["register_listener"] + +[[permission]] +identifier = "deny-register-listener" +description = "Denies the register_listener command without any pre-configured scope." +commands.deny = ["register_listener"] diff --git a/plugins/notification/permissions/autogenerated/commands/remove_active.toml b/plugins/notification/permissions/autogenerated/commands/remove_active.toml new file mode 100644 index 00000000..9ad2add1 --- /dev/null +++ b/plugins/notification/permissions/autogenerated/commands/remove_active.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-remove-active" +description = "Enables the remove_active command without any pre-configured scope." +commands.allow = ["remove_active"] + +[[permission]] +identifier = "deny-remove-active" +description = "Denies the remove_active command without any pre-configured scope." +commands.deny = ["remove_active"] diff --git a/plugins/notification/permissions/autogenerated/commands/request_permission.toml b/plugins/notification/permissions/autogenerated/commands/request_permission.toml new file mode 100644 index 00000000..0b410d6a --- /dev/null +++ b/plugins/notification/permissions/autogenerated/commands/request_permission.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-request-permission" +description = "Enables the request_permission command without any pre-configured scope." +commands.allow = ["request_permission"] + +[[permission]] +identifier = "deny-request-permission" +description = "Denies the request_permission command without any pre-configured scope." +commands.deny = ["request_permission"] diff --git a/plugins/notification/permissions/autogenerated/commands/show.toml b/plugins/notification/permissions/autogenerated/commands/show.toml new file mode 100644 index 00000000..3d4cbf38 --- /dev/null +++ b/plugins/notification/permissions/autogenerated/commands/show.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-show" +description = "Enables the show command without any pre-configured scope." +commands.allow = ["show"] + +[[permission]] +identifier = "deny-show" +description = "Denies the show command without any pre-configured scope." +commands.deny = ["show"] diff --git a/plugins/notification/permissions/autogenerated/reference.md b/plugins/notification/permissions/autogenerated/reference.md new file mode 100644 index 00000000..7186a421 --- /dev/null +++ b/plugins/notification/permissions/autogenerated/reference.md @@ -0,0 +1,455 @@ +## Default Permission + +This permission set configures which +notification features are by default exposed. + +#### Granted Permissions + +It allows all notification related features. + + + +#### This default permission set includes the following: + +- `allow-is-permission-granted` +- `allow-request-permission` +- `allow-notify` +- `allow-register-action-types` +- `allow-register-listener` +- `allow-cancel` +- `allow-get-pending` +- `allow-remove-active` +- `allow-get-active` +- `allow-check-permissions` +- `allow-show` +- `allow-batch` +- `allow-list-channels` +- `allow-delete-channel` +- `allow-create-channel` +- `allow-permission-state` + +## Permission Table + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IdentifierDescription
+ +`notification:allow-batch` + + + +Enables the batch command without any pre-configured scope. + +
+ +`notification:deny-batch` + + + +Denies the batch command without any pre-configured scope. + +
+ +`notification:allow-cancel` + + + +Enables the cancel command without any pre-configured scope. + +
+ +`notification:deny-cancel` + + + +Denies the cancel command without any pre-configured scope. + +
+ +`notification:allow-check-permissions` + + + +Enables the check_permissions command without any pre-configured scope. + +
+ +`notification:deny-check-permissions` + + + +Denies the check_permissions command without any pre-configured scope. + +
+ +`notification:allow-create-channel` + + + +Enables the create_channel command without any pre-configured scope. + +
+ +`notification:deny-create-channel` + + + +Denies the create_channel command without any pre-configured scope. + +
+ +`notification:allow-delete-channel` + + + +Enables the delete_channel command without any pre-configured scope. + +
+ +`notification:deny-delete-channel` + + + +Denies the delete_channel command without any pre-configured scope. + +
+ +`notification:allow-get-active` + + + +Enables the get_active command without any pre-configured scope. + +
+ +`notification:deny-get-active` + + + +Denies the get_active command without any pre-configured scope. + +
+ +`notification:allow-get-pending` + + + +Enables the get_pending command without any pre-configured scope. + +
+ +`notification:deny-get-pending` + + + +Denies the get_pending command without any pre-configured scope. + +
+ +`notification:allow-is-permission-granted` + + + +Enables the is_permission_granted command without any pre-configured scope. + +
+ +`notification:deny-is-permission-granted` + + + +Denies the is_permission_granted command without any pre-configured scope. + +
+ +`notification:allow-list-channels` + + + +Enables the list_channels command without any pre-configured scope. + +
+ +`notification:deny-list-channels` + + + +Denies the list_channels command without any pre-configured scope. + +
+ +`notification:allow-notify` + + + +Enables the notify command without any pre-configured scope. + +
+ +`notification:deny-notify` + + + +Denies the notify command without any pre-configured scope. + +
+ +`notification:allow-permission-state` + + + +Enables the permission_state command without any pre-configured scope. + +
+ +`notification:deny-permission-state` + + + +Denies the permission_state command without any pre-configured scope. + +
+ +`notification:allow-register-action-types` + + + +Enables the register_action_types command without any pre-configured scope. + +
+ +`notification:deny-register-action-types` + + + +Denies the register_action_types command without any pre-configured scope. + +
+ +`notification:allow-register-listener` + + + +Enables the register_listener command without any pre-configured scope. + +
+ +`notification:deny-register-listener` + + + +Denies the register_listener command without any pre-configured scope. + +
+ +`notification:allow-remove-active` + + + +Enables the remove_active command without any pre-configured scope. + +
+ +`notification:deny-remove-active` + + + +Denies the remove_active command without any pre-configured scope. + +
+ +`notification:allow-request-permission` + + + +Enables the request_permission command without any pre-configured scope. + +
+ +`notification:deny-request-permission` + + + +Denies the request_permission command without any pre-configured scope. + +
+ +`notification:allow-show` + + + +Enables the show command without any pre-configured scope. + +
+ +`notification:deny-show` + + + +Denies the show command without any pre-configured scope. + +
diff --git a/plugins/notification/permissions/default.toml b/plugins/notification/permissions/default.toml new file mode 100644 index 00000000..00b4e1d0 --- /dev/null +++ b/plugins/notification/permissions/default.toml @@ -0,0 +1,30 @@ +"$schema" = "schemas/schema.json" +[default] +description = """ +This permission set configures which +notification features are by default exposed. + +#### Granted Permissions + +It allows all notification related features. + +""" + +permissions = [ + "allow-is-permission-granted", + "allow-request-permission", + "allow-notify", + "allow-register-action-types", + "allow-register-listener", + "allow-cancel", + "allow-get-pending", + "allow-remove-active", + "allow-get-active", + "allow-check-permissions", + "allow-show", + "allow-batch", + "allow-list-channels", + "allow-delete-channel", + "allow-create-channel", + "allow-permission-state", +] diff --git a/plugins/notification/permissions/schemas/schema.json b/plugins/notification/permissions/schemas/schema.json new file mode 100644 index 00000000..26703a8a --- /dev/null +++ b/plugins/notification/permissions/schemas/schema.json @@ -0,0 +1,498 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "PermissionFile", + "description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.", + "type": "object", + "properties": { + "default": { + "description": "The default permission set for the plugin", + "anyOf": [ + { + "$ref": "#/definitions/DefaultPermission" + }, + { + "type": "null" + } + ] + }, + "set": { + "description": "A list of permissions sets defined", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionSet" + } + }, + "permission": { + "description": "A list of inlined permissions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Permission" + } + } + }, + "definitions": { + "DefaultPermission": { + "description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.", + "type": "object", + "required": [ + "permissions" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "PermissionSet": { + "description": "A set of direct permissions grouped together under a new name.", + "type": "object", + "required": [ + "description", + "identifier", + "permissions" + ], + "properties": { + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does.", + "type": "string" + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionKind" + } + } + } + }, + "Permission": { + "description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.", + "type": "object", + "required": [ + "identifier" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri internal convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "commands": { + "description": "Allowed or denied commands when using this permission.", + "default": { + "allow": [], + "deny": [] + }, + "allOf": [ + { + "$ref": "#/definitions/Commands" + } + ] + }, + "scope": { + "description": "Allowed or denied scoped when using this permission.", + "allOf": [ + { + "$ref": "#/definitions/Scopes" + } + ] + }, + "platforms": { + "description": "Target platforms this permission applies. By default all platforms are affected by this permission.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Target" + } + } + } + }, + "Commands": { + "description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.", + "type": "object", + "properties": { + "allow": { + "description": "Allowed command.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "deny": { + "description": "Denied command, which takes priority.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "Scopes": { + "description": "An argument for fine grained behavior control of Tauri commands.\n\nIt can be of any serde serializable type and is used to allow or prevent certain actions inside a Tauri command. The configured scope is passed to the command and will be enforced by the command implementation.\n\n## Example\n\n```json { \"allow\": [{ \"path\": \"$HOME/**\" }], \"deny\": [{ \"path\": \"$HOME/secret.txt\" }] } ```", + "type": "object", + "properties": { + "allow": { + "description": "Data that defines what is allowed by the scope.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + }, + "deny": { + "description": "Data that defines what is denied by the scope. This should be prioritized by validation logic.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + } + } + }, + "Value": { + "description": "All supported ACL values.", + "anyOf": [ + { + "description": "Represents a null JSON value.", + "type": "null" + }, + { + "description": "Represents a [`bool`].", + "type": "boolean" + }, + { + "description": "Represents a valid ACL [`Number`].", + "allOf": [ + { + "$ref": "#/definitions/Number" + } + ] + }, + { + "description": "Represents a [`String`].", + "type": "string" + }, + { + "description": "Represents a list of other [`Value`]s.", + "type": "array", + "items": { + "$ref": "#/definitions/Value" + } + }, + { + "description": "Represents a map of [`String`] keys to [`Value`]s.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/Value" + } + } + ] + }, + "Number": { + "description": "A valid ACL number.", + "anyOf": [ + { + "description": "Represents an [`i64`].", + "type": "integer", + "format": "int64" + }, + { + "description": "Represents a [`f64`].", + "type": "number", + "format": "double" + } + ] + }, + "Target": { + "description": "Platform target.", + "oneOf": [ + { + "description": "MacOS.", + "type": "string", + "enum": [ + "macOS" + ] + }, + { + "description": "Windows.", + "type": "string", + "enum": [ + "windows" + ] + }, + { + "description": "Linux.", + "type": "string", + "enum": [ + "linux" + ] + }, + { + "description": "Android.", + "type": "string", + "enum": [ + "android" + ] + }, + { + "description": "iOS.", + "type": "string", + "enum": [ + "iOS" + ] + } + ] + }, + "PermissionKind": { + "type": "string", + "oneOf": [ + { + "description": "Enables the batch command without any pre-configured scope.", + "type": "string", + "const": "allow-batch", + "markdownDescription": "Enables the batch command without any pre-configured scope." + }, + { + "description": "Denies the batch command without any pre-configured scope.", + "type": "string", + "const": "deny-batch", + "markdownDescription": "Denies the batch command without any pre-configured scope." + }, + { + "description": "Enables the cancel command without any pre-configured scope.", + "type": "string", + "const": "allow-cancel", + "markdownDescription": "Enables the cancel command without any pre-configured scope." + }, + { + "description": "Denies the cancel command without any pre-configured scope.", + "type": "string", + "const": "deny-cancel", + "markdownDescription": "Denies the cancel command without any pre-configured scope." + }, + { + "description": "Enables the check_permissions command without any pre-configured scope.", + "type": "string", + "const": "allow-check-permissions", + "markdownDescription": "Enables the check_permissions command without any pre-configured scope." + }, + { + "description": "Denies the check_permissions command without any pre-configured scope.", + "type": "string", + "const": "deny-check-permissions", + "markdownDescription": "Denies the check_permissions command without any pre-configured scope." + }, + { + "description": "Enables the create_channel command without any pre-configured scope.", + "type": "string", + "const": "allow-create-channel", + "markdownDescription": "Enables the create_channel command without any pre-configured scope." + }, + { + "description": "Denies the create_channel command without any pre-configured scope.", + "type": "string", + "const": "deny-create-channel", + "markdownDescription": "Denies the create_channel command without any pre-configured scope." + }, + { + "description": "Enables the delete_channel command without any pre-configured scope.", + "type": "string", + "const": "allow-delete-channel", + "markdownDescription": "Enables the delete_channel command without any pre-configured scope." + }, + { + "description": "Denies the delete_channel command without any pre-configured scope.", + "type": "string", + "const": "deny-delete-channel", + "markdownDescription": "Denies the delete_channel command without any pre-configured scope." + }, + { + "description": "Enables the get_active command without any pre-configured scope.", + "type": "string", + "const": "allow-get-active", + "markdownDescription": "Enables the get_active command without any pre-configured scope." + }, + { + "description": "Denies the get_active command without any pre-configured scope.", + "type": "string", + "const": "deny-get-active", + "markdownDescription": "Denies the get_active command without any pre-configured scope." + }, + { + "description": "Enables the get_pending command without any pre-configured scope.", + "type": "string", + "const": "allow-get-pending", + "markdownDescription": "Enables the get_pending command without any pre-configured scope." + }, + { + "description": "Denies the get_pending command without any pre-configured scope.", + "type": "string", + "const": "deny-get-pending", + "markdownDescription": "Denies the get_pending command without any pre-configured scope." + }, + { + "description": "Enables the is_permission_granted command without any pre-configured scope.", + "type": "string", + "const": "allow-is-permission-granted", + "markdownDescription": "Enables the is_permission_granted command without any pre-configured scope." + }, + { + "description": "Denies the is_permission_granted command without any pre-configured scope.", + "type": "string", + "const": "deny-is-permission-granted", + "markdownDescription": "Denies the is_permission_granted command without any pre-configured scope." + }, + { + "description": "Enables the list_channels command without any pre-configured scope.", + "type": "string", + "const": "allow-list-channels", + "markdownDescription": "Enables the list_channels command without any pre-configured scope." + }, + { + "description": "Denies the list_channels command without any pre-configured scope.", + "type": "string", + "const": "deny-list-channels", + "markdownDescription": "Denies the list_channels command without any pre-configured scope." + }, + { + "description": "Enables the notify command without any pre-configured scope.", + "type": "string", + "const": "allow-notify", + "markdownDescription": "Enables the notify command without any pre-configured scope." + }, + { + "description": "Denies the notify command without any pre-configured scope.", + "type": "string", + "const": "deny-notify", + "markdownDescription": "Denies the notify command without any pre-configured scope." + }, + { + "description": "Enables the permission_state command without any pre-configured scope.", + "type": "string", + "const": "allow-permission-state", + "markdownDescription": "Enables the permission_state command without any pre-configured scope." + }, + { + "description": "Denies the permission_state command without any pre-configured scope.", + "type": "string", + "const": "deny-permission-state", + "markdownDescription": "Denies the permission_state command without any pre-configured scope." + }, + { + "description": "Enables the register_action_types command without any pre-configured scope.", + "type": "string", + "const": "allow-register-action-types", + "markdownDescription": "Enables the register_action_types command without any pre-configured scope." + }, + { + "description": "Denies the register_action_types command without any pre-configured scope.", + "type": "string", + "const": "deny-register-action-types", + "markdownDescription": "Denies the register_action_types command without any pre-configured scope." + }, + { + "description": "Enables the register_listener command without any pre-configured scope.", + "type": "string", + "const": "allow-register-listener", + "markdownDescription": "Enables the register_listener command without any pre-configured scope." + }, + { + "description": "Denies the register_listener command without any pre-configured scope.", + "type": "string", + "const": "deny-register-listener", + "markdownDescription": "Denies the register_listener command without any pre-configured scope." + }, + { + "description": "Enables the remove_active command without any pre-configured scope.", + "type": "string", + "const": "allow-remove-active", + "markdownDescription": "Enables the remove_active command without any pre-configured scope." + }, + { + "description": "Denies the remove_active command without any pre-configured scope.", + "type": "string", + "const": "deny-remove-active", + "markdownDescription": "Denies the remove_active command without any pre-configured scope." + }, + { + "description": "Enables the request_permission command without any pre-configured scope.", + "type": "string", + "const": "allow-request-permission", + "markdownDescription": "Enables the request_permission command without any pre-configured scope." + }, + { + "description": "Denies the request_permission command without any pre-configured scope.", + "type": "string", + "const": "deny-request-permission", + "markdownDescription": "Denies the request_permission command without any pre-configured scope." + }, + { + "description": "Enables the show command without any pre-configured scope.", + "type": "string", + "const": "allow-show", + "markdownDescription": "Enables the show command without any pre-configured scope." + }, + { + "description": "Denies the show command without any pre-configured scope.", + "type": "string", + "const": "deny-show", + "markdownDescription": "Denies the show command without any pre-configured scope." + }, + { + "description": "This permission set configures which\nnotification features are by default exposed.\n\n#### Granted Permissions\n\nIt allows all notification related features.\n\n\n#### This default permission set includes:\n\n- `allow-is-permission-granted`\n- `allow-request-permission`\n- `allow-notify`\n- `allow-register-action-types`\n- `allow-register-listener`\n- `allow-cancel`\n- `allow-get-pending`\n- `allow-remove-active`\n- `allow-get-active`\n- `allow-check-permissions`\n- `allow-show`\n- `allow-batch`\n- `allow-list-channels`\n- `allow-delete-channel`\n- `allow-create-channel`\n- `allow-permission-state`", + "type": "string", + "const": "default", + "markdownDescription": "This permission set configures which\nnotification features are by default exposed.\n\n#### Granted Permissions\n\nIt allows all notification related features.\n\n\n#### This default permission set includes:\n\n- `allow-is-permission-granted`\n- `allow-request-permission`\n- `allow-notify`\n- `allow-register-action-types`\n- `allow-register-listener`\n- `allow-cancel`\n- `allow-get-pending`\n- `allow-remove-active`\n- `allow-get-active`\n- `allow-check-permissions`\n- `allow-show`\n- `allow-batch`\n- `allow-list-channels`\n- `allow-delete-channel`\n- `allow-create-channel`\n- `allow-permission-state`" + } + ] + } + } +} \ No newline at end of file diff --git a/plugins/notification/rollup.config.js b/plugins/notification/rollup.config.js new file mode 100644 index 00000000..a7dbd4f6 --- /dev/null +++ b/plugins/notification/rollup.config.js @@ -0,0 +1,22 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import { createConfig } from '../../shared/rollup.config.js' +import { nodeResolve } from '@rollup/plugin-node-resolve' +import typescript from '@rollup/plugin-typescript' +import terser from '@rollup/plugin-terser' + +export default createConfig({ + additionalConfigs: { + input: 'guest-js/init.ts', + output: { + file: 'src/init-iife.js', + format: 'iife' + }, + plugins: [typescript(), terser(), nodeResolve()], + onwarn: (warning) => { + throw Object.assign(new Error(), warning) + } + } +}) diff --git a/plugins/notification/rollup.config.mjs b/plugins/notification/rollup.config.mjs deleted file mode 100644 index d2a3cda6..00000000 --- a/plugins/notification/rollup.config.mjs +++ /dev/null @@ -1,34 +0,0 @@ -import { readFileSync } from "fs"; - -import { createConfig } from "../../shared/rollup.config.mjs"; - -import typescript from "@rollup/plugin-typescript"; -import resolve from "@rollup/plugin-node-resolve"; -import terser from "@rollup/plugin-terser"; - -const config = createConfig({ - input: "guest-js/index.ts", - pkg: JSON.parse( - readFileSync(new URL("./package.json", import.meta.url), "utf8"), - ), - external: [/^@tauri-apps\/api/], -}); - -config.push({ - input: "guest-js/init.ts", - output: { - file: "src/init-iife.js", - format: "iife", - }, - plugins: [ - resolve(), - typescript({ - sourceMap: false, - declaration: false, - declarationDir: undefined, - }), - terser(), - ], -}); - -export default config; diff --git a/plugins/notification/src/api-iife.js b/plugins/notification/src/api-iife.js deleted file mode 100644 index 828c877c..00000000 --- a/plugins/notification/src/api-iife.js +++ /dev/null @@ -1 +0,0 @@ -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__})} diff --git a/plugins/notification/src/commands.rs b/plugins/notification/src/commands.rs index 4af85585..99b96c5b 100644 --- a/plugins/notification/src/commands.rs +++ b/plugins/notification/src/commands.rs @@ -2,9 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use tauri::{command, AppHandle, Runtime, State}; +use tauri::{command, plugin::PermissionState, AppHandle, Runtime, State}; -use crate::{Notification, NotificationData, PermissionState, Result}; +use crate::{Notification, NotificationData, Result}; #[command] pub(crate) async fn is_permission_granted( @@ -15,7 +15,7 @@ pub(crate) async fn is_permission_granted( match state { PermissionState::Granted => Ok(Some(true)), PermissionState::Denied => Ok(Some(false)), - PermissionState::Unknown => Ok(None), + PermissionState::Prompt | PermissionState::PromptWithRationale => Ok(None), } } diff --git a/plugins/notification/src/desktop.rs b/plugins/notification/src/desktop.rs index 7dfde80b..47279225 100644 --- a/plugins/notification/src/desktop.rs +++ b/plugins/notification/src/desktop.rs @@ -3,9 +3,12 @@ // SPDX-License-Identifier: MIT use serde::de::DeserializeOwned; -use tauri::{plugin::PluginApi, AppHandle, Runtime}; +use tauri::{ + plugin::{PermissionState, PluginApi}, + AppHandle, Runtime, +}; -use crate::{models::*, NotificationBuilder}; +use crate::NotificationBuilder; pub fn init( app: &AppHandle, @@ -15,17 +18,18 @@ pub fn init( } /// Access to the notification APIs. +/// +/// You can get an instance of this type via [`NotificationExt`](crate::NotificationExt) pub struct Notification(AppHandle); impl crate::NotificationBuilder { pub fn show(self) -> crate::Result<()> { - let mut notification = - imp::Notification::new(self.app.config().tauri.bundle.identifier.clone()); + let mut notification = imp::Notification::new(self.app.config().identifier.clone()); if let Some(title) = self .data .title - .or_else(|| self.app.config().package.product_name.clone()) + .or_else(|| self.app.config().product_name.clone()) { notification = notification.title(title); } @@ -157,7 +161,7 @@ mod imp { /// /// - **Windows**: Not supported on Windows 7. If your app targets it, enable the `windows7-compat` feature and use [`Self::notify`]. #[cfg_attr( - all(not(doc_cfg), feature = "windows7-compat"), + all(not(docsrs), feature = "windows7-compat"), deprecated = "This function does not work on Windows 7. Use `Self::notify` instead." )] pub fn show(self) -> crate::Result<()> { @@ -187,10 +191,10 @@ mod imp { } #[cfg(target_os = "macos")] { - let _ = notify_rust::set_application(if cfg!(feature = "custom-protocol") { - &self.identifier - } else { + let _ = notify_rust::set_application(if tauri::is_dev() { "com.apple.Terminal" + } else { + &self.identifier }); } @@ -221,12 +225,18 @@ mod imp { /// .expect("error while running tauri application"); /// ``` #[cfg(feature = "windows7-compat")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "windows7-compat")))] + #[cfg_attr(docsrs, doc(cfg(feature = "windows7-compat")))] #[allow(unused_variables)] pub fn notify(self, app: &tauri::AppHandle) -> crate::Result<()> { #[cfg(windows)] { - if tauri::utils::platform::is_windows_7() { + fn is_windows_7() -> bool { + let v = windows_version::OsVersion::current(); + // windows 7 is 6.1 + v.major == 6 && v.minor == 1 + } + + if is_windows_7() { self.notify_win7(app) } else { #[allow(deprecated)] @@ -242,9 +252,8 @@ mod imp { #[cfg(all(windows, feature = "windows7-compat"))] fn notify_win7(self, app: &tauri::AppHandle) -> crate::Result<()> { - let app = app.clone(); - let default_window_icon = app.default_window_icon().cloned(); - let _ = app.run_on_main_thread(move || { + let app_ = app.clone(); + let _ = app.clone().run_on_main_thread(move || { let mut notification = win7_notifications::Notification::new(); if let Some(body) = self.body { notification.body(&body); @@ -252,13 +261,8 @@ mod imp { if let Some(title) = self.title { notification.summary(&title); } - if let Some(tauri::Icon::Rgba { - rgba, - width, - height, - }) = default_window_icon - { - notification.icon(rgba, width, height); + if let Some(icon) = app_.default_window_icon() { + notification.icon(icon.rgba().to_vec(), icon.width(), icon.height()); } let _ = notification.show(); }); diff --git a/plugins/notification/src/init-iife.js b/plugins/notification/src/init-iife.js index 8c927674..30bff97d 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||{};!async function(n){"object"==typeof n&&Object.freeze(n),await i("plugin:notification|notify",{options:"string"==typeof n?{title:n}:n})}(Object.assign(o,{title:n}))},window.Notification.requestPermission=async function(){return await i("plugin:notification|request_permission").then((i=>(o("prompt"===i||"prompt-with-rationale"===i?"default":i),i)))},Object.defineProperty(window.Notification,"permission",{enumerable:!0,get:()=>t,set:i=>{if(!n)throw new Error("Readonly property");t=i}}),async function(){return"default"!==window.Notification.permission||__TEMPLATE_windows__?await Promise.resolve("granted"===window.Notification.permission):await i("plugin:notification|is_permission_granted")}().then((function(i){o(null===i?"default":i?"granted":"denied")}))}()}(); diff --git a/plugins/notification/src/lib.rs b/plugins/notification/src/lib.rs index 4df17b87..9ca33d63 100644 --- a/plugins/notification/src/lib.rs +++ b/plugins/notification/src/lib.rs @@ -2,8 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -//! [![](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/notification/banner.png)](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/notification) -//! //! Send message notifications (brief auto-expiring OS window element) to your user. Can also be used with the Notification Web API. #![doc( @@ -22,6 +20,7 @@ use tauri::{ }; pub use models::*; +pub use tauri::plugin::PermissionState; #[cfg(desktop)] mod desktop; @@ -35,9 +34,9 @@ mod models; pub use error::{Error, Result}; #[cfg(desktop)] -use desktop::Notification; +pub use desktop::Notification; #[cfg(mobile)] -use mobile::Notification; +pub use mobile::Notification; /// The notification builder. #[derive(Debug)] @@ -121,7 +120,7 @@ impl NotificationBuilder { /// Identifier used to group multiple notifications. /// - /// https://developer.apple.com/documentation/usernotifications/unmutablenotificationcontent/1649872-threadidentifier + /// pub fn group(mut self, group: impl Into) -> Self { self.data.group.replace(group.into()); self @@ -208,7 +207,7 @@ impl NotificationBuilder { } } -/// Extensions to [`tauri::App`], [`tauri::AppHandle`] and [`tauri::Window`] to access the notification APIs. +/// Extensions to [`tauri::App`], [`tauri::AppHandle`], [`tauri::WebviewWindow`], [`tauri::Webview`] and [`tauri::Window`] to access the notification APIs. pub trait NotificationExt { fn notification(&self) -> &Notification; } @@ -221,15 +220,16 @@ impl> crate::NotificationExt for T { /// Initializes the plugin. pub fn init() -> TauriPlugin { - let mut init_script = include_str!("init-iife.js").to_string(); - init_script.push_str(include_str!("api-iife.js")); Builder::new("notification") .invoke_handler(tauri::generate_handler![ commands::notify, commands::request_permission, commands::is_permission_granted ]) - .js_init_script(init_script) + .js_init_script(include_str!("init-iife.js").replace( + "__TEMPLATE_windows__", + if cfg!(windows) { "true" } else { "false" }, + )) .setup(|app, api| { #[cfg(mobile)] let notification = mobile::init(app, api)?; diff --git a/plugins/notification/src/mobile.rs b/plugins/notification/src/mobile.rs index 83513eef..edfef728 100644 --- a/plugins/notification/src/mobile.rs +++ b/plugins/notification/src/mobile.rs @@ -4,7 +4,7 @@ use serde::{de::DeserializeOwned, Deserialize}; use tauri::{ - plugin::{PluginApi, PluginHandle}, + plugin::{PermissionState, PluginApi, PluginHandle}, AppHandle, Runtime, }; @@ -33,13 +33,15 @@ 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) } } /// Access to the notification APIs. +/// +/// You can get an instance of this type via [`NotificationExt`](crate::NotificationExt) pub struct Notification(PluginHandle); impl Notification { @@ -89,8 +91,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 +103,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 +138,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 063a3702..02134e4d 100644 --- a/plugins/notification/src/models.rs +++ b/plugins/notification/src/models.rs @@ -51,14 +51,14 @@ impl Display for ScheduleEvery { f, "{}", match self { - Self::Year => "Year", - Self::Month => "Month", - Self::TwoWeeks => "TwoWeeks", - Self::Week => "Week", - Self::Day => "Day", - Self::Hour => "Hour", - Self::Minute => "Minute", - Self::Second => "Second", + Self::Year => "year", + Self::Month => "month", + Self::TwoWeeks => "twoWeeks", + Self::Week => "week", + Self::Day => "day", + Self::Hour => "hour", + Self::Minute => "minute", + Self::Second => "second", } ) } @@ -94,8 +94,9 @@ impl<'de> Deserialize<'de> for ScheduleEvery { } #[derive(Debug, Serialize, Deserialize)] -#[serde(tag = "kind", content = "data")] +#[serde(rename_all = "camelCase")] pub enum Schedule { + #[serde(rename_all = "camelCase")] At { #[serde( serialize_with = "iso8601::serialize", @@ -104,10 +105,21 @@ pub enum Schedule { date: time::OffsetDateTime, #[serde(default)] repeating: bool, + #[serde(default)] + allow_while_idle: bool, }, - Interval(ScheduleInterval), + #[serde(rename_all = "camelCase")] + Interval { + interval: ScheduleInterval, + #[serde(default)] + allow_while_idle: bool, + }, + #[serde(rename_all = "camelCase")] Every { interval: ScheduleEvery, + count: u8, + #[serde(default)] + allow_while_idle: bool, }, } @@ -197,51 +209,6 @@ impl Default for NotificationData { } } -/// Permission state. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum PermissionState { - /// Permission access has been granted. - Granted, - /// Permission access has been denied. - Denied, - /// Unknown state. Must request permission. - Unknown, -} - -impl Display for PermissionState { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Self::Granted => write!(f, "granted"), - Self::Denied => write!(f, "denied"), - Self::Unknown => write!(f, "Unknown"), - } - } -} - -impl Serialize for PermissionState { - fn serialize(&self, serializer: S) -> std::result::Result - where - S: Serializer, - { - serializer.serialize_str(self.to_string().as_ref()) - } -} - -impl<'de> Deserialize<'de> for PermissionState { - fn deserialize(deserializer: D) -> std::result::Result - where - D: Deserializer<'de>, - { - let s = String::deserialize(deserializer)?; - match s.to_lowercase().as_str() { - "granted" => Ok(Self::Granted), - "denied" => Ok(Self::Denied), - "prompt" => Ok(Self::Unknown), - _ => Err(DeError::custom(format!("unknown permission state '{s}'"))), - } - } -} - #[derive(Debug, Deserialize)] #[serde(rename_all = "camelCase")] pub struct PendingNotification { @@ -340,6 +307,7 @@ impl ActiveNotification { } } +#[cfg(mobile)] #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub struct ActionType { @@ -352,6 +320,7 @@ pub struct ActionType { hidden_previews_show_subtitle: bool, } +#[cfg(mobile)] #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub struct Action { diff --git a/plugins/notification/test/tauri.conf.json b/plugins/notification/test/tauri.conf.json index 6b015c11..4d0ae021 100644 --- a/plugins/notification/test/tauri.conf.json +++ b/plugins/notification/test/tauri.conf.json @@ -1,15 +1,10 @@ { - "$schema": "../../../node_modules/.pnpm/@tauri-apps+cli@2.0.0-alpha.16/node_modules/@tauri-apps/cli/schema.json", + "identifier": "app.tauri.example", "build": { - "distDir": ".", - "devPath": "http://localhost:4000" + "frontendDist": ".", + "devUrl": "http://localhost:4000" }, - "tauri": { - "bundle": { - "identifier": "studio.tauri.example", - "active": true, - "icon": ["../../../examples/api/src-tauri/icons/icon.png"] - }, + "app": { "windows": [ { "title": "Tauri App" @@ -18,5 +13,9 @@ "security": { "csp": "default-src blob: data: filesystem: ws: wss: http: https: tauri: http://tauri.localhost 'unsafe-eval' 'unsafe-inline' 'self'" } + }, + "bundle": { + "active": true, + "icon": ["../../../examples/api/src-tauri/icons/icon.png"] } } diff --git a/plugins/opener/CHANGELOG.md b/plugins/opener/CHANGELOG.md new file mode 100644 index 00000000..f5d4c379 --- /dev/null +++ b/plugins/opener/CHANGELOG.md @@ -0,0 +1,39 @@ +# Changelog + +## \[2.2.7] + +- [`6c9e08dc`](https://github.com/tauri-apps/plugins-workspace/commit/6c9e08dccb3ac99fccfce586fa2b69717ba81b52) ([#2695](https://github.com/tauri-apps/plugins-workspace/pull/2695) by [@ShaunSHamilton](https://github.com/tauri-apps/plugins-workspace/../../ShaunSHamilton)) Adjust `open_url` url type to allow `URL` +- [`dde6f3c3`](https://github.com/tauri-apps/plugins-workspace/commit/dde6f3c31c1b79942abb556be31757dc583f509e) ([#2549](https://github.com/tauri-apps/plugins-workspace/pull/2549) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Update `windows` crate to 0.61 to align with Tauri 2.5 + +## \[2.2.6] + +- [`1a984659`](https://github.com/tauri-apps/plugins-workspace/commit/1a9846599b6a71faf330845847a30f6bf9735898) ([#2469](https://github.com/tauri-apps/plugins-workspace/pull/2469) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Update `objc2` crate to 0.6. No user facing changes. +- [`71f95c9f`](https://github.com/tauri-apps/plugins-workspace/commit/71f95c9f05b29cf1be586849614c0b007757c15d) ([#2445](https://github.com/tauri-apps/plugins-workspace/pull/2445) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Updated `windows` crate to 0.60 to match Tauri 2.3.0. No user facing changes. + +## \[2.2.5] + +- [`5b821181`](https://github.com/tauri-apps/plugins-workspace/commit/5b8211815825ddae2dcc0c00520e0cfdff002763) ([#2332](https://github.com/tauri-apps/plugins-workspace/pull/2332) by [@betamos](https://github.com/tauri-apps/plugins-workspace/../../betamos)) Fix broken JS commands `opener.openPath` and `opener.openUrl` on mobile. + +## \[2.2.4] + +- [`da5c59e2`](https://github.com/tauri-apps/plugins-workspace/commit/da5c59e2fe879d177e3cfd52fcacce85440423cb) ([#2271](https://github.com/tauri-apps/plugins-workspace/pull/2271) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Updated `zbus` dependency to version 5. No API changes. + +## \[2.2.3] + +- [`a9ac1e3c`](https://github.com/tauri-apps/plugins-workspace/commit/a9ac1e3c939cec4338a9422ef02323c1d4dde6cd) ([#2253](https://github.com/tauri-apps/plugins-workspace/pull/2253) by [@betamos](https://github.com/tauri-apps/plugins-workspace/../../betamos)) Return an error in `open_path` if the file does not exist when opening with default application. + +## \[2.2.2] + +- [`ee0f65de`](https://github.com/tauri-apps/plugins-workspace/commit/ee0f65de5c645c244c5f0b638e0e0aab687cb9bf) ([#2207](https://github.com/tauri-apps/plugins-workspace/pull/2207) by [@universalappfactory](https://github.com/tauri-apps/plugins-workspace/../../universalappfactory)) Fixed OpenerPlugin packagename for android + +## \[2.2.1] + +- [`18dffc9d`](https://github.com/tauri-apps/plugins-workspace/commit/18dffc9dfecaf0c900e233e041d9ca36c92834b5) ([#2189](https://github.com/tauri-apps/plugins-workspace/pull/2189) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Fix usage on iOS. + +## \[2.2.0] + +- [`3a79266b`](https://github.com/tauri-apps/plugins-workspace/commit/3a79266b8cf96a55b1ae6339d725567d45a44b1d) ([#2173](https://github.com/tauri-apps/plugins-workspace/pull/2173) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Bumped all plugins to `v2.2.0`. From now, the versions for the Rust and JavaScript packages of each plugin will be in sync with each other. + +## \[2.0.0] + +- [`383e636a`](https://github.com/tauri-apps/plugins-workspace/commit/383e636a8e595aec1300999a8aeb7d9bf8c14632) ([#2019](https://github.com/tauri-apps/plugins-workspace/pull/2019) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Initial Release diff --git a/plugins/opener/Cargo.toml b/plugins/opener/Cargo.toml new file mode 100644 index 00000000..5b040dff --- /dev/null +++ b/plugins/opener/Cargo.toml @@ -0,0 +1,67 @@ +[package] +name = "tauri-plugin-opener" +version = "2.2.7" +description = "Open files and URLs using their default application." +edition = { workspace = true } +authors = { workspace = true } +license = { workspace = true } +repository = { workspace = true } +links = "tauri-plugin-opener" + +[package.metadata.docs.rs] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] + +# Platforms supported by the plugin +# Support levels are "full", "partial", "none", "unknown" +# Details of the support level are left to plugin maintainer +[package.metadata.platforms.support] +windows = { level = "full", notes = "" } +linux = { level = "full", notes = "" } +macos = { level = "full", notes = "" } +android = { level = "partial", notes = "Only allows to open URLs via `open`" } +ios = { level = "partial", notes = "Only allows to open URLs via `open`" } + + +[build-dependencies] +tauri-plugin = { workspace = true, features = ["build"] } +schemars = { workspace = true } +serde = { workspace = true } + +[dependencies] +serde = { workspace = true } +serde_json = { workspace = true } +tauri = { workspace = true } +thiserror = { workspace = true } +open = { version = "5", features = ["shellexecute-on-windows"] } +glob = { workspace = true } + +[target."cfg(windows)".dependencies] +dunce = { workspace = true } + +[target."cfg(windows)".dependencies.windows] +version = "0.61" +features = [ + "Win32_Foundation", + "Win32_UI_Shell_Common", + "Win32_UI_WindowsAndMessaging", + "Win32_System_Com", + "Win32_System_Registry", +] + +[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"netbsd\", target_os = \"openbsd\"))".dependencies] +zbus = { workspace = true } +url = { workspace = true } + +[target."cfg(target_os = \"macos\")".dependencies.objc2-app-kit] +version = "0.3" +default-features = false +features = ["std", "NSWorkspace"] + +[target."cfg(target_os = \"macos\")".dependencies.objc2-foundation] +version = "0.3" +default-features = false +features = ["std", "NSURL", "NSArray", "NSString"] + +[target.'cfg(target_os = "ios")'.dependencies] +tauri = { workspace = true, features = ["wry"] } diff --git a/plugins/opener/LICENSE.spdx b/plugins/opener/LICENSE.spdx new file mode 100644 index 00000000..cdd0df5a --- /dev/null +++ b/plugins/opener/LICENSE.spdx @@ -0,0 +1,20 @@ +SPDXVersion: SPDX-2.1 +DataLicense: CC0-1.0 +PackageName: tauri +DataFormat: SPDXRef-1 +PackageSupplier: Organization: The Tauri Programme in the Commons Conservancy +PackageHomePage: https://tauri.app +PackageLicenseDeclared: Apache-2.0 +PackageLicenseDeclared: MIT +PackageCopyrightText: 2019-2022, The Tauri Programme in the Commons Conservancy +PackageSummary: Tauri is a rust project that enables developers to make secure +and small desktop applications using a web frontend. + +PackageComment: The package includes the following libraries; see +Relationship information. + +Created: 2019-05-20T09:00:00Z +PackageDownloadLocation: git://github.com/tauri-apps/tauri +PackageDownloadLocation: git+https://github.com/tauri-apps/tauri.git +PackageDownloadLocation: git+ssh://github.com/tauri-apps/tauri.git +Creator: Person: Daniel Thompson-Yvetot \ No newline at end of file diff --git a/plugins/opener/LICENSE_APACHE-2.0 b/plugins/opener/LICENSE_APACHE-2.0 new file mode 100644 index 00000000..4947287f --- /dev/null +++ b/plugins/opener/LICENSE_APACHE-2.0 @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/plugins/opener/LICENSE_MIT b/plugins/opener/LICENSE_MIT new file mode 100644 index 00000000..4d754725 --- /dev/null +++ b/plugins/opener/LICENSE_MIT @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 - Present Tauri Apps Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/plugins/opener/README.md b/plugins/opener/README.md new file mode 100644 index 00000000..71509eaa --- /dev/null +++ b/plugins/opener/README.md @@ -0,0 +1,145 @@ +![opener](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/opener/banner.png) + + + +| Platform | Supported | +| -------- | --------- | +| Linux | ✓ | +| Windows | ✓ | +| macOS | ✓ | +| Android | ? | +| iOS | ? | + +## Install + +_This plugin requires a Rust version of at least **1.77.2**_ + +There are three general methods of installation that we can recommend. + +1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked) +2. Pull sources directly from Github using git tags / revision hashes (most secure) +3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use) + +Install the Core plugin by adding the following to your `Cargo.toml` file: + +`src-tauri/Cargo.toml` + +```toml +[dependencies] +tauri-plugin-opener = "2.0.0" +# alternatively with Git: +tauri-plugin-opener = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } +``` + +You can install the JavaScript Guest bindings using your preferred JavaScript package manager: + +> Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use. + + + +```sh +pnpm add @tauri-apps/plugin-opener +# or +npm add @tauri-apps/plugin-opener +# or +yarn add @tauri-apps/plugin-opener + +# alternatively with Git: +pnpm add https://github.com/tauri-apps/tauri-plugin-opener#v2 +# or +npm add https://github.com/tauri-apps/tauri-plugin-opener#v2 +# or +yarn add https://github.com/tauri-apps/tauri-plugin-opener#v2 +``` + +## Usage + +First you need to register the core plugin with Tauri: + +`src-tauri/src/lib.rs` + +```rust +fn main() { + tauri::Builder::default() + .plugin(tauri_plugin_opener::init()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} +``` + +Afterwards all the plugin's APIs are available through the JavaScript guest bindings: + +```javascript +import { openUrl, openPath, revealItemInDir } from '@tauri-apps/plugin-opener' + +// Opens the URL in the default browser +await openUrl('https://example.com') +// Or with a specific browser/app +await openUrl('https://example.com', 'firefox') + +// Opens the path with the system's default app +await openPath('/path/to/file') +// Or with a specific app +await openPath('/path/to/file', 'firefox') + +// Reveal a path with the system's default explorer +await revealItemInDir('/path/to/file') +``` + +### Usage from Rust + +You can also use those APIs from Rust: + +```rust +use tauri_plugin_opener::OpenerExt; + +fn main() { + tauri::Builder::default() + .plugin(tauri_plugin_opener::init()) + .setup(|app| { + let opener = app.opener(); + + // Opens the URL in the default browser + opener.open_url("https://example.com", None::<&str>)?; + // Or with a specific browser/app + opener.open_url("https://example.com", Some("firefox"))?; + + // Opens the path with the system's default app + opener.open_path("/path/to/file", None::<&str>)?; + // Or with a specific app + opener.open_path("/path/to/file", Some("firefox"))?; + + // Reveal a path with the system's default explorer + opener.reveal_item_in_dir("/path/to/file")?; + Ok(()) + }) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} +``` + +## Contributing + +PRs accepted. Please make sure to read the Contributing Guide before making a pull request. + +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + +## License + +Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. + +MIT or MIT/Apache 2.0 where applicable. diff --git a/plugins/opener/SECURITY.md b/plugins/opener/SECURITY.md new file mode 100644 index 00000000..4f09bbac --- /dev/null +++ b/plugins/opener/SECURITY.md @@ -0,0 +1,23 @@ +# Security Policy + +**Do not report security vulnerabilities through public GitHub issues.** + +**Please use the [Private Vulnerability Disclosure](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) feature of GitHub.** + +Include as much of the following information: + +- Type of issue (e.g. improper input parsing, privilege escalation, etc.) +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- The distribution affected or used to help us with reproduction of the issue +- Step-by-step instructions to reproduce the issue +- Ideally a reproduction repository +- Impact of the issue, including how an attacker might exploit the issue + +We prefer to receive reports in English. + +## Contact + +Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). + +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/opener/android/.gitignore b/plugins/opener/android/.gitignore new file mode 100644 index 00000000..c0f21ec2 --- /dev/null +++ b/plugins/opener/android/.gitignore @@ -0,0 +1,2 @@ +/build +/.tauri diff --git a/plugins/opener/android/build.gradle.kts b/plugins/opener/android/build.gradle.kts new file mode 100644 index 00000000..9dcce212 --- /dev/null +++ b/plugins/opener/android/build.gradle.kts @@ -0,0 +1,39 @@ +plugins { + id("com.android.library") + id("org.jetbrains.kotlin.android") +} + +android { + namespace = "app.tauri.opener" + compileSdk = 34 + + defaultConfig { + minSdk = 24 + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles("consumer-rules.pro") + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = "1.8" + } +} + +dependencies { + implementation("androidx.core:core-ktx:1.9.0") + implementation("com.fasterxml.jackson.core:jackson-databind:2.15.3") + implementation(project(":tauri-android")) +} diff --git a/plugins/opener/android/proguard-rules.pro b/plugins/opener/android/proguard-rules.pro new file mode 100644 index 00000000..481bb434 --- /dev/null +++ b/plugins/opener/android/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/plugins/opener/android/settings.gradle b/plugins/opener/android/settings.gradle new file mode 100644 index 00000000..14a752e4 --- /dev/null +++ b/plugins/opener/android/settings.gradle @@ -0,0 +1,2 @@ +include ':tauri-android' +project(':tauri-android').projectDir = new File('./.tauri/tauri-api') diff --git a/plugins/opener/android/src/main/AndroidManifest.xml b/plugins/opener/android/src/main/AndroidManifest.xml new file mode 100644 index 00000000..9a40236b --- /dev/null +++ b/plugins/opener/android/src/main/AndroidManifest.xml @@ -0,0 +1,3 @@ + + + diff --git a/plugins/opener/android/src/main/java/OpenerPlugin.kt b/plugins/opener/android/src/main/java/OpenerPlugin.kt new file mode 100644 index 00000000..16b76032 --- /dev/null +++ b/plugins/opener/android/src/main/java/OpenerPlugin.kt @@ -0,0 +1,30 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +package app.tauri.opener + +import android.app.Activity +import android.content.Intent +import android.net.Uri +import app.tauri.annotation.Command +import app.tauri.annotation.TauriPlugin +import app.tauri.plugin.Invoke +import app.tauri.plugin.Plugin +import java.io.File + +@TauriPlugin +class OpenerPlugin(private val activity: Activity) : Plugin(activity) { + @Command + fun open(invoke: Invoke) { + try { + val url = invoke.parseArgs(String::class.java) + val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + activity.applicationContext?.startActivity(intent) + invoke.resolve() + } catch (ex: Exception) { + invoke.reject(ex.message) + } + } +} diff --git a/plugins/opener/api-iife.js b/plugins/opener/api-iife.js new file mode 100644 index 00000000..30415a61 --- /dev/null +++ b/plugins/opener/api-iife.js @@ -0,0 +1 @@ +if("__TAURI__"in window){var __TAURI_PLUGIN_OPENER__=function(n){"use strict";async function e(n,e={},_){return window.__TAURI_INTERNALS__.invoke(n,e,_)}return"function"==typeof SuppressedError&&SuppressedError,n.openPath=async function(n,_){await e("plugin:opener|open_path",{path:n,with:_})},n.openUrl=async function(n,_){await e("plugin:opener|open_url",{url:n,with:_})},n.revealItemInDir=async function(n){return e("plugin:opener|reveal_item_in_dir",{path:n})},n}({});Object.defineProperty(window.__TAURI__,"opener",{value:__TAURI_PLUGIN_OPENER__})} diff --git a/plugins/opener/build.rs b/plugins/opener/build.rs new file mode 100644 index 00000000..fbad4d3a --- /dev/null +++ b/plugins/opener/build.rs @@ -0,0 +1,136 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use std::path::PathBuf; + +#[path = "src/scope_entry.rs"] +#[allow(dead_code)] +mod scope; + +/// Opener scope application. +#[derive(schemars::JsonSchema)] +#[serde(untagged)] +#[allow(unused)] +enum Application { + /// Open in default application. + Default, + /// If true, allow open with any application. + Enable(bool), + /// Allow specific application to open with. + App(String), +} + +impl Default for Application { + fn default() -> Self { + Self::Default + } +} + +/// Opener scope entry. +#[derive(schemars::JsonSchema)] +#[serde(untagged)] +#[allow(unused)] +enum OpenerScopeEntry { + Url { + /// A URL that can be opened by the webview when using the Opener APIs. + /// + /// Wildcards can be used following the UNIX glob pattern. + /// + /// Examples: + /// + /// - "https://*" : allows all HTTPS origin + /// + /// - "https://*.github.com/tauri-apps/tauri": allows any subdomain of "github.com" with the "tauri-apps/api" path + /// + /// - "https://myapi.service.com/users/*": allows access to any URLs that begins with "https://myapi.service.com/users/" + url: String, + /// An application to open this url with, for example: firefox. + #[serde(default)] + app: Application, + }, + Path { + /// A path that can be opened by the webview when using the Opener APIs. + /// + /// The pattern can start with a variable that resolves to a system base directory. + /// The variables are: `$AUDIO`, `$CACHE`, `$CONFIG`, `$DATA`, `$LOCALDATA`, `$DESKTOP`, + /// `$DOCUMENT`, `$DOWNLOAD`, `$EXE`, `$FONT`, `$HOME`, `$PICTURE`, `$PUBLIC`, `$RUNTIME`, + /// `$TEMPLATE`, `$VIDEO`, `$RESOURCE`, `$APP`, `$LOG`, `$TEMP`, `$APPCONFIG`, `$APPDATA`, + /// `$APPLOCALDATA`, `$APPCACHE`, `$APPLOG`. + path: PathBuf, + /// An application to open this path with, for example: xdg-open. + #[serde(default)] + app: Application, + }, +} + +// Ensure `OpenerScopeEntry` and `scope::EntryRaw` is kept in sync +fn _f() { + match (scope::EntryRaw::Url { + url: String::new(), + app: scope::Application::Enable(true), + }) { + scope::EntryRaw::Url { url, app } => OpenerScopeEntry::Url { + url, + app: match app { + scope::Application::Enable(p) => Application::Enable(p), + scope::Application::App(p) => Application::App(p), + scope::Application::Default => Application::Default, + }, + }, + scope::EntryRaw::Path { path, app } => OpenerScopeEntry::Path { + path, + app: match app { + scope::Application::Enable(p) => Application::Enable(p), + scope::Application::App(p) => Application::App(p), + scope::Application::Default => Application::Default, + }, + }, + }; + match (OpenerScopeEntry::Url { + url: String::new(), + app: Application::Enable(true), + }) { + OpenerScopeEntry::Url { url, app } => scope::EntryRaw::Url { + url, + app: match app { + Application::Enable(p) => scope::Application::Enable(p), + Application::App(p) => scope::Application::App(p), + Application::Default => scope::Application::Default, + }, + }, + OpenerScopeEntry::Path { path, app } => scope::EntryRaw::Path { + path, + app: match app { + Application::Enable(p) => scope::Application::Enable(p), + Application::App(p) => scope::Application::App(p), + Application::Default => scope::Application::Default, + }, + }, + }; +} + +const COMMANDS: &[&str] = &["open_url", "open_path", "reveal_item_in_dir"]; + +fn main() { + tauri_plugin::Builder::new(COMMANDS) + .global_api_script_path("./api-iife.js") + .android_path("android") + .ios_path("ios") + .global_scope_schema(schemars::schema_for!(OpenerScopeEntry)) + .build(); + + let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap(); + let mobile = target_os == "ios" || target_os == "android"; + alias("desktop", !mobile); + alias("mobile", mobile); +} + +// creates a cfg alias if `has_feature` is true. +// `alias` must be a snake case string. +fn alias(alias: &str, has_feature: bool) { + println!("cargo:rustc-check-cfg=cfg({alias})"); + if has_feature { + println!("cargo:rustc-cfg={alias}"); + } +} diff --git a/plugins/opener/guest-js/index.ts b/plugins/opener/guest-js/index.ts new file mode 100644 index 00000000..5705c722 --- /dev/null +++ b/plugins/opener/guest-js/index.ts @@ -0,0 +1,95 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +/** + * Open files and URLs using their default application. + * + * ## Security + * + * This API has a scope configuration that forces you to restrict the files and urls to be opened. + * + * ### Restricting access to the {@link open | `open`} API + * + * On the configuration object, `open: true` means that the {@link open} API can be used with any URL, + * as the argument is validated with the `^((mailto:\w+)|(tel:\w+)|(https?://\w+)).+` regex. + * You can change that regex by changing the boolean value to a string, e.g. `open: ^https://github.com/`. + * + * @module + */ + +import { invoke } from '@tauri-apps/api/core' + +/** + * Opens a url with the system's default app, or the one specified with {@linkcode openWith}. + * + * @example + * ```typescript + * import { openUrl } from '@tauri-apps/plugin-opener'; + * + * // opens the given URL on the default browser: + * await openUrl('https://github.com/tauri-apps/tauri'); + * // opens the given URL using `firefox`: + * await openUrl('https://github.com/tauri-apps/tauri', 'firefox'); + * ``` + * + * @param url The URL to open. + * @param openWith The app to open the URL with. If not specified, defaults to the system default application for the specified url type. + * + * @since 2.0.0 + */ +export async function openUrl( + url: string | URL, + openWith?: string +): Promise { + await invoke('plugin:opener|open_url', { + url, + with: openWith + }) +} + +/** + * Opens a path with the system's default app, or the one specified with {@linkcode openWith}. + * + * @example + * ```typescript + * import { openPath } from '@tauri-apps/plugin-opener'; + * + * // opens a file using the default program: + * await openPath('/path/to/file'); + * // opens a file using `vlc` command on Windows. + * await openPath('C:/path/to/file', 'vlc'); + * ``` + * + * @param path The path to open. + * @param openWith The app to open the path with. If not specified, defaults to the system default application for the specified path type. + * + * @since 2.0.0 + */ +export async function openPath(path: string, openWith?: string): Promise { + await invoke('plugin:opener|open_path', { + path, + with: openWith + }) +} + +/** + * Reveal a path with the system's default explorer. + * + * #### Platform-specific: + * + * - **Android / iOS:** Unsupported. + * + * @example + * ```typescript + * import { revealItemInDir } from '@tauri-apps/plugin-opener'; + * await revealItemInDir('/path/to/file'); + * ``` + * + * @param path The path to reveal. + * + * @since 2.0.0 + */ +export async function revealItemInDir(path: string) { + return invoke('plugin:opener|reveal_item_in_dir', { path }) +} diff --git a/plugins/opener/guest-js/init.ts b/plugins/opener/guest-js/init.ts new file mode 100644 index 00000000..6f81141a --- /dev/null +++ b/plugins/opener/guest-js/init.ts @@ -0,0 +1,61 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import { invoke } from '@tauri-apps/api/core' + +// open links with the API +window.addEventListener('click', function (evt) { + // return early if + if ( + // event was prevented + evt.defaultPrevented + // or not a left click + || evt.button !== 0 + // or meta key pressed + || evt.metaKey + // or al key pressed + || evt.altKey + ) + return + + const a = evt + .composedPath() + .find((el) => el instanceof Node && el.nodeName.toUpperCase() === 'A') as + | HTMLAnchorElement + | undefined + + // return early if + if ( + // not tirggered from element + !a + // or doesn't have a href + || !a.href + // or not supposed to be open in a new tab + || !( + a.target === '_blank' + // or ctrl key pressed + || evt.ctrlKey + // or shift key pressed + || evt.shiftKey + ) + ) + return + + const url = new URL(a.href) + + // return early if + if ( + // same origin (internal navigation) + url.origin === window.location.origin + // not default protocols + || ['http:', 'https:', 'mailto:', 'tel:'].every((p) => url.protocol !== p) + ) + return + + evt.preventDefault() + + void invoke('plugin:opener|open_url', { + url + }) +}) diff --git a/plugins/opener/ios/Package.resolved b/plugins/opener/ios/Package.resolved new file mode 100644 index 00000000..5f998e0e --- /dev/null +++ b/plugins/opener/ios/Package.resolved @@ -0,0 +1,16 @@ +{ + "object": { + "pins": [ + { + "package": "SwiftRs", + "repositoryURL": "https://github.com/Brendonovich/swift-rs", + "state": { + "branch": null, + "revision": "b5ed223fcdab165bc21219c1925dc1e77e2bef5e", + "version": "1.0.6" + } + } + ] + }, + "version": 1 +} diff --git a/plugins/opener/ios/Package.swift b/plugins/opener/ios/Package.swift new file mode 100644 index 00000000..8d06936e --- /dev/null +++ b/plugins/opener/ios/Package.swift @@ -0,0 +1,34 @@ +// swift-tools-version:5.3 +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import PackageDescription + +let package = Package( + name: "tauri-plugin-opener", + platforms: [ + .macOS(.v10_13), + .iOS(.v13), + ], + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .library( + name: "tauri-plugin-opener", + type: .static, + targets: ["tauri-plugin-opener"]) + ], + dependencies: [ + .package(name: "Tauri", path: "../.tauri/tauri-api") + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .target( + name: "tauri-plugin-opener", + dependencies: [ + .byName(name: "Tauri") + ], + path: "Sources") + ] +) diff --git a/plugins/opener/ios/Sources/OpenerPlugin.swift b/plugins/opener/ios/Sources/OpenerPlugin.swift new file mode 100644 index 00000000..81ff76b4 --- /dev/null +++ b/plugins/opener/ios/Sources/OpenerPlugin.swift @@ -0,0 +1,32 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import Foundation +import SwiftRs +import Tauri +import UIKit +import WebKit + +class OpenerPlugin: Plugin { + @objc public func open(_ invoke: Invoke) throws { + do { + let urlString = try invoke.parseArgs(String.self) + if let url = URL(string: urlString) { + if #available(iOS 10, *) { + UIApplication.shared.open(url, options: [:]) + } else { + UIApplication.shared.openURL(url) + } + } + invoke.resolve() + } catch { + invoke.reject(error.localizedDescription) + } + } +} + +@_cdecl("init_plugin_opener") +func initPlugin() -> Plugin { + return OpenerPlugin() +} diff --git a/plugins/opener/package.json b/plugins/opener/package.json new file mode 100644 index 00000000..c4ae6f9b --- /dev/null +++ b/plugins/opener/package.json @@ -0,0 +1,30 @@ +{ + "name": "@tauri-apps/plugin-opener", + "version": "2.2.7", + "description": "Open files and URLs using their default application.", + "license": "MIT OR Apache-2.0", + "authors": [ + "Tauri Programme within The Commons Conservancy" + ], + "repository": "https://github.com/tauri-apps/plugins-workspace", + "type": "module", + "types": "./dist-js/index.d.ts", + "main": "./dist-js/index.cjs", + "module": "./dist-js/index.js", + "exports": { + "types": "./dist-js/index.d.ts", + "import": "./dist-js/index.js", + "require": "./dist-js/index.cjs" + }, + "scripts": { + "build": "rollup -c" + }, + "files": [ + "dist-js", + "README.md", + "LICENSE" + ], + "dependencies": { + "@tauri-apps/api": "^2.0.0" + } +} diff --git a/plugins/opener/permissions/allow-default-urls.toml b/plugins/opener/permissions/allow-default-urls.toml new file mode 100644 index 00000000..93495b89 --- /dev/null +++ b/plugins/opener/permissions/allow-default-urls.toml @@ -0,0 +1,17 @@ +"$schema" = "schemas/schema.json" + +[[permission]] +identifier = "allow-default-urls" +description = "This enables opening `mailto:`, `tel:`, `https://` and `http://` urls using their default application." + +[[permission.scope.allow]] +url = "mailto:*" + +[[permission.scope.allow]] +url = "tel:*" + +[[permission.scope.allow]] +url = "http://*" + +[[permission.scope.allow]] +url = "https://*" diff --git a/plugins/opener/permissions/autogenerated/commands/open_path.toml b/plugins/opener/permissions/autogenerated/commands/open_path.toml new file mode 100644 index 00000000..ae67b939 --- /dev/null +++ b/plugins/opener/permissions/autogenerated/commands/open_path.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-open-path" +description = "Enables the open_path command without any pre-configured scope." +commands.allow = ["open_path"] + +[[permission]] +identifier = "deny-open-path" +description = "Denies the open_path command without any pre-configured scope." +commands.deny = ["open_path"] diff --git a/plugins/opener/permissions/autogenerated/commands/open_url.toml b/plugins/opener/permissions/autogenerated/commands/open_url.toml new file mode 100644 index 00000000..f1e694b1 --- /dev/null +++ b/plugins/opener/permissions/autogenerated/commands/open_url.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-open-url" +description = "Enables the open_url command without any pre-configured scope." +commands.allow = ["open_url"] + +[[permission]] +identifier = "deny-open-url" +description = "Denies the open_url command without any pre-configured scope." +commands.deny = ["open_url"] diff --git a/plugins/opener/permissions/autogenerated/commands/reveal_item_in_dir.toml b/plugins/opener/permissions/autogenerated/commands/reveal_item_in_dir.toml new file mode 100644 index 00000000..e669620f --- /dev/null +++ b/plugins/opener/permissions/autogenerated/commands/reveal_item_in_dir.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-reveal-item-in-dir" +description = "Enables the reveal_item_in_dir command without any pre-configured scope." +commands.allow = ["reveal_item_in_dir"] + +[[permission]] +identifier = "deny-reveal-item-in-dir" +description = "Denies the reveal_item_in_dir command without any pre-configured scope." +commands.deny = ["reveal_item_in_dir"] diff --git a/plugins/opener/permissions/autogenerated/reference.md b/plugins/opener/permissions/autogenerated/reference.md new file mode 100644 index 00000000..6ad6ba1f --- /dev/null +++ b/plugins/opener/permissions/autogenerated/reference.md @@ -0,0 +1,111 @@ +## Default Permission + +This permission set allows opening `mailto:`, `tel:`, `https://` and `http://` urls using their default application +as well as reveal file in directories using default file explorer + +#### This default permission set includes the following: + +- `allow-open-url` +- `allow-reveal-item-in-dir` +- `allow-default-urls` + +## Permission Table + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IdentifierDescription
+ +`opener:allow-default-urls` + + + +This enables opening `mailto:`, `tel:`, `https://` and `http://` urls using their default application. + +
+ +`opener:allow-open-path` + + + +Enables the open_path command without any pre-configured scope. + +
+ +`opener:deny-open-path` + + + +Denies the open_path command without any pre-configured scope. + +
+ +`opener:allow-open-url` + + + +Enables the open_url command without any pre-configured scope. + +
+ +`opener:deny-open-url` + + + +Denies the open_url command without any pre-configured scope. + +
+ +`opener:allow-reveal-item-in-dir` + + + +Enables the reveal_item_in_dir command without any pre-configured scope. + +
+ +`opener:deny-reveal-item-in-dir` + + + +Denies the reveal_item_in_dir command without any pre-configured scope. + +
diff --git a/plugins/opener/permissions/default.toml b/plugins/opener/permissions/default.toml new file mode 100644 index 00000000..846d6e51 --- /dev/null +++ b/plugins/opener/permissions/default.toml @@ -0,0 +1,10 @@ +"$schema" = "schemas/schema.json" + +[default] +description = """This permission set allows opening `mailto:`, `tel:`, `https://` and `http://` urls using their default application +as well as reveal file in directories using default file explorer""" +permissions = [ + "allow-open-url", + "allow-reveal-item-in-dir", + "allow-default-urls", +] diff --git a/plugins/opener/permissions/schemas/schema.json b/plugins/opener/permissions/schemas/schema.json new file mode 100644 index 00000000..78c80ba3 --- /dev/null +++ b/plugins/opener/permissions/schemas/schema.json @@ -0,0 +1,348 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "PermissionFile", + "description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.", + "type": "object", + "properties": { + "default": { + "description": "The default permission set for the plugin", + "anyOf": [ + { + "$ref": "#/definitions/DefaultPermission" + }, + { + "type": "null" + } + ] + }, + "set": { + "description": "A list of permissions sets defined", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionSet" + } + }, + "permission": { + "description": "A list of inlined permissions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Permission" + } + } + }, + "definitions": { + "DefaultPermission": { + "description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.", + "type": "object", + "required": [ + "permissions" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "PermissionSet": { + "description": "A set of direct permissions grouped together under a new name.", + "type": "object", + "required": [ + "description", + "identifier", + "permissions" + ], + "properties": { + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does.", + "type": "string" + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionKind" + } + } + } + }, + "Permission": { + "description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.", + "type": "object", + "required": [ + "identifier" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri internal convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "commands": { + "description": "Allowed or denied commands when using this permission.", + "default": { + "allow": [], + "deny": [] + }, + "allOf": [ + { + "$ref": "#/definitions/Commands" + } + ] + }, + "scope": { + "description": "Allowed or denied scoped when using this permission.", + "allOf": [ + { + "$ref": "#/definitions/Scopes" + } + ] + }, + "platforms": { + "description": "Target platforms this permission applies. By default all platforms are affected by this permission.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Target" + } + } + } + }, + "Commands": { + "description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.", + "type": "object", + "properties": { + "allow": { + "description": "Allowed command.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "deny": { + "description": "Denied command, which takes priority.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "Scopes": { + "description": "An argument for fine grained behavior control of Tauri commands.\n\nIt can be of any serde serializable type and is used to allow or prevent certain actions inside a Tauri command. The configured scope is passed to the command and will be enforced by the command implementation.\n\n## Example\n\n```json { \"allow\": [{ \"path\": \"$HOME/**\" }], \"deny\": [{ \"path\": \"$HOME/secret.txt\" }] } ```", + "type": "object", + "properties": { + "allow": { + "description": "Data that defines what is allowed by the scope.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + }, + "deny": { + "description": "Data that defines what is denied by the scope. This should be prioritized by validation logic.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + } + } + }, + "Value": { + "description": "All supported ACL values.", + "anyOf": [ + { + "description": "Represents a null JSON value.", + "type": "null" + }, + { + "description": "Represents a [`bool`].", + "type": "boolean" + }, + { + "description": "Represents a valid ACL [`Number`].", + "allOf": [ + { + "$ref": "#/definitions/Number" + } + ] + }, + { + "description": "Represents a [`String`].", + "type": "string" + }, + { + "description": "Represents a list of other [`Value`]s.", + "type": "array", + "items": { + "$ref": "#/definitions/Value" + } + }, + { + "description": "Represents a map of [`String`] keys to [`Value`]s.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/Value" + } + } + ] + }, + "Number": { + "description": "A valid ACL number.", + "anyOf": [ + { + "description": "Represents an [`i64`].", + "type": "integer", + "format": "int64" + }, + { + "description": "Represents a [`f64`].", + "type": "number", + "format": "double" + } + ] + }, + "Target": { + "description": "Platform target.", + "oneOf": [ + { + "description": "MacOS.", + "type": "string", + "enum": [ + "macOS" + ] + }, + { + "description": "Windows.", + "type": "string", + "enum": [ + "windows" + ] + }, + { + "description": "Linux.", + "type": "string", + "enum": [ + "linux" + ] + }, + { + "description": "Android.", + "type": "string", + "enum": [ + "android" + ] + }, + { + "description": "iOS.", + "type": "string", + "enum": [ + "iOS" + ] + } + ] + }, + "PermissionKind": { + "type": "string", + "oneOf": [ + { + "description": "This enables opening `mailto:`, `tel:`, `https://` and `http://` urls using their default application.", + "type": "string", + "const": "allow-default-urls", + "markdownDescription": "This enables opening `mailto:`, `tel:`, `https://` and `http://` urls using their default application." + }, + { + "description": "Enables the open_path command without any pre-configured scope.", + "type": "string", + "const": "allow-open-path", + "markdownDescription": "Enables the open_path command without any pre-configured scope." + }, + { + "description": "Denies the open_path command without any pre-configured scope.", + "type": "string", + "const": "deny-open-path", + "markdownDescription": "Denies the open_path command without any pre-configured scope." + }, + { + "description": "Enables the open_url command without any pre-configured scope.", + "type": "string", + "const": "allow-open-url", + "markdownDescription": "Enables the open_url command without any pre-configured scope." + }, + { + "description": "Denies the open_url command without any pre-configured scope.", + "type": "string", + "const": "deny-open-url", + "markdownDescription": "Denies the open_url command without any pre-configured scope." + }, + { + "description": "Enables the reveal_item_in_dir command without any pre-configured scope.", + "type": "string", + "const": "allow-reveal-item-in-dir", + "markdownDescription": "Enables the reveal_item_in_dir command without any pre-configured scope." + }, + { + "description": "Denies the reveal_item_in_dir command without any pre-configured scope.", + "type": "string", + "const": "deny-reveal-item-in-dir", + "markdownDescription": "Denies the reveal_item_in_dir command without any pre-configured scope." + }, + { + "description": "This permission set allows opening `mailto:`, `tel:`, `https://` and `http://` urls using their default application\nas well as reveal file in directories using default file explorer\n#### This default permission set includes:\n\n- `allow-open-url`\n- `allow-reveal-item-in-dir`\n- `allow-default-urls`", + "type": "string", + "const": "default", + "markdownDescription": "This permission set allows opening `mailto:`, `tel:`, `https://` and `http://` urls using their default application\nas well as reveal file in directories using default file explorer\n#### This default permission set includes:\n\n- `allow-open-url`\n- `allow-reveal-item-in-dir`\n- `allow-default-urls`" + } + ] + } + } +} \ No newline at end of file diff --git a/plugins/opener/rollup.config.js b/plugins/opener/rollup.config.js new file mode 100644 index 00000000..a7dbd4f6 --- /dev/null +++ b/plugins/opener/rollup.config.js @@ -0,0 +1,22 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import { createConfig } from '../../shared/rollup.config.js' +import { nodeResolve } from '@rollup/plugin-node-resolve' +import typescript from '@rollup/plugin-typescript' +import terser from '@rollup/plugin-terser' + +export default createConfig({ + additionalConfigs: { + input: 'guest-js/init.ts', + output: { + file: 'src/init-iife.js', + format: 'iife' + }, + plugins: [typescript(), terser(), nodeResolve()], + onwarn: (warning) => { + throw Object.assign(new Error(), warning) + } + } +}) diff --git a/plugins/opener/src/commands.rs b/plugins/opener/src/commands.rs new file mode 100644 index 00000000..b00d5306 --- /dev/null +++ b/plugins/opener/src/commands.rs @@ -0,0 +1,75 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use std::path::{Path, PathBuf}; + +use tauri::{ + ipc::{CommandScope, GlobalScope}, + AppHandle, Runtime, +}; + +use crate::{scope::Scope, Error, OpenerExt}; + +#[tauri::command] +pub async fn open_url( + app: AppHandle, + command_scope: CommandScope, + global_scope: GlobalScope, + url: String, + with: Option, +) -> crate::Result<()> { + let scope = Scope::new( + &app, + command_scope + .allows() + .iter() + .chain(global_scope.allows()) + .collect(), + command_scope + .denies() + .iter() + .chain(global_scope.denies()) + .collect(), + ); + + if scope.is_url_allowed(&url, with.as_deref()) { + app.opener().open_url(url, with) + } else { + Err(Error::ForbiddenUrl { url, with }) + } +} + +#[tauri::command] +pub async fn open_path( + app: AppHandle, + command_scope: CommandScope, + global_scope: GlobalScope, + path: String, + with: Option, +) -> crate::Result<()> { + let scope = Scope::new( + &app, + command_scope + .allows() + .iter() + .chain(global_scope.allows()) + .collect(), + command_scope + .denies() + .iter() + .chain(global_scope.denies()) + .collect(), + ); + + if scope.is_path_allowed(Path::new(&path), with.as_deref())? { + app.opener().open_path(path, with) + } else { + Err(Error::ForbiddenPath { path, with }) + } +} + +#[tauri::command] +pub async fn reveal_item_in_dir(path: PathBuf) -> crate::Result<()> { + crate::reveal_item_in_dir(path) +} diff --git a/plugins/opener/src/error.rs b/plugins/opener/src/error.rs new file mode 100644 index 00000000..157922fc --- /dev/null +++ b/plugins/opener/src/error.rs @@ -0,0 +1,54 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use std::path::PathBuf; + +use serde::{Serialize, Serializer}; + +#[derive(Debug, thiserror::Error)] +#[non_exhaustive] +pub enum Error { + #[cfg(mobile)] + #[error(transparent)] + PluginInvoke(#[from] tauri::plugin::mobile::PluginInvokeError), + #[error(transparent)] + Tauri(#[from] tauri::Error), + #[error(transparent)] + Io(#[from] std::io::Error), + #[error(transparent)] + Json(#[from] serde_json::Error), + #[error("unknown program {0}")] + UnknownProgramName(String), + #[error("Not allowed to open path {}{}", .path, .with.as_ref().map(|w| format!(" with {w}")).unwrap_or_default())] + ForbiddenPath { path: String, with: Option }, + #[error("Not allowed to open url {}{}", .url, .with.as_ref().map(|w| format!(" with {w}")).unwrap_or_default())] + ForbiddenUrl { url: String, with: Option }, + #[error("API not supported on the current platform")] + UnsupportedPlatform, + #[error(transparent)] + #[cfg(windows)] + Win32Error(#[from] windows::core::Error), + #[error("Path doesn't have a parent: {0}")] + NoParent(PathBuf), + #[error("Failed to convert path to file:// url")] + FailedToConvertPathToFileUrl, + #[error(transparent)] + #[cfg(any( + target_os = "linux", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "netbsd", + target_os = "openbsd" + ))] + Zbus(#[from] zbus::Error), +} + +impl Serialize for Error { + fn serialize(&self, serializer: S) -> std::result::Result + where + S: Serializer, + { + serializer.serialize_str(self.to_string().as_ref()) + } +} diff --git a/plugins/opener/src/init-iife.js b/plugins/opener/src/init-iife.js new file mode 100644 index 00000000..51f6f068 --- /dev/null +++ b/plugins/opener/src/init-iife.js @@ -0,0 +1 @@ +!function(){"use strict";"function"==typeof SuppressedError&&SuppressedError,window.addEventListener("click",(function(e){if(e.defaultPrevented||0!==e.button||e.metaKey||e.altKey)return;const t=e.composedPath().find((e=>e instanceof Node&&"A"===e.nodeName.toUpperCase()));if(!t||!t.href||"_blank"!==t.target&&!e.ctrlKey&&!e.shiftKey)return;const n=new URL(t.href);n.origin===window.location.origin||["http:","https:","mailto:","tel:"].every((e=>n.protocol!==e))||(e.preventDefault(),async function(e,t={},n){window.__TAURI_INTERNALS__.invoke(e,t,n)}("plugin:opener|open_url",{url:n}))}))}(); diff --git a/plugins/opener/src/lib.rs b/plugins/opener/src/lib.rs new file mode 100644 index 00000000..9934b0fc --- /dev/null +++ b/plugins/opener/src/lib.rs @@ -0,0 +1,221 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use std::path::Path; + +use tauri::{plugin::TauriPlugin, Manager, Runtime}; + +#[cfg(mobile)] +use tauri::plugin::PluginHandle; +#[cfg(target_os = "android")] +const PLUGIN_IDENTIFIER: &str = "app.tauri.opener"; +#[cfg(target_os = "ios")] +tauri::ios_plugin_binding!(init_plugin_opener); + +mod commands; +mod error; +mod open; +mod reveal_item_in_dir; +mod scope; +mod scope_entry; + +pub use error::Error; +type Result = std::result::Result; + +pub use open::{open_path, open_url}; +pub use reveal_item_in_dir::reveal_item_in_dir; + +pub struct Opener { + // we use `fn() -> R` to slicence the unused generic error + // while keeping this struct `Send + Sync` without requiring `R` to be + #[cfg(not(mobile))] + _marker: std::marker::PhantomData R>, + #[cfg(mobile)] + mobile_plugin_handle: PluginHandle, +} + +impl Opener { + /// Open a url with a default or specific program. + /// + /// # Examples + /// + /// ```rust,no_run + /// use tauri_plugin_opener::OpenerExt; + /// + /// tauri::Builder::default() + /// .setup(|app| { + /// // open the given URL on the system default browser + /// app.opener().open_url("https://github.com/tauri-apps/tauri", None::<&str>)?; + /// Ok(()) + /// }); + /// ``` + /// + /// ## Platform-specific: + /// + /// - **Android / iOS**: Always opens using default program. + #[cfg(desktop)] + pub fn open_url(&self, url: impl Into, with: Option>) -> Result<()> { + crate::open::open(url.into(), with.map(Into::into)) + } + + /// Open a url with a default or specific program. + /// + /// # Examples + /// + /// ```rust,no_run + /// use tauri_plugin_opener::OpenerExt; + /// + /// tauri::Builder::default() + /// .setup(|app| { + /// // open the given URL on the system default browser + /// app.opener().open_url("https://github.com/tauri-apps/tauri", None::<&str>)?; + /// Ok(()) + /// }); + /// ``` + /// + /// ## Platform-specific: + /// + /// - **Android / iOS**: Always opens using default program. + #[cfg(mobile)] + pub fn open_url(&self, url: impl Into, _with: Option>) -> Result<()> { + self.mobile_plugin_handle + .run_mobile_plugin("open", url.into()) + .map_err(Into::into) + } + + /// Open a path with a default or specific program. + /// + /// # Examples + /// + /// ```rust,no_run + /// use tauri_plugin_opener::OpenerExt; + /// + /// tauri::Builder::default() + /// .setup(|app| { + /// // open the given path on the system default explorer + /// app.opener().open_path("/path/to/file", None::<&str>)?; + /// Ok(()) + /// }); + /// ``` + /// + /// ## Platform-specific: + /// + /// - **Android / iOS**: Always opens using default program. + #[cfg(desktop)] + pub fn open_path( + &self, + path: impl Into, + with: Option>, + ) -> Result<()> { + crate::open::open(path.into(), with.map(Into::into)) + } + + /// Open a path with a default or specific program. + /// + /// # Examples + /// + /// ```rust,no_run + /// use tauri_plugin_opener::OpenerExt; + /// + /// tauri::Builder::default() + /// .setup(|app| { + /// // open the given path on the system default explorer + /// app.opener().open_path("/path/to/file", None::<&str>)?; + /// Ok(()) + /// }); + /// ``` + /// + /// ## Platform-specific: + /// + /// - **Android / iOS**: Always opens using default program. + #[cfg(mobile)] + pub fn open_path( + &self, + path: impl Into, + _with: Option>, + ) -> Result<()> { + self.mobile_plugin_handle + .run_mobile_plugin("open", path.into()) + .map_err(Into::into) + } + + pub fn reveal_item_in_dir>(&self, p: P) -> Result<()> { + crate::reveal_item_in_dir::reveal_item_in_dir(p) + } +} + +/// Extensions to [`tauri::App`], [`tauri::AppHandle`], [`tauri::WebviewWindow`], [`tauri::Webview`] and [`tauri::Window`] to access the opener APIs. +pub trait OpenerExt { + fn opener(&self) -> &Opener; +} + +impl> OpenerExt for T { + fn opener(&self) -> &Opener { + self.state::>().inner() + } +} + +/// The opener plugin Builder. +pub struct Builder { + open_js_links_on_click: bool, +} + +impl Default for Builder { + fn default() -> Self { + Self { + open_js_links_on_click: true, + } + } +} + +impl Builder { + /// Create a new opener plugin Builder. + pub fn new() -> Self { + Self::default() + } + + /// Whether the plugin should inject a JS script to open URLs in default browser + /// when clicking on `` elements that has `_blank` target, or when pressing `Ctrl` or `Shift` while clicking it. + /// + /// Enabled by default for `http:`, `https:`, `mailto:`, `tel:` links. + pub fn open_js_links_on_click(mut self, open: bool) -> Self { + self.open_js_links_on_click = open; + self + } + + /// Build and Initializes the plugin. + pub fn build(self) -> TauriPlugin { + let mut builder = tauri::plugin::Builder::new("opener") + .setup(|app, _api| { + #[cfg(target_os = "android")] + let handle = _api.register_android_plugin(PLUGIN_IDENTIFIER, "OpenerPlugin")?; + #[cfg(target_os = "ios")] + let handle = _api.register_ios_plugin(init_plugin_opener)?; + + app.manage(Opener { + #[cfg(not(mobile))] + _marker: std::marker::PhantomData:: R>, + #[cfg(mobile)] + mobile_plugin_handle: handle, + }); + Ok(()) + }) + .invoke_handler(tauri::generate_handler![ + commands::open_url, + commands::open_path, + commands::reveal_item_in_dir + ]); + + if self.open_js_links_on_click { + builder = builder.js_init_script(include_str!("init-iife.js").to_string()); + } + + builder.build() + } +} + +/// Initializes the plugin. +pub fn init() -> TauriPlugin { + Builder::default().build() +} diff --git a/plugins/opener/src/open.rs b/plugins/opener/src/open.rs new file mode 100644 index 00000000..a3d46c50 --- /dev/null +++ b/plugins/opener/src/open.rs @@ -0,0 +1,61 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +//! Types and functions related to shell. + +use std::{ffi::OsStr, path::Path}; + +pub(crate) fn open, S: AsRef>(path: P, with: Option) -> crate::Result<()> { + match with { + Some(program) => ::open::with_detached(path, program.as_ref()), + None => ::open::that_detached(path), + } + .map_err(Into::into) +} + +/// Opens URL with the program specified in `with`, or system default if `None`. +/// +/// ## Platform-specific: +/// +/// - **Android / iOS**: Always opens using default program. +/// +/// # Examples +/// +/// ```rust,no_run +/// tauri::Builder::default() +/// .setup(|app| { +/// // open the given URL on the system default browser +/// tauri_plugin_opener::open_url("https://github.com/tauri-apps/tauri", None::<&str>)?; +/// Ok(()) +/// }); +/// ``` +pub fn open_url, S: AsRef>(url: P, with: Option) -> crate::Result<()> { + let url = url.as_ref(); + open(url, with) +} + +/// Opens path with the program specified in `with`, or system default if `None`. +/// +/// ## Platform-specific: +/// +/// - **Android / iOS**: Always opens using default program. +/// +/// # Examples +/// +/// ```rust,no_run +/// tauri::Builder::default() +/// .setup(|app| { +/// // open the given URL on the system default explorer +/// tauri_plugin_opener::open_path("/path/to/file", None::<&str>)?; +/// Ok(()) +/// }); +/// ``` +pub fn open_path, S: AsRef>(path: P, with: Option) -> crate::Result<()> { + let path = path.as_ref(); + if with.is_none() { + // Returns an IO error if not exists, and besides `exists()` is a shorthand for `metadata()` + _ = path.metadata()?; + } + open(path, with) +} diff --git a/plugins/opener/src/reveal_item_in_dir.rs b/plugins/opener/src/reveal_item_in_dir.rs new file mode 100644 index 00000000..6e3dfc2c --- /dev/null +++ b/plugins/opener/src/reveal_item_in_dir.rs @@ -0,0 +1,196 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use std::path::Path; + +/// Reveal a path the system's default explorer. +/// +/// ## Platform-specific: +/// +/// - **Android / iOS:** Unsupported. +pub fn reveal_item_in_dir>(path: P) -> crate::Result<()> { + let path = path.as_ref().canonicalize()?; + + #[cfg(any( + windows, + target_os = "macos", + target_os = "linux", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "netbsd", + target_os = "openbsd" + ))] + return imp::reveal_item_in_dir(&path); + + #[cfg(not(any( + windows, + target_os = "macos", + target_os = "linux", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "netbsd", + target_os = "openbsd" + )))] + Err(crate::Error::UnsupportedPlatform) +} + +#[cfg(windows)] +mod imp { + use super::*; + + use windows::{ + core::{w, HSTRING, PCWSTR}, + Win32::{ + Foundation::ERROR_FILE_NOT_FOUND, + System::Com::CoInitialize, + UI::{ + Shell::{ + ILCreateFromPathW, ILFree, SHOpenFolderAndSelectItems, ShellExecuteExW, + SHELLEXECUTEINFOW, + }, + WindowsAndMessaging::SW_SHOWNORMAL, + }, + }, + }; + + pub fn reveal_item_in_dir(path: &Path) -> crate::Result<()> { + let file = dunce::simplified(path); + + let _ = unsafe { CoInitialize(None) }; + + let dir = file + .parent() + .ok_or_else(|| crate::Error::NoParent(file.to_path_buf()))?; + + let dir = HSTRING::from(dir); + let dir_item = unsafe { ILCreateFromPathW(&dir) }; + + let file_h = HSTRING::from(file); + let file_item = unsafe { ILCreateFromPathW(&file_h) }; + + unsafe { + if let Err(e) = SHOpenFolderAndSelectItems(dir_item, Some(&[file_item]), 0) { + // from https://github.com/electron/electron/blob/10d967028af2e72382d16b7e2025d243b9e204ae/shell/common/platform_util_win.cc#L302 + // On some systems, the above call mysteriously fails with "file not + // found" even though the file is there. In these cases, ShellExecute() + // seems to work as a fallback (although it won't select the file). + if e.code().0 == ERROR_FILE_NOT_FOUND.0 as i32 { + let is_dir = file.is_dir(); + let mut info = SHELLEXECUTEINFOW { + cbSize: std::mem::size_of::() as _, + nShow: SW_SHOWNORMAL.0, + lpFile: PCWSTR(dir.as_ptr()), + lpClass: if is_dir { w!("folder") } else { PCWSTR::null() }, + lpVerb: if is_dir { + w!("explore") + } else { + PCWSTR::null() + }, + ..std::mem::zeroed() + }; + + ShellExecuteExW(&mut info).inspect_err(|_| { + ILFree(Some(dir_item)); + ILFree(Some(file_item)); + })?; + } + } + } + + unsafe { + ILFree(Some(dir_item)); + ILFree(Some(file_item)); + } + + Ok(()) + } +} + +#[cfg(any( + target_os = "linux", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "netbsd", + target_os = "openbsd" +))] +mod imp { + + use std::collections::HashMap; + + use super::*; + + pub fn reveal_item_in_dir(path: &Path) -> crate::Result<()> { + let connection = zbus::blocking::Connection::session()?; + + reveal_with_filemanager1(path, &connection) + .or_else(|_| reveal_with_open_uri_portal(path, &connection)) + } + + fn reveal_with_filemanager1( + path: &Path, + connection: &zbus::blocking::Connection, + ) -> crate::Result<()> { + let uri = url::Url::from_file_path(path) + .map_err(|_| crate::Error::FailedToConvertPathToFileUrl)?; + + #[zbus::proxy( + interface = "org.freedesktop.FileManager1", + default_service = "org.freedesktop.FileManager1", + default_path = "/org/freedesktop/FileManager1" + )] + trait FileManager1 { + async fn ShowItems(&self, name: Vec<&str>, arg2: &str) -> crate::Result<()>; + } + + let proxy = FileManager1ProxyBlocking::new(connection)?; + + proxy.ShowItems(vec![uri.as_str()], "") + } + + fn reveal_with_open_uri_portal( + path: &Path, + connection: &zbus::blocking::Connection, + ) -> crate::Result<()> { + let uri = url::Url::from_file_path(path) + .map_err(|_| crate::Error::FailedToConvertPathToFileUrl)?; + + #[zbus::proxy( + interface = "org.freedesktop.portal.Desktop", + default_service = "org.freedesktop.portal.OpenURI", + default_path = "/org/freedesktop/portal/desktop" + )] + trait PortalDesktop { + async fn OpenDirectory( + &self, + arg1: &str, + name: &str, + arg3: HashMap<&str, &str>, + ) -> crate::Result<()>; + } + + let proxy = PortalDesktopProxyBlocking::new(connection)?; + + proxy.OpenDirectory("", uri.as_str(), HashMap::new()) + } +} + +#[cfg(target_os = "macos")] +mod imp { + use super::*; + use objc2_app_kit::NSWorkspace; + use objc2_foundation::{NSArray, NSString, NSURL}; + pub fn reveal_item_in_dir(path: &Path) -> crate::Result<()> { + unsafe { + let path = path.to_string_lossy(); + let path = NSString::from_str(&path); + let urls = vec![NSURL::fileURLWithPath(&path)]; + let urls = NSArray::from_retained_slice(&urls); + + let workspace = NSWorkspace::new(); + workspace.activateFileViewerSelectingURLs(&urls); + } + + Ok(()) + } +} diff --git a/plugins/opener/src/scope.rs b/plugins/opener/src/scope.rs new file mode 100644 index 00000000..22c9787e --- /dev/null +++ b/plugins/opener/src/scope.rs @@ -0,0 +1,138 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use std::{ + marker::PhantomData, + path::{Path, PathBuf}, + sync::Arc, +}; + +use tauri::{ipc::ScopeObject, utils::acl::Value, AppHandle, Manager, Runtime}; + +use crate::{scope_entry::EntryRaw, Error}; + +pub use crate::scope_entry::Application; + +#[derive(Debug)] +pub enum Entry { + Url { + url: glob::Pattern, + app: Application, + }, + Path { + path: Option, + app: Application, + }, +} + +impl ScopeObject for Entry { + type Error = Error; + + fn deserialize( + app_handle: &AppHandle, + raw: Value, + ) -> std::result::Result { + serde_json::from_value(raw.into()) + .and_then(|raw| { + let entry = match raw { + EntryRaw::Url { url, app } => Entry::Url { + url: glob::Pattern::new(&url) + .map_err(|e| serde::de::Error::custom(e.to_string()))?, + app, + }, + EntryRaw::Path { path, app } => { + let path = match app_handle.path().parse(path) { + Ok(path) => Some(path), + #[cfg(not(target_os = "android"))] + Err(tauri::Error::UnknownPath) => None, + Err(err) => return Err(serde::de::Error::custom(err.to_string())), + }; + + Entry::Path { path, app } + } + }; + + Ok(entry) + }) + .map_err(Into::into) + } +} + +impl Application { + fn matches(&self, a: Option<&str>) -> bool { + match self { + Self::Default => a.is_none(), + Self::Enable(enable) => *enable, + Self::App(program) => Some(program.as_str()) == a, + } + } +} + +impl Entry { + fn path(&self) -> Option { + match self { + Self::Url { .. } => None, + Self::Path { path, .. } => path.clone(), + } + } + + fn matches_url(&self, u: &str, a: Option<&str>) -> bool { + match self { + Self::Url { url, app } => url.matches(u) && app.matches(a), + Self::Path { .. } => false, + } + } + + fn matches_path_program(&self, a: Option<&str>) -> bool { + match self { + Self::Url { .. } => false, + Self::Path { app, .. } => app.matches(a), + } + } +} + +#[derive(Debug)] +pub struct Scope<'a, R: Runtime, M: Manager> { + allowed: Vec<&'a Arc>, + denied: Vec<&'a Arc>, + manager: &'a M, + _marker: PhantomData, +} + +impl<'a, R: Runtime, M: Manager> Scope<'a, R, M> { + pub(crate) fn new( + manager: &'a M, + allowed: Vec<&'a Arc>, + denied: Vec<&'a Arc>, + ) -> Self { + Self { + manager, + allowed, + denied, + _marker: PhantomData, + } + } + + pub fn is_url_allowed(&self, url: &str, with: Option<&str>) -> bool { + let denied = self.denied.iter().any(|e| e.matches_url(url, with)); + if denied { + false + } else { + self.allowed.iter().any(|e| e.matches_url(url, with)) + } + } + + pub fn is_path_allowed(&self, path: &Path, with: Option<&str>) -> crate::Result { + let fs_scope = tauri::fs::Scope::new( + self.manager, + &tauri::utils::config::FsScope::Scope { + allow: self.allowed.iter().filter_map(|e| e.path()).collect(), + deny: self.denied.iter().filter_map(|e| e.path()).collect(), + require_literal_leading_dot: None, + }, + )?; + + Ok(fs_scope.is_allowed(path) && self.allowed.iter().any(|e| e.matches_path_program(with))) + } +} diff --git a/plugins/opener/src/scope_entry.rs b/plugins/opener/src/scope_entry.rs new file mode 100644 index 00000000..cf9004a2 --- /dev/null +++ b/plugins/opener/src/scope_entry.rs @@ -0,0 +1,36 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use std::path::PathBuf; + +use serde::Deserialize; + +#[derive(Deserialize, Debug)] +#[serde(untagged)] +pub enum Application { + Default, + Enable(bool), + App(String), +} + +impl Default for Application { + fn default() -> Self { + Self::Default + } +} + +#[derive(Deserialize)] +#[serde(untagged, rename_all = "camelCase")] +pub(crate) enum EntryRaw { + Url { + url: String, + #[serde(default)] + app: Application, + }, + Path { + path: PathBuf, + #[serde(default)] + app: Application, + }, +} diff --git a/plugins/opener/tsconfig.json b/plugins/opener/tsconfig.json new file mode 100644 index 00000000..5098169a --- /dev/null +++ b/plugins/opener/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.base.json", + "include": ["guest-js/*.ts"] +} diff --git a/plugins/os/CHANGELOG.md b/plugins/os/CHANGELOG.md index a74c8386..415953e4 100644 --- a/plugins/os/CHANGELOG.md +++ b/plugins/os/CHANGELOG.md @@ -1,5 +1,89 @@ # Changelog +## \[2.2.1] + +- [`a1b3fa27`](https://github.com/tauri-apps/plugins-workspace/commit/a1b3fa27f11022c9b6622b4fab12d93239eb05de) ([#2515](https://github.com/tauri-apps/plugins-workspace/pull/2515) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Re-exported the `Geolocation`, `Haptics`, `Notification`, and `Os` structs so that they show up on docs.rs. + +## \[2.2.0] + +- [`3a79266b`](https://github.com/tauri-apps/plugins-workspace/commit/3a79266b8cf96a55b1ae6339d725567d45a44b1d) ([#2173](https://github.com/tauri-apps/plugins-workspace/pull/2173) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Bumped all plugins to `v2.2.0`. From now, the versions for the Rust and JavaScript packages of each plugin will be in sync with each other. + +## \[2.0.1] + +- [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. + +## \[2.0.0] + +- [`e2c4dfb6`](https://github.com/tauri-apps/plugins-workspace/commit/e2c4dfb6af43e5dd8d9ceba232c315f5febd55c1) Update to tauri v2 stable release. + +## \[2.0.0-rc.1] + +- [`e2e97db5`](https://github.com/tauri-apps/plugins-workspace/commit/e2e97db51983267f5be84d4f6f0278d58834d1f5) ([#1701](https://github.com/tauri-apps/plugins-workspace/pull/1701) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri 2.0.0-rc.8 + +## \[2.0.0-rc.0] + +- [`9887d1`](https://github.com/tauri-apps/plugins-workspace/commit/9887d14bd0e971c4c0f5c1188fc4005d3fc2e29e) Update to tauri RC. + +## \[2.0.0-beta.8] + +- [`99d6ac0f`](https://github.com/tauri-apps/plugins-workspace/commit/99d6ac0f9506a6a4a1aa59c728157190a7441af6) ([#1606](https://github.com/tauri-apps/plugins-workspace/pull/1606) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) The JS packages now specify the *minimum* `@tauri-apps/api` version instead of a single exact version. +- [`6de87966`](https://github.com/tauri-apps/plugins-workspace/commit/6de87966ecc00ad9d91c25be452f1f46bd2b7e1f) ([#1597](https://github.com/tauri-apps/plugins-workspace/pull/1597) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Update to tauri beta.25. + +## \[2.0.0-beta.7] + +- [`40ef9a81`](https://github.com/tauri-apps/plugins-workspace/commit/40ef9a818fb03457819c1d72ea84de57fbf868ba) ([#1514](https://github.com/tauri-apps/plugins-workspace/pull/1514) by [@fynntang](https://github.com/tauri-apps/plugins-workspace/../../fynntang)) **Changed:** `platform`, `arch`, `type`, `family`, `version` and `exe_extension` functions in the documentation examples to better reflect that these functions are synchronous. +- [`22a17980`](https://github.com/tauri-apps/plugins-workspace/commit/22a17980ff4f6f8c40adb1b8f4ffc6dae2fe7e30) ([#1537](https://github.com/tauri-apps/plugins-workspace/pull/1537) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri beta.24. + +## \[2.0.0-beta.6] + +- [`0959fe37`](https://github.com/tauri-apps/plugins-workspace/commit/0959fe3757250c6dea6247edb20e6ab468f20511) ([#1353](https://github.com/tauri-apps/plugins-workspace/pull/1353) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) **Breaking** Changed `platform`, `arch`, `type`, `family`, `version` and `exe_extension` functions to be sync. +- [`76daee7a`](https://github.com/tauri-apps/plugins-workspace/commit/76daee7aafece34de3092c86e531cf9eb1138989) ([#1512](https://github.com/tauri-apps/plugins-workspace/pull/1512) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Update to tauri beta.23. + +## \[2.0.0-beta.5] + +- [`9013854f`](https://github.com/tauri-apps/plugins-workspace/commit/9013854f42a49a230b9dbb9d02774765528a923f)([#1382](https://github.com/tauri-apps/plugins-workspace/pull/1382)) Update to tauri beta.22. + +## \[2.0.0-beta.4] + +- [`430bd6f4`](https://github.com/tauri-apps/plugins-workspace/commit/430bd6f4f379bee5d232ae6b098ae131db7f178a)([#1363](https://github.com/tauri-apps/plugins-workspace/pull/1363)) Update to tauri beta.20. + +## \[2.0.0-beta.3] + +- [`bd1ed590`](https://github.com/tauri-apps/plugins-workspace/commit/bd1ed5903ffcce5500310dac1e59e8c67674ef1e)([#1237](https://github.com/tauri-apps/plugins-workspace/pull/1237)) Update to tauri beta.17. + +## \[2.0.0-beta.3] + +- [`a04ea2f`](https://github.com/tauri-apps/plugins-workspace/commit/a04ea2f38294d5a3987578283badc8eec87a7752)([#1071](https://github.com/tauri-apps/plugins-workspace/pull/1071)) The global API script is now only added to the binary when the `withGlobalTauri` config is true. + +## \[2.0.0-beta.2] + +- [`99bea25`](https://github.com/tauri-apps/plugins-workspace/commit/99bea2559c2c0648c2519c50a18cd124dacef57b)([#1005](https://github.com/tauri-apps/plugins-workspace/pull/1005)) Update to tauri beta.8. + +## \[2.0.0-beta.1] + +- [`569defb`](https://github.com/tauri-apps/plugins-workspace/commit/569defbe9492e38938554bb7bdc1be9151456d21) Update to tauri beta.4. + +## \[2.0.0-beta.0] + +- [`d198c01`](https://github.com/tauri-apps/plugins-workspace/commit/d198c014863ee260cb0de88a14b7fc4356ef7474)([#862](https://github.com/tauri-apps/plugins-workspace/pull/862)) Update to tauri beta. + +## \[2.0.0-alpha.6] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.13. + +## \[2.0.0-alpha.5] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.12. +- [`fc62ead`](https://github.com/tauri-apps/plugins-workspace/commit/fc62ead56515b64138b8342af1c5ec6071b715fc)([#721](https://github.com/tauri-apps/plugins-workspace/pull/721)) Fix `Uncaught TypeError: Cannot read properties of undefined (reading 'os')` + +## \[2.0.0-alpha.4] + +- [`e438e0a`](https://github.com/tauri-apps/plugins-workspace/commit/e438e0a62d4b430a5159f05f13ecd397dd891a0d)([#676](https://github.com/tauri-apps/plugins-workspace/pull/676)) Update to @tauri-apps/api v2.0.0-alpha.11. + +## \[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.9. + ## \[2.0.0-alpha.2] - [`4e2cef9`](https://github.com/tauri-apps/plugins-workspace/commit/4e2cef9b702bbbb9cf4ee17de50791cb21f1b2a4)([#593](https://github.com/tauri-apps/plugins-workspace/pull/593)) Update to alpha.12. @@ -21,9 +105,4 @@ ## \[2.0.0-alpha.0] -- [`717ae67`](https://github.com/tauri-apps/plugins-workspace/commit/717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! - te to alpha.11. - -## \[2.0.0-alpha.0] - - [`717ae67`](https://github.com/tauri-apps/plugins-workspace/commit/717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! diff --git a/plugins/os/Cargo.toml b/plugins/os/Cargo.toml index 559d2160..424b7581 100644 --- a/plugins/os/Cargo.toml +++ b/plugins/os/Cargo.toml @@ -1,14 +1,27 @@ [package] name = "tauri-plugin-os" -version = "2.0.0-alpha.2" +version = "2.2.1" description = "Read information about the operating system." edition = { workspace = true } authors = { workspace = true } license = { workspace = true } rust-version = { workspace = true } +repository = { workspace = true } +links = "tauri-plugin-os" [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] + +[package.metadata.platforms.support] +windows = { level = "full", notes = "" } +linux = { level = "full", notes = "" } +macos = { level = "full", notes = "" } +android = { level = "full", notes = "" } +ios = { level = "full", notes = "" } + +[build-dependencies] +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } @@ -18,5 +31,5 @@ log = { workspace = true } thiserror = { workspace = true } os_info = "3" sys-locale = "0.3" -gethostname = "0.4" +gethostname = "1.0" serialize-to-javascript = "=0.1.1" diff --git a/plugins/os/README.md b/plugins/os/README.md index 7e8bc7c1..f6679504 100644 --- a/plugins/os/README.md +++ b/plugins/os/README.md @@ -2,9 +2,17 @@ Read information about the operating system. +| Platform | Supported | +| -------- | --------- | +| Linux | ✓ | +| Windows | ✓ | +| macOS | ✓ | +| Android | ✓ | +| iOS | ✓ | + ## Install -_This plugin requires a Rust version of at least **1.70**_ +_This plugin requires a Rust version of at least **1.77.2**_ There are three general methods of installation that we can recommend. @@ -18,7 +26,7 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] -tauri-plugin-os = "2.0.0-alpha" +tauri-plugin-os = "2.0.0" # alternatively with Git: tauri-plugin-os = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -46,7 +54,7 @@ yarn add https://github.com/tauri-apps/tauri-plugin-os#v2 First you need to register the core plugin with Tauri: -`src-tauri/src/main.rs` +`src-tauri/src/lib.rs` ```rust fn main() { @@ -60,14 +68,30 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import { version } from "@tauri-apps/plugin-os"; -const osVersion = await version(); +import { version } from '@tauri-apps/plugin-os' +const osVersion = await version() ``` ## Contributing PRs accepted. Please make sure to read the Contributing Guide before making a pull request. +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + ## License Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. diff --git a/plugins/os/SECURITY.md b/plugins/os/SECURITY.md new file mode 100644 index 00000000..4f09bbac --- /dev/null +++ b/plugins/os/SECURITY.md @@ -0,0 +1,23 @@ +# Security Policy + +**Do not report security vulnerabilities through public GitHub issues.** + +**Please use the [Private Vulnerability Disclosure](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) feature of GitHub.** + +Include as much of the following information: + +- Type of issue (e.g. improper input parsing, privilege escalation, etc.) +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- The distribution affected or used to help us with reproduction of the issue +- Step-by-step instructions to reproduce the issue +- Ideally a reproduction repository +- Impact of the issue, including how an attacker might exploit the issue + +We prefer to receive reports in English. + +## Contact + +Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). + +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/os/api-iife.js b/plugins/os/api-iife.js new file mode 100644 index 00000000..2b7924de --- /dev/null +++ b/plugins/os/api-iife.js @@ -0,0 +1 @@ +if("__TAURI__"in window){var __TAURI_PLUGIN_OS__=function(_){"use strict";async function n(_,n={},o){return window.__TAURI_INTERNALS__.invoke(_,n,o)}return"function"==typeof SuppressedError&&SuppressedError,_.arch=function(){return window.__TAURI_OS_PLUGIN_INTERNALS__.arch},_.eol=function(){return window.__TAURI_OS_PLUGIN_INTERNALS__.eol},_.exeExtension=function(){return window.__TAURI_OS_PLUGIN_INTERNALS__.exe_extension},_.family=function(){return window.__TAURI_OS_PLUGIN_INTERNALS__.family},_.hostname=async function(){return await n("plugin:os|hostname")},_.locale=async function(){return await n("plugin:os|locale")},_.platform=function(){return window.__TAURI_OS_PLUGIN_INTERNALS__.platform},_.type=function(){return window.__TAURI_OS_PLUGIN_INTERNALS__.os_type},_.version=function(){return window.__TAURI_OS_PLUGIN_INTERNALS__.version},_}({});Object.defineProperty(window.__TAURI__,"os",{value:__TAURI_PLUGIN_OS__})} diff --git a/plugins/os/build.rs b/plugins/os/build.rs new file mode 100644 index 00000000..f108f965 --- /dev/null +++ b/plugins/os/build.rs @@ -0,0 +1,20 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +const COMMANDS: &[&str] = &[ + "platform", + "version", + "os_type", + "family", + "arch", + "exe_extension", + "locale", + "hostname", +]; + +fn main() { + tauri_plugin::Builder::new(COMMANDS) + .global_api_script_path("./api-iife.js") + .build(); +} diff --git a/plugins/os/guest-js/index.ts b/plugins/os/guest-js/index.ts index 01759bd8..697ae8ed 100644 --- a/plugins/os/guest-js/index.ts +++ b/plugins/os/guest-js/index.ts @@ -8,43 +8,49 @@ * @module */ -import { invoke } from "@tauri-apps/api/primitives"; +import { invoke } from '@tauri-apps/api/core' /** @ignore */ declare global { interface Window { - __TAURI__: { - os: { __eol: string }; - }; + __TAURI_OS_PLUGIN_INTERNALS__: { + eol: string + os_type: OsType + platform: Platform + family: Family + version: string + arch: Arch + exe_extension: string + } } } type Platform = - | "linux" - | "macos" - | "ios" - | "freebsd" - | "dragonfly" - | "netbsd" - | "openbsd" - | "solaris" - | "android" - | "windows"; - -type OsType = "linux" | "windows" | "macos" | "ios" | "android"; + | 'linux' + | 'macos' + | 'ios' + | 'freebsd' + | 'dragonfly' + | 'netbsd' + | 'openbsd' + | 'solaris' + | 'android' + | 'windows' + +type OsType = 'linux' | 'windows' | 'macos' | 'ios' | 'android' type Arch = - | "x86" - | "x86_64" - | "arm" - | "aarch64" - | "mips" - | "mips64" - | "powerpc" - | "powerpc64" - | "riscv64" - | "s390x" - | "sparc64"; + | 'x86' + | 'x86_64' + | 'arm' + | 'aarch64' + | 'mips' + | 'mips64' + | 'powerpc' + | 'powerpc64' + | 'riscv64' + | 's390x' + | 'sparc64' /** * Returns the operating system-specific end-of-line marker. @@ -53,8 +59,8 @@ type Arch = * * @since 2.0.0 * */ -function eol() { - return window.__TAURI__.os.__eol; +function eol(): string { + return window.__TAURI_OS_PLUGIN_INTERNALS__.eol } /** @@ -64,14 +70,14 @@ function eol() { * @example * ```typescript * import { platform } from '@tauri-apps/plugin-os'; - * const platformName = await platform(); + * const platformName = platform(); * ``` * * @since 2.0.0 * */ -async function platform(): Promise { - return invoke("plugin:os|platform"); +function platform(): Platform { + return window.__TAURI_OS_PLUGIN_INTERNALS__.platform } /** @@ -79,29 +85,29 @@ async function platform(): Promise { * @example * ```typescript * import { version } from '@tauri-apps/plugin-os'; - * const osVersion = await version(); + * const osVersion = version(); * ``` * * @since 2.0.0 */ -async function version(): Promise { - return invoke("plugin:os|version"); +function version(): string { + return window.__TAURI_OS_PLUGIN_INTERNALS__.version } -type Family = "unix" | "windows"; +type Family = 'unix' | 'windows' /** * Returns the current operating system family. Possible values are `'unix'`, `'windows'`. * @example * ```typescript * import { family } from '@tauri-apps/plugin-os'; - * const family = await family(); + * const family = family(); * ``` * * @since 2.0.0 */ -async function family(): Promise { - return invoke("plugin:os|family"); +function family(): Family { + return window.__TAURI_OS_PLUGIN_INTERNALS__.family } /** @@ -109,13 +115,13 @@ async function family(): Promise { * @example * ```typescript * import { type } from '@tauri-apps/plugin-os'; - * const osType = await type(); + * const osType = type(); * ``` * * @since 2.0.0 */ -async function type(): Promise { - return invoke("plugin:os|os_type"); +function type(): OsType { + return window.__TAURI_OS_PLUGIN_INTERNALS__.os_type } /** @@ -124,44 +130,44 @@ async function type(): Promise { * @example * ```typescript * import { arch } from '@tauri-apps/plugin-os'; - * const archName = await arch(); + * const archName = arch(); * ``` * * @since 2.0.0 */ -async function arch(): Promise { - return invoke("plugin:os|arch"); +function arch(): Arch { + return window.__TAURI_OS_PLUGIN_INTERNALS__.arch } /** - * Returns a String with a `BCP-47` language tag inside. If the locale couldn’t be obtained, `null` is returned instead. + * Returns the file extension, if any, used for executable binaries on this platform. Possible values are `'exe'` and `''` (empty string). * @example * ```typescript - * import { locale } from '@tauri-apps/plugin-os'; - * const locale = await locale(); - * if (locale) { - * // use the locale string here - * } + * import { exeExtension } from '@tauri-apps/plugin-os'; + * const exeExt = exeExtension(); * ``` * * @since 2.0.0 */ -async function locale(): Promise { - return invoke("plugin:os|locale"); +function exeExtension(): string { + return window.__TAURI_OS_PLUGIN_INTERNALS__.exe_extension } /** - * Returns the file extension, if any, used for executable binaries on this platform. Possible values are `'exe'` and `''` (empty string). + * Returns a String with a `BCP-47` language tag inside. If the locale couldn’t be obtained, `null` is returned instead. * @example * ```typescript - * import { exeExtension } from '@tauri-apps/plugin-os'; - * const exeExt = await exeExtension(); + * import { locale } from '@tauri-apps/plugin-os'; + * const locale = await locale(); + * if (locale) { + * // use the locale string here + * } * ``` * * @since 2.0.0 */ -async function exeExtension(): Promise { - return invoke("plugin:os|exe_extension"); +async function locale(): Promise { + return await invoke('plugin:os|locale') } /** @@ -173,7 +179,7 @@ async function exeExtension(): Promise { * ``` */ async function hostname(): Promise { - return invoke("plugin:os|hostname"); + return await invoke('plugin:os|hostname') } export { @@ -185,6 +191,6 @@ export { arch, locale, exeExtension, - hostname, -}; -export type { Platform, OsType, Arch, Family }; + hostname +} +export type { Platform, OsType, Arch, Family } diff --git a/plugins/os/package.json b/plugins/os/package.json index a7539210..840f5352 100644 --- a/plugins/os/package.json +++ b/plugins/os/package.json @@ -1,32 +1,29 @@ { "name": "@tauri-apps/plugin-os", - "version": "2.0.0-alpha.2", - "license": "MIT or APACHE-2.0", + "version": "2.2.1", + "license": "MIT OR Apache-2.0", "authors": [ "Tauri Programme within The Commons Conservancy" ], + "repository": "https://github.com/tauri-apps/plugins-workspace", "type": "module", - "browser": "dist-js/index.min.js", - "module": "dist-js/index.mjs", - "types": "dist-js/index.d.ts", + "types": "./dist-js/index.d.ts", + "main": "./dist-js/index.cjs", + "module": "./dist-js/index.js", "exports": { - "import": "./dist-js/index.mjs", "types": "./dist-js/index.d.ts", - "browser": "./dist-js/index.min.js" + "import": "./dist-js/index.js", + "require": "./dist-js/index.cjs" }, "scripts": { "build": "rollup -c" }, "files": [ "dist-js", - "!dist-js/**/*.map", "README.md", "LICENSE" ], - "devDependencies": { - "tslib": "2.6.0" - }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.9" + "@tauri-apps/api": "^2.0.0" } } diff --git a/plugins/os/permissions/autogenerated/commands/arch.toml b/plugins/os/permissions/autogenerated/commands/arch.toml new file mode 100644 index 00000000..160cce0d --- /dev/null +++ b/plugins/os/permissions/autogenerated/commands/arch.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-arch" +description = "Enables the arch command without any pre-configured scope." +commands.allow = ["arch"] + +[[permission]] +identifier = "deny-arch" +description = "Denies the arch command without any pre-configured scope." +commands.deny = ["arch"] diff --git a/plugins/os/permissions/autogenerated/commands/exe_extension.toml b/plugins/os/permissions/autogenerated/commands/exe_extension.toml new file mode 100644 index 00000000..aef4d2e6 --- /dev/null +++ b/plugins/os/permissions/autogenerated/commands/exe_extension.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-exe-extension" +description = "Enables the exe_extension command without any pre-configured scope." +commands.allow = ["exe_extension"] + +[[permission]] +identifier = "deny-exe-extension" +description = "Denies the exe_extension command without any pre-configured scope." +commands.deny = ["exe_extension"] diff --git a/plugins/os/permissions/autogenerated/commands/family.toml b/plugins/os/permissions/autogenerated/commands/family.toml new file mode 100644 index 00000000..4109be39 --- /dev/null +++ b/plugins/os/permissions/autogenerated/commands/family.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-family" +description = "Enables the family command without any pre-configured scope." +commands.allow = ["family"] + +[[permission]] +identifier = "deny-family" +description = "Denies the family command without any pre-configured scope." +commands.deny = ["family"] diff --git a/plugins/os/permissions/autogenerated/commands/hostname.toml b/plugins/os/permissions/autogenerated/commands/hostname.toml new file mode 100644 index 00000000..c65376cb --- /dev/null +++ b/plugins/os/permissions/autogenerated/commands/hostname.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-hostname" +description = "Enables the hostname command without any pre-configured scope." +commands.allow = ["hostname"] + +[[permission]] +identifier = "deny-hostname" +description = "Denies the hostname command without any pre-configured scope." +commands.deny = ["hostname"] diff --git a/plugins/os/permissions/autogenerated/commands/locale.toml b/plugins/os/permissions/autogenerated/commands/locale.toml new file mode 100644 index 00000000..2a85e471 --- /dev/null +++ b/plugins/os/permissions/autogenerated/commands/locale.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-locale" +description = "Enables the locale command without any pre-configured scope." +commands.allow = ["locale"] + +[[permission]] +identifier = "deny-locale" +description = "Denies the locale command without any pre-configured scope." +commands.deny = ["locale"] diff --git a/plugins/os/permissions/autogenerated/commands/os_type.toml b/plugins/os/permissions/autogenerated/commands/os_type.toml new file mode 100644 index 00000000..c91987a3 --- /dev/null +++ b/plugins/os/permissions/autogenerated/commands/os_type.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-os-type" +description = "Enables the os_type command without any pre-configured scope." +commands.allow = ["os_type"] + +[[permission]] +identifier = "deny-os-type" +description = "Denies the os_type command without any pre-configured scope." +commands.deny = ["os_type"] diff --git a/plugins/os/permissions/autogenerated/commands/platform.toml b/plugins/os/permissions/autogenerated/commands/platform.toml new file mode 100644 index 00000000..49dc08d6 --- /dev/null +++ b/plugins/os/permissions/autogenerated/commands/platform.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-platform" +description = "Enables the platform command without any pre-configured scope." +commands.allow = ["platform"] + +[[permission]] +identifier = "deny-platform" +description = "Denies the platform command without any pre-configured scope." +commands.deny = ["platform"] diff --git a/plugins/os/permissions/autogenerated/commands/version.toml b/plugins/os/permissions/autogenerated/commands/version.toml new file mode 100644 index 00000000..2d65e325 --- /dev/null +++ b/plugins/os/permissions/autogenerated/commands/version.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-version" +description = "Enables the version command without any pre-configured scope." +commands.allow = ["version"] + +[[permission]] +identifier = "deny-version" +description = "Denies the version command without any pre-configured scope." +commands.deny = ["version"] diff --git a/plugins/os/permissions/autogenerated/reference.md b/plugins/os/permissions/autogenerated/reference.md new file mode 100644 index 00000000..9ed7385e --- /dev/null +++ b/plugins/os/permissions/autogenerated/reference.md @@ -0,0 +1,239 @@ +## Default Permission + +This permission set configures which +operating system information are available +to gather from the frontend. + +#### Granted Permissions + +All information except the host name are available. + + + +#### This default permission set includes the following: + +- `allow-arch` +- `allow-exe-extension` +- `allow-family` +- `allow-locale` +- `allow-os-type` +- `allow-platform` +- `allow-version` + +## Permission Table + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IdentifierDescription
+ +`os:allow-arch` + + + +Enables the arch command without any pre-configured scope. + +
+ +`os:deny-arch` + + + +Denies the arch command without any pre-configured scope. + +
+ +`os:allow-exe-extension` + + + +Enables the exe_extension command without any pre-configured scope. + +
+ +`os:deny-exe-extension` + + + +Denies the exe_extension command without any pre-configured scope. + +
+ +`os:allow-family` + + + +Enables the family command without any pre-configured scope. + +
+ +`os:deny-family` + + + +Denies the family command without any pre-configured scope. + +
+ +`os:allow-hostname` + + + +Enables the hostname command without any pre-configured scope. + +
+ +`os:deny-hostname` + + + +Denies the hostname command without any pre-configured scope. + +
+ +`os:allow-locale` + + + +Enables the locale command without any pre-configured scope. + +
+ +`os:deny-locale` + + + +Denies the locale command without any pre-configured scope. + +
+ +`os:allow-os-type` + + + +Enables the os_type command without any pre-configured scope. + +
+ +`os:deny-os-type` + + + +Denies the os_type command without any pre-configured scope. + +
+ +`os:allow-platform` + + + +Enables the platform command without any pre-configured scope. + +
+ +`os:deny-platform` + + + +Denies the platform command without any pre-configured scope. + +
+ +`os:allow-version` + + + +Enables the version command without any pre-configured scope. + +
+ +`os:deny-version` + + + +Denies the version command without any pre-configured scope. + +
diff --git a/plugins/os/permissions/default.toml b/plugins/os/permissions/default.toml new file mode 100644 index 00000000..217b389c --- /dev/null +++ b/plugins/os/permissions/default.toml @@ -0,0 +1,23 @@ +"$schema" = "schemas/schema.json" + +[default] +description = """ +This permission set configures which +operating system information are available +to gather from the frontend. + +#### Granted Permissions + +All information except the host name are available. + +""" + +permissions = [ + "allow-arch", + "allow-exe-extension", + "allow-family", + "allow-locale", + "allow-os-type", + "allow-platform", + "allow-version", +] diff --git a/plugins/os/permissions/schemas/schema.json b/plugins/os/permissions/schemas/schema.json new file mode 100644 index 00000000..36680b44 --- /dev/null +++ b/plugins/os/permissions/schemas/schema.json @@ -0,0 +1,402 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "PermissionFile", + "description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.", + "type": "object", + "properties": { + "default": { + "description": "The default permission set for the plugin", + "anyOf": [ + { + "$ref": "#/definitions/DefaultPermission" + }, + { + "type": "null" + } + ] + }, + "set": { + "description": "A list of permissions sets defined", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionSet" + } + }, + "permission": { + "description": "A list of inlined permissions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Permission" + } + } + }, + "definitions": { + "DefaultPermission": { + "description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.", + "type": "object", + "required": [ + "permissions" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "PermissionSet": { + "description": "A set of direct permissions grouped together under a new name.", + "type": "object", + "required": [ + "description", + "identifier", + "permissions" + ], + "properties": { + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does.", + "type": "string" + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionKind" + } + } + } + }, + "Permission": { + "description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.", + "type": "object", + "required": [ + "identifier" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri internal convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "commands": { + "description": "Allowed or denied commands when using this permission.", + "default": { + "allow": [], + "deny": [] + }, + "allOf": [ + { + "$ref": "#/definitions/Commands" + } + ] + }, + "scope": { + "description": "Allowed or denied scoped when using this permission.", + "allOf": [ + { + "$ref": "#/definitions/Scopes" + } + ] + }, + "platforms": { + "description": "Target platforms this permission applies. By default all platforms are affected by this permission.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Target" + } + } + } + }, + "Commands": { + "description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.", + "type": "object", + "properties": { + "allow": { + "description": "Allowed command.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "deny": { + "description": "Denied command, which takes priority.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "Scopes": { + "description": "An argument for fine grained behavior control of Tauri commands.\n\nIt can be of any serde serializable type and is used to allow or prevent certain actions inside a Tauri command. The configured scope is passed to the command and will be enforced by the command implementation.\n\n## Example\n\n```json { \"allow\": [{ \"path\": \"$HOME/**\" }], \"deny\": [{ \"path\": \"$HOME/secret.txt\" }] } ```", + "type": "object", + "properties": { + "allow": { + "description": "Data that defines what is allowed by the scope.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + }, + "deny": { + "description": "Data that defines what is denied by the scope. This should be prioritized by validation logic.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + } + } + }, + "Value": { + "description": "All supported ACL values.", + "anyOf": [ + { + "description": "Represents a null JSON value.", + "type": "null" + }, + { + "description": "Represents a [`bool`].", + "type": "boolean" + }, + { + "description": "Represents a valid ACL [`Number`].", + "allOf": [ + { + "$ref": "#/definitions/Number" + } + ] + }, + { + "description": "Represents a [`String`].", + "type": "string" + }, + { + "description": "Represents a list of other [`Value`]s.", + "type": "array", + "items": { + "$ref": "#/definitions/Value" + } + }, + { + "description": "Represents a map of [`String`] keys to [`Value`]s.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/Value" + } + } + ] + }, + "Number": { + "description": "A valid ACL number.", + "anyOf": [ + { + "description": "Represents an [`i64`].", + "type": "integer", + "format": "int64" + }, + { + "description": "Represents a [`f64`].", + "type": "number", + "format": "double" + } + ] + }, + "Target": { + "description": "Platform target.", + "oneOf": [ + { + "description": "MacOS.", + "type": "string", + "enum": [ + "macOS" + ] + }, + { + "description": "Windows.", + "type": "string", + "enum": [ + "windows" + ] + }, + { + "description": "Linux.", + "type": "string", + "enum": [ + "linux" + ] + }, + { + "description": "Android.", + "type": "string", + "enum": [ + "android" + ] + }, + { + "description": "iOS.", + "type": "string", + "enum": [ + "iOS" + ] + } + ] + }, + "PermissionKind": { + "type": "string", + "oneOf": [ + { + "description": "Enables the arch command without any pre-configured scope.", + "type": "string", + "const": "allow-arch", + "markdownDescription": "Enables the arch command without any pre-configured scope." + }, + { + "description": "Denies the arch command without any pre-configured scope.", + "type": "string", + "const": "deny-arch", + "markdownDescription": "Denies the arch command without any pre-configured scope." + }, + { + "description": "Enables the exe_extension command without any pre-configured scope.", + "type": "string", + "const": "allow-exe-extension", + "markdownDescription": "Enables the exe_extension command without any pre-configured scope." + }, + { + "description": "Denies the exe_extension command without any pre-configured scope.", + "type": "string", + "const": "deny-exe-extension", + "markdownDescription": "Denies the exe_extension command without any pre-configured scope." + }, + { + "description": "Enables the family command without any pre-configured scope.", + "type": "string", + "const": "allow-family", + "markdownDescription": "Enables the family command without any pre-configured scope." + }, + { + "description": "Denies the family command without any pre-configured scope.", + "type": "string", + "const": "deny-family", + "markdownDescription": "Denies the family command without any pre-configured scope." + }, + { + "description": "Enables the hostname command without any pre-configured scope.", + "type": "string", + "const": "allow-hostname", + "markdownDescription": "Enables the hostname command without any pre-configured scope." + }, + { + "description": "Denies the hostname command without any pre-configured scope.", + "type": "string", + "const": "deny-hostname", + "markdownDescription": "Denies the hostname command without any pre-configured scope." + }, + { + "description": "Enables the locale command without any pre-configured scope.", + "type": "string", + "const": "allow-locale", + "markdownDescription": "Enables the locale command without any pre-configured scope." + }, + { + "description": "Denies the locale command without any pre-configured scope.", + "type": "string", + "const": "deny-locale", + "markdownDescription": "Denies the locale command without any pre-configured scope." + }, + { + "description": "Enables the os_type command without any pre-configured scope.", + "type": "string", + "const": "allow-os-type", + "markdownDescription": "Enables the os_type command without any pre-configured scope." + }, + { + "description": "Denies the os_type command without any pre-configured scope.", + "type": "string", + "const": "deny-os-type", + "markdownDescription": "Denies the os_type command without any pre-configured scope." + }, + { + "description": "Enables the platform command without any pre-configured scope.", + "type": "string", + "const": "allow-platform", + "markdownDescription": "Enables the platform command without any pre-configured scope." + }, + { + "description": "Denies the platform command without any pre-configured scope.", + "type": "string", + "const": "deny-platform", + "markdownDescription": "Denies the platform command without any pre-configured scope." + }, + { + "description": "Enables the version command without any pre-configured scope.", + "type": "string", + "const": "allow-version", + "markdownDescription": "Enables the version command without any pre-configured scope." + }, + { + "description": "Denies the version command without any pre-configured scope.", + "type": "string", + "const": "deny-version", + "markdownDescription": "Denies the version command without any pre-configured scope." + }, + { + "description": "This permission set configures which\noperating system information are available\nto gather from the frontend.\n\n#### Granted Permissions\n\nAll information except the host name are available.\n\n\n#### This default permission set includes:\n\n- `allow-arch`\n- `allow-exe-extension`\n- `allow-family`\n- `allow-locale`\n- `allow-os-type`\n- `allow-platform`\n- `allow-version`", + "type": "string", + "const": "default", + "markdownDescription": "This permission set configures which\noperating system information are available\nto gather from the frontend.\n\n#### Granted Permissions\n\nAll information except the host name are available.\n\n\n#### This default permission set includes:\n\n- `allow-arch`\n- `allow-exe-extension`\n- `allow-family`\n- `allow-locale`\n- `allow-os-type`\n- `allow-platform`\n- `allow-version`" + } + ] + } + } +} \ No newline at end of file diff --git a/plugins/os/rollup.config.js b/plugins/os/rollup.config.js new file mode 100644 index 00000000..1f349ec8 --- /dev/null +++ b/plugins/os/rollup.config.js @@ -0,0 +1,7 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import { createConfig } from '../../shared/rollup.config.js' + +export default createConfig() diff --git a/plugins/os/rollup.config.mjs b/plugins/os/rollup.config.mjs deleted file mode 100644 index 99a3dd31..00000000 --- a/plugins/os/rollup.config.mjs +++ /dev/null @@ -1,11 +0,0 @@ -import { readFileSync } from "fs"; - -import { createConfig } from "../../shared/rollup.config.mjs"; - -export default createConfig({ - input: "guest-js/index.ts", - pkg: JSON.parse( - readFileSync(new URL("./package.json", import.meta.url), "utf8"), - ), - external: [/^@tauri-apps\/api/], -}); diff --git a/plugins/os/src/api-iife.js b/plugins/os/src/api-iife.js deleted file mode 100644 index 8193db54..00000000 --- a/plugins/os/src/api-iife.js +++ /dev/null @@ -1 +0,0 @@ -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__})} diff --git a/plugins/os/src/commands.rs b/plugins/os/src/commands.rs index fdfa09a0..b10c7f5d 100644 --- a/plugins/os/src/commands.rs +++ b/plugins/os/src/commands.rs @@ -2,36 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -#[tauri::command] -pub fn platform() -> &'static str { - crate::platform() -} - -#[tauri::command] -pub fn version() -> String { - crate::version().to_string() -} - -#[tauri::command] -pub fn os_type() -> String { - crate::type_().to_string() -} - -#[tauri::command] -pub fn family() -> &'static str { - crate::family() -} - -#[tauri::command] -pub fn arch() -> &'static str { - crate::arch() -} - -#[tauri::command] -pub fn exe_extension() -> &'static str { - crate::exe_extension() -} - #[tauri::command] pub fn locale() -> Option { crate::locale() diff --git a/plugins/os/src/init.js b/plugins/os/src/init.js index 33e42748..97eeab3a 100644 --- a/plugins/os/src/init.js +++ b/plugins/os/src/init.js @@ -2,7 +2,15 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -__RAW_global_os_api__; - // eslint-disable-next-line -window.__TAURI__.os.__eol = __TEMPLATE_eol__; +Object.defineProperty(window, '__TAURI_OS_PLUGIN_INTERNALS__', { + value: { + eol: __TEMPLATE_eol__, + os_type: __TEMPLATE_os_type__, + platform: __TEMPLATE_platform__, + family: __TEMPLATE_family__, + version: __TEMPLATE_version__, + arch: __TEMPLATE_arch__, + exe_extension: __TEMPLATE_exe_extension__ + } +}) diff --git a/plugins/os/src/lib.rs b/plugins/os/src/lib.rs index fab629d5..50ab89ee 100644 --- a/plugins/os/src/lib.rs +++ b/plugins/os/src/lib.rs @@ -2,8 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -//! [![](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/os/banner.png)](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/os) -//! //! Read information about the operating system. #![doc( @@ -90,7 +88,7 @@ pub fn exe_extension() -> &'static str { std::env::consts::EXE_EXTENSION } -/// Returns the current operating system locale with the `BCP-47` language tag. If the locale couldn’t be obtained, `None` is returned instead. +/// Returns the current operating system locale with the `BCP-47` language tag. If the locale couldn't be obtained, `None` is returned instead. pub fn locale() -> Option { sys_locale::get_locale() } @@ -102,33 +100,42 @@ pub fn hostname() -> String { #[derive(Template)] #[default_template("./init.js")] -struct InitJavascript { - #[raw] - global_os_api: &'static str, +struct InitJavascript<'a> { eol: &'static str, + os_type: String, + platform: &'a str, + family: &'a str, + version: String, + arch: &'a str, + exe_extension: &'a str, } -pub fn init() -> TauriPlugin { - let init_js = InitJavascript { - global_os_api: include_str!("api-iife.js"), - #[cfg(windows)] - eol: "\r\n", - #[cfg(not(windows))] - eol: "\n", +impl InitJavascript<'_> { + fn new() -> Self { + Self { + #[cfg(windows)] + eol: "\r\n", + #[cfg(not(windows))] + eol: "\n", + os_type: crate::type_().to_string(), + platform: crate::platform(), + family: crate::family(), + version: crate::version().to_string(), + arch: crate::arch(), + exe_extension: crate::exe_extension(), + } } - .render_default(&Default::default()) - // this will never fail with the above global_os_api eol values - .unwrap(); +} + +pub fn init() -> TauriPlugin { + let init_js = InitJavascript::new() + .render_default(&Default::default()) + // this will never fail with the above global_os_api values + .unwrap(); Builder::new("os") .js_init_script(init_js.to_string()) .invoke_handler(tauri::generate_handler![ - commands::platform, - commands::version, - commands::os_type, - commands::family, - commands::arch, - commands::exe_extension, commands::locale, commands::hostname ]) diff --git a/plugins/persisted-scope/CHANGELOG.md b/plugins/persisted-scope/CHANGELOG.md index e918b31e..5261ec8f 100644 --- a/plugins/persisted-scope/CHANGELOG.md +++ b/plugins/persisted-scope/CHANGELOG.md @@ -1,5 +1,254 @@ # Changelog +## \[2.2.2] + +### Dependencies + +- Upgraded to `fs@2.3.0` + +## \[2.2.1] + +### Dependencies + +- Upgraded to `fs@2.2.1` + +## \[2.2.0] + +- [`3a79266b`](https://github.com/tauri-apps/plugins-workspace/commit/3a79266b8cf96a55b1ae6339d725567d45a44b1d) ([#2173](https://github.com/tauri-apps/plugins-workspace/pull/2173) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Bumped all plugins to `v2.2.0`. From now, the versions for the Rust and JavaScript packages of each plugin will be in sync with each other. + +### Dependencies + +- Upgraded to `fs@2.2.0` + +## \[2.1.1] + +### Dependencies + +- Upgraded to `fs@2.1.1` + +## \[2.1.0] + +- [`fecfd553`](https://github.com/tauri-apps/plugins-workspace/commit/fecfd5533a6452f054fbcd909021f12b0dce834f) ([#2070](https://github.com/tauri-apps/plugins-workspace/pull/2070) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) **Breaking Change:** Replaced the custom `tauri_plugin_fs::Scope` struct with `tauri::fs::Scope`. + +### Dependencies + +- Upgraded to `fs@2.1.0` + +## \[2.0.3] + +### Dependencies + +- Upgraded to `fs@2.0.3` + +## \[2.0.2] + +### Dependencies + +- Upgraded to `fs@2.0.2` + +## \[2.0.1] + +- [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. + +### Dependencies + +- Upgraded to `fs@2.0.1` + +## \[2.0.0] + +- [`e2c4dfb6`](https://github.com/tauri-apps/plugins-workspace/commit/e2c4dfb6af43e5dd8d9ceba232c315f5febd55c1) Update to tauri v2 stable release. + +### Dependencies + +- Upgraded to `fs@2.0.0` + +## \[2.0.0-rc.6] + +### Dependencies + +- Upgraded to `fs@2.0.0-rc.6` + +## \[2.0.0-rc.5] + +### Dependencies + +- Upgraded to `fs@2.0.0-rc.5` + +## \[2.0.0-rc.4] + +### Dependencies + +- Upgraded to `fs@2.0.0-rc.4` + +## \[2.0.0-rc.3] + +### Dependencies + +- Upgraded to `fs@2.0.0-rc.3` + +## \[2.0.0-rc.2] + +### Dependencies + +- Upgraded to `fs@2.0.0-rc.2` + +## \[2.0.0-rc.1] + +- [`e2e97db5`](https://github.com/tauri-apps/plugins-workspace/commit/e2e97db51983267f5be84d4f6f0278d58834d1f5) ([#1701](https://github.com/tauri-apps/plugins-workspace/pull/1701) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri 2.0.0-rc.8 + +### Dependencies + +- Upgraded to `fs@2.0.0-rc.1` + +## \[2.0.0-rc.0] + +- [`9887d1`](https://github.com/tauri-apps/plugins-workspace/commit/9887d14bd0e971c4c0f5c1188fc4005d3fc2e29e) Update to tauri RC. + +### Dependencies + +- Upgraded to `fs@2.0.0-rc.0` + +## \[2.0.0-beta.12] + +- [`e847cedc`](https://github.com/tauri-apps/plugins-workspace/commit/e847cedc1f46f3e7a2ad81ea579b620bc5b992d7) ([#1402](https://github.com/tauri-apps/plugins-workspace/pull/1402) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Use no default features on tauri for all plugins so that consumers can use `default-features = false` on tauri, note that this will still enable wry feature on iOS +- [`6de87966`](https://github.com/tauri-apps/plugins-workspace/commit/6de87966ecc00ad9d91c25be452f1f46bd2b7e1f) ([#1597](https://github.com/tauri-apps/plugins-workspace/pull/1597) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Update to tauri beta.25. + +### Dependencies + +- Upgraded to `fs@2.0.0-beta.12` + +## \[2.0.0-beta.11] + +- [`22a17980`](https://github.com/tauri-apps/plugins-workspace/commit/22a17980ff4f6f8c40adb1b8f4ffc6dae2fe7e30) ([#1537](https://github.com/tauri-apps/plugins-workspace/pull/1537) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri beta.24. + +### Dependencies + +- Upgraded to `fs@2.0.0-beta.11` + +## \[2.0.0-beta.10] + +- [`76daee7a`](https://github.com/tauri-apps/plugins-workspace/commit/76daee7aafece34de3092c86e531cf9eb1138989) ([#1512](https://github.com/tauri-apps/plugins-workspace/pull/1512) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Update to tauri beta.23. + +### Dependencies + +- Upgraded to `fs@2.0.0-beta.10` + +## \[2.0.0-beta.9] + +- [`9013854f`](https://github.com/tauri-apps/plugins-workspace/commit/9013854f42a49a230b9dbb9d02774765528a923f)([#1382](https://github.com/tauri-apps/plugins-workspace/pull/1382)) Update to tauri beta.22. + +### Dependencies + +- Upgraded to `fs@2.0.0-beta.9` + +## \[2.0.0-beta.8] + +- [`430bd6f4`](https://github.com/tauri-apps/plugins-workspace/commit/430bd6f4f379bee5d232ae6b098ae131db7f178a)([#1363](https://github.com/tauri-apps/plugins-workspace/pull/1363)) Update to tauri beta.20. + +### Dependencies + +- Upgraded to `fs@2.0.0-beta.8` + +## \[2.0.0-beta.7] + +- [`bd1ed590`](https://github.com/tauri-apps/plugins-workspace/commit/bd1ed5903ffcce5500310dac1e59e8c67674ef1e)([#1237](https://github.com/tauri-apps/plugins-workspace/pull/1237)) Update to tauri beta.17. + +### Dependencies + +- Upgraded to `fs@2.0.0-beta.7` + +## \[2.0.0-beta.6] + +### Dependencies + +- Upgraded to `fs@2.0.0-beta.6` + +## \[2.0.0-beta.5] + +### Dependencies + +- Upgraded to `fs@2.0.0-beta.5` + +## \[2.0.0-beta.4] + +### Dependencies + +- Upgraded to `fs@2.0.0-beta.4` + +## \[2.0.0-beta.3] + +- [`a04ea2f`](https://github.com/tauri-apps/plugins-workspace/commit/a04ea2f38294d5a3987578283badc8eec87a7752)([#1071](https://github.com/tauri-apps/plugins-workspace/pull/1071)) The global API script is now only added to the binary when the `withGlobalTauri` config is true. + +### Dependencies + +- Upgraded to `fs@2.0.0-beta.3` + +## \[2.0.0-beta.2] + +- [`99bea25`](https://github.com/tauri-apps/plugins-workspace/commit/99bea2559c2c0648c2519c50a18cd124dacef57b)([#1005](https://github.com/tauri-apps/plugins-workspace/pull/1005)) Update to tauri beta.8. + +### Dependencies + +- Upgraded to `fs@2.0.0-beta.2` + +## \[2.0.0-beta.1] + +- [`14f381a`](https://github.com/tauri-apps/plugins-workspace/commit/14f381acf8fe690acecc676922c6f05939b95734) Update MSRV to 1.75. +- [`569defb`](https://github.com/tauri-apps/plugins-workspace/commit/569defbe9492e38938554bb7bdc1be9151456d21) Update to tauri beta.4. + +### Dependencies + +- Upgraded to `fs@2.0.0-beta.1` + +## \[2.0.0-beta.0] + +- [`d198c01`](https://github.com/tauri-apps/plugins-workspace/commit/d198c014863ee260cb0de88a14b7fc4356ef7474)([#862](https://github.com/tauri-apps/plugins-workspace/pull/862)) Update to tauri beta. +- [`d198c01`](https://github.com/tauri-apps/plugins-workspace/commit/d198c014863ee260cb0de88a14b7fc4356ef7474)([#862](https://github.com/tauri-apps/plugins-workspace/pull/862)) Add permissions. + +### Dependencies + +- Upgraded to `fs@2.0.0-beta.0` + +## \[2.0.0-alpha.7] + +### Dependencies + +- Upgraded to `fs@2.0.0-alpha.7` + +## \[2.0.0-alpha.6] + +- [`2cf8faa`](https://github.com/tauri-apps/plugins-workspace/commit/2cf8faa3e149af55eb86e5aba8ebfc54210ca703)([#839](https://github.com/tauri-apps/plugins-workspace/pull/839)) Update to tauri@alpha.20. +- [`10b8039`](https://github.com/tauri-apps/plugins-workspace/commit/10b80391fcdef28e26124505053fb3a4c4f85e75)([#825](https://github.com/tauri-apps/plugins-workspace/pull/825)) Use `tauri::scope::fs::Scope` instead of local copy of its implementation. + +### Dependencies + +- Upgraded to `fs@2.0.0-alpha.6` + +## \[2.0.0-alpha.5] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to tauri@alpha.18. + +### Dependencies + +- Upgraded to `fs@2.0.0-alpha.5` + +## \[2.0.0-alpha.4] + +- [`e438e0a`](https://github.com/tauri-apps/plugins-workspace/commit/e438e0a62d4b430a5159f05f13ecd397dd891a0d)([#676](https://github.com/tauri-apps/plugins-workspace/pull/676)) Update to tauri@alpha.17. + +### Dependencies + +- Upgraded to `fs@2.0.0-alpha.4` + +## \[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 MSRV to 1.75. +- [`5de23e7`](https://github.com/tauri-apps/plugins-workspace/commit/5de23e79f9880921b62e4b7a8819bc0dbc833216)([#649](https://github.com/tauri-apps/plugins-workspace/pull/649)) Update to tauri@alpha.15. + +### Dependencies + +- Upgraded to `fs@2.0.0-alpha.3` + ## \[2.0.0-alpha.2] - [`4e2cef9`](https://github.com/tauri-apps/plugins-workspace/commit/4e2cef9b702bbbb9cf4ee17de50791cb21f1b2a4)([#593](https://github.com/tauri-apps/plugins-workspace/pull/593)) Update to alpha.12. diff --git a/plugins/persisted-scope/Cargo.toml b/plugins/persisted-scope/Cargo.toml index e38b1e23..06bcaff0 100644 --- a/plugins/persisted-scope/Cargo.toml +++ b/plugins/persisted-scope/Cargo.toml @@ -1,14 +1,23 @@ [package] name = "tauri-plugin-persisted-scope" -version = "2.0.0-alpha.2" +version = "2.2.2" description = "Save filesystem and asset scopes and restore them when the app is reopened." authors = { workspace = true } license = { workspace = true } edition = { workspace = true } rust-version = { workspace = true } +repository = { workspace = true } [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] + +[package.metadata.platforms.support] +windows = { level = "full", notes = "" } +linux = { level = "full", notes = "" } +macos = { level = "full", notes = "" } +android = { level = "full", notes = "" } +ios = { level = "full", notes = "" } [dependencies] serde = { workspace = true } @@ -16,9 +25,9 @@ serde_json = { workspace = true } tauri = { workspace = true } log = { workspace = true } thiserror = { workspace = true } -aho-corasick = "1.0" +aho-corasick = "1" bincode = "1" -tauri-plugin-fs = { path = "../fs", version = "2.0.0-alpha.2" } +tauri-plugin-fs = { path = "../fs", version = "2.3.0" } [features] -protocol-asset = [ "tauri/protocol-asset" ] +protocol-asset = ["tauri/protocol-asset"] diff --git a/plugins/persisted-scope/README.md b/plugins/persisted-scope/README.md index 5a9d1a7e..c3ec88fe 100644 --- a/plugins/persisted-scope/README.md +++ b/plugins/persisted-scope/README.md @@ -2,9 +2,17 @@ Save filesystem and asset scopes and restore them when the app is reopened. +| Platform | Supported | +| -------- | --------- | +| Linux | ✓ | +| Windows | ✓ | +| macOS | ✓ | +| Android | ✓ | +| iOS | ✓ | + ## Install -_This plugin requires a Rust version of at least **1.70**_ +_This plugin requires a Rust version of at least **1.77.2**_ There are three general methods of installation that we can recommend. @@ -18,7 +26,7 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] -tauri-plugin-persisted-scope = "2.0.0-alpha" +tauri-plugin-persisted-scope = "2.0.0" # alternatively with Git: tauri-plugin-persisted-scope = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -27,7 +35,7 @@ tauri-plugin-persisted-scope = { git = "https://github.com/tauri-apps/plugins-wo First you need to register the core plugin with Tauri: -`src-tauri/src/main.rs` +`src-tauri/src/lib.rs` ```rust fn main() { @@ -44,6 +52,22 @@ Afterwards the plugin will automatically save and restore filesystem and asset s PRs accepted. Please make sure to read the Contributing Guide before making a pull request. +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + ## License Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. diff --git a/plugins/persisted-scope/SECURITY.md b/plugins/persisted-scope/SECURITY.md new file mode 100644 index 00000000..4f09bbac --- /dev/null +++ b/plugins/persisted-scope/SECURITY.md @@ -0,0 +1,23 @@ +# Security Policy + +**Do not report security vulnerabilities through public GitHub issues.** + +**Please use the [Private Vulnerability Disclosure](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) feature of GitHub.** + +Include as much of the following information: + +- Type of issue (e.g. improper input parsing, privilege escalation, etc.) +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- The distribution affected or used to help us with reproduction of the issue +- Step-by-step instructions to reproduce the issue +- Ideally a reproduction repository +- Impact of the issue, including how an attacker might exploit the issue + +We prefer to receive reports in English. + +## Contact + +Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). + +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/persisted-scope/src/lib.rs b/plugins/persisted-scope/src/lib.rs index 8012e8b9..6ced7b24 100644 --- a/plugins/persisted-scope/src/lib.rs +++ b/plugins/persisted-scope/src/lib.rs @@ -2,8 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -//! [![](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/persisted-scope/banner.png)](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/persisted-scope) -//! //! Save filesystem and asset scopes and restore them when the app is reopened. #![doc( @@ -13,17 +11,14 @@ use aho_corasick::AhoCorasick; use serde::{Deserialize, Serialize}; + use tauri::{ plugin::{Builder, TauriPlugin}, - scope::fs::Pattern as GlobPattern, Manager, Runtime, }; -#[cfg(feature = "protocol-asset")] -use tauri::{FsScope, FsScopeEvent}; -use tauri_plugin_fs::{FsExt, Scope as FsPluginScope, ScopeEvent as FsPluginScopeEvent}; +use tauri_plugin_fs::FsExt; use std::{ - collections::HashSet, fs::{create_dir_all, File}, io::Write, path::Path, @@ -47,70 +42,6 @@ const PATTERNS: &[&str] = &[ ]; const REPLACE_WITH: &[&str] = &[r"[", r"]", r"?", r"*", r"\?", r"\\?\", r"\\?\"]; -trait ScopeExt { - fn allow_file(&self, path: &Path); - fn allow_directory(&self, path: &Path, recursive: bool); - - fn forbid_file(&self, path: &Path); - fn forbid_directory(&self, path: &Path, recursive: bool); - - fn allowed_patterns(&self) -> HashSet; - fn forbidden_patterns(&self) -> HashSet; -} - -impl ScopeExt for &FsPluginScope { - fn allow_file(&self, path: &Path) { - let _ = FsPluginScope::allow_file(self, path); - } - - fn allow_directory(&self, path: &Path, recursive: bool) { - let _ = FsPluginScope::allow_directory(self, path, recursive); - } - - fn forbid_file(&self, path: &Path) { - let _ = FsPluginScope::forbid_file(self, path); - } - - fn forbid_directory(&self, path: &Path, recursive: bool) { - let _ = FsPluginScope::forbid_directory(self, path, recursive); - } - - fn allowed_patterns(&self) -> HashSet { - FsPluginScope::allowed_patterns(self) - } - - fn forbidden_patterns(&self) -> HashSet { - FsPluginScope::forbidden_patterns(self) - } -} - -#[cfg(feature = "protocol-asset")] -impl ScopeExt for &FsScope { - fn allow_file(&self, path: &Path) { - let _ = FsScope::allow_file(self, path); - } - - fn allow_directory(&self, path: &Path, recursive: bool) { - let _ = FsScope::allow_directory(self, path, recursive); - } - - fn forbid_file(&self, path: &Path) { - let _ = FsScope::forbid_file(self, path); - } - - fn forbid_directory(&self, path: &Path, recursive: bool) { - let _ = FsScope::forbid_directory(self, path, recursive); - } - - fn allowed_patterns(&self) -> HashSet { - FsScope::allowed_patterns(self) - } - - fn forbidden_patterns(&self) -> HashSet { - FsScope::forbidden_patterns(self) - } -} - #[derive(Debug, thiserror::Error)] enum Error { #[error(transparent)] @@ -171,41 +102,41 @@ fn fix_directory(path_str: &str) -> &Path { path } -fn allow_path(scope: impl ScopeExt, path: &str) { +fn allow_path(scope: &tauri::fs::Scope, path: &str) { let target_type = detect_scope_type(path); match target_type { TargetType::File => { - scope.allow_file(Path::new(path)); + let _ = scope.allow_file(Path::new(path)); } TargetType::Directory => { // We remove the '*' at the end of it, else it will be escaped by the pattern. - scope.allow_directory(fix_directory(path), false); + let _ = scope.allow_directory(fix_directory(path), false); } TargetType::RecursiveDirectory => { // We remove the '**' at the end of it, else it will be escaped by the pattern. - scope.allow_directory(fix_directory(path), true); + let _ = scope.allow_directory(fix_directory(path), true); } } } -fn forbid_path(scope: impl ScopeExt, path: &str) { +fn forbid_path(scope: &tauri::fs::Scope, path: &str) { let target_type = detect_scope_type(path); match target_type { TargetType::File => { - scope.forbid_file(Path::new(path)); + let _ = scope.forbid_file(Path::new(path)); } TargetType::Directory => { - scope.forbid_directory(fix_directory(path), false); + let _ = scope.forbid_directory(fix_directory(path), false); } TargetType::RecursiveDirectory => { - scope.forbid_directory(fix_directory(path), true); + let _ = scope.forbid_directory(fix_directory(path), true); } } } -fn save_scopes(scope: impl ScopeExt, app_dir: &Path, scope_state_path: &Path) { +fn save_scopes(scope: &tauri::fs::Scope, app_dir: &Path, scope_state_path: &Path) { let scope = Scope { allowed_paths: scope .allowed_patterns() @@ -242,8 +173,12 @@ pub fn init() -> TauriPlugin { #[cfg(feature = "protocol-asset")] let asset_scope_state_path = app_dir.join(ASSET_SCOPE_STATE_FILENAME); - if let Some(fs_scope) = fs_scope { - let _ = fs_scope.forbid_file(&fs_scope_state_path);} + if let Some(fs_scope) = &fs_scope { + let _ = fs_scope.forbid_file(&fs_scope_state_path); + } else { + #[cfg(debug_assertions)] + eprintln!("Please make sure to register the `fs` plugin before the `persisted-scope` plugin!"); + } #[cfg(feature = "protocol-asset")] let _ = asset_protocol_scope.forbid_file(&asset_scope_state_path); @@ -251,7 +186,7 @@ pub fn init() -> TauriPlugin { // We will still save some semi-broken values because the scope events are quite spammy and we don't want to reduce runtime performance any further. let ac = AhoCorasick::new(PATTERNS).unwrap(/* This should be impossible to fail since we're using a small static input */); - if let Some(fs_scope) = fs_scope { + if let Some(fs_scope) = &fs_scope { if fs_scope_state_path.exists() { let scope: Scope = std::fs::read(&fs_scope_state_path) .map_err(Error::from) @@ -271,7 +206,7 @@ pub fn init() -> TauriPlugin { // This is needed to fix broken .peristed-scope files in case the app doesn't update the scope itself. save_scopes(fs_scope, &app_dir, &fs_scope_state_path); } - } + } #[cfg(feature = "protocol-asset")] if asset_scope_state_path.exists() { @@ -295,11 +230,12 @@ pub fn init() -> TauriPlugin { #[cfg(feature = "protocol-asset")] let app_dir_ = app_dir.clone(); - if let Some(fs_scope) = fs_scope { - let fs_scope_ = fs_scope.clone(); + + if let Some(fs_scope) = &fs_scope { + let app_ = app.clone(); fs_scope.listen(move |event| { - if let FsPluginScopeEvent::PathAllowed(_) = event { - save_scopes(&fs_scope_, &app_dir, &fs_scope_state_path); + if let tauri::fs::Event::PathAllowed(_) = event { + save_scopes(&app_.fs_scope(), &app_dir, &fs_scope_state_path); } }); } @@ -308,10 +244,11 @@ pub fn init() -> TauriPlugin { { let asset_protocol_scope_ = asset_protocol_scope.clone(); asset_protocol_scope.listen(move |event| { - if let FsScopeEvent::PathAllowed(_) = event { - save_scopes(&asset_protocol_scope_, &app_dir_, &asset_scope_state_path); - } - });} + if let tauri::scope::fs::Event::PathAllowed(_) = event { + save_scopes(&asset_protocol_scope_, &app_dir_, &asset_scope_state_path); + } + }); + } } Ok(()) }) diff --git a/plugins/positioner/.gitignore b/plugins/positioner/.gitignore deleted file mode 100644 index b512c09d..00000000 --- a/plugins/positioner/.gitignore +++ /dev/null @@ -1 +0,0 @@ -node_modules \ No newline at end of file diff --git a/plugins/positioner/CHANGELOG.md b/plugins/positioner/CHANGELOG.md index 962ea04a..3070b168 100644 --- a/plugins/positioner/CHANGELOG.md +++ b/plugins/positioner/CHANGELOG.md @@ -1,5 +1,98 @@ # Changelog +## \[2.2.0] + +- [`3a79266b`](https://github.com/tauri-apps/plugins-workspace/commit/3a79266b8cf96a55b1ae6339d725567d45a44b1d) ([#2173](https://github.com/tauri-apps/plugins-workspace/pull/2173) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Bumped all plugins to `v2.2.0`. From now, the versions for the Rust and JavaScript packages of each plugin will be in sync with each other. + +## \[2.1.0] + +- [`4db62635`](https://github.com/tauri-apps/plugins-workspace/commit/4db626354c8e29e37bedcf94787a8dd36ce21c55) ([#2076](https://github.com/tauri-apps/plugins-workspace/pull/2076) by [@jakobwesthoff](https://github.com/tauri-apps/plugins-workspace/../../jakobwesthoff)) Add `moveWindowConstrained` function that is similar to `moveWindow` but constrains the window to the screen dimensions in case of tray icon positions. + +## \[2.0.1] + +- [`3c1f3874`](https://github.com/tauri-apps/plugins-workspace/commit/3c1f3874f4c828637b3aa983cba13c77427faf58) ([#1911](https://github.com/tauri-apps/plugins-workspace/pull/1911) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Added missing permission for `handleIconState` and fixed its event processing logic. + +## \[2.0.1] + +- [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. + +## \[2.0.0] + +- [`e2c4dfb6`](https://github.com/tauri-apps/plugins-workspace/commit/e2c4dfb6af43e5dd8d9ceba232c315f5febd55c1) Update to tauri v2 stable release. + +## \[2.0.0-rc.2] + +- [`2f7e32b5`](https://github.com/tauri-apps/plugins-workspace/commit/2f7e32b5e07454d6c0cf3ab03f8af8da74c4a8a7) ([#1822](https://github.com/tauri-apps/plugins-workspace/pull/1822) by [@jbolda](https://github.com/tauri-apps/plugins-workspace/../../jbolda)) `handleIconState` function for use in JavaScript event handlers. This allows one to update the TrayIcon state through JavaScript and fully create and handle the TrayIcon without requiring Rust (and the side-effect of creating a TrayIcon). + +## \[2.0.0-rc.1] + +- [`e2e97db5`](https://github.com/tauri-apps/plugins-workspace/commit/e2e97db51983267f5be84d4f6f0278d58834d1f5) ([#1701](https://github.com/tauri-apps/plugins-workspace/pull/1701) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri 2.0.0-rc.8 + +## \[2.0.0-rc.0] + +- [`9887d1`](https://github.com/tauri-apps/plugins-workspace/commit/9887d14bd0e971c4c0f5c1188fc4005d3fc2e29e) Update to tauri RC. + +## \[2.0.0-beta.8] + +- [`99d6ac0f`](https://github.com/tauri-apps/plugins-workspace/commit/99d6ac0f9506a6a4a1aa59c728157190a7441af6) ([#1606](https://github.com/tauri-apps/plugins-workspace/pull/1606) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) The JS packages now specify the *minimum* `@tauri-apps/api` version instead of a single exact version. +- [`6de87966`](https://github.com/tauri-apps/plugins-workspace/commit/6de87966ecc00ad9d91c25be452f1f46bd2b7e1f) ([#1597](https://github.com/tauri-apps/plugins-workspace/pull/1597) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Update to tauri beta.25. + +## \[2.0.0-beta.7] + +- [`22a17980`](https://github.com/tauri-apps/plugins-workspace/commit/22a17980ff4f6f8c40adb1b8f4ffc6dae2fe7e30) ([#1537](https://github.com/tauri-apps/plugins-workspace/pull/1537) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri beta.24. + +## \[2.0.0-beta.6] + +- [`76daee7a`](https://github.com/tauri-apps/plugins-workspace/commit/76daee7aafece34de3092c86e531cf9eb1138989) ([#1512](https://github.com/tauri-apps/plugins-workspace/pull/1512) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Update to tauri beta.23. + +## \[2.0.0-beta.5] + +- [`9013854f`](https://github.com/tauri-apps/plugins-workspace/commit/9013854f42a49a230b9dbb9d02774765528a923f)([#1382](https://github.com/tauri-apps/plugins-workspace/pull/1382)) Update to tauri beta.22. + +## \[2.0.0-beta.4] + +- [`430bd6f4`](https://github.com/tauri-apps/plugins-workspace/commit/430bd6f4f379bee5d232ae6b098ae131db7f178a)([#1363](https://github.com/tauri-apps/plugins-workspace/pull/1363)) Update to tauri beta.20. + +## \[2.0.0-beta.5] + +- [`d9de5b19`](https://github.com/tauri-apps/plugins-workspace/commit/d9de5b19d1e950c06f0915ae92a862acb266d108)([#1283](https://github.com/tauri-apps/plugins-workspace/pull/1283)) Implement `WindowExt` for `WebviewWindow`. + +## \[2.0.0-beta.3] + +- [`bd1ed590`](https://github.com/tauri-apps/plugins-workspace/commit/bd1ed5903ffcce5500310dac1e59e8c67674ef1e)([#1237](https://github.com/tauri-apps/plugins-workspace/pull/1237)) Update to tauri beta.17. + +## \[2.0.0-beta.3] + +- [`a04ea2f`](https://github.com/tauri-apps/plugins-workspace/commit/a04ea2f38294d5a3987578283badc8eec87a7752)([#1071](https://github.com/tauri-apps/plugins-workspace/pull/1071)) The global API script is now only added to the binary when the `withGlobalTauri` config is true. + +## \[2.0.0-beta.2] + +- [`99bea25`](https://github.com/tauri-apps/plugins-workspace/commit/99bea2559c2c0648c2519c50a18cd124dacef57b)([#1005](https://github.com/tauri-apps/plugins-workspace/pull/1005)) Update to tauri beta.8. + +## \[2.0.0-beta.1] + +- [`569defb`](https://github.com/tauri-apps/plugins-workspace/commit/569defbe9492e38938554bb7bdc1be9151456d21) Update to tauri beta.4. + +## \[2.0.0-beta.0] + +- [`d198c01`](https://github.com/tauri-apps/plugins-workspace/commit/d198c014863ee260cb0de88a14b7fc4356ef7474)([#862](https://github.com/tauri-apps/plugins-workspace/pull/862)) Update to tauri beta. + +## \[2.0.0-alpha.5] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.13. + +## \[2.0.0-alpha.4] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.12. + +## \[2.0.0-alpha.3] + +- [`e438e0a`](https://github.com/tauri-apps/plugins-workspace/commit/e438e0a62d4b430a5159f05f13ecd397dd891a0d)([#676](https://github.com/tauri-apps/plugins-workspace/pull/676)) Update to @tauri-apps/api v2.0.0-alpha.11. + +## \[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.9. + ## \[2.0.0-alpha.2] - [`4e2cef9`](https://github.com/tauri-apps/plugins-workspace/commit/4e2cef9b702bbbb9cf4ee17de50791cb21f1b2a4)([#593](https://github.com/tauri-apps/plugins-workspace/pull/593)) Update to alpha.12. @@ -12,6 +105,11 @@ - [`717ae67`](https://github.com/tauri-apps/plugins-workspace/commit/717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! +## \[1.0.5] + +- `TrayLeft`, `TrayRight` and `TrayCenter` will now position the window according to the tray position relative to the monitor dimensions to prevent windows being displayed partially off-screen. + - [3d27909](https://github.com/tauri-apps/plugins-workspace/commit/3d279094d44be78cdc5d1de3938f1414e13db6b0) fix(positioner): Prevent tray relative windows from being moved off-screen ([#291](https://github.com/tauri-apps/plugins-workspace/pull/291)) on 2023-09-27 + ## \[0.2.7] - Update Tauri to v1.0.0 @@ -63,11 +161,3 @@ ## \[0.1.0] - Update package/crate metadata - - [119d9c4](https://www.github.com/JonasKruckenberg/tauri-plugin-positioner/commit/119d9c47639e1df16f5520a08f039bdb6f39532b) update metadata on 2021-11-19 - - [39e517c](https://www.github.com/JonasKruckenberg/tauri-plugin-positioner/commit/39e517c145a4a901839ae9b46e296370ce6ababf) Update update-metadata.md on 2021-11-19 - data on 2021-11-19 - - [39e517c](https://www.github.com/JonasKruckenberg/tauri-plugin-positioner/commit/39e517c145a4a901839ae9b46e296370ce6ababf) Update update-metadata.md on 2021-11-19 - nberg/tauri-plugin-positioner/commit/119d9c47639e1df16f5520a08f039bdb6f39532b) update metadata on 2021-11-19 - - [39e517c](https://www.github.com/JonasKruckenberg/tauri-plugin-positioner/commit/39e517c145a4a901839ae9b46e296370ce6ababf) Update update-metadata.md on 2021-11-19 - data on 2021-11-19 - - [39e517c](https://www.github.com/JonasKruckenberg/tauri-plugin-positioner/commit/39e517c145a4a901839ae9b46e296370ce6ababf) Update update-metadata.md on 2021-11-19 diff --git a/plugins/positioner/Cargo.toml b/plugins/positioner/Cargo.toml index b0ddefe2..3123f44c 100644 --- a/plugins/positioner/Cargo.toml +++ b/plugins/positioner/Cargo.toml @@ -1,14 +1,27 @@ [package] name = "tauri-plugin-positioner" -version = "2.0.0-alpha.2" +version = "2.2.0" description = "Position your windows at well-known locations." authors = { workspace = true } license = { workspace = true } edition = { workspace = true } rust-version = { workspace = true } +repository = { workspace = true } +links = "tauri-plugin-positioner" [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] + +[package.metadata.platforms.support] +windows = { level = "full", notes = "" } +linux = { level = "full", notes = "" } +macos = { level = "full", notes = "" } +android = { level = "none", notes = "" } +ios = { level = "none", notes = "" } + +[build-dependencies] +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } @@ -19,4 +32,4 @@ thiserror = { workspace = true } serde_repr = "0.1" [features] -tray-icon = [ "tauri/tray-icon" ] +tray-icon = ["tauri/tray-icon"] diff --git a/plugins/positioner/README.md b/plugins/positioner/README.md index b8ca23d9..8a86160d 100644 --- a/plugins/positioner/README.md +++ b/plugins/positioner/README.md @@ -4,9 +4,17 @@ Position your windows at well-known locations. This plugin is a port of [electron-positioner](https://github.com/jenslind/electron-positioner) for Tauri. +| Platform | Supported | +| -------- | --------- | +| Linux | ✓ | +| Windows | ✓ | +| macOS | ✓ | +| Android | x | +| iOS | x | + ## Install -_This plugin requires a Rust version of at least **1.70**_ +_This plugin requires a Rust version of at least **1.77.2**_ There are three general methods of installation that we can recommend. @@ -20,7 +28,7 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] -tauri-plugin-positioner = "2.0.0-alpha" +tauri-plugin-positioner = "2.0.0" # alternatively with Git: tauri-plugin-positioner = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -48,27 +56,69 @@ yarn add https://github.com/tauri-apps/tauri-plugin-positioner#v2 First you need to register the core plugin with Tauri: -`src-tauri/src/main.rs` +`src-tauri/src/lib.rs` ```rust +use tauri::tray::TrayIconBuilder; + fn main() { tauri::Builder::default() .plugin(tauri_plugin_positioner::init()) // This is required to get tray-relative positions to work - .on_system_tray_event(|app, event| { - tauri_plugin_positioner::on_tray_event(app, &event); + .setup(|app| { + // note that this will create a new TrayIcon + TrayIconBuilder::new() + .on_tray_icon_event(|app, event| { + tauri_plugin_positioner::on_tray_event(app.app_handle(), &event); + }) + .build(app)?; + Ok(()) }) .run(tauri::generate_context!()) .expect("error while running tauri application"); } ``` +Alternatively, you may handle the tray events through JavaScript. Register the plugin as previously noted. + +```rust +fn main() { + tauri::Builder::default() + .plugin(tauri_plugin_positioner::init()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} +``` + +And in JavaScript, the `action` passed to the TrayIcon should include the handler. + +```javascript +import { + moveWindow, + Position, + handleIconState, +} from "@tauri-apps/plugin-positioner"; + +const action = async (event: TrayIconEvent) => { + // add the handle in the action to update the state + await handleIconState(event); + + if (event.type === "Click") { + // note this option requires enabling the `tray-icon` + // feature in the Cargo.toml + await moveWindow(Position.TrayLeft); + } +}; + +const tray = await TrayIcon.new({ id: "main", action }); +``` + Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import { move_window, Position } from "@tauri-apps/plugin-positioner"; +import { moveWindow, Position } from '@tauri-apps/plugin-positioner' -move_window(Position.TopRight); +moveWindow(Position.TopRight) ``` If you only intend on moving the window from rust code, you can import the Window trait extension instead of registering the plugin: @@ -84,6 +134,22 @@ let _ = win.move_window(Position::TopRight); PRs accepted. Please make sure to read the Contributing Guide before making a pull request. +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + ## License Code: (c) 2021 - Jonas Kruckenberg. 2021 - Present - The Tauri Programme within The Commons Conservancy. diff --git a/plugins/positioner/SECURITY.md b/plugins/positioner/SECURITY.md new file mode 100644 index 00000000..4f09bbac --- /dev/null +++ b/plugins/positioner/SECURITY.md @@ -0,0 +1,23 @@ +# Security Policy + +**Do not report security vulnerabilities through public GitHub issues.** + +**Please use the [Private Vulnerability Disclosure](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) feature of GitHub.** + +Include as much of the following information: + +- Type of issue (e.g. improper input parsing, privilege escalation, etc.) +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- The distribution affected or used to help us with reproduction of the issue +- Step-by-step instructions to reproduce the issue +- Ideally a reproduction repository +- Impact of the issue, including how an attacker might exploit the issue + +We prefer to receive reports in English. + +## Contact + +Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). + +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/positioner/api-iife.js b/plugins/positioner/api-iife.js new file mode 100644 index 00000000..dda21778 --- /dev/null +++ b/plugins/positioner/api-iife.js @@ -0,0 +1 @@ +if("__TAURI__"in window){var __TAURI_PLUGIN_POSITIONER__=function(t){"use strict";async function o(t,o={},e){return window.__TAURI_INTERNALS__.invoke(t,o,e)}var e;return"function"==typeof SuppressedError&&SuppressedError,t.Position=void 0,(e=t.Position||(t.Position={}))[e.TopLeft=0]="TopLeft",e[e.TopRight=1]="TopRight",e[e.BottomLeft=2]="BottomLeft",e[e.BottomRight=3]="BottomRight",e[e.TopCenter=4]="TopCenter",e[e.BottomCenter=5]="BottomCenter",e[e.LeftCenter=6]="LeftCenter",e[e.RightCenter=7]="RightCenter",e[e.Center=8]="Center",e[e.TrayLeft=9]="TrayLeft",e[e.TrayBottomLeft=10]="TrayBottomLeft",e[e.TrayRight=11]="TrayRight",e[e.TrayBottomRight=12]="TrayBottomRight",e[e.TrayCenter=13]="TrayCenter",e[e.TrayBottomCenter=14]="TrayBottomCenter",t.handleIconState=async function(t){await o("plugin:positioner|set_tray_icon_state",{position:t.rect.position,size:t.rect.size})},t.moveWindow=async function(t){await o("plugin:positioner|move_window",{position:t})},t.moveWindowConstrained=async function(t){await o("plugin:positioner|move_window_constrained",{position:t})},t}({});Object.defineProperty(window.__TAURI__,"positioner",{value:__TAURI_PLUGIN_POSITIONER__})} diff --git a/plugins/positioner/build.rs b/plugins/positioner/build.rs new file mode 100644 index 00000000..830c61fb --- /dev/null +++ b/plugins/positioner/build.rs @@ -0,0 +1,15 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +const COMMANDS: &[&str] = &[ + "move_window", + "move_window_constrained", + "set_tray_icon_state", +]; + +fn main() { + tauri_plugin::Builder::new(COMMANDS) + .global_api_script_path("./api-iife.js") + .build(); +} diff --git a/plugins/positioner/guest-js/index.ts b/plugins/positioner/guest-js/index.ts index b2121758..74d0295e 100644 --- a/plugins/positioner/guest-js/index.ts +++ b/plugins/positioner/guest-js/index.ts @@ -3,7 +3,8 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { invoke } from "@tauri-apps/api/primitives"; +import { invoke } from '@tauri-apps/api/core' +import type { TrayIconEvent } from '@tauri-apps/api/tray' /** * Well known window positions. @@ -23,7 +24,7 @@ export enum Position { TrayRight, TrayBottomRight, TrayCenter, - TrayBottomCenter, + TrayBottomCenter } /** @@ -33,7 +34,27 @@ export enum Position { * @param to The {@link Position} to move to. */ export async function moveWindow(to: Position): Promise { - await invoke("plugin:positioner|move_window", { - position: to, - }); + await invoke('plugin:positioner|move_window', { + position: to + }) +} + +/** + * Moves the `Window` to the given {@link Position} using `WindowExt.move_window_constrained()` + * + * This move operation constrains the window to the screen dimensions in case of + * tray-icon positions. + * @param to The (tray) {@link Position} to move to. + */ +export async function moveWindowConstrained(to: Position): Promise { + await invoke('plugin:positioner|move_window_constrained', { + position: to + }) +} + +export async function handleIconState(event: TrayIconEvent): Promise { + await invoke('plugin:positioner|set_tray_icon_state', { + position: event.rect.position, + size: event.rect.size + }) } diff --git a/plugins/positioner/package.json b/plugins/positioner/package.json index 54bedf18..fd57b990 100644 --- a/plugins/positioner/package.json +++ b/plugins/positioner/package.json @@ -1,33 +1,30 @@ { "name": "@tauri-apps/plugin-positioner", - "version": "2.0.0-alpha.1", + "version": "2.2.0", "description": "Position your windows at well-known locations.", - "license": "MIT or APACHE-2.0", + "license": "MIT OR Apache-2.0", "authors": [ "Tauri Programme within The Commons Conservancy" ], + "repository": "https://github.com/tauri-apps/plugins-workspace", "type": "module", - "browser": "dist-js/index.min.js", - "module": "dist-js/index.mjs", - "types": "dist-js/index.d.ts", + "types": "./dist-js/index.d.ts", + "main": "./dist-js/index.cjs", + "module": "./dist-js/index.js", "exports": { - "import": "./dist-js/index.mjs", "types": "./dist-js/index.d.ts", - "browser": "./dist-js/index.min.js" + "import": "./dist-js/index.js", + "require": "./dist-js/index.cjs" }, "scripts": { "build": "rollup -c" }, "files": [ "dist-js", - "!dist-js/**/*.map", "README.md", "LICENSE" ], - "devDependencies": { - "tslib": "2.6.0" - }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.9" + "@tauri-apps/api": "^2.0.0" } } diff --git a/plugins/positioner/permissions/autogenerated/commands/move_window.toml b/plugins/positioner/permissions/autogenerated/commands/move_window.toml new file mode 100644 index 00000000..f78f9c78 --- /dev/null +++ b/plugins/positioner/permissions/autogenerated/commands/move_window.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-move-window" +description = "Enables the move_window command without any pre-configured scope." +commands.allow = ["move_window"] + +[[permission]] +identifier = "deny-move-window" +description = "Denies the move_window command without any pre-configured scope." +commands.deny = ["move_window"] diff --git a/plugins/positioner/permissions/autogenerated/commands/move_window_constrained.toml b/plugins/positioner/permissions/autogenerated/commands/move_window_constrained.toml new file mode 100644 index 00000000..80343990 --- /dev/null +++ b/plugins/positioner/permissions/autogenerated/commands/move_window_constrained.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-move-window-constrained" +description = "Enables the move_window_constrained command without any pre-configured scope." +commands.allow = ["move_window_constrained"] + +[[permission]] +identifier = "deny-move-window-constrained" +description = "Denies the move_window_constrained command without any pre-configured scope." +commands.deny = ["move_window_constrained"] diff --git a/plugins/positioner/permissions/autogenerated/commands/set_tray_icon_state.toml b/plugins/positioner/permissions/autogenerated/commands/set_tray_icon_state.toml new file mode 100644 index 00000000..6b85f635 --- /dev/null +++ b/plugins/positioner/permissions/autogenerated/commands/set_tray_icon_state.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-set-tray-icon-state" +description = "Enables the set_tray_icon_state command without any pre-configured scope." +commands.allow = ["set_tray_icon_state"] + +[[permission]] +identifier = "deny-set-tray-icon-state" +description = "Denies the set_tray_icon_state command without any pre-configured scope." +commands.deny = ["set_tray_icon_state"] diff --git a/plugins/positioner/permissions/autogenerated/reference.md b/plugins/positioner/permissions/autogenerated/reference.md new file mode 100644 index 00000000..f6e09133 --- /dev/null +++ b/plugins/positioner/permissions/autogenerated/reference.md @@ -0,0 +1,97 @@ +## Default Permission + +Allows the moveWindow and handleIconState APIs + +#### This default permission set includes the following: + +- `allow-move-window` +- `allow-move-window-constrained` +- `allow-set-tray-icon-state` + +## Permission Table + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IdentifierDescription
+ +`positioner:allow-move-window` + + + +Enables the move_window command without any pre-configured scope. + +
+ +`positioner:deny-move-window` + + + +Denies the move_window command without any pre-configured scope. + +
+ +`positioner:allow-move-window-constrained` + + + +Enables the move_window_constrained command without any pre-configured scope. + +
+ +`positioner:deny-move-window-constrained` + + + +Denies the move_window_constrained command without any pre-configured scope. + +
+ +`positioner:allow-set-tray-icon-state` + + + +Enables the set_tray_icon_state command without any pre-configured scope. + +
+ +`positioner:deny-set-tray-icon-state` + + + +Denies the set_tray_icon_state command without any pre-configured scope. + +
diff --git a/plugins/positioner/permissions/default.toml b/plugins/positioner/permissions/default.toml new file mode 100644 index 00000000..7fc3c3d9 --- /dev/null +++ b/plugins/positioner/permissions/default.toml @@ -0,0 +1,8 @@ +"$schema" = "schemas/schema.json" +[default] +description = "Allows the moveWindow and handleIconState APIs" +permissions = [ + "allow-move-window", + "allow-move-window-constrained", + "allow-set-tray-icon-state", +] diff --git a/plugins/positioner/permissions/schemas/schema.json b/plugins/positioner/permissions/schemas/schema.json new file mode 100644 index 00000000..b0fc760a --- /dev/null +++ b/plugins/positioner/permissions/schemas/schema.json @@ -0,0 +1,342 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "PermissionFile", + "description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.", + "type": "object", + "properties": { + "default": { + "description": "The default permission set for the plugin", + "anyOf": [ + { + "$ref": "#/definitions/DefaultPermission" + }, + { + "type": "null" + } + ] + }, + "set": { + "description": "A list of permissions sets defined", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionSet" + } + }, + "permission": { + "description": "A list of inlined permissions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Permission" + } + } + }, + "definitions": { + "DefaultPermission": { + "description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.", + "type": "object", + "required": [ + "permissions" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "PermissionSet": { + "description": "A set of direct permissions grouped together under a new name.", + "type": "object", + "required": [ + "description", + "identifier", + "permissions" + ], + "properties": { + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does.", + "type": "string" + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionKind" + } + } + } + }, + "Permission": { + "description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.", + "type": "object", + "required": [ + "identifier" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri internal convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "commands": { + "description": "Allowed or denied commands when using this permission.", + "default": { + "allow": [], + "deny": [] + }, + "allOf": [ + { + "$ref": "#/definitions/Commands" + } + ] + }, + "scope": { + "description": "Allowed or denied scoped when using this permission.", + "allOf": [ + { + "$ref": "#/definitions/Scopes" + } + ] + }, + "platforms": { + "description": "Target platforms this permission applies. By default all platforms are affected by this permission.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Target" + } + } + } + }, + "Commands": { + "description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.", + "type": "object", + "properties": { + "allow": { + "description": "Allowed command.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "deny": { + "description": "Denied command, which takes priority.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "Scopes": { + "description": "An argument for fine grained behavior control of Tauri commands.\n\nIt can be of any serde serializable type and is used to allow or prevent certain actions inside a Tauri command. The configured scope is passed to the command and will be enforced by the command implementation.\n\n## Example\n\n```json { \"allow\": [{ \"path\": \"$HOME/**\" }], \"deny\": [{ \"path\": \"$HOME/secret.txt\" }] } ```", + "type": "object", + "properties": { + "allow": { + "description": "Data that defines what is allowed by the scope.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + }, + "deny": { + "description": "Data that defines what is denied by the scope. This should be prioritized by validation logic.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + } + } + }, + "Value": { + "description": "All supported ACL values.", + "anyOf": [ + { + "description": "Represents a null JSON value.", + "type": "null" + }, + { + "description": "Represents a [`bool`].", + "type": "boolean" + }, + { + "description": "Represents a valid ACL [`Number`].", + "allOf": [ + { + "$ref": "#/definitions/Number" + } + ] + }, + { + "description": "Represents a [`String`].", + "type": "string" + }, + { + "description": "Represents a list of other [`Value`]s.", + "type": "array", + "items": { + "$ref": "#/definitions/Value" + } + }, + { + "description": "Represents a map of [`String`] keys to [`Value`]s.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/Value" + } + } + ] + }, + "Number": { + "description": "A valid ACL number.", + "anyOf": [ + { + "description": "Represents an [`i64`].", + "type": "integer", + "format": "int64" + }, + { + "description": "Represents a [`f64`].", + "type": "number", + "format": "double" + } + ] + }, + "Target": { + "description": "Platform target.", + "oneOf": [ + { + "description": "MacOS.", + "type": "string", + "enum": [ + "macOS" + ] + }, + { + "description": "Windows.", + "type": "string", + "enum": [ + "windows" + ] + }, + { + "description": "Linux.", + "type": "string", + "enum": [ + "linux" + ] + }, + { + "description": "Android.", + "type": "string", + "enum": [ + "android" + ] + }, + { + "description": "iOS.", + "type": "string", + "enum": [ + "iOS" + ] + } + ] + }, + "PermissionKind": { + "type": "string", + "oneOf": [ + { + "description": "Enables the move_window command without any pre-configured scope.", + "type": "string", + "const": "allow-move-window", + "markdownDescription": "Enables the move_window command without any pre-configured scope." + }, + { + "description": "Denies the move_window command without any pre-configured scope.", + "type": "string", + "const": "deny-move-window", + "markdownDescription": "Denies the move_window command without any pre-configured scope." + }, + { + "description": "Enables the move_window_constrained command without any pre-configured scope.", + "type": "string", + "const": "allow-move-window-constrained", + "markdownDescription": "Enables the move_window_constrained command without any pre-configured scope." + }, + { + "description": "Denies the move_window_constrained command without any pre-configured scope.", + "type": "string", + "const": "deny-move-window-constrained", + "markdownDescription": "Denies the move_window_constrained command without any pre-configured scope." + }, + { + "description": "Enables the set_tray_icon_state command without any pre-configured scope.", + "type": "string", + "const": "allow-set-tray-icon-state", + "markdownDescription": "Enables the set_tray_icon_state command without any pre-configured scope." + }, + { + "description": "Denies the set_tray_icon_state command without any pre-configured scope.", + "type": "string", + "const": "deny-set-tray-icon-state", + "markdownDescription": "Denies the set_tray_icon_state command without any pre-configured scope." + }, + { + "description": "Allows the moveWindow and handleIconState APIs\n#### This default permission set includes:\n\n- `allow-move-window`\n- `allow-move-window-constrained`\n- `allow-set-tray-icon-state`", + "type": "string", + "const": "default", + "markdownDescription": "Allows the moveWindow and handleIconState APIs\n#### This default permission set includes:\n\n- `allow-move-window`\n- `allow-move-window-constrained`\n- `allow-set-tray-icon-state`" + } + ] + } + } +} \ No newline at end of file diff --git a/plugins/positioner/rollup.config.js b/plugins/positioner/rollup.config.js new file mode 100644 index 00000000..1f349ec8 --- /dev/null +++ b/plugins/positioner/rollup.config.js @@ -0,0 +1,7 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import { createConfig } from '../../shared/rollup.config.js' + +export default createConfig() diff --git a/plugins/positioner/rollup.config.mjs b/plugins/positioner/rollup.config.mjs deleted file mode 100644 index 99a3dd31..00000000 --- a/plugins/positioner/rollup.config.mjs +++ /dev/null @@ -1,11 +0,0 @@ -import { readFileSync } from "fs"; - -import { createConfig } from "../../shared/rollup.config.mjs"; - -export default createConfig({ - input: "guest-js/index.ts", - pkg: JSON.parse( - readFileSync(new URL("./package.json", import.meta.url), "utf8"), - ), - external: [/^@tauri-apps\/api/], -}); diff --git a/plugins/positioner/src/api-iife.js b/plugins/positioner/src/api-iife.js deleted file mode 100644 index 6dce1743..00000000 --- a/plugins/positioner/src/api-iife.js +++ /dev/null @@ -1 +0,0 @@ -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__})} diff --git a/plugins/positioner/src/ext.rs b/plugins/positioner/src/ext.rs index 11a725dc..b3d405ea 100644 --- a/plugins/positioner/src/ext.rs +++ b/plugins/positioner/src/ext.rs @@ -8,7 +8,9 @@ use crate::Tray; use serde_repr::Deserialize_repr; #[cfg(feature = "tray-icon")] use tauri::Manager; -use tauri::{PhysicalPosition, PhysicalSize, Result, Runtime, Window}; +#[cfg(feature = "tray-icon")] +use tauri::Monitor; +use tauri::{PhysicalPosition, PhysicalSize, Result, Runtime, WebviewWindow, Window}; /// Well known window positions. #[derive(Debug, Deserialize_repr)] @@ -41,144 +43,265 @@ pub enum Position { pub trait WindowExt { /// Moves the [`Window`] to the given [`Position`] /// - /// All positions are relative to the **current** screen. + /// All (non-tray) positions are relative to the **current** screen. fn move_window(&self, position: Position) -> Result<()>; + #[cfg(feature = "tray-icon")] + /// Moves the [`Window`] to the given [`Position`] while constraining Tray Positions to the dimensions of the screen. + /// + /// All non-tray positions will not be constrained by this method. + /// + /// This method allows you to position your Tray Windows without having them + /// cut off on the screen borders. + fn move_window_constrained(&self, position: Position) -> Result<()>; +} + +impl WindowExt for WebviewWindow { + fn move_window(&self, pos: Position) -> Result<()> { + self.as_ref().window().move_window(pos) + } + + #[cfg(feature = "tray-icon")] + fn move_window_constrained(&self, position: Position) -> Result<()> { + self.as_ref().window().move_window_constrained(position) + } } impl WindowExt for Window { + #[cfg(feature = "tray-icon")] + fn move_window_constrained(&self, position: Position) -> Result<()> { + // Diverge to basic move_window, if the position is not a tray position + if !matches!( + position, + Position::TrayLeft + | Position::TrayBottomLeft + | Position::TrayRight + | Position::TrayBottomRight + | Position::TrayCenter + | Position::TrayBottomCenter + ) { + return self.move_window(position); + } + + let window_position = calculate_position(self, position)?; + let monitor = get_monitor_for_tray_icon(self)?; + if let Some(monitor) = monitor { + let monitor_size = monitor.size(); + let monitor_position = monitor.position(); + let window_size = self.outer_size()?; + + let right_border_monitor = monitor_position.x as f64 + monitor_size.width as f64; + let left_border_monitor = monitor_position.x as f64; + let right_border_window = window_position.x as f64 + window_size.width as f64; + let left_border_window = window_position.x as f64; + + let constrained_x = if left_border_window < left_border_monitor { + left_border_monitor + } else if right_border_window > right_border_monitor { + right_border_monitor - window_size.width as f64 + } else { + window_position.x as f64 + }; + + let bottom_border_monitor = monitor_position.y as f64 + monitor_size.height as f64; + let top_border_monitor = monitor_position.y as f64; + let bottom_border_window = window_position.y as f64 + window_size.height as f64; + let top_border_window = window_position.y as f64; + + let constrained_y = if top_border_window < top_border_monitor { + top_border_monitor + } else if bottom_border_window > bottom_border_monitor { + bottom_border_monitor - window_size.height as f64 + } else { + window_position.y as f64 + }; + + self.set_position(PhysicalPosition::new(constrained_x, constrained_y))?; + } else { + // Fallback on non constrained positioning + self.set_position(window_position)?; + } + + Ok(()) + } + fn move_window(&self, pos: Position) -> Result<()> { - use Position::*; - - let screen = self.current_monitor()?.unwrap(); - let screen_position = screen.position(); - let screen_size = PhysicalSize:: { - width: screen.size().width as i32, - height: screen.size().height as i32, - }; - let window_size = PhysicalSize:: { - width: self.outer_size()?.width as i32, - height: self.outer_size()?.height as i32, - }; + let position = calculate_position(self, pos)?; + self.set_position(position) + } +} + +#[cfg(feature = "tray-icon")] +/// Retrieve the monitor, where the tray icon is located on. +fn get_monitor_for_tray_icon(window: &Window) -> Result> { + let tray_position = window + .state::() + .0 + .lock() + .unwrap() + .map(|(pos, _)| pos) + .unwrap_or_default(); + + window.monitor_from_point(tray_position.x, tray_position.y) +} + +/// Calculate the top-left position of the window based on the given +/// [`Position`]. +fn calculate_position( + window: &Window, + pos: Position, +) -> Result> { + use Position::*; + + let screen = window.current_monitor()?.unwrap(); + // Only use the screen_position for the Tray independent positioning, + // because a tray event may not be called on the currently active monitor. + let screen_position = screen.position(); + let screen_size = PhysicalSize:: { + width: screen.size().width as i32, + height: screen.size().height as i32, + }; + let window_size = PhysicalSize:: { + width: window.outer_size()?.width as i32, + height: window.outer_size()?.height as i32, + }; + #[cfg(feature = "tray-icon")] + let (tray_position, tray_size) = window + .state::() + .0 + .lock() + .unwrap() + .map(|(pos, size)| { + ( + Some((pos.x as i32, pos.y as i32)), + Some((size.width as i32, size.height as i32)), + ) + }) + .unwrap_or_default(); + + let physical_pos = match pos { + TopLeft => *screen_position, + TopRight => PhysicalPosition { + x: screen_position.x + (screen_size.width - window_size.width), + y: screen_position.y, + }, + BottomLeft => PhysicalPosition { + x: screen_position.x, + y: screen_size.height - (window_size.height - screen_position.y), + }, + BottomRight => PhysicalPosition { + x: screen_position.x + (screen_size.width - window_size.width), + y: screen_size.height - (window_size.height - screen_position.y), + }, + TopCenter => PhysicalPosition { + x: screen_position.x + ((screen_size.width / 2) - (window_size.width / 2)), + y: screen_position.y, + }, + BottomCenter => PhysicalPosition { + x: screen_position.x + ((screen_size.width / 2) - (window_size.width / 2)), + y: screen_size.height - (window_size.height - screen_position.y), + }, + LeftCenter => PhysicalPosition { + x: screen_position.x, + y: screen_position.y + (screen_size.height / 2) - (window_size.height / 2), + }, + RightCenter => PhysicalPosition { + x: screen_position.x + (screen_size.width - window_size.width), + y: screen_position.y + (screen_size.height / 2) - (window_size.height / 2), + }, + Center => PhysicalPosition { + x: screen_position.x + ((screen_size.width / 2) - (window_size.width / 2)), + y: screen_position.y + (screen_size.height / 2) - (window_size.height / 2), + }, #[cfg(feature = "tray-icon")] - let (tray_position, tray_size) = self - .state::() - .0 - .lock() - .unwrap() - .map(|(pos, size)| { - ( - Some((pos.x as i32, pos.y as i32)), - Some((size.width as i32, size.height as i32)), - ) - }) - .unwrap_or_default(); - - let physical_pos = match pos { - TopLeft => *screen_position, - TopRight => PhysicalPosition { - x: screen_position.x + (screen_size.width - window_size.width), - y: screen_position.y, - }, - BottomLeft => PhysicalPosition { - x: screen_position.x, - y: screen_size.height - (window_size.height - screen_position.y), - }, - BottomRight => PhysicalPosition { - x: screen_position.x + (screen_size.width - window_size.width), - y: screen_size.height - (window_size.height - screen_position.y), - }, - TopCenter => PhysicalPosition { - x: screen_position.x + ((screen_size.width / 2) - (window_size.width / 2)), - y: screen_position.y, - }, - BottomCenter => PhysicalPosition { - x: screen_position.x + ((screen_size.width / 2) - (window_size.width / 2)), - y: screen_size.height - (window_size.height - screen_position.y), - }, - LeftCenter => PhysicalPosition { - x: screen_position.x, - y: screen_position.y + (screen_size.height / 2) - (window_size.height / 2), - }, - RightCenter => PhysicalPosition { - x: screen_position.x + (screen_size.width - window_size.width), - y: screen_position.y + (screen_size.height / 2) - (window_size.height / 2), - }, - Center => PhysicalPosition { - x: screen_position.x + ((screen_size.width / 2) - (window_size.width / 2)), - y: screen_position.y + (screen_size.height / 2) - (window_size.height / 2), - }, - #[cfg(feature = "tray-icon")] - TrayLeft => { - if let Some((tray_x, tray_y)) = tray_position { - PhysicalPosition { - x: tray_x, - y: tray_y - window_size.height, - } - } else { - panic!("tray position not set"); - } + TrayLeft => { + if let (Some((tray_x, tray_y)), Some((_, _tray_height))) = (tray_position, tray_size) { + let y = tray_y - window_size.height; + // Choose y value based on the target OS + #[cfg(target_os = "windows")] + let y = if y < 0 { tray_y + _tray_height } else { y }; + + #[cfg(target_os = "macos")] + let y = if y < 0 { tray_y } else { y }; + + PhysicalPosition { x: tray_x, y } + } else { + panic!("Tray position not set"); } - #[cfg(feature = "tray-icon")] - TrayBottomLeft => { - if let Some((tray_x, tray_y)) = tray_position { - PhysicalPosition { - x: tray_x, - y: tray_y, - } - } else { - panic!("Tray position not set"); + } + #[cfg(feature = "tray-icon")] + TrayBottomLeft => { + if let Some((tray_x, tray_y)) = tray_position { + PhysicalPosition { + x: tray_x, + y: tray_y, } + } else { + panic!("Tray position not set"); } - #[cfg(feature = "tray-icon")] - TrayRight => { - if let (Some((tray_x, tray_y)), Some((tray_width, _))) = (tray_position, tray_size) - { - PhysicalPosition { - x: tray_x + tray_width, - y: tray_y - window_size.height, - } - } else { - panic!("Tray position not set"); + } + #[cfg(feature = "tray-icon")] + TrayRight => { + if let (Some((tray_x, tray_y)), Some((tray_width, _tray_height))) = + (tray_position, tray_size) + { + let y = tray_y - window_size.height; + // Choose y value based on the target OS + #[cfg(target_os = "windows")] + let y = if y < 0 { tray_y + _tray_height } else { y }; + + #[cfg(target_os = "macos")] + let y = if y < 0 { tray_y } else { y }; + + PhysicalPosition { + x: tray_x + tray_width, + y, } + } else { + panic!("Tray position not set"); } - #[cfg(feature = "tray-icon")] - TrayBottomRight => { - if let (Some((tray_x, tray_y)), Some((tray_width, _))) = (tray_position, tray_size) - { - PhysicalPosition { - x: tray_x + tray_width, - y: tray_y, - } - } else { - panic!("Tray position not set"); + } + #[cfg(feature = "tray-icon")] + TrayBottomRight => { + if let (Some((tray_x, tray_y)), Some((tray_width, _))) = (tray_position, tray_size) { + PhysicalPosition { + x: tray_x + tray_width, + y: tray_y, } + } else { + panic!("Tray position not set"); } - #[cfg(feature = "tray-icon")] - TrayCenter => { - if let (Some((tray_x, tray_y)), Some((tray_width, _))) = (tray_position, tray_size) - { - PhysicalPosition { - x: tray_x + (tray_width / 2) - (window_size.width / 2), - y: tray_y - window_size.height, - } - } else { - panic!("Tray position not set"); - } + } + #[cfg(feature = "tray-icon")] + TrayCenter => { + if let (Some((tray_x, tray_y)), Some((tray_width, _tray_height))) = + (tray_position, tray_size) + { + let x = tray_x + tray_width / 2 - window_size.width / 2; + let y = tray_y - window_size.height; + // Choose y value based on the target OS + #[cfg(target_os = "windows")] + let y = if y < 0 { tray_y + _tray_height } else { y }; + + #[cfg(target_os = "macos")] + let y = if y < 0 { tray_y } else { y }; + + PhysicalPosition { x, y } + } else { + panic!("Tray position not set"); } - #[cfg(feature = "tray-icon")] - TrayBottomCenter => { - if let (Some((tray_x, tray_y)), Some((tray_width, _))) = (tray_position, tray_size) - { - PhysicalPosition { - x: tray_x + (tray_width / 2) - (window_size.width / 2), - y: tray_y, - } - } else { - panic!("Tray position not set"); + } + #[cfg(feature = "tray-icon")] + TrayBottomCenter => { + if let (Some((tray_x, tray_y)), Some((tray_width, _))) = (tray_position, tray_size) { + PhysicalPosition { + x: tray_x + (tray_width / 2) - (window_size.width / 2), + y: tray_y, } + } else { + panic!("Tray position not set"); } - }; + } + }; - self.set_position(tauri::Position::Physical(physical_pos)) - } + Ok(physical_pos) } diff --git a/plugins/positioner/src/lib.rs b/plugins/positioner/src/lib.rs index 6c5b735e..59d0c3c1 100644 --- a/plugins/positioner/src/lib.rs +++ b/plugins/positioner/src/lib.rs @@ -3,8 +3,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -//! [![](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/positioner/banner.png)](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/positioner) -//! //! A plugin for Tauri that helps position your windows at well-known locations. //! //! # Cargo features @@ -35,14 +33,22 @@ struct Tray(std::sync::Mutex, PhysicalSize)>> #[cfg(feature = "tray-icon")] pub fn on_tray_event(app: &AppHandle, event: &TrayIconEvent) { - let position = PhysicalPosition { - x: event.x, - y: event.y, - }; - let size = PhysicalSize { - width: event.icon_rect.right - event.icon_rect.left, - height: event.icon_rect.bottom - event.icon_rect.top, + let (position, size) = { + match event { + TrayIconEvent::Click { rect, .. } + | TrayIconEvent::Enter { rect, .. } + | TrayIconEvent::Leave { rect, .. } + | TrayIconEvent::Move { rect, .. } => { + // tray-icon emits PhysicalSize so the scale factor should not matter. + let size = rect.size.to_physical(1.0); + let position = rect.position.to_physical(1.0); + (position, size) + } + + _ => return, + } }; + app.state::() .0 .lock() @@ -55,11 +61,38 @@ async fn move_window(window: tauri::Window, position: Position) - window.move_window(position) } +#[cfg(feature = "tray-icon")] +#[tauri::command] +async fn move_window_constrained( + window: tauri::Window, + position: Position, +) -> Result<()> { + window.move_window_constrained(position) +} + +#[cfg(feature = "tray-icon")] +#[tauri::command] +fn set_tray_icon_state( + app: AppHandle, + position: PhysicalPosition, + size: PhysicalSize, +) { + app.state::() + .0 + .lock() + .unwrap() + .replace((position, size)); +} + /// The Tauri plugin that exposes [`WindowExt::move_window`] to the webview. pub fn init() -> TauriPlugin { - let plugin = plugin::Builder::new("positioner") - .js_init_script(include_str!("api-iife.js").to_string()) - .invoke_handler(tauri::generate_handler![move_window]); + let plugin = plugin::Builder::new("positioner").invoke_handler(tauri::generate_handler![ + move_window, + #[cfg(feature = "tray-icon")] + move_window_constrained, + #[cfg(feature = "tray-icon")] + set_tray_icon_state + ]); #[cfg(feature = "tray-icon")] let plugin = plugin.setup(|app_handle, _api| { diff --git a/plugins/process/CHANGELOG.md b/plugins/process/CHANGELOG.md index 3109c03f..12cb7136 100644 --- a/plugins/process/CHANGELOG.md +++ b/plugins/process/CHANGELOG.md @@ -1,5 +1,86 @@ # Changelog +## \[2.2.1] + +- [`d2aef2fd`](https://github.com/tauri-apps/plugins-workspace/commit/d2aef2fddbdfad6526935c55ac10a94171a4f5f5) ([#2581](https://github.com/tauri-apps/plugins-workspace/pull/2581)) Migrate restart to use tauri's new `AppHandle::request_restart` method + +## \[2.2.0] + +- [`3a79266b`](https://github.com/tauri-apps/plugins-workspace/commit/3a79266b8cf96a55b1ae6339d725567d45a44b1d) ([#2173](https://github.com/tauri-apps/plugins-workspace/pull/2173) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Bumped all plugins to `v2.2.0`. From now, the versions for the Rust and JavaScript packages of each plugin will be in sync with each other. + +## \[2.0.1] + +- [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. + +## \[2.0.0] + +- [`e2c4dfb6`](https://github.com/tauri-apps/plugins-workspace/commit/e2c4dfb6af43e5dd8d9ceba232c315f5febd55c1) Update to tauri v2 stable release. + +## \[2.0.0-rc.1] + +- [`e2e97db5`](https://github.com/tauri-apps/plugins-workspace/commit/e2e97db51983267f5be84d4f6f0278d58834d1f5) ([#1701](https://github.com/tauri-apps/plugins-workspace/pull/1701) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri 2.0.0-rc.8 + +## \[2.0.0-rc.0] + +- [`9887d1`](https://github.com/tauri-apps/plugins-workspace/commit/9887d14bd0e971c4c0f5c1188fc4005d3fc2e29e) Update to tauri RC. + +## \[2.0.0-beta.8] + +- [`99d6ac0f`](https://github.com/tauri-apps/plugins-workspace/commit/99d6ac0f9506a6a4a1aa59c728157190a7441af6) ([#1606](https://github.com/tauri-apps/plugins-workspace/pull/1606) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) The JS packages now specify the *minimum* `@tauri-apps/api` version instead of a single exact version. +- [`6de87966`](https://github.com/tauri-apps/plugins-workspace/commit/6de87966ecc00ad9d91c25be452f1f46bd2b7e1f) ([#1597](https://github.com/tauri-apps/plugins-workspace/pull/1597) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Update to tauri beta.25. + +## \[2.0.0-beta.7] + +- [`22a17980`](https://github.com/tauri-apps/plugins-workspace/commit/22a17980ff4f6f8c40adb1b8f4ffc6dae2fe7e30) ([#1537](https://github.com/tauri-apps/plugins-workspace/pull/1537) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri beta.24. + +## \[2.0.0-beta.6] + +- [`76daee7a`](https://github.com/tauri-apps/plugins-workspace/commit/76daee7aafece34de3092c86e531cf9eb1138989) ([#1512](https://github.com/tauri-apps/plugins-workspace/pull/1512) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Update to tauri beta.23. + +## \[2.0.0-beta.5] + +- [`9013854f`](https://github.com/tauri-apps/plugins-workspace/commit/9013854f42a49a230b9dbb9d02774765528a923f)([#1382](https://github.com/tauri-apps/plugins-workspace/pull/1382)) Update to tauri beta.22. + +## \[2.0.0-beta.4] + +- [`430bd6f4`](https://github.com/tauri-apps/plugins-workspace/commit/430bd6f4f379bee5d232ae6b098ae131db7f178a)([#1363](https://github.com/tauri-apps/plugins-workspace/pull/1363)) Update to tauri beta.20. + +## \[2.0.0-beta.3] + +- [`bd1ed590`](https://github.com/tauri-apps/plugins-workspace/commit/bd1ed5903ffcce5500310dac1e59e8c67674ef1e)([#1237](https://github.com/tauri-apps/plugins-workspace/pull/1237)) Update to tauri beta.17. + +## \[2.0.0-beta.3] + +- [`a04ea2f`](https://github.com/tauri-apps/plugins-workspace/commit/a04ea2f38294d5a3987578283badc8eec87a7752)([#1071](https://github.com/tauri-apps/plugins-workspace/pull/1071)) The global API script is now only added to the binary when the `withGlobalTauri` config is true. + +## \[2.0.0-beta.2] + +- [`99bea25`](https://github.com/tauri-apps/plugins-workspace/commit/99bea2559c2c0648c2519c50a18cd124dacef57b)([#1005](https://github.com/tauri-apps/plugins-workspace/pull/1005)) Update to tauri beta.8. + +## \[2.0.0-beta.1] + +- [`569defb`](https://github.com/tauri-apps/plugins-workspace/commit/569defbe9492e38938554bb7bdc1be9151456d21) Update to tauri beta.4. + +## \[2.0.0-beta.0] + +- [`d198c01`](https://github.com/tauri-apps/plugins-workspace/commit/d198c014863ee260cb0de88a14b7fc4356ef7474)([#862](https://github.com/tauri-apps/plugins-workspace/pull/862)) Update to tauri beta. + +## \[2.0.0-alpha.5] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.13. + +## \[2.0.0-alpha.4] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.12. + +## \[2.0.0-alpha.3] + +- [`e438e0a`](https://github.com/tauri-apps/plugins-workspace/commit/e438e0a62d4b430a5159f05f13ecd397dd891a0d)([#676](https://github.com/tauri-apps/plugins-workspace/pull/676)) Update to @tauri-apps/api v2.0.0-alpha.11. + +## \[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.9. + ## \[2.0.0-alpha.2] - [`4e2cef9`](https://github.com/tauri-apps/plugins-workspace/commit/4e2cef9b702bbbb9cf4ee17de50791cb21f1b2a4)([#593](https://github.com/tauri-apps/plugins-workspace/pull/593)) Update to alpha.12. @@ -10,9 +91,4 @@ ## \[2.0.0-alpha.0] -- [`717ae67`](https://github.com/tauri-apps/plugins-workspace/commit/717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! - te to alpha.11. - -## \[2.0.0-alpha.0] - - [`717ae67`](https://github.com/tauri-apps/plugins-workspace/commit/717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! diff --git a/plugins/process/Cargo.toml b/plugins/process/Cargo.toml index 10d0e235..8ccf62c5 100644 --- a/plugins/process/Cargo.toml +++ b/plugins/process/Cargo.toml @@ -1,14 +1,27 @@ [package] name = "tauri-plugin-process" -version = "2.0.0-alpha.2" +version = "2.2.1" description = "Access the current process of your Tauri application." edition = { workspace = true } authors = { workspace = true } license = { workspace = true } rust-version = { workspace = true } +repository = { workspace = true } +links = "tauri-plugin-process" [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] + +[package.metadata.platforms.support] +windows = { level = "full", notes = "" } +linux = { level = "full", notes = "" } +macos = { level = "full", notes = "" } +android = { level = "none", notes = "" } +ios = { level = "none", notes = "" } + +[build-dependencies] +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] tauri = { workspace = true } diff --git a/plugins/process/README.md b/plugins/process/README.md index 4176f08d..9f75bacb 100644 --- a/plugins/process/README.md +++ b/plugins/process/README.md @@ -2,9 +2,17 @@ This plugin provides APIs to access the current process. To spawn child processes, see the [`shell`](https://github.com/tauri-apps/tauri-plugin-shell) plugin. +| Platform | Supported | +| -------- | --------- | +| Linux | ✓ | +| Windows | ✓ | +| macOS | ✓ | +| Android | x | +| iOS | x | + ## Install -_This plugin requires a Rust version of at least **1.70**_ +_This plugin requires a Rust version of at least **1.77.2**_ There are three general methods of installation that we can recommend. @@ -18,7 +26,7 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] -tauri-plugin-process = "2.0.0-alpha" +tauri-plugin-process = "2.0.0" # alternatively with Git: tauri-plugin-process = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -46,7 +54,7 @@ yarn add https://github.com/tauri-apps/tauri-plugin-process#v2 First you need to register the core plugin with Tauri: -`src-tauri/src/main.rs` +`src-tauri/src/lib.rs` ```rust fn main() { @@ -60,17 +68,33 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import { exit, relaunch } from "@tauri-apps/plugin-process"; +import { exit, relaunch } from '@tauri-apps/plugin-process' // exit the app with the given status code -await exit(0); +await exit(0) // restart the app -await relaunch(); +await relaunch() ``` ## Contributing PRs accepted. Please make sure to read the Contributing Guide before making a pull request. +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + ## License Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. diff --git a/plugins/process/SECURITY.md b/plugins/process/SECURITY.md new file mode 100644 index 00000000..4f09bbac --- /dev/null +++ b/plugins/process/SECURITY.md @@ -0,0 +1,23 @@ +# Security Policy + +**Do not report security vulnerabilities through public GitHub issues.** + +**Please use the [Private Vulnerability Disclosure](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) feature of GitHub.** + +Include as much of the following information: + +- Type of issue (e.g. improper input parsing, privilege escalation, etc.) +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- The distribution affected or used to help us with reproduction of the issue +- Step-by-step instructions to reproduce the issue +- Ideally a reproduction repository +- Impact of the issue, including how an attacker might exploit the issue + +We prefer to receive reports in English. + +## Contact + +Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). + +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/process/api-iife.js b/plugins/process/api-iife.js new file mode 100644 index 00000000..b214396e --- /dev/null +++ b/plugins/process/api-iife.js @@ -0,0 +1 @@ +if("__TAURI__"in window){var __TAURI_PLUGIN_PROCESS__=function(_){"use strict";async function n(_,n={},e){return window.__TAURI_INTERNALS__.invoke(_,n,e)}return"function"==typeof SuppressedError&&SuppressedError,_.exit=async function(_=0){await n("plugin:process|exit",{code:_})},_.relaunch=async function(){await n("plugin:process|restart")},_}({});Object.defineProperty(window.__TAURI__,"process",{value:__TAURI_PLUGIN_PROCESS__})} diff --git a/plugins/process/build.rs b/plugins/process/build.rs new file mode 100644 index 00000000..e412b34e --- /dev/null +++ b/plugins/process/build.rs @@ -0,0 +1,11 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +const COMMANDS: &[&str] = &["exit", "restart"]; + +fn main() { + tauri_plugin::Builder::new(COMMANDS) + .global_api_script_path("./api-iife.js") + .build(); +} diff --git a/plugins/process/guest-js/index.ts b/plugins/process/guest-js/index.ts index 4f26f1d9..da15831a 100644 --- a/plugins/process/guest-js/index.ts +++ b/plugins/process/guest-js/index.ts @@ -7,7 +7,7 @@ * @module */ -import { invoke } from "@tauri-apps/api/primitives"; +import { invoke } from '@tauri-apps/api/core' /** * Exits immediately with the given `exitCode`. @@ -23,7 +23,7 @@ import { invoke } from "@tauri-apps/api/primitives"; * @since 2.0.0 */ async function exit(code = 0): Promise { - return invoke("plugin:process|exit", { code }); + await invoke('plugin:process|exit', { code }) } /** @@ -39,7 +39,7 @@ async function exit(code = 0): Promise { * @since 2.0.0 */ async function relaunch(): Promise { - return invoke("plugin:process|restart"); + await invoke('plugin:process|restart') } -export { exit, relaunch }; +export { exit, relaunch } diff --git a/plugins/process/package.json b/plugins/process/package.json index 1250df6b..fdb2ad49 100644 --- a/plugins/process/package.json +++ b/plugins/process/package.json @@ -1,32 +1,29 @@ { "name": "@tauri-apps/plugin-process", - "version": "2.0.0-alpha.1", - "license": "MIT or APACHE-2.0", + "version": "2.2.1", + "license": "MIT OR Apache-2.0", "authors": [ "Tauri Programme within The Commons Conservancy" ], + "repository": "https://github.com/tauri-apps/plugins-workspace", "type": "module", - "browser": "dist-js/index.min.js", - "module": "dist-js/index.mjs", - "types": "dist-js/index.d.ts", + "types": "./dist-js/index.d.ts", + "main": "./dist-js/index.cjs", + "module": "./dist-js/index.js", "exports": { - "import": "./dist-js/index.mjs", "types": "./dist-js/index.d.ts", - "browser": "./dist-js/index.min.js" + "import": "./dist-js/index.js", + "require": "./dist-js/index.cjs" }, "scripts": { "build": "rollup -c" }, "files": [ "dist-js", - "!dist-js/**/*.map", "README.md", "LICENSE" ], - "devDependencies": { - "tslib": "2.6.0" - }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.9" + "@tauri-apps/api": "^2.0.0" } } diff --git a/plugins/process/permissions/autogenerated/commands/exit.toml b/plugins/process/permissions/autogenerated/commands/exit.toml new file mode 100644 index 00000000..8abaf296 --- /dev/null +++ b/plugins/process/permissions/autogenerated/commands/exit.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-exit" +description = "Enables the exit command without any pre-configured scope." +commands.allow = ["exit"] + +[[permission]] +identifier = "deny-exit" +description = "Denies the exit command without any pre-configured scope." +commands.deny = ["exit"] diff --git a/plugins/process/permissions/autogenerated/commands/restart.toml b/plugins/process/permissions/autogenerated/commands/restart.toml new file mode 100644 index 00000000..63b228c8 --- /dev/null +++ b/plugins/process/permissions/autogenerated/commands/restart.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-restart" +description = "Enables the restart command without any pre-configured scope." +commands.allow = ["restart"] + +[[permission]] +identifier = "deny-restart" +description = "Denies the restart command without any pre-configured scope." +commands.deny = ["restart"] diff --git a/plugins/process/permissions/autogenerated/reference.md b/plugins/process/permissions/autogenerated/reference.md new file mode 100644 index 00000000..6cb15b5f --- /dev/null +++ b/plugins/process/permissions/autogenerated/reference.md @@ -0,0 +1,77 @@ +## Default Permission + +This permission set configures which +process features are by default exposed. + +#### Granted Permissions + +This enables to quit via `allow-exit` and restart via `allow-restart` +the application. + + +#### This default permission set includes the following: + +- `allow-exit` +- `allow-restart` + +## Permission Table + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IdentifierDescription
+ +`process:allow-exit` + + + +Enables the exit command without any pre-configured scope. + +
+ +`process:deny-exit` + + + +Denies the exit command without any pre-configured scope. + +
+ +`process:allow-restart` + + + +Enables the restart command without any pre-configured scope. + +
+ +`process:deny-restart` + + + +Denies the restart command without any pre-configured scope. + +
diff --git a/plugins/process/permissions/default.toml b/plugins/process/permissions/default.toml new file mode 100644 index 00000000..69a9b00d --- /dev/null +++ b/plugins/process/permissions/default.toml @@ -0,0 +1,14 @@ +"$schema" = "schemas/schema.json" + +[default] +description = """ +This permission set configures which +process features are by default exposed. + +#### Granted Permissions + +This enables to quit via `allow-exit` and restart via `allow-restart` +the application. +""" + +permissions = ["allow-exit", "allow-restart"] diff --git a/plugins/process/permissions/schemas/schema.json b/plugins/process/permissions/schemas/schema.json new file mode 100644 index 00000000..9d68fc63 --- /dev/null +++ b/plugins/process/permissions/schemas/schema.json @@ -0,0 +1,330 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "PermissionFile", + "description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.", + "type": "object", + "properties": { + "default": { + "description": "The default permission set for the plugin", + "anyOf": [ + { + "$ref": "#/definitions/DefaultPermission" + }, + { + "type": "null" + } + ] + }, + "set": { + "description": "A list of permissions sets defined", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionSet" + } + }, + "permission": { + "description": "A list of inlined permissions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Permission" + } + } + }, + "definitions": { + "DefaultPermission": { + "description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.", + "type": "object", + "required": [ + "permissions" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "PermissionSet": { + "description": "A set of direct permissions grouped together under a new name.", + "type": "object", + "required": [ + "description", + "identifier", + "permissions" + ], + "properties": { + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does.", + "type": "string" + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionKind" + } + } + } + }, + "Permission": { + "description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.", + "type": "object", + "required": [ + "identifier" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri internal convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "commands": { + "description": "Allowed or denied commands when using this permission.", + "default": { + "allow": [], + "deny": [] + }, + "allOf": [ + { + "$ref": "#/definitions/Commands" + } + ] + }, + "scope": { + "description": "Allowed or denied scoped when using this permission.", + "allOf": [ + { + "$ref": "#/definitions/Scopes" + } + ] + }, + "platforms": { + "description": "Target platforms this permission applies. By default all platforms are affected by this permission.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Target" + } + } + } + }, + "Commands": { + "description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.", + "type": "object", + "properties": { + "allow": { + "description": "Allowed command.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "deny": { + "description": "Denied command, which takes priority.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "Scopes": { + "description": "An argument for fine grained behavior control of Tauri commands.\n\nIt can be of any serde serializable type and is used to allow or prevent certain actions inside a Tauri command. The configured scope is passed to the command and will be enforced by the command implementation.\n\n## Example\n\n```json { \"allow\": [{ \"path\": \"$HOME/**\" }], \"deny\": [{ \"path\": \"$HOME/secret.txt\" }] } ```", + "type": "object", + "properties": { + "allow": { + "description": "Data that defines what is allowed by the scope.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + }, + "deny": { + "description": "Data that defines what is denied by the scope. This should be prioritized by validation logic.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + } + } + }, + "Value": { + "description": "All supported ACL values.", + "anyOf": [ + { + "description": "Represents a null JSON value.", + "type": "null" + }, + { + "description": "Represents a [`bool`].", + "type": "boolean" + }, + { + "description": "Represents a valid ACL [`Number`].", + "allOf": [ + { + "$ref": "#/definitions/Number" + } + ] + }, + { + "description": "Represents a [`String`].", + "type": "string" + }, + { + "description": "Represents a list of other [`Value`]s.", + "type": "array", + "items": { + "$ref": "#/definitions/Value" + } + }, + { + "description": "Represents a map of [`String`] keys to [`Value`]s.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/Value" + } + } + ] + }, + "Number": { + "description": "A valid ACL number.", + "anyOf": [ + { + "description": "Represents an [`i64`].", + "type": "integer", + "format": "int64" + }, + { + "description": "Represents a [`f64`].", + "type": "number", + "format": "double" + } + ] + }, + "Target": { + "description": "Platform target.", + "oneOf": [ + { + "description": "MacOS.", + "type": "string", + "enum": [ + "macOS" + ] + }, + { + "description": "Windows.", + "type": "string", + "enum": [ + "windows" + ] + }, + { + "description": "Linux.", + "type": "string", + "enum": [ + "linux" + ] + }, + { + "description": "Android.", + "type": "string", + "enum": [ + "android" + ] + }, + { + "description": "iOS.", + "type": "string", + "enum": [ + "iOS" + ] + } + ] + }, + "PermissionKind": { + "type": "string", + "oneOf": [ + { + "description": "Enables the exit command without any pre-configured scope.", + "type": "string", + "const": "allow-exit", + "markdownDescription": "Enables the exit command without any pre-configured scope." + }, + { + "description": "Denies the exit command without any pre-configured scope.", + "type": "string", + "const": "deny-exit", + "markdownDescription": "Denies the exit command without any pre-configured scope." + }, + { + "description": "Enables the restart command without any pre-configured scope.", + "type": "string", + "const": "allow-restart", + "markdownDescription": "Enables the restart command without any pre-configured scope." + }, + { + "description": "Denies the restart command without any pre-configured scope.", + "type": "string", + "const": "deny-restart", + "markdownDescription": "Denies the restart command without any pre-configured scope." + }, + { + "description": "This permission set configures which\nprocess features are by default exposed.\n\n#### Granted Permissions\n\nThis enables to quit via `allow-exit` and restart via `allow-restart`\nthe application.\n\n#### This default permission set includes:\n\n- `allow-exit`\n- `allow-restart`", + "type": "string", + "const": "default", + "markdownDescription": "This permission set configures which\nprocess features are by default exposed.\n\n#### Granted Permissions\n\nThis enables to quit via `allow-exit` and restart via `allow-restart`\nthe application.\n\n#### This default permission set includes:\n\n- `allow-exit`\n- `allow-restart`" + } + ] + } + } +} \ No newline at end of file diff --git a/plugins/process/rollup.config.js b/plugins/process/rollup.config.js new file mode 100644 index 00000000..1f349ec8 --- /dev/null +++ b/plugins/process/rollup.config.js @@ -0,0 +1,7 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import { createConfig } from '../../shared/rollup.config.js' + +export default createConfig() diff --git a/plugins/process/rollup.config.mjs b/plugins/process/rollup.config.mjs deleted file mode 100644 index 99a3dd31..00000000 --- a/plugins/process/rollup.config.mjs +++ /dev/null @@ -1,11 +0,0 @@ -import { readFileSync } from "fs"; - -import { createConfig } from "../../shared/rollup.config.mjs"; - -export default createConfig({ - input: "guest-js/index.ts", - pkg: JSON.parse( - readFileSync(new URL("./package.json", import.meta.url), "utf8"), - ), - external: [/^@tauri-apps\/api/], -}); diff --git a/plugins/process/src/api-iife.js b/plugins/process/src/api-iife.js deleted file mode 100644 index 402f2154..00000000 --- a/plugins/process/src/api-iife.js +++ /dev/null @@ -1 +0,0 @@ -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__})} diff --git a/plugins/process/src/commands.rs b/plugins/process/src/commands.rs index 2c27a3d2..3777294a 100644 --- a/plugins/process/src/commands.rs +++ b/plugins/process/src/commands.rs @@ -11,5 +11,5 @@ pub fn exit(app: AppHandle, code: i32) { #[tauri::command] pub fn restart(app: AppHandle) { - app.restart() + app.request_restart() } diff --git a/plugins/process/src/lib.rs b/plugins/process/src/lib.rs index 2de82914..b83d8964 100644 --- a/plugins/process/src/lib.rs +++ b/plugins/process/src/lib.rs @@ -2,8 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -//! [![](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/process/banner.png)](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/process) -//! //! This plugin provides APIs to access the current process. To spawn child processes, see the [`shell`](https://github.com/tauri-apps/tauri-plugin-shell) plugin. #![doc( @@ -20,7 +18,6 @@ mod commands; pub fn init() -> TauriPlugin { Builder::new("process") - .js_init_script(include_str!("api-iife.js").to_string()) .invoke_handler(tauri::generate_handler![commands::exit, commands::restart]) .build() } diff --git a/plugins/shell/CHANGELOG.md b/plugins/shell/CHANGELOG.md index 1b459ee1..9af199bf 100644 --- a/plugins/shell/CHANGELOG.md +++ b/plugins/shell/CHANGELOG.md @@ -1,18 +1,123 @@ # Changelog +## \[2.2.1] + +### bug + +- [`9cf0390a`](https://github.com/tauri-apps/plugins-workspace/commit/9cf0390a52497e273db1a1b613a0e26827aa327c) Apply the default open validation regex `^((mailto:\w+)|(tel:\w+)|(https?://\w+)).+` when the open configuration is not set, preventing unchecked input from being used in this scenario (previously the plugin would skip validation when it should disable all calls). This keeps backwards compatibility while still fixing this vulnerability. + The scope is no longer validated for Rust calls via `ShellExt::shell()` so if you need to block JavaScript from calling the API you can simply set `tauri.conf.json > plugins > shell > open` to `false`. + +## \[2.2.0] + +- [`3a79266b`](https://github.com/tauri-apps/plugins-workspace/commit/3a79266b8cf96a55b1ae6339d725567d45a44b1d) ([#2173](https://github.com/tauri-apps/plugins-workspace/pull/2173) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Bumped all plugins to `v2.2.0`. From now, the versions for the Rust and JavaScript packages of each plugin will be in sync with each other. + +## \[2.0.1] + +- [`51ddf6a7`](https://github.com/tauri-apps/plugins-workspace/commit/51ddf6a71544acfb261ffc9393dab1342da0a219) ([#1881](https://github.com/tauri-apps/plugins-workspace/pull/1881) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) On Windows, Fix `open` JS API hanging and freezing the app. + +## \[2.0.1] + +- [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. + +## \[2.0.0] + +- [`e2c4dfb6`](https://github.com/tauri-apps/plugins-workspace/commit/e2c4dfb6af43e5dd8d9ceba232c315f5febd55c1) Update to tauri v2 stable release. + +## \[2.0.0-rc.4] + +- [`44273b98`](https://github.com/tauri-apps/plugins-workspace/commit/44273b988957a254eff715d6be7547d2ace882e1) ([#1839](https://github.com/tauri-apps/plugins-workspace/pull/1839) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Fix the plugin schema requiring to set `sidecar` property when it is in fact optional. + +## \[2.0.0-rc.1] + +- [`e2e97db5`](https://github.com/tauri-apps/plugins-workspace/commit/e2e97db51983267f5be84d4f6f0278d58834d1f5) ([#1701](https://github.com/tauri-apps/plugins-workspace/pull/1701) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri 2.0.0-rc.8 + +## \[2.0.0-rc.2] + +- [`b9147758`](https://github.com/tauri-apps/plugins-workspace/commit/b914775898c2bee7ceb20bd17ee595005cd17a64) ([#1679](https://github.com/tauri-apps/plugins-workspace/pull/1679) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Explicitly set a minimum macOS version for the Swift package. + +## \[2.0.0-rc.1] + +### changes + +- [`6b079cfd`](https://github.com/tauri-apps/plugins-workspace/commit/6b079cfdd107c94abc2c7300f6af00bac3ff4040) ([#1649](https://github.com/tauri-apps/plugins-workspace/pull/1649) by [@ahqsoftwares](https://github.com/tauri-apps/plugins-workspace/../../ahqsoftwares)) Remove targetSdk from build.kts files as it is deprecated and will be removed from DSL v9.0 + +## \[2.0.0-rc.0] + +- [`9887d1`](https://github.com/tauri-apps/plugins-workspace/commit/9887d14bd0e971c4c0f5c1188fc4005d3fc2e29e) Update to tauri RC. +- [`34df132f`](https://github.com/tauri-apps/plugins-workspace/commit/34df132fb14212ba7330adc9ccd64267751950c8) ([#1603](https://github.com/tauri-apps/plugins-workspace/pull/1603)) Change the `open` scope validator regex to match on the entire string. +- [`34df132f`](https://github.com/tauri-apps/plugins-workspace/commit/34df132fb14212ba7330adc9ccd64267751950c8) ([#1603](https://github.com/tauri-apps/plugins-workspace/pull/1603)) Change the `execute` scope argument validator regex to match on the entire string by default. + If this behavior is not desired check the `raw` boolean configuration option that is available along the `validator` string. + +## \[2.0.0-beta.9] + +- [`99d6ac0f`](https://github.com/tauri-apps/plugins-workspace/commit/99d6ac0f9506a6a4a1aa59c728157190a7441af6) ([#1606](https://github.com/tauri-apps/plugins-workspace/pull/1606) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) The JS packages now specify the *minimum* `@tauri-apps/api` version instead of a single exact version. +- [`6de87966`](https://github.com/tauri-apps/plugins-workspace/commit/6de87966ecc00ad9d91c25be452f1f46bd2b7e1f) ([#1597](https://github.com/tauri-apps/plugins-workspace/pull/1597) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Update to tauri beta.25. + +## \[2.0.0-beta.8] + +- [`22a17980`](https://github.com/tauri-apps/plugins-workspace/commit/22a17980ff4f6f8c40adb1b8f4ffc6dae2fe7e30) ([#1537](https://github.com/tauri-apps/plugins-workspace/pull/1537) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri beta.24. + +## \[2.0.0-beta.7] + +- [`76daee7a`](https://github.com/tauri-apps/plugins-workspace/commit/76daee7aafece34de3092c86e531cf9eb1138989) ([#1512](https://github.com/tauri-apps/plugins-workspace/pull/1512) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Update to tauri beta.23. + +## \[2.0.0-beta.6] + +- [`9013854f`](https://github.com/tauri-apps/plugins-workspace/commit/9013854f42a49a230b9dbb9d02774765528a923f)([#1382](https://github.com/tauri-apps/plugins-workspace/pull/1382)) Update to tauri beta.22. + +## \[2.0.0-beta.5] + +- [`430bd6f4`](https://github.com/tauri-apps/plugins-workspace/commit/430bd6f4f379bee5d232ae6b098ae131db7f178a)([#1363](https://github.com/tauri-apps/plugins-workspace/pull/1363)) Update to tauri beta.20. + +## \[2.0.0-beta.4] + +- [`eb1679b9`](https://github.com/tauri-apps/plugins-workspace/commit/eb1679b99780e5d2b867f5649a1ccc2f3f70ab56)([#1299](https://github.com/tauri-apps/plugins-workspace/pull/1299)) Fix `Command.execute` API including extra new lines. +- [`eb1679b9`](https://github.com/tauri-apps/plugins-workspace/commit/eb1679b99780e5d2b867f5649a1ccc2f3f70ab56)([#1299](https://github.com/tauri-apps/plugins-workspace/pull/1299)) Improve the speed of the JS `Command.execute` API + +## \[2.0.0-beta.3] + +- [`bd1ed590`](https://github.com/tauri-apps/plugins-workspace/commit/bd1ed5903ffcce5500310dac1e59e8c67674ef1e)([#1237](https://github.com/tauri-apps/plugins-workspace/pull/1237)) Update to tauri beta.17. + +## \[2.0.0-beta.3] + +- [`a04ea2f`](https://github.com/tauri-apps/plugins-workspace/commit/a04ea2f38294d5a3987578283badc8eec87a7752)([#1071](https://github.com/tauri-apps/plugins-workspace/pull/1071)) The global API script is now only added to the binary when the `withGlobalTauri` config is true. +- [`040004a`](https://github.com/tauri-apps/plugins-workspace/commit/040004a6b9fbb89161d1b5764d79428dfe693776)([#1069](https://github.com/tauri-apps/plugins-workspace/pull/1069)) Change shell's schema property name `command` to `cmd`. + +## \[2.0.0-beta.2] + +- [`9586eab`](https://github.com/tauri-apps/plugins-workspace/commit/9586eabd5a96673e4d976757777f470ae358d68a)([#1021](https://github.com/tauri-apps/plugins-workspace/pull/1021)) On Windows, fix `open` can't open file if the file is being used by a program. +- [`99bea25`](https://github.com/tauri-apps/plugins-workspace/commit/99bea2559c2c0648c2519c50a18cd124dacef57b)([#1005](https://github.com/tauri-apps/plugins-workspace/pull/1005)) Update to tauri beta.8. + +## \[2.0.0-beta.1] + +- [`569defb`](https://github.com/tauri-apps/plugins-workspace/commit/569defbe9492e38938554bb7bdc1be9151456d21) Update to tauri beta.4. + +## \[2.0.0-beta.0] + +- [`d198c01`](https://github.com/tauri-apps/plugins-workspace/commit/d198c014863ee260cb0de88a14b7fc4356ef7474)([#862](https://github.com/tauri-apps/plugins-workspace/pull/862)) Update to tauri beta. + +## \[2.0.0-alpha.5] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.13. + +## \[2.0.0-alpha.4] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.12. + +## \[2.0.0-alpha.3] + +- [`e438e0a`](https://github.com/tauri-apps/plugins-workspace/commit/e438e0a62d4b430a5159f05f13ecd397dd891a0d)([#676](https://github.com/tauri-apps/plugins-workspace/pull/676)) Update to @tauri-apps/api v2.0.0-alpha.11. + ## \[2.0.0-alpha.2] -- [`4e2cef9`](https://github.com/tauri-apps/plugins-workspace/commit/4e2cef9b702bbbb9cf4ee17de50791cb21f1b2a4)([#593](https://github.com/tauri-apps/plugins-workspace/pull/593)) Update to alpha.12. +- [`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.1] +## \[2.0.0-alpha.2] -- [`d74fc0a`](https://github.com/tauri-apps/plugins-workspace/commit/d74fc0a097996e90a37be8f57d50b7d1f6ca616f)([#555](https://github.com/tauri-apps/plugins-workspace/pull/555)) Update to alpha.11. +- [`4e2cef9`](https://github.com/tauri-apps/plugins-workspace/commit/4e2cef9b702bbbb9cf4ee17de50791cb21f1b2a4)([#593](https://github.com/tauri-apps/plugins-workspace/pull/593)) Update to alpha.12. -## \[2.0.0-alpha.0] +## \[2.0.0-alpha.1] -- [`717ae67`](https://github.com/tauri-apps/plugins-workspace/commit/717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! - d `Command::arg`, `Command::env` and changed `Command::new` input type. -- [`52ef0ad`](https://github.com/tauri-apps/plugins-workspace/commit/52ef0addd84a1737a4e1a4b07113a30d3d496fa1)([#463](https://github.com/tauri-apps/plugins-workspace/pull/463)) Ensure the launched process is detached so it can out-live your tauri app and does not shutdown with it. - [`d74fc0a`](https://github.com/tauri-apps/plugins-workspace/commit/d74fc0a097996e90a37be8f57d50b7d1f6ca616f)([#555](https://github.com/tauri-apps/plugins-workspace/pull/555)) Update to alpha.11. ## \[2.0.0-alpha.0] diff --git a/plugins/shell/Cargo.toml b/plugins/shell/Cargo.toml index 48c7caf7..f3f1248c 100644 --- a/plugins/shell/Cargo.toml +++ b/plugins/shell/Cargo.toml @@ -1,23 +1,42 @@ [package] name = "tauri-plugin-shell" -version = "2.0.0-alpha.2" +version = "2.2.1" description = "Access the system shell. Allows you to spawn child processes and manage files and URLs using their default application." edition = { workspace = true } authors = { workspace = true } license = { workspace = true } rust-version = { workspace = true } +repository = { workspace = true } +links = "tauri-plugin-shell" [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] + +[package.metadata.platforms.support] +windows = { level = "full", notes = "" } +linux = { level = "full", notes = "" } +macos = { level = "full", notes = "" } +android = { level = "partial", notes = "Only allows to open URLs via `open`" } +ios = { level = "partial", notes = "Only allows to open URLs via `open`" } + +[build-dependencies] +tauri-plugin = { workspace = true, features = ["build"] } +schemars = { workspace = true } +serde = { workspace = true } [dependencies] serde = { workspace = true } serde_json = { workspace = true } tauri = { workspace = true } +tokio = { version = "1", features = ["time"] } log = { workspace = true } thiserror = { workspace = true } shared_child = "1" regex = "1" -open = "4" +open = { version = "5", features = ["shellexecute-on-windows"] } encoding_rs = "0.8" os_pipe = "1" + +[target.'cfg(target_os = "ios")'.dependencies] +tauri = { workspace = true, features = ["wry"] } diff --git a/plugins/shell/README.md b/plugins/shell/README.md index e7c995ea..5f309b8c 100644 --- a/plugins/shell/README.md +++ b/plugins/shell/README.md @@ -2,9 +2,17 @@ Access the system shell. Allows you to spawn child processes and manage files and URLs using their default application. +| Platform | Supported | +| -------- | --------- | +| Linux | ✓ | +| Windows | ✓ | +| macOS | ✓ | +| Android | ✓ | +| iOS | ✓ | + ## Install -_This plugin requires a Rust version of at least **1.70**_ +_This plugin requires a Rust version of at least **1.77.2**_ There are three general methods of installation that we can recommend. @@ -18,7 +26,7 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] -tauri-plugin-shell = "2.0.0-alpha" +tauri-plugin-shell = "2.0.0" # alternatively with Git: tauri-plugin-shell = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -46,7 +54,7 @@ yarn add https://github.com/tauri-apps/tauri-plugin-shell#v2 First you need to register the core plugin with Tauri: -`src-tauri/src/main.rs` +`src-tauri/src/lib.rs` ```rust fn main() { @@ -60,14 +68,30 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import { Command } from "@tauri-apps/plugin-shell"; -Command.create("git", ["commit", "-m", "the commit message"]); +import { Command } from '@tauri-apps/plugin-shell' +Command.create('git', ['commit', '-m', 'the commit message']) ``` ## Contributing PRs accepted. Please make sure to read the Contributing Guide before making a pull request. +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + ## License Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. diff --git a/plugins/shell/SECURITY.md b/plugins/shell/SECURITY.md new file mode 100644 index 00000000..4f09bbac --- /dev/null +++ b/plugins/shell/SECURITY.md @@ -0,0 +1,23 @@ +# Security Policy + +**Do not report security vulnerabilities through public GitHub issues.** + +**Please use the [Private Vulnerability Disclosure](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) feature of GitHub.** + +Include as much of the following information: + +- Type of issue (e.g. improper input parsing, privilege escalation, etc.) +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- The distribution affected or used to help us with reproduction of the issue +- Step-by-step instructions to reproduce the issue +- Ideally a reproduction repository +- Impact of the issue, including how an attacker might exploit the issue + +We prefer to receive reports in English. + +## Contact + +Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). + +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/shell/android/.gitignore b/plugins/shell/android/.gitignore new file mode 100644 index 00000000..c0f21ec2 --- /dev/null +++ b/plugins/shell/android/.gitignore @@ -0,0 +1,2 @@ +/build +/.tauri diff --git a/plugins/shell/android/build.gradle.kts b/plugins/shell/android/build.gradle.kts new file mode 100644 index 00000000..88082c65 --- /dev/null +++ b/plugins/shell/android/build.gradle.kts @@ -0,0 +1,39 @@ +plugins { + id("com.android.library") + id("org.jetbrains.kotlin.android") +} + +android { + namespace = "app.tauri.shell" + compileSdk = 34 + + defaultConfig { + minSdk = 24 + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles("consumer-rules.pro") + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = "1.8" + } +} + +dependencies { + implementation("androidx.core:core-ktx:1.9.0") + implementation("com.fasterxml.jackson.core:jackson-databind:2.15.3") + implementation(project(":tauri-android")) +} diff --git a/plugins/shell/android/proguard-rules.pro b/plugins/shell/android/proguard-rules.pro new file mode 100644 index 00000000..481bb434 --- /dev/null +++ b/plugins/shell/android/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/plugins/shell/android/settings.gradle b/plugins/shell/android/settings.gradle new file mode 100644 index 00000000..14a752e4 --- /dev/null +++ b/plugins/shell/android/settings.gradle @@ -0,0 +1,2 @@ +include ':tauri-android' +project(':tauri-android').projectDir = new File('./.tauri/tauri-api') diff --git a/plugins/shell/android/src/main/AndroidManifest.xml b/plugins/shell/android/src/main/AndroidManifest.xml new file mode 100644 index 00000000..9a40236b --- /dev/null +++ b/plugins/shell/android/src/main/AndroidManifest.xml @@ -0,0 +1,3 @@ + + + diff --git a/plugins/shell/android/src/main/java/ShellPlugin.kt b/plugins/shell/android/src/main/java/ShellPlugin.kt new file mode 100644 index 00000000..2268bc26 --- /dev/null +++ b/plugins/shell/android/src/main/java/ShellPlugin.kt @@ -0,0 +1,30 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +package app.tauri.shell + +import android.app.Activity +import android.content.Intent +import android.net.Uri +import app.tauri.annotation.Command +import app.tauri.annotation.TauriPlugin +import app.tauri.plugin.Invoke +import app.tauri.plugin.Plugin +import java.io.File + +@TauriPlugin +class ShellPlugin(private val activity: Activity) : Plugin(activity) { + @Command + fun open(invoke: Invoke) { + try { + val url = invoke.parseArgs(String::class.java) + val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + activity.applicationContext?.startActivity(intent) + invoke.resolve() + } catch (ex: Exception) { + invoke.reject(ex.message) + } + } +} \ No newline at end of file diff --git a/plugins/shell/api-iife.js b/plugins/shell/api-iife.js new file mode 100644 index 00000000..07ef37fc --- /dev/null +++ b/plugins/shell/api-iife.js @@ -0,0 +1 @@ +if("__TAURI__"in window){var __TAURI_PLUGIN_SHELL__=function(e){"use strict";function t(e,t,s,i){if("function"==typeof t||!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?i:"a"===s?i.call(e):i?i.value:t.get(e)}function s(e,t,s,i,n){if("function"==typeof t||!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,s),s}var i,n,r,o;"function"==typeof SuppressedError&&SuppressedError;const a="__TAURI_TO_IPC_KEY__";class h{constructor(e){i.set(this,void 0),n.set(this,0),r.set(this,[]),o.set(this,void 0),s(this,i,e||(()=>{})),this.id=function(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}((e=>{const a=e.index;if("end"in e)return void(a==t(this,n,"f")?this.cleanupCallback():s(this,o,a));const h=e.message;if(a==t(this,n,"f")){for(t(this,i,"f").call(this,h),s(this,n,t(this,n,"f")+1);t(this,n,"f")in t(this,r,"f");){const e=t(this,r,"f")[t(this,n,"f")];t(this,i,"f").call(this,e),delete t(this,r,"f")[t(this,n,"f")],s(this,n,t(this,n,"f")+1)}t(this,n,"f")===t(this,o,"f")&&this.cleanupCallback()}else t(this,r,"f")[a]=h}))}cleanupCallback(){Reflect.deleteProperty(window,`_${this.id}`)}set onmessage(e){s(this,i,e)}get onmessage(){return t(this,i,"f")}[(i=new WeakMap,n=new WeakMap,r=new WeakMap,o=new WeakMap,a)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[a]()}}async function c(e,t={},s){return window.__TAURI_INTERNALS__.invoke(e,t,s)}class l{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=i=>{this.removeListener(e,s),t(i)};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=i=>{this.removeListener(e,s),t(i)};return this.prependListener(e,s)}}class u{constructor(e){this.pid=e}async write(e){await c("plugin:shell|stdin_write",{pid:this.pid,buffer:e})}async kill(){await c("plugin:shell|kill",{cmd:"killChild",pid:this.pid})}}class p extends l{constructor(e,t=[],s){super(),this.stdout=new l,this.stderr=new l,this.program=e,this.args="string"==typeof t?[t]:t,this.options=s??{}}static create(e,t=[],s){return new p(e,t,s)}static sidecar(e,t=[],s){const i=new p(e,t,s);return i.options.sidecar=!0,i}async spawn(){const e=this.program,t=this.args,s=this.options;"object"==typeof t&&Object.freeze(t);const i=new h;return i.onmessage=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)}},await c("plugin:shell|spawn",{program:e,args:t,options:s,onEvent:i}).then((e=>new u(e)))}async execute(){const e=this.program,t=this.args,s=this.options;return"object"==typeof t&&Object.freeze(t),await c("plugin:shell|execute",{program:e,args:t,options:s})}}return e.Child=u,e.Command=p,e.EventEmitter=l,e.open=async function(e,t){await c("plugin:shell|open",{path:e,with:t})},e}({});Object.defineProperty(window.__TAURI__,"shell",{value:__TAURI_PLUGIN_SHELL__})} diff --git a/plugins/shell/build.rs b/plugins/shell/build.rs new file mode 100644 index 00000000..4e19ccd8 --- /dev/null +++ b/plugins/shell/build.rs @@ -0,0 +1,189 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use std::path::PathBuf; + +use schemars::JsonSchema; + +#[path = "src/scope_entry.rs"] +mod scope_entry; + +/// A command argument allowed to be executed by the webview API. +#[derive(Debug, PartialEq, Eq, Clone, Hash, schemars::JsonSchema)] +#[serde(untagged, deny_unknown_fields)] +#[non_exhaustive] +pub enum ShellScopeEntryAllowedArg { + /// A non-configurable argument that is passed to the command in the order it was specified. + Fixed(String), + + /// A variable that is set while calling the command from the webview API. + /// + Var { + /// [regex] validator to require passed values to conform to an expected input. + /// + /// This will require the argument value passed to this variable to match the `validator` regex + /// before it will be executed. + /// + /// The regex string is by default surrounded by `^...$` to match the full string. + /// For example the `https?://\w+` regex would be registered as `^https?://\w+$`. + /// + /// [regex]: + validator: String, + + /// Marks the validator as a raw regex, meaning the plugin should not make any modification at runtime. + /// + /// This means the regex will not match on the entire string by default, which might + /// be exploited if your regex allow unexpected input to be considered valid. + /// When using this option, make sure your regex is correct. + #[serde(default)] + raw: bool, + }, +} + +/// A set of command arguments allowed to be executed by the webview API. +/// +/// A value of `true` will allow any arguments to be passed to the command. `false` will disable all +/// arguments. A list of [`ShellScopeEntryAllowedArg`] will set those arguments as the only valid arguments to +/// be passed to the attached command configuration. +#[derive(Debug, PartialEq, Eq, Clone, Hash, JsonSchema)] +#[serde(untagged, deny_unknown_fields)] +#[non_exhaustive] +pub enum ShellScopeEntryAllowedArgs { + /// Use a simple boolean to allow all or disable all arguments to this command configuration. + Flag(bool), + + /// A specific set of [`ShellScopeEntryAllowedArg`] that are valid to call for the command configuration. + List(Vec), +} + +impl Default for ShellScopeEntryAllowedArgs { + fn default() -> Self { + Self::Flag(false) + } +} + +/// Shell scope entry. +#[derive(JsonSchema)] +#[serde(untagged, deny_unknown_fields)] +#[allow(unused)] +pub(crate) enum ShellScopeEntry { + Command { + /// The name for this allowed shell command configuration. + /// + /// This name will be used inside of the webview API to call this command along with + /// any specified arguments. + name: String, + /// The command name. + /// It can start with a variable that resolves to a system base directory. + /// The variables are: `$AUDIO`, `$CACHE`, `$CONFIG`, `$DATA`, `$LOCALDATA`, `$DESKTOP`, + /// `$DOCUMENT`, `$DOWNLOAD`, `$EXE`, `$FONT`, `$HOME`, `$PICTURE`, `$PUBLIC`, `$RUNTIME`, + /// `$TEMPLATE`, `$VIDEO`, `$RESOURCE`, `$LOG`, `$TEMP`, `$APPCONFIG`, `$APPDATA`, + /// `$APPLOCALDATA`, `$APPCACHE`, `$APPLOG`. + // use default just so the schema doesn't flag it as required + #[serde(rename = "cmd")] + command: PathBuf, + /// The allowed arguments for the command execution. + #[serde(default)] + args: ShellScopeEntryAllowedArgs, + }, + Sidecar { + /// The name for this allowed shell command configuration. + /// + /// This name will be used inside of the webview API to call this command along with + /// any specified arguments. + name: String, + /// The allowed arguments for the command execution. + #[serde(default)] + args: ShellScopeEntryAllowedArgs, + /// If this command is a sidecar command. + sidecar: bool, + }, +} + +// Ensure `ShellScopeEntry` and `scope_entry::EntryRaw` +// and `ShellScopeEntryAllowedArg` and `ShellAllowedArg` +// and `ShellScopeEntryAllowedArgs` and `ShellAllowedArgs` +// are kept in sync +#[allow(clippy::unnecessary_operation)] +fn _f() { + match (ShellScopeEntry::Sidecar { + name: String::new(), + args: ShellScopeEntryAllowedArgs::Flag(false), + sidecar: true, + }) { + ShellScopeEntry::Command { + name, + command, + args, + } => scope_entry::EntryRaw { + name, + command: Some(command), + args: match args { + ShellScopeEntryAllowedArgs::Flag(flag) => scope_entry::ShellAllowedArgs::Flag(flag), + ShellScopeEntryAllowedArgs::List(vec) => scope_entry::ShellAllowedArgs::List( + vec.into_iter() + .map(|s| match s { + ShellScopeEntryAllowedArg::Fixed(fixed) => { + scope_entry::ShellAllowedArg::Fixed(fixed) + } + ShellScopeEntryAllowedArg::Var { validator, raw } => { + scope_entry::ShellAllowedArg::Var { validator, raw } + } + }) + .collect(), + ), + }, + sidecar: false, + }, + ShellScopeEntry::Sidecar { + name, + args, + sidecar, + } => scope_entry::EntryRaw { + name, + command: None, + args: match args { + ShellScopeEntryAllowedArgs::Flag(flag) => scope_entry::ShellAllowedArgs::Flag(flag), + ShellScopeEntryAllowedArgs::List(vec) => scope_entry::ShellAllowedArgs::List( + vec.into_iter() + .map(|s| match s { + ShellScopeEntryAllowedArg::Fixed(fixed) => { + scope_entry::ShellAllowedArg::Fixed(fixed) + } + ShellScopeEntryAllowedArg::Var { validator, raw } => { + scope_entry::ShellAllowedArg::Var { validator, raw } + } + }) + .collect(), + ), + }, + sidecar, + }, + }; +} + +const COMMANDS: &[&str] = &["execute", "spawn", "stdin_write", "kill", "open"]; + +fn main() { + tauri_plugin::Builder::new(COMMANDS) + .global_api_script_path("./api-iife.js") + .global_scope_schema(schemars::schema_for!(ShellScopeEntry)) + .android_path("android") + .ios_path("ios") + .build(); + + let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap(); + let mobile = target_os == "ios" || target_os == "android"; + alias("desktop", !mobile); + alias("mobile", mobile); +} + +// creates a cfg alias if `has_feature` is true. +// `alias` must be a snake case string. +fn alias(alias: &str, has_feature: bool) { + println!("cargo:rustc-check-cfg=cfg({alias})"); + if has_feature { + println!("cargo:rustc-cfg={alias}"); + } +} diff --git a/plugins/shell/guest-js/index.ts b/plugins/shell/guest-js/index.ts index 9fb5e4f2..1ed2ac5d 100644 --- a/plugins/shell/guest-js/index.ts +++ b/plugins/shell/guest-js/index.ts @@ -18,11 +18,11 @@ * * ### Restricting access to the {@link Command | `Command`} APIs * - * The plugin configuration object has a `scope` field that defines an array of CLIs that can be used. + * The plugin permissions object has a `scope` field that defines an array of CLIs that can be used. * Each CLI is a configuration object `{ name: string, cmd: string, sidecar?: bool, args?: boolean | Arg[] }`. * * - `name`: the unique identifier of the command, passed to the {@link Command.create | Command.create function}. - * If it's a sidecar, this must be the value defined on `tauri.conf.json > tauri > bundle > externalBin`. + * If it's a sidecar, this must be the value defined on `tauri.conf.json > bundle > externalBin`. * - `cmd`: the program that is executed on this configuration. If it's a sidecar, this value is ignored. * - `sidecar`: whether the object configures a sidecar or a system program. * - `args`: the arguments that can be passed to the program. By default no arguments are allowed. @@ -35,12 +35,13 @@ * * CLI: `git commit -m "the commit message"` * - * Configuration: + * Capability: * ```json * { - * "plugins": { - * "shell": { - * "scope": [ + * "permissions": [ + * { + * "identifier": "shell:allow-execute", + * "allow": [ * { * "name": "run-git-commit", * "cmd": "git", @@ -48,7 +49,7 @@ * } * ] * } - * } + * ] * } * ``` * Usage: @@ -62,27 +63,27 @@ * @module */ -import { invoke, Channel } from "@tauri-apps/api/primitives"; +import { invoke, Channel } from '@tauri-apps/api/core' /** * @since 2.0.0 */ interface SpawnOptions { /** Current working directory. */ - cwd?: string; + cwd?: string /** Environment variables. set to `null` to clear the process env. */ - env?: Record; + env?: Record /** * Character encoding for stdout/stderr * * @since 2.0.0 * */ - encoding?: string; + encoding?: string } /** @ignore */ interface InternalSpawnOptions extends SpawnOptions { - sidecar?: boolean; + sidecar?: boolean } /** @@ -90,46 +91,13 @@ interface InternalSpawnOptions extends SpawnOptions { */ interface ChildProcess { /** Exit code of the process. `null` if the process was terminated by a signal on Unix. */ - code: number | null; + code: number | null /** If the process was terminated by a signal, represents that signal. */ - signal: number | null; + signal: number | null /** The data that the process wrote to `stdout`. */ - stdout: O; + stdout: O /** The data that the process wrote to `stderr`. */ - stderr: O; -} - -/** - * Spawns a process. - * - * @ignore - * @param program The name of the scoped command. - * @param onEventHandler Event handler. - * @param args Program arguments. - * @param options Configuration for the process spawn. - * @returns A promise resolving to the process id. - * - * @since 2.0.0 - */ -async function execute( - onEventHandler: (event: CommandEvent) => void, - program: string, - args: string | string[] = [], - options?: InternalSpawnOptions, -): Promise { - if (typeof args === "object") { - Object.freeze(args); - } - - const onEvent = new Channel>(); - onEvent.onmessage = onEventHandler; - - return invoke("plugin:shell|execute", { - program, - args, - options, - onEvent, - }); + stderr: O } /** @@ -140,7 +108,7 @@ class EventEmitter> { /** @ignore */ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any private eventListeners: Record void>> = - Object.create(null); + Object.create(null) /** * Alias for `emitter.on(eventName, listener)`. @@ -149,9 +117,9 @@ class EventEmitter> { */ addListener( eventName: N, - listener: (arg: E[typeof eventName]) => void, + listener: (arg: E[typeof eventName]) => void ): this { - return this.on(eventName, listener); + return this.on(eventName, listener) } /** @@ -161,9 +129,9 @@ class EventEmitter> { */ removeListener( eventName: N, - listener: (arg: E[typeof eventName]) => void, + listener: (arg: E[typeof eventName]) => void ): this { - return this.off(eventName, listener); + return this.off(eventName, listener) } /** @@ -178,16 +146,16 @@ class EventEmitter> { */ on( eventName: N, - listener: (arg: E[typeof eventName]) => void, + listener: (arg: E[typeof eventName]) => void ): this { if (eventName in this.eventListeners) { // eslint-disable-next-line security/detect-object-injection - this.eventListeners[eventName].push(listener); + this.eventListeners[eventName].push(listener) } else { // eslint-disable-next-line security/detect-object-injection - this.eventListeners[eventName] = [listener]; + this.eventListeners[eventName] = [listener] } - return this; + return this } /** @@ -200,14 +168,13 @@ class EventEmitter> { */ once( eventName: N, - listener: (arg: E[typeof eventName]) => void, + listener: (arg: E[typeof eventName]) => void ): this { const wrapper = (arg: E[typeof eventName]): void => { - this.removeListener(eventName, wrapper); - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument - listener(arg); - }; - return this.addListener(eventName, wrapper); + this.removeListener(eventName, wrapper) + listener(arg) + } + return this.addListener(eventName, wrapper) } /** @@ -218,15 +185,15 @@ class EventEmitter> { */ off( eventName: N, - listener: (arg: E[typeof eventName]) => void, + listener: (arg: E[typeof eventName]) => void ): this { if (eventName in this.eventListeners) { // eslint-disable-next-line security/detect-object-injection this.eventListeners[eventName] = this.eventListeners[eventName].filter( - (l) => l !== listener, - ); + (l) => l !== listener + ) } - return this; + return this } /** @@ -238,13 +205,13 @@ class EventEmitter> { */ removeAllListeners(event?: N): this { if (event) { - // eslint-disable-next-line @typescript-eslint/no-dynamic-delete,security/detect-object-injection - delete this.eventListeners[event]; + // eslint-disable-next-line security/detect-object-injection + delete this.eventListeners[event] } else { // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment - this.eventListeners = Object.create(null); + this.eventListeners = Object.create(null) } - return this; + return this } /** @@ -258,13 +225,12 @@ class EventEmitter> { */ emit(eventName: N, arg: E[typeof eventName]): boolean { if (eventName in this.eventListeners) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,security/detect-object-injection - const listeners = this.eventListeners[eventName]; - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument - for (const listener of listeners) listener(arg); - return true; + // eslint-disable-next-line security/detect-object-injection + const listeners = this.eventListeners[eventName] + for (const listener of listeners) listener(arg) + return true } - return false; + return false } /** @@ -275,8 +241,8 @@ class EventEmitter> { listenerCount(eventName: N): number { if (eventName in this.eventListeners) // eslint-disable-next-line security/detect-object-injection - return this.eventListeners[eventName].length; - return 0; + return this.eventListeners[eventName].length + return 0 } /** @@ -291,16 +257,16 @@ class EventEmitter> { */ prependListener( eventName: N, - listener: (arg: E[typeof eventName]) => void, + listener: (arg: E[typeof eventName]) => void ): this { if (eventName in this.eventListeners) { // eslint-disable-next-line security/detect-object-injection - this.eventListeners[eventName].unshift(listener); + this.eventListeners[eventName].unshift(listener) } else { // eslint-disable-next-line security/detect-object-injection - this.eventListeners[eventName] = [listener]; + this.eventListeners[eventName] = [listener] } - return this; + return this } /** @@ -313,15 +279,15 @@ class EventEmitter> { */ prependOnceListener( eventName: N, - listener: (arg: E[typeof eventName]) => void, + listener: (arg: E[typeof eventName]) => void ): this { // eslint-disable-next-line @typescript-eslint/no-explicit-any const wrapper = (arg: any): void => { - this.removeListener(eventName, wrapper); + this.removeListener(eventName, wrapper) // eslint-disable-next-line @typescript-eslint/no-unsafe-argument - listener(arg); - }; - return this.prependListener(eventName, wrapper); + listener(arg) + } + return this.prependListener(eventName, wrapper) } } @@ -330,10 +296,10 @@ class EventEmitter> { */ class Child { /** The child process `pid`. */ - pid: number; + pid: number constructor(pid: number) { - this.pid = pid; + this.pid = pid } /** @@ -353,12 +319,11 @@ class Child { * * @since 2.0.0 */ - async write(data: IOPayload): Promise { - return invoke("plugin:shell|stdin_write", { + async write(data: IOPayload | number[]): Promise { + await invoke('plugin:shell|stdin_write', { pid: this.pid, - // correctly serialize Uint8Arrays - buffer: typeof data === "string" ? data : Array.from(data), - }); + buffer: data + }) } /** @@ -369,20 +334,20 @@ class Child { * @since 2.0.0 */ async kill(): Promise { - return invoke("plugin:shell|kill", { - cmd: "killChild", - pid: this.pid, - }); + await invoke('plugin:shell|kill', { + cmd: 'killChild', + pid: this.pid + }) } } interface CommandEvents { - close: TerminatedPayload; - error: string; + close: TerminatedPayload + error: string } interface OutputEvents { - data: O; + data: O } /** @@ -408,15 +373,15 @@ interface OutputEvents { */ class Command extends EventEmitter { /** @ignore Program to execute. */ - private readonly program: string; + private readonly program: string /** @ignore Program arguments */ - private readonly args: string[]; + private readonly args: string[] /** @ignore Spawn options. */ - private readonly options: InternalSpawnOptions; + private readonly options: InternalSpawnOptions /** Event emitter for the `stdout`. Emits the `data` event. */ - readonly stdout = new EventEmitter>(); + readonly stdout = new EventEmitter>() /** Event emitter for the `stderr`. Emits the `data` event. */ - readonly stderr = new EventEmitter>(); + readonly stderr = new EventEmitter>() /** * @ignore @@ -430,25 +395,25 @@ class Command extends EventEmitter { private constructor( program: string, args: string | string[] = [], - options?: SpawnOptions, + options?: SpawnOptions ) { - super(); - this.program = program; - this.args = typeof args === "string" ? [args] : args; - this.options = options ?? {}; + super() + this.program = program + this.args = typeof args === 'string' ? [args] : args + this.options = options ?? {} } - static create(program: string, args?: string | string[]): Command; + static create(program: string, args?: string | string[]): Command static create( program: string, args?: string | string[], - options?: SpawnOptions & { encoding: "raw" }, - ): Command; + options?: SpawnOptions & { encoding: 'raw' } + ): Command static create( program: string, args?: string | string[], - options?: SpawnOptions, - ): Command; + options?: SpawnOptions + ): Command /** * Creates a command to execute the given program. @@ -465,22 +430,22 @@ class Command extends EventEmitter { static create( program: string, args: string | string[] = [], - options?: SpawnOptions, + options?: SpawnOptions ): Command { - return new Command(program, args, options); + return new Command(program, args, options) } - static sidecar(program: string, args?: string | string[]): Command; + static sidecar(program: string, args?: string | string[]): Command static sidecar( program: string, args?: string | string[], - options?: SpawnOptions & { encoding: "raw" }, - ): Command; + options?: SpawnOptions & { encoding: 'raw' } + ): Command static sidecar( program: string, args?: string | string[], - options?: SpawnOptions, - ): Command; + options?: SpawnOptions + ): Command /** * Creates a command to execute the given sidecar program. @@ -497,11 +462,11 @@ class Command extends EventEmitter { static sidecar( program: string, args: string | string[] = [], - options?: SpawnOptions, + options?: SpawnOptions ): Command { - const instance = new Command(program, args, options); - instance.options.sidecar = true; - return instance; + const instance = new Command(program, args, options) + instance.options.sidecar = true + return instance } /** @@ -512,27 +477,38 @@ class Command extends EventEmitter { * @since 2.0.0 */ async spawn(): Promise { - return execute( - (event) => { - switch (event.event) { - case "Error": - this.emit("error", event.payload); - break; - case "Terminated": - this.emit("close", event.payload); - break; - case "Stdout": - this.stdout.emit("data", event.payload); - break; - case "Stderr": - this.stderr.emit("data", event.payload); - break; - } - }, - this.program, - this.args, - this.options, - ).then((pid) => new Child(pid)); + const program = this.program + const args = this.args + const options = this.options + + if (typeof args === 'object') { + Object.freeze(args) + } + + const onEvent = new Channel>() + onEvent.onmessage = (event) => { + switch (event.event) { + case 'Error': + this.emit('error', event.payload) + break + case 'Terminated': + this.emit('close', event.payload) + break + case 'Stdout': + this.stdout.emit('data', event.payload) + break + case 'Stderr': + this.stderr.emit('data', event.payload) + break + } + } + + return await invoke('plugin:shell|spawn', { + program, + args, + options, + onEvent + }).then((pid) => new Child(pid)) } /** @@ -552,40 +528,19 @@ class Command extends EventEmitter { * @since 2.0.0 */ async execute(): Promise> { - return new Promise((resolve, reject) => { - this.on("error", reject); - - const stdout: O[] = []; - const stderr: O[] = []; - this.stdout.on("data", (line: O) => { - stdout.push(line); - }); - this.stderr.on("data", (line: O) => { - stderr.push(line); - }); - - this.on("close", (payload: TerminatedPayload) => { - resolve({ - code: payload.code, - signal: payload.signal, - stdout: this.collectOutput(stdout) as O, - stderr: this.collectOutput(stderr) as O, - }); - }); - - this.spawn().catch(reject); - }); - } + const program = this.program + const args = this.args + const options = this.options - /** @ignore */ - private collectOutput(events: O[]): string | Uint8Array { - if (this.options.encoding === "raw") { - return events.reduce((p, c) => { - return new Uint8Array([...p, ...(c as Uint8Array), 10]); - }, new Uint8Array()); - } else { - return events.join("\n"); + if (typeof args === 'object') { + Object.freeze(args) } + + return await invoke>('plugin:shell|execute', { + program, + args, + options + }) } } @@ -593,8 +548,8 @@ class Command extends EventEmitter { * Describes the event message received from the command. */ interface Event { - event: T; - payload: V; + event: T + payload: V } /** @@ -602,20 +557,20 @@ interface Event { */ interface TerminatedPayload { /** Exit code of the process. `null` if the process was terminated by a signal on Unix. */ - code: number | null; + code: number | null /** If the process was terminated by a signal, represents that signal. */ - signal: number | null; + signal: number | null } /** Event payload type */ -type IOPayload = string | Uint8Array; +type IOPayload = string | Uint8Array /** Events emitted by the child process. */ type CommandEvent = - | Event<"Stdout", O> - | Event<"Stderr", O> - | Event<"Terminated", TerminatedPayload> - | Event<"Error", string>; + | Event<'Stdout', O> + | Event<'Stderr', O> + | Event<'Terminated', TerminatedPayload> + | Event<'Error', string> /** * Opens a path or URL with the system's default app, @@ -644,18 +599,18 @@ type CommandEvent = * @since 2.0.0 */ async function open(path: string, openWith?: string): Promise { - return invoke("plugin:shell|open", { + await invoke('plugin:shell|open', { path, - with: openWith, - }); + with: openWith + }) } -export { Command, Child, EventEmitter, open }; +export { Command, Child, EventEmitter, open } export type { IOPayload, CommandEvents, TerminatedPayload, OutputEvents, ChildProcess, - SpawnOptions, -}; + SpawnOptions +} diff --git a/plugins/shell/guest-js/init.ts b/plugins/shell/guest-js/init.ts index 61c10a9e..b7e68a15 100644 --- a/plugins/shell/guest-js/init.ts +++ b/plugins/shell/guest-js/init.ts @@ -2,39 +2,39 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { invoke } from "@tauri-apps/api/primitives"; +import { invoke } from '@tauri-apps/api/core' // open
links with the API -function openLinks() { - document.querySelector("body")?.addEventListener("click", function (e) { - let target = e.target as HTMLElement; - while (target != null) { - if (target.matches("a")) { - const t = target as HTMLAnchorElement; +function openLinks(): void { + document.querySelector('body')?.addEventListener('click', function (e) { + let target: HTMLElement | null = e.target as HTMLElement + while (target) { + if (target.matches('a')) { + const t = target as HTMLAnchorElement if ( - t.href && - ["http://", "https://", "mailto:", "tel:"].some((v) => - t.href.startsWith(v), - ) && - t.target === "_blank" + t.href !== '' + && ['http://', 'https://', 'mailto:', 'tel:'].some((v) => + t.href.startsWith(v) + ) + && t.target === '_blank' ) { - invoke("plugin:shell|open", { - path: t.href, - }); - e.preventDefault(); + void invoke('plugin:shell|open', { + path: t.href + }) + e.preventDefault() } - break; + break } - target = target.parentElement as HTMLElement; + target = target.parentElement } - }); + }) } if ( - document.readyState === "complete" || - document.readyState === "interactive" + document.readyState === 'complete' + || document.readyState === 'interactive' ) { - openLinks(); + openLinks() } else { - window.addEventListener("DOMContentLoaded", openLinks, true); + window.addEventListener('DOMContentLoaded', openLinks, true) } diff --git a/plugins/shell/ios/Package.resolved b/plugins/shell/ios/Package.resolved new file mode 100644 index 00000000..5f998e0e --- /dev/null +++ b/plugins/shell/ios/Package.resolved @@ -0,0 +1,16 @@ +{ + "object": { + "pins": [ + { + "package": "SwiftRs", + "repositoryURL": "https://github.com/Brendonovich/swift-rs", + "state": { + "branch": null, + "revision": "b5ed223fcdab165bc21219c1925dc1e77e2bef5e", + "version": "1.0.6" + } + } + ] + }, + "version": 1 +} diff --git a/plugins/shell/ios/Package.swift b/plugins/shell/ios/Package.swift new file mode 100644 index 00000000..c7b2a7aa --- /dev/null +++ b/plugins/shell/ios/Package.swift @@ -0,0 +1,34 @@ +// swift-tools-version:5.3 +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import PackageDescription + +let package = Package( + name: "tauri-plugin-shell", + platforms: [ + .macOS(.v10_13), + .iOS(.v13), + ], + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .library( + name: "tauri-plugin-shell", + type: .static, + targets: ["tauri-plugin-shell"]) + ], + dependencies: [ + .package(name: "Tauri", path: "../.tauri/tauri-api") + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .target( + name: "tauri-plugin-shell", + dependencies: [ + .byName(name: "Tauri") + ], + path: "Sources") + ] +) diff --git a/plugins/shell/ios/Sources/ShellPlugin.swift b/plugins/shell/ios/Sources/ShellPlugin.swift new file mode 100644 index 00000000..0fcb7dac --- /dev/null +++ b/plugins/shell/ios/Sources/ShellPlugin.swift @@ -0,0 +1,34 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import Foundation + +import SwiftRs +import Tauri +import UIKit +import WebKit + +class ShellPlugin: Plugin { + + @objc public func open(_ invoke: Invoke) throws { + do { + let urlString = try invoke.parseArgs(String.self) + if let url = URL(string: urlString) { + if #available(iOS 10, *) { + UIApplication.shared.open(url, options: [:]) + } else { + UIApplication.shared.openURL(url) + } + } + invoke.resolve() + } catch { + invoke.reject(error.localizedDescription) + } + } +} + +@_cdecl("init_plugin_shell") +func initPlugin() -> Plugin { + return ShellPlugin() +} diff --git a/plugins/shell/package.json b/plugins/shell/package.json index 20e4501a..e42394c8 100644 --- a/plugins/shell/package.json +++ b/plugins/shell/package.json @@ -1,32 +1,29 @@ { "name": "@tauri-apps/plugin-shell", - "version": "2.0.0-alpha.1", - "license": "MIT or APACHE-2.0", + "version": "2.2.1", + "license": "MIT OR Apache-2.0", "authors": [ "Tauri Programme within The Commons Conservancy" ], + "repository": "https://github.com/tauri-apps/plugins-workspace", "type": "module", - "browser": "dist-js/index.min.js", - "module": "dist-js/index.mjs", - "types": "dist-js/index.d.ts", + "types": "./dist-js/index.d.ts", + "main": "./dist-js/index.cjs", + "module": "./dist-js/index.js", "exports": { - "import": "./dist-js/index.mjs", "types": "./dist-js/index.d.ts", - "browser": "./dist-js/index.min.js" + "import": "./dist-js/index.js", + "require": "./dist-js/index.cjs" }, "scripts": { "build": "rollup -c" }, "files": [ "dist-js", - "!dist-js/**/*.map", "README.md", "LICENSE" ], - "devDependencies": { - "tslib": "^2.4.1" - }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.9" + "@tauri-apps/api": "^2.0.0" } } diff --git a/plugins/shell/permissions/autogenerated/commands/execute.toml b/plugins/shell/permissions/autogenerated/commands/execute.toml new file mode 100644 index 00000000..d98be899 --- /dev/null +++ b/plugins/shell/permissions/autogenerated/commands/execute.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-execute" +description = "Enables the execute command without any pre-configured scope." +commands.allow = ["execute"] + +[[permission]] +identifier = "deny-execute" +description = "Denies the execute command without any pre-configured scope." +commands.deny = ["execute"] diff --git a/plugins/shell/permissions/autogenerated/commands/kill.toml b/plugins/shell/permissions/autogenerated/commands/kill.toml new file mode 100644 index 00000000..11d2f7f0 --- /dev/null +++ b/plugins/shell/permissions/autogenerated/commands/kill.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-kill" +description = "Enables the kill command without any pre-configured scope." +commands.allow = ["kill"] + +[[permission]] +identifier = "deny-kill" +description = "Denies the kill command without any pre-configured scope." +commands.deny = ["kill"] diff --git a/plugins/shell/permissions/autogenerated/commands/open.toml b/plugins/shell/permissions/autogenerated/commands/open.toml new file mode 100644 index 00000000..4ea6dff1 --- /dev/null +++ b/plugins/shell/permissions/autogenerated/commands/open.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-open" +description = "Enables the open command without any pre-configured scope." +commands.allow = ["open"] + +[[permission]] +identifier = "deny-open" +description = "Denies the open command without any pre-configured scope." +commands.deny = ["open"] diff --git a/plugins/shell/permissions/autogenerated/commands/spawn.toml b/plugins/shell/permissions/autogenerated/commands/spawn.toml new file mode 100644 index 00000000..a3802d2a --- /dev/null +++ b/plugins/shell/permissions/autogenerated/commands/spawn.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-spawn" +description = "Enables the spawn command without any pre-configured scope." +commands.allow = ["spawn"] + +[[permission]] +identifier = "deny-spawn" +description = "Denies the spawn command without any pre-configured scope." +commands.deny = ["spawn"] diff --git a/plugins/shell/permissions/autogenerated/commands/stdin_write.toml b/plugins/shell/permissions/autogenerated/commands/stdin_write.toml new file mode 100644 index 00000000..46ca5a73 --- /dev/null +++ b/plugins/shell/permissions/autogenerated/commands/stdin_write.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-stdin-write" +description = "Enables the stdin_write command without any pre-configured scope." +commands.allow = ["stdin_write"] + +[[permission]] +identifier = "deny-stdin-write" +description = "Denies the stdin_write command without any pre-configured scope." +commands.deny = ["stdin_write"] diff --git a/plugins/shell/permissions/autogenerated/reference.md b/plugins/shell/permissions/autogenerated/reference.md new file mode 100644 index 00000000..d2b86f8a --- /dev/null +++ b/plugins/shell/permissions/autogenerated/reference.md @@ -0,0 +1,155 @@ +## Default Permission + +This permission set configures which +shell functionality is exposed by default. + +#### Granted Permissions + +It allows to use the `open` functionality with a reasonable +scope pre-configured. It will allow opening `http(s)://`, +`tel:` and `mailto:` links. + + +#### This default permission set includes the following: + +- `allow-open` + +## Permission Table + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IdentifierDescription
+ +`shell:allow-execute` + + + +Enables the execute command without any pre-configured scope. + +
+ +`shell:deny-execute` + + + +Denies the execute command without any pre-configured scope. + +
+ +`shell:allow-kill` + + + +Enables the kill command without any pre-configured scope. + +
+ +`shell:deny-kill` + + + +Denies the kill command without any pre-configured scope. + +
+ +`shell:allow-open` + + + +Enables the open command without any pre-configured scope. + +
+ +`shell:deny-open` + + + +Denies the open command without any pre-configured scope. + +
+ +`shell:allow-spawn` + + + +Enables the spawn command without any pre-configured scope. + +
+ +`shell:deny-spawn` + + + +Denies the spawn command without any pre-configured scope. + +
+ +`shell:allow-stdin-write` + + + +Enables the stdin_write command without any pre-configured scope. + +
+ +`shell:deny-stdin-write` + + + +Denies the stdin_write command without any pre-configured scope. + +
diff --git a/plugins/shell/permissions/default.toml b/plugins/shell/permissions/default.toml new file mode 100644 index 00000000..dba2ea20 --- /dev/null +++ b/plugins/shell/permissions/default.toml @@ -0,0 +1,15 @@ +"$schema" = "schemas/schema.json" + +[default] +description = """ +This permission set configures which +shell functionality is exposed by default. + +#### Granted Permissions + +It allows to use the `open` functionality with a reasonable +scope pre-configured. It will allow opening `http(s)://`, +`tel:` and `mailto:` links. +""" + +permissions = ["allow-open"] diff --git a/plugins/shell/permissions/schemas/schema.json b/plugins/shell/permissions/schemas/schema.json new file mode 100644 index 00000000..9a198981 --- /dev/null +++ b/plugins/shell/permissions/schemas/schema.json @@ -0,0 +1,366 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "PermissionFile", + "description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.", + "type": "object", + "properties": { + "default": { + "description": "The default permission set for the plugin", + "anyOf": [ + { + "$ref": "#/definitions/DefaultPermission" + }, + { + "type": "null" + } + ] + }, + "set": { + "description": "A list of permissions sets defined", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionSet" + } + }, + "permission": { + "description": "A list of inlined permissions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Permission" + } + } + }, + "definitions": { + "DefaultPermission": { + "description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.", + "type": "object", + "required": [ + "permissions" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "PermissionSet": { + "description": "A set of direct permissions grouped together under a new name.", + "type": "object", + "required": [ + "description", + "identifier", + "permissions" + ], + "properties": { + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does.", + "type": "string" + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionKind" + } + } + } + }, + "Permission": { + "description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.", + "type": "object", + "required": [ + "identifier" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri internal convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "commands": { + "description": "Allowed or denied commands when using this permission.", + "default": { + "allow": [], + "deny": [] + }, + "allOf": [ + { + "$ref": "#/definitions/Commands" + } + ] + }, + "scope": { + "description": "Allowed or denied scoped when using this permission.", + "allOf": [ + { + "$ref": "#/definitions/Scopes" + } + ] + }, + "platforms": { + "description": "Target platforms this permission applies. By default all platforms are affected by this permission.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Target" + } + } + } + }, + "Commands": { + "description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.", + "type": "object", + "properties": { + "allow": { + "description": "Allowed command.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "deny": { + "description": "Denied command, which takes priority.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "Scopes": { + "description": "An argument for fine grained behavior control of Tauri commands.\n\nIt can be of any serde serializable type and is used to allow or prevent certain actions inside a Tauri command. The configured scope is passed to the command and will be enforced by the command implementation.\n\n## Example\n\n```json { \"allow\": [{ \"path\": \"$HOME/**\" }], \"deny\": [{ \"path\": \"$HOME/secret.txt\" }] } ```", + "type": "object", + "properties": { + "allow": { + "description": "Data that defines what is allowed by the scope.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + }, + "deny": { + "description": "Data that defines what is denied by the scope. This should be prioritized by validation logic.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + } + } + }, + "Value": { + "description": "All supported ACL values.", + "anyOf": [ + { + "description": "Represents a null JSON value.", + "type": "null" + }, + { + "description": "Represents a [`bool`].", + "type": "boolean" + }, + { + "description": "Represents a valid ACL [`Number`].", + "allOf": [ + { + "$ref": "#/definitions/Number" + } + ] + }, + { + "description": "Represents a [`String`].", + "type": "string" + }, + { + "description": "Represents a list of other [`Value`]s.", + "type": "array", + "items": { + "$ref": "#/definitions/Value" + } + }, + { + "description": "Represents a map of [`String`] keys to [`Value`]s.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/Value" + } + } + ] + }, + "Number": { + "description": "A valid ACL number.", + "anyOf": [ + { + "description": "Represents an [`i64`].", + "type": "integer", + "format": "int64" + }, + { + "description": "Represents a [`f64`].", + "type": "number", + "format": "double" + } + ] + }, + "Target": { + "description": "Platform target.", + "oneOf": [ + { + "description": "MacOS.", + "type": "string", + "enum": [ + "macOS" + ] + }, + { + "description": "Windows.", + "type": "string", + "enum": [ + "windows" + ] + }, + { + "description": "Linux.", + "type": "string", + "enum": [ + "linux" + ] + }, + { + "description": "Android.", + "type": "string", + "enum": [ + "android" + ] + }, + { + "description": "iOS.", + "type": "string", + "enum": [ + "iOS" + ] + } + ] + }, + "PermissionKind": { + "type": "string", + "oneOf": [ + { + "description": "Enables the execute command without any pre-configured scope.", + "type": "string", + "const": "allow-execute", + "markdownDescription": "Enables the execute command without any pre-configured scope." + }, + { + "description": "Denies the execute command without any pre-configured scope.", + "type": "string", + "const": "deny-execute", + "markdownDescription": "Denies the execute command without any pre-configured scope." + }, + { + "description": "Enables the kill command without any pre-configured scope.", + "type": "string", + "const": "allow-kill", + "markdownDescription": "Enables the kill command without any pre-configured scope." + }, + { + "description": "Denies the kill command without any pre-configured scope.", + "type": "string", + "const": "deny-kill", + "markdownDescription": "Denies the kill command without any pre-configured scope." + }, + { + "description": "Enables the open command without any pre-configured scope.", + "type": "string", + "const": "allow-open", + "markdownDescription": "Enables the open command without any pre-configured scope." + }, + { + "description": "Denies the open command without any pre-configured scope.", + "type": "string", + "const": "deny-open", + "markdownDescription": "Denies the open command without any pre-configured scope." + }, + { + "description": "Enables the spawn command without any pre-configured scope.", + "type": "string", + "const": "allow-spawn", + "markdownDescription": "Enables the spawn command without any pre-configured scope." + }, + { + "description": "Denies the spawn command without any pre-configured scope.", + "type": "string", + "const": "deny-spawn", + "markdownDescription": "Denies the spawn command without any pre-configured scope." + }, + { + "description": "Enables the stdin_write command without any pre-configured scope.", + "type": "string", + "const": "allow-stdin-write", + "markdownDescription": "Enables the stdin_write command without any pre-configured scope." + }, + { + "description": "Denies the stdin_write command without any pre-configured scope.", + "type": "string", + "const": "deny-stdin-write", + "markdownDescription": "Denies the stdin_write command without any pre-configured scope." + }, + { + "description": "This permission set configures which\nshell functionality is exposed by default.\n\n#### Granted Permissions\n\nIt allows to use the `open` functionality with a reasonable\nscope pre-configured. It will allow opening `http(s)://`,\n`tel:` and `mailto:` links.\n\n#### This default permission set includes:\n\n- `allow-open`", + "type": "string", + "const": "default", + "markdownDescription": "This permission set configures which\nshell functionality is exposed by default.\n\n#### Granted Permissions\n\nIt allows to use the `open` functionality with a reasonable\nscope pre-configured. It will allow opening `http(s)://`,\n`tel:` and `mailto:` links.\n\n#### This default permission set includes:\n\n- `allow-open`" + } + ] + } + } +} \ No newline at end of file diff --git a/plugins/shell/rollup.config.js b/plugins/shell/rollup.config.js new file mode 100644 index 00000000..a7dbd4f6 --- /dev/null +++ b/plugins/shell/rollup.config.js @@ -0,0 +1,22 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import { createConfig } from '../../shared/rollup.config.js' +import { nodeResolve } from '@rollup/plugin-node-resolve' +import typescript from '@rollup/plugin-typescript' +import terser from '@rollup/plugin-terser' + +export default createConfig({ + additionalConfigs: { + input: 'guest-js/init.ts', + output: { + file: 'src/init-iife.js', + format: 'iife' + }, + plugins: [typescript(), terser(), nodeResolve()], + onwarn: (warning) => { + throw Object.assign(new Error(), warning) + } + } +}) diff --git a/plugins/shell/rollup.config.mjs b/plugins/shell/rollup.config.mjs deleted file mode 100644 index d2a3cda6..00000000 --- a/plugins/shell/rollup.config.mjs +++ /dev/null @@ -1,34 +0,0 @@ -import { readFileSync } from "fs"; - -import { createConfig } from "../../shared/rollup.config.mjs"; - -import typescript from "@rollup/plugin-typescript"; -import resolve from "@rollup/plugin-node-resolve"; -import terser from "@rollup/plugin-terser"; - -const config = createConfig({ - input: "guest-js/index.ts", - pkg: JSON.parse( - readFileSync(new URL("./package.json", import.meta.url), "utf8"), - ), - external: [/^@tauri-apps\/api/], -}); - -config.push({ - input: "guest-js/init.ts", - output: { - file: "src/init-iife.js", - format: "iife", - }, - plugins: [ - resolve(), - typescript({ - sourceMap: false, - declaration: false, - declarationDir: undefined, - }), - terser(), - ], -}); - -export default config; diff --git a/plugins/shell/src/api-iife.js b/plugins/shell/src/api-iife.js deleted file mode 100644 index 1f62d77f..00000000 --- a/plugins/shell/src/api-iife.js +++ /dev/null @@ -1 +0,0 @@ -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__})} diff --git a/plugins/shell/src/commands.rs b/plugins/shell/src/commands.rs index fd1e5058..5275e9b9 100644 --- a/plugins/shell/src/commands.rs +++ b/plugins/shell/src/commands.rs @@ -2,14 +2,18 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use std::{collections::HashMap, path::PathBuf, string::FromUtf8Error}; +use std::{collections::HashMap, future::Future, path::PathBuf, pin::Pin, string::FromUtf8Error}; use encoding_rs::Encoding; use serde::{Deserialize, Serialize}; -use tauri::{ipc::Channel, Manager, Runtime, State, Window}; +use tauri::{ + ipc::{Channel, CommandScope, GlobalScope}, + Manager, Runtime, State, Window, +}; +#[allow(deprecated)] +use crate::open::Program; use crate::{ - open::Program, process::{CommandEvent, TerminatedPayload}, scope::ExecuteArgs, Shell, @@ -20,7 +24,7 @@ type ChildId = u32; #[derive(Debug, Clone, Serialize)] #[serde(tag = "event", content = "payload")] #[non_exhaustive] -enum JSCommandEvent { +pub enum JSCommandEvent { /// Stderr bytes until a newline (\n) or carriage return (\r) is found. Stderr(Buffer), /// Stdout bytes until a newline (\n) or carriage return (\r) is found. @@ -91,22 +95,29 @@ fn default_env() -> Option> { Some(HashMap::default()) } -#[tauri::command] -pub fn execute( +#[inline(always)] +fn prepare_cmd( window: Window, - shell: State<'_, Shell>, program: String, args: ExecuteArgs, - on_event: Channel, options: CommandOptions, -) -> crate::Result { + command_scope: CommandScope, + global_scope: GlobalScope, +) -> crate::Result<(crate::process::Command, EncodingWrapper)> { + let scope = crate::scope::ShellScope { + scopes: command_scope + .allows() + .iter() + .chain(global_scope.allows()) + .collect(), + }; + let mut command = if options.sidecar { let program = PathBuf::from(program); let program_as_string = program.display().to_string(); let program_no_ext_as_string = program.with_extension("").display().to_string(); let configured_sidecar = window .config() - .tauri .bundle .external_bin .as_ref() @@ -116,14 +127,12 @@ pub fn execute( }) .cloned(); if let Some(sidecar) = configured_sidecar { - shell - .scope - .prepare_sidecar(&program.to_string_lossy(), &sidecar, args)? + scope.prepare_sidecar(&program.to_string_lossy(), &sidecar, args)? } else { return Err(crate::Error::SidecarNotAllowed(program)); } } else { - match shell.scope.prepare(&program, args) { + match scope.prepare(&program, args) { Ok(cmd) => cmd, Err(e) => { #[cfg(debug_assertions)] @@ -140,10 +149,14 @@ pub fn execute( } else { command = command.env_clear(); } + let encoding = match options.encoding { Option::None => EncodingWrapper::Text(None), Some(encoding) => match encoding.as_str() { - "raw" => EncodingWrapper::Raw, + "raw" => { + command = command.set_raw_out(true); + EncodingWrapper::Raw + } _ => { if let Some(text_encoding) = Encoding::for_label(encoding.as_bytes()) { EncodingWrapper::Text(Some(text_encoding)) @@ -154,6 +167,81 @@ pub fn execute( }, }; + Ok((command, encoding)) +} + +#[derive(Serialize)] +#[serde(untagged)] +enum Output { + String(String), + Raw(Vec), +} + +#[derive(Serialize)] +pub struct ChildProcessReturn { + code: Option, + signal: Option, + stdout: Output, + stderr: Output, +} + +#[allow(clippy::too_many_arguments)] +#[tauri::command] +pub async fn execute( + window: Window, + program: String, + args: ExecuteArgs, + options: CommandOptions, + command_scope: CommandScope, + global_scope: GlobalScope, +) -> crate::Result { + let (command, encoding) = + prepare_cmd(window, program, args, options, command_scope, global_scope)?; + + let mut command: std::process::Command = command.into(); + let output = command.output()?; + + let (stdout, stderr) = match encoding { + EncodingWrapper::Text(Some(encoding)) => ( + Output::String(encoding.decode_with_bom_removal(&output.stdout).0.into()), + Output::String(encoding.decode_with_bom_removal(&output.stderr).0.into()), + ), + EncodingWrapper::Text(None) => ( + Output::String(String::from_utf8(output.stdout)?), + Output::String(String::from_utf8(output.stderr)?), + ), + EncodingWrapper::Raw => (Output::Raw(output.stdout), Output::Raw(output.stderr)), + }; + + #[cfg(unix)] + use std::os::unix::process::ExitStatusExt; + + Ok(ChildProcessReturn { + code: output.status.code(), + #[cfg(windows)] + signal: None, + #[cfg(unix)] + signal: output.status.signal(), + stdout, + stderr, + }) +} + +#[allow(clippy::too_many_arguments)] +#[tauri::command] +pub fn spawn( + window: Window, + shell: State<'_, Shell>, + program: String, + args: ExecuteArgs, + on_event: Channel, + options: CommandOptions, + command_scope: CommandScope, + global_scope: GlobalScope, +) -> crate::Result { + let (command, encoding) = + prepare_cmd(window, program, args, options, command_scope, global_scope)?; + let (mut rx, child) = command.spawn()?; let pid = child.pid(); @@ -166,7 +254,21 @@ pub fn execute( children.lock().unwrap().remove(&pid); }; let js_event = JSCommandEvent::new(event, encoding); - let _ = on_event.send(&js_event); + + if on_event.send(js_event.clone()).is_err() { + fn send<'a>( + on_event: &'a Channel, + js_event: &'a JSCommandEvent, + ) -> Pin + Send + 'a>> { + Box::pin(async move { + tokio::time::sleep(std::time::Duration::from_millis(15)).await; + if on_event.send(js_event.clone()).is_err() { + send(on_event, js_event).await; + } + }) + } + send(&on_event, &js_event).await; + } } }); @@ -201,12 +303,13 @@ pub fn kill( Ok(()) } +#[allow(deprecated)] #[tauri::command] -pub fn open( +pub async fn open( _window: Window, shell: State<'_, Shell>, path: String, with: Option, ) -> crate::Result<()> { - shell.open(path, with) + crate::open::open(Some(&shell.open_scope), path, with) } diff --git a/plugins/shell/src/config.rs b/plugins/shell/src/config.rs index 5dd32862..69a92ee1 100644 --- a/plugins/shell/src/config.rs +++ b/plugins/shell/src/config.rs @@ -2,135 +2,25 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use std::path::PathBuf; - -use serde::{de::Error as DeError, Deserialize, Deserializer}; +use serde::Deserialize; /// Configuration for the shell plugin. #[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize)] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct Config { - /// Access scope for the binary execution APIs. - /// Sidecars are automatically enabled. - #[serde(default)] - pub scope: ShellAllowlistScope, /// Open URL with the user's default application. #[serde(default)] pub open: ShellAllowlistOpen, } -/// A command allowed to be executed by the webview API. -#[derive(Debug, PartialEq, Eq, Clone)] -pub struct ShellAllowedCommand { - /// The name for this allowed shell command configuration. - /// - /// This name will be used inside of the webview API to call this command along with - /// any specified arguments. - pub name: String, - - /// The command name. - /// It can start with a variable that resolves to a system base directory. - /// The variables are: `$AUDIO`, `$CACHE`, `$CONFIG`, `$DATA`, `$LOCALDATA`, `$DESKTOP`, - /// `$DOCUMENT`, `$DOWNLOAD`, `$EXE`, `$FONT`, `$HOME`, `$PICTURE`, `$PUBLIC`, `$RUNTIME`, - /// `$TEMPLATE`, `$VIDEO`, `$RESOURCE`, `$APP`, `$LOG`, `$TEMP`, `$APPCONFIG`, `$APPDATA`, - /// `$APPLOCALDATA`, `$APPCACHE`, `$APPLOG`. - // use default just so the schema doesn't flag it as required - pub command: PathBuf, - - /// The allowed arguments for the command execution. - pub args: ShellAllowedArgs, - - /// If this command is a sidecar command. - pub sidecar: bool, -} - -impl<'de> Deserialize<'de> for ShellAllowedCommand { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - #[derive(Deserialize)] - struct InnerShellAllowedCommand { - name: String, - #[serde(rename = "cmd")] - command: Option, - #[serde(default)] - args: ShellAllowedArgs, - #[serde(default)] - sidecar: bool, - } - - let config = InnerShellAllowedCommand::deserialize(deserializer)?; - - if !config.sidecar && config.command.is_none() { - return Err(DeError::custom( - "The shell scope `command` value is required.", - )); - } - - Ok(ShellAllowedCommand { - name: config.name, - command: config.command.unwrap_or_default(), - args: config.args, - sidecar: config.sidecar, - }) - } -} - -/// A set of command arguments allowed to be executed by the webview API. -/// -/// A value of `true` will allow any arguments to be passed to the command. `false` will disable all -/// arguments. A list of [`ShellAllowedArg`] will set those arguments as the only valid arguments to -/// be passed to the attached command configuration. -#[derive(Debug, PartialEq, Eq, Clone, Deserialize)] -#[serde(untagged, deny_unknown_fields)] -#[non_exhaustive] -pub enum ShellAllowedArgs { - /// Use a simple boolean to allow all or disable all arguments to this command configuration. - Flag(bool), - - /// A specific set of [`ShellAllowedArg`] that are valid to call for the command configuration. - List(Vec), -} - -impl Default for ShellAllowedArgs { - fn default() -> Self { - Self::Flag(false) - } -} - -/// A command argument allowed to be executed by the webview API. -#[derive(Debug, PartialEq, Eq, Clone, Deserialize)] -#[serde(untagged, deny_unknown_fields)] -#[non_exhaustive] -pub enum ShellAllowedArg { - /// A non-configurable argument that is passed to the command in the order it was specified. - Fixed(String), - - /// A variable that is set while calling the command from the webview API. - /// - Var { - /// [regex] validator to require passed values to conform to an expected input. - /// - /// This will require the argument value passed to this variable to match the `validator` regex - /// before it will be executed. - /// - /// [regex]: https://docs.rs/regex/latest/regex/#syntax - validator: String, - }, -} - -/// Shell scope definition. -/// It is a list of command names and associated CLI arguments that restrict the API access from the webview. -#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize)] - -pub struct ShellAllowlistScope(pub Vec); - /// Defines the `shell > open` api scope. #[derive(Debug, PartialEq, Eq, Clone, Deserialize)] #[serde(untagged, deny_unknown_fields)] #[non_exhaustive] pub enum ShellAllowlistOpen { + /// Shell open API allowlist is not defined by the user. + /// In this case we add the default validation regex (same as [`Self::Flag(true)`]). + Unset, /// If the shell open API should be enabled. /// /// If enabled, the default validation regex (`^((mailto:\w+)|(tel:\w+)|(https?://\w+)).+`) is used. @@ -138,6 +28,9 @@ pub enum ShellAllowlistOpen { /// Enable the shell open API, with a custom regex that the opened path must match against. /// + /// The regex string is automatically surrounded by `^...$` to match the full string. + /// For example the `https?://\w+` regex would be registered as `^https?://\w+$`. + /// /// If using a custom regex to support a non-http(s) schema, care should be used to prevent values /// that allow flag-like strings to pass validation. e.g. `--enable-debugging`, `-i`, `/R`. Validate(String), @@ -145,6 +38,6 @@ pub enum ShellAllowlistOpen { impl Default for ShellAllowlistOpen { fn default() -> Self { - Self::Flag(false) + Self::Unset } } diff --git a/plugins/shell/src/error.rs b/plugins/shell/src/error.rs index 0a673e8a..652421b8 100644 --- a/plugins/shell/src/error.rs +++ b/plugins/shell/src/error.rs @@ -8,6 +8,9 @@ use serde::{Serialize, Serializer}; #[derive(Debug, thiserror::Error)] pub enum Error { + #[cfg(mobile)] + #[error(transparent)] + PluginInvoke(#[from] tauri::plugin::mobile::PluginInvokeError), #[error(transparent)] Io(#[from] std::io::Error), #[error("current executable path has no parent")] @@ -17,13 +20,19 @@ pub enum Error { #[error(transparent)] Scope(#[from] crate::scope::Error), /// Sidecar not allowed by the configuration. - #[error("sidecar not configured under `tauri.conf.json > tauri > bundle > externalBin`: {0}")] + #[error("sidecar not configured under `tauri.conf.json > bundle > externalBin`: {0}")] SidecarNotAllowed(PathBuf), /// Program not allowed by the scope. #[error("program not allowed on the configured shell scope: {0}")] ProgramNotAllowed(PathBuf), #[error("unknown encoding {0}")] UnknownEncoding(String), + /// JSON error. + #[error(transparent)] + Json(#[from] serde_json::Error), + /// Utf8 error. + #[error(transparent)] + Utf8(#[from] std::string::FromUtf8Error), } impl Serialize for Error { diff --git a/plugins/shell/src/init-iife.js b/plugins/shell/src/init-iife.js index 6c32a6c7..3c91c81c 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(){document.querySelector("body")?.addEventListener("click",(function(t){let n=t.target;for(;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/lib.rs b/plugins/shell/src/lib.rs index 36d022aa..c9503731 100644 --- a/plugins/shell/src/lib.rs +++ b/plugins/shell/src/lib.rs @@ -2,8 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -//! [![](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/shell/banner.png)](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/shell) -//! //! Access the system shell. Allows you to spawn child processes and manage files and URLs using their default application. #![doc( @@ -20,7 +18,6 @@ use std::{ use process::{Command, CommandChild}; use regex::Regex; -use scope::{Scope, ScopeAllowedCommand, ScopeConfig}; use tauri::{ plugin::{Builder, TauriPlugin}, AppHandle, Manager, RunEvent, Runtime, @@ -29,19 +26,31 @@ use tauri::{ mod commands; mod config; mod error; -mod open; +#[deprecated(since = "2.1.0", note = "Use tauri-plugin-opener instead.")] +#[allow(deprecated)] +pub mod open; pub mod process; mod scope; +mod scope_entry; -use config::{Config, ShellAllowedArg, ShellAllowedArgs, ShellAllowlistOpen, ShellAllowlistScope}; pub use error::Error; type Result = std::result::Result; + +#[cfg(mobile)] +use tauri::plugin::PluginHandle; +#[cfg(target_os = "android")] +const PLUGIN_IDENTIFIER: &str = "app.tauri.shell"; +#[cfg(target_os = "ios")] +tauri::ios_plugin_binding!(init_plugin_shell); + type ChildStore = Arc>>; pub struct Shell { #[allow(dead_code)] app: AppHandle, - scope: Scope, + #[cfg(mobile)] + mobile_plugin_handle: PluginHandle, + open_scope: scope::OpenScope, children: ChildStore, } @@ -61,9 +70,23 @@ impl Shell { /// Open a (url) path with a default or specific browser opening program. /// - /// See [`crate::api::shell::open`] for how it handles security-related measures. + /// See [`crate::open::open`] for how it handles security-related measures. + #[cfg(desktop)] + #[deprecated(since = "2.1.0", note = "Use tauri-plugin-opener instead.")] + #[allow(deprecated)] pub fn open(&self, path: impl Into, with: Option) -> Result<()> { - open::open(&self.scope, path.into(), with).map_err(Into::into) + open::open(None, path.into(), with) + } + + /// Open a (url) path with a default or specific browser opening program. + /// + /// See [`crate::open::open`] for how it handles security-related measures. + #[cfg(mobile)] + #[deprecated(since = "2.1.0", note = "Use tauri-plugin-opener instead.")] + pub fn open(&self, path: impl Into, _with: Option) -> Result<()> { + self.mobile_plugin_handle + .run_mobile_plugin("open", path.into()) + .map_err(Into::into) } } @@ -77,25 +100,32 @@ impl> ShellExt for T { } } -pub fn init() -> TauriPlugin> { - let mut init_script = include_str!("init-iife.js").to_string(); - init_script.push_str(include_str!("api-iife.js")); - - Builder::>::new("shell") - .js_init_script(init_script) +pub fn init() -> TauriPlugin> { + Builder::>::new("shell") + .js_init_script(include_str!("init-iife.js").to_string()) .invoke_handler(tauri::generate_handler![ commands::execute, + commands::spawn, commands::stdin_write, commands::kill, commands::open ]) .setup(|app, api| { - let default_config = Config::default(); + let default_config = config::Config::default(); let config = api.config().as_ref().unwrap_or(&default_config); + + #[cfg(target_os = "android")] + let handle = api.register_android_plugin(PLUGIN_IDENTIFIER, "ShellPlugin")?; + #[cfg(target_os = "ios")] + let handle = api.register_ios_plugin(init_plugin_shell)?; + app.manage(Shell { app: app.clone(), children: Default::default(), - scope: Scope::new(app, shell_scope(config.scope.clone(), &config.open)), + open_scope: open_scope(&config.open), + + #[cfg(mobile)] + mobile_plugin_handle: handle, }); Ok(()) }) @@ -114,56 +144,22 @@ pub fn init() -> TauriPlugin> { .build() } -fn shell_scope(scope: ShellAllowlistScope, open: &ShellAllowlistOpen) -> ScopeConfig { - let shell_scopes = get_allowed_clis(scope); - +fn open_scope(open: &config::ShellAllowlistOpen) -> scope::OpenScope { let shell_scope_open = match open { - ShellAllowlistOpen::Flag(false) => None, - ShellAllowlistOpen::Flag(true) => { + config::ShellAllowlistOpen::Flag(false) => None, + // we want to add a basic regex validation even if the config is not set + config::ShellAllowlistOpen::Unset | config::ShellAllowlistOpen::Flag(true) => { Some(Regex::new(r"^((mailto:\w+)|(tel:\w+)|(https?://\w+)).+").unwrap()) } - ShellAllowlistOpen::Validate(validator) => { + config::ShellAllowlistOpen::Validate(validator) => { + let regex = format!("^{validator}$"); let validator = - Regex::new(validator).unwrap_or_else(|e| panic!("invalid regex {validator}: {e}")); + Regex::new(®ex).unwrap_or_else(|e| panic!("invalid regex {regex}: {e}")); Some(validator) } }; - ScopeConfig { + scope::OpenScope { open: shell_scope_open, - scopes: shell_scopes, } } - -fn get_allowed_clis(scope: ShellAllowlistScope) -> HashMap { - scope - .0 - .into_iter() - .map(|scope| { - let args = match scope.args { - ShellAllowedArgs::Flag(true) => None, - ShellAllowedArgs::Flag(false) => Some(Vec::new()), - ShellAllowedArgs::List(list) => { - let list = list.into_iter().map(|arg| match arg { - ShellAllowedArg::Fixed(fixed) => scope::ScopeAllowedArg::Fixed(fixed), - ShellAllowedArg::Var { validator } => { - let validator = Regex::new(&validator) - .unwrap_or_else(|e| panic!("invalid regex {validator}: {e}")); - scope::ScopeAllowedArg::Var { validator } - } - }); - Some(list.collect()) - } - }; - - ( - scope.name, - ScopeAllowedCommand { - command: scope.command, - args, - sidecar: scope.sidecar, - }, - ) - }) - .collect() -} diff --git a/plugins/shell/src/open.rs b/plugins/shell/src/open.rs index a46d3f14..6958a832 100644 --- a/plugins/shell/src/open.rs +++ b/plugins/shell/src/open.rs @@ -6,10 +6,11 @@ use serde::{Deserialize, Deserializer}; -use crate::scope::Scope; +use crate::scope::OpenScope; use std::str::FromStr; /// Program to use on the [`open()`] call. +#[deprecated(since = "2.1.0", note = "Use tauri-plugin-opener instead.")] pub enum Program { /// Use the `open` program. Open, @@ -117,6 +118,21 @@ impl Program { /// Ok(()) /// }); /// ``` -pub fn open>(scope: &Scope, path: P, with: Option) -> crate::Result<()> { - scope.open(path.as_ref(), with).map_err(Into::into) +#[deprecated(since = "2.1.0", note = "Use tauri-plugin-opener instead.")] +pub fn open>( + scope: Option<&OpenScope>, + path: P, + with: Option, +) -> crate::Result<()> { + // validate scope if we have any (JS calls) + if let Some(scope) = scope { + scope.open(path.as_ref(), with).map_err(Into::into) + } else { + // when running directly from Rust code we don't need to validate the path + match with.map(Program::name) { + Some(program) => ::open::with_detached(path.as_ref(), program), + None => ::open::that_detached(path.as_ref()), + } + .map_err(Into::into) + } } diff --git a/plugins/shell/src/process/mod.rs b/plugins/shell/src/process/mod.rs index 8065de40..44f037b0 100644 --- a/plugins/shell/src/process/mod.rs +++ b/plugins/shell/src/process/mod.rs @@ -4,7 +4,7 @@ use std::{ ffi::OsStr, - io::{BufReader, Write}, + io::{BufRead, BufReader, Write}, path::{Path, PathBuf}, process::{Command as StdCommand, Stdio}, sync::{Arc, RwLock}, @@ -41,11 +41,13 @@ pub struct TerminatedPayload { #[derive(Debug, Clone)] #[non_exhaustive] pub enum CommandEvent { - /// Stderr bytes until a newline (\n) or carriage return (\r) is found. + /// If configured for raw output, all bytes written to stderr. + /// Otherwise, bytes until a newline (\n) or carriage return (\r) is found. Stderr(Vec), - /// Stdout bytes until a newline (\n) or carriage return (\r) is found. + /// If configured for raw output, all bytes written to stdout. + /// Otherwise, bytes until a newline (\n) or carriage return (\r) is found. Stdout(Vec), - /// An error happened waiting for the command to finish or converting the stdout/stderr bytes to an UTF-8 string. + /// An error happened waiting for the command to finish or converting the stdout/stderr bytes to a UTF-8 string. Error(String), /// Command process terminated. Terminated(TerminatedPayload), @@ -53,7 +55,10 @@ pub enum CommandEvent { /// The type to spawn commands. #[derive(Debug)] -pub struct Command(StdCommand); +pub struct Command { + cmd: StdCommand, + raw_out: bool, +} /// Spawned child process. #[derive(Debug)] @@ -122,7 +127,7 @@ fn relative_command_path(command: &Path) -> crate::Result { impl From for StdCommand { fn from(cmd: Command) -> StdCommand { - cmd.0 + cmd.cmd } } @@ -136,7 +141,10 @@ impl Command { #[cfg(windows)] command.creation_flags(CREATE_NO_WINDOW); - Self(command) + Self { + cmd: command, + raw_out: false, + } } pub(crate) fn new_sidecar>(program: S) -> crate::Result { @@ -146,7 +154,7 @@ impl Command { /// Appends an argument to the command. #[must_use] pub fn arg>(mut self, arg: S) -> Self { - self.0.arg(arg); + self.cmd.arg(arg); self } @@ -157,14 +165,14 @@ impl Command { I: IntoIterator, S: AsRef, { - self.0.args(args); + self.cmd.args(args); self } /// Clears the entire environment map for the child process. #[must_use] pub fn env_clear(mut self) -> Self { - self.0.env_clear(); + self.cmd.env_clear(); self } @@ -175,7 +183,7 @@ impl Command { K: AsRef, V: AsRef, { - self.0.env(key, value); + self.cmd.env(key, value); self } @@ -187,14 +195,20 @@ impl Command { K: AsRef, V: AsRef, { - self.0.envs(envs); + self.cmd.envs(envs); self } /// Sets the working directory for the child process. #[must_use] pub fn current_dir>(mut self, current_dir: P) -> Self { - self.0.current_dir(current_dir); + self.cmd.current_dir(current_dir); + self + } + + /// Configures the reader to output bytes from the child process exactly as received + pub fn set_raw_out(mut self, raw_out: bool) -> Self { + self.raw_out = raw_out; self } @@ -229,6 +243,7 @@ impl Command { /// }); /// ``` pub fn spawn(self) -> crate::Result<(Receiver, CommandChild)> { + let raw = self.raw_out; let mut command: StdCommand = self.into(); let (stdout_reader, stdout_writer) = pipe()?; let (stderr_reader, stderr_writer) = pipe()?; @@ -249,12 +264,14 @@ impl Command { guard.clone(), stdout_reader, CommandEvent::Stdout, + raw, ); spawn_pipe_reader( tx.clone(), guard.clone(), stderr_reader, CommandEvent::Stderr, + raw, ); spawn(move || { @@ -359,34 +376,74 @@ impl Command { } } +fn read_raw_bytes) -> CommandEvent + Send + Copy + 'static>( + mut reader: BufReader, + tx: Sender, + wrapper: F, +) { + loop { + let result = reader.fill_buf(); + match result { + Ok(buf) => { + let length = buf.len(); + if length == 0 { + break; + } + let tx_ = tx.clone(); + let _ = block_on_task(async move { tx_.send(wrapper(buf.to_vec())).await }); + reader.consume(length); + } + Err(e) => { + let tx_ = tx.clone(); + let _ = block_on_task( + async move { tx_.send(CommandEvent::Error(e.to_string())).await }, + ); + } + } + } +} + +fn read_line) -> CommandEvent + Send + Copy + 'static>( + mut reader: BufReader, + tx: Sender, + wrapper: F, +) { + loop { + let mut buf = Vec::new(); + match tauri::utils::io::read_line(&mut reader, &mut buf) { + Ok(n) => { + if n == 0 { + break; + } + let tx_ = tx.clone(); + let _ = block_on_task(async move { tx_.send(wrapper(buf)).await }); + } + Err(e) => { + let tx_ = tx.clone(); + let _ = block_on_task( + async move { tx_.send(CommandEvent::Error(e.to_string())).await }, + ); + break; + } + } + } +} + fn spawn_pipe_reader) -> CommandEvent + Send + Copy + 'static>( tx: Sender, guard: Arc>, pipe_reader: PipeReader, wrapper: F, + raw_out: bool, ) { spawn(move || { let _lock = guard.read().unwrap(); - let mut reader = BufReader::new(pipe_reader); - - loop { - let mut buf = Vec::new(); - match tauri::utils::io::read_line(&mut reader, &mut buf) { - Ok(n) => { - if n == 0 { - break; - } - let tx_ = tx.clone(); - let _ = block_on_task(async move { tx_.send(wrapper(buf)).await }); - } - Err(e) => { - let tx_ = tx.clone(); - let _ = - block_on_task( - async move { tx_.send(CommandEvent::Error(e.to_string())).await }, - ); - } - } + let reader = BufReader::new(pipe_reader); + + if raw_out { + read_raw_bytes(reader, tx, wrapper); + } else { + read_line(reader, tx, wrapper); } }); } @@ -455,7 +512,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 +537,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 +568,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/shell/src/scope.rs b/plugins/shell/src/scope.rs index c184e922..35fdeaff 100644 --- a/plugins/shell/src/scope.rs +++ b/plugins/shell/src/scope.rs @@ -2,13 +2,15 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT +use std::sync::Arc; + +#[allow(deprecated)] use crate::open::Program; use crate::process::Command; -use crate::{Manager, Runtime}; use regex::Regex; - -use std::collections::HashMap; +use tauri::ipc::ScopeObject; +use tauri::Manager; /// Allowed representation of `Execute` command arguments. #[derive(Debug, Clone, serde::Deserialize)] @@ -55,19 +57,12 @@ impl From> for ExecuteArgs { } } -/// Shell scope configuration. -#[derive(Debug, Clone)] -pub struct ScopeConfig { - /// The validation regex that `shell > open` paths must match against. - pub open: Option, - - /// All allowed commands, using their unique command name as the keys. - pub scopes: HashMap, -} - /// A configured scoped shell command. #[derive(Debug, Clone)] pub struct ScopeAllowedCommand { + /// Name of the command (key). + pub name: String, + /// The shell command to be called. pub command: std::path::PathBuf, @@ -78,6 +73,52 @@ pub struct ScopeAllowedCommand { pub sidecar: bool, } +impl ScopeObject for ScopeAllowedCommand { + type Error = crate::Error; + fn deserialize( + app: &tauri::AppHandle, + raw: tauri::utils::acl::Value, + ) -> Result { + let scope = serde_json::from_value::(raw.into())?; + + let args = match scope.args.clone() { + crate::scope_entry::ShellAllowedArgs::Flag(true) => None, + crate::scope_entry::ShellAllowedArgs::Flag(false) => Some(Vec::new()), + crate::scope_entry::ShellAllowedArgs::List(list) => { + let list = list.into_iter().map(|arg| match arg { + crate::scope_entry::ShellAllowedArg::Fixed(fixed) => { + crate::scope::ScopeAllowedArg::Fixed(fixed) + } + crate::scope_entry::ShellAllowedArg::Var { validator, raw } => { + let regex = if raw { + validator + } else { + format!("^{validator}$") + }; + let validator = Regex::new(®ex) + .unwrap_or_else(|e| panic!("invalid regex {regex}: {e}")); + crate::scope::ScopeAllowedArg::Var { validator } + } + }); + Some(list.collect()) + } + }; + + let command = if let Ok(path) = app.path().parse(&scope.command) { + path + } else { + scope.command.clone() + }; + + Ok(Self { + name: scope.name, + command, + args, + sidecar: scope.sidecar, + }) + } +} + /// A configured argument to a scoped shell command. #[derive(Debug, Clone)] pub enum ScopeAllowedArg { @@ -98,9 +139,19 @@ impl ScopeAllowedArg { } } -/// Scope for filesystem access. +/// Scope for the open command +pub struct OpenScope { + /// The validation regex that `shell > open` paths must match against. + /// When set to `None`, no values are accepted. + pub open: Option, +} + +/// Scope for shell process spawning. #[derive(Clone)] -pub struct Scope(ScopeConfig); +pub struct ShellScope<'a> { + /// All allowed commands, using their unique command name as the keys. + pub scopes: Vec<&'a Arc>, +} /// All errors that can happen while validating a scoped command. #[derive(Debug, thiserror::Error)] @@ -147,17 +198,40 @@ pub enum Error { Io(#[from] std::io::Error), } -impl Scope { - /// Creates a new shell scope. - pub(crate) fn new>(manager: &M, mut scope: ScopeConfig) -> Self { - for cmd in scope.scopes.values_mut() { - if let Ok(path) = manager.path().parse(&cmd.command) { - cmd.command = path; +impl OpenScope { + /// Open a path in the default (or specified) browser. + /// + /// The path is validated against the `plugins > shell > open` validation regex, which + /// defaults to `^((mailto:\w+)|(tel:\w+)|(https?://\w+)).+`. + #[allow(deprecated)] + pub fn open(&self, path: &str, with: Option) -> Result<(), Error> { + // ensure we pass validation if the configuration has one + if let Some(regex) = &self.open { + if !regex.is_match(path) { + return Err(Error::Validation { + index: 0, + validation: regex.as_str().into(), + }); } + } else { + log::warn!("open() command called but the plugin configuration denies calls from JavaScript; set `tauri.conf.json > plugins > shell > open` to true or a validation regex string"); + return Err(Error::Validation { + index: 0, + validation: "tauri^".to_string(), // purposefully impossible regex + }); + } + + // The prevention of argument escaping is handled by the usage of std::process::Command::arg by + // the `open` dependency. This behavior should be re-confirmed during upgrades of `open`. + match with.map(Program::name) { + Some(program) => ::open::with_detached(path, program), + None => ::open::that_detached(path), } - Self(scope) + .map_err(Into::into) } +} +impl ShellScope<'_> { /// Validates argument inputs and creates a Tauri sidecar [`Command`]. pub fn prepare_sidecar( &self, @@ -180,7 +254,7 @@ impl Scope { args: ExecuteArgs, sidecar: Option<&str>, ) -> Result { - let command = match self.0.scopes.get(command_name) { + let command = match self.scopes.iter().find(|s| s.name == command_name) { Some(command) => command, None => return Err(Error::NotFound(command_name.into())), }; @@ -230,7 +304,7 @@ impl Scope { .map(|s| { std::path::PathBuf::from(s) .components() - .last() + .next_back() .unwrap() .as_os_str() .to_string_lossy() @@ -245,28 +319,4 @@ impl Scope { Ok(command.args(args)) } - - /// Open a path in the default (or specified) browser. - /// - /// The path is validated against the `plugins > shell > open` validation regex, which - /// defaults to `^((mailto:\w+)|(tel:\w+)|(https?://\w+)).+`. - pub fn open(&self, path: &str, with: Option) -> Result<(), Error> { - // ensure we pass validation if the configuration has one - if let Some(regex) = &self.0.open { - if !regex.is_match(path) { - return Err(Error::Validation { - index: 0, - validation: regex.as_str().into(), - }); - } - } - - // The prevention of argument escaping is handled by the usage of std::process::Command::arg by - // the `open` dependency. This behavior should be re-confirmed during upgrades of `open`. - match with.map(Program::name) { - Some(program) => ::open::with_detached(path, program), - None => ::open::that_detached(path), - } - .map_err(Into::into) - } } diff --git a/plugins/shell/src/scope_entry.rs b/plugins/shell/src/scope_entry.rs new file mode 100644 index 00000000..59839178 --- /dev/null +++ b/plugins/shell/src/scope_entry.rs @@ -0,0 +1,75 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use serde::{de::Error as DeError, Deserialize, Deserializer}; + +use std::path::PathBuf; + +/// A command allowed to be executed by the webview API. +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub(crate) struct Entry { + pub(crate) name: String, + pub(crate) command: PathBuf, + pub(crate) args: ShellAllowedArgs, + pub(crate) sidecar: bool, +} + +#[derive(Deserialize)] +pub(crate) struct EntryRaw { + pub(crate) name: String, + #[serde(rename = "cmd")] + pub(crate) command: Option, + #[serde(default)] + pub(crate) args: ShellAllowedArgs, + #[serde(default)] + pub(crate) sidecar: bool, +} + +impl<'de> Deserialize<'de> for Entry { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let config = EntryRaw::deserialize(deserializer)?; + + if !config.sidecar && config.command.is_none() { + return Err(DeError::custom( + "The shell scope `command` value is required.", + )); + } + + Ok(Entry { + name: config.name, + command: config.command.unwrap_or_default(), + args: config.args, + sidecar: config.sidecar, + }) + } +} + +#[derive(Debug, PartialEq, Eq, Clone, Hash, Deserialize)] +#[serde(untagged, deny_unknown_fields)] +#[non_exhaustive] +pub enum ShellAllowedArgs { + Flag(bool), + List(Vec), +} + +impl Default for ShellAllowedArgs { + fn default() -> Self { + Self::Flag(false) + } +} + +#[derive(Debug, PartialEq, Eq, Clone, Hash, Deserialize)] +#[serde(untagged, deny_unknown_fields)] +#[non_exhaustive] +pub enum ShellAllowedArg { + Fixed(String), + Var { + validator: String, + #[serde(default)] + raw: bool, + }, +} diff --git a/plugins/single-instance/CHANGELOG.md b/plugins/single-instance/CHANGELOG.md index c7a91c82..5c14f4a3 100644 --- a/plugins/single-instance/CHANGELOG.md +++ b/plugins/single-instance/CHANGELOG.md @@ -1,5 +1,166 @@ # Changelog +## \[2.2.4] + +- [`dc84f8d8`](https://github.com/tauri-apps/plugins-workspace/commit/dc84f8d8bbaa70de3bb3185fbacb472993b996ef) ([#2609](https://github.com/tauri-apps/plugins-workspace/pull/2609) by [@Simon-Laux](https://github.com/tauri-apps/plugins-workspace/../../Simon-Laux)) fix `cwd` in single instance on macOS, which was the cwd of the first instance, instead of the second (like it is on windows and linux) + +### Dependencies + +- Upgraded to `deep-link@2.3.0` + +## \[2.2.3] + +### Dependencies + +- Upgraded to `deep-link@2.2.1` + +## \[2.2.2] + +- [`1ab5f157`](https://github.com/tauri-apps/plugins-workspace/commit/1ab5f1576333174095bc7dad4bef7a8576bb29ab) ([#2452](https://github.com/tauri-apps/plugins-workspace/pull/2452) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Fixed `null pointer dereference` panic on rust nightly on Windows. + +## \[2.2.1] + +- [`da5c59e2`](https://github.com/tauri-apps/plugins-workspace/commit/da5c59e2fe879d177e3cfd52fcacce85440423cb) ([#2271](https://github.com/tauri-apps/plugins-workspace/pull/2271) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Updated `zbus` dependency to version 5. No API changes. + +## \[2.2.0] + +- [`3a79266b`](https://github.com/tauri-apps/plugins-workspace/commit/3a79266b8cf96a55b1ae6339d725567d45a44b1d) ([#2173](https://github.com/tauri-apps/plugins-workspace/pull/2173) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Bumped all plugins to `v2.2.0`. From now, the versions for the Rust and JavaScript packages of each plugin will be in sync with each other. + +### Dependencies + +- Upgraded to `deep-link@2.1.0` + +## \[2.0.2] + +### Dependencies + +- Upgraded to `deep-link@2.0.2` + +## \[2.0.1] + +- [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. + +### Dependencies + +- Upgraded to `deep-link@2.0.1` + +## \[2.0.0] + +- [`e2c4dfb6`](https://github.com/tauri-apps/plugins-workspace/commit/e2c4dfb6af43e5dd8d9ceba232c315f5febd55c1) Update to tauri v2 stable release. + +### Dependencies + +- Upgraded to `deep-link@2.0.0` + +## \[2.0.0-rc.5] + +### Dependencies + +- Upgraded to `deep-link@2.0.0-rc.7` + +## \[2.0.0-rc.4] + +### Dependencies + +- Upgraded to `deep-link@2.0.0-rc.6` + +## \[2.0.0-rc.3] + +- [`b2269333`](https://github.com/tauri-apps/plugins-workspace/commit/b2269333e39afe32629a11763a8e25d0b12b132b) ([#1766](https://github.com/tauri-apps/plugins-workspace/pull/1766) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Put deep link integration behined a feature + +### Dependencies + +- Upgraded to `deep-link@2.0.0-rc.5` + +## \[2.0.0-rc.2] + +- [`64a6240f`](https://github.com/tauri-apps/plugins-workspace/commit/64a6240f79fcd52267c8d721b727ae695055d7ff) ([#1759](https://github.com/tauri-apps/plugins-workspace/pull/1759) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Integrate with the deep link plugin out of the box. + +### Dependencies + +- Upgraded to `deep-link@2.0.0-rc.4` + +## \[2.0.0-rc.1] + +- [`3c52f30e`](https://github.com/tauri-apps/plugins-workspace/commit/3c52f30ea4ec29c51f7021aa7871614d72e43258) ([#1665](https://github.com/tauri-apps/plugins-workspace/pull/1665) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Updated `windows-sys` crate to `0.59` +- [`e2e97db5`](https://github.com/tauri-apps/plugins-workspace/commit/e2e97db51983267f5be84d4f6f0278d58834d1f5) ([#1701](https://github.com/tauri-apps/plugins-workspace/pull/1701) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri 2.0.0-rc.8 + +## \[2.0.0-rc.0] + +- [`9887d1`](https://github.com/tauri-apps/plugins-workspace/commit/9887d14bd0e971c4c0f5c1188fc4005d3fc2e29e) Update to tauri RC. + +## \[2.0.0-beta.12] + +- [`e847cedc`](https://github.com/tauri-apps/plugins-workspace/commit/e847cedc1f46f3e7a2ad81ea579b620bc5b992d7) ([#1402](https://github.com/tauri-apps/plugins-workspace/pull/1402) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Use no default features on tauri for all plugins so that consumers can use `default-features = false` on tauri, note that this will still enable wry feature on iOS +- [`6de87966`](https://github.com/tauri-apps/plugins-workspace/commit/6de87966ecc00ad9d91c25be452f1f46bd2b7e1f) ([#1597](https://github.com/tauri-apps/plugins-workspace/pull/1597) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Update to tauri beta.25. + +## \[2.0.0-beta.11] + +- [`22a17980`](https://github.com/tauri-apps/plugins-workspace/commit/22a17980ff4f6f8c40adb1b8f4ffc6dae2fe7e30) ([#1537](https://github.com/tauri-apps/plugins-workspace/pull/1537) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri beta.24. + +## \[2.0.0-beta.10] + +- [`76daee7a`](https://github.com/tauri-apps/plugins-workspace/commit/76daee7aafece34de3092c86e531cf9eb1138989) ([#1512](https://github.com/tauri-apps/plugins-workspace/pull/1512) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Update to tauri beta.23. + +## \[2.0.0-beta.9] + +- [`9013854f`](https://github.com/tauri-apps/plugins-workspace/commit/9013854f42a49a230b9dbb9d02774765528a923f)([#1382](https://github.com/tauri-apps/plugins-workspace/pull/1382)) Update to tauri beta.22. + +## \[2.0.0-beta.8] + +- [`430bd6f4`](https://github.com/tauri-apps/plugins-workspace/commit/430bd6f4f379bee5d232ae6b098ae131db7f178a)([#1363](https://github.com/tauri-apps/plugins-workspace/pull/1363)) Update to tauri beta.20. + +## \[2.0.0-beta.7] + +- [`bd1ed590`](https://github.com/tauri-apps/plugins-workspace/commit/bd1ed5903ffcce5500310dac1e59e8c67674ef1e)([#1237](https://github.com/tauri-apps/plugins-workspace/pull/1237)) Update to tauri beta.17. + +## \[2.0.0-beta.6] + +- [`ed46dca`](https://github.com/tauri-apps/plugins-workspace/commit/ed46dca74ff3947dbbcb26a7b571c129bf925698) Added the `semver` feature flag to make the single instance mechanism only trigger for semver compatible versions. + +## \[2.0.0-beta.5] + +- [`dabac0e`](https://github.com/tauri-apps/plugins-workspace/commit/dabac0eedfd6e6d192c6c5a214e708b3c0223f6f)([#1035](https://github.com/tauri-apps/plugins-workspace/pull/1035)) Added implementation for MacOS. + +## \[2.0.0-beta.4] + +- [`a04ea2f`](https://github.com/tauri-apps/plugins-workspace/commit/a04ea2f38294d5a3987578283badc8eec87a7752)([#1071](https://github.com/tauri-apps/plugins-workspace/pull/1071)) The global API script is now only added to the binary when the `withGlobalTauri` config is true. + +## \[2.0.0-beta.3] + +- [`2397ec5`](https://github.com/tauri-apps/plugins-workspace/commit/2397ec5937e594397e533925ccd257cae30b4cd1)([#1019](https://github.com/tauri-apps/plugins-workspace/pull/1019)) Fix doesn't shutdown immediately. +- [`99bea25`](https://github.com/tauri-apps/plugins-workspace/commit/99bea2559c2c0648c2519c50a18cd124dacef57b)([#1005](https://github.com/tauri-apps/plugins-workspace/pull/1005)) Update to tauri beta.8. + +## \[2.0.0-beta.2] + +- [`6d1e621`](https://github.com/tauri-apps/plugins-workspace/commit/6d1e6218b5877ef91f589f790f7251acda9c9605)([#981](https://github.com/tauri-apps/plugins-workspace/pull/981)) Fix `zbus::blocking::connection::Builder` import. + +## \[2.0.0-beta.1] + +- [`14f381a`](https://github.com/tauri-apps/plugins-workspace/commit/14f381acf8fe690acecc676922c6f05939b95734) Update MSRV to 1.75. +- [`569defb`](https://github.com/tauri-apps/plugins-workspace/commit/569defbe9492e38938554bb7bdc1be9151456d21) Update to tauri beta.4. + +## \[2.0.0-beta.0] + +- [`d198c01`](https://github.com/tauri-apps/plugins-workspace/commit/d198c014863ee260cb0de88a14b7fc4356ef7474)([#862](https://github.com/tauri-apps/plugins-workspace/pull/862)) Update to tauri beta. +- [`d198c01`](https://github.com/tauri-apps/plugins-workspace/commit/d198c014863ee260cb0de88a14b7fc4356ef7474)([#862](https://github.com/tauri-apps/plugins-workspace/pull/862)) Add permissions. + +## \[2.0.0-alpha.6] + +- [`2cf8faa`](https://github.com/tauri-apps/plugins-workspace/commit/2cf8faa3e149af55eb86e5aba8ebfc54210ca703)([#839](https://github.com/tauri-apps/plugins-workspace/pull/839)) Update to tauri@alpha.20. + +## \[2.0.0-alpha.5] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to tauri@alpha.18. + +## \[2.0.0-alpha.4] + +- [`e438e0a`](https://github.com/tauri-apps/plugins-workspace/commit/e438e0a62d4b430a5159f05f13ecd397dd891a0d)([#676](https://github.com/tauri-apps/plugins-workspace/pull/676)) Update to tauri@alpha.17. + +## \[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 MSRV to 1.75. + ## \[2.0.0-alpha.2] - [`4e2cef9`](https://github.com/tauri-apps/plugins-workspace/commit/4e2cef9b702bbbb9cf4ee17de50791cb21f1b2a4)([#593](https://github.com/tauri-apps/plugins-workspace/pull/593)) Update to alpha.12. diff --git a/plugins/single-instance/Cargo.toml b/plugins/single-instance/Cargo.toml index aedca4f9..8d61f5a3 100644 --- a/plugins/single-instance/Cargo.toml +++ b/plugins/single-instance/Cargo.toml @@ -1,25 +1,36 @@ [package] name = "tauri-plugin-single-instance" -version = "2.0.0-alpha.2" +version = "2.2.4" description = "Ensure a single instance of your tauri app is running." authors = { workspace = true } license = { workspace = true } edition = { workspace = true } rust-version = { workspace = true } -exclude = [ "/examples" ] +repository = { workspace = true } +exclude = ["/examples"] [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] + +[package.metadata.platforms.support] +windows = { level = "full", notes = "" } +linux = { level = "full", notes = "" } +macos = { level = "full", notes = "" } +android = { level = "none", notes = "" } +ios = { level = "none", notes = "" } [dependencies] serde = { workspace = true } serde_json = { workspace = true } tauri = { workspace = true } -log = { workspace = true } +tracing = { workspace = true } thiserror = { workspace = true } +tauri-plugin-deep-link = { path = "../deep-link", version = "2.3.0", optional = true } +semver = { version = "1", optional = true } [target."cfg(target_os = \"windows\")".dependencies.windows-sys] -version = "0.48" +version = "0.59" features = [ "Win32_System_Threading", "Win32_System_DataExchange", @@ -27,8 +38,12 @@ features = [ "Win32_UI_WindowsAndMessaging", "Win32_Security", "Win32_System_LibraryLoader", - "Win32_Graphics_Gdi" + "Win32_Graphics_Gdi", ] [target."cfg(target_os = \"linux\")".dependencies] -zbus = "3" +zbus = { workspace = true } + +[features] +semver = ["dep:semver"] +deep-link = ["dep:tauri-plugin-deep-link"] diff --git a/plugins/single-instance/README.md b/plugins/single-instance/README.md index 3343eaab..711be6ae 100644 --- a/plugins/single-instance/README.md +++ b/plugins/single-instance/README.md @@ -2,9 +2,17 @@ Ensure a single instance of your tauri app is running. +| Platform | Supported | +| -------- | --------- | +| Linux | ✓ | +| Windows | ✓ | +| macOS | ✓ | +| Android | x | +| iOS | x | + ## Install -_This plugin requires a Rust version of at least **1.70**_ +_This plugin requires a Rust version of at least **1.77.2**_ There are three general methods of installation that we can recommend. @@ -18,7 +26,7 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] -tauri-plugin-single-instance = "2.0.0-alpha" +tauri-plugin-single-instance = "2.0.0" # alternatively with Git: tauri-plugin-single-instance = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -27,33 +35,50 @@ tauri-plugin-single-instance = { git = "https://github.com/tauri-apps/plugins-wo First you need to register the core plugin with Tauri: -`src-tauri/src/main.rs` +`src-tauri/src/lib.rs` ```rust use tauri::{Manager}; #[derive(Clone, serde::Serialize)] struct Payload { - args: Vec, - cwd: String, + args: Vec, + cwd: String, } fn main() { tauri::Builder::default() .plugin(tauri_plugin_single_instance::init(|app, argv, cwd| { println!("{}, {argv:?}, {cwd}", app.package_info().name); - - app.emit_all("single-instance", Payload { args: argv, cwd }).unwrap(); + app.emit("single-instance", Payload { args: argv, cwd }).unwrap(); })) .run(tauri::generate_context!()) .expect("error while running tauri application"); } ``` +Note that currently, plugins run in the order they were added in to the builder, so make sure that this plugin is registered first. + ## Contributing PRs accepted. Please make sure to read the Contributing Guide before making a pull request. +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + ## License Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. diff --git a/plugins/single-instance/SECURITY.md b/plugins/single-instance/SECURITY.md new file mode 100644 index 00000000..4f09bbac --- /dev/null +++ b/plugins/single-instance/SECURITY.md @@ -0,0 +1,23 @@ +# Security Policy + +**Do not report security vulnerabilities through public GitHub issues.** + +**Please use the [Private Vulnerability Disclosure](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) feature of GitHub.** + +Include as much of the following information: + +- Type of issue (e.g. improper input parsing, privilege escalation, etc.) +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- The distribution affected or used to help us with reproduction of the issue +- Step-by-step instructions to reproduce the issue +- Ideally a reproduction repository +- Impact of the issue, including how an attacker might exploit the issue + +We prefer to receive reports in English. + +## Contact + +Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). + +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/single-instance/examples/vanilla/.gitignore b/plugins/single-instance/examples/vanilla/.gitignore index c2658d7d..b3f41c3f 100644 --- a/plugins/single-instance/examples/vanilla/.gitignore +++ b/plugins/single-instance/examples/vanilla/.gitignore @@ -1 +1,3 @@ node_modules/ +dist/** +!dist/.gitkeep \ No newline at end of file diff --git a/plugins/deep-link/examples/app/src-tauri/gen/apple/assets/.gitkeep b/plugins/single-instance/examples/vanilla/dist/.gitkeep similarity index 100% rename from plugins/deep-link/examples/app/src-tauri/gen/apple/assets/.gitkeep rename to plugins/single-instance/examples/vanilla/dist/.gitkeep diff --git a/plugins/single-instance/examples/vanilla/package.json b/plugins/single-instance/examples/vanilla/package.json index ebeb7b92..d1d0828e 100644 --- a/plugins/single-instance/examples/vanilla/package.json +++ b/plugins/single-instance/examples/vanilla/package.json @@ -4,11 +4,11 @@ "description": "", "main": "index.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "tauri": "tauri" }, "author": "", "license": "MIT", "devDependencies": { - "@tauri-apps/cli": "2.0.0-alpha.16" + "@tauri-apps/cli": "2.5.0" } } diff --git a/plugins/single-instance/examples/vanilla/src-tauri/.gitignore b/plugins/single-instance/examples/vanilla/src-tauri/.gitignore index c1237045..949785a1 100644 --- a/plugins/single-instance/examples/vanilla/src-tauri/.gitignore +++ b/plugins/single-instance/examples/vanilla/src-tauri/.gitignore @@ -2,3 +2,5 @@ # will have compiled files and executables /target/ WixTools + +/gen/schemas diff --git a/plugins/single-instance/examples/vanilla/src-tauri/Cargo.toml b/plugins/single-instance/examples/vanilla/src-tauri/Cargo.toml index 71bc0d1f..d764081c 100644 --- a/plugins/single-instance/examples/vanilla/src-tauri/Cargo.toml +++ b/plugins/single-instance/examples/vanilla/src-tauri/Cargo.toml @@ -2,19 +2,20 @@ name = "single-instance-example" version = "0.1.0" description = "A Tauri App" -authors = [ "You" ] +authors = ["You"] repository = "" edition = "2021" -rust-version = "1.70" +rust-version = "1.77.2" [dependencies] -serde_json = { workspace = true } serde = { workspace = true } -tauri = { workspace = true } +serde_json = { workspace = true } +tauri = { workspace = true, features = ["wry", "compression"] } tauri-plugin-single-instance = { path = "../../../" } +tauri-plugin-cli = { path = "../../../../cli" } [build-dependencies] tauri-build = { workspace = true } [features] -custom-protocol = [ "tauri/custom-protocol" ] +prod = ["tauri/custom-protocol"] diff --git a/plugins/single-instance/examples/vanilla/src-tauri/build.rs b/plugins/single-instance/examples/vanilla/src-tauri/build.rs index b055ec37..5ebf8d2f 100644 --- a/plugins/single-instance/examples/vanilla/src-tauri/build.rs +++ b/plugins/single-instance/examples/vanilla/src-tauri/build.rs @@ -3,5 +3,5 @@ // SPDX-License-Identifier: MIT fn main() { - tauri_build::build() + tauri_build::build() } diff --git a/plugins/single-instance/examples/vanilla/src-tauri/rustfmt.toml b/plugins/single-instance/examples/vanilla/src-tauri/rustfmt.toml deleted file mode 100644 index 550a0985..00000000 --- a/plugins/single-instance/examples/vanilla/src-tauri/rustfmt.toml +++ /dev/null @@ -1,14 +0,0 @@ -max_width = 100 -hard_tabs = false -tab_spaces = 2 -newline_style = "Auto" -use_small_heuristics = "Default" -reorder_imports = true -reorder_modules = true -remove_nested_parens = true -edition = "2021" -merge_derives = true -use_try_shorthand = false -use_field_init_shorthand = false -force_explicit_abi = true -imports_granularity = "Crate" diff --git a/plugins/single-instance/examples/vanilla/src-tauri/src/main.rs b/plugins/single-instance/examples/vanilla/src-tauri/src/main.rs index 0b93460d..e736c4f3 100644 --- a/plugins/single-instance/examples/vanilla/src-tauri/src/main.rs +++ b/plugins/single-instance/examples/vanilla/src-tauri/src/main.rs @@ -3,15 +3,15 @@ // SPDX-License-Identifier: MIT #![cfg_attr( - all(not(debug_assertions), target_os = "windows"), - windows_subsystem = "windows" + all(not(debug_assertions), target_os = "windows"), + windows_subsystem = "windows" )] fn main() { - tauri::Builder::default() - .plugin(tauri_plugin_single_instance::init(|app, argv, cwd| { - println!("{}, {argv:?}, {cwd}", app.package_info().name); - })) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); + tauri::Builder::default() + .plugin(tauri_plugin_single_instance::init(|app, argv, cwd| { + println!("{}, {argv:?}, {cwd}", app.package_info().name); + })) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); } diff --git a/plugins/single-instance/examples/vanilla/src-tauri/tauri.conf.json b/plugins/single-instance/examples/vanilla/src-tauri/tauri.conf.json index ee356ba2..41623cc5 100644 --- a/plugins/single-instance/examples/vanilla/src-tauri/tauri.conf.json +++ b/plugins/single-instance/examples/vanilla/src-tauri/tauri.conf.json @@ -1,45 +1,11 @@ { - "package": { - "productName": "app", - "version": "0.1.0" - }, + "productName": "app", + "version": "0.1.0", + "identifier": "com.tauri.single-instance", "build": { - "distDir": "../public", - "devPath": "../public" + "frontendDist": "../public" }, - "tauri": { - "bundle": { - "active": true, - "targets": "all", - "identifier": "com.tauri.single-instance", - "icon": [ - "icons/32x32.png", - "icons/128x128.png", - "icons/128x128@2x.png", - "icons/icon.icns", - "icons/icon.ico" - ], - "resources": [], - "externalBin": [], - "copyright": "", - "category": "DeveloperTool", - "shortDescription": "", - "longDescription": "", - "deb": { - "depends": [] - }, - "macOS": { - "frameworks": [], - "exceptionDomain": "", - "signingIdentity": null, - "entitlements": null - }, - "windows": { - "certificateThumbprint": null, - "digestAlgorithm": "sha256", - "timestampUrl": "" - } - }, + "app": { "windows": [ { "title": "app", @@ -52,5 +18,28 @@ "security": { "csp": "default-src blob: data: filesystem: ws: wss: http: https: tauri: http://tauri.localhost 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'" } + }, + "bundle": { + "active": true, + "targets": "all", + "icon": [ + "icons/32x32.png", + "icons/128x128.png", + "icons/128x128@2x.png", + "icons/icon.icns", + "icons/icon.ico" + ] + }, + "plugins": { + "cli": { + "description": "Testing single-instance on MacOS", + "args": [ + { + "name": "somearg", + "index": 1, + "takesValue": true + } + ] + } } } diff --git a/plugins/single-instance/src/lib.rs b/plugins/single-instance/src/lib.rs index 715c894e..03fd1ed7 100644 --- a/plugins/single-instance/src/lib.rs +++ b/plugins/single-instance/src/lib.rs @@ -2,8 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -//! [![](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/single-instance/banner.png)](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/single-instance) -//! //! Ensure a single instance of your tauri app is running. #![doc( @@ -24,13 +22,22 @@ mod platform_impl; #[path = "platform_impl/macos.rs"] mod platform_impl; +#[cfg(feature = "semver")] +mod semver_compat; + pub(crate) type SingleInstanceCallback = dyn FnMut(&AppHandle, Vec, String) + Send + Sync + 'static; pub fn init, Vec, String) + Send + Sync + 'static>( - f: F, + mut f: F, ) -> TauriPlugin { - platform_impl::init(Box::new(f)) + platform_impl::init(Box::new(move |app, args, cwd| { + #[cfg(feature = "deep-link")] + if let Some(deep_link) = app.try_state::>() { + deep_link.handle_cli_arguments(args.iter()); + } + f(app, args, cwd) + })) } pub fn destroy>(manager: &M) { diff --git a/plugins/single-instance/src/platform_impl/linux.rs b/plugins/single-instance/src/platform_impl/linux.rs index 3ad8585f..3136074f 100644 --- a/plugins/single-instance/src/platform_impl/linux.rs +++ b/plugins/single-instance/src/platform_impl/linux.rs @@ -2,9 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -#![cfg(target_os = "linux")] - -use std::sync::Arc; +#[cfg(feature = "semver")] +use crate::semver_compat::semver_compat_string; use crate::SingleInstanceCallback; use tauri::{ @@ -12,8 +11,8 @@ use tauri::{ AppHandle, Config, Manager, RunEvent, Runtime, }; use zbus::{ - blocking::{Connection, ConnectionBuilder}, - dbus_interface, + blocking::{connection::Builder, Connection}, + interface, }; struct ConnectionHandle(Connection); @@ -23,21 +22,34 @@ struct SingleInstanceDBus { app_handle: AppHandle, } -#[dbus_interface(name = "org.SingleInstance.DBus")] +#[interface(name = "org.SingleInstance.DBus")] impl SingleInstanceDBus { fn execute_callback(&mut self, argv: Vec, cwd: String) { (self.callback)(&self.app_handle, argv, cwd); } } -fn dbus_id(config: Arc) -> String { - config.tauri.bundle.identifier.replace(['.', '-'], "_") +#[cfg(feature = "semver")] +fn dbus_id(config: &Config, version: semver::Version) -> String { + let mut id = config.identifier.replace(['.', '-'], "_"); + id.push('_'); + id.push_str(semver_compat_string(version).as_str()); + id +} + +#[cfg(not(feature = "semver"))] +fn dbus_id(config: &Config) -> String { + config.identifier.replace(['.', '-'], "_") } pub fn init(f: Box>) -> TauriPlugin { plugin::Builder::new("single-instance") .setup(|app, _api| { + #[cfg(feature = "semver")] + let id = dbus_id(app.config(), app.package_info().version.clone()); + #[cfg(not(feature = "semver"))] let id = dbus_id(app.config()); + let single_instance_dbus = SingleInstanceDBus { callback: f, app_handle: app.clone(), @@ -45,7 +57,7 @@ pub fn init(f: Box>) -> TauriPlugin { let dbus_name = format!("org.{id}.SingleInstance"); let dbus_path = format!("/org/{id}/SingleInstance"); - match ConnectionBuilder::session() + match Builder::session() .unwrap() .name(dbus_name.as_str()) .unwrap() @@ -72,7 +84,8 @@ pub fn init(f: Box>) -> TauriPlugin { ), ); } - std::process::exit(0) + app.cleanup_before_exit(); + std::process::exit(0); } _ => {} } @@ -89,7 +102,15 @@ pub fn init(f: Box>) -> TauriPlugin { pub fn destroy>(manager: &M) { if let Some(connection) = manager.try_state::() { - let dbus_name = format!("org.{}.SingleInstance", dbus_id(manager.config())); + #[cfg(feature = "semver")] + let id = dbus_id( + manager.config(), + manager.app_handle().package_info().version.clone(), + ); + #[cfg(not(feature = "semver"))] + let id = dbus_id(manager.config()); + + let dbus_name = format!("org.{id}.SingleInstance",); let _ = connection.0.release_name(dbus_name); } } diff --git a/plugins/single-instance/src/platform_impl/macos.rs b/plugins/single-instance/src/platform_impl/macos.rs index 170ff0e0..63991513 100644 --- a/plugins/single-instance/src/platform_impl/macos.rs +++ b/plugins/single-instance/src/platform_impl/macos.rs @@ -2,15 +2,132 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -#![cfg(target_os = "macos")] +use std::{ + io::{BufWriter, Error, ErrorKind, Read, Write}, + os::unix::net::{UnixListener, UnixStream}, + path::PathBuf, +}; +#[cfg(feature = "semver")] +use crate::semver_compat::semver_compat_string; use crate::SingleInstanceCallback; use tauri::{ plugin::{self, TauriPlugin}, - Manager, Runtime, + AppHandle, Config, Manager, RunEvent, Runtime, }; -pub fn init(_f: Box>) -> TauriPlugin { - plugin::Builder::new("single-instance").build() + +pub fn init(cb: Box>) -> TauriPlugin { + plugin::Builder::new("single-instance") + .setup(|app, _api| { + let socket = socket_path(app.config(), app.package_info()); + + // Notify the singleton which may or may not exist. + match notify_singleton(&socket) { + Ok(_) => { + std::process::exit(0); + } + Err(e) => { + match e.kind() { + ErrorKind::NotFound | ErrorKind::ConnectionRefused => { + // This process claims itself as singleton as likely none exists + socket_cleanup(&socket); + listen_for_other_instances(&socket, app.clone(), cb); + } + _ => { + tracing::debug!( + "single_instance failed to notify - launching normally: {}", + e + ); + } + } + } + } + Ok(()) + }) + .on_event(|app, event| { + if let RunEvent::Exit = event { + destroy(app); + } + }) + .build() +} + +pub fn destroy>(manager: &M) { + let socket = socket_path(manager.config(), manager.package_info()); + socket_cleanup(&socket); +} + +fn socket_path(config: &Config, _package_info: &tauri::PackageInfo) -> PathBuf { + let identifier = config.identifier.replace(['.', '-'].as_ref(), "_"); + + #[cfg(feature = "semver")] + let identifier = format!( + "{identifier}_{}", + semver_compat_string(_package_info.version.clone()), + ); + + // Use /tmp as socket path must be shorter than 100 chars. + PathBuf::from(format!("/tmp/{}_si.sock", identifier)) +} + +fn socket_cleanup(socket: &PathBuf) { + let _ = std::fs::remove_file(socket); } -pub fn destroy>(_manager: &M) {} +fn notify_singleton(socket: &PathBuf) -> Result<(), Error> { + let stream = UnixStream::connect(socket)?; + let mut bf = BufWriter::new(&stream); + let cwd = std::env::current_dir() + .unwrap_or_default() + .to_str() + .unwrap_or_default() + .to_string(); + bf.write_all(cwd.as_bytes())?; + bf.write_all(b"\0\0")?; + let args_joined = std::env::args().collect::>().join("\0"); + bf.write_all(args_joined.as_bytes())?; + bf.flush()?; + drop(bf); + Ok(()) +} + +fn listen_for_other_instances( + socket: &PathBuf, + app: AppHandle
, + mut cb: Box>, +) { + match UnixListener::bind(socket) { + Ok(listener) => { + tauri::async_runtime::spawn(async move { + for stream in listener.incoming() { + match stream { + Ok(mut stream) => { + let mut s = String::new(); + match stream.read_to_string(&mut s) { + Ok(_) => { + let (cwd, args) = s.split_once("\0\0").unwrap_or_default(); + let args: Vec = + args.split('\0').map(String::from).collect(); + cb(app.app_handle(), args, cwd.to_string()); + } + Err(e) => { + tracing::debug!("single_instance failed to be notified: {e}") + } + } + } + Err(err) => { + tracing::debug!("single_instance failed to be notified: {}", err); + continue; + } + } + } + }); + } + Err(err) => { + tracing::error!( + "single_instance failed to listen to other processes - launching normally: {}", + err + ); + } + } +} diff --git a/plugins/single-instance/src/platform_impl/windows.rs b/plugins/single-instance/src/platform_impl/windows.rs index 31c4f229..832d0803 100644 --- a/plugins/single-instance/src/platform_impl/windows.rs +++ b/plugins/single-instance/src/platform_impl/windows.rs @@ -2,7 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -#![cfg(target_os = "windows")] +#[cfg(feature = "semver")] +use crate::semver_compat::semver_compat_string; use crate::SingleInstanceCallback; use std::ffi::CStr; @@ -19,21 +20,47 @@ use windows_sys::Win32::{ }, UI::WindowsAndMessaging::{ self as w32wm, CreateWindowExW, DefWindowProcW, DestroyWindow, FindWindowW, - RegisterClassExW, SendMessageW, GWL_STYLE, GWL_USERDATA, WINDOW_LONG_PTR_INDEX, - WM_COPYDATA, WM_DESTROY, WNDCLASSEXW, WS_EX_LAYERED, WS_EX_NOACTIVATE, WS_EX_TOOLWINDOW, - WS_EX_TRANSPARENT, WS_OVERLAPPED, WS_POPUP, WS_VISIBLE, + RegisterClassExW, SendMessageW, CREATESTRUCTW, GWLP_USERDATA, GWL_STYLE, + WINDOW_LONG_PTR_INDEX, WM_COPYDATA, WM_CREATE, WM_DESTROY, WNDCLASSEXW, WS_EX_LAYERED, + WS_EX_NOACTIVATE, WS_EX_TOOLWINDOW, WS_EX_TRANSPARENT, WS_OVERLAPPED, WS_POPUP, WS_VISIBLE, }, }; +const WMCOPYDATA_SINGLE_INSTANCE_DATA: usize = 1542; + struct MutexHandle(isize); + struct TargetWindowHandle(isize); -const WMCOPYDATA_SINGLE_INSTANCE_DATA: usize = 1542; +struct UserData { + app: AppHandle, + callback: Box>, +} + +impl UserData { + unsafe fn from_hwnd_raw(hwnd: HWND) -> *mut Self { + GetWindowLongPtrW(hwnd, GWLP_USERDATA) as *mut Self + } -pub fn init(f: Box>) -> TauriPlugin { + unsafe fn from_hwnd<'a>(hwnd: HWND) -> &'a mut Self { + &mut *Self::from_hwnd_raw(hwnd) + } + + fn run_callback(&mut self, args: Vec, cwd: String) { + (self.callback)(&self.app, args, cwd) + } +} + +pub fn init(callback: Box>) -> TauriPlugin { plugin::Builder::new("single-instance") .setup(|app, _api| { - let id = &app.config().tauri.bundle.identifier; + #[allow(unused_mut)] + let mut id = app.config().identifier.clone(); + #[cfg(feature = "semver")] + { + id.push('_'); + id.push_str(semver_compat_string(app.package_info().version.clone()).as_str()); + } let class_name = encode_wide(format!("{id}-sic")); let window_name = encode_wide(format!("{id}-siw")); @@ -46,38 +73,37 @@ pub fn init(f: Box>) -> TauriPlugin { unsafe { let hwnd = FindWindowW(class_name.as_ptr(), window_name.as_ptr()); - if hwnd != 0 { - let data = format!( - "{}|{}\0", - std::env::current_dir() - .unwrap_or_default() - .to_str() - .unwrap_or_default(), - std::env::args().collect::>().join("|") - ); + if !hwnd.is_null() { + let cwd = std::env::current_dir().unwrap_or_default(); + let cwd = cwd.to_str().unwrap_or_default(); + + let args = std::env::args().collect::>().join("|"); + + let data = format!("{cwd}|{args}\0",); + let bytes = data.as_bytes(); let cds = COPYDATASTRUCT { dwData: WMCOPYDATA_SINGLE_INSTANCE_DATA, cbData: bytes.len() as _, lpData: bytes.as_ptr() as _, }; + SendMessageW(hwnd, WM_COPYDATA, 0, &cds as *const _ as _); - app.exit(0); + + app.cleanup_before_exit(); + std::process::exit(0); } } } else { - app.manage(MutexHandle(hmutex)); + app.manage(MutexHandle(hmutex as _)); - let hwnd = create_event_target_window::(&class_name, &window_name); - unsafe { - SetWindowLongPtrW( - hwnd, - GWL_USERDATA, - Box::into_raw(Box::new((app.clone(), f))) as _, - ) + let userdata = UserData { + app: app.clone(), + callback, }; - - app.manage(TargetWindowHandle(hwnd)); + let userdata = Box::into_raw(Box::new(userdata)); + let hwnd = create_event_target_window::(&class_name, &window_name, userdata); + app.manage(TargetWindowHandle(hwnd as _)); } Ok(()) @@ -93,12 +119,12 @@ pub fn init(f: Box>) -> TauriPlugin { pub fn destroy>(manager: &M) { if let Some(hmutex) = manager.try_state::() { unsafe { - ReleaseMutex(hmutex.0); - CloseHandle(hmutex.0); + ReleaseMutex(hmutex.0 as _); + CloseHandle(hmutex.0 as _); } } if let Some(hwnd) = manager.try_state::() { - unsafe { DestroyWindow(hwnd.0) }; + unsafe { DestroyWindow(hwnd.0 as _) }; } } @@ -108,32 +134,43 @@ unsafe extern "system" fn single_instance_window_proc( wparam: WPARAM, lparam: LPARAM, ) -> LRESULT { - let data_ptr = GetWindowLongPtrW(hwnd, GWL_USERDATA) - as *mut (AppHandle, Box>); - let (app_handle, callback) = &mut *data_ptr; - match msg { + WM_CREATE => { + let create_struct = &*(lparam as *const CREATESTRUCTW); + let userdata = create_struct.lpCreateParams as *const UserData; + SetWindowLongPtrW(hwnd, GWLP_USERDATA, userdata as _); + 0 + } + WM_COPYDATA => { let cds_ptr = lparam as *const COPYDATASTRUCT; if (*cds_ptr).dwData == WMCOPYDATA_SINGLE_INSTANCE_DATA { + let userdata = UserData::::from_hwnd(hwnd); + let data = CStr::from_ptr((*cds_ptr).lpData as _).to_string_lossy(); let mut s = data.split('|'); let cwd = s.next().unwrap(); - let args = s.into_iter().map(|s| s.to_string()).collect(); - callback(app_handle, args, cwd.to_string()); + let args = s.map(|s| s.to_string()).collect(); + + userdata.run_callback(args, cwd.to_string()); } 1 } WM_DESTROY => { - let _ = Box::from_raw(data_ptr); + let userdata = UserData::::from_hwnd_raw(hwnd); + drop(Box::from_raw(userdata)); 0 } _ => DefWindowProcW(hwnd, msg, wparam, lparam), } } -fn create_event_target_window(class_name: &[u16], window_name: &[u16]) -> HWND { +fn create_event_target_window( + class_name: &[u16], + window_name: &[u16], + userdata: *const UserData, +) -> HWND { unsafe { let class = WNDCLASSEXW { cbSize: std::mem::size_of::() as u32, @@ -142,12 +179,12 @@ fn create_event_target_window(class_name: &[u16], window_name: &[u16 cbClsExtra: 0, cbWndExtra: 0, hInstance: GetModuleHandleW(std::ptr::null()), - hIcon: 0, - hCursor: 0, - hbrBackground: 0, + hIcon: std::ptr::null_mut(), + hCursor: std::ptr::null_mut(), + hbrBackground: std::ptr::null_mut(), lpszMenuName: std::ptr::null(), lpszClassName: class_name.as_ptr(), - hIconSm: 0, + hIconSm: std::ptr::null_mut(), }; RegisterClassExW(&class); @@ -171,10 +208,10 @@ fn create_event_target_window(class_name: &[u16], window_name: &[u16 0, 0, 0, - 0, - 0, + std::ptr::null_mut(), + std::ptr::null_mut(), GetModuleHandleW(std::ptr::null()), - std::ptr::null(), + userdata as _, ); SetWindowLongPtrW( hwnd, diff --git a/plugins/single-instance/src/semver_compat.rs b/plugins/single-instance/src/semver_compat.rs new file mode 100644 index 00000000..80487cae --- /dev/null +++ b/plugins/single-instance/src/semver_compat.rs @@ -0,0 +1,19 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +/// Takes a version and spits out a String with trailing _x, thus only considering the digits +/// relevant regarding semver compatibility +pub fn semver_compat_string(version: semver::Version) -> String { + // for pre-release always treat each version separately + if !version.pre.is_empty() { + return version.to_string().replace(['.', '-'], "_"); + } + match version.major { + 0 => match version.minor { + 0 => format!("0_0_{}", version.patch), + _ => format!("0_{}_x", version.minor), + }, + _ => format!("{}_x_x", version.major), + } +} diff --git a/plugins/sql/.gitignore b/plugins/sql/.gitignore deleted file mode 100644 index b512c09d..00000000 --- a/plugins/sql/.gitignore +++ /dev/null @@ -1 +0,0 @@ -node_modules \ No newline at end of file diff --git a/plugins/sql/CHANGELOG.md b/plugins/sql/CHANGELOG.md index 3109c03f..a80c3ff1 100644 --- a/plugins/sql/CHANGELOG.md +++ b/plugins/sql/CHANGELOG.md @@ -1,5 +1,110 @@ # Changelog +## \[2.2.0] + +- [`3a79266b`](https://github.com/tauri-apps/plugins-workspace/commit/3a79266b8cf96a55b1ae6339d725567d45a44b1d) ([#2173](https://github.com/tauri-apps/plugins-workspace/pull/2173) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Bumped all plugins to `v2.2.0`. From now, the versions for the Rust and JavaScript packages of each plugin will be in sync with each other. + +## \[2.0.2] + +- [`31956469`](https://github.com/tauri-apps/plugins-workspace/commit/319564699638c080b73d506bcaad186ecc4a8236) ([#1928](https://github.com/tauri-apps/plugins-workspace/pull/1928) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Fixed the QueryResult typing by marking `lastInsertId` as optional to reflect postgres-only changes made in the 2.0.0 release. + +## \[2.0.3] + +- [`90ef77c8`](https://github.com/tauri-apps/plugins-workspace/commit/90ef77c8723ac9d0ba7bd3b52a80a2b14843ff99) ([#2038](https://github.com/tauri-apps/plugins-workspace/pull/2038) by [@johncarmack1984](https://github.com/tauri-apps/plugins-workspace/../../johncarmack1984)) Allow blocking on async code without creating a nested runtime. + +## \[2.0.1] + +- [`0ca4cc91`](https://github.com/tauri-apps/plugins-workspace/commit/0ca4cc914c5ea995c98f9e60a2ab49827c219350) ([#1963](https://github.com/tauri-apps/plugins-workspace/pull/1963) by [@yoggys](https://github.com/tauri-apps/plugins-workspace/../../yoggys)) Fixed incorrect documentation of the select method in the Database class. + +## \[2.0.1] + +- [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. + +## \[2.0.0] + +- [`e2c4dfb6`](https://github.com/tauri-apps/plugins-workspace/commit/e2c4dfb6af43e5dd8d9ceba232c315f5febd55c1) Update to tauri v2 stable release. + +## \[2.0.0-rc.3] + +- [`30bcf5dc`](https://github.com/tauri-apps/plugins-workspace/commit/30bcf5dcc22e1bb1fb983a8d2887edc39404e6df) ([#1838](https://github.com/tauri-apps/plugins-workspace/pull/1838) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) It is now possible to enable multiple SQL backends at the same time. There will be no compile error anymore if no backends are enabled! + +## \[2.0.0-rc.2] + +- [`0dd97d91`](https://github.com/tauri-apps/plugins-workspace/commit/0dd97d911569cdedab07f504b708036d62ff83c1) ([#1375](https://github.com/tauri-apps/plugins-workspace/pull/1375) by [@KauanCurbani](https://github.com/tauri-apps/plugins-workspace/../../KauanCurbani)) Added support for `UUID` columns to the postgres implementation. + +## \[2.0.0-rc.1] + +- [`e2e97db5`](https://github.com/tauri-apps/plugins-workspace/commit/e2e97db51983267f5be84d4f6f0278d58834d1f5) ([#1701](https://github.com/tauri-apps/plugins-workspace/pull/1701) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri 2.0.0-rc.8 + +## \[2.0.0-rc.0] + +- [`9887d1`](https://github.com/tauri-apps/plugins-workspace/commit/9887d14bd0e971c4c0f5c1188fc4005d3fc2e29e) Update to tauri RC. + +## \[2.0.0-beta.8] + +- [`99d6ac0f`](https://github.com/tauri-apps/plugins-workspace/commit/99d6ac0f9506a6a4a1aa59c728157190a7441af6) ([#1606](https://github.com/tauri-apps/plugins-workspace/pull/1606) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) The JS packages now specify the *minimum* `@tauri-apps/api` version instead of a single exact version. +- [`6de87966`](https://github.com/tauri-apps/plugins-workspace/commit/6de87966ecc00ad9d91c25be452f1f46bd2b7e1f) ([#1597](https://github.com/tauri-apps/plugins-workspace/pull/1597) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Update to tauri beta.25. + +## \[2.0.0-beta.10] + +- [`37cb9a66`](https://github.com/tauri-apps/plugins-workspace/commit/37cb9a6681b948908cd9443340f6b23401607df7) ([#1575](https://github.com/tauri-apps/plugins-workspace/pull/1575) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Update sqlx to 0.8 - Check out their changelog for behavior changes: https://github.com/launchbadge/sqlx/blob/main/CHANGELOG.md#080---2024-07-22 + +## \[2.0.0-beta.7] + +- [`22a17980`](https://github.com/tauri-apps/plugins-workspace/commit/22a17980ff4f6f8c40adb1b8f4ffc6dae2fe7e30) ([#1537](https://github.com/tauri-apps/plugins-workspace/pull/1537) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri beta.24. + +## \[2.0.0-beta.6] + +- [`76daee7a`](https://github.com/tauri-apps/plugins-workspace/commit/76daee7aafece34de3092c86e531cf9eb1138989) ([#1512](https://github.com/tauri-apps/plugins-workspace/pull/1512) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Update to tauri beta.23. + +## \[2.0.0-beta.7] + +- [`4216c051`](https://github.com/tauri-apps/plugins-workspace/commit/4216c0517fd1dcb29d0162dc2fc15291472a2b00) ([#1381](https://github.com/tauri-apps/plugins-workspace/pull/1381) by [@thewh1teagle](https://github.com/tauri-apps/plugins-workspace/../../thewh1teagle)) Made `DbInstances` public for managing database instances directly from `Rust`. + +## \[2.0.0-beta.5] + +- [`9013854f`](https://github.com/tauri-apps/plugins-workspace/commit/9013854f42a49a230b9dbb9d02774765528a923f)([#1382](https://github.com/tauri-apps/plugins-workspace/pull/1382)) Update to tauri beta.22. + +## \[2.0.0-beta.4] + +- [`430bd6f4`](https://github.com/tauri-apps/plugins-workspace/commit/430bd6f4f379bee5d232ae6b098ae131db7f178a)([#1363](https://github.com/tauri-apps/plugins-workspace/pull/1363)) Update to tauri beta.20. + +## \[2.0.0-beta.3] + +- [`bd1ed590`](https://github.com/tauri-apps/plugins-workspace/commit/bd1ed5903ffcce5500310dac1e59e8c67674ef1e)([#1237](https://github.com/tauri-apps/plugins-workspace/pull/1237)) Update to tauri beta.17. + +## \[2.0.0-beta.3] + +- [`a04ea2f`](https://github.com/tauri-apps/plugins-workspace/commit/a04ea2f38294d5a3987578283badc8eec87a7752)([#1071](https://github.com/tauri-apps/plugins-workspace/pull/1071)) The global API script is now only added to the binary when the `withGlobalTauri` config is true. + +## \[2.0.0-beta.2] + +- [`99bea25`](https://github.com/tauri-apps/plugins-workspace/commit/99bea2559c2c0648c2519c50a18cd124dacef57b)([#1005](https://github.com/tauri-apps/plugins-workspace/pull/1005)) Update to tauri beta.8. + +## \[2.0.0-beta.1] + +- [`569defb`](https://github.com/tauri-apps/plugins-workspace/commit/569defbe9492e38938554bb7bdc1be9151456d21) Update to tauri beta.4. + +## \[2.0.0-beta.0] + +- [`d198c01`](https://github.com/tauri-apps/plugins-workspace/commit/d198c014863ee260cb0de88a14b7fc4356ef7474)([#862](https://github.com/tauri-apps/plugins-workspace/pull/862)) Update to tauri beta. + +## \[2.0.0-alpha.5] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.13. + +## \[2.0.0-alpha.4] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.12. + +## \[2.0.0-alpha.3] + +- [`e438e0a`](https://github.com/tauri-apps/plugins-workspace/commit/e438e0a62d4b430a5159f05f13ecd397dd891a0d)([#676](https://github.com/tauri-apps/plugins-workspace/pull/676)) Update to @tauri-apps/api v2.0.0-alpha.11. + +## \[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.9. + ## \[2.0.0-alpha.2] - [`4e2cef9`](https://github.com/tauri-apps/plugins-workspace/commit/4e2cef9b702bbbb9cf4ee17de50791cb21f1b2a4)([#593](https://github.com/tauri-apps/plugins-workspace/pull/593)) Update to alpha.12. @@ -10,9 +115,4 @@ ## \[2.0.0-alpha.0] -- [`717ae67`](https://github.com/tauri-apps/plugins-workspace/commit/717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! - te to alpha.11. - -## \[2.0.0-alpha.0] - - [`717ae67`](https://github.com/tauri-apps/plugins-workspace/commit/717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! diff --git a/plugins/sql/Cargo.toml b/plugins/sql/Cargo.toml index 84759d71..0449a4be 100644 --- a/plugins/sql/Cargo.toml +++ b/plugins/sql/Cargo.toml @@ -1,14 +1,28 @@ [package] name = "tauri-plugin-sql" -version = "2.0.0-alpha.2" +version = "2.2.0" description = "Interface with SQL databases." authors = { workspace = true } license = { workspace = true } edition = { workspace = true } rust-version = { workspace = true } +repository = { workspace = true } +links = "tauri-plugin-sql" [package.metadata.docs.rs] -features = [ "dox", "sqlite" ] +features = ["sqlite"] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] + +[package.metadata.platforms.support] +windows = { level = "full", notes = "" } +linux = { level = "full", notes = "" } +macos = { level = "full", notes = "" } +android = { level = "full", notes = "" } +ios = { level = "full", notes = "" } + +[build-dependencies] +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } @@ -17,11 +31,13 @@ tauri = { workspace = true } log = { workspace = true } thiserror = { workspace = true } futures-core = "0.3" -sqlx = { version = "0.7", features = [ "runtime-tokio-rustls", "json", "time" ] } +sqlx = { version = "0.8", features = ["json", "time"] } time = "0.3" -tokio = { version = "1", features = [ "sync" ] } +tokio = { version = "1", features = ["sync"] } +indexmap = { version = "2", features = ["serde"] } [features] -sqlite = [ "sqlx/sqlite" ] -mysql = [ "sqlx/mysql" ] -postgres = [ "sqlx/postgres" ] +sqlite = ["sqlx/sqlite", "sqlx/runtime-tokio"] +mysql = ["sqlx/mysql", "sqlx/runtime-tokio-rustls"] +postgres = ["sqlx/postgres", "sqlx/runtime-tokio-rustls"] +# TODO: bundled-cipher etc diff --git a/plugins/sql/README.md b/plugins/sql/README.md index bafd54ac..1df02e21 100644 --- a/plugins/sql/README.md +++ b/plugins/sql/README.md @@ -2,9 +2,17 @@ Interface with SQL databases through [sqlx](https://github.com/launchbadge/sqlx). It supports the `sqlite`, `mysql` and `postgres` drivers, enabled by a Cargo feature. +| Platform | Supported | +| -------- | --------- | +| Linux | ✓ | +| Windows | ✓ | +| macOS | ✓ | +| Android | ✓ | +| iOS | x | + ## Install -_This plugin requires a Rust version of at least **1.70**_ +_This plugin requires a Rust version of at least **1.77.2**_ There are three general methods of installation that we can recommend. @@ -19,7 +27,7 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies.tauri-plugin-sql] features = ["sqlite"] # or "postgres", or "mysql" -version = "2.0.0-alpha" +version = "2.0.0" # alternatively with Git git = "https://github.com/tauri-apps/plugins-workspace" branch = "v2" @@ -48,7 +56,7 @@ yarn add https://github.com/tauri-apps/tauri-plugin-sql#v2 First you need to register the core plugin with Tauri: -`src-tauri/src/main.rs` +`src-tauri/src/lib.rs` ```rust fn main() { @@ -62,16 +70,16 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import Database from "@tauri-apps/plugin-sql"; +import Database from '@tauri-apps/plugin-sql' -// sqlite. The path is relative to `tauri::api::path::BaseDirectory::App`. -const db = await Database.load("sqlite:test.db"); +// sqlite. The path is relative to `tauri::api::path::BaseDirectory::AppConfig`. +const db = await Database.load('sqlite:test.db') // mysql -const db = await Database.load("mysql://user:pass@host/database"); +const db = await Database.load('mysql://user:pass@host/database') // postgres -const db = await Database.load("postgres://postgres:password@localhost/test"); +const db = await Database.load('postgres://postgres:password@localhost/test') -await db.execute("INSERT INTO ..."); +await db.execute('INSERT INTO ...') ``` ## Syntax @@ -84,31 +92,127 @@ We use sqlx as our underlying library, adopting their query syntax: ```javascript // INSERT and UPDATE examples for sqlite and postgres const result = await db.execute( - "INSERT into todos (id, title, status) VALUES ($1, $2, $3)", - [todos.id, todos.title, todos.status], -); + 'INSERT into todos (id, title, status) VALUES ($1, $2, $3)', + [todos.id, todos.title, todos.status] +) const result = await db.execute( - "UPDATE todos SET title = $1, completed = $2 WHERE id = $3", - [todos.title, todos.status, todos.id], -); + 'UPDATE todos SET title = $1, status = $2 WHERE id = $3', + [todos.title, todos.status, todos.id] +) // INSERT and UPDATE examples for mysql const result = await db.execute( - "INSERT into todos (id, title, status) VALUES (?, ?, ?)", - [todos.id, todos.title, todos.status], -); + 'INSERT into todos (id, title, status) VALUES (?, ?, ?)', + [todos.id, todos.title, todos.status] +) const result = await db.execute( - "UPDATE todos SET title = ?, completed = ? WHERE id = ?", - [todos.title, todos.status, todos.id], -); + 'UPDATE todos SET title = ?, status = ? WHERE id = ?', + [todos.title, todos.status, todos.id] +) +``` + +## Migrations + +This plugin supports database migrations, allowing you to manage database schema evolution over time. + +### Defining Migrations + +Migrations are defined in Rust using the `Migration` struct. Each migration should include a unique version number, a description, the SQL to be executed, and the type of migration (Up or Down). + +Example of a migration: + +```rust +use tauri_plugin_sql::{Migration, MigrationKind}; + +let migration = Migration { + version: 1, + description: "create_initial_tables", + sql: "CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT);", + kind: MigrationKind::Up, +}; +``` + +### Adding Migrations to the Plugin Builder + +Migrations are registered with the `Builder` struct provided by the plugin. Use the `add_migrations` method to add your migrations to the plugin for a specific database connection. + +Example of adding migrations: + +```rust +use tauri_plugin_sql::{Builder, Migration, MigrationKind}; + +fn main() { + let migrations = vec![ + // Define your migrations here + Migration { + version: 1, + description: "create_initial_tables", + sql: "CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT);", + kind: MigrationKind::Up, + } + ]; + + tauri::Builder::default() + .plugin( + tauri_plugin_sql::Builder::default() + .add_migrations("sqlite:mydatabase.db", migrations) + .build(), + ) + ... +} +``` + +### Applying Migrations + +To apply the migrations when the plugin is initialized, add the connection string to the `tauri.conf.json` file: + +```json +{ + "plugins": { + "sql": { + "preload": ["sqlite:mydatabase.db"] + } + } +} +``` + +Alternatively, the client side `load()` also runs the migrations for a given connection string: + +```ts +import Database from '@tauri-apps/plugin-sql' +const db = await Database.load('sqlite:mydatabase.db') ``` +Ensure that the migrations are defined in the correct order and are safe to run multiple times. + +### Migration Management + +- **Version Control**: Each migration must have a unique version number. This is crucial for ensuring the migrations are applied in the correct order. +- **Idempotency**: Write migrations in a way that they can be safely re-run without causing errors or unintended consequences. +- **Testing**: Thoroughly test migrations to ensure they work as expected and do not compromise the integrity of your database. + ## Contributing PRs accepted. Please make sure to read the Contributing Guide before making a pull request. +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + ## License Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. diff --git a/plugins/sql/SECURITY.md b/plugins/sql/SECURITY.md new file mode 100644 index 00000000..4f09bbac --- /dev/null +++ b/plugins/sql/SECURITY.md @@ -0,0 +1,23 @@ +# Security Policy + +**Do not report security vulnerabilities through public GitHub issues.** + +**Please use the [Private Vulnerability Disclosure](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) feature of GitHub.** + +Include as much of the following information: + +- Type of issue (e.g. improper input parsing, privilege escalation, etc.) +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- The distribution affected or used to help us with reproduction of the issue +- Step-by-step instructions to reproduce the issue +- Ideally a reproduction repository +- Impact of the issue, including how an attacker might exploit the issue + +We prefer to receive reports in English. + +## Contact + +Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). + +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/sql/api-iife.js b/plugins/sql/api-iife.js new file mode 100644 index 00000000..a30f68d9 --- /dev/null +++ b/plugins/sql/api-iife.js @@ -0,0 +1 @@ +if("__TAURI__"in window){var __TAURI_PLUGIN_SQL__=function(){"use strict";async function e(e,t={},s){return window.__TAURI_INTERNALS__.invoke(e,t,s)}"function"==typeof SuppressedError&&SuppressedError;class t{constructor(e){this.path=e}static async load(s){const n=await e("plugin:sql|load",{db:s});return new t(n)}static get(e){return new t(e)}async execute(t,s){const[n,r]=await e("plugin:sql|execute",{db:this.path,query:t,values:s??[]});return{lastInsertId:r,rowsAffected:n}}async select(t,s){return await e("plugin:sql|select",{db:this.path,query:t,values:s??[]})}async close(t){return await e("plugin:sql|close",{db:t})}}return t}();Object.defineProperty(window.__TAURI__,"sql",{value:__TAURI_PLUGIN_SQL__})} diff --git a/plugins/sql/build.rs b/plugins/sql/build.rs new file mode 100644 index 00000000..fbbca422 --- /dev/null +++ b/plugins/sql/build.rs @@ -0,0 +1,11 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +const COMMANDS: &[&str] = &["load", "execute", "select", "close"]; + +fn main() { + tauri_plugin::Builder::new(COMMANDS) + .global_api_script_path("./api-iife.js") + .build(); +} diff --git a/plugins/sql/guest-js/index.ts b/plugins/sql/guest-js/index.ts index 1b08af5a..11d39e70 100644 --- a/plugins/sql/guest-js/index.ts +++ b/plugins/sql/guest-js/index.ts @@ -2,20 +2,20 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { invoke } from "@tauri-apps/api/primitives"; +import { invoke } from '@tauri-apps/api/core' export interface QueryResult { /** The number of rows affected by the query. */ - rowsAffected: number; + rowsAffected: number /** * The last inserted `id`. * - * This value is always `0` when using the Postgres driver. If the + * This value is not set for Postgres databases. If the * last inserted id is required on Postgres, the `select` function * must be used, with a `RETURNING` clause * (`INSERT INTO todos (title) VALUES ($1) RETURNING id`). */ - lastInsertId: number; + lastInsertId?: number } /** @@ -25,9 +25,9 @@ export interface QueryResult { * communicating with the rust side of the sql plugin. */ export default class Database { - path: string; + path: string constructor(path: string) { - this.path = path; + this.path = path } /** @@ -46,11 +46,11 @@ export default class Database { * ``` */ static async load(path: string): Promise { - const _path = await invoke("plugin:sql|load", { - db: path, - }); + const _path = await invoke('plugin:sql|load', { + db: path + }) - return new Database(_path); + return new Database(_path) } /** @@ -70,7 +70,7 @@ export default class Database { * ``` */ static get(path: string): Database { - return new Database(path); + return new Database(path) } /** @@ -107,19 +107,19 @@ export default class Database { */ async execute(query: string, bindValues?: unknown[]): Promise { const [rowsAffected, lastInsertId] = await invoke<[number, number]>( - "plugin:sql|execute", + 'plugin:sql|execute', { db: this.path, query, - values: bindValues ?? [], - }, - ); - + values: bindValues ?? [] + } + ) return { lastInsertId, - rowsAffected, - }; + rowsAffected + } } + /** * **select** * @@ -129,23 +129,23 @@ export default class Database { * ```ts * // for sqlite & postgres * const result = await db.select( - * "SELECT * from todos WHERE id = $1", id + * "SELECT * from todos WHERE id = $1", [ id ] * ); * * // for mysql * const result = await db.select( - * "SELECT * from todos WHERE id = ?", id + * "SELECT * from todos WHERE id = ?", [ id ] * ); * ``` */ async select(query: string, bindValues?: unknown[]): Promise { - const result = await invoke("plugin:sql|select", { + const result = await invoke('plugin:sql|select', { db: this.path, query, - values: bindValues ?? [], - }); + values: bindValues ?? [] + }) - return result; + return result } /** @@ -160,9 +160,9 @@ export default class Database { * @param db - Optionally state the name of a database if you are managing more than one. Otherwise, all database pools will be in scope. */ async close(db?: string): Promise { - const success = await invoke("plugin:sql|close", { - db, - }); - return success; + const success = await invoke('plugin:sql|close', { + db + }) + return success } } diff --git a/plugins/sql/package.json b/plugins/sql/package.json index ec608ce2..162df528 100644 --- a/plugins/sql/package.json +++ b/plugins/sql/package.json @@ -1,33 +1,30 @@ { "name": "@tauri-apps/plugin-sql", - "version": "2.0.0-alpha.1", + "version": "2.2.0", "description": "Interface with SQL databases", - "license": "MIT or APACHE-2.0", + "license": "MIT OR Apache-2.0", "authors": [ "Tauri Programme within The Commons Conservancy" ], + "repository": "https://github.com/tauri-apps/plugins-workspace", "type": "module", - "browser": "dist-js/index.min.js", - "module": "dist-js/index.mjs", - "types": "dist-js/index.d.ts", + "types": "./dist-js/index.d.ts", + "main": "./dist-js/index.cjs", + "module": "./dist-js/index.js", "exports": { - "import": "./dist-js/index.mjs", "types": "./dist-js/index.d.ts", - "browser": "./dist-js/index.min.js" + "import": "./dist-js/index.js", + "require": "./dist-js/index.cjs" }, "scripts": { "build": "rollup -c" }, "files": [ "dist-js", - "!dist-js/**/*.map", "README.md", "LICENSE" ], - "devDependencies": { - "tslib": "2.6.0" - }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.9" + "@tauri-apps/api": "^2.0.0" } } diff --git a/plugins/sql/permissions/autogenerated/commands/close.toml b/plugins/sql/permissions/autogenerated/commands/close.toml new file mode 100644 index 00000000..fad12d15 --- /dev/null +++ b/plugins/sql/permissions/autogenerated/commands/close.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-close" +description = "Enables the close command without any pre-configured scope." +commands.allow = ["close"] + +[[permission]] +identifier = "deny-close" +description = "Denies the close command without any pre-configured scope." +commands.deny = ["close"] diff --git a/plugins/sql/permissions/autogenerated/commands/execute.toml b/plugins/sql/permissions/autogenerated/commands/execute.toml new file mode 100644 index 00000000..d98be899 --- /dev/null +++ b/plugins/sql/permissions/autogenerated/commands/execute.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-execute" +description = "Enables the execute command without any pre-configured scope." +commands.allow = ["execute"] + +[[permission]] +identifier = "deny-execute" +description = "Denies the execute command without any pre-configured scope." +commands.deny = ["execute"] diff --git a/plugins/sql/permissions/autogenerated/commands/load.toml b/plugins/sql/permissions/autogenerated/commands/load.toml new file mode 100644 index 00000000..f6e47ad8 --- /dev/null +++ b/plugins/sql/permissions/autogenerated/commands/load.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-load" +description = "Enables the load command without any pre-configured scope." +commands.allow = ["load"] + +[[permission]] +identifier = "deny-load" +description = "Denies the load command without any pre-configured scope." +commands.deny = ["load"] diff --git a/plugins/sql/permissions/autogenerated/commands/select.toml b/plugins/sql/permissions/autogenerated/commands/select.toml new file mode 100644 index 00000000..5a13a022 --- /dev/null +++ b/plugins/sql/permissions/autogenerated/commands/select.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-select" +description = "Enables the select command without any pre-configured scope." +commands.allow = ["select"] + +[[permission]] +identifier = "deny-select" +description = "Denies the select command without any pre-configured scope." +commands.deny = ["select"] diff --git a/plugins/sql/permissions/autogenerated/reference.md b/plugins/sql/permissions/autogenerated/reference.md new file mode 100644 index 00000000..e09044c4 --- /dev/null +++ b/plugins/sql/permissions/autogenerated/reference.md @@ -0,0 +1,133 @@ +## Default Permission + +### Default Permissions + +This permission set configures what kind of +database operations are available from the sql plugin. + +### Granted Permissions + +All reading related operations are enabled. +Also allows to load or close a connection. + + + +#### This default permission set includes the following: + +- `allow-close` +- `allow-load` +- `allow-select` + +## Permission Table + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IdentifierDescription
+ +`sql:allow-close` + + + +Enables the close command without any pre-configured scope. + +
+ +`sql:deny-close` + + + +Denies the close command without any pre-configured scope. + +
+ +`sql:allow-execute` + + + +Enables the execute command without any pre-configured scope. + +
+ +`sql:deny-execute` + + + +Denies the execute command without any pre-configured scope. + +
+ +`sql:allow-load` + + + +Enables the load command without any pre-configured scope. + +
+ +`sql:deny-load` + + + +Denies the load command without any pre-configured scope. + +
+ +`sql:allow-select` + + + +Enables the select command without any pre-configured scope. + +
+ +`sql:deny-select` + + + +Denies the select command without any pre-configured scope. + +
diff --git a/plugins/sql/permissions/default.toml b/plugins/sql/permissions/default.toml new file mode 100644 index 00000000..eb5fa555 --- /dev/null +++ b/plugins/sql/permissions/default.toml @@ -0,0 +1,16 @@ +"$schema" = "schemas/schema.json" + +[default] +description = """ +### Default Permissions + +This permission set configures what kind of +database operations are available from the sql plugin. + +### Granted Permissions + +All reading related operations are enabled. +Also allows to load or close a connection. + +""" +permissions = ["allow-close", "allow-load", "allow-select"] diff --git a/plugins/sql/permissions/schemas/schema.json b/plugins/sql/permissions/schemas/schema.json new file mode 100644 index 00000000..488a953c --- /dev/null +++ b/plugins/sql/permissions/schemas/schema.json @@ -0,0 +1,354 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "PermissionFile", + "description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.", + "type": "object", + "properties": { + "default": { + "description": "The default permission set for the plugin", + "anyOf": [ + { + "$ref": "#/definitions/DefaultPermission" + }, + { + "type": "null" + } + ] + }, + "set": { + "description": "A list of permissions sets defined", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionSet" + } + }, + "permission": { + "description": "A list of inlined permissions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Permission" + } + } + }, + "definitions": { + "DefaultPermission": { + "description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.", + "type": "object", + "required": [ + "permissions" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "PermissionSet": { + "description": "A set of direct permissions grouped together under a new name.", + "type": "object", + "required": [ + "description", + "identifier", + "permissions" + ], + "properties": { + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does.", + "type": "string" + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionKind" + } + } + } + }, + "Permission": { + "description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.", + "type": "object", + "required": [ + "identifier" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri internal convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "commands": { + "description": "Allowed or denied commands when using this permission.", + "default": { + "allow": [], + "deny": [] + }, + "allOf": [ + { + "$ref": "#/definitions/Commands" + } + ] + }, + "scope": { + "description": "Allowed or denied scoped when using this permission.", + "allOf": [ + { + "$ref": "#/definitions/Scopes" + } + ] + }, + "platforms": { + "description": "Target platforms this permission applies. By default all platforms are affected by this permission.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Target" + } + } + } + }, + "Commands": { + "description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.", + "type": "object", + "properties": { + "allow": { + "description": "Allowed command.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "deny": { + "description": "Denied command, which takes priority.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "Scopes": { + "description": "An argument for fine grained behavior control of Tauri commands.\n\nIt can be of any serde serializable type and is used to allow or prevent certain actions inside a Tauri command. The configured scope is passed to the command and will be enforced by the command implementation.\n\n## Example\n\n```json { \"allow\": [{ \"path\": \"$HOME/**\" }], \"deny\": [{ \"path\": \"$HOME/secret.txt\" }] } ```", + "type": "object", + "properties": { + "allow": { + "description": "Data that defines what is allowed by the scope.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + }, + "deny": { + "description": "Data that defines what is denied by the scope. This should be prioritized by validation logic.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + } + } + }, + "Value": { + "description": "All supported ACL values.", + "anyOf": [ + { + "description": "Represents a null JSON value.", + "type": "null" + }, + { + "description": "Represents a [`bool`].", + "type": "boolean" + }, + { + "description": "Represents a valid ACL [`Number`].", + "allOf": [ + { + "$ref": "#/definitions/Number" + } + ] + }, + { + "description": "Represents a [`String`].", + "type": "string" + }, + { + "description": "Represents a list of other [`Value`]s.", + "type": "array", + "items": { + "$ref": "#/definitions/Value" + } + }, + { + "description": "Represents a map of [`String`] keys to [`Value`]s.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/Value" + } + } + ] + }, + "Number": { + "description": "A valid ACL number.", + "anyOf": [ + { + "description": "Represents an [`i64`].", + "type": "integer", + "format": "int64" + }, + { + "description": "Represents a [`f64`].", + "type": "number", + "format": "double" + } + ] + }, + "Target": { + "description": "Platform target.", + "oneOf": [ + { + "description": "MacOS.", + "type": "string", + "enum": [ + "macOS" + ] + }, + { + "description": "Windows.", + "type": "string", + "enum": [ + "windows" + ] + }, + { + "description": "Linux.", + "type": "string", + "enum": [ + "linux" + ] + }, + { + "description": "Android.", + "type": "string", + "enum": [ + "android" + ] + }, + { + "description": "iOS.", + "type": "string", + "enum": [ + "iOS" + ] + } + ] + }, + "PermissionKind": { + "type": "string", + "oneOf": [ + { + "description": "Enables the close command without any pre-configured scope.", + "type": "string", + "const": "allow-close", + "markdownDescription": "Enables the close command without any pre-configured scope." + }, + { + "description": "Denies the close command without any pre-configured scope.", + "type": "string", + "const": "deny-close", + "markdownDescription": "Denies the close command without any pre-configured scope." + }, + { + "description": "Enables the execute command without any pre-configured scope.", + "type": "string", + "const": "allow-execute", + "markdownDescription": "Enables the execute command without any pre-configured scope." + }, + { + "description": "Denies the execute command without any pre-configured scope.", + "type": "string", + "const": "deny-execute", + "markdownDescription": "Denies the execute command without any pre-configured scope." + }, + { + "description": "Enables the load command without any pre-configured scope.", + "type": "string", + "const": "allow-load", + "markdownDescription": "Enables the load command without any pre-configured scope." + }, + { + "description": "Denies the load command without any pre-configured scope.", + "type": "string", + "const": "deny-load", + "markdownDescription": "Denies the load command without any pre-configured scope." + }, + { + "description": "Enables the select command without any pre-configured scope.", + "type": "string", + "const": "allow-select", + "markdownDescription": "Enables the select command without any pre-configured scope." + }, + { + "description": "Denies the select command without any pre-configured scope.", + "type": "string", + "const": "deny-select", + "markdownDescription": "Denies the select command without any pre-configured scope." + }, + { + "description": "### Default Permissions\n\nThis permission set configures what kind of\ndatabase operations are available from the sql plugin.\n\n### Granted Permissions\n\nAll reading related operations are enabled.\nAlso allows to load or close a connection.\n\n\n#### This default permission set includes:\n\n- `allow-close`\n- `allow-load`\n- `allow-select`", + "type": "string", + "const": "default", + "markdownDescription": "### Default Permissions\n\nThis permission set configures what kind of\ndatabase operations are available from the sql plugin.\n\n### Granted Permissions\n\nAll reading related operations are enabled.\nAlso allows to load or close a connection.\n\n\n#### This default permission set includes:\n\n- `allow-close`\n- `allow-load`\n- `allow-select`" + } + ] + } + } +} \ No newline at end of file diff --git a/plugins/sql/rollup.config.js b/plugins/sql/rollup.config.js new file mode 100644 index 00000000..1f349ec8 --- /dev/null +++ b/plugins/sql/rollup.config.js @@ -0,0 +1,7 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import { createConfig } from '../../shared/rollup.config.js' + +export default createConfig() diff --git a/plugins/sql/rollup.config.mjs b/plugins/sql/rollup.config.mjs deleted file mode 100644 index 99a3dd31..00000000 --- a/plugins/sql/rollup.config.mjs +++ /dev/null @@ -1,11 +0,0 @@ -import { readFileSync } from "fs"; - -import { createConfig } from "../../shared/rollup.config.mjs"; - -export default createConfig({ - input: "guest-js/index.ts", - pkg: JSON.parse( - readFileSync(new URL("./package.json", import.meta.url), "utf8"), - ), - external: [/^@tauri-apps\/api/], -}); diff --git a/plugins/sql/src/api-iife.js b/plugins/sql/src/api-iife.js deleted file mode 100644 index 60ceb80a..00000000 --- a/plugins/sql/src/api-iife.js +++ /dev/null @@ -1 +0,0 @@ -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__})} diff --git a/plugins/sql/src/commands.rs b/plugins/sql/src/commands.rs new file mode 100644 index 00000000..760d00b2 --- /dev/null +++ b/plugins/sql/src/commands.rs @@ -0,0 +1,80 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use indexmap::IndexMap; +use serde_json::Value as JsonValue; +use sqlx::migrate::Migrator; +use tauri::{command, AppHandle, Runtime, State}; + +use crate::{DbInstances, DbPool, Error, LastInsertId, Migrations}; + +#[command] +pub(crate) async fn load( + app: AppHandle, + db_instances: State<'_, DbInstances>, + migrations: State<'_, Migrations>, + db: String, +) -> Result { + let pool = DbPool::connect(&db, &app).await?; + + if let Some(migrations) = migrations.0.lock().await.remove(&db) { + let migrator = Migrator::new(migrations).await?; + pool.migrate(&migrator).await?; + } + + db_instances.0.write().await.insert(db.clone(), pool); + + Ok(db) +} + +/// Allows the database connection(s) to be closed; if no database +/// name is passed in then _all_ database connection pools will be +/// shut down. +#[command] +pub(crate) async fn close( + db_instances: State<'_, DbInstances>, + db: Option, +) -> Result { + let instances = db_instances.0.read().await; + + let pools = if let Some(db) = db { + vec![db] + } else { + instances.keys().cloned().collect() + }; + + for pool in pools { + let db = instances.get(&pool).ok_or(Error::DatabaseNotLoaded(pool))?; + db.close().await; + } + + Ok(true) +} + +/// Execute a command against the database +#[command] +pub(crate) async fn execute( + db_instances: State<'_, DbInstances>, + db: String, + query: String, + values: Vec, +) -> Result<(u64, LastInsertId), crate::Error> { + let instances = db_instances.0.read().await; + + let db = instances.get(&db).ok_or(Error::DatabaseNotLoaded(db))?; + db.execute(query, values).await +} + +#[command] +pub(crate) async fn select( + db_instances: State<'_, DbInstances>, + db: String, + query: String, + values: Vec, +) -> Result>, crate::Error> { + let instances = db_instances.0.read().await; + + let db = instances.get(&db).ok_or(Error::DatabaseNotLoaded(db))?; + db.select(query, values).await +} diff --git a/plugins/sql/src/decode/mod.rs b/plugins/sql/src/decode/mod.rs index 50fb3c78..0a2d2cdd 100644 --- a/plugins/sql/src/decode/mod.rs +++ b/plugins/sql/src/decode/mod.rs @@ -3,17 +3,8 @@ // SPDX-License-Identifier: MIT #[cfg(feature = "mysql")] -mod mysql; +pub(crate) mod mysql; #[cfg(feature = "postgres")] -mod postgres; +pub(crate) mod postgres; #[cfg(feature = "sqlite")] -mod sqlite; - -#[cfg(feature = "mysql")] -pub(crate) use mysql::to_json; - -#[cfg(feature = "postgres")] -pub(crate) use postgres::to_json; - -#[cfg(feature = "sqlite")] -pub(crate) use sqlite::to_json; +pub(crate) mod sqlite; diff --git a/plugins/sql/src/decode/mysql.rs b/plugins/sql/src/decode/mysql.rs index 6ca7e403..53fd20c7 100644 --- a/plugins/sql/src/decode/mysql.rs +++ b/plugins/sql/src/decode/mysql.rs @@ -21,7 +21,14 @@ pub(crate) fn to_json(v: MySqlValueRef) -> Result { JsonValue::Null } } - "FLOAT" | "DOUBLE" => { + "FLOAT" => { + if let Ok(v) = ValueRef::to_owned(&v).try_decode::() { + JsonValue::from(v) + } else { + JsonValue::Null + } + } + "DOUBLE" => { if let Ok(v) = ValueRef::to_owned(&v).try_decode::() { JsonValue::from(v) } else { diff --git a/plugins/sql/src/decode/postgres.rs b/plugins/sql/src/decode/postgres.rs index bd77aff0..6f689dce 100644 --- a/plugins/sql/src/decode/postgres.rs +++ b/plugins/sql/src/decode/postgres.rs @@ -14,21 +14,42 @@ pub(crate) fn to_json(v: PgValueRef) -> Result { } let res = match v.type_info().name() { - "CHAR" | "VARCHAR" | "TEXT" | "NAME" => { + "CHAR" | "VARCHAR" | "TEXT" | "NAME" | "UUID" => { if let Ok(v) = ValueRef::to_owned(&v).try_decode() { JsonValue::String(v) } else { JsonValue::Null } } - "FLOAT4" | "FLOAT8" => { + "FLOAT4" => { + if let Ok(v) = ValueRef::to_owned(&v).try_decode::() { + JsonValue::from(v) + } else { + JsonValue::Null + } + } + "FLOAT8" => { if let Ok(v) = ValueRef::to_owned(&v).try_decode::() { JsonValue::from(v) } else { JsonValue::Null } } - "INT2" | "INT4" | "INT8" => { + "INT2" => { + if let Ok(v) = ValueRef::to_owned(&v).try_decode::() { + JsonValue::Number(v.into()) + } else { + JsonValue::Null + } + } + "INT4" => { + if let Ok(v) = ValueRef::to_owned(&v).try_decode::() { + JsonValue::Number(v.into()) + } else { + JsonValue::Null + } + } + "INT8" => { if let Ok(v) = ValueRef::to_owned(&v).try_decode::() { JsonValue::Number(v.into()) } else { diff --git a/plugins/sql/src/error.rs b/plugins/sql/src/error.rs new file mode 100644 index 00000000..5ac845b8 --- /dev/null +++ b/plugins/sql/src/error.rs @@ -0,0 +1,28 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use serde::{Serialize, Serializer}; + +#[derive(Debug, thiserror::Error)] +pub enum Error { + #[error(transparent)] + Sql(#[from] sqlx::Error), + #[error(transparent)] + Migration(#[from] sqlx::migrate::MigrateError), + #[error("invalid connection url: {0}")] + InvalidDbUrl(String), + #[error("database {0} not loaded")] + DatabaseNotLoaded(String), + #[error("unsupported datatype: {0}")] + UnsupportedDatatype(String), +} + +impl Serialize for Error { + fn serialize(&self, serializer: S) -> std::result::Result + where + S: Serializer, + { + serializer.serialize_str(self.to_string().as_ref()) + } +} diff --git a/plugins/sql/src/lib.rs b/plugins/sql/src/lib.rs index f25ede21..56b2a3a6 100644 --- a/plugins/sql/src/lib.rs +++ b/plugins/sql/src/lib.rs @@ -2,8 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -//! [![](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/sql/banner.png)](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/sql) -//! //! Interface with SQL databases through [sqlx](https://github.com/launchbadge/sqlx). It supports the `sqlite`, `mysql` and `postgres` drivers, enabled by a Cargo feature. #![doc( @@ -11,20 +9,179 @@ html_favicon_url = "https://github.com/tauri-apps/tauri/raw/dev/app-icon.png" )] -#[cfg(any( - all(feature = "sqlite", feature = "mysql"), - all(feature = "sqlite", feature = "postgres"), - all(feature = "mysql", feature = "postgres") -))] -compile_error!( - "Only one database driver can be enabled. Set the feature flag for the driver of your choice." -); +mod commands; +mod decode; +mod error; +mod wrapper; -#[cfg(not(any(feature = "sqlite", feature = "mysql", feature = "postgres")))] -compile_error!( - "Database driver not defined. Please set the feature flag for the driver of your choice." -); +pub use error::Error; +pub use wrapper::DbPool; -mod decode; -mod plugin; -pub use plugin::*; +use futures_core::future::BoxFuture; +use serde::{Deserialize, Serialize}; +use sqlx::{ + error::BoxDynError, + migrate::{Migration as SqlxMigration, MigrationSource, MigrationType, Migrator}, +}; +use tauri::{ + plugin::{Builder as PluginBuilder, TauriPlugin}, + Manager, RunEvent, Runtime, +}; +use tokio::sync::{Mutex, RwLock}; + +use std::collections::HashMap; + +#[derive(Default)] +pub struct DbInstances(pub RwLock>); + +#[derive(Serialize)] +#[serde(untagged)] +pub(crate) enum LastInsertId { + #[cfg(feature = "sqlite")] + Sqlite(i64), + #[cfg(feature = "mysql")] + MySql(u64), + #[cfg(feature = "postgres")] + Postgres(()), + #[cfg(not(any(feature = "sqlite", feature = "mysql", feature = "postgres")))] + None, +} + +struct Migrations(Mutex>); + +#[derive(Default, Clone, Deserialize)] +pub struct PluginConfig { + #[serde(default)] + preload: Vec, +} + +#[derive(Debug)] +pub enum MigrationKind { + Up, + Down, +} + +impl From for MigrationType { + fn from(kind: MigrationKind) -> Self { + match kind { + MigrationKind::Up => Self::ReversibleUp, + MigrationKind::Down => Self::ReversibleDown, + } + } +} + +/// A migration definition. +#[derive(Debug)] +pub struct Migration { + pub version: i64, + pub description: &'static str, + pub sql: &'static str, + pub kind: MigrationKind, +} + +#[derive(Debug)] +struct MigrationList(Vec); + +impl MigrationSource<'static> for MigrationList { + fn resolve(self) -> BoxFuture<'static, std::result::Result, BoxDynError>> { + Box::pin(async move { + let mut migrations = Vec::new(); + for migration in self.0 { + if matches!(migration.kind, MigrationKind::Up) { + migrations.push(SqlxMigration::new( + migration.version, + migration.description.into(), + migration.kind.into(), + migration.sql.into(), + false, + )); + } + } + Ok(migrations) + }) + } +} + +/// Allows blocking on async code without creating a nested runtime. +fn run_async_command(cmd: F) -> F::Output { + if tokio::runtime::Handle::try_current().is_ok() { + tokio::task::block_in_place(|| tokio::runtime::Handle::current().block_on(cmd)) + } else { + tauri::async_runtime::block_on(cmd) + } +} + +/// Tauri SQL plugin builder. +#[derive(Default)] +pub struct Builder { + migrations: Option>, +} + +impl Builder { + pub fn new() -> Self { + #[cfg(not(any(feature = "sqlite", feature = "mysql", feature = "postgres")))] + eprintln!("No sql driver enabled. Please set at least one of the \"sqlite\", \"mysql\", \"postgres\" feature flags."); + + Self::default() + } + + /// Add migrations to a database. + #[must_use] + pub fn add_migrations(mut self, db_url: &str, migrations: Vec) -> Self { + self.migrations + .get_or_insert(Default::default()) + .insert(db_url.to_string(), MigrationList(migrations)); + self + } + + pub fn build(mut self) -> TauriPlugin> { + PluginBuilder::>::new("sql") + .invoke_handler(tauri::generate_handler![ + commands::load, + commands::execute, + commands::select, + commands::close + ]) + .setup(|app, api| { + let config = api.config().clone().unwrap_or_default(); + + run_async_command(async move { + let instances = DbInstances::default(); + let mut lock = instances.0.write().await; + + for db in config.preload { + let pool = DbPool::connect(&db, app).await?; + + if let Some(migrations) = + self.migrations.as_mut().and_then(|mm| mm.remove(&db)) + { + let migrator = Migrator::new(migrations).await?; + pool.migrate(&migrator).await?; + } + + lock.insert(db, pool); + } + drop(lock); + + app.manage(instances); + app.manage(Migrations(Mutex::new( + self.migrations.take().unwrap_or_default(), + ))); + + Ok(()) + }) + }) + .on_event(|app, event| { + if let RunEvent::Exit = event { + run_async_command(async move { + let instances = &*app.state::(); + let instances = instances.0.read().await; + for value in instances.values() { + value.close().await; + } + }); + } + }) + .build() + } +} diff --git a/plugins/sql/src/plugin.rs b/plugins/sql/src/plugin.rs deleted file mode 100644 index 8d524345..00000000 --- a/plugins/sql/src/plugin.rs +++ /dev/null @@ -1,334 +0,0 @@ -// Copyright 2019-2023 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - -use futures_core::future::BoxFuture; -use serde::{ser::Serializer, Deserialize, Serialize}; -use serde_json::Value as JsonValue; -use sqlx::{ - error::BoxDynError, - migrate::{ - MigrateDatabase, Migration as SqlxMigration, MigrationSource, MigrationType, Migrator, - }, - Column, Pool, Row, -}; -use tauri::{ - command, - plugin::{Builder as PluginBuilder, TauriPlugin}, - AppHandle, Manager, RunEvent, Runtime, State, -}; -use tokio::sync::Mutex; - -use std::collections::HashMap; - -#[cfg(feature = "sqlite")] -use std::{fs::create_dir_all, path::PathBuf}; - -#[cfg(feature = "sqlite")] -type Db = sqlx::sqlite::Sqlite; -#[cfg(feature = "mysql")] -type Db = sqlx::mysql::MySql; -#[cfg(feature = "postgres")] -type Db = sqlx::postgres::Postgres; - -#[cfg(feature = "sqlite")] -type LastInsertId = i64; -#[cfg(not(feature = "sqlite"))] -type LastInsertId = u64; - -#[derive(Debug, thiserror::Error)] -pub enum Error { - #[error(transparent)] - Sql(#[from] sqlx::Error), - #[error(transparent)] - Migration(#[from] sqlx::migrate::MigrateError), - #[error("database {0} not loaded")] - DatabaseNotLoaded(String), - #[error("unsupported datatype: {0}")] - UnsupportedDatatype(String), -} - -impl Serialize for Error { - fn serialize(&self, serializer: S) -> std::result::Result - where - S: Serializer, - { - serializer.serialize_str(self.to_string().as_ref()) - } -} - -type Result = std::result::Result; - -#[cfg(feature = "sqlite")] -/// Resolves the App's **file path** from the `AppHandle` context -/// object -fn app_path(app: &AppHandle) -> PathBuf { - app.path().app_config_dir().expect("No App path was found!") -} - -#[cfg(feature = "sqlite")] -/// Maps the user supplied DB connection string to a connection string -/// with a fully qualified file path to the App's designed "app_path" -fn path_mapper(mut app_path: PathBuf, connection_string: &str) -> String { - app_path.push( - connection_string - .split_once(':') - .expect("Couldn't parse the connection string for DB!") - .1, - ); - - format!( - "sqlite:{}", - app_path - .to_str() - .expect("Problem creating fully qualified path to Database file!") - ) -} - -#[derive(Default)] -struct DbInstances(Mutex>>); - -struct Migrations(Mutex>); - -#[derive(Default, Clone, Deserialize)] -pub struct PluginConfig { - #[serde(default)] - preload: Vec, -} - -#[derive(Debug)] -pub enum MigrationKind { - Up, - Down, -} - -impl From for MigrationType { - fn from(kind: MigrationKind) -> Self { - match kind { - MigrationKind::Up => Self::ReversibleUp, - MigrationKind::Down => Self::ReversibleDown, - } - } -} - -/// A migration definition. -#[derive(Debug)] -pub struct Migration { - pub version: i64, - pub description: &'static str, - pub sql: &'static str, - pub kind: MigrationKind, -} - -#[derive(Debug)] -struct MigrationList(Vec); - -impl MigrationSource<'static> for MigrationList { - fn resolve(self) -> BoxFuture<'static, std::result::Result, BoxDynError>> { - Box::pin(async move { - let mut migrations = Vec::new(); - for migration in self.0 { - if matches!(migration.kind, MigrationKind::Up) { - migrations.push(SqlxMigration::new( - migration.version, - migration.description.into(), - migration.kind.into(), - migration.sql.into(), - )); - } - } - Ok(migrations) - }) - } -} - -#[command] -async fn load( - #[allow(unused_variables)] app: AppHandle, - db_instances: State<'_, DbInstances>, - migrations: State<'_, Migrations>, - db: String, -) -> Result { - #[cfg(feature = "sqlite")] - let fqdb = path_mapper(app_path(&app), &db); - #[cfg(not(feature = "sqlite"))] - let fqdb = db.clone(); - - #[cfg(feature = "sqlite")] - create_dir_all(app_path(&app)).expect("Problem creating App directory!"); - - if !Db::database_exists(&fqdb).await.unwrap_or(false) { - Db::create_database(&fqdb).await?; - } - let pool = Pool::connect(&fqdb).await?; - - if let Some(migrations) = migrations.0.lock().await.remove(&db) { - let migrator = Migrator::new(migrations).await?; - migrator.run(&pool).await?; - } - - db_instances.0.lock().await.insert(db.clone(), pool); - Ok(db) -} - -/// Allows the database connection(s) to be closed; if no database -/// name is passed in then _all_ database connection pools will be -/// shut down. -#[command] -async fn close(db_instances: State<'_, DbInstances>, db: Option) -> Result { - let mut instances = db_instances.0.lock().await; - - let pools = if let Some(db) = db { - vec![db] - } else { - instances.keys().cloned().collect() - }; - - for pool in pools { - let db = instances - .get_mut(&pool) // - .ok_or(Error::DatabaseNotLoaded(pool))?; - db.close().await; - } - - Ok(true) -} - -/// Execute a command against the database -#[command] -async fn execute( - db_instances: State<'_, DbInstances>, - db: String, - query: String, - values: Vec, -) -> Result<(u64, LastInsertId)> { - let mut instances = db_instances.0.lock().await; - - let db = instances.get_mut(&db).ok_or(Error::DatabaseNotLoaded(db))?; - let mut query = sqlx::query(&query); - for value in values { - if value.is_null() { - query = query.bind(None::); - } else if value.is_string() { - query = query.bind(value.as_str().unwrap().to_owned()) - } else { - query = query.bind(value); - } - } - let result = query.execute(&*db).await?; - #[cfg(feature = "sqlite")] - let r = Ok((result.rows_affected(), result.last_insert_rowid())); - #[cfg(feature = "mysql")] - let r = Ok((result.rows_affected(), result.last_insert_id())); - #[cfg(feature = "postgres")] - let r = Ok((result.rows_affected(), 0)); - r -} - -#[command] -async fn select( - db_instances: State<'_, DbInstances>, - db: String, - query: String, - values: Vec, -) -> Result>> { - let mut instances = db_instances.0.lock().await; - let db = instances.get_mut(&db).ok_or(Error::DatabaseNotLoaded(db))?; - let mut query = sqlx::query(&query); - for value in values { - if value.is_null() { - query = query.bind(None::); - } else if value.is_string() { - query = query.bind(value.as_str().unwrap().to_owned()) - } else { - query = query.bind(value); - } - } - let rows = query.fetch_all(&*db).await?; - let mut values = Vec::new(); - for row in rows { - let mut value = HashMap::default(); - for (i, column) in row.columns().iter().enumerate() { - let v = row.try_get_raw(i)?; - - let v = crate::decode::to_json(v)?; - - value.insert(column.name().to_string(), v); - } - - values.push(value); - } - - Ok(values) -} - -/// Tauri SQL plugin builder. -#[derive(Default)] -pub struct Builder { - migrations: Option>, -} - -impl Builder { - /// Add migrations to a database. - #[must_use] - pub fn add_migrations(mut self, db_url: &str, migrations: Vec) -> Self { - self.migrations - .get_or_insert(Default::default()) - .insert(db_url.to_string(), MigrationList(migrations)); - self - } - - pub fn build(mut self) -> TauriPlugin> { - PluginBuilder::>::new("sql") - .js_init_script(include_str!("api-iife.js").to_string()) - .invoke_handler(tauri::generate_handler![load, execute, select, close]) - .setup(|app, api| { - let config = api.config().clone().unwrap_or_default(); - - #[cfg(feature = "sqlite")] - create_dir_all(app_path(app)).expect("problems creating App directory!"); - - tauri::async_runtime::block_on(async move { - let instances = DbInstances::default(); - let mut lock = instances.0.lock().await; - for db in config.preload { - #[cfg(feature = "sqlite")] - let fqdb = path_mapper(app_path(app), &db); - #[cfg(not(feature = "sqlite"))] - let fqdb = db.clone(); - - if !Db::database_exists(&fqdb).await.unwrap_or(false) { - Db::create_database(&fqdb).await?; - } - let pool = Pool::connect(&fqdb).await?; - - if let Some(migrations) = self.migrations.as_mut().unwrap().remove(&db) { - let migrator = Migrator::new(migrations).await?; - migrator.run(&pool).await?; - } - lock.insert(db, pool); - } - drop(lock); - - app.manage(instances); - app.manage(Migrations(Mutex::new( - self.migrations.take().unwrap_or_default(), - ))); - - Ok(()) - }) - }) - .on_event(|app, event| { - if let RunEvent::Exit = event { - tauri::async_runtime::block_on(async move { - let instances = &*app.state::(); - let instances = instances.0.lock().await; - for value in instances.values() { - value.close().await; - } - }); - } - }) - .build() - } -} diff --git a/plugins/sql/src/wrapper.rs b/plugins/sql/src/wrapper.rs new file mode 100644 index 00000000..d47b2d1c --- /dev/null +++ b/plugins/sql/src/wrapper.rs @@ -0,0 +1,333 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +#[cfg(feature = "sqlite")] +use std::fs::create_dir_all; + +use indexmap::IndexMap; +use serde_json::Value as JsonValue; +#[cfg(any(feature = "sqlite", feature = "mysql", feature = "postgres"))] +use sqlx::{migrate::MigrateDatabase, Column, Executor, Pool, Row}; +#[cfg(any(feature = "sqlite", feature = "mysql", feature = "postgres"))] +use tauri::Manager; +use tauri::{AppHandle, Runtime}; + +#[cfg(feature = "mysql")] +use sqlx::MySql; +#[cfg(feature = "postgres")] +use sqlx::Postgres; +#[cfg(feature = "sqlite")] +use sqlx::Sqlite; + +use crate::LastInsertId; + +pub enum DbPool { + #[cfg(feature = "sqlite")] + Sqlite(Pool), + #[cfg(feature = "mysql")] + MySql(Pool), + #[cfg(feature = "postgres")] + Postgres(Pool), + #[cfg(not(any(feature = "sqlite", feature = "mysql", feature = "postgres")))] + None, +} + +// public methods +/* impl DbPool { + /// Get the inner Sqlite Pool. Returns None for MySql and Postgres pools. + #[cfg(feature = "sqlite")] + pub fn sqlite(&self) -> Option<&Pool> { + match self { + DbPool::Sqlite(pool) => Some(pool), + _ => None, + } + } + + /// Get the inner MySql Pool. Returns None for Sqlite and Postgres pools. + #[cfg(feature = "mysql")] + pub fn mysql(&self) -> Option<&Pool> { + match self { + DbPool::MySql(pool) => Some(pool), + _ => None, + } + } + + /// Get the inner Postgres Pool. Returns None for MySql and Sqlite pools. + #[cfg(feature = "postgres")] + pub fn postgres(&self) -> Option<&Pool> { + match self { + DbPool::Postgres(pool) => Some(pool), + _ => None, + } + } +} */ + +// private methods +impl DbPool { + pub(crate) async fn connect( + conn_url: &str, + _app: &AppHandle, + ) -> Result { + match conn_url + .split_once(':') + .ok_or_else(|| crate::Error::InvalidDbUrl(conn_url.to_string()))? + .0 + { + #[cfg(feature = "sqlite")] + "sqlite" => { + let app_path = _app + .path() + .app_config_dir() + .expect("No App config path was found!"); + + create_dir_all(&app_path).expect("Couldn't create app config dir"); + + let conn_url = &path_mapper(app_path, conn_url); + + if !Sqlite::database_exists(conn_url).await.unwrap_or(false) { + Sqlite::create_database(conn_url).await?; + } + Ok(Self::Sqlite(Pool::connect(conn_url).await?)) + } + #[cfg(feature = "mysql")] + "mysql" => { + if !MySql::database_exists(conn_url).await.unwrap_or(false) { + MySql::create_database(conn_url).await?; + } + Ok(Self::MySql(Pool::connect(conn_url).await?)) + } + #[cfg(feature = "postgres")] + "postgres" => { + if !Postgres::database_exists(conn_url).await.unwrap_or(false) { + Postgres::create_database(conn_url).await?; + } + Ok(Self::Postgres(Pool::connect(conn_url).await?)) + } + #[cfg(not(any(feature = "sqlite", feature = "postgres", feature = "mysql")))] + _ => Err(crate::Error::InvalidDbUrl(format!( + "{conn_url} - No database driver enabled!" + ))), + #[cfg(any(feature = "sqlite", feature = "postgres", feature = "mysql"))] + _ => Err(crate::Error::InvalidDbUrl(conn_url.to_string())), + } + } + + pub(crate) async fn migrate( + &self, + _migrator: &sqlx::migrate::Migrator, + ) -> Result<(), crate::Error> { + match self { + #[cfg(feature = "sqlite")] + DbPool::Sqlite(pool) => _migrator.run(pool).await?, + #[cfg(feature = "mysql")] + DbPool::MySql(pool) => _migrator.run(pool).await?, + #[cfg(feature = "postgres")] + DbPool::Postgres(pool) => _migrator.run(pool).await?, + #[cfg(not(any(feature = "sqlite", feature = "mysql", feature = "postgres")))] + DbPool::None => (), + } + Ok(()) + } + + pub(crate) async fn close(&self) { + match self { + #[cfg(feature = "sqlite")] + DbPool::Sqlite(pool) => pool.close().await, + #[cfg(feature = "mysql")] + DbPool::MySql(pool) => pool.close().await, + #[cfg(feature = "postgres")] + DbPool::Postgres(pool) => pool.close().await, + #[cfg(not(any(feature = "sqlite", feature = "mysql", feature = "postgres")))] + DbPool::None => (), + } + } + + pub(crate) async fn execute( + &self, + _query: String, + _values: Vec, + ) -> Result<(u64, LastInsertId), crate::Error> { + Ok(match self { + #[cfg(feature = "sqlite")] + DbPool::Sqlite(pool) => { + let mut query = sqlx::query(&_query); + for value in _values { + if value.is_null() { + query = query.bind(None::); + } else if value.is_string() { + query = query.bind(value.as_str().unwrap().to_owned()) + } else if let Some(number) = value.as_number() { + query = query.bind(number.as_f64().unwrap_or_default()) + } else { + query = query.bind(value); + } + } + let result = pool.execute(query).await?; + ( + result.rows_affected(), + LastInsertId::Sqlite(result.last_insert_rowid()), + ) + } + #[cfg(feature = "mysql")] + DbPool::MySql(pool) => { + let mut query = sqlx::query(&_query); + for value in _values { + if value.is_null() { + query = query.bind(None::); + } else if value.is_string() { + query = query.bind(value.as_str().unwrap().to_owned()) + } else if let Some(number) = value.as_number() { + query = query.bind(number.as_f64().unwrap_or_default()) + } else { + query = query.bind(value); + } + } + let result = pool.execute(query).await?; + ( + result.rows_affected(), + LastInsertId::MySql(result.last_insert_id()), + ) + } + #[cfg(feature = "postgres")] + DbPool::Postgres(pool) => { + let mut query = sqlx::query(&_query); + for value in _values { + if value.is_null() { + query = query.bind(None::); + } else if value.is_string() { + query = query.bind(value.as_str().unwrap().to_owned()) + } else if let Some(number) = value.as_number() { + query = query.bind(number.as_f64().unwrap_or_default()) + } else { + query = query.bind(value); + } + } + let result = pool.execute(query).await?; + (result.rows_affected(), LastInsertId::Postgres(())) + } + #[cfg(not(any(feature = "sqlite", feature = "mysql", feature = "postgres")))] + DbPool::None => (0, LastInsertId::None), + }) + } + + pub(crate) async fn select( + &self, + _query: String, + _values: Vec, + ) -> Result>, crate::Error> { + Ok(match self { + #[cfg(feature = "sqlite")] + DbPool::Sqlite(pool) => { + let mut query = sqlx::query(&_query); + for value in _values { + if value.is_null() { + query = query.bind(None::); + } else if value.is_string() { + query = query.bind(value.as_str().unwrap().to_owned()) + } else if let Some(number) = value.as_number() { + query = query.bind(number.as_f64().unwrap_or_default()) + } else { + query = query.bind(value); + } + } + let rows = pool.fetch_all(query).await?; + let mut values = Vec::new(); + for row in rows { + let mut value = IndexMap::default(); + for (i, column) in row.columns().iter().enumerate() { + let v = row.try_get_raw(i)?; + + let v = crate::decode::sqlite::to_json(v)?; + + value.insert(column.name().to_string(), v); + } + + values.push(value); + } + values + } + #[cfg(feature = "mysql")] + DbPool::MySql(pool) => { + let mut query = sqlx::query(&_query); + for value in _values { + if value.is_null() { + query = query.bind(None::); + } else if value.is_string() { + query = query.bind(value.as_str().unwrap().to_owned()) + } else if let Some(number) = value.as_number() { + query = query.bind(number.as_f64().unwrap_or_default()) + } else { + query = query.bind(value); + } + } + let rows = pool.fetch_all(query).await?; + let mut values = Vec::new(); + for row in rows { + let mut value = IndexMap::default(); + for (i, column) in row.columns().iter().enumerate() { + let v = row.try_get_raw(i)?; + + let v = crate::decode::mysql::to_json(v)?; + + value.insert(column.name().to_string(), v); + } + + values.push(value); + } + values + } + #[cfg(feature = "postgres")] + DbPool::Postgres(pool) => { + let mut query = sqlx::query(&_query); + for value in _values { + if value.is_null() { + query = query.bind(None::); + } else if value.is_string() { + query = query.bind(value.as_str().unwrap().to_owned()) + } else if let Some(number) = value.as_number() { + query = query.bind(number.as_f64().unwrap_or_default()) + } else { + query = query.bind(value); + } + } + let rows = pool.fetch_all(query).await?; + let mut values = Vec::new(); + for row in rows { + let mut value = IndexMap::default(); + for (i, column) in row.columns().iter().enumerate() { + let v = row.try_get_raw(i)?; + + let v = crate::decode::postgres::to_json(v)?; + + value.insert(column.name().to_string(), v); + } + + values.push(value); + } + values + } + #[cfg(not(any(feature = "sqlite", feature = "mysql", feature = "postgres")))] + DbPool::None => Vec::new(), + }) + } +} + +#[cfg(feature = "sqlite")] +/// Maps the user supplied DB connection string to a connection string +/// with a fully qualified file path to the App's designed "app_path" +fn path_mapper(mut app_path: std::path::PathBuf, connection_string: &str) -> String { + app_path.push( + connection_string + .split_once(':') + .expect("Couldn't parse the connection string for DB!") + .1, + ); + + format!( + "sqlite:{}", + app_path + .to_str() + .expect("Problem creating fully qualified path to Database file!") + ) +} diff --git a/plugins/store/.gitignore b/plugins/store/.gitignore deleted file mode 100644 index b512c09d..00000000 --- a/plugins/store/.gitignore +++ /dev/null @@ -1 +0,0 @@ -node_modules \ No newline at end of file diff --git a/plugins/store/CHANGELOG.md b/plugins/store/CHANGELOG.md index 3109c03f..fa4e13b1 100644 --- a/plugins/store/CHANGELOG.md +++ b/plugins/store/CHANGELOG.md @@ -1,5 +1,112 @@ # Changelog +## \[2.2.0] + +- [`3a79266b`](https://github.com/tauri-apps/plugins-workspace/commit/3a79266b8cf96a55b1ae6339d725567d45a44b1d) ([#2173](https://github.com/tauri-apps/plugins-workspace/pull/2173) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Bumped all plugins to `v2.2.0`. From now, the versions for the Rust and JavaScript packages of each plugin will be in sync with each other. + +## \[2.1.0] + +### feat + +- [`8c67d44a`](https://github.com/tauri-apps/plugins-workspace/commit/8c67d44aef60b1427019538d8420787ef35bd3d5) ([#1860](https://github.com/tauri-apps/plugins-workspace/pull/1860) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) - Add `getStore` + - Add an option to use pre-stored (de)serialize functions (registered on rust) + - Add `LazyStore` + +## \[2.0.1] + +- [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. + +## \[2.0.0] + +- [`e2c4dfb6`](https://github.com/tauri-apps/plugins-workspace/commit/e2c4dfb6af43e5dd8d9ceba232c315f5febd55c1) Update to tauri v2 stable release. + +## \[2.0.0-rc.2] + +- [`f12d3560`](https://github.com/tauri-apps/plugins-workspace/commit/f12d35609ab84f536c0f087665fdc1f978af3093) ([#1550](https://github.com/tauri-apps/plugins-workspace/pull/1550) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) **Breaking change**: Removed the `Store` constructor and added the `createStore` API. + +## \[2.0.0-rc.1] + +- [`e2e97db5`](https://github.com/tauri-apps/plugins-workspace/commit/e2e97db51983267f5be84d4f6f0278d58834d1f5) ([#1701](https://github.com/tauri-apps/plugins-workspace/pull/1701) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri 2.0.0-rc.8 + +## \[2.0.0-rc.2] + +- [`b9147758`](https://github.com/tauri-apps/plugins-workspace/commit/b914775898c2bee7ceb20bd17ee595005cd17a64) ([#1679](https://github.com/tauri-apps/plugins-workspace/pull/1679) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Explicitly set a minimum macOS version for the Swift package. + +## \[2.0.0-rc.1] + +### changes + +- [`6b079cfd`](https://github.com/tauri-apps/plugins-workspace/commit/6b079cfdd107c94abc2c7300f6af00bac3ff4040) ([#1649](https://github.com/tauri-apps/plugins-workspace/pull/1649) by [@ahqsoftwares](https://github.com/tauri-apps/plugins-workspace/../../ahqsoftwares)) Remove targetSdk from build.kts files as it is deprecated and will be removed from DSL v9.0 + +## \[2.0.0-rc.0] + +- [`9887d1`](https://github.com/tauri-apps/plugins-workspace/commit/9887d14bd0e971c4c0f5c1188fc4005d3fc2e29e) Update to tauri RC. + +## \[2.0.0-beta.8] + +- [`99d6ac0f`](https://github.com/tauri-apps/plugins-workspace/commit/99d6ac0f9506a6a4a1aa59c728157190a7441af6) ([#1606](https://github.com/tauri-apps/plugins-workspace/pull/1606) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) The JS packages now specify the *minimum* `@tauri-apps/api` version instead of a single exact version. +- [`6de87966`](https://github.com/tauri-apps/plugins-workspace/commit/6de87966ecc00ad9d91c25be452f1f46bd2b7e1f) ([#1597](https://github.com/tauri-apps/plugins-workspace/pull/1597) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Update to tauri beta.25. + +## \[2.0.0-beta.7] + +- [`22a17980`](https://github.com/tauri-apps/plugins-workspace/commit/22a17980ff4f6f8c40adb1b8f4ffc6dae2fe7e30) ([#1537](https://github.com/tauri-apps/plugins-workspace/pull/1537) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri beta.24. + +## \[2.0.0-beta.6] + +- [`76daee7a`](https://github.com/tauri-apps/plugins-workspace/commit/76daee7aafece34de3092c86e531cf9eb1138989) ([#1512](https://github.com/tauri-apps/plugins-workspace/pull/1512) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Update to tauri beta.23. + +## \[2.0.0-beta.5] + +- [`9013854f`](https://github.com/tauri-apps/plugins-workspace/commit/9013854f42a49a230b9dbb9d02774765528a923f)([#1382](https://github.com/tauri-apps/plugins-workspace/pull/1382)) Update to tauri beta.22. + +## \[2.0.0-beta.4] + +- [`430bd6f4`](https://github.com/tauri-apps/plugins-workspace/commit/430bd6f4f379bee5d232ae6b098ae131db7f178a)([#1363](https://github.com/tauri-apps/plugins-workspace/pull/1363)) Update to tauri beta.20. + +## \[2.0.0-beta.3] + +- [`bd1ed590`](https://github.com/tauri-apps/plugins-workspace/commit/bd1ed5903ffcce5500310dac1e59e8c67674ef1e)([#1237](https://github.com/tauri-apps/plugins-workspace/pull/1237)) Update to tauri beta.17. + +## \[2.0.0-beta.5] + +- [`bb51a41`](https://github.com/tauri-apps/plugins-workspace/commit/bb51a41d67ebf989e8aedf10c4b1a7f9514d1bdf)([#1168](https://github.com/tauri-apps/plugins-workspace/pull/1168)) **Breaking Change:** All apis that return paths to the frontend will now remove the `\\?\` UNC prefix on Windows. + +## \[2.0.0-beta.4] + +- [`a04ea2f`](https://github.com/tauri-apps/plugins-workspace/commit/a04ea2f38294d5a3987578283badc8eec87a7752)([#1071](https://github.com/tauri-apps/plugins-workspace/pull/1071)) The global API script is now only added to the binary when the `withGlobalTauri` config is true. + +## \[2.0.0-beta.3] + +- [`79691e9`](https://github.com/tauri-apps/plugins-workspace/commit/79691e93e04b820e44dce1c7d91b8865fa6ccb14)([#1040](https://github.com/tauri-apps/plugins-workspace/pull/1040)) Fix `with_store` and `StoreCollection` changed to private in #1011 + +## \[2.0.0-beta.2] + +- [`99bea25`](https://github.com/tauri-apps/plugins-workspace/commit/99bea2559c2c0648c2519c50a18cd124dacef57b)([#1005](https://github.com/tauri-apps/plugins-workspace/pull/1005)) Update to tauri beta.8. + +## \[2.0.0-beta.1] + +- [`569defb`](https://github.com/tauri-apps/plugins-workspace/commit/569defbe9492e38938554bb7bdc1be9151456d21) Update to tauri beta.4. + +## \[2.0.0-beta.0] + +- [`d198c01`](https://github.com/tauri-apps/plugins-workspace/commit/d198c014863ee260cb0de88a14b7fc4356ef7474)([#862](https://github.com/tauri-apps/plugins-workspace/pull/862)) Update to tauri beta. + +## \[2.0.0-alpha.5] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.13. + +## \[2.0.0-alpha.4] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.12. + +## \[2.0.0-alpha.3] + +- [`e438e0a`](https://github.com/tauri-apps/plugins-workspace/commit/e438e0a62d4b430a5159f05f13ecd397dd891a0d)([#676](https://github.com/tauri-apps/plugins-workspace/pull/676)) Update to @tauri-apps/api v2.0.0-alpha.11. + +## \[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.9. + ## \[2.0.0-alpha.2] - [`4e2cef9`](https://github.com/tauri-apps/plugins-workspace/commit/4e2cef9b702bbbb9cf4ee17de50791cb21f1b2a4)([#593](https://github.com/tauri-apps/plugins-workspace/pull/593)) Update to alpha.12. @@ -10,9 +117,4 @@ ## \[2.0.0-alpha.0] -- [`717ae67`](https://github.com/tauri-apps/plugins-workspace/commit/717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! - te to alpha.11. - -## \[2.0.0-alpha.0] - - [`717ae67`](https://github.com/tauri-apps/plugins-workspace/commit/717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! diff --git a/plugins/store/Cargo.toml b/plugins/store/Cargo.toml index ea12a464..1ed19962 100644 --- a/plugins/store/Cargo.toml +++ b/plugins/store/Cargo.toml @@ -1,18 +1,39 @@ [package] name = "tauri-plugin-store" -version = "2.0.0-alpha.2" +version = "2.2.0" description = "Simple, persistent key-value store." authors = { workspace = true } license = { workspace = true } edition = { workspace = true } rust-version = { workspace = true } +repository = { workspace = true } +links = "tauri-plugin-store" [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] + +[package.metadata.platforms.support] +windows = { level = "full", notes = "" } +linux = { level = "full", notes = "" } +macos = { level = "full", notes = "" } +android = { level = "full", notes = "" } +ios = { level = "full", notes = "" } + +[build-dependencies] +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } serde_json = { workspace = true } tauri = { workspace = true } -log = { workspace = true } +tracing = { workspace = true } thiserror = { workspace = true } +dunce = { workspace = true } +tokio = { version = "1", features = ["sync", "time", "macros"] } + +[target.'cfg(target_os = "ios")'.dependencies] +tauri = { workspace = true, features = ["wry"] } + +[dev-dependencies] +tauri = { workspace = true, features = ["wry"] } diff --git a/plugins/store/README.md b/plugins/store/README.md index d375db2e..8a2fcbf7 100644 --- a/plugins/store/README.md +++ b/plugins/store/README.md @@ -2,9 +2,17 @@ Simple, persistent key-value store. +| Platform | Supported | +| -------- | --------- | +| Linux | ✓ | +| Windows | ✓ | +| macOS | ✓ | +| Android | ✓ | +| iOS | ✓ | + ## Install -_This plugin requires a Rust version of at least **1.70**_ +_This plugin requires a Rust version of at least **1.77.2**_ There are three general methods of installation that we can recommend. @@ -18,7 +26,7 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] -tauri-plugin-store = "2.0.0-alpha" +tauri-plugin-store = "2.0.0" # alternatively with Git: tauri-plugin-store = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -46,7 +54,7 @@ yarn add https://github.com/tauri-apps/tauri-plugin-store#v2 First you need to register the core plugin with Tauri: -`src-tauri/src/main.rs` +`src-tauri/src/lib.rs` ```rust fn main() { @@ -59,63 +67,98 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: -```javascript -import { Store } from "@tauri-apps/plugin-store"; +```typescript +import { Store } from '@tauri-apps/plugin-store' + +const store = await Store.load('settings.json') + +await store.set('some-key', { value: 5 }) + +const val = await store.get<{ value: number }>('some-key') + +if (val) { + console.log(val) +} else { + console.log('val is null') +} +``` + +### Persisting Values + +Modifications made to the store are automatically saved by default -const store = new Store(".settings.dat"); +You can manually save a store with: -await store.set("some-key", { value: 5 }); +```javascript +await store.save() +``` -const val = await store.get("some-key"); -assert(val, { value: 5 }); +Stores are loaded automatically when used from the JavaScript bindings. +However, you can also load them manually later like so: -await store.save(); // this manually saves the store, otherwise the store is only saved when your app is closed +```javascript +await store.load() ``` -### Persisting values +### LazyStore -Values added to the store are not persisted between application loads unless: +There's also a high level API `LazyStore` which only loads the store on first access, note that the options will be ignored if a `Store` with that path has already been created -1. The application is closed gracefully (plugin automatically saves) -2. The store is manually saved (using `store.save()`) +```typescript +import { LazyStore } from '@tauri-apps/plugin-store' + +const store = new LazyStore('settings.json') +``` ## Usage from Rust -You can also access Stores from Rust, you can create new stores: +You can also create `Store` instances directly in Rust: ```rust -use tauri_plugin_store::StoreBuilder; +use tauri_plugin_store::StoreExt; use serde_json::json; fn main() { tauri::Builder::default() .plugin(tauri_plugin_store::Builder::default().build()) .setup(|app| { - let mut store = StoreBuilder::new(app.handle(), "path/to/store.bin".parse()?).build(); + // This loads the store from disk + let store = app.store("app_data.json")?; - store.insert("a".to_string(), json!("b")) // note that values must be serd_json::Value to be compatible with JS + // Note that values must be serde_json::Value instances, + // otherwise, they will not be compatible with the JavaScript bindings. + store.set("a".to_string(), json!("b")); + Ok(()) }) .run(tauri::generate_context!()) .expect("error while running tauri application"); } ``` -As you may have noticed, the Store crated above isn't accessible to the frontend. To interoperate with stores created by JS use the exported `with_store` method: +### Frontend Interoperability -```rust -use tauri::Wry; -use tauri_plugin_store::with_store; - -let stores = app.state::>(); -let path = PathBuf::from("path/to/the/storefile"); - -with_store(app_handle, stores, path, |store| store.insert("a".to_string(), json!("b"))) -``` +The store created from both Rust side and JavaScript side are stored in the app's resource table and can be accessed by both sides, you can access it by using the same path, with `getStore` and `LazyStore` in the JavaScript side and `get_store` and `store` in the Rust side ## Contributing PRs accepted. Please make sure to read the Contributing Guide before making a pull request. +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + ## License Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. diff --git a/plugins/store/SECURITY.md b/plugins/store/SECURITY.md new file mode 100644 index 00000000..4f09bbac --- /dev/null +++ b/plugins/store/SECURITY.md @@ -0,0 +1,23 @@ +# Security Policy + +**Do not report security vulnerabilities through public GitHub issues.** + +**Please use the [Private Vulnerability Disclosure](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) feature of GitHub.** + +Include as much of the following information: + +- Type of issue (e.g. improper input parsing, privilege escalation, etc.) +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- The distribution affected or used to help us with reproduction of the issue +- Step-by-step instructions to reproduce the issue +- Ideally a reproduction repository +- Impact of the issue, including how an attacker might exploit the issue + +We prefer to receive reports in English. + +## Contact + +Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). + +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/store/api-iife.js b/plugins/store/api-iife.js new file mode 100644 index 00000000..61dc5df4 --- /dev/null +++ b/plugins/store/api-iife.js @@ -0,0 +1 @@ +if("__TAURI__"in window){var __TAURI_PLUGIN_STORE__=function(t){"use strict";var e,a;function r(t,e=!1){return window.__TAURI_INTERNALS__.transformCallback(t,e)}async function s(t,e={},a){return window.__TAURI_INTERNALS__.invoke(t,e,a)}"function"==typeof SuppressedError&&SuppressedError;class i{get rid(){return function(t,e,a,r){if("function"==typeof e||!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?r:"a"===a?r.call(t):r?r.value:e.get(t)}(this,e,"f")}constructor(t){e.set(this,void 0),function(t,e,a){if("function"==typeof e||!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");e.set(t,a)}(this,e,t)}async close(){return s("plugin:resources|close",{rid:this.rid})}}async function n(t,e,a){const i={kind:"Any"};return s("plugin:event|listen",{event:t,target:i,handler:r(e)}).then((e=>async()=>async function(t,e){await s("plugin:event|unlisten",{event:t,eventId:e})}(t,e)))}async function o(t,e){return await u.load(t,e)}e=new WeakMap,function(t){t.WINDOW_RESIZED="tauri://resize",t.WINDOW_MOVED="tauri://move",t.WINDOW_CLOSE_REQUESTED="tauri://close-requested",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_CREATED="tauri://window-created",t.WEBVIEW_CREATED="tauri://webview-created",t.DRAG_ENTER="tauri://drag-enter",t.DRAG_OVER="tauri://drag-over",t.DRAG_DROP="tauri://drag-drop",t.DRAG_LEAVE="tauri://drag-leave"}(a||(a={}));class u extends i{constructor(t){super(t)}static async load(t,e){const a=await s("plugin:store|load",{path:t,...e});return new u(a)}static async get(t){return await s("plugin:store|get_store",{path:t}).then((t=>t?new u(t):null))}async set(t,e){await s("plugin:store|set",{rid:this.rid,key:t,value:e})}async get(t){const[e,a]=await s("plugin:store|get",{rid:this.rid,key:t});return a?e:void 0}async has(t){return await s("plugin:store|has",{rid:this.rid,key:t})}async delete(t){return await s("plugin:store|delete",{rid:this.rid,key:t})}async clear(){await s("plugin:store|clear",{rid:this.rid})}async reset(){await s("plugin:store|reset",{rid:this.rid})}async keys(){return await s("plugin:store|keys",{rid:this.rid})}async values(){return await s("plugin:store|values",{rid:this.rid})}async entries(){return await s("plugin:store|entries",{rid:this.rid})}async length(){return await s("plugin:store|length",{rid:this.rid})}async reload(){await s("plugin:store|reload",{rid:this.rid})}async save(){await s("plugin:store|save",{rid:this.rid})}async onKeyChange(t,e){return await n("store://change",(a=>{a.payload.resourceId===this.rid&&a.payload.key===t&&e(a.payload.exists?a.payload.value:void 0)}))}async onChange(t){return await n("store://change",(e=>{e.payload.resourceId===this.rid&&t(e.payload.key,e.payload.exists?e.payload.value:void 0)}))}}return t.LazyStore=class{get store(){return this._store||(this._store=o(this.path,this.options)),this._store}constructor(t,e){this.path=t,this.options=e}async init(){await this.store}async set(t,e){return(await this.store).set(t,e)}async get(t){return(await this.store).get(t)}async has(t){return(await this.store).has(t)}async delete(t){return(await this.store).delete(t)}async clear(){await(await this.store).clear()}async reset(){await(await this.store).reset()}async keys(){return(await this.store).keys()}async values(){return(await this.store).values()}async entries(){return(await this.store).entries()}async length(){return(await this.store).length()}async reload(){await(await this.store).reload()}async save(){await(await this.store).save()}async onKeyChange(t,e){return(await this.store).onKeyChange(t,e)}async onChange(t){return(await this.store).onChange(t)}async close(){this._store&&await(await this._store).close()}},t.Store=u,t.getStore=async function(t){return await u.get(t)},t.load=o,t}({});Object.defineProperty(window.__TAURI__,"store",{value:__TAURI_PLUGIN_STORE__})} diff --git a/plugins/store/build.rs b/plugins/store/build.rs new file mode 100644 index 00000000..2e88d59a --- /dev/null +++ b/plugins/store/build.rs @@ -0,0 +1,26 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +const COMMANDS: &[&str] = &[ + "load", + "get_store", + "set", + "get", + "has", + "delete", + "clear", + "reset", + "keys", + "values", + "entries", + "length", + "reload", + "save", +]; + +fn main() { + tauri_plugin::Builder::new(COMMANDS) + .global_api_script_path("./api-iife.js") + .build(); +} diff --git a/plugins/store/examples/AppSettingsManager/.gitignore b/plugins/store/examples/AppSettingsManager/.gitignore new file mode 100644 index 00000000..a9b26d1f --- /dev/null +++ b/plugins/store/examples/AppSettingsManager/.gitignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +#dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/plugins/store/examples/AppSettingsManager/.vscode/extensions.json b/plugins/store/examples/AppSettingsManager/.vscode/extensions.json new file mode 100644 index 00000000..24d7cc6d --- /dev/null +++ b/plugins/store/examples/AppSettingsManager/.vscode/extensions.json @@ -0,0 +1,3 @@ +{ + "recommendations": ["tauri-apps.tauri-vscode", "rust-lang.rust-analyzer"] +} diff --git a/plugins/store/examples/AppSettingsManager/README.md b/plugins/store/examples/AppSettingsManager/README.md new file mode 100644 index 00000000..b381dcf5 --- /dev/null +++ b/plugins/store/examples/AppSettingsManager/README.md @@ -0,0 +1,7 @@ +# Tauri + Vanilla TS + +This template should help get you started developing with Tauri in vanilla HTML, CSS and Typescript. + +## Recommended IDE Setup + +- [VS Code](https://code.visualstudio.com/) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer) diff --git a/plugins/store/examples/AppSettingsManager/dist/.gitkeep b/plugins/store/examples/AppSettingsManager/dist/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/plugins/store/examples/AppSettingsManager/index.html b/plugins/store/examples/AppSettingsManager/index.html new file mode 100644 index 00000000..7c268692 --- /dev/null +++ b/plugins/store/examples/AppSettingsManager/index.html @@ -0,0 +1,54 @@ + + + + + + + Tauri App + + + + + +
+ + diff --git a/plugins/store/examples/AppSettingsManager/package.json b/plugins/store/examples/AppSettingsManager/package.json new file mode 100644 index 00000000..59fe89da --- /dev/null +++ b/plugins/store/examples/AppSettingsManager/package.json @@ -0,0 +1,15 @@ +{ + "private": true, + "type": "module", + "scripts": { + "dev": "vite", + "build": "tsc && vite build", + "preview": "vite preview", + "tauri": "tauri" + }, + "devDependencies": { + "@tauri-apps/cli": "2.5.0", + "typescript": "^5.7.3", + "vite": "^6.2.6" + } +} diff --git a/plugins/store/examples/AppSettingsManager/src-tauri/.gitignore b/plugins/store/examples/AppSettingsManager/src-tauri/.gitignore new file mode 100644 index 00000000..043cc4af --- /dev/null +++ b/plugins/store/examples/AppSettingsManager/src-tauri/.gitignore @@ -0,0 +1,4 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ +gen/schemas diff --git a/plugins/store/examples/AppSettingsManager/src-tauri/Cargo.toml b/plugins/store/examples/AppSettingsManager/src-tauri/Cargo.toml new file mode 100644 index 00000000..7c60d516 --- /dev/null +++ b/plugins/store/examples/AppSettingsManager/src-tauri/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "app_settings_manager" +version = "0.0.0" +description = "A Tauri App" +authors = ["you"] +license = "" +repository = "" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[build-dependencies] +tauri-build = { workspace = true } + +[dependencies] +tauri = { workspace = true, features = ["wry", "compression"] } +serde = { workspace = true } +serde_json = { workspace = true } +tauri-plugin-store = { path = "../../../" } + +[features] +# this feature is used for production builds or when `devPath` points to the filesystem +# DO NOT REMOVE!! +prod = ["tauri/custom-protocol"] diff --git a/plugins/websocket/examples/svelte-app/src/routes/+layout.ts b/plugins/store/examples/AppSettingsManager/src-tauri/build.rs similarity index 71% rename from plugins/websocket/examples/svelte-app/src/routes/+layout.ts rename to plugins/store/examples/AppSettingsManager/src-tauri/build.rs index 050af12d..5ebf8d2f 100644 --- a/plugins/websocket/examples/svelte-app/src/routes/+layout.ts +++ b/plugins/store/examples/AppSettingsManager/src-tauri/build.rs @@ -2,5 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -export const prerender = true; -export const ssr = false; +fn main() { + tauri_build::build() +} diff --git a/plugins/store/examples/AppSettingsManager/src-tauri/icons/128x128.png b/plugins/store/examples/AppSettingsManager/src-tauri/icons/128x128.png new file mode 100644 index 00000000..6be5e50e Binary files /dev/null and b/plugins/store/examples/AppSettingsManager/src-tauri/icons/128x128.png differ diff --git a/plugins/store/examples/AppSettingsManager/src-tauri/icons/128x128@2x.png b/plugins/store/examples/AppSettingsManager/src-tauri/icons/128x128@2x.png new file mode 100644 index 00000000..e81becee Binary files /dev/null and b/plugins/store/examples/AppSettingsManager/src-tauri/icons/128x128@2x.png differ diff --git a/plugins/store/examples/AppSettingsManager/src-tauri/icons/32x32.png b/plugins/store/examples/AppSettingsManager/src-tauri/icons/32x32.png new file mode 100644 index 00000000..a437dd51 Binary files /dev/null and b/plugins/store/examples/AppSettingsManager/src-tauri/icons/32x32.png differ diff --git a/plugins/store/examples/AppSettingsManager/src-tauri/icons/Square107x107Logo.png b/plugins/store/examples/AppSettingsManager/src-tauri/icons/Square107x107Logo.png new file mode 100644 index 00000000..0ca4f271 Binary files /dev/null and b/plugins/store/examples/AppSettingsManager/src-tauri/icons/Square107x107Logo.png differ diff --git a/plugins/store/examples/AppSettingsManager/src-tauri/icons/Square142x142Logo.png b/plugins/store/examples/AppSettingsManager/src-tauri/icons/Square142x142Logo.png new file mode 100644 index 00000000..b81f8203 Binary files /dev/null and b/plugins/store/examples/AppSettingsManager/src-tauri/icons/Square142x142Logo.png differ diff --git a/plugins/store/examples/AppSettingsManager/src-tauri/icons/Square150x150Logo.png b/plugins/store/examples/AppSettingsManager/src-tauri/icons/Square150x150Logo.png new file mode 100644 index 00000000..624c7bfb Binary files /dev/null and b/plugins/store/examples/AppSettingsManager/src-tauri/icons/Square150x150Logo.png differ diff --git a/plugins/store/examples/AppSettingsManager/src-tauri/icons/Square284x284Logo.png b/plugins/store/examples/AppSettingsManager/src-tauri/icons/Square284x284Logo.png new file mode 100644 index 00000000..c021d2ba Binary files /dev/null and b/plugins/store/examples/AppSettingsManager/src-tauri/icons/Square284x284Logo.png differ diff --git a/plugins/store/examples/AppSettingsManager/src-tauri/icons/Square30x30Logo.png b/plugins/store/examples/AppSettingsManager/src-tauri/icons/Square30x30Logo.png new file mode 100644 index 00000000..62197002 Binary files /dev/null and b/plugins/store/examples/AppSettingsManager/src-tauri/icons/Square30x30Logo.png differ diff --git a/plugins/store/examples/AppSettingsManager/src-tauri/icons/Square310x310Logo.png b/plugins/store/examples/AppSettingsManager/src-tauri/icons/Square310x310Logo.png new file mode 100644 index 00000000..f9bc0483 Binary files /dev/null and b/plugins/store/examples/AppSettingsManager/src-tauri/icons/Square310x310Logo.png differ diff --git a/plugins/store/examples/AppSettingsManager/src-tauri/icons/Square44x44Logo.png b/plugins/store/examples/AppSettingsManager/src-tauri/icons/Square44x44Logo.png new file mode 100644 index 00000000..d5fbfb2a Binary files /dev/null and b/plugins/store/examples/AppSettingsManager/src-tauri/icons/Square44x44Logo.png differ diff --git a/plugins/store/examples/AppSettingsManager/src-tauri/icons/Square71x71Logo.png b/plugins/store/examples/AppSettingsManager/src-tauri/icons/Square71x71Logo.png new file mode 100644 index 00000000..63440d79 Binary files /dev/null and b/plugins/store/examples/AppSettingsManager/src-tauri/icons/Square71x71Logo.png differ diff --git a/plugins/store/examples/AppSettingsManager/src-tauri/icons/Square89x89Logo.png b/plugins/store/examples/AppSettingsManager/src-tauri/icons/Square89x89Logo.png new file mode 100644 index 00000000..f3f705af Binary files /dev/null and b/plugins/store/examples/AppSettingsManager/src-tauri/icons/Square89x89Logo.png differ diff --git a/plugins/store/examples/AppSettingsManager/src-tauri/icons/StoreLogo.png b/plugins/store/examples/AppSettingsManager/src-tauri/icons/StoreLogo.png new file mode 100644 index 00000000..45563882 Binary files /dev/null and b/plugins/store/examples/AppSettingsManager/src-tauri/icons/StoreLogo.png differ diff --git a/plugins/store/examples/AppSettingsManager/src-tauri/icons/icon.icns b/plugins/store/examples/AppSettingsManager/src-tauri/icons/icon.icns new file mode 100644 index 00000000..12a5bcee Binary files /dev/null and b/plugins/store/examples/AppSettingsManager/src-tauri/icons/icon.icns differ diff --git a/plugins/store/examples/AppSettingsManager/src-tauri/icons/icon.ico b/plugins/store/examples/AppSettingsManager/src-tauri/icons/icon.ico new file mode 100644 index 00000000..b3636e4b Binary files /dev/null and b/plugins/store/examples/AppSettingsManager/src-tauri/icons/icon.ico differ diff --git a/plugins/store/examples/AppSettingsManager/src-tauri/icons/icon.png b/plugins/store/examples/AppSettingsManager/src-tauri/icons/icon.png new file mode 100644 index 00000000..e1cd2619 Binary files /dev/null and b/plugins/store/examples/AppSettingsManager/src-tauri/icons/icon.png differ diff --git a/plugins/store/examples/AppSettingsManager/src-tauri/src/app/mod.rs b/plugins/store/examples/AppSettingsManager/src-tauri/src/app/mod.rs new file mode 100644 index 00000000..e8c1bb01 --- /dev/null +++ b/plugins/store/examples/AppSettingsManager/src-tauri/src/app/mod.rs @@ -0,0 +1,5 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +pub mod settings; diff --git a/plugins/store/examples/AppSettingsManager/src-tauri/src/app/settings.rs b/plugins/store/examples/AppSettingsManager/src-tauri/src/app/settings.rs new file mode 100644 index 00000000..30514a00 --- /dev/null +++ b/plugins/store/examples/AppSettingsManager/src-tauri/src/app/settings.rs @@ -0,0 +1,32 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use tauri_plugin_store::Store; + +#[derive(Debug, Clone)] +pub struct AppSettings { + pub launch_at_login: bool, + pub theme: String, +} + +impl AppSettings { + pub fn load_from_store( + store: &Store, + ) -> Result> { + let launch_at_login = store + .get("appSettings.launchAtLogin") + .and_then(|v| v.as_bool()) + .unwrap_or(false); + + let theme = store + .get("appSettings.theme") + .and_then(|v| v.as_str().map(String::from)) + .unwrap_or_else(|| "dark".to_owned()); + + Ok(AppSettings { + launch_at_login, + theme, + }) + } +} diff --git a/plugins/store/examples/AppSettingsManager/src-tauri/src/main.rs b/plugins/store/examples/AppSettingsManager/src-tauri/src/main.rs new file mode 100644 index 00000000..f20db4fc --- /dev/null +++ b/plugins/store/examples/AppSettingsManager/src-tauri/src/main.rs @@ -0,0 +1,47 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +// Prevents additional console window on Windows in release, DO NOT REMOVE!! +#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] + +use serde_json::json; +use tauri::Listener; +use tauri_plugin_store::StoreExt; + +mod app; +use app::settings::AppSettings; + +fn main() { + tauri::Builder::default() + .plugin(tauri_plugin_store::Builder::new().build()) + .setup(|app| { + // Init store and load it from disk + let store = app.store("settings.json")?; + app.listen("store://change", |event| { + dbg!(event); + }); + let app_settings = AppSettings::load_from_store(&store); + match app_settings { + Ok(app_settings) => { + let theme = app_settings.theme; + let launch_at_login = app_settings.launch_at_login; + + println!("theme {theme}"); + println!("launch_at_login {launch_at_login}"); + store.set( + "appSettings", + json!({ "theme": theme, "launchAtLogin": launch_at_login }), + ); + } + Err(err) => { + eprintln!("Error loading settings: {err}"); + // Handle the error case if needed + return Err(err); // Convert the error to a Box and return Err(err) here + } + } + Ok(()) + }) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} diff --git a/plugins/store/examples/AppSettingsManager/src-tauri/tauri.conf.json b/plugins/store/examples/AppSettingsManager/src-tauri/tauri.conf.json new file mode 100644 index 00000000..d3f60daa --- /dev/null +++ b/plugins/store/examples/AppSettingsManager/src-tauri/tauri.conf.json @@ -0,0 +1,34 @@ +{ + "productName": "app", + "version": "0.1.0", + "identifier": "com.tauri.app-settings-manager", + "build": { + "devUrl": "http://localhost:1420", + "frontendDist": "../dist" + }, + "app": { + "windows": [ + { + "title": "app", + "width": 800, + "height": 600, + "resizable": true, + "fullscreen": false + } + ], + "security": { + "csp": "default-src blob: data: filesystem: ws: wss: http: https: tauri: http://tauri.localhost 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'" + } + }, + "bundle": { + "active": true, + "targets": "all", + "icon": [ + "icons/32x32.png", + "icons/128x128.png", + "icons/128x128@2x.png", + "icons/icon.icns", + "icons/icon.ico" + ] + } +} diff --git a/plugins/store/examples/AppSettingsManager/src/assets/tauri.svg b/plugins/store/examples/AppSettingsManager/src/assets/tauri.svg new file mode 100644 index 00000000..31b62c92 --- /dev/null +++ b/plugins/store/examples/AppSettingsManager/src/assets/tauri.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/plugins/store/examples/AppSettingsManager/src/assets/typescript.svg b/plugins/store/examples/AppSettingsManager/src/assets/typescript.svg new file mode 100644 index 00000000..30a5edd3 --- /dev/null +++ b/plugins/store/examples/AppSettingsManager/src/assets/typescript.svg @@ -0,0 +1,25 @@ + + + + + + + + diff --git a/plugins/store/examples/AppSettingsManager/src/assets/vite.svg b/plugins/store/examples/AppSettingsManager/src/assets/vite.svg new file mode 100644 index 00000000..e7b8dfb1 --- /dev/null +++ b/plugins/store/examples/AppSettingsManager/src/assets/vite.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/plugins/store/examples/AppSettingsManager/src/main.ts b/plugins/store/examples/AppSettingsManager/src/main.ts new file mode 100644 index 00000000..57cbe4b7 --- /dev/null +++ b/plugins/store/examples/AppSettingsManager/src/main.ts @@ -0,0 +1,9 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +window.addEventListener('DOMContentLoaded', () => { + document.querySelector('#greet-form')?.addEventListener('submit', (e) => { + e.preventDefault() + }) +}) diff --git a/plugins/store/examples/AppSettingsManager/src/styles.css b/plugins/store/examples/AppSettingsManager/src/styles.css new file mode 100644 index 00000000..f7de85bf --- /dev/null +++ b/plugins/store/examples/AppSettingsManager/src/styles.css @@ -0,0 +1,109 @@ +:root { + font-family: Inter, Avenir, Helvetica, Arial, sans-serif; + font-size: 16px; + line-height: 24px; + font-weight: 400; + + color: #0f0f0f; + background-color: #f6f6f6; + + font-synthesis: none; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + -webkit-text-size-adjust: 100%; +} + +.container { + margin: 0; + padding-top: 10vh; + display: flex; + flex-direction: column; + justify-content: center; + text-align: center; +} + +.logo { + height: 6em; + padding: 1.5em; + will-change: filter; + transition: 0.75s; +} + +.logo.tauri:hover { + filter: drop-shadow(0 0 2em #24c8db); +} + +.row { + display: flex; + justify-content: center; +} + +a { + font-weight: 500; + color: #646cff; + text-decoration: inherit; +} + +a:hover { + color: #535bf2; +} + +h1 { + text-align: center; +} + +input, +button { + border-radius: 8px; + border: 1px solid transparent; + padding: 0.6em 1.2em; + font-size: 1em; + font-weight: 500; + font-family: inherit; + color: #0f0f0f; + background-color: #ffffff; + transition: border-color 0.25s; + box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2); +} + +button { + cursor: pointer; +} + +button:hover { + border-color: #396cd8; +} +button:active { + border-color: #396cd8; + background-color: #e8e8e8; +} + +input, +button { + outline: none; +} + +#greet-input { + margin-right: 5px; +} + +@media (prefers-color-scheme: dark) { + :root { + color: #f6f6f6; + background-color: #2f2f2f; + } + + a:hover { + color: #24c8db; + } + + input, + button { + color: #ffffff; + background-color: #0f0f0f98; + } + button:active { + background-color: #0f0f0f69; + } +} diff --git a/plugins/store/examples/AppSettingsManager/tsconfig.json b/plugins/store/examples/AppSettingsManager/tsconfig.json new file mode 100644 index 00000000..75abdef2 --- /dev/null +++ b/plugins/store/examples/AppSettingsManager/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "module": "ESNext", + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src"] +} diff --git a/plugins/store/examples/AppSettingsManager/vite.config.ts b/plugins/store/examples/AppSettingsManager/vite.config.ts new file mode 100644 index 00000000..661eb233 --- /dev/null +++ b/plugins/store/examples/AppSettingsManager/vite.config.ts @@ -0,0 +1,21 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import { defineConfig } from 'vite' + +// https://vitejs.dev/config/ +export default defineConfig(async () => ({ + // Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build` + // + // 1. prevent vite from obscuring rust errors + clearScreen: false, + // 2. tauri expects a fixed port, fail if that port is not available + server: { + port: 1420, + strictPort: true + }, + // 3. to make use of `TAURI_DEBUG` and other env variables + // https://tauri.studio/v1/api/config#buildconfig.beforedevcommand + envPrefix: ['VITE_', 'TAURI_'] +})) diff --git a/plugins/store/guest-js/index.ts b/plugins/store/guest-js/index.ts index 40137ed0..1df89fd5 100644 --- a/plugins/store/guest-js/index.ts +++ b/plugins/store/guest-js/index.ts @@ -2,25 +2,318 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { listen, UnlistenFn } from "@tauri-apps/api/event"; +import { listen, type UnlistenFn } from '@tauri-apps/api/event' -import { invoke } from "@tauri-apps/api/primitives"; +import { invoke, Resource } from '@tauri-apps/api/core' interface ChangePayload { - path: string; - key: string; - value: T | null; + path: string + resourceId?: number + key: string + value: T + exists: boolean +} + +/** + * Options to create a store + */ +export type StoreOptions = { + /** + * Auto save on modification with debounce duration in milliseconds, it's 100ms by default, pass in `false` to disable it + */ + autoSave?: boolean | number + /** + * Name of a serialize function registered in the rust side plugin builder + */ + serializeFnName?: string + /** + * Name of a deserialize function registered in the rust side plugin builder + */ + deserializeFnName?: string + /** + * Force create a new store with default values even if it already exists. + */ + createNew?: boolean +} + +/** + * Create a new Store or load the existing store with the path. + * + * @example + * ```typescript + * import { Store } from '@tauri-apps/api/store'; + * const store = await Store.load('store.json'); + * ``` + * + * @param path Path to save the store in `app_data_dir` + * @param options Store configuration options + */ +export async function load( + path: string, + options?: StoreOptions +): Promise { + return await Store.load(path, options) +} + +/** + * Gets an already loaded store. + * + * If the store is not loaded, returns `null`. In this case you must {@link Store.load load} it. + * + * This function is more useful when you already know the store is loaded + * and just need to access its instance. Prefer {@link Store.load} otherwise. + * + * @example + * ```typescript + * import { getStore } from '@tauri-apps/api/store'; + * const store = await getStore('store.json'); + * ``` + * + * @param path Path of the store. + */ +export async function getStore(path: string): Promise { + return await Store.get(path) +} + +/** + * A lazy loaded key-value store persisted by the backend layer. + */ +export class LazyStore implements IStore { + private _store?: Promise + + private get store(): Promise { + if (!this._store) { + this._store = load(this.path, this.options) + } + return this._store + } + + /** + * Note that the options are not applied if someone else already created the store + * @param path Path to save the store in `app_data_dir` + * @param options Store configuration options + */ + constructor( + private readonly path: string, + private readonly options?: StoreOptions + ) {} + + /** + * Init/load the store if it's not loaded already + */ + async init(): Promise { + await this.store + } + + async set(key: string, value: unknown): Promise { + return (await this.store).set(key, value) + } + + async get(key: string): Promise { + return (await this.store).get(key) + } + + async has(key: string): Promise { + return (await this.store).has(key) + } + + async delete(key: string): Promise { + return (await this.store).delete(key) + } + + async clear(): Promise { + await (await this.store).clear() + } + + async reset(): Promise { + await (await this.store).reset() + } + + async keys(): Promise { + return (await this.store).keys() + } + + async values(): Promise { + return (await this.store).values() + } + + async entries(): Promise> { + return (await this.store).entries() + } + + async length(): Promise { + return (await this.store).length() + } + + async reload(): Promise { + await (await this.store).reload() + } + + async save(): Promise { + await (await this.store).save() + } + + async onKeyChange( + key: string, + cb: (value: T | undefined) => void + ): Promise { + return (await this.store).onKeyChange(key, cb) + } + + async onChange( + cb: (key: string, value: T | undefined) => void + ): Promise { + return (await this.store).onChange(cb) + } + + async close(): Promise { + if (this._store) { + await (await this._store).close() + } + } } /** * A key-value store persisted by the backend layer. */ -export class Store { - path: string; - constructor(path: string) { - this.path = path; +export class Store extends Resource implements IStore { + private constructor(rid: number) { + super(rid) } + /** + * Create a new Store or load the existing store with the path. + * + * @example + * ```typescript + * import { Store } from '@tauri-apps/api/store'; + * const store = await Store.load('store.json'); + * ``` + * + * @param path Path to save the store in `app_data_dir` + * @param options Store configuration options + */ + static async load(path: string, options?: StoreOptions): Promise { + const rid = await invoke('plugin:store|load', { + path, + ...options + }) + return new Store(rid) + } + + /** + * Gets an already loaded store. + * + * If the store is not loaded, returns `null`. In this case you must {@link Store.load load} it. + * + * This function is more useful when you already know the store is loaded + * and just need to access its instance. Prefer {@link Store.load} otherwise. + * + * @example + * ```typescript + * import { Store } from '@tauri-apps/api/store'; + * let store = await Store.get('store.json'); + * if (!store) { + * store = await Store.load('store.json'); + * } + * ``` + * + * @param path Path of the store. + */ + static async get(path: string): Promise { + return await invoke('plugin:store|get_store', { path }).then( + (rid) => (rid ? new Store(rid) : null) + ) + } + + async set(key: string, value: unknown): Promise { + await invoke('plugin:store|set', { + rid: this.rid, + key, + value + }) + } + + async get(key: string): Promise { + const [value, exists] = await invoke<[T, boolean]>('plugin:store|get', { + rid: this.rid, + key + }) + return exists ? value : undefined + } + + async has(key: string): Promise { + return await invoke('plugin:store|has', { + rid: this.rid, + key + }) + } + + async delete(key: string): Promise { + return await invoke('plugin:store|delete', { + rid: this.rid, + key + }) + } + + async clear(): Promise { + await invoke('plugin:store|clear', { rid: this.rid }) + } + + async reset(): Promise { + await invoke('plugin:store|reset', { rid: this.rid }) + } + + async keys(): Promise { + return await invoke('plugin:store|keys', { rid: this.rid }) + } + + async values(): Promise { + return await invoke('plugin:store|values', { rid: this.rid }) + } + + async entries(): Promise> { + return await invoke('plugin:store|entries', { rid: this.rid }) + } + + async length(): Promise { + return await invoke('plugin:store|length', { rid: this.rid }) + } + + async reload(): Promise { + await invoke('plugin:store|reload', { rid: this.rid }) + } + + async save(): Promise { + await invoke('plugin:store|save', { rid: this.rid }) + } + + async onKeyChange( + key: string, + cb: (value: T | undefined) => void + ): Promise { + return await listen>('store://change', (event) => { + if (event.payload.resourceId === this.rid && event.payload.key === key) { + cb(event.payload.exists ? event.payload.value : undefined) + } + }) + } + + async onChange( + cb: (key: string, value: T | undefined) => void + ): Promise { + return await listen>('store://change', (event) => { + if (event.payload.resourceId === this.rid) { + cb( + event.payload.key, + event.payload.exists ? event.payload.value : undefined + ) + } + }) + } +} + +interface IStore { /** * Inserts a key-value pair into the store. * @@ -28,26 +321,15 @@ export class Store { * @param value * @returns */ - async set(key: string, value: unknown): Promise { - return await invoke("plugin:store|set", { - path: this.path, - key, - value, - }); - } + set(key: string, value: unknown): Promise /** - * Returns the value for the given `key` or `null` the key does not exist. + * Returns the value for the given `key` or `undefined` if the key does not exist. * * @param key * @returns */ - async get(key: string): Promise { - return await invoke("plugin:store|get", { - path: this.path, - key, - }); - } + get(key: string): Promise /** * Returns `true` if the given `key` exists in the store. @@ -55,12 +337,7 @@ export class Store { * @param key * @returns */ - async has(key: string): Promise { - return await invoke("plugin:store|has", { - path: this.path, - key, - }); - } + has(key: string): Promise /** * Removes a key-value pair from the store. @@ -68,107 +345,67 @@ export class Store { * @param key * @returns */ - async delete(key: string): Promise { - return await invoke("plugin:store|delete", { - path: this.path, - key, - }); - } + delete(key: string): Promise /** * Clears the store, removing all key-value pairs. * - * Note: To clear the storage and reset it to it's `default` value, use `reset` instead. + * Note: To clear the storage and reset it to its `default` value, use {@linkcode reset} instead. * @returns */ - async clear(): Promise { - return await invoke("plugin:store|clear", { - path: this.path, - }); - } + clear(): Promise /** - * Resets the store to it's `default` value. + * Resets the store to its `default` value. * - * If no default value has been set, this method behaves identical to `clear`. + * If no default value has been set, this method behaves identical to {@linkcode clear}. * @returns */ - async reset(): Promise { - return await invoke("plugin:store|reset", { - path: this.path, - }); - } + reset(): Promise /** - * Returns a list of all key in the store. + * Returns a list of all keys in the store. * * @returns */ - async keys(): Promise { - return await invoke("plugin:store|keys", { - path: this.path, - }); - } + keys(): Promise /** * Returns a list of all values in the store. * * @returns */ - async values(): Promise { - return await invoke("plugin:store|values", { - path: this.path, - }); - } + values(): Promise /** * Returns a list of all entries in the store. * * @returns */ - async entries(): Promise> { - return await invoke("plugin:store|entries", { - path: this.path, - }); - } + entries(): Promise> /** * Returns the number of key-value pairs in the store. * * @returns */ - async length(): Promise { - return await invoke("plugin:store|length", { - path: this.path, - }); - } + length(): Promise /** - * Attempts to load the on-disk state at the stores `path` into memory. + * Attempts to load the on-disk state at the store's `path` into memory. * * This method is useful if the on-disk state was edited by the user and you want to synchronize the changes. * * Note: This method does not emit change events. * @returns */ - async load(): Promise { - return await invoke("plugin:store|load", { - path: this.path, - }); - } + reload(): Promise /** - * Saves the store to disk at the stores `path`. - * - * As the store is only persisted to disk before the apps exit, changes might be lost in a crash. - * This method lets you persist the store to disk whenever you deem necessary. + * Saves the store to disk at the store's `path`. * @returns */ - async save(): Promise { - return await invoke("plugin:store|save", { - path: this.path, - }); - } + save(): Promise /** * Listen to changes on a store key. @@ -178,16 +415,10 @@ export class Store { * * @since 2.0.0 */ - async onKeyChange( + onKeyChange( key: string, - cb: (value: T | null) => void, - ): Promise { - return await listen>("store://change", (event) => { - if (event.payload.path === this.path && event.payload.key === key) { - cb(event.payload.value); - } - }); - } + cb: (value: T | undefined) => void + ): Promise /** * Listen to changes on the store. @@ -196,13 +427,13 @@ export class Store { * * @since 2.0.0 */ - async onChange( - cb: (key: string, value: T | null) => void, - ): Promise { - return await listen>("store://change", (event) => { - if (event.payload.path === this.path) { - cb(event.payload.key, event.payload.value); - } - }); - } + onChange( + cb: (key: string, value: T | undefined) => void + ): Promise + + /** + * Close the store and cleans up this resource from memory. + * **You should not call any method on this object anymore and should drop any reference to it.** + */ + close(): Promise } diff --git a/plugins/store/package.json b/plugins/store/package.json index 6f05cae5..a3a28e66 100644 --- a/plugins/store/package.json +++ b/plugins/store/package.json @@ -1,33 +1,30 @@ { "name": "@tauri-apps/plugin-store", - "version": "2.0.0-alpha.1", + "version": "2.2.0", "description": "Simple, persistent key-value store.", - "license": "MIT or APACHE-2.0", + "license": "MIT OR Apache-2.0", "authors": [ "Tauri Programme within The Commons Conservancy" ], + "repository": "https://github.com/tauri-apps/plugins-workspace", "type": "module", - "browser": "dist-js/index.min.js", - "module": "dist-js/index.mjs", - "types": "dist-js/index.d.ts", + "types": "./dist-js/index.d.ts", + "main": "./dist-js/index.cjs", + "module": "./dist-js/index.js", "exports": { - "import": "./dist-js/index.mjs", "types": "./dist-js/index.d.ts", - "browser": "./dist-js/index.min.js" + "import": "./dist-js/index.js", + "require": "./dist-js/index.cjs" }, "scripts": { "build": "rollup -c" }, "files": [ "dist-js", - "!dist-js/**/*.map", "README.md", "LICENSE" ], - "devDependencies": { - "tslib": "2.6.0" - }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.9" + "@tauri-apps/api": "^2.0.0" } } diff --git a/plugins/store/permissions/autogenerated/commands/clear.toml b/plugins/store/permissions/autogenerated/commands/clear.toml new file mode 100644 index 00000000..83de1819 --- /dev/null +++ b/plugins/store/permissions/autogenerated/commands/clear.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-clear" +description = "Enables the clear command without any pre-configured scope." +commands.allow = ["clear"] + +[[permission]] +identifier = "deny-clear" +description = "Denies the clear command without any pre-configured scope." +commands.deny = ["clear"] diff --git a/plugins/store/permissions/autogenerated/commands/delete.toml b/plugins/store/permissions/autogenerated/commands/delete.toml new file mode 100644 index 00000000..3d9d5234 --- /dev/null +++ b/plugins/store/permissions/autogenerated/commands/delete.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-delete" +description = "Enables the delete command without any pre-configured scope." +commands.allow = ["delete"] + +[[permission]] +identifier = "deny-delete" +description = "Denies the delete command without any pre-configured scope." +commands.deny = ["delete"] diff --git a/plugins/store/permissions/autogenerated/commands/entries.toml b/plugins/store/permissions/autogenerated/commands/entries.toml new file mode 100644 index 00000000..ce8b5f4b --- /dev/null +++ b/plugins/store/permissions/autogenerated/commands/entries.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-entries" +description = "Enables the entries command without any pre-configured scope." +commands.allow = ["entries"] + +[[permission]] +identifier = "deny-entries" +description = "Denies the entries command without any pre-configured scope." +commands.deny = ["entries"] diff --git a/plugins/store/permissions/autogenerated/commands/get.toml b/plugins/store/permissions/autogenerated/commands/get.toml new file mode 100644 index 00000000..d75b4030 --- /dev/null +++ b/plugins/store/permissions/autogenerated/commands/get.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-get" +description = "Enables the get command without any pre-configured scope." +commands.allow = ["get"] + +[[permission]] +identifier = "deny-get" +description = "Denies the get command without any pre-configured scope." +commands.deny = ["get"] diff --git a/plugins/store/permissions/autogenerated/commands/get_store.toml b/plugins/store/permissions/autogenerated/commands/get_store.toml new file mode 100644 index 00000000..7c19173a --- /dev/null +++ b/plugins/store/permissions/autogenerated/commands/get_store.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-get-store" +description = "Enables the get_store command without any pre-configured scope." +commands.allow = ["get_store"] + +[[permission]] +identifier = "deny-get-store" +description = "Denies the get_store command without any pre-configured scope." +commands.deny = ["get_store"] diff --git a/plugins/store/permissions/autogenerated/commands/has.toml b/plugins/store/permissions/autogenerated/commands/has.toml new file mode 100644 index 00000000..41d0a938 --- /dev/null +++ b/plugins/store/permissions/autogenerated/commands/has.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-has" +description = "Enables the has command without any pre-configured scope." +commands.allow = ["has"] + +[[permission]] +identifier = "deny-has" +description = "Denies the has command without any pre-configured scope." +commands.deny = ["has"] diff --git a/plugins/store/permissions/autogenerated/commands/keys.toml b/plugins/store/permissions/autogenerated/commands/keys.toml new file mode 100644 index 00000000..1808d0e9 --- /dev/null +++ b/plugins/store/permissions/autogenerated/commands/keys.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-keys" +description = "Enables the keys command without any pre-configured scope." +commands.allow = ["keys"] + +[[permission]] +identifier = "deny-keys" +description = "Denies the keys command without any pre-configured scope." +commands.deny = ["keys"] diff --git a/plugins/store/permissions/autogenerated/commands/length.toml b/plugins/store/permissions/autogenerated/commands/length.toml new file mode 100644 index 00000000..318c5582 --- /dev/null +++ b/plugins/store/permissions/autogenerated/commands/length.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-length" +description = "Enables the length command without any pre-configured scope." +commands.allow = ["length"] + +[[permission]] +identifier = "deny-length" +description = "Denies the length command without any pre-configured scope." +commands.deny = ["length"] diff --git a/plugins/store/permissions/autogenerated/commands/load.toml b/plugins/store/permissions/autogenerated/commands/load.toml new file mode 100644 index 00000000..f6e47ad8 --- /dev/null +++ b/plugins/store/permissions/autogenerated/commands/load.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-load" +description = "Enables the load command without any pre-configured scope." +commands.allow = ["load"] + +[[permission]] +identifier = "deny-load" +description = "Denies the load command without any pre-configured scope." +commands.deny = ["load"] diff --git a/plugins/store/permissions/autogenerated/commands/reload.toml b/plugins/store/permissions/autogenerated/commands/reload.toml new file mode 100644 index 00000000..92e25253 --- /dev/null +++ b/plugins/store/permissions/autogenerated/commands/reload.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-reload" +description = "Enables the reload command without any pre-configured scope." +commands.allow = ["reload"] + +[[permission]] +identifier = "deny-reload" +description = "Denies the reload command without any pre-configured scope." +commands.deny = ["reload"] diff --git a/plugins/store/permissions/autogenerated/commands/reset.toml b/plugins/store/permissions/autogenerated/commands/reset.toml new file mode 100644 index 00000000..c32086de --- /dev/null +++ b/plugins/store/permissions/autogenerated/commands/reset.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-reset" +description = "Enables the reset command without any pre-configured scope." +commands.allow = ["reset"] + +[[permission]] +identifier = "deny-reset" +description = "Denies the reset command without any pre-configured scope." +commands.deny = ["reset"] diff --git a/plugins/store/permissions/autogenerated/commands/save.toml b/plugins/store/permissions/autogenerated/commands/save.toml new file mode 100644 index 00000000..d3e84220 --- /dev/null +++ b/plugins/store/permissions/autogenerated/commands/save.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-save" +description = "Enables the save command without any pre-configured scope." +commands.allow = ["save"] + +[[permission]] +identifier = "deny-save" +description = "Denies the save command without any pre-configured scope." +commands.deny = ["save"] diff --git a/plugins/store/permissions/autogenerated/commands/set.toml b/plugins/store/permissions/autogenerated/commands/set.toml new file mode 100644 index 00000000..1e1cc9e7 --- /dev/null +++ b/plugins/store/permissions/autogenerated/commands/set.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-set" +description = "Enables the set command without any pre-configured scope." +commands.allow = ["set"] + +[[permission]] +identifier = "deny-set" +description = "Denies the set command without any pre-configured scope." +commands.deny = ["set"] diff --git a/plugins/store/permissions/autogenerated/commands/values.toml b/plugins/store/permissions/autogenerated/commands/values.toml new file mode 100644 index 00000000..9343fd1a --- /dev/null +++ b/plugins/store/permissions/autogenerated/commands/values.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-values" +description = "Enables the values command without any pre-configured scope." +commands.allow = ["values"] + +[[permission]] +identifier = "deny-values" +description = "Denies the values command without any pre-configured scope." +commands.deny = ["values"] diff --git a/plugins/store/permissions/autogenerated/reference.md b/plugins/store/permissions/autogenerated/reference.md new file mode 100644 index 00000000..7b7d1016 --- /dev/null +++ b/plugins/store/permissions/autogenerated/reference.md @@ -0,0 +1,401 @@ +## Default Permission + +This permission set configures what kind of +operations are available from the store plugin. + +#### Granted Permissions + +All operations are enabled by default. + + + +#### This default permission set includes the following: + +- `allow-load` +- `allow-get-store` +- `allow-set` +- `allow-get` +- `allow-has` +- `allow-delete` +- `allow-clear` +- `allow-reset` +- `allow-keys` +- `allow-values` +- `allow-entries` +- `allow-length` +- `allow-reload` +- `allow-save` + +## Permission Table + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IdentifierDescription
+ +`store:allow-clear` + + + +Enables the clear command without any pre-configured scope. + +
+ +`store:deny-clear` + + + +Denies the clear command without any pre-configured scope. + +
+ +`store:allow-delete` + + + +Enables the delete command without any pre-configured scope. + +
+ +`store:deny-delete` + + + +Denies the delete command without any pre-configured scope. + +
+ +`store:allow-entries` + + + +Enables the entries command without any pre-configured scope. + +
+ +`store:deny-entries` + + + +Denies the entries command without any pre-configured scope. + +
+ +`store:allow-get` + + + +Enables the get command without any pre-configured scope. + +
+ +`store:deny-get` + + + +Denies the get command without any pre-configured scope. + +
+ +`store:allow-get-store` + + + +Enables the get_store command without any pre-configured scope. + +
+ +`store:deny-get-store` + + + +Denies the get_store command without any pre-configured scope. + +
+ +`store:allow-has` + + + +Enables the has command without any pre-configured scope. + +
+ +`store:deny-has` + + + +Denies the has command without any pre-configured scope. + +
+ +`store:allow-keys` + + + +Enables the keys command without any pre-configured scope. + +
+ +`store:deny-keys` + + + +Denies the keys command without any pre-configured scope. + +
+ +`store:allow-length` + + + +Enables the length command without any pre-configured scope. + +
+ +`store:deny-length` + + + +Denies the length command without any pre-configured scope. + +
+ +`store:allow-load` + + + +Enables the load command without any pre-configured scope. + +
+ +`store:deny-load` + + + +Denies the load command without any pre-configured scope. + +
+ +`store:allow-reload` + + + +Enables the reload command without any pre-configured scope. + +
+ +`store:deny-reload` + + + +Denies the reload command without any pre-configured scope. + +
+ +`store:allow-reset` + + + +Enables the reset command without any pre-configured scope. + +
+ +`store:deny-reset` + + + +Denies the reset command without any pre-configured scope. + +
+ +`store:allow-save` + + + +Enables the save command without any pre-configured scope. + +
+ +`store:deny-save` + + + +Denies the save command without any pre-configured scope. + +
+ +`store:allow-set` + + + +Enables the set command without any pre-configured scope. + +
+ +`store:deny-set` + + + +Denies the set command without any pre-configured scope. + +
+ +`store:allow-values` + + + +Enables the values command without any pre-configured scope. + +
+ +`store:deny-values` + + + +Denies the values command without any pre-configured scope. + +
diff --git a/plugins/store/permissions/default.toml b/plugins/store/permissions/default.toml new file mode 100644 index 00000000..3a3e4b3a --- /dev/null +++ b/plugins/store/permissions/default.toml @@ -0,0 +1,28 @@ +"$schema" = "schemas/schema.json" + +[default] +description = """ +This permission set configures what kind of +operations are available from the store plugin. + +#### Granted Permissions + +All operations are enabled by default. + +""" +permissions = [ + "allow-load", + "allow-get-store", + "allow-set", + "allow-get", + "allow-has", + "allow-delete", + "allow-clear", + "allow-reset", + "allow-keys", + "allow-values", + "allow-entries", + "allow-length", + "allow-reload", + "allow-save", +] diff --git a/plugins/store/permissions/schemas/schema.json b/plugins/store/permissions/schemas/schema.json new file mode 100644 index 00000000..af475189 --- /dev/null +++ b/plugins/store/permissions/schemas/schema.json @@ -0,0 +1,474 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "PermissionFile", + "description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.", + "type": "object", + "properties": { + "default": { + "description": "The default permission set for the plugin", + "anyOf": [ + { + "$ref": "#/definitions/DefaultPermission" + }, + { + "type": "null" + } + ] + }, + "set": { + "description": "A list of permissions sets defined", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionSet" + } + }, + "permission": { + "description": "A list of inlined permissions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Permission" + } + } + }, + "definitions": { + "DefaultPermission": { + "description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.", + "type": "object", + "required": [ + "permissions" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "PermissionSet": { + "description": "A set of direct permissions grouped together under a new name.", + "type": "object", + "required": [ + "description", + "identifier", + "permissions" + ], + "properties": { + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does.", + "type": "string" + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionKind" + } + } + } + }, + "Permission": { + "description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.", + "type": "object", + "required": [ + "identifier" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri internal convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "commands": { + "description": "Allowed or denied commands when using this permission.", + "default": { + "allow": [], + "deny": [] + }, + "allOf": [ + { + "$ref": "#/definitions/Commands" + } + ] + }, + "scope": { + "description": "Allowed or denied scoped when using this permission.", + "allOf": [ + { + "$ref": "#/definitions/Scopes" + } + ] + }, + "platforms": { + "description": "Target platforms this permission applies. By default all platforms are affected by this permission.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Target" + } + } + } + }, + "Commands": { + "description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.", + "type": "object", + "properties": { + "allow": { + "description": "Allowed command.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "deny": { + "description": "Denied command, which takes priority.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "Scopes": { + "description": "An argument for fine grained behavior control of Tauri commands.\n\nIt can be of any serde serializable type and is used to allow or prevent certain actions inside a Tauri command. The configured scope is passed to the command and will be enforced by the command implementation.\n\n## Example\n\n```json { \"allow\": [{ \"path\": \"$HOME/**\" }], \"deny\": [{ \"path\": \"$HOME/secret.txt\" }] } ```", + "type": "object", + "properties": { + "allow": { + "description": "Data that defines what is allowed by the scope.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + }, + "deny": { + "description": "Data that defines what is denied by the scope. This should be prioritized by validation logic.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + } + } + }, + "Value": { + "description": "All supported ACL values.", + "anyOf": [ + { + "description": "Represents a null JSON value.", + "type": "null" + }, + { + "description": "Represents a [`bool`].", + "type": "boolean" + }, + { + "description": "Represents a valid ACL [`Number`].", + "allOf": [ + { + "$ref": "#/definitions/Number" + } + ] + }, + { + "description": "Represents a [`String`].", + "type": "string" + }, + { + "description": "Represents a list of other [`Value`]s.", + "type": "array", + "items": { + "$ref": "#/definitions/Value" + } + }, + { + "description": "Represents a map of [`String`] keys to [`Value`]s.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/Value" + } + } + ] + }, + "Number": { + "description": "A valid ACL number.", + "anyOf": [ + { + "description": "Represents an [`i64`].", + "type": "integer", + "format": "int64" + }, + { + "description": "Represents a [`f64`].", + "type": "number", + "format": "double" + } + ] + }, + "Target": { + "description": "Platform target.", + "oneOf": [ + { + "description": "MacOS.", + "type": "string", + "enum": [ + "macOS" + ] + }, + { + "description": "Windows.", + "type": "string", + "enum": [ + "windows" + ] + }, + { + "description": "Linux.", + "type": "string", + "enum": [ + "linux" + ] + }, + { + "description": "Android.", + "type": "string", + "enum": [ + "android" + ] + }, + { + "description": "iOS.", + "type": "string", + "enum": [ + "iOS" + ] + } + ] + }, + "PermissionKind": { + "type": "string", + "oneOf": [ + { + "description": "Enables the clear command without any pre-configured scope.", + "type": "string", + "const": "allow-clear", + "markdownDescription": "Enables the clear command without any pre-configured scope." + }, + { + "description": "Denies the clear command without any pre-configured scope.", + "type": "string", + "const": "deny-clear", + "markdownDescription": "Denies the clear command without any pre-configured scope." + }, + { + "description": "Enables the delete command without any pre-configured scope.", + "type": "string", + "const": "allow-delete", + "markdownDescription": "Enables the delete command without any pre-configured scope." + }, + { + "description": "Denies the delete command without any pre-configured scope.", + "type": "string", + "const": "deny-delete", + "markdownDescription": "Denies the delete command without any pre-configured scope." + }, + { + "description": "Enables the entries command without any pre-configured scope.", + "type": "string", + "const": "allow-entries", + "markdownDescription": "Enables the entries command without any pre-configured scope." + }, + { + "description": "Denies the entries command without any pre-configured scope.", + "type": "string", + "const": "deny-entries", + "markdownDescription": "Denies the entries command without any pre-configured scope." + }, + { + "description": "Enables the get command without any pre-configured scope.", + "type": "string", + "const": "allow-get", + "markdownDescription": "Enables the get command without any pre-configured scope." + }, + { + "description": "Denies the get command without any pre-configured scope.", + "type": "string", + "const": "deny-get", + "markdownDescription": "Denies the get command without any pre-configured scope." + }, + { + "description": "Enables the get_store command without any pre-configured scope.", + "type": "string", + "const": "allow-get-store", + "markdownDescription": "Enables the get_store command without any pre-configured scope." + }, + { + "description": "Denies the get_store command without any pre-configured scope.", + "type": "string", + "const": "deny-get-store", + "markdownDescription": "Denies the get_store command without any pre-configured scope." + }, + { + "description": "Enables the has command without any pre-configured scope.", + "type": "string", + "const": "allow-has", + "markdownDescription": "Enables the has command without any pre-configured scope." + }, + { + "description": "Denies the has command without any pre-configured scope.", + "type": "string", + "const": "deny-has", + "markdownDescription": "Denies the has command without any pre-configured scope." + }, + { + "description": "Enables the keys command without any pre-configured scope.", + "type": "string", + "const": "allow-keys", + "markdownDescription": "Enables the keys command without any pre-configured scope." + }, + { + "description": "Denies the keys command without any pre-configured scope.", + "type": "string", + "const": "deny-keys", + "markdownDescription": "Denies the keys command without any pre-configured scope." + }, + { + "description": "Enables the length command without any pre-configured scope.", + "type": "string", + "const": "allow-length", + "markdownDescription": "Enables the length command without any pre-configured scope." + }, + { + "description": "Denies the length command without any pre-configured scope.", + "type": "string", + "const": "deny-length", + "markdownDescription": "Denies the length command without any pre-configured scope." + }, + { + "description": "Enables the load command without any pre-configured scope.", + "type": "string", + "const": "allow-load", + "markdownDescription": "Enables the load command without any pre-configured scope." + }, + { + "description": "Denies the load command without any pre-configured scope.", + "type": "string", + "const": "deny-load", + "markdownDescription": "Denies the load command without any pre-configured scope." + }, + { + "description": "Enables the reload command without any pre-configured scope.", + "type": "string", + "const": "allow-reload", + "markdownDescription": "Enables the reload command without any pre-configured scope." + }, + { + "description": "Denies the reload command without any pre-configured scope.", + "type": "string", + "const": "deny-reload", + "markdownDescription": "Denies the reload command without any pre-configured scope." + }, + { + "description": "Enables the reset command without any pre-configured scope.", + "type": "string", + "const": "allow-reset", + "markdownDescription": "Enables the reset command without any pre-configured scope." + }, + { + "description": "Denies the reset command without any pre-configured scope.", + "type": "string", + "const": "deny-reset", + "markdownDescription": "Denies the reset command without any pre-configured scope." + }, + { + "description": "Enables the save command without any pre-configured scope.", + "type": "string", + "const": "allow-save", + "markdownDescription": "Enables the save command without any pre-configured scope." + }, + { + "description": "Denies the save command without any pre-configured scope.", + "type": "string", + "const": "deny-save", + "markdownDescription": "Denies the save command without any pre-configured scope." + }, + { + "description": "Enables the set command without any pre-configured scope.", + "type": "string", + "const": "allow-set", + "markdownDescription": "Enables the set command without any pre-configured scope." + }, + { + "description": "Denies the set command without any pre-configured scope.", + "type": "string", + "const": "deny-set", + "markdownDescription": "Denies the set command without any pre-configured scope." + }, + { + "description": "Enables the values command without any pre-configured scope.", + "type": "string", + "const": "allow-values", + "markdownDescription": "Enables the values command without any pre-configured scope." + }, + { + "description": "Denies the values command without any pre-configured scope.", + "type": "string", + "const": "deny-values", + "markdownDescription": "Denies the values command without any pre-configured scope." + }, + { + "description": "This permission set configures what kind of\noperations are available from the store plugin.\n\n#### Granted Permissions\n\nAll operations are enabled by default.\n\n\n#### This default permission set includes:\n\n- `allow-load`\n- `allow-get-store`\n- `allow-set`\n- `allow-get`\n- `allow-has`\n- `allow-delete`\n- `allow-clear`\n- `allow-reset`\n- `allow-keys`\n- `allow-values`\n- `allow-entries`\n- `allow-length`\n- `allow-reload`\n- `allow-save`", + "type": "string", + "const": "default", + "markdownDescription": "This permission set configures what kind of\noperations are available from the store plugin.\n\n#### Granted Permissions\n\nAll operations are enabled by default.\n\n\n#### This default permission set includes:\n\n- `allow-load`\n- `allow-get-store`\n- `allow-set`\n- `allow-get`\n- `allow-has`\n- `allow-delete`\n- `allow-clear`\n- `allow-reset`\n- `allow-keys`\n- `allow-values`\n- `allow-entries`\n- `allow-length`\n- `allow-reload`\n- `allow-save`" + } + ] + } + } +} \ No newline at end of file diff --git a/plugins/store/rollup.config.js b/plugins/store/rollup.config.js new file mode 100644 index 00000000..1f349ec8 --- /dev/null +++ b/plugins/store/rollup.config.js @@ -0,0 +1,7 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import { createConfig } from '../../shared/rollup.config.js' + +export default createConfig() diff --git a/plugins/store/rollup.config.mjs b/plugins/store/rollup.config.mjs deleted file mode 100644 index 99a3dd31..00000000 --- a/plugins/store/rollup.config.mjs +++ /dev/null @@ -1,11 +0,0 @@ -import { readFileSync } from "fs"; - -import { createConfig } from "../../shared/rollup.config.mjs"; - -export default createConfig({ - input: "guest-js/index.ts", - pkg: JSON.parse( - readFileSync(new URL("./package.json", import.meta.url), "utf8"), - ), - external: [/^@tauri-apps\/api/], -}); diff --git a/plugins/store/src/api-iife.js b/plugins/store/src/api-iife.js deleted file mode 100644 index 75c36224..00000000 --- a/plugins/store/src/api-iife.js +++ /dev/null @@ -1 +0,0 @@ -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__})} diff --git a/plugins/store/src/error.rs b/plugins/store/src/error.rs index 0a04bb09..ef5ee593 100644 --- a/plugins/store/src/error.rs +++ b/plugins/store/src/error.rs @@ -3,7 +3,8 @@ // SPDX-License-Identifier: MIT use serde::{Serialize, Serializer}; -use std::path::PathBuf; + +pub type Result = std::result::Result; /// The error types. #[derive(thiserror::Error, Debug)] @@ -19,9 +20,15 @@ pub enum Error { /// IO error. #[error(transparent)] Io(#[from] std::io::Error), - /// Store not found - #[error("Store \"{0}\" not found")] - NotFound(PathBuf), + // /// Store already exists + // #[error("Store at \"{0}\" already exists")] + // AlreadyExists(PathBuf), + /// Serialize function not found + #[error("Serialize Function \"{0}\" not found")] + SerializeFunctionNotFound(String), + /// Deserialize function not found + #[error("Deserialize Function \"{0}\" not found")] + DeserializeFunctionNotFound(String), /// Some Tauri API failed #[error(transparent)] Tauri(#[from] tauri::Error), diff --git a/plugins/store/src/lib.rs b/plugins/store/src/lib.rs index 45a0c826..0e59cd81 100644 --- a/plugins/store/src/lib.rs +++ b/plugins/store/src/lib.rs @@ -2,8 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -//! [![](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/store/banner.png)](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/store) -//! //! Simple, persistent key-value store. #![doc( @@ -11,311 +9,431 @@ html_favicon_url = "https://github.com/tauri-apps/tauri/raw/dev/app-icon.png" )] -pub use error::Error; -use log::warn; -use serde::Serialize; +pub use error::{Error, Result}; +use serde::{Deserialize, Serialize}; pub use serde_json::Value as JsonValue; use std::{ collections::HashMap, path::{Path, PathBuf}, - sync::Mutex, + sync::{Arc, Mutex}, + time::Duration, }; -pub use store::{Store, StoreBuilder}; +pub use store::{resolve_store_path, DeserializeFn, SerializeFn, Store, StoreBuilder}; use tauri::{ plugin::{self, TauriPlugin}, - AppHandle, Manager, RunEvent, Runtime, State, + AppHandle, Manager, ResourceId, RunEvent, Runtime, State, }; mod error; mod store; #[derive(Serialize, Clone)] +#[serde(rename_all = "camelCase")] struct ChangePayload<'a> { path: &'a Path, + resource_id: Option, key: &'a str, - value: &'a JsonValue, + value: Option<&'a JsonValue>, + exists: bool, } -#[derive(Default)] -pub struct StoreCollection { - stores: Mutex>>, - frozen: bool, +#[derive(Debug)] +struct StoreState { + stores: Arc>>, + serialize_fns: HashMap, + deserialize_fns: HashMap, + default_serialize: SerializeFn, + default_deserialize: DeserializeFn, } -pub fn with_store) -> Result>( +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +enum AutoSave { + DebounceDuration(u64), + Bool(bool), +} + +fn builder( app: AppHandle, - collection: State<'_, StoreCollection>, - path: impl AsRef, - f: F, -) -> Result { - let mut stores = collection.stores.lock().expect("mutex poisoned"); - - let path = path.as_ref(); - if !stores.contains_key(path) { - if collection.frozen { - return Err(Error::NotFound(path.to_path_buf())); - } - let mut store = StoreBuilder::new(path).build(app); - // ignore loading errors, just use the default - if let Err(err) = store.load() { - warn!( - "Failed to load store {:?} from disk: {}. Falling back to default values.", - path, err - ); + store_state: State<'_, StoreState>, + path: PathBuf, + auto_save: Option, + serialize_fn_name: Option, + deserialize_fn_name: Option, + create_new: bool, +) -> Result> { + let mut builder = app.store_builder(path); + if let Some(auto_save) = auto_save { + match auto_save { + AutoSave::DebounceDuration(duration) => { + builder = builder.auto_save(Duration::from_millis(duration)); + } + AutoSave::Bool(false) => { + builder = builder.disable_auto_save(); + } + _ => {} } - stores.insert(path.to_path_buf(), store); } - f(stores - .get_mut(path) - .expect("failed to retrieve store. This is a bug!")) + if let Some(serialize_fn_name) = serialize_fn_name { + let serialize_fn = store_state + .serialize_fns + .get(&serialize_fn_name) + .ok_or_else(|| crate::Error::SerializeFunctionNotFound(serialize_fn_name))?; + builder = builder.serialize(*serialize_fn); + } + + if let Some(deserialize_fn_name) = deserialize_fn_name { + let deserialize_fn = store_state + .deserialize_fns + .get(&deserialize_fn_name) + .ok_or_else(|| crate::Error::DeserializeFunctionNotFound(deserialize_fn_name))?; + builder = builder.deserialize(*deserialize_fn); + } + + if create_new { + builder = builder.create_new(); + } + + Ok(builder) } #[tauri::command] -async fn set( +async fn load( app: AppHandle, - stores: State<'_, StoreCollection>, + store_state: State<'_, StoreState>, path: PathBuf, - key: String, - value: JsonValue, -) -> Result<(), Error> { - with_store(app, stores, path, |store| store.insert(key, value)) + auto_save: Option, + serialize_fn_name: Option, + deserialize_fn_name: Option, + create_new: Option, +) -> Result { + let builder = builder( + app, + store_state, + path, + auto_save, + serialize_fn_name, + deserialize_fn_name, + create_new.unwrap_or_default(), + )?; + let (_, rid) = builder.build_inner()?; + Ok(rid) } #[tauri::command] -async fn get( +async fn get_store( app: AppHandle, - stores: State<'_, StoreCollection>, + store_state: State<'_, StoreState>, path: PathBuf, - key: String, -) -> Result, Error> { - with_store(app, stores, path, |store| Ok(store.get(key).cloned())) +) -> Result> { + let stores = store_state.stores.lock().unwrap(); + Ok(stores.get(&resolve_store_path(&app, path)?).copied()) } #[tauri::command] -async fn has( +async fn set( app: AppHandle, - stores: State<'_, StoreCollection>, - path: PathBuf, + rid: ResourceId, key: String, -) -> Result { - with_store(app, stores, path, |store| Ok(store.has(key))) + value: JsonValue, +) -> Result<()> { + let store = app.resources_table().get::>(rid)?; + store.set(key, value); + Ok(()) } #[tauri::command] -async fn delete( +async fn get( app: AppHandle, - stores: State<'_, StoreCollection>, - path: PathBuf, + rid: ResourceId, key: String, -) -> Result { - with_store(app, stores, path, |store| store.delete(key)) +) -> Result<(Option, bool)> { + let store = app.resources_table().get::>(rid)?; + let value = store.get(key); + let exists = value.is_some(); + Ok((value, exists)) } #[tauri::command] -async fn clear( - app: AppHandle, - stores: State<'_, StoreCollection>, - path: PathBuf, -) -> Result<(), Error> { - with_store(app, stores, path, |store| store.clear()) +async fn has(app: AppHandle, rid: ResourceId, key: String) -> Result { + let store = app.resources_table().get::>(rid)?; + Ok(store.has(key)) } #[tauri::command] -async fn reset( - app: AppHandle, - collection: State<'_, StoreCollection>, - path: PathBuf, -) -> Result<(), Error> { - with_store(app, collection, path, |store| store.reset()) +async fn delete(app: AppHandle, rid: ResourceId, key: String) -> Result { + let store = app.resources_table().get::>(rid)?; + Ok(store.delete(key)) } #[tauri::command] -async fn keys( - app: AppHandle, - stores: State<'_, StoreCollection>, - path: PathBuf, -) -> Result, Error> { - with_store(app, stores, path, |store| { - Ok(store.keys().cloned().collect()) - }) +async fn clear(app: AppHandle, rid: ResourceId) -> Result<()> { + let store = app.resources_table().get::>(rid)?; + store.clear(); + Ok(()) } #[tauri::command] -async fn values( - app: AppHandle, - stores: State<'_, StoreCollection>, - path: PathBuf, -) -> Result, Error> { - with_store(app, stores, path, |store| { - Ok(store.values().cloned().collect()) - }) +async fn reset(app: AppHandle, rid: ResourceId) -> Result<()> { + let store = app.resources_table().get::>(rid)?; + store.reset(); + Ok(()) } #[tauri::command] -async fn entries( - app: AppHandle, - stores: State<'_, StoreCollection>, - path: PathBuf, -) -> Result, Error> { - with_store(app, stores, path, |store| { - Ok(store - .entries() - .map(|(k, v)| (k.to_owned(), v.to_owned())) - .collect()) - }) +async fn keys(app: AppHandle, rid: ResourceId) -> Result> { + let store = app.resources_table().get::>(rid)?; + Ok(store.keys()) } #[tauri::command] -async fn length( - app: AppHandle, - stores: State<'_, StoreCollection>, - path: PathBuf, -) -> Result { - with_store(app, stores, path, |store| Ok(store.len())) +async fn values(app: AppHandle, rid: ResourceId) -> Result> { + let store = app.resources_table().get::>(rid)?; + Ok(store.values()) } #[tauri::command] -async fn load( +async fn entries( app: AppHandle, - stores: State<'_, StoreCollection>, - path: PathBuf, -) -> Result<(), Error> { - with_store(app, stores, path, |store| store.load()) + rid: ResourceId, +) -> Result> { + let store = app.resources_table().get::>(rid)?; + Ok(store.entries()) } #[tauri::command] -async fn save( - app: AppHandle, - stores: State<'_, StoreCollection>, - path: PathBuf, -) -> Result<(), Error> { - with_store(app, stores, path, |store| store.save()) +async fn length(app: AppHandle, rid: ResourceId) -> Result { + let store = app.resources_table().get::>(rid)?; + Ok(store.length()) } -// #[derive(Default)] -pub struct Builder { - stores: HashMap>, - frozen: bool, +#[tauri::command] +async fn reload(app: AppHandle, rid: ResourceId) -> Result<()> { + let store = app.resources_table().get::>(rid)?; + store.reload() } -impl Default for Builder { - fn default() -> Self { - Self { - stores: Default::default(), - frozen: false, - } - } +#[tauri::command] +async fn save(app: AppHandle, rid: ResourceId) -> Result<()> { + let store = app.resources_table().get::>(rid)?; + store.save() } -impl Builder { - /// Registers a store with the plugin. +pub trait StoreExt { + /// Create a store or load an existing store with default settings at the given path. + /// + /// If the store is already loaded, its instance is automatically returned. /// /// # Examples /// /// ``` - /// use tauri_plugin_store::{StoreBuilder, Builder}; + /// use tauri_plugin_store::StoreExt; /// /// tauri::Builder::default() + /// .plugin(tauri_plugin_store::Builder::default().build()) /// .setup(|app| { - /// let store = StoreBuilder::new("store.bin").build(app.handle().clone()); - /// let builder = Builder::default().store(store); + /// let store = app.store("my-store")?; /// Ok(()) /// }); /// ``` - pub fn store(mut self, store: Store) -> Self { - self.stores.insert(store.path.clone(), store); - self - } - - /// Registers multiple stores with the plugin. + fn store(&self, path: impl AsRef) -> Result>>; + /// Get a store builder. + /// + /// The builder can be used to configure the store. + /// To use the default settings see [`Self::store`]. /// /// # Examples /// /// ``` - /// use tauri_plugin_store::{StoreBuilder, Builder}; + /// use tauri_plugin_store::StoreExt; + /// use std::time::Duration; /// /// tauri::Builder::default() + /// .plugin(tauri_plugin_store::Builder::default().build()) /// .setup(|app| { - /// let store = StoreBuilder::new("store.bin").build(app.handle().clone()); - /// let builder = Builder::default().stores([store]); + /// let store = app.store_builder("users.json").auto_save(Duration::from_secs(1)).build()?; /// Ok(()) /// }); /// ``` - pub fn stores>>(mut self, stores: T) -> Self { - self.stores = stores - .into_iter() - .map(|store| (store.path.clone(), store)) - .collect(); - self - } - - /// Freezes the collection. + fn store_builder(&self, path: impl AsRef) -> StoreBuilder; + /// Get a handle of an already loaded store. /// - /// This causes requests for plugins that haven't been registered to fail + /// If the store is not loaded or does not exist, it returns `None`. + /// + /// Note that using this function can cause race conditions if you fallback to creating or loading the store, + /// so you should consider using [`Self::store`] if you are not sure if the store is loaded or not. /// /// # Examples /// /// ``` - /// use tauri_plugin_store::{StoreBuilder, Builder}; + /// use tauri_plugin_store::StoreExt; /// /// tauri::Builder::default() + /// .plugin(tauri_plugin_store::Builder::default().build()) /// .setup(|app| { - /// let store = StoreBuilder::new("store.bin").build(app.handle().clone()); - /// app.handle().plugin(Builder::default().freeze().build()); + /// let store = if let Some(s) = app.get_store("store.json") { + /// s + /// } else { + /// // this is not thread safe; if another thread is doing the same load/create, + /// // there will be a race condition; in this case we could remove the get_store + /// // and only run app.store() as it will return the existing store if it has been loaded + /// app.store("store.json")? + /// }; /// Ok(()) /// }); /// ``` - pub fn freeze(mut self) -> Self { - self.frozen = true; + fn get_store(&self, path: impl AsRef) -> Option>>; +} + +impl> StoreExt for T { + fn store(&self, path: impl AsRef) -> Result>> { + StoreBuilder::new(self.app_handle(), path).build() + } + + fn store_builder(&self, path: impl AsRef) -> StoreBuilder { + StoreBuilder::new(self.app_handle(), path) + } + + fn get_store(&self, path: impl AsRef) -> Option>> { + let collection = self.state::(); + let stores = collection.stores.lock().unwrap(); + stores + .get(&resolve_store_path(self.app_handle(), path.as_ref()).ok()?) + .and_then(|rid| self.resources_table().get(*rid).ok()) + } +} + +fn default_serialize( + cache: &HashMap, +) -> std::result::Result, Box> { + Ok(serde_json::to_vec_pretty(&cache)?) +} + +fn default_deserialize( + bytes: &[u8], +) -> std::result::Result, Box> { + serde_json::from_slice(bytes).map_err(Into::into) +} + +pub struct Builder { + serialize_fns: HashMap, + deserialize_fns: HashMap, + default_serialize: SerializeFn, + default_deserialize: DeserializeFn, +} + +impl Default for Builder { + fn default() -> Self { + Self { + serialize_fns: Default::default(), + deserialize_fns: Default::default(), + default_serialize, + default_deserialize, + } + } +} + +impl Builder { + pub fn new() -> Self { + Self::default() + } + + /// Register a serialize function to access it from the JavaScript side + /// + /// # Examples + /// + /// ``` + /// fn no_pretty_json( + /// cache: &std::collections::HashMap, + /// ) -> Result, Box> { + /// Ok(serde_json::to_vec(&cache)?) + /// } + /// + /// tauri::Builder::default() + /// .plugin( + /// tauri_plugin_store::Builder::default() + /// .register_serialize_fn("no-pretty-json".to_owned(), no_pretty_json) + /// .build(), + /// ); + /// ``` + pub fn register_serialize_fn(mut self, name: String, serialize_fn: SerializeFn) -> Self { + self.serialize_fns.insert(name, serialize_fn); self } - /// Builds the plugin. + /// Register a deserialize function to access it from the JavaScript side + pub fn register_deserialize_fn(mut self, name: String, deserialize_fn: DeserializeFn) -> Self { + self.deserialize_fns.insert(name, deserialize_fn); + self + } + + /// Use this serialize function for stores by default /// /// # Examples /// /// ``` - /// use tauri_plugin_store::{StoreBuilder, Builder}; + /// fn no_pretty_json( + /// cache: &std::collections::HashMap, + /// ) -> Result, Box> { + /// Ok(serde_json::to_vec(&cache)?) + /// } + /// + /// tauri::Builder::default() + /// .plugin( + /// tauri_plugin_store::Builder::default() + /// .default_serialize_fn(no_pretty_json) + /// .build(), + /// ); + /// ``` + pub fn default_serialize_fn(mut self, serialize_fn: SerializeFn) -> Self { + self.default_serialize = serialize_fn; + self + } + + /// Use this deserialize function for stores by default + pub fn default_deserialize_fn(mut self, deserialize_fn: DeserializeFn) -> Self { + self.default_deserialize = deserialize_fn; + self + } + + /// Builds the plugin. + /// + /// # Examples /// + /// ``` /// tauri::Builder::default() + /// .plugin(tauri_plugin_store::Builder::default().build()) /// .setup(|app| { - /// let store = StoreBuilder::new("store.bin").build(app.handle().clone()); - /// app.handle().plugin(Builder::default().build()); + /// let store = tauri_plugin_store::StoreBuilder::new(app, "store.bin").build()?; /// Ok(()) /// }); /// ``` - pub fn build(mut self) -> TauriPlugin { + pub fn build(self) -> TauriPlugin { plugin::Builder::new("store") - .js_init_script(include_str!("api-iife.js").to_string()) .invoke_handler(tauri::generate_handler![ - set, get, has, delete, clear, reset, keys, values, length, entries, load, save + load, get_store, set, get, has, delete, clear, reset, keys, values, length, + entries, reload, save, ]) .setup(move |app_handle, _api| { - for (path, store) in self.stores.iter_mut() { - // ignore loading errors, just use the default - if let Err(err) = store.load() { - warn!( - "Failed to load store {:?} from disk: {}. Falling back to default values.", - path, err - ); - } - } - - app_handle.manage(StoreCollection { - stores: Mutex::new(self.stores), - frozen: self.frozen, + app_handle.manage(StoreState { + stores: Arc::new(Mutex::new(HashMap::new())), + serialize_fns: self.serialize_fns, + deserialize_fns: self.deserialize_fns, + default_serialize: self.default_serialize, + default_deserialize: self.default_deserialize, }); - Ok(()) }) .on_event(|app_handle, event| { if let RunEvent::Exit = event { - let collection = app_handle.state::>(); - - for store in collection.stores.lock().expect("mutex poisoned").values() { - if let Err(err) = store.save() { - eprintln!("failed to save store {:?} with error {:?}", store.path, err); + let collection = app_handle.state::(); + let stores = collection.stores.lock().unwrap(); + for (path, rid) in stores.iter() { + if let Ok(store) = app_handle.resources_table().get::>(*rid) { + if let Err(err) = store.save() { + tracing::error!("failed to save store {path:?} with error {err:?}"); + } } } } diff --git a/plugins/store/src/store.rs b/plugins/store/src/store.rs index cea0eb17..1dc5e1d2 100644 --- a/plugins/store/src/store.rs +++ b/plugins/store/src/store.rs @@ -2,62 +2,70 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use crate::{ChangePayload, Error}; +use crate::{ChangePayload, StoreState}; use serde_json::Value as JsonValue; use std::{ collections::HashMap, - fs::{create_dir_all, read, File}, - io::Write, + fs, path::{Path, PathBuf}, + sync::{Arc, Mutex}, + time::Duration, +}; +use tauri::{path::BaseDirectory, AppHandle, Emitter, Manager, Resource, ResourceId, Runtime}; +use tokio::{ + select, + sync::mpsc::{unbounded_channel, UnboundedSender}, + time::sleep, }; -use tauri::{AppHandle, Manager, Runtime}; -type SerializeFn = +pub type SerializeFn = fn(&HashMap) -> Result, Box>; -type DeserializeFn = +pub type DeserializeFn = fn(&[u8]) -> Result, Box>; -fn default_serialize( - cache: &HashMap, -) -> Result, Box> { - Ok(serde_json::to_vec(&cache)?) -} - -fn default_deserialize( - bytes: &[u8], -) -> Result, Box> { - serde_json::from_slice(bytes).map_err(Into::into) +pub fn resolve_store_path( + app: &AppHandle, + path: impl AsRef, +) -> crate::Result { + Ok(dunce::simplified(&app.path().resolve(path, BaseDirectory::AppData)?).to_path_buf()) } /// Builds a [`Store`] -pub struct StoreBuilder { +pub struct StoreBuilder { + app: AppHandle, path: PathBuf, defaults: Option>, - cache: HashMap, - serialize: SerializeFn, - deserialize: DeserializeFn, + serialize_fn: SerializeFn, + deserialize_fn: DeserializeFn, + auto_save: Option, + create_new: bool, } -impl StoreBuilder { +impl StoreBuilder { /// Creates a new [`StoreBuilder`]. /// /// # Examples /// ``` - /// # fn main() -> Result<(), Box> { - /// use tauri_plugin_store::StoreBuilder; - /// - /// let builder = StoreBuilder::new("store.bin"); - /// - /// # Ok(()) - /// # } + /// tauri::Builder::default() + /// .plugin(tauri_plugin_store::Builder::default().build()) + /// .setup(|app| { + /// let builder = tauri_plugin_store::StoreBuilder::new(app, "store.bin"); + /// Ok(()) + /// }); /// ``` - pub fn new>(path: P) -> Self { + pub fn new, P: AsRef>(manager: &M, path: P) -> Self { + let app = manager.app_handle().clone(); + let state = app.state::(); + let serialize_fn = state.default_serialize; + let deserialize_fn = state.default_deserialize; Self { + app, path: path.as_ref().to_path_buf(), defaults: None, - cache: Default::default(), - serialize: default_serialize, - deserialize: default_deserialize, + serialize_fn, + deserialize_fn, + auto_save: Some(Duration::from_millis(100)), + create_new: false, } } @@ -65,39 +73,39 @@ impl StoreBuilder { /// /// # Examples /// ``` - /// # fn main() -> Result<(), Box> { - /// use tauri_plugin_store::StoreBuilder; - /// use std::collections::HashMap; - /// - /// let mut defaults = HashMap::new(); - /// - /// defaults.insert("foo".to_string(), "bar".into()); - /// - /// let builder = StoreBuilder::new("store.bin") - /// .defaults(defaults); + /// tauri::Builder::default() + /// .plugin(tauri_plugin_store::Builder::default().build()) + /// .setup(|app| { + /// let mut defaults = std::collections::HashMap::new(); + /// defaults.insert("foo".to_string(), "bar".into()); /// - /// # Ok(()) - /// # } + /// let store = tauri_plugin_store::StoreBuilder::new(app, "store.bin") + /// .defaults(defaults) + /// .build()?; + /// Ok(()) + /// }); + /// ``` pub fn defaults(mut self, defaults: HashMap) -> Self { - self.cache = defaults.clone(); self.defaults = Some(defaults); self } - /// Inserts multiple key-value pairs. + /// Inserts multiple default key-value pairs. /// /// # Examples /// ``` - /// # fn main() -> Result<(), Box> { - /// use tauri_plugin_store::StoreBuilder; - /// - /// let builder = StoreBuilder::new("store.bin") - /// .default("foo".to_string(), "bar".into()); - /// - /// # Ok(()) - /// # } - pub fn default(mut self, key: String, value: JsonValue) -> Self { - self.cache.insert(key.clone(), value.clone()); + /// tauri::Builder::default() + /// .plugin(tauri_plugin_store::Builder::default().build()) + /// .setup(|app| { + /// let store = tauri_plugin_store::StoreBuilder::new(app, "store.bin") + /// .default("foo".to_string(), "bar") + /// .build()?; + /// Ok(()) + /// }); + /// ``` + pub fn default(mut self, key: impl Into, value: impl Into) -> Self { + let key = key.into(); + let value = value.into(); self.defaults .get_or_insert(HashMap::new()) .insert(key, value); @@ -108,16 +116,17 @@ impl StoreBuilder { /// /// # Examples /// ``` - /// # fn main() -> Result<(), Box> { - /// use tauri_plugin_store::StoreBuilder; - /// - /// let builder = StoreBuilder::new("store.json") - /// .serialize(|cache| serde_json::to_vec(&cache).map_err(Into::into)); - /// - /// # Ok(()) - /// # } + /// tauri::Builder::default() + /// .plugin(tauri_plugin_store::Builder::default().build()) + /// .setup(|app| { + /// let store = tauri_plugin_store::StoreBuilder::new(app, "store.json") + /// .serialize(|cache| serde_json::to_vec(&cache).map_err(Into::into)) + /// .build()?; + /// Ok(()) + /// }); + /// ``` pub fn serialize(mut self, serialize: SerializeFn) -> Self { - self.serialize = serialize; + self.serialize_fn = serialize; self } @@ -125,192 +134,443 @@ impl StoreBuilder { /// /// # Examples /// ``` - /// # fn main() -> Result<(), Box> { - /// use tauri_plugin_store::StoreBuilder; - /// - /// let builder = StoreBuilder::new("store.json") - /// .deserialize(|bytes| serde_json::from_slice(&bytes).map_err(Into::into)); - /// - /// # Ok(()) - /// # } + /// tauri::Builder::default() + /// .plugin(tauri_plugin_store::Builder::default().build()) + /// .setup(|app| { + /// let store = tauri_plugin_store::StoreBuilder::new(app, "store.json") + /// .deserialize(|bytes| serde_json::from_slice(&bytes).map_err(Into::into)) + /// .build()?; + /// Ok(()) + /// }); + /// ``` pub fn deserialize(mut self, deserialize: DeserializeFn) -> Self { - self.deserialize = deserialize; + self.deserialize_fn = deserialize; self } - /// Builds the [`Store`]. + /// Auto save on modified with a debounce duration /// /// # Examples /// ``` /// tauri::Builder::default() + /// .plugin(tauri_plugin_store::Builder::default().build()) /// .setup(|app| { - /// let store = tauri_plugin_store::StoreBuilder::new("store.json").build(app.handle().clone()); + /// let store = tauri_plugin_store::StoreBuilder::new(app, "store.json") + /// .auto_save(std::time::Duration::from_millis(100)) + /// .build()?; /// Ok(()) /// }); /// ``` - pub fn build(self, app: AppHandle) -> Store { - Store { - app, - path: self.path, - defaults: self.defaults, - cache: self.cache, - serialize: self.serialize, - deserialize: self.deserialize, + pub fn auto_save(mut self, debounce_duration: Duration) -> Self { + self.auto_save = Some(debounce_duration); + self + } + + /// Disable auto save on modified with a debounce duration. + pub fn disable_auto_save(mut self) -> Self { + self.auto_save = None; + self + } + + /// Force create a new store with default values even if it already exists. + pub fn create_new(mut self) -> Self { + self.create_new = true; + self + } + + pub(crate) fn build_inner(mut self) -> crate::Result<(Arc>, ResourceId)> { + let stores = self.app.state::().stores.clone(); + let mut stores = stores.lock().unwrap(); + + self.path = resolve_store_path(&self.app, self.path)?; + + if self.create_new { + if let Some(rid) = stores.remove(&self.path) { + let _ = self.app.resources_table().take::>(rid); + } + } else if let Some(rid) = stores.get(&self.path) { + return Ok((self.app.resources_table().get(*rid).unwrap(), *rid)); + } + + // if stores.contains_key(&self.path) { + // return Err(crate::Error::AlreadyExists(self.path)); + // } + + let mut store_inner = StoreInner::new( + self.app.clone(), + self.path.clone(), + self.defaults.take(), + self.serialize_fn, + self.deserialize_fn, + ); + + if !self.create_new { + let _ = store_inner.load(); } + + let store = Store { + auto_save: self.auto_save, + auto_save_debounce_sender: Arc::new(Mutex::new(None)), + store: Arc::new(Mutex::new(store_inner)), + }; + + let store = Arc::new(store); + let rid = self.app.resources_table().add_arc(store.clone()); + stores.insert(self.path, rid); + + Ok((store, rid)) + } + + /// Load the existing store with the same path or creates a new [`Store`]. + /// + /// If a store with the same path has already been loaded its instance is returned. + /// + /// # Examples + /// ``` + /// tauri::Builder::default() + /// .plugin(tauri_plugin_store::Builder::default().build()) + /// .setup(|app| { + /// let store = tauri_plugin_store::StoreBuilder::new(app, "store.json").build(); + /// Ok(()) + /// }); + /// ``` + pub fn build(self) -> crate::Result>> { + let (store, _) = self.build_inner()?; + Ok(store) } } +enum AutoSaveMessage { + Reset, + Cancel, +} + #[derive(Clone)] -pub struct Store { +struct StoreInner { app: AppHandle, - pub(crate) path: PathBuf, - defaults: Option>, + path: PathBuf, cache: HashMap, - serialize: SerializeFn, - deserialize: DeserializeFn, + defaults: Option>, + serialize_fn: SerializeFn, + deserialize_fn: DeserializeFn, } -impl Store { - /// Update the store from the on-disk state - pub fn load(&mut self) -> Result<(), Error> { - let app_dir = self - .app - .path() - .app_data_dir() - .expect("failed to resolve app dir"); - let store_path = app_dir.join(&self.path); +impl StoreInner { + fn new( + app: AppHandle, + path: PathBuf, + defaults: Option>, + serialize_fn: SerializeFn, + deserialize_fn: DeserializeFn, + ) -> Self { + Self { + app, + path, + cache: defaults.clone().unwrap_or_default(), + defaults, + serialize_fn, + deserialize_fn, + } + } - let bytes = read(store_path)?; + /// Saves the store to disk at the store's `path`. + pub fn save(&self) -> crate::Result<()> { + fs::create_dir_all(self.path.parent().expect("invalid store path"))?; - self.cache - .extend((self.deserialize)(&bytes).map_err(Error::Deserialize)?); + let bytes = (self.serialize_fn)(&self.cache).map_err(crate::Error::Serialize)?; + fs::write(&self.path, bytes)?; Ok(()) } - /// Saves the store to disk - pub fn save(&self) -> Result<(), Error> { - let app_dir = self - .app - .path() - .app_data_dir() - .expect("failed to resolve app dir"); - let store_path = app_dir.join(&self.path); - - create_dir_all(store_path.parent().expect("invalid store path"))?; + /// Update the store from the on-disk state + pub fn load(&mut self) -> crate::Result<()> { + let bytes = fs::read(&self.path)?; - let bytes = (self.serialize)(&self.cache).map_err(Error::Serialize)?; - let mut f = File::create(&store_path)?; - f.write_all(&bytes)?; + self.cache + .extend((self.deserialize_fn)(&bytes).map_err(crate::Error::Deserialize)?); Ok(()) } - pub fn insert(&mut self, key: String, value: JsonValue) -> Result<(), Error> { + /// Inserts a key-value pair into the store. + pub fn set(&mut self, key: impl Into, value: impl Into) { + let key = key.into(); + let value = value.into(); self.cache.insert(key.clone(), value.clone()); - self.app.emit_all( - "store://change", - ChangePayload { - path: &self.path, - key: &key, - value: &value, - }, - )?; - - Ok(()) + let _ = self.emit_change_event(&key, Some(&value)); } + /// Returns a reference to the value corresponding to the key. pub fn get(&self, key: impl AsRef) -> Option<&JsonValue> { self.cache.get(key.as_ref()) } + /// Returns `true` if the given `key` exists in the store. pub fn has(&self, key: impl AsRef) -> bool { self.cache.contains_key(key.as_ref()) } - pub fn delete(&mut self, key: impl AsRef) -> Result { + /// Removes a key-value pair from the store. + pub fn delete(&mut self, key: impl AsRef) -> bool { let flag = self.cache.remove(key.as_ref()).is_some(); if flag { - self.app.emit_all( - "store://change", - ChangePayload { - path: &self.path, - key: key.as_ref(), - value: &JsonValue::Null, - }, - )?; + let _ = self.emit_change_event(key.as_ref(), None); } - Ok(flag) + flag } - pub fn clear(&mut self) -> Result<(), Error> { + /// Clears the store, removing all key-value pairs. + /// + /// Note: To clear the storage and reset it to its `default` value, use [`reset`](Self::reset) instead. + pub fn clear(&mut self) { let keys: Vec = self.cache.keys().cloned().collect(); self.cache.clear(); - for key in keys { - self.app.emit_all( - "store://change", - ChangePayload { - path: &self.path, - key: &key, - value: &JsonValue::Null, - }, - )?; + for key in &keys { + let _ = self.emit_change_event(key, None); } - Ok(()) } - pub fn reset(&mut self) -> Result<(), Error> { - let has_defaults = self.defaults.is_some(); - - if has_defaults { - if let Some(defaults) = &self.defaults { - for (key, value) in &self.cache { - if defaults.get(key) != Some(value) { - let _ = self.app.emit_all( - "store://change", - ChangePayload { - path: &self.path, - key, - value: defaults.get(key).unwrap_or(&JsonValue::Null), - }, - ); - } + /// Resets the store to its `default` value. + /// + /// If no default value has been set, this method behaves identical to [`clear`](Self::clear). + pub fn reset(&mut self) { + if let Some(defaults) = &self.defaults { + for (key, value) in &self.cache { + if defaults.get(key) != Some(value) { + let _ = self.emit_change_event(key, defaults.get(key)); } - self.cache = defaults.clone(); } - Ok(()) + for (key, value) in defaults { + if !self.cache.contains_key(key) { + let _ = self.emit_change_event(key, Some(value)); + } + } + self.cache.clone_from(defaults); } else { self.clear() } } + /// An iterator visiting all keys in arbitrary order. pub fn keys(&self) -> impl Iterator { self.cache.keys() } + /// An iterator visiting all values in arbitrary order. pub fn values(&self) -> impl Iterator { self.cache.values() } + /// An iterator visiting all key-value pairs in arbitrary order. pub fn entries(&self) -> impl Iterator { self.cache.iter() } + /// Returns the number of elements in the store. pub fn len(&self) -> usize { self.cache.len() } + /// Returns true if the store contains no elements. pub fn is_empty(&self) -> bool { self.cache.is_empty() } + + fn emit_change_event(&self, key: &str, value: Option<&JsonValue>) -> crate::Result<()> { + let state = self.app.state::(); + let stores = state.stores.lock().unwrap(); + let exists = value.is_some(); + self.app.emit( + "store://change", + ChangePayload { + path: &self.path, + resource_id: stores.get(&self.path).copied(), + key, + value, + exists, + }, + )?; + Ok(()) + } } -impl std::fmt::Debug for Store { +impl std::fmt::Debug for StoreInner { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("Store") .field("path", &self.path) - .field("defaults", &self.defaults) .field("cache", &self.cache) .finish() } } + +pub struct Store { + auto_save: Option, + auto_save_debounce_sender: Arc>>>, + store: Arc>>, +} + +impl Resource for Store { + fn close(self: Arc) { + let store = self.store.lock().unwrap(); + let state = store.app.state::(); + let mut stores = state.stores.lock().unwrap(); + stores.remove(&store.path); + } +} + +impl Store { + // /// Do something with the inner store, + // /// useful for batching some work if you need higher performance + // pub fn with_store(&self, f: impl FnOnce(&mut StoreInner) -> T) -> T { + // let mut store = self.store.lock().unwrap(); + // f(&mut store) + // } + + /// Inserts a key-value pair into the store. + pub fn set(&self, key: impl Into, value: impl Into) { + self.store.lock().unwrap().set(key.into(), value.into()); + let _ = self.trigger_auto_save(); + } + + /// Returns the value for the given `key` or `None` if the key does not exist. + pub fn get(&self, key: impl AsRef) -> Option { + self.store.lock().unwrap().get(key).cloned() + } + + /// Returns `true` if the given `key` exists in the store. + pub fn has(&self, key: impl AsRef) -> bool { + self.store.lock().unwrap().has(key) + } + + /// Removes a key-value pair from the store. + pub fn delete(&self, key: impl AsRef) -> bool { + let deleted = self.store.lock().unwrap().delete(key); + if deleted { + let _ = self.trigger_auto_save(); + } + deleted + } + + /// Clears the store, removing all key-value pairs. + /// + /// Note: To clear the storage and reset it to its `default` value, use [`reset`](Self::reset) instead. + pub fn clear(&self) { + self.store.lock().unwrap().clear(); + let _ = self.trigger_auto_save(); + } + + /// Resets the store to its `default` value. + /// + /// If no default value has been set, this method behaves identical to [`clear`](Self::clear). + pub fn reset(&self) { + self.store.lock().unwrap().reset(); + let _ = self.trigger_auto_save(); + } + + /// Returns a list of all keys in the store. + pub fn keys(&self) -> Vec { + self.store.lock().unwrap().keys().cloned().collect() + } + + /// Returns a list of all values in the store. + pub fn values(&self) -> Vec { + self.store.lock().unwrap().values().cloned().collect() + } + + /// Returns a list of all key-value pairs in the store. + pub fn entries(&self) -> Vec<(String, JsonValue)> { + self.store + .lock() + .unwrap() + .entries() + .map(|(k, v)| (k.to_owned(), v.to_owned())) + .collect() + } + + /// Returns the number of elements in the store. + pub fn length(&self) -> usize { + self.store.lock().unwrap().len() + } + + /// Returns true if the store contains no elements. + pub fn is_empty(&self) -> bool { + self.store.lock().unwrap().is_empty() + } + + /// Update the store from the on-disk state + pub fn reload(&self) -> crate::Result<()> { + self.store.lock().unwrap().load() + } + + /// Saves the store to disk at the store's `path`. + pub fn save(&self) -> crate::Result<()> { + if let Some(sender) = self.auto_save_debounce_sender.lock().unwrap().take() { + let _ = sender.send(AutoSaveMessage::Cancel); + } + self.store.lock().unwrap().save() + } + + /// Removes the store from the resource table + pub fn close_resource(&self) { + let store = self.store.lock().unwrap(); + let app = store.app.clone(); + let state = app.state::(); + let stores = state.stores.lock().unwrap(); + if let Some(rid) = stores.get(&store.path).copied() { + drop(store); + drop(stores); + let _ = app.resources_table().close(rid); + } + } + + fn trigger_auto_save(&self) -> crate::Result<()> { + let Some(auto_save_delay) = self.auto_save else { + return Ok(()); + }; + if auto_save_delay.is_zero() { + return self.save(); + } + let mut auto_save_debounce_sender = self.auto_save_debounce_sender.lock().unwrap(); + if let Some(ref sender) = *auto_save_debounce_sender { + let _ = sender.send(AutoSaveMessage::Reset); + return Ok(()); + } + let (sender, mut receiver) = unbounded_channel(); + auto_save_debounce_sender.replace(sender); + drop(auto_save_debounce_sender); + let store = self.store.clone(); + let auto_save_debounce_sender = self.auto_save_debounce_sender.clone(); + tauri::async_runtime::spawn(async move { + loop { + select! { + should_cancel = receiver.recv() => { + if matches!(should_cancel, Some(AutoSaveMessage::Cancel) | None) { + return; + } + } + _ = sleep(auto_save_delay) => { + auto_save_debounce_sender.lock().unwrap().take(); + let _ = store.lock().unwrap().save(); + return; + } + }; + } + }); + Ok(()) + } + + fn apply_pending_auto_save(&self) { + // Cancel and save if auto save is pending + if let Some(sender) = self.auto_save_debounce_sender.lock().unwrap().take() { + let _ = sender.send(AutoSaveMessage::Cancel); + let _ = self.save(); + }; + } +} + +impl Drop for Store { + fn drop(&mut self) { + self.apply_pending_auto_save(); + } +} diff --git a/plugins/stronghold/.gitignore b/plugins/stronghold/.gitignore deleted file mode 100644 index b512c09d..00000000 --- a/plugins/stronghold/.gitignore +++ /dev/null @@ -1 +0,0 @@ -node_modules \ No newline at end of file diff --git a/plugins/stronghold/CHANGELOG.md b/plugins/stronghold/CHANGELOG.md index 9e51dd31..5d7ea2d1 100644 --- a/plugins/stronghold/CHANGELOG.md +++ b/plugins/stronghold/CHANGELOG.md @@ -1,5 +1,82 @@ # Changelog +## \[2.2.0] + +- [`3a79266b`](https://github.com/tauri-apps/plugins-workspace/commit/3a79266b8cf96a55b1ae6339d725567d45a44b1d) ([#2173](https://github.com/tauri-apps/plugins-workspace/pull/2173) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Bumped all plugins to `v2.2.0`. From now, the versions for the Rust and JavaScript packages of each plugin will be in sync with each other. + +## \[2.0.1] + +- [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. + +## \[2.0.0] + +- [`e2c4dfb6`](https://github.com/tauri-apps/plugins-workspace/commit/e2c4dfb6af43e5dd8d9ceba232c315f5febd55c1) Update to tauri v2 stable release. + +## \[2.0.0-rc.1] + +- [`e2e97db5`](https://github.com/tauri-apps/plugins-workspace/commit/e2e97db51983267f5be84d4f6f0278d58834d1f5) ([#1701](https://github.com/tauri-apps/plugins-workspace/pull/1701) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri 2.0.0-rc.8 + +## \[2.0.0-rc.0] + +- [`9887d1`](https://github.com/tauri-apps/plugins-workspace/commit/9887d14bd0e971c4c0f5c1188fc4005d3fc2e29e) Update to tauri RC. + +## \[2.0.0-beta.8] + +- [`99d6ac0f`](https://github.com/tauri-apps/plugins-workspace/commit/99d6ac0f9506a6a4a1aa59c728157190a7441af6) ([#1606](https://github.com/tauri-apps/plugins-workspace/pull/1606) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) The JS packages now specify the *minimum* `@tauri-apps/api` version instead of a single exact version. +- [`6de87966`](https://github.com/tauri-apps/plugins-workspace/commit/6de87966ecc00ad9d91c25be452f1f46bd2b7e1f) ([#1597](https://github.com/tauri-apps/plugins-workspace/pull/1597) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Update to tauri beta.25. + +## \[2.0.0-beta.7] + +- [`22a17980`](https://github.com/tauri-apps/plugins-workspace/commit/22a17980ff4f6f8c40adb1b8f4ffc6dae2fe7e30) ([#1537](https://github.com/tauri-apps/plugins-workspace/pull/1537) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri beta.24. + +## \[2.0.0-beta.6] + +- [`76daee7a`](https://github.com/tauri-apps/plugins-workspace/commit/76daee7aafece34de3092c86e531cf9eb1138989) ([#1512](https://github.com/tauri-apps/plugins-workspace/pull/1512) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Update to tauri beta.23. + +## \[2.0.0-beta.5] + +- [`9013854f`](https://github.com/tauri-apps/plugins-workspace/commit/9013854f42a49a230b9dbb9d02774765528a923f)([#1382](https://github.com/tauri-apps/plugins-workspace/pull/1382)) Update to tauri beta.22. + +## \[2.0.0-beta.4] + +- [`430bd6f4`](https://github.com/tauri-apps/plugins-workspace/commit/430bd6f4f379bee5d232ae6b098ae131db7f178a)([#1363](https://github.com/tauri-apps/plugins-workspace/pull/1363)) Update to tauri beta.20. + +## \[2.0.0-beta.3] + +- [`bd1ed590`](https://github.com/tauri-apps/plugins-workspace/commit/bd1ed5903ffcce5500310dac1e59e8c67674ef1e)([#1237](https://github.com/tauri-apps/plugins-workspace/pull/1237)) Update to tauri beta.17. + +## \[2.0.0-beta.3] + +- [`a04ea2f`](https://github.com/tauri-apps/plugins-workspace/commit/a04ea2f38294d5a3987578283badc8eec87a7752)([#1071](https://github.com/tauri-apps/plugins-workspace/pull/1071)) The global API script is now only added to the binary when the `withGlobalTauri` config is true. + +## \[2.0.0-beta.2] + +- [`99bea25`](https://github.com/tauri-apps/plugins-workspace/commit/99bea2559c2c0648c2519c50a18cd124dacef57b)([#1005](https://github.com/tauri-apps/plugins-workspace/pull/1005)) Update to tauri beta.8. + +## \[2.0.0-beta.1] + +- [`569defb`](https://github.com/tauri-apps/plugins-workspace/commit/569defbe9492e38938554bb7bdc1be9151456d21) Update to tauri beta.4. + +## \[2.0.0-beta.0] + +- [`d198c01`](https://github.com/tauri-apps/plugins-workspace/commit/d198c014863ee260cb0de88a14b7fc4356ef7474)([#862](https://github.com/tauri-apps/plugins-workspace/pull/862)) Update to tauri beta. + +## \[2.0.0-alpha.6] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.13. + +## \[2.0.0-alpha.5] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.12. + +## \[2.0.0-alpha.4] + +- [`e438e0a`](https://github.com/tauri-apps/plugins-workspace/commit/e438e0a62d4b430a5159f05f13ecd397dd891a0d)([#676](https://github.com/tauri-apps/plugins-workspace/pull/676)) Update to @tauri-apps/api v2.0.0-alpha.11. + +## \[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.9. + ## \[2.0.0-alpha.2] - [`4e2cef9`](https://github.com/tauri-apps/plugins-workspace/commit/4e2cef9b702bbbb9cf4ee17de50791cb21f1b2a4)([#593](https://github.com/tauri-apps/plugins-workspace/pull/593)) Update to alpha.12. diff --git a/plugins/stronghold/Cargo.toml b/plugins/stronghold/Cargo.toml index 6341a5a3..7d40957a 100644 --- a/plugins/stronghold/Cargo.toml +++ b/plugins/stronghold/Cargo.toml @@ -1,14 +1,27 @@ [package] name = "tauri-plugin-stronghold" -version = "2.0.0-alpha.2" -description = "Store secrets and keys using the IOTA Stronghold encrypted database." +version = "2.2.0" +description = "Store secrets and keys using the IOTA Stronghold secret management engine." authors = { workspace = true } license = { workspace = true } edition = { workspace = true } rust-version = { workspace = true } +repository = { workspace = true } +links = "tauri-plugin-stronghold" [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] + +[package.metadata.platforms.support] +windows = { level = "full", notes = "" } +linux = { level = "full", notes = "" } +macos = { level = "full", notes = "" } +android = { level = "full", notes = "" } +ios = { level = "full", notes = "" } + +[build-dependencies] +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } @@ -16,11 +29,18 @@ serde_json = { workspace = true } tauri = { workspace = true } log = { workspace = true } thiserror = { workspace = true } -iota_stronghold = "1" +iota_stronghold = "2" iota-crypto = "0.23" hex = "0.4" -zeroize = { version = "1", features = [ "zeroize_derive" ] } +zeroize = { version = "1", features = ["zeroize_derive"] } +rust-argon2 = { version = "2", optional = true } +rand_chacha = { version = "0.3.1", optional = true } +rand_core = { version = "0.6.4", features = ["getrandom"], optional = true } [dev-dependencies] rand = "0.8" rusty-fork = "0.3" + +[features] +default = ["kdf"] +kdf = ["dep:rust-argon2", "dep:rand_chacha", "dep:rand_core"] diff --git a/plugins/stronghold/README.md b/plugins/stronghold/README.md index e30e92a7..6dd16519 100644 --- a/plugins/stronghold/README.md +++ b/plugins/stronghold/README.md @@ -1,10 +1,18 @@ ![plugin-stronghold](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/stronghold/banner.png) -Store secrets and keys using the [IOTA Stronghold](https://github.com/iotaledger/stronghold.rs) encrypted database and secure runtime. +Store secrets and keys using the [IOTA Stronghold](https://github.com/iotaledger/stronghold.rs) secret management engine. + +| Platform | Supported | +| -------- | --------- | +| Linux | ✓ | +| Windows | ✓ | +| macOS | ✓ | +| Android | ✓ | +| iOS | ✓ | ## Install -_This plugin requires a Rust version of at least **1.70**_ +_This plugin requires a Rust version of at least **1.77.2**_ There are three general methods of installation that we can recommend. @@ -18,14 +26,14 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] -tauri-plugin-stronghold = "2.0.0-alpha" +tauri-plugin-stronghold = "2.0.0" # alternatively with Git: tauri-plugin-stronghold = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` You can install the JavaScript Guest bindings using your preferred JavaScript package manager: -> Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use. +> Note: If your JavaScript package manager cannot install packages from git monorepos, you can still use the code by manually copying the [Guest bindings](./guest-js/index.ts) into your source files. ```sh pnpm add @tauri-apps/plugin-stronghold @@ -46,14 +54,31 @@ yarn add https://github.com/tauri-apps/tauri-plugin-stronghold#v2 First you need to register the core plugin with Tauri: -`src-tauri/src/main.rs` +`src-tauri/src/lib.rs` ```rust fn main() { tauri::Builder::default() .plugin(tauri_plugin_stronghold::Builder::new(|password| { - // TODO: hash the password here with e.g. argon2, blake2b or any other secure algorithm - todo!() + // Hash the password here with e.g. argon2, blake2b or any other secure algorithm + // Here is an example implementation using the `rust-argon2` crate for hashing the password + + use argon2::{hash_raw, Config, Variant, Version}; + + let config = Config { + lanes: 4, + mem_cost: 10_000, + time_cost: 10, + variant: Variant::Argon2id, + version: Version::Version13, + ..Default::default() + }; + + let salt = "your-salt".as_bytes(); + + let key = hash_raw(password.as_ref(), salt, &config).expect("failed to hash password"); + + key.to_vec() }) .build()) .run(tauri::generate_context!()) @@ -64,15 +89,79 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import { Stronghold, Location } from "@tauri-apps/plugin-stronghold"; +import { Stronghold, Location, Client } from "tauri-plugin-stronghold-api"; +import { appDataDir } from "@tauri-apps/api/path"; + +const initStronghold = async () => { + const vaultPath = `${await appDataDir()}/vault.hold`; + + const vaultKey = "The key to the vault"; + + const stronghold = await Stronghold.load(vaultPath, vaultKey); + + let client: Client; + + const clientName = "name your client"; + + try { + client = await hold.loadClient(clientName); + } catch { + client = await hold.createClient(clientName); + } + + return { + stronghold, + client, + }; +}; -// TODO +const { stronghold, client } = await initStronghold(); + +const store = client.getStore(); + +const key = "my_key"; + +// Insert a record to the store + +const data = Array.from(new TextEncoder().encode("Hello, World!")); + +await store.insert(key, data); + +// Read a record from store + +const data = await store.get(key); + +const value = new TextDecoder().decode(new Uint8Array(data)); + +// Save your updates + +await stronghold.save(); + +// Remove a record from store + +await store.remove(key); ``` ## Contributing PRs accepted. Please make sure to read the Contributing Guide before making a pull request. +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + ## License Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. diff --git a/plugins/stronghold/SECURITY.md b/plugins/stronghold/SECURITY.md new file mode 100644 index 00000000..4f09bbac --- /dev/null +++ b/plugins/stronghold/SECURITY.md @@ -0,0 +1,23 @@ +# Security Policy + +**Do not report security vulnerabilities through public GitHub issues.** + +**Please use the [Private Vulnerability Disclosure](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) feature of GitHub.** + +Include as much of the following information: + +- Type of issue (e.g. improper input parsing, privilege escalation, etc.) +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- The distribution affected or used to help us with reproduction of the issue +- Step-by-step instructions to reproduce the issue +- Ideally a reproduction repository +- Impact of the issue, including how an attacker might exploit the issue + +We prefer to receive reports in English. + +## Contact + +Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). + +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/stronghold/api-iife.js b/plugins/stronghold/api-iife.js new file mode 100644 index 00000000..aabe9ed2 --- /dev/null +++ b/plugins/stronghold/api-iife.js @@ -0,0 +1 @@ +if("__TAURI__"in window){var __TAURI_PLUGIN_STRONGHOLD__=function(t){"use strict";async function e(t,e={},r){return window.__TAURI_INTERNALS__.invoke(t,e,r)}"function"==typeof SuppressedError&&SuppressedError;class r{constructor(t,e){this.type=t,this.payload=e}static generic(t,e){return new r("Generic",{vault:t,record:e})}static counter(t,e){return new r("Counter",{vault:t,counter:e})}}class n{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 a{constructor(t,e){this.path=t,this.name=e}getVault(t){return new o(this.path,this.name,t)}getStore(){return new s(this.path,this.name)}}class s{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:t}).then((t=>t&&Uint8Array.from(t)))}async insert(t,r,n){await e("plugin:stronghold|save_store_record",{snapshotPath:this.path,client:this.client,key:t,value:r,lifetime:n})}async remove(t){return await e("plugin:stronghold|remove_store_record",{snapshotPath:this.path,client:this.client,key:t}).then((t=>t&&Uint8Array.from(t)))}}class o extends n{constructor(t,e,r){super({snapshotPath:t,client:e,vault:r}),this.path=t,this.client=e,this.name=r}async insert(t,r){await e("plugin:stronghold|save_secret",{snapshotPath:this.path,client:this.client,vault:this.name,recordPath:t,secret:r})}async remove(t){await e("plugin:stronghold|remove_secret",{snapshotPath:this.path,client:this.client,vault:this.name,recordPath:t.payload.record})}}class i{constructor(t){this.path=t}static async load(t,r){return await e("plugin:stronghold|initialize",{snapshotPath:t,password:r}).then((()=>new i(t)))}async unload(){await e("plugin:stronghold|destroy",{snapshotPath:this.path})}async loadClient(t){return await e("plugin:stronghold|load_client",{snapshotPath:this.path,client:t}).then((()=>new a(this.path,t)))}async createClient(t){return await e("plugin:stronghold|create_client",{snapshotPath:this.path,client:t}).then((()=>new a(this.path,t)))}async save(){await e("plugin:stronghold|save",{snapshotPath:this.path})}}return t.Client=a,t.Location=r,t.Store=s,t.Stronghold=i,t.Vault=o,t}({});Object.defineProperty(window.__TAURI__,"stronghold",{value:__TAURI_PLUGIN_STRONGHOLD__})} diff --git a/plugins/stronghold/build.rs b/plugins/stronghold/build.rs new file mode 100644 index 00000000..e9550e25 --- /dev/null +++ b/plugins/stronghold/build.rs @@ -0,0 +1,23 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +const COMMANDS: &[&str] = &[ + "initialize", + "destroy", + "save", + "create_client", + "load_client", + "get_store_record", + "save_store_record", + "remove_store_record", + "save_secret", + "remove_secret", + "execute_procedure", +]; + +fn main() { + tauri_plugin::Builder::new(COMMANDS) + .global_api_script_path("./api-iife.js") + .build(); +} diff --git a/plugins/stronghold/guest-js/index.ts b/plugins/stronghold/guest-js/index.ts index b52043d3..c1945a21 100644 --- a/plugins/stronghold/guest-js/index.ts +++ b/plugins/stronghold/guest-js/index.ts @@ -2,122 +2,112 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { invoke } from "@tauri-apps/api/primitives"; +import { invoke } from '@tauri-apps/api/core' -type BytesDto = string | number[]; export type ClientPath = | string | Iterable | ArrayLike - | ArrayBuffer; + | ArrayBuffer export type VaultPath = | string | Iterable | ArrayLike - | ArrayBuffer; + | ArrayBuffer export type RecordPath = | string | Iterable | ArrayLike - | ArrayBuffer; + | ArrayBuffer export type StoreKey = | string | Iterable | ArrayLike - | ArrayBuffer; - -function toBytesDto( - v: ClientPath | VaultPath | RecordPath | StoreKey, -): string | number[] { - if (typeof v === "string") { - return v; - } - return Array.from(v instanceof ArrayBuffer ? new Uint8Array(v) : v); -} + | ArrayBuffer export interface ConnectionLimits { - maxPendingIncoming?: number; - maxPendingOutgoing?: number; - maxEstablishedIncoming?: number; - maxEstablishedOutgoing?: number; - maxEstablishedPerPeer?: number; - maxEstablishedTotal?: number; + maxPendingIncoming?: number + maxPendingOutgoing?: number + maxEstablishedIncoming?: number + maxEstablishedOutgoing?: number + maxEstablishedPerPeer?: number + maxEstablishedTotal?: number } export interface PeerAddress { - known: string[]; // multiaddr - use_relay_fallback: boolean; + known: string[] // multiaddr + use_relay_fallback: boolean } export interface AddressInfo { - peers: Map; - relays: string[]; // peers + peers: Map + relays: string[] // peers } export interface ClientAccess { - useVaultDefault?: boolean; - useVaultExceptions?: Map; - writeVaultDefault?: boolean; - writeVaultExceptions?: Map; - cloneVaultDefault?: boolean; - cloneVaultExceptions?: Map; - readStore?: boolean; - writeStore?: boolean; + useVaultDefault?: boolean + useVaultExceptions?: Map + writeVaultDefault?: boolean + writeVaultExceptions?: Map + cloneVaultDefault?: boolean + cloneVaultExceptions?: Map + readStore?: boolean + writeStore?: boolean } export interface Permissions { - default?: ClientAccess; - exceptions?: Map; + default?: ClientAccess + exceptions?: Map } export interface NetworkConfig { - requestTimeout?: Duration; - connectionTimeout?: Duration; - connectionsLimit?: ConnectionLimits; - enableMdns?: boolean; - enableRelay?: boolean; - addresses?: AddressInfo; - peerPermissions?: Map; - permissionsDefault?: Permissions; + requestTimeout?: Duration + connectionTimeout?: Duration + connectionsLimit?: ConnectionLimits + enableMdns?: boolean + enableRelay?: boolean + addresses?: AddressInfo + peerPermissions?: Map + permissionsDefault?: Permissions } /** A duration definition. */ export interface Duration { /** The number of whole seconds contained by this Duration. */ - secs: number; - /** The fractional part of this Duration, in nanoseconds. Must be greater or equal to 0 and smaller than 1e+9 (the max number of nanoseoncds in a second)*/ - nanos: number; + secs: number + /** The fractional part of this Duration, in nanoseconds. Must be greater or equal to 0 and smaller than 1e+9 (the max number of nanoseoncds in a second) */ + nanos: number } export class Location { - type: string; - payload: Record; + type: string + payload: Record constructor(type: string, payload: Record) { - this.type = type; - this.payload = payload; + this.type = type + this.payload = payload } static generic(vault: VaultPath, record: RecordPath): Location { - return new Location("Generic", { - vault: toBytesDto(vault), - record: toBytesDto(record), - }); + return new Location('Generic', { + vault, + record + }) } static counter(vault: VaultPath, counter: number): Location { - return new Location("Counter", { - vault: toBytesDto(vault), - counter, - }); + return new Location('Counter', { + vault, + counter + }) } } class ProcedureExecutor { - procedureArgs: Record; + procedureArgs: Record constructor(procedureArgs: Record) { - this.procedureArgs = procedureArgs; + this.procedureArgs = procedureArgs } /** @@ -129,18 +119,18 @@ class ProcedureExecutor { */ async generateSLIP10Seed( outputLocation: Location, - sizeBytes?: number, + sizeBytes?: number ): Promise { - return await invoke("plugin:stronghold|execute_procedure", { + return await invoke('plugin:stronghold|execute_procedure', { ...this.procedureArgs, procedure: { - type: "SLIP10Generate", + type: 'SLIP10Generate', payload: { output: outputLocation, - sizeBytes, - }, - }, - }).then((n) => Uint8Array.from(n)); + sizeBytes + } + } + }).then((n) => Uint8Array.from(n)) } /** @@ -154,24 +144,24 @@ class ProcedureExecutor { */ async deriveSLIP10( chain: number[], - source: "Seed" | "Key", + source: 'Seed' | 'Key', sourceLocation: Location, - outputLocation: Location, + outputLocation: Location ): Promise { - return await invoke("plugin:stronghold|execute_procedure", { + return await invoke('plugin:stronghold|execute_procedure', { ...this.procedureArgs, procedure: { - type: "SLIP10Derive", + type: 'SLIP10Derive', payload: { chain, input: { type: source, - payload: sourceLocation, + payload: sourceLocation }, - output: outputLocation, - }, - }, - }).then((n) => Uint8Array.from(n)); + output: outputLocation + } + } + }).then((n) => Uint8Array.from(n)) } /** @@ -185,19 +175,19 @@ class ProcedureExecutor { async recoverBIP39( mnemonic: string, outputLocation: Location, - passphrase?: string, + passphrase?: string ): Promise { - return await invoke("plugin:stronghold|execute_procedure", { + return await invoke('plugin:stronghold|execute_procedure', { ...this.procedureArgs, procedure: { - type: "BIP39Recover", + type: 'BIP39Recover', payload: { mnemonic, passphrase, - output: outputLocation, - }, - }, - }).then((n) => Uint8Array.from(n)); + output: outputLocation + } + } + }).then((n) => Uint8Array.from(n)) } /** @@ -209,18 +199,18 @@ class ProcedureExecutor { */ async generateBIP39( outputLocation: Location, - passphrase?: string, + passphrase?: string ): Promise { - return await invoke("plugin:stronghold|execute_procedure", { + return await invoke('plugin:stronghold|execute_procedure', { ...this.procedureArgs, procedure: { - type: "BIP39Generate", + type: 'BIP39Generate', payload: { output: outputLocation, - passphrase, - }, - }, - }).then((n) => Uint8Array.from(n)); + passphrase + } + } + }).then((n) => Uint8Array.from(n)) } /** @@ -231,16 +221,16 @@ class ProcedureExecutor { * @since 2.0.0 */ async getEd25519PublicKey(privateKeyLocation: Location): Promise { - return await invoke("plugin:stronghold|execute_procedure", { + return await invoke('plugin:stronghold|execute_procedure', { ...this.procedureArgs, procedure: { - type: "PublicKey", + type: 'PublicKey', payload: { - type: "Ed25519", - privateKey: privateKeyLocation, - }, - }, - }).then((n) => Uint8Array.from(n)); + type: 'Ed25519', + privateKey: privateKeyLocation + } + } + }).then((n) => Uint8Array.from(n)) } /** @@ -253,28 +243,28 @@ class ProcedureExecutor { */ async signEd25519( privateKeyLocation: Location, - msg: string, + msg: string ): Promise { - return await invoke("plugin:stronghold|execute_procedure", { + return await invoke('plugin:stronghold|execute_procedure', { ...this.procedureArgs, procedure: { - type: "Ed25519Sign", + type: 'Ed25519Sign', payload: { privateKey: privateKeyLocation, - msg, - }, - }, - }).then((n) => Uint8Array.from(n)); + msg + } + } + }).then((n) => Uint8Array.from(n)) } } export class Client { - path: string; - name: BytesDto; + path: string + name: ClientPath constructor(path: string, name: ClientPath) { - this.path = path; - this.name = toBytesDto(name); + this.path = path + this.name = name } /** @@ -284,54 +274,54 @@ export class Client { * @returns */ getVault(name: VaultPath): Vault { - return new Vault(this.path, this.name, toBytesDto(name)); + return new Vault(this.path, this.name, name) } getStore(): Store { - return new Store(this.path, this.name); + return new Store(this.path, this.name) } } export class Store { - path: string; - client: BytesDto; + path: string + client: ClientPath - constructor(path: string, client: BytesDto) { - this.path = path; - this.client = client; + constructor(path: string, client: ClientPath) { + this.path = path + this.client = client } async get(key: StoreKey): Promise { - return await invoke("plugin:stronghold|get_store_record", { + return await invoke('plugin:stronghold|get_store_record', { snapshotPath: this.path, client: this.client, - key: toBytesDto(key), - }).then((v) => (v != null ? Uint8Array.from(v) : null)); + key + }).then((v) => v && Uint8Array.from(v)) } async insert( key: StoreKey, value: number[], - lifetime?: Duration, + lifetime?: Duration ): Promise { - return await invoke("plugin:stronghold|save_store_record", { + await invoke('plugin:stronghold|save_store_record', { snapshotPath: this.path, client: this.client, - key: toBytesDto(key), + key, value, - lifetime, - }); + lifetime + }) } async remove(key: StoreKey): Promise { return await invoke( - "plugin:stronghold|remove_store_record", + 'plugin:stronghold|remove_store_record', { snapshotPath: this.path, client: this.client, - key: toBytesDto(key), - }, - ).then((v) => (v != null ? Uint8Array.from(v) : null)); + key + } + ).then((v) => v && Uint8Array.from(v)) } } @@ -342,20 +332,20 @@ export class Store { */ export class Vault extends ProcedureExecutor { /** The vault path. */ - path: string; - client: BytesDto; + path: string + client: ClientPath /** The vault name. */ - name: BytesDto; + name: VaultPath constructor(path: string, client: ClientPath, name: VaultPath) { super({ snapshotPath: path, client, - vault: name, - }); - this.path = path; - this.client = toBytesDto(client); - this.name = toBytesDto(name); + vault: name + }) + this.path = path + this.client = client + this.name = name } /** @@ -366,13 +356,13 @@ export class Vault extends ProcedureExecutor { * @returns */ async insert(recordPath: RecordPath, secret: number[]): Promise { - return await invoke("plugin:stronghold|save_secret", { + await invoke('plugin:stronghold|save_secret', { snapshotPath: this.path, client: this.client, vault: this.name, - recordPath: toBytesDto(recordPath), - secret, - }); + recordPath, + secret + }) } /** @@ -382,12 +372,12 @@ export class Vault extends ProcedureExecutor { * @returns */ async remove(location: Location): Promise { - return await invoke("plugin:stronghold|remove_secret", { + await invoke('plugin:stronghold|remove_secret', { snapshotPath: this.path, client: this.client, vault: this.name, - recordPath: location.payload.record, - }); + recordPath: location.payload.record + }) } } @@ -395,7 +385,7 @@ export class Vault extends ProcedureExecutor { * A representation of an access to a stronghold. */ export class Stronghold { - path: string; + path: string /** * Initializes a stronghold. @@ -404,7 +394,7 @@ export class Stronghold { * @param password */ private constructor(path: string) { - this.path = path; + this.path = path } /** @@ -413,33 +403,33 @@ export class Stronghold { * @returns */ static async load(path: string, password: string): Promise { - return await invoke("plugin:stronghold|initialize", { + return await invoke('plugin:stronghold|initialize', { snapshotPath: path, - password, - }).then(() => new Stronghold(path)); + password + }).then(() => new Stronghold(path)) } /** * Remove this instance from the cache. */ async unload(): Promise { - return await invoke("plugin:stronghold|destroy", { - snapshotPath: this.path, - }); + await invoke('plugin:stronghold|destroy', { + snapshotPath: this.path + }) } async loadClient(client: ClientPath): Promise { - return await invoke("plugin:stronghold|load_client", { + return await invoke('plugin:stronghold|load_client', { snapshotPath: this.path, - client: toBytesDto(client), - }).then(() => new Client(this.path, client)); + client + }).then(() => new Client(this.path, client)) } async createClient(client: ClientPath): Promise { - return await invoke("plugin:stronghold|create_client", { + return await invoke('plugin:stronghold|create_client', { snapshotPath: this.path, - client: toBytesDto(client), - }).then(() => new Client(this.path, client)); + client + }).then(() => new Client(this.path, client)) } /** @@ -447,8 +437,8 @@ export class Stronghold { * @returns */ async save(): Promise { - return await invoke("plugin:stronghold|save", { - snapshotPath: this.path, - }); + await invoke('plugin:stronghold|save', { + snapshotPath: this.path + }) } } diff --git a/plugins/stronghold/package.json b/plugins/stronghold/package.json index e0e91eae..87611e2a 100644 --- a/plugins/stronghold/package.json +++ b/plugins/stronghold/package.json @@ -1,33 +1,30 @@ { "name": "@tauri-apps/plugin-stronghold", - "version": "2.0.0-alpha.2", + "version": "2.2.0", "description": "Store secrets and keys using the IOTA Stronghold encrypted database.", - "license": "MIT or APACHE-2.0", + "license": "MIT OR Apache-2.0", "authors": [ "Tauri Programme within The Commons Conservancy" ], + "repository": "https://github.com/tauri-apps/plugins-workspace", "type": "module", - "browser": "dist-js/index.min.js", - "module": "dist-js/index.mjs", - "types": "dist-js/index.d.ts", + "types": "./dist-js/index.d.ts", + "main": "./dist-js/index.cjs", + "module": "./dist-js/index.js", "exports": { - "import": "./dist-js/index.mjs", "types": "./dist-js/index.d.ts", - "browser": "./dist-js/index.min.js" + "import": "./dist-js/index.js", + "require": "./dist-js/index.cjs" }, "scripts": { "build": "rollup -c" }, "files": [ "dist-js", - "!dist-js/**/*.map", "README.md", "LICENSE" ], - "devDependencies": { - "tslib": "2.6.0" - }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.9" + "@tauri-apps/api": "^2.0.0" } } diff --git a/plugins/stronghold/permissions/autogenerated/commands/create_client.toml b/plugins/stronghold/permissions/autogenerated/commands/create_client.toml new file mode 100644 index 00000000..1405d1e2 --- /dev/null +++ b/plugins/stronghold/permissions/autogenerated/commands/create_client.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-create-client" +description = "Enables the create_client command without any pre-configured scope." +commands.allow = ["create_client"] + +[[permission]] +identifier = "deny-create-client" +description = "Denies the create_client command without any pre-configured scope." +commands.deny = ["create_client"] diff --git a/plugins/stronghold/permissions/autogenerated/commands/destroy.toml b/plugins/stronghold/permissions/autogenerated/commands/destroy.toml new file mode 100644 index 00000000..79580619 --- /dev/null +++ b/plugins/stronghold/permissions/autogenerated/commands/destroy.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-destroy" +description = "Enables the destroy command without any pre-configured scope." +commands.allow = ["destroy"] + +[[permission]] +identifier = "deny-destroy" +description = "Denies the destroy command without any pre-configured scope." +commands.deny = ["destroy"] diff --git a/plugins/stronghold/permissions/autogenerated/commands/execute_procedure.toml b/plugins/stronghold/permissions/autogenerated/commands/execute_procedure.toml new file mode 100644 index 00000000..f6c2d2b1 --- /dev/null +++ b/plugins/stronghold/permissions/autogenerated/commands/execute_procedure.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-execute-procedure" +description = "Enables the execute_procedure command without any pre-configured scope." +commands.allow = ["execute_procedure"] + +[[permission]] +identifier = "deny-execute-procedure" +description = "Denies the execute_procedure command without any pre-configured scope." +commands.deny = ["execute_procedure"] diff --git a/plugins/stronghold/permissions/autogenerated/commands/get_store_record.toml b/plugins/stronghold/permissions/autogenerated/commands/get_store_record.toml new file mode 100644 index 00000000..84a9e53c --- /dev/null +++ b/plugins/stronghold/permissions/autogenerated/commands/get_store_record.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-get-store-record" +description = "Enables the get_store_record command without any pre-configured scope." +commands.allow = ["get_store_record"] + +[[permission]] +identifier = "deny-get-store-record" +description = "Denies the get_store_record command without any pre-configured scope." +commands.deny = ["get_store_record"] diff --git a/plugins/stronghold/permissions/autogenerated/commands/initialize.toml b/plugins/stronghold/permissions/autogenerated/commands/initialize.toml new file mode 100644 index 00000000..73961d13 --- /dev/null +++ b/plugins/stronghold/permissions/autogenerated/commands/initialize.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-initialize" +description = "Enables the initialize command without any pre-configured scope." +commands.allow = ["initialize"] + +[[permission]] +identifier = "deny-initialize" +description = "Denies the initialize command without any pre-configured scope." +commands.deny = ["initialize"] diff --git a/plugins/stronghold/permissions/autogenerated/commands/load_client.toml b/plugins/stronghold/permissions/autogenerated/commands/load_client.toml new file mode 100644 index 00000000..77949c10 --- /dev/null +++ b/plugins/stronghold/permissions/autogenerated/commands/load_client.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-load-client" +description = "Enables the load_client command without any pre-configured scope." +commands.allow = ["load_client"] + +[[permission]] +identifier = "deny-load-client" +description = "Denies the load_client command without any pre-configured scope." +commands.deny = ["load_client"] diff --git a/plugins/stronghold/permissions/autogenerated/commands/remove_secret.toml b/plugins/stronghold/permissions/autogenerated/commands/remove_secret.toml new file mode 100644 index 00000000..6dafb68b --- /dev/null +++ b/plugins/stronghold/permissions/autogenerated/commands/remove_secret.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-remove-secret" +description = "Enables the remove_secret command without any pre-configured scope." +commands.allow = ["remove_secret"] + +[[permission]] +identifier = "deny-remove-secret" +description = "Denies the remove_secret command without any pre-configured scope." +commands.deny = ["remove_secret"] diff --git a/plugins/stronghold/permissions/autogenerated/commands/remove_store_record.toml b/plugins/stronghold/permissions/autogenerated/commands/remove_store_record.toml new file mode 100644 index 00000000..20fd1e8a --- /dev/null +++ b/plugins/stronghold/permissions/autogenerated/commands/remove_store_record.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-remove-store-record" +description = "Enables the remove_store_record command without any pre-configured scope." +commands.allow = ["remove_store_record"] + +[[permission]] +identifier = "deny-remove-store-record" +description = "Denies the remove_store_record command without any pre-configured scope." +commands.deny = ["remove_store_record"] diff --git a/plugins/stronghold/permissions/autogenerated/commands/save.toml b/plugins/stronghold/permissions/autogenerated/commands/save.toml new file mode 100644 index 00000000..d3e84220 --- /dev/null +++ b/plugins/stronghold/permissions/autogenerated/commands/save.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-save" +description = "Enables the save command without any pre-configured scope." +commands.allow = ["save"] + +[[permission]] +identifier = "deny-save" +description = "Denies the save command without any pre-configured scope." +commands.deny = ["save"] diff --git a/plugins/stronghold/permissions/autogenerated/commands/save_secret.toml b/plugins/stronghold/permissions/autogenerated/commands/save_secret.toml new file mode 100644 index 00000000..d999f0b2 --- /dev/null +++ b/plugins/stronghold/permissions/autogenerated/commands/save_secret.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-save-secret" +description = "Enables the save_secret command without any pre-configured scope." +commands.allow = ["save_secret"] + +[[permission]] +identifier = "deny-save-secret" +description = "Denies the save_secret command without any pre-configured scope." +commands.deny = ["save_secret"] diff --git a/plugins/stronghold/permissions/autogenerated/commands/save_store_record.toml b/plugins/stronghold/permissions/autogenerated/commands/save_store_record.toml new file mode 100644 index 00000000..8292ded0 --- /dev/null +++ b/plugins/stronghold/permissions/autogenerated/commands/save_store_record.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-save-store-record" +description = "Enables the save_store_record command without any pre-configured scope." +commands.allow = ["save_store_record"] + +[[permission]] +identifier = "deny-save-store-record" +description = "Denies the save_store_record command without any pre-configured scope." +commands.deny = ["save_store_record"] diff --git a/plugins/stronghold/permissions/autogenerated/reference.md b/plugins/stronghold/permissions/autogenerated/reference.md new file mode 100644 index 00000000..c00e56c3 --- /dev/null +++ b/plugins/stronghold/permissions/autogenerated/reference.md @@ -0,0 +1,317 @@ +## Default Permission + +This permission set configures what kind of +operations are available from the stronghold plugin. + +#### Granted Permissions + +All non-destructive operations are enabled by default. + + + +#### This default permission set includes the following: + +- `allow-create-client` +- `allow-get-store-record` +- `allow-initialize` +- `allow-execute-procedure` +- `allow-load-client` +- `allow-save-secret` +- `allow-save-store-record` +- `allow-save` + +## Permission Table + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IdentifierDescription
+ +`stronghold:allow-create-client` + + + +Enables the create_client command without any pre-configured scope. + +
+ +`stronghold:deny-create-client` + + + +Denies the create_client command without any pre-configured scope. + +
+ +`stronghold:allow-destroy` + + + +Enables the destroy command without any pre-configured scope. + +
+ +`stronghold:deny-destroy` + + + +Denies the destroy command without any pre-configured scope. + +
+ +`stronghold:allow-execute-procedure` + + + +Enables the execute_procedure command without any pre-configured scope. + +
+ +`stronghold:deny-execute-procedure` + + + +Denies the execute_procedure command without any pre-configured scope. + +
+ +`stronghold:allow-get-store-record` + + + +Enables the get_store_record command without any pre-configured scope. + +
+ +`stronghold:deny-get-store-record` + + + +Denies the get_store_record command without any pre-configured scope. + +
+ +`stronghold:allow-initialize` + + + +Enables the initialize command without any pre-configured scope. + +
+ +`stronghold:deny-initialize` + + + +Denies the initialize command without any pre-configured scope. + +
+ +`stronghold:allow-load-client` + + + +Enables the load_client command without any pre-configured scope. + +
+ +`stronghold:deny-load-client` + + + +Denies the load_client command without any pre-configured scope. + +
+ +`stronghold:allow-remove-secret` + + + +Enables the remove_secret command without any pre-configured scope. + +
+ +`stronghold:deny-remove-secret` + + + +Denies the remove_secret command without any pre-configured scope. + +
+ +`stronghold:allow-remove-store-record` + + + +Enables the remove_store_record command without any pre-configured scope. + +
+ +`stronghold:deny-remove-store-record` + + + +Denies the remove_store_record command without any pre-configured scope. + +
+ +`stronghold:allow-save` + + + +Enables the save command without any pre-configured scope. + +
+ +`stronghold:deny-save` + + + +Denies the save command without any pre-configured scope. + +
+ +`stronghold:allow-save-secret` + + + +Enables the save_secret command without any pre-configured scope. + +
+ +`stronghold:deny-save-secret` + + + +Denies the save_secret command without any pre-configured scope. + +
+ +`stronghold:allow-save-store-record` + + + +Enables the save_store_record command without any pre-configured scope. + +
+ +`stronghold:deny-save-store-record` + + + +Denies the save_store_record command without any pre-configured scope. + +
diff --git a/plugins/stronghold/permissions/default.toml b/plugins/stronghold/permissions/default.toml new file mode 100644 index 00000000..c157fe7e --- /dev/null +++ b/plugins/stronghold/permissions/default.toml @@ -0,0 +1,22 @@ +"$schema" = "schemas/schema.json" + +[default] +description = """ +This permission set configures what kind of +operations are available from the stronghold plugin. + +#### Granted Permissions + +All non-destructive operations are enabled by default. + +""" +permissions = [ + "allow-create-client", + "allow-get-store-record", + "allow-initialize", + "allow-execute-procedure", + "allow-load-client", + "allow-save-secret", + "allow-save-store-record", + "allow-save", +] diff --git a/plugins/stronghold/permissions/schemas/schema.json b/plugins/stronghold/permissions/schemas/schema.json new file mode 100644 index 00000000..6af87c6a --- /dev/null +++ b/plugins/stronghold/permissions/schemas/schema.json @@ -0,0 +1,438 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "PermissionFile", + "description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.", + "type": "object", + "properties": { + "default": { + "description": "The default permission set for the plugin", + "anyOf": [ + { + "$ref": "#/definitions/DefaultPermission" + }, + { + "type": "null" + } + ] + }, + "set": { + "description": "A list of permissions sets defined", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionSet" + } + }, + "permission": { + "description": "A list of inlined permissions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Permission" + } + } + }, + "definitions": { + "DefaultPermission": { + "description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.", + "type": "object", + "required": [ + "permissions" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "PermissionSet": { + "description": "A set of direct permissions grouped together under a new name.", + "type": "object", + "required": [ + "description", + "identifier", + "permissions" + ], + "properties": { + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does.", + "type": "string" + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionKind" + } + } + } + }, + "Permission": { + "description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.", + "type": "object", + "required": [ + "identifier" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri internal convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "commands": { + "description": "Allowed or denied commands when using this permission.", + "default": { + "allow": [], + "deny": [] + }, + "allOf": [ + { + "$ref": "#/definitions/Commands" + } + ] + }, + "scope": { + "description": "Allowed or denied scoped when using this permission.", + "allOf": [ + { + "$ref": "#/definitions/Scopes" + } + ] + }, + "platforms": { + "description": "Target platforms this permission applies. By default all platforms are affected by this permission.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Target" + } + } + } + }, + "Commands": { + "description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.", + "type": "object", + "properties": { + "allow": { + "description": "Allowed command.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "deny": { + "description": "Denied command, which takes priority.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "Scopes": { + "description": "An argument for fine grained behavior control of Tauri commands.\n\nIt can be of any serde serializable type and is used to allow or prevent certain actions inside a Tauri command. The configured scope is passed to the command and will be enforced by the command implementation.\n\n## Example\n\n```json { \"allow\": [{ \"path\": \"$HOME/**\" }], \"deny\": [{ \"path\": \"$HOME/secret.txt\" }] } ```", + "type": "object", + "properties": { + "allow": { + "description": "Data that defines what is allowed by the scope.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + }, + "deny": { + "description": "Data that defines what is denied by the scope. This should be prioritized by validation logic.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + } + } + }, + "Value": { + "description": "All supported ACL values.", + "anyOf": [ + { + "description": "Represents a null JSON value.", + "type": "null" + }, + { + "description": "Represents a [`bool`].", + "type": "boolean" + }, + { + "description": "Represents a valid ACL [`Number`].", + "allOf": [ + { + "$ref": "#/definitions/Number" + } + ] + }, + { + "description": "Represents a [`String`].", + "type": "string" + }, + { + "description": "Represents a list of other [`Value`]s.", + "type": "array", + "items": { + "$ref": "#/definitions/Value" + } + }, + { + "description": "Represents a map of [`String`] keys to [`Value`]s.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/Value" + } + } + ] + }, + "Number": { + "description": "A valid ACL number.", + "anyOf": [ + { + "description": "Represents an [`i64`].", + "type": "integer", + "format": "int64" + }, + { + "description": "Represents a [`f64`].", + "type": "number", + "format": "double" + } + ] + }, + "Target": { + "description": "Platform target.", + "oneOf": [ + { + "description": "MacOS.", + "type": "string", + "enum": [ + "macOS" + ] + }, + { + "description": "Windows.", + "type": "string", + "enum": [ + "windows" + ] + }, + { + "description": "Linux.", + "type": "string", + "enum": [ + "linux" + ] + }, + { + "description": "Android.", + "type": "string", + "enum": [ + "android" + ] + }, + { + "description": "iOS.", + "type": "string", + "enum": [ + "iOS" + ] + } + ] + }, + "PermissionKind": { + "type": "string", + "oneOf": [ + { + "description": "Enables the create_client command without any pre-configured scope.", + "type": "string", + "const": "allow-create-client", + "markdownDescription": "Enables the create_client command without any pre-configured scope." + }, + { + "description": "Denies the create_client command without any pre-configured scope.", + "type": "string", + "const": "deny-create-client", + "markdownDescription": "Denies the create_client command without any pre-configured scope." + }, + { + "description": "Enables the destroy command without any pre-configured scope.", + "type": "string", + "const": "allow-destroy", + "markdownDescription": "Enables the destroy command without any pre-configured scope." + }, + { + "description": "Denies the destroy command without any pre-configured scope.", + "type": "string", + "const": "deny-destroy", + "markdownDescription": "Denies the destroy command without any pre-configured scope." + }, + { + "description": "Enables the execute_procedure command without any pre-configured scope.", + "type": "string", + "const": "allow-execute-procedure", + "markdownDescription": "Enables the execute_procedure command without any pre-configured scope." + }, + { + "description": "Denies the execute_procedure command without any pre-configured scope.", + "type": "string", + "const": "deny-execute-procedure", + "markdownDescription": "Denies the execute_procedure command without any pre-configured scope." + }, + { + "description": "Enables the get_store_record command without any pre-configured scope.", + "type": "string", + "const": "allow-get-store-record", + "markdownDescription": "Enables the get_store_record command without any pre-configured scope." + }, + { + "description": "Denies the get_store_record command without any pre-configured scope.", + "type": "string", + "const": "deny-get-store-record", + "markdownDescription": "Denies the get_store_record command without any pre-configured scope." + }, + { + "description": "Enables the initialize command without any pre-configured scope.", + "type": "string", + "const": "allow-initialize", + "markdownDescription": "Enables the initialize command without any pre-configured scope." + }, + { + "description": "Denies the initialize command without any pre-configured scope.", + "type": "string", + "const": "deny-initialize", + "markdownDescription": "Denies the initialize command without any pre-configured scope." + }, + { + "description": "Enables the load_client command without any pre-configured scope.", + "type": "string", + "const": "allow-load-client", + "markdownDescription": "Enables the load_client command without any pre-configured scope." + }, + { + "description": "Denies the load_client command without any pre-configured scope.", + "type": "string", + "const": "deny-load-client", + "markdownDescription": "Denies the load_client command without any pre-configured scope." + }, + { + "description": "Enables the remove_secret command without any pre-configured scope.", + "type": "string", + "const": "allow-remove-secret", + "markdownDescription": "Enables the remove_secret command without any pre-configured scope." + }, + { + "description": "Denies the remove_secret command without any pre-configured scope.", + "type": "string", + "const": "deny-remove-secret", + "markdownDescription": "Denies the remove_secret command without any pre-configured scope." + }, + { + "description": "Enables the remove_store_record command without any pre-configured scope.", + "type": "string", + "const": "allow-remove-store-record", + "markdownDescription": "Enables the remove_store_record command without any pre-configured scope." + }, + { + "description": "Denies the remove_store_record command without any pre-configured scope.", + "type": "string", + "const": "deny-remove-store-record", + "markdownDescription": "Denies the remove_store_record command without any pre-configured scope." + }, + { + "description": "Enables the save command without any pre-configured scope.", + "type": "string", + "const": "allow-save", + "markdownDescription": "Enables the save command without any pre-configured scope." + }, + { + "description": "Denies the save command without any pre-configured scope.", + "type": "string", + "const": "deny-save", + "markdownDescription": "Denies the save command without any pre-configured scope." + }, + { + "description": "Enables the save_secret command without any pre-configured scope.", + "type": "string", + "const": "allow-save-secret", + "markdownDescription": "Enables the save_secret command without any pre-configured scope." + }, + { + "description": "Denies the save_secret command without any pre-configured scope.", + "type": "string", + "const": "deny-save-secret", + "markdownDescription": "Denies the save_secret command without any pre-configured scope." + }, + { + "description": "Enables the save_store_record command without any pre-configured scope.", + "type": "string", + "const": "allow-save-store-record", + "markdownDescription": "Enables the save_store_record command without any pre-configured scope." + }, + { + "description": "Denies the save_store_record command without any pre-configured scope.", + "type": "string", + "const": "deny-save-store-record", + "markdownDescription": "Denies the save_store_record command without any pre-configured scope." + }, + { + "description": "This permission set configures what kind of\noperations are available from the stronghold plugin.\n\n#### Granted Permissions\n\nAll non-destructive operations are enabled by default.\n\n\n#### This default permission set includes:\n\n- `allow-create-client`\n- `allow-get-store-record`\n- `allow-initialize`\n- `allow-execute-procedure`\n- `allow-load-client`\n- `allow-save-secret`\n- `allow-save-store-record`\n- `allow-save`", + "type": "string", + "const": "default", + "markdownDescription": "This permission set configures what kind of\noperations are available from the stronghold plugin.\n\n#### Granted Permissions\n\nAll non-destructive operations are enabled by default.\n\n\n#### This default permission set includes:\n\n- `allow-create-client`\n- `allow-get-store-record`\n- `allow-initialize`\n- `allow-execute-procedure`\n- `allow-load-client`\n- `allow-save-secret`\n- `allow-save-store-record`\n- `allow-save`" + } + ] + } + } +} \ No newline at end of file diff --git a/plugins/stronghold/rollup.config.js b/plugins/stronghold/rollup.config.js new file mode 100644 index 00000000..1f349ec8 --- /dev/null +++ b/plugins/stronghold/rollup.config.js @@ -0,0 +1,7 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import { createConfig } from '../../shared/rollup.config.js' + +export default createConfig() diff --git a/plugins/stronghold/rollup.config.mjs b/plugins/stronghold/rollup.config.mjs deleted file mode 100644 index 99a3dd31..00000000 --- a/plugins/stronghold/rollup.config.mjs +++ /dev/null @@ -1,11 +0,0 @@ -import { readFileSync } from "fs"; - -import { createConfig } from "../../shared/rollup.config.mjs"; - -export default createConfig({ - input: "guest-js/index.ts", - pkg: JSON.parse( - readFileSync(new URL("./package.json", import.meta.url), "utf8"), - ), - external: [/^@tauri-apps\/api/], -}); diff --git a/plugins/stronghold/src/api-iife.js b/plugins/stronghold/src/api-iife.js deleted file mode 100644 index 8fba22ec..00000000 --- a/plugins/stronghold/src/api-iife.js +++ /dev/null @@ -1 +0,0 @@ -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__})} diff --git a/plugins/stronghold/src/kdf.rs b/plugins/stronghold/src/kdf.rs new file mode 100644 index 00000000..94e7b677 --- /dev/null +++ b/plugins/stronghold/src/kdf.rs @@ -0,0 +1,39 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use rand_chacha::ChaCha20Rng; +use rand_core::{RngCore, SeedableRng}; +use std::path::Path; + +/// NOTE: Hash supplied to Stronghold must be 32bits long. +/// This is a current limitation of Stronghold. +const HASH_LENGTH: usize = 32; + +pub struct KeyDerivation {} + +impl KeyDerivation { + /// Will create a key from [`password`] and a generated salt. + /// Salt will be generated to file [`salt_path`] or taken from it + /// if file already exists + pub fn argon2(password: &str, salt_path: &Path) -> Vec { + let mut salt = [0u8; HASH_LENGTH]; + create_or_get_salt(&mut salt, salt_path); + + argon2::hash_raw(password.as_bytes(), &salt, &Default::default()) + .expect("Failed to generate hash for password") + } +} + +fn create_or_get_salt(salt: &mut [u8], salt_path: &Path) { + if salt_path.is_file() { + // Get existing salt + let tmp = std::fs::read(salt_path).unwrap(); + salt.clone_from_slice(&tmp); + } else { + // Generate new salt + let mut gen = ChaCha20Rng::from_entropy(); + gen.fill_bytes(salt); + std::fs::write(salt_path, salt).expect("Failed to write salt for Stronghold") + } +} diff --git a/plugins/stronghold/src/lib.rs b/plugins/stronghold/src/lib.rs index 96489c84..23acc3a2 100644 --- a/plugins/stronghold/src/lib.rs +++ b/plugins/stronghold/src/lib.rs @@ -2,8 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -//! [![](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/stronghold/banner.png)](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/stronghold) -//! //! Store secrets and keys using the [IOTA Stronghold](https://github.com/iotaledger/stronghold.rs) encrypted database and secure runtime. #![doc( @@ -19,9 +17,10 @@ use std::{ time::Duration, }; +use crypto::keys::bip39; use iota_stronghold::{ procedures::{ - BIP39Generate, BIP39Recover, Chain, Ed25519Sign, KeyType as StrongholdKeyType, + BIP39Generate, BIP39Recover, Curve, Ed25519Sign, KeyType as StrongholdKeyType, MnemonicLanguage, PublicKey, Slip10Derive, Slip10DeriveInput, Slip10Generate, StrongholdProcedure, }, @@ -33,7 +32,10 @@ use tauri::{ plugin::{Builder as PluginBuilder, TauriPlugin}, Manager, Runtime, State, }; -use zeroize::Zeroize; +use zeroize::{Zeroize, Zeroizing}; + +#[cfg(feature = "kdf")] +pub mod kdf; pub mod stronghold; @@ -123,7 +125,7 @@ impl<'de> Deserialize<'de> for KeyType { { struct KeyTypeVisitor; - impl<'de> Visitor<'de> for KeyTypeVisitor { + impl Visitor<'_> for KeyTypeVisitor { type Value = KeyType; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { @@ -196,7 +198,8 @@ impl From for StrongholdProcedure { input, output, } => StrongholdProcedure::Slip10Derive(Slip10Derive { - chain: Chain::from_u32_hardened(chain), + curve: Curve::Ed25519, + chain, input: input.into(), output: output.into(), }), @@ -205,13 +208,13 @@ impl From for StrongholdProcedure { passphrase, output, } => StrongholdProcedure::BIP39Recover(BIP39Recover { - mnemonic, - passphrase, + mnemonic: bip39::Mnemonic::from(mnemonic), + passphrase: bip39::Passphrase::from(passphrase.unwrap_or_default()), output: output.into(), }), ProcedureDto::BIP39Generate { passphrase, output } => { StrongholdProcedure::BIP39Generate(BIP39Generate { - passphrase, + passphrase: bip39::Passphrase::from(passphrase.unwrap_or_default()), output: output.into(), language: MnemonicLanguage::English, }) @@ -348,7 +351,10 @@ async fn save_secret( let client = get_client(collection, snapshot_path, client)?; client .vault(&vault) - .write_secret(Location::generic(vault, record_path), secret) + .write_secret( + Location::generic(vault, record_path), + Zeroizing::new(secret), + ) .map_err(Into::into) } @@ -407,27 +413,71 @@ fn get_client( } } +enum PasswordHashFunctionKind { + #[cfg(feature = "kdf")] + Argon2(PathBuf), + Custom(Box), +} + pub struct Builder { - password_hash_function: Box, + password_hash_function: PasswordHashFunctionKind, } impl Builder { pub fn new Vec + Send + Sync + 'static>(password_hash_function: F) -> Self { Self { - password_hash_function: Box::new(password_hash_function), + password_hash_function: PasswordHashFunctionKind::Custom(Box::new( + password_hash_function, + )), + } + } + + /// Initializes [`Self`] with argon2 as password hash function. + /// + /// # Examples + /// + /// ```rust + /// use tauri::Manager; + /// tauri::Builder::default() + /// .setup(|app| { + /// let salt_path = app + /// .path() + /// .app_local_data_dir() + /// .expect("could not resolve app local data path") + /// .join("salt.txt"); + /// app.handle().plugin(tauri_plugin_stronghold::Builder::with_argon2(&salt_path).build())?; + /// Ok(()) + /// }); + /// ``` + #[cfg(feature = "kdf")] + pub fn with_argon2(salt_path: &std::path::Path) -> Self { + Self { + password_hash_function: PasswordHashFunctionKind::Argon2(salt_path.to_owned()), } } pub fn build(self) -> TauriPlugin { let password_hash_function = self.password_hash_function; - PluginBuilder::new("stronghold") - .js_init_script(include_str!("api-iife.js").to_string()) - .setup(move |app, _api| { - app.manage(StrongholdCollection::default()); - app.manage(PasswordHashFunction(password_hash_function)); - Ok(()) - }) + let plugin_builder = PluginBuilder::new("stronghold").setup(move |app, _api| { + app.manage(StrongholdCollection::default()); + app.manage(PasswordHashFunction(match password_hash_function { + #[cfg(feature = "kdf")] + PasswordHashFunctionKind::Argon2(path) => { + Box::new(move |p| kdf::KeyDerivation::argon2(p, &path)) + } + PasswordHashFunctionKind::Custom(f) => f, + })); + Ok(()) + }); + + Builder::invoke_stronghold_handlers_and_build(plugin_builder) + } + + fn invoke_stronghold_handlers_and_build( + builder: PluginBuilder, + ) -> TauriPlugin { + builder .invoke_handler(tauri::generate_handler![ initialize, destroy, diff --git a/plugins/stronghold/src/stronghold.rs b/plugins/stronghold/src/stronghold.rs index 7da521bd..a5cadc26 100644 --- a/plugins/stronghold/src/stronghold.rs +++ b/plugins/stronghold/src/stronghold.rs @@ -6,6 +6,7 @@ use std::{convert::TryFrom, ops::Deref, path::Path}; use iota_stronghold::{KeyProvider, SnapshotPath}; use serde::{Serialize, Serializer}; +use zeroize::Zeroizing; pub type Result = std::result::Result; @@ -40,7 +41,7 @@ impl Stronghold { pub fn new>(path: P, password: Vec) -> Result { let path = SnapshotPath::from_path(path); let stronghold = iota_stronghold::Stronghold::default(); - let keyprovider = KeyProvider::try_from(password)?; + let keyprovider = KeyProvider::try_from(Zeroizing::new(password))?; if path.exists() { stronghold.load_snapshot(&keyprovider, &path)?; } diff --git a/plugins/updater/CHANGELOG.md b/plugins/updater/CHANGELOG.md index b427e7bb..ccf98564 100644 --- a/plugins/updater/CHANGELOG.md +++ b/plugins/updater/CHANGELOG.md @@ -1,5 +1,175 @@ # Changelog +## \[2.7.1] + +- [`c5b0f51c`](https://github.com/tauri-apps/plugins-workspace/commit/c5b0f51cfd911cca9317b59efc718b570980129b) ([#2621](https://github.com/tauri-apps/plugins-workspace/pull/2621) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Fix `check` and `download` overrides the `accept` header + +## \[2.7.0] + +### bug + +- [`2d731f80`](https://github.com/tauri-apps/plugins-workspace/commit/2d731f80224f74faf1b7170b25e04f5da1da49c8) ([#2573](https://github.com/tauri-apps/plugins-workspace/pull/2573)) Fix JS API `Update.date` not formatted to RFC 3339 +- [`0bc5d588`](https://github.com/tauri-apps/plugins-workspace/commit/0bc5d5887420ba1eb718254490b7995c771c0447) ([#2572](https://github.com/tauri-apps/plugins-workspace/pull/2572)) Fix `timeout` passed to `check` gets re-used by `download` and `downloadAndinstall` + +## \[2.6.1] + +- [`12c4537b`](https://github.com/tauri-apps/plugins-workspace/commit/12c4537b8e4fed29b415ff817434b664c0596dac) ([#2541](https://github.com/tauri-apps/plugins-workspace/pull/2541) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Add support to the `riscv64` architecture. + +## \[2.6.0] + +- [`faefcc9f`](https://github.com/tauri-apps/plugins-workspace/commit/faefcc9fd8c61f709d491649e255a7fcac82c09a) ([#2430](https://github.com/tauri-apps/plugins-workspace/pull/2430) by [@goenning](https://github.com/tauri-apps/plugins-workspace/../../goenning)) Add `UpdaterBuilder::configure_client` method on Rust side, to configure the `reqwest` client used to check and download the update. +- [`ac60d589`](https://github.com/tauri-apps/plugins-workspace/commit/ac60d589eca2bbc4aed040feb18da148e66ec171) ([#2513](https://github.com/tauri-apps/plugins-workspace/pull/2513) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Enhance error logging. + +## \[2.5.1] + +- [`6f881293`](https://github.com/tauri-apps/plugins-workspace/commit/6f881293fcd67838f6f3f8063f536292431dd1f7) ([#2439](https://github.com/tauri-apps/plugins-workspace/pull/2439) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Fixed an issue that caused the plugin to emit a `ReleaseNotFound` error instead of a `Reqwest` error when the http request in `check()` failed. + +## \[2.5.0] + +- [`5369898d`](https://github.com/tauri-apps/plugins-workspace/commit/5369898db7a6098e3e2f43436100ea556d405628) ([#2067](https://github.com/tauri-apps/plugins-workspace/pull/2067) by [@jLynx](https://github.com/tauri-apps/plugins-workspace/../../jLynx)) Fix update installation on macOS when using an user without admin privileges. +- [`5369898d`](https://github.com/tauri-apps/plugins-workspace/commit/5369898db7a6098e3e2f43436100ea556d405628) ([#2067](https://github.com/tauri-apps/plugins-workspace/pull/2067) by [@jLynx](https://github.com/tauri-apps/plugins-workspace/../../jLynx)) Remove the `UpdaterBuilder::new` function, use `UpdaterExt::updater_builder` instead. + +## \[2.4.0] + +- [`0afc9b6b`](https://github.com/tauri-apps/plugins-workspace/commit/0afc9b6be07bee1077f05a86285d977e57810ed9) ([#2325](https://github.com/tauri-apps/plugins-workspace/pull/2325) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) The `Update` struct/object will now contain a `raw_json`/`rawJson` property to be able to read parts of server's json response that are not handled by the plugin. + +## \[2.3.1] + +- [`57efb47c`](https://github.com/tauri-apps/plugins-workspace/commit/57efb47c116f880477f72f02a8e4239e88007d44) ([#2235](https://github.com/tauri-apps/plugins-workspace/pull/2235) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Add `Builder::header` and `Builder::headers` method to configure default headers for updater. + +## \[2.3.0] + +- [`829b6326`](https://github.com/tauri-apps/plugins-workspace/commit/829b63265030bc9c61d1738c4eaca0ffb3178677) ([#1919](https://github.com/tauri-apps/plugins-workspace/pull/1919) by [@n1ght-hunter](https://github.com/tauri-apps/plugins-workspace/../../n1ght-hunter)) Add `tauri_plugin_updater::Builder::default_version_comparator` method to set the default version comparator for the updater. + +## \[2.2.0] + +- [`3a79266b`](https://github.com/tauri-apps/plugins-workspace/commit/3a79266b8cf96a55b1ae6339d725567d45a44b1d) ([#2173](https://github.com/tauri-apps/plugins-workspace/pull/2173) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Bumped all plugins to `v2.2.0`. From now, the versions for the Rust and JavaScript packages of each plugin will be in sync with each other. + +## \[2.1.0] + +- [`f8f2eefe`](https://github.com/tauri-apps/plugins-workspace/commit/f8f2eefe03ab231beafbd6a88d61b53d77f0400d) ([#1991](https://github.com/tauri-apps/plugins-workspace/pull/1991) by [@jLynx](https://github.com/tauri-apps/plugins-workspace/../../jLynx)) Added support for `.deb` package updates on Linux systems. + +## \[2.0.2] + +- [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. + +## \[2.0.1] + +- [`9501cfa5`](https://github.com/tauri-apps/plugins-workspace/commit/9501cfa5f5385b2d7eb43a8378b322ee97cba06f) ([#1868](https://github.com/tauri-apps/plugins-workspace/pull/1868) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Fix configuration parser incorrectly warning about the endpoint scheme. + +## \[2.0.0] + +- [`e2c4dfb6`](https://github.com/tauri-apps/plugins-workspace/commit/e2c4dfb6af43e5dd8d9ceba232c315f5febd55c1) Update to tauri v2 stable release. + +## \[2.0.0-rc.4] + +- [`221f50f5`](https://github.com/tauri-apps/plugins-workspace/commit/221f50f53bd7a87dbd404e4cb1aaf502a5047785) ([#1816](https://github.com/tauri-apps/plugins-workspace/pull/1816) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Encode `+` when making updater requests which can be cause incorrectly interpolating the endpoint when using `{{current_version}}` in the endpoint where the current version contains a build number, for example `1.8.0+1`. +- [`04a0aea0`](https://github.com/tauri-apps/plugins-workspace/commit/04a0aea0ab9f8750200bc2fe5aff99c1c488082d) ([#1814](https://github.com/tauri-apps/plugins-workspace/pull/1814) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) **Breaking change**, Changed `UpdaterBuilder::endpoints` method to return a `Result`. +- [`04a0aea0`](https://github.com/tauri-apps/plugins-workspace/commit/04a0aea0ab9f8750200bc2fe5aff99c1c488082d) ([#1814](https://github.com/tauri-apps/plugins-workspace/pull/1814) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Add `dangerousInsecureTransportProtocol` config option to allow using insecure transport protocols, like `http` + +## \[2.0.0-rc.3] + +- [`d00519e3`](https://github.com/tauri-apps/plugins-workspace/commit/d00519e3e3a3234f9eb6c2ba82c92d4199f03e53) ([#1735](https://github.com/tauri-apps/plugins-workspace/pull/1735) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) This releases the changes from 2.0.0-rc.2 to crates.io. Please see the links below for the actual changes. + +## \[2.0.0-rc.2] + +- [`f8255e1d`](https://github.com/tauri-apps/plugins-workspace/commit/f8255e1db5df6cf562b9334fbefe5e62f4a28e0a) ([#1661](https://github.com/tauri-apps/plugins-workspace/pull/1661) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Add a second argument in `Update.download` and `Update.donloadAndInstall` JS APIs to modify headers and timeout when downloading the update. + +## \[2.0.0-rc.1] + +- [`e2e97db5`](https://github.com/tauri-apps/plugins-workspace/commit/e2e97db51983267f5be84d4f6f0278d58834d1f5) ([#1701](https://github.com/tauri-apps/plugins-workspace/pull/1701) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri 2.0.0-rc.8 + +## \[2.0.0-rc.1] + +- [`77013925`](https://github.com/tauri-apps/plugins-workspace/commit/7701392500f375340045880fce5fb8f867bfe670) ([#1636](https://github.com/tauri-apps/plugins-workspace/pull/1636) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Fixes the updater not preserving AppImage file permissions. +- [`5d170a54`](https://github.com/tauri-apps/plugins-workspace/commit/5d170a5444982dcc14135f6f1fc3e5da359f0eb0) ([#1671](https://github.com/tauri-apps/plugins-workspace/pull/1671) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri 2.0.0-rc.3. + +## \[2.0.0-rc.0] + +- [`9887d1`](https://github.com/tauri-apps/plugins-workspace/commit/9887d14bd0e971c4c0f5c1188fc4005d3fc2e29e) Update to tauri RC. + +## \[2.0.0-beta.8] + +- [`99d6ac0f`](https://github.com/tauri-apps/plugins-workspace/commit/99d6ac0f9506a6a4a1aa59c728157190a7441af6) ([#1606](https://github.com/tauri-apps/plugins-workspace/pull/1606) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) The JS packages now specify the *minimum* `@tauri-apps/api` version instead of a single exact version. +- [`6de87966`](https://github.com/tauri-apps/plugins-workspace/commit/6de87966ecc00ad9d91c25be452f1f46bd2b7e1f) ([#1597](https://github.com/tauri-apps/plugins-workspace/pull/1597) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Update to tauri beta.25. + +## \[2.0.0-beta.11] + +- [`f83b9e98`](https://github.com/tauri-apps/plugins-workspace/commit/f83b9e9813843df19b03b6af1018d848111b2a62) ([#1544](https://github.com/tauri-apps/plugins-workspace/pull/1544) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) On Windows, use a named tempfile with `--installer.exe` (or `.msi`) for v2 updater + + **Breaking Change**: `UpdaterBuilder::new` now takes one more argument `app_name: String` + +## \[2.0.0-beta.7] + +- [`22a17980`](https://github.com/tauri-apps/plugins-workspace/commit/22a17980ff4f6f8c40adb1b8f4ffc6dae2fe7e30) ([#1537](https://github.com/tauri-apps/plugins-workspace/pull/1537) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri beta.24. + +## \[2.0.0-beta.6] + +- [`76daee7a`](https://github.com/tauri-apps/plugins-workspace/commit/76daee7aafece34de3092c86e531cf9eb1138989) ([#1512](https://github.com/tauri-apps/plugins-workspace/pull/1512) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Update to tauri beta.23. + +## \[2.0.0-beta.8] + +- [`bf29a72b`](https://github.com/tauri-apps/plugins-workspace/commit/bf29a72baaff15214a21989df23081eee84e3b8b) ([#1454](https://github.com/tauri-apps/plugins-workspace/pull/1454) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Fix regression in updater plugin failing to update using `.msi` installer. + +## \[2.0.0-beta.5] + +- [`9013854f`](https://github.com/tauri-apps/plugins-workspace/commit/9013854f42a49a230b9dbb9d02774765528a923f)([#1382](https://github.com/tauri-apps/plugins-workspace/pull/1382)) Update to tauri beta.22. + +## \[2.0.0-beta.4] + +- [`430bd6f4`](https://github.com/tauri-apps/plugins-workspace/commit/430bd6f4f379bee5d232ae6b098ae131db7f178a)([#1363](https://github.com/tauri-apps/plugins-workspace/pull/1363)) Update to tauri beta.20. +- [`43224c5d`](https://github.com/tauri-apps/plugins-workspace/commit/43224c5d5cfe2dd676e79ebafe424027c62c51c3)([#1330](https://github.com/tauri-apps/plugins-workspace/pull/1330)) Add `Update.download` and `Update.install` functions to the JavaScript API + +## \[2.0.0-beta.3] + +- [`bd1ed590`](https://github.com/tauri-apps/plugins-workspace/commit/bd1ed5903ffcce5500310dac1e59e8c67674ef1e)([#1237](https://github.com/tauri-apps/plugins-workspace/pull/1237)) Update to tauri beta.17. + +## \[2.0.0-beta.4] + +- [`293f363`](https://github.com/tauri-apps/plugins-workspace/commit/293f363c0dccc43e8403729fdc8cc2b4311c2d5b)([#1175](https://github.com/tauri-apps/plugins-workspace/pull/1175)) Add a `on_before_exit` hook for cleanup before spawning the updater on Windows, defaults to `app.cleanup_before_exit` when used through `UpdaterExt` +- [`293f363`](https://github.com/tauri-apps/plugins-workspace/commit/293f363c0dccc43e8403729fdc8cc2b4311c2d5b)([#1175](https://github.com/tauri-apps/plugins-workspace/pull/1175)) **Breaking change:** The `rustls-tls` feature flag is now enabled by default. +- [`e3d41f4`](https://github.com/tauri-apps/plugins-workspace/commit/e3d41f4011bd3ea3ce281bb38bbe31d3709f8e0f)([#1191](https://github.com/tauri-apps/plugins-workspace/pull/1191)) Internally use the webview scoped resources table instead of the app one, so other webviews can't access other webviews resources. +- [`7e2fcc5`](https://github.com/tauri-apps/plugins-workspace/commit/7e2fcc5e74df7c3c718e40f75bfb0eafc7d69d8d)([#1146](https://github.com/tauri-apps/plugins-workspace/pull/1146)) Update dependencies to align with tauri 2.0.0-beta.14. +- [`e3d41f4`](https://github.com/tauri-apps/plugins-workspace/commit/e3d41f4011bd3ea3ce281bb38bbe31d3709f8e0f)([#1191](https://github.com/tauri-apps/plugins-workspace/pull/1191)) Update for tauri 2.0.0-beta.15. + +## \[2.0.0-beta.3] + +- [`4e37316`](https://github.com/tauri-apps/plugins-workspace/commit/4e37316af0d6532bf9a9bd0e712b5b14b0598285)([#1051](https://github.com/tauri-apps/plugins-workspace/pull/1051)) Fix deserialization of `windows > installerArgs` config field. +- [`4e37316`](https://github.com/tauri-apps/plugins-workspace/commit/4e37316af0d6532bf9a9bd0e712b5b14b0598285)([#1051](https://github.com/tauri-apps/plugins-workspace/pull/1051)) On Windows, fallback to `passive` install mode when not defined in config. +- [`a3b5396`](https://github.com/tauri-apps/plugins-workspace/commit/a3b5396113ca93912274f6890d9ef5b1a409587a)([#1054](https://github.com/tauri-apps/plugins-workspace/pull/1054)) Fix Windows powershell window flashing on update +- [`a04ea2f`](https://github.com/tauri-apps/plugins-workspace/commit/a04ea2f38294d5a3987578283badc8eec87a7752)([#1071](https://github.com/tauri-apps/plugins-workspace/pull/1071)) The global API script is now only added to the binary when the `withGlobalTauri` config is true. + +## \[2.0.0-beta.2] + +- [`99bea25`](https://github.com/tauri-apps/plugins-workspace/commit/99bea2559c2c0648c2519c50a18cd124dacef57b)([#1005](https://github.com/tauri-apps/plugins-workspace/pull/1005)) Update to tauri beta.8. + +## \[2.0.0-beta.1] + +- [`569defb`](https://github.com/tauri-apps/plugins-workspace/commit/569defbe9492e38938554bb7bdc1be9151456d21) Update to tauri beta.4. + +## \[2.0.0-beta.0] + +- [`d198c01`](https://github.com/tauri-apps/plugins-workspace/commit/d198c014863ee260cb0de88a14b7fc4356ef7474)([#862](https://github.com/tauri-apps/plugins-workspace/pull/862)) Update to tauri beta. +- [`0879a87`](https://github.com/tauri-apps/plugins-workspace/commit/0879a87a7ecc83c9e886e6f1412fe253082b8d34)([#899](https://github.com/tauri-apps/plugins-workspace/pull/899)) Fix `Started` event not emitted to JS when downloading update. +- [`8505a75`](https://github.com/tauri-apps/plugins-workspace/commit/8505a756b569d88757ec58e452bfe4814d8107bf)([#907](https://github.com/tauri-apps/plugins-workspace/pull/907)) Add support for specifying proxy to use for checking and downloading updates. + +## \[2.0.0-alpha.5] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.13. +- [`e5f979f`](https://github.com/tauri-apps/plugins-workspace/commit/e5f979f91abbb1775fa048af3219b30ff30ed691)([#818](https://github.com/tauri-apps/plugins-workspace/pull/818)) Fix NSIS updater failing to launch when using `basicUi` mode. + +## \[2.0.0-alpha.4] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.12. + +## \[2.0.0-alpha.3] + +- [`e438e0a`](https://github.com/tauri-apps/plugins-workspace/commit/e438e0a62d4b430a5159f05f13ecd397dd891a0d)([#676](https://github.com/tauri-apps/plugins-workspace/pull/676)) Update to @tauri-apps/api v2.0.0-alpha.11. + +## \[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.9. + ## \[2.0.0-alpha.2] - [`4e2cef9`](https://github.com/tauri-apps/plugins-workspace/commit/4e2cef9b702bbbb9cf4ee17de50791cb21f1b2a4)([#593](https://github.com/tauri-apps/plugins-workspace/pull/593)) Update to alpha.12. @@ -11,11 +181,4 @@ ## \[2.0.0-alpha.0] -- [`717ae67`](https://github.com/tauri-apps/plugins-workspace/commit/717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! - ater. -- [`1cb8311`](https://github.com/tauri-apps/plugins-workspace/commit/1cb831183c63ba5bd3f72d8a482992f6467d950d)([#405](https://github.com/tauri-apps/plugins-workspace/pull/405)) Implement passive mode on NSIS and automatically restart after NSIS update. -- [`4ab90f0`](https://github.com/tauri-apps/plugins-workspace/commit/4ab90f048eab2918344f97dc8e04413a404e392d)([#431](https://github.com/tauri-apps/plugins-workspace/pull/431)) The updater plugin is recieving a few changes to improve consistency and ergonomics of the Rust and JS APIs - -## \[2.0.0-alpha.0] - - [`717ae67`](https://github.com/tauri-apps/plugins-workspace/commit/717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! diff --git a/plugins/updater/Cargo.toml b/plugins/updater/Cargo.toml index 9764f771..a7d6f45c 100644 --- a/plugins/updater/Cargo.toml +++ b/plugins/updater/Cargo.toml @@ -1,46 +1,73 @@ [package] name = "tauri-plugin-updater" -version = "2.0.0-alpha.2" +version = "2.7.1" description = "In-app updates for Tauri applications." edition = { workspace = true } authors = { workspace = true } license = { workspace = true } rust-version = { workspace = true } +repository = { workspace = true } +links = "tauri-plugin-updater" [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] +no-default-features = true +features = ["zip"] + +[package.metadata.platforms.support] +windows = { level = "full", notes = "" } +linux = { level = "full", notes = "" } +macos = { level = "full", notes = "" } +android = { level = "none", notes = "" } +ios = { level = "none", notes = "" } + +[build-dependencies] +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] tauri = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } thiserror = { workspace = true } +log = { workspace = true } tokio = "1" -reqwest = { version = "0.11", default-features = false, features = [ "json", "stream" ] } -url = "2" -http = "0.2" -dirs-next = "2" +reqwest = { version = "0.12", default-features = false, features = [ + "json", + "stream", +] } +url = { workspace = true } +http = "1" minisign-verify = "0.2" -time = { version = "0.3", features = [ "parsing", "formatting" ] } -base64 = "0.21" -percent-encoding = "2" -semver = { version = "1", features = [ "serde" ] } +time = { version = "0.3", features = ["parsing", "formatting"] } +base64 = "0.22" +semver = { version = "1", features = ["serde"] } futures-util = "0.3" tempfile = "3" -zip = "0.6" -tar = "0.4" +infer = "0.19" +percent-encoding = "2.3" [target."cfg(target_os = \"windows\")".dependencies] -zip = { version = "0.6", default-features = false } +zip = { version = "4", default-features = false, optional = true } +windows-sys = { version = "0.59.0", features = [ + "Win32_Foundation", + "Win32_UI_WindowsAndMessaging", + "Win32_UI_Shell", +] } -[target."cfg(target_os = \"macos\")".dependencies] -flate2 = "1.0.27" +[target."cfg(target_os = \"linux\")".dependencies] +dirs = "6" +tar = { version = "0.4", optional = true } +flate2 = { version = "1", optional = true } - -[dev-dependencies] -mockito = "0.31" +[target."cfg(target_os = \"macos\")".dependencies] +tar = "0.4" +flate2 = "1" +osakit = { version = "0.3", features = ["full"] } [features] -native-tls = [ "reqwest/native-tls" ] -native-tls-vendored = [ "reqwest/native-tls-vendored" ] -rustls-tls = [ "reqwest/rustls-tls" ] +default = ["rustls-tls", "zip"] +zip = ["dep:zip", "dep:tar", "dep:flate2"] +native-tls = ["reqwest/native-tls"] +native-tls-vendored = ["reqwest/native-tls-vendored"] +rustls-tls = ["reqwest/rustls-tls"] diff --git a/plugins/updater/README.md b/plugins/updater/README.md index b956322e..79fea467 100644 --- a/plugins/updater/README.md +++ b/plugins/updater/README.md @@ -2,11 +2,17 @@ In-app updates for Tauri applications. -- Supported platforms: Windows, Linux and macOS. +| Platform | Supported | +| -------- | --------- | +| Linux | ✓ | +| Windows | ✓ | +| macOS | ✓ | +| Android | x | +| iOS | x | ## Install -_This plugin requires a Rust version of at least **1.70**_ +_This plugin requires a Rust version of at least **1.77.2**_ There are three general methods of installation that we can recommend. @@ -21,7 +27,7 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml # you can add the dependencies on the `[dependencies]` section if you do not target mobile [target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies] -tauri-plugin-updater = "2.0.0-alpha" +tauri-plugin-updater = "2.0.0" # alternatively with Git: tauri-plugin-updater = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -49,7 +55,7 @@ yarn add https://github.com/tauri-apps/tauri-plugin-updater#v2 First you need to register the core plugin with Tauri: -`src-tauri/src/main.rs` +`src-tauri/src/lib.rs` ```rust fn main() { @@ -67,19 +73,37 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import { check } from "@tauri-apps/plugin-updater"; -import { relaunch } from "@tauri-apps/plugin-process"; -const update = await check(); -if (update.response.available) { - await update.downloadAndInstall(); - await relaunch(); +import { check } from '@tauri-apps/plugin-updater' +import { relaunch } from '@tauri-apps/plugin-process' +const update = await check() +if (update) { + await update.downloadAndInstall() + await relaunch() } ``` +Note that for these APIs to work you have to properly configure the updater first and generate updater artifacts. Please refer to the [guide on our website](https://v2.tauri.app/plugin/updater/) for this. + ## Contributing PRs accepted. Please make sure to read the Contributing Guide before making a pull request. +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + ## License Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. diff --git a/plugins/updater/SECURITY.md b/plugins/updater/SECURITY.md new file mode 100644 index 00000000..4f09bbac --- /dev/null +++ b/plugins/updater/SECURITY.md @@ -0,0 +1,23 @@ +# Security Policy + +**Do not report security vulnerabilities through public GitHub issues.** + +**Please use the [Private Vulnerability Disclosure](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) feature of GitHub.** + +Include as much of the following information: + +- Type of issue (e.g. improper input parsing, privilege escalation, etc.) +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- The distribution affected or used to help us with reproduction of the issue +- Step-by-step instructions to reproduce the issue +- Ideally a reproduction repository +- Impact of the issue, including how an attacker might exploit the issue + +We prefer to receive reports in English. + +## Contact + +Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). + +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/updater/api-iife.js b/plugins/updater/api-iife.js new file mode 100644 index 00000000..33acd52a --- /dev/null +++ b/plugins/updater/api-iife.js @@ -0,0 +1 @@ +if("__TAURI__"in window){var __TAURI_PLUGIN_UPDATER__=function(t){"use strict";function e(t,e,s,n){if("function"==typeof e||!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?n:"a"===s?n.call(t):n?n.value:e.get(t)}function s(t,e,s,n,i){if("function"==typeof e||!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,s),s}var n,i,a,r,o;"function"==typeof SuppressedError&&SuppressedError;const d="__TAURI_TO_IPC_KEY__";class c{constructor(t){n.set(this,void 0),i.set(this,0),a.set(this,[]),r.set(this,void 0),s(this,n,t||(()=>{})),this.id=function(t,e=!1){return window.__TAURI_INTERNALS__.transformCallback(t,e)}((t=>{const o=t.index;if("end"in t)return void(o==e(this,i,"f")?this.cleanupCallback():s(this,r,o));const d=t.message;if(o==e(this,i,"f")){for(e(this,n,"f").call(this,d),s(this,i,e(this,i,"f")+1);e(this,i,"f")in e(this,a,"f");){const t=e(this,a,"f")[e(this,i,"f")];e(this,n,"f").call(this,t),delete e(this,a,"f")[e(this,i,"f")],s(this,i,e(this,i,"f")+1)}e(this,i,"f")===e(this,r,"f")&&this.cleanupCallback()}else e(this,a,"f")[o]=d}))}cleanupCallback(){Reflect.deleteProperty(window,`_${this.id}`)}set onmessage(t){s(this,n,t)}get onmessage(){return e(this,n,"f")}[(n=new WeakMap,i=new WeakMap,a=new WeakMap,r=new WeakMap,d)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[d]()}}async function l(t,e={},s){return window.__TAURI_INTERNALS__.invoke(t,e,s)}class h{get rid(){return e(this,o,"f")}constructor(t){o.set(this,void 0),s(this,o,t)}async close(){return l("plugin:resources|close",{rid:this.rid})}}o=new WeakMap;class u extends h{constructor(t){super(t.rid),this.available=!0,this.currentVersion=t.currentVersion,this.version=t.version,this.date=t.date,this.body=t.body,this.rawJson=t.rawJson}async download(t,e){w(e);const s=new c;t&&(s.onmessage=t);const n=await l("plugin:updater|download",{onEvent:s,rid:this.rid,...e});this.downloadedBytes=new h(n)}async install(){if(!this.downloadedBytes)throw new Error("Update.install called before Update.download");await l("plugin:updater|install",{updateRid:this.rid,bytesRid:this.downloadedBytes.rid}),this.downloadedBytes=void 0}async downloadAndInstall(t,e){w(e);const s=new c;t&&(s.onmessage=t),await l("plugin:updater|download_and_install",{onEvent:s,rid:this.rid,...e})}async close(){await(this.downloadedBytes?.close()),await super.close()}}function w(t){t?.headers&&(t.headers=Array.from(new Headers(t.headers).entries()))}return t.Update=u,t.check=async function(t){w(t);const e=await l("plugin:updater|check",{...t});return e?new u(e):null},t}({});Object.defineProperty(window.__TAURI__,"updater",{value:__TAURI_PLUGIN_UPDATER__})} diff --git a/plugins/updater/build.rs b/plugins/updater/build.rs index 0b339c43..30f70b98 100644 --- a/plugins/updater/build.rs +++ b/plugins/updater/build.rs @@ -2,7 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT +const COMMANDS: &[&str] = &["check", "download", "install", "download_and_install"]; + fn main() { + tauri_plugin::Builder::new(COMMANDS) + .global_api_script_path("./api-iife.js") + .build(); + let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap(); let mobile = target_os == "ios" || target_os == "android"; alias("desktop", !mobile); @@ -12,6 +18,7 @@ fn main() { // creates a cfg alias if `has_feature` is true. // `alias` must be a snake case string. fn alias(alias: &str, has_feature: bool) { + println!("cargo:rustc-check-cfg=cfg({alias})"); if has_feature { println!("cargo:rustc-cfg={alias}"); } diff --git a/plugins/updater/guest-js/index.ts b/plugins/updater/guest-js/index.ts index 5e3e1e6b..b6518436 100644 --- a/plugins/updater/guest-js/index.ts +++ b/plugins/updater/guest-js/index.ts @@ -2,75 +2,154 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { invoke, Channel } from "@tauri-apps/api/primitives"; +import { invoke, Channel, Resource } from '@tauri-apps/api/core' -/** Options used to check for updates */ +/** Options used when checking for updates */ interface CheckOptions { /** * Request headers */ - headers?: HeadersInit; + headers?: HeadersInit /** - * Timeout in seconds + * Timeout in milliseconds */ - timeout?: number; + timeout?: number + /** + * A proxy url to be used when checking and downloading updates. + */ + proxy?: string /** * Target identifier for the running application. This is sent to the backend. */ - target?: string; + target?: string + /** + * Allow downgrades to previous versions by not checking if the current version is greater than the available version. + */ + allowDowngrades?: boolean +} + +/** Options used when downloading an update */ +interface DownloadOptions { + /** + * Request headers + */ + headers?: HeadersInit + /** + * Timeout in milliseconds + */ + timeout?: number } interface UpdateMetadata { - available: boolean; - currentVersion: string; - version: string; - date?: string; - body?: string; + rid: number + currentVersion: string + version: string + date?: string + body?: string + rawJson: Record } /** Updater download event */ type DownloadEvent = - | { event: "Started"; data: { contentLength?: number } } - | { event: "Progress"; data: { chunkLength: number } } - | { event: "Finished" }; + | { event: 'Started'; data: { contentLength?: number } } + | { event: 'Progress'; data: { chunkLength: number } } + | { event: 'Finished' } -class Update { - currentVersion: string; - version: string; - date?: string; - body?: string; +class Update extends Resource { + // TODO: remove this field in v3 + /** @deprecated This is always true, check if the return value is `null` instead when using {@linkcode check} */ + available: boolean + currentVersion: string + version: string + date?: string + body?: string + rawJson: Record + private downloadedBytes?: Resource constructor(metadata: UpdateMetadata) { - this.currentVersion = metadata.currentVersion; - this.version = metadata.version; - this.date = metadata.date; - this.body = metadata.body; + super(metadata.rid) + this.available = true + this.currentVersion = metadata.currentVersion + this.version = metadata.version + this.date = metadata.date + this.body = metadata.body + this.rawJson = metadata.rawJson + } + + /** Download the updater package */ + async download( + onEvent?: (progress: DownloadEvent) => void, + options?: DownloadOptions + ): Promise { + convertToRustHeaders(options) + const channel = new Channel() + if (onEvent) { + channel.onmessage = onEvent + } + const downloadedBytesRid = await invoke('plugin:updater|download', { + onEvent: channel, + rid: this.rid, + ...options + }) + this.downloadedBytes = new Resource(downloadedBytesRid) + } + + /** Install downloaded updater package */ + async install(): Promise { + if (!this.downloadedBytes) { + throw new Error('Update.install called before Update.download') + } + + await invoke('plugin:updater|install', { + updateRid: this.rid, + bytesRid: this.downloadedBytes.rid + }) + + // Don't need to call close, we did it in rust side already + this.downloadedBytes = undefined } /** Downloads the updater package and installs it */ async downloadAndInstall( onEvent?: (progress: DownloadEvent) => void, + options?: DownloadOptions ): Promise { - const channel = new Channel(); - if (onEvent != null) { - channel.onmessage = onEvent; + convertToRustHeaders(options) + const channel = new Channel() + if (onEvent) { + channel.onmessage = onEvent } - return invoke("plugin:updater|download_and_install", { + await invoke('plugin:updater|download_and_install', { onEvent: channel, - }); + rid: this.rid, + ...options + }) + } + + async close(): Promise { + await this.downloadedBytes?.close() + await super.close() } } /** Check for updates, resolves to `null` if no updates are available */ async function check(options?: CheckOptions): Promise { + convertToRustHeaders(options) + + const metadata = await invoke('plugin:updater|check', { + ...options + }) + return metadata ? new Update(metadata) : null +} + +/** + * Converts the headers in options to be an {@linkcode Array<[string, string]>} which is what the Rust side expects + */ +function convertToRustHeaders(options?: { headers?: HeadersInit }) { if (options?.headers) { - options.headers = Array.from(new Headers(options.headers).entries()); + options.headers = Array.from(new Headers(options.headers).entries()) } - - return invoke("plugin:updater|check", { ...options }).then( - (meta) => (meta.available ? new Update(meta) : null), - ); } -export type { CheckOptions, DownloadEvent }; -export { check, Update }; +export type { CheckOptions, DownloadOptions, DownloadEvent } +export { check, Update } diff --git a/plugins/updater/package.json b/plugins/updater/package.json index 58e7bbe1..08a9a5dd 100644 --- a/plugins/updater/package.json +++ b/plugins/updater/package.json @@ -1,32 +1,29 @@ { "name": "@tauri-apps/plugin-updater", - "version": "2.0.0-alpha.1", - "license": "MIT or APACHE-2.0", + "version": "2.7.1", + "license": "MIT OR Apache-2.0", "authors": [ "Tauri Programme within The Commons Conservancy" ], + "repository": "https://github.com/tauri-apps/plugins-workspace", "type": "module", - "browser": "dist-js/index.min.js", - "module": "dist-js/index.mjs", - "types": "dist-js/index.d.ts", + "types": "./dist-js/index.d.ts", + "main": "./dist-js/index.cjs", + "module": "./dist-js/index.js", "exports": { - "import": "./dist-js/index.mjs", "types": "./dist-js/index.d.ts", - "browser": "./dist-js/index.min.js" + "import": "./dist-js/index.js", + "require": "./dist-js/index.cjs" }, "scripts": { "build": "rollup -c" }, "files": [ "dist-js", - "!dist-js/**/*.map", "README.md", "LICENSE" ], - "devDependencies": { - "tslib": "^2.5.0" - }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.9" + "@tauri-apps/api": "^2.0.0" } } diff --git a/plugins/updater/permissions/autogenerated/commands/check.toml b/plugins/updater/permissions/autogenerated/commands/check.toml new file mode 100644 index 00000000..fca73ce9 --- /dev/null +++ b/plugins/updater/permissions/autogenerated/commands/check.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-check" +description = "Enables the check command without any pre-configured scope." +commands.allow = ["check"] + +[[permission]] +identifier = "deny-check" +description = "Denies the check command without any pre-configured scope." +commands.deny = ["check"] diff --git a/plugins/updater/permissions/autogenerated/commands/download.toml b/plugins/updater/permissions/autogenerated/commands/download.toml new file mode 100644 index 00000000..896b30ce --- /dev/null +++ b/plugins/updater/permissions/autogenerated/commands/download.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-download" +description = "Enables the download command without any pre-configured scope." +commands.allow = ["download"] + +[[permission]] +identifier = "deny-download" +description = "Denies the download command without any pre-configured scope." +commands.deny = ["download"] diff --git a/plugins/updater/permissions/autogenerated/commands/download_and_install.toml b/plugins/updater/permissions/autogenerated/commands/download_and_install.toml new file mode 100644 index 00000000..40858d1b --- /dev/null +++ b/plugins/updater/permissions/autogenerated/commands/download_and_install.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-download-and-install" +description = "Enables the download_and_install command without any pre-configured scope." +commands.allow = ["download_and_install"] + +[[permission]] +identifier = "deny-download-and-install" +description = "Denies the download_and_install command without any pre-configured scope." +commands.deny = ["download_and_install"] diff --git a/plugins/updater/permissions/autogenerated/commands/install.toml b/plugins/updater/permissions/autogenerated/commands/install.toml new file mode 100644 index 00000000..4c6a29d4 --- /dev/null +++ b/plugins/updater/permissions/autogenerated/commands/install.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-install" +description = "Enables the install command without any pre-configured scope." +commands.allow = ["install"] + +[[permission]] +identifier = "deny-install" +description = "Denies the install command without any pre-configured scope." +commands.deny = ["install"] diff --git a/plugins/updater/permissions/autogenerated/reference.md b/plugins/updater/permissions/autogenerated/reference.md new file mode 100644 index 00000000..74588fef --- /dev/null +++ b/plugins/updater/permissions/autogenerated/reference.md @@ -0,0 +1,132 @@ +## Default Permission + +This permission set configures which kind of +updater functions are exposed to the frontend. + +#### Granted Permissions + +The full workflow from checking for updates to installing them +is enabled. + + + +#### This default permission set includes the following: + +- `allow-check` +- `allow-download` +- `allow-install` +- `allow-download-and-install` + +## Permission Table + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IdentifierDescription
+ +`updater:allow-check` + + + +Enables the check command without any pre-configured scope. + +
+ +`updater:deny-check` + + + +Denies the check command without any pre-configured scope. + +
+ +`updater:allow-download` + + + +Enables the download command without any pre-configured scope. + +
+ +`updater:deny-download` + + + +Denies the download command without any pre-configured scope. + +
+ +`updater:allow-download-and-install` + + + +Enables the download_and_install command without any pre-configured scope. + +
+ +`updater:deny-download-and-install` + + + +Denies the download_and_install command without any pre-configured scope. + +
+ +`updater:allow-install` + + + +Enables the install command without any pre-configured scope. + +
+ +`updater:deny-install` + + + +Denies the install command without any pre-configured scope. + +
diff --git a/plugins/updater/permissions/default.toml b/plugins/updater/permissions/default.toml new file mode 100644 index 00000000..fcf08fa8 --- /dev/null +++ b/plugins/updater/permissions/default.toml @@ -0,0 +1,18 @@ +"$schema" = "schemas/schema.json" +[default] +description = """ +This permission set configures which kind of +updater functions are exposed to the frontend. + +#### Granted Permissions + +The full workflow from checking for updates to installing them +is enabled. + +""" +permissions = [ + "allow-check", + "allow-download", + "allow-install", + "allow-download-and-install", +] diff --git a/plugins/updater/permissions/schemas/schema.json b/plugins/updater/permissions/schemas/schema.json new file mode 100644 index 00000000..7f295916 --- /dev/null +++ b/plugins/updater/permissions/schemas/schema.json @@ -0,0 +1,354 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "PermissionFile", + "description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.", + "type": "object", + "properties": { + "default": { + "description": "The default permission set for the plugin", + "anyOf": [ + { + "$ref": "#/definitions/DefaultPermission" + }, + { + "type": "null" + } + ] + }, + "set": { + "description": "A list of permissions sets defined", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionSet" + } + }, + "permission": { + "description": "A list of inlined permissions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Permission" + } + } + }, + "definitions": { + "DefaultPermission": { + "description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.", + "type": "object", + "required": [ + "permissions" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "PermissionSet": { + "description": "A set of direct permissions grouped together under a new name.", + "type": "object", + "required": [ + "description", + "identifier", + "permissions" + ], + "properties": { + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does.", + "type": "string" + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionKind" + } + } + } + }, + "Permission": { + "description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.", + "type": "object", + "required": [ + "identifier" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri internal convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "commands": { + "description": "Allowed or denied commands when using this permission.", + "default": { + "allow": [], + "deny": [] + }, + "allOf": [ + { + "$ref": "#/definitions/Commands" + } + ] + }, + "scope": { + "description": "Allowed or denied scoped when using this permission.", + "allOf": [ + { + "$ref": "#/definitions/Scopes" + } + ] + }, + "platforms": { + "description": "Target platforms this permission applies. By default all platforms are affected by this permission.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Target" + } + } + } + }, + "Commands": { + "description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.", + "type": "object", + "properties": { + "allow": { + "description": "Allowed command.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "deny": { + "description": "Denied command, which takes priority.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "Scopes": { + "description": "An argument for fine grained behavior control of Tauri commands.\n\nIt can be of any serde serializable type and is used to allow or prevent certain actions inside a Tauri command. The configured scope is passed to the command and will be enforced by the command implementation.\n\n## Example\n\n```json { \"allow\": [{ \"path\": \"$HOME/**\" }], \"deny\": [{ \"path\": \"$HOME/secret.txt\" }] } ```", + "type": "object", + "properties": { + "allow": { + "description": "Data that defines what is allowed by the scope.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + }, + "deny": { + "description": "Data that defines what is denied by the scope. This should be prioritized by validation logic.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + } + } + }, + "Value": { + "description": "All supported ACL values.", + "anyOf": [ + { + "description": "Represents a null JSON value.", + "type": "null" + }, + { + "description": "Represents a [`bool`].", + "type": "boolean" + }, + { + "description": "Represents a valid ACL [`Number`].", + "allOf": [ + { + "$ref": "#/definitions/Number" + } + ] + }, + { + "description": "Represents a [`String`].", + "type": "string" + }, + { + "description": "Represents a list of other [`Value`]s.", + "type": "array", + "items": { + "$ref": "#/definitions/Value" + } + }, + { + "description": "Represents a map of [`String`] keys to [`Value`]s.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/Value" + } + } + ] + }, + "Number": { + "description": "A valid ACL number.", + "anyOf": [ + { + "description": "Represents an [`i64`].", + "type": "integer", + "format": "int64" + }, + { + "description": "Represents a [`f64`].", + "type": "number", + "format": "double" + } + ] + }, + "Target": { + "description": "Platform target.", + "oneOf": [ + { + "description": "MacOS.", + "type": "string", + "enum": [ + "macOS" + ] + }, + { + "description": "Windows.", + "type": "string", + "enum": [ + "windows" + ] + }, + { + "description": "Linux.", + "type": "string", + "enum": [ + "linux" + ] + }, + { + "description": "Android.", + "type": "string", + "enum": [ + "android" + ] + }, + { + "description": "iOS.", + "type": "string", + "enum": [ + "iOS" + ] + } + ] + }, + "PermissionKind": { + "type": "string", + "oneOf": [ + { + "description": "Enables the check command without any pre-configured scope.", + "type": "string", + "const": "allow-check", + "markdownDescription": "Enables the check command without any pre-configured scope." + }, + { + "description": "Denies the check command without any pre-configured scope.", + "type": "string", + "const": "deny-check", + "markdownDescription": "Denies the check command without any pre-configured scope." + }, + { + "description": "Enables the download command without any pre-configured scope.", + "type": "string", + "const": "allow-download", + "markdownDescription": "Enables the download command without any pre-configured scope." + }, + { + "description": "Denies the download command without any pre-configured scope.", + "type": "string", + "const": "deny-download", + "markdownDescription": "Denies the download command without any pre-configured scope." + }, + { + "description": "Enables the download_and_install command without any pre-configured scope.", + "type": "string", + "const": "allow-download-and-install", + "markdownDescription": "Enables the download_and_install command without any pre-configured scope." + }, + { + "description": "Denies the download_and_install command without any pre-configured scope.", + "type": "string", + "const": "deny-download-and-install", + "markdownDescription": "Denies the download_and_install command without any pre-configured scope." + }, + { + "description": "Enables the install command without any pre-configured scope.", + "type": "string", + "const": "allow-install", + "markdownDescription": "Enables the install command without any pre-configured scope." + }, + { + "description": "Denies the install command without any pre-configured scope.", + "type": "string", + "const": "deny-install", + "markdownDescription": "Denies the install command without any pre-configured scope." + }, + { + "description": "This permission set configures which kind of\nupdater functions are exposed to the frontend.\n\n#### Granted Permissions\n\nThe full workflow from checking for updates to installing them\nis enabled.\n\n\n#### This default permission set includes:\n\n- `allow-check`\n- `allow-download`\n- `allow-install`\n- `allow-download-and-install`", + "type": "string", + "const": "default", + "markdownDescription": "This permission set configures which kind of\nupdater functions are exposed to the frontend.\n\n#### Granted Permissions\n\nThe full workflow from checking for updates to installing them\nis enabled.\n\n\n#### This default permission set includes:\n\n- `allow-check`\n- `allow-download`\n- `allow-install`\n- `allow-download-and-install`" + } + ] + } + } +} \ No newline at end of file diff --git a/plugins/updater/rollup.config.js b/plugins/updater/rollup.config.js new file mode 100644 index 00000000..1f349ec8 --- /dev/null +++ b/plugins/updater/rollup.config.js @@ -0,0 +1,7 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import { createConfig } from '../../shared/rollup.config.js' + +export default createConfig() diff --git a/plugins/updater/rollup.config.mjs b/plugins/updater/rollup.config.mjs deleted file mode 100644 index 99a3dd31..00000000 --- a/plugins/updater/rollup.config.mjs +++ /dev/null @@ -1,11 +0,0 @@ -import { readFileSync } from "fs"; - -import { createConfig } from "../../shared/rollup.config.mjs"; - -export default createConfig({ - input: "guest-js/index.ts", - pkg: JSON.parse( - readFileSync(new URL("./package.json", import.meta.url), "utf8"), - ), - external: [/^@tauri-apps\/api/], -}); diff --git a/plugins/updater/src/api-iife.js b/plugins/updater/src/api-iife.js deleted file mode 100644 index a12f444b..00000000 --- a/plugins/updater/src/api-iife.js +++ /dev/null @@ -1 +0,0 @@ -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__})} diff --git a/plugins/updater/src/commands.rs b/plugins/updater/src/commands.rs index 4e8fcdc8..129c413c 100644 --- a/plugins/updater/src/commands.rs +++ b/plugins/updater/src/commands.rs @@ -2,17 +2,16 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use crate::{PendingUpdate, Result, UpdaterExt}; +use crate::{Result, Update, UpdaterExt}; +use http::{HeaderMap, HeaderName, HeaderValue}; use serde::Serialize; -use tauri::{ipc::Channel, AppHandle, Runtime, State}; +use tauri::{ipc::Channel, Manager, Resource, ResourceId, Runtime, Webview}; -use std::{ - sync::atomic::{AtomicBool, Ordering}, - time::Duration, -}; +use std::{str::FromStr, time::Duration}; +use url::Url; -#[derive(Debug, Serialize)] +#[derive(Debug, Clone, Serialize)] #[serde(tag = "event", content = "data")] pub enum DownloadEvent { #[serde(rename_all = "camelCase")] @@ -29,75 +28,170 @@ pub enum DownloadEvent { #[derive(Serialize, Default)] #[serde(rename_all = "camelCase")] pub(crate) struct Metadata { - available: bool, + rid: ResourceId, current_version: String, version: String, date: Option, body: Option, + raw_json: serde_json::Value, } +struct DownloadedBytes(pub Vec); +impl Resource for DownloadedBytes {} + #[tauri::command] pub(crate) async fn check( - app: AppHandle, - pending: State<'_, PendingUpdate>, + webview: Webview, headers: Option>, timeout: Option, + proxy: Option, target: Option, -) -> Result { - let mut builder = app.updater_builder(); + allow_downgrades: Option, +) -> Result> { + let mut builder = webview.updater_builder(); if let Some(headers) = headers { for (k, v) in headers { builder = builder.header(k, v)?; } } if let Some(timeout) = timeout { - builder = builder.timeout(Duration::from_secs(timeout)); + builder = builder.timeout(Duration::from_millis(timeout)); + } + if let Some(ref proxy) = proxy { + let url = Url::parse(proxy.as_str())?; + builder = builder.proxy(url); } if let Some(target) = target { builder = builder.target(target); } + if allow_downgrades.unwrap_or(false) { + builder = builder.version_comparator(|current, update| update.version != current); + } let updater = builder.build()?; let update = updater.check().await?; - let mut metadata = Metadata::default(); + if let Some(update) = update { - metadata.available = true; - metadata.current_version = update.current_version.clone(); - metadata.version = update.version.clone(); - metadata.date = update.date.map(|d| d.to_string()); - metadata.body = update.body.clone(); - pending.0.lock().await.replace(update); + let formatted_date = if let Some(date) = update.date { + let formatted_date = date + .format(&time::format_description::well_known::Rfc3339) + .map_err(|_| crate::Error::FormatDate)?; + Some(formatted_date) + } else { + None + }; + let metadata = Metadata { + current_version: update.current_version.clone(), + version: update.version.clone(), + date: formatted_date, + body: update.body.clone(), + raw_json: update.raw_json.clone(), + rid: webview.resources_table().add(update), + }; + Ok(Some(metadata)) + } else { + Ok(None) } +} + +#[tauri::command] +pub(crate) async fn download( + webview: Webview, + rid: ResourceId, + on_event: Channel, + headers: Option>, + timeout: Option, +) -> Result { + let update = webview.resources_table().get::(rid)?; + + let mut update = (*update).clone(); + + if let Some(headers) = headers { + let mut map = HeaderMap::new(); + for (k, v) in headers { + map.append(HeaderName::from_str(&k)?, HeaderValue::from_str(&v)?); + } + update.headers = map; + } + + if let Some(timeout) = timeout { + update.timeout = Some(Duration::from_millis(timeout)); + } + + let mut first_chunk = true; + let bytes = update + .download( + |chunk_length, content_length| { + if first_chunk { + first_chunk = !first_chunk; + let _ = on_event.send(DownloadEvent::Started { content_length }); + } + let _ = on_event.send(DownloadEvent::Progress { chunk_length }); + }, + || { + let _ = on_event.send(DownloadEvent::Finished); + }, + ) + .await?; - Ok(metadata) + Ok(webview.resources_table().add(DownloadedBytes(bytes))) +} + +#[tauri::command] +pub(crate) async fn install( + webview: Webview, + update_rid: ResourceId, + bytes_rid: ResourceId, +) -> Result<()> { + let update = webview.resources_table().get::(update_rid)?; + let bytes = webview + .resources_table() + .get::(bytes_rid)?; + update.install(&bytes.0)?; + let _ = webview.resources_table().close(bytes_rid); + Ok(()) } #[tauri::command] pub(crate) async fn download_and_install( - _app: AppHandle, - pending: State<'_, PendingUpdate>, - on_event: Channel, + webview: Webview, + rid: ResourceId, + on_event: Channel, + headers: Option>, + timeout: Option, ) -> Result<()> { - if let Some(pending) = &*pending.0.lock().await { - let first_chunk = AtomicBool::new(false); - let on_event_c = on_event.clone(); - pending - .download_and_install( - move |chunk_length, content_length| { - if first_chunk.swap(false, Ordering::Acquire) { - on_event - .send(DownloadEvent::Started { content_length }) - .unwrap(); - } - on_event - .send(DownloadEvent::Progress { chunk_length }) - .unwrap(); - }, - move || { - on_event_c.send(&DownloadEvent::Finished).unwrap(); - }, - ) - .await?; + let update = webview.resources_table().get::(rid)?; + + let mut update = (*update).clone(); + + if let Some(headers) = headers { + let mut map = HeaderMap::new(); + for (k, v) in headers { + map.append(HeaderName::from_str(&k)?, HeaderValue::from_str(&v)?); + } + update.headers = map; } + + if let Some(timeout) = timeout { + update.timeout = Some(Duration::from_millis(timeout)); + } + + let mut first_chunk = true; + + update + .download_and_install( + |chunk_length, content_length| { + if first_chunk { + first_chunk = !first_chunk; + let _ = on_event.send(DownloadEvent::Started { content_length }); + } + let _ = on_event.send(DownloadEvent::Progress { chunk_length }); + }, + || { + let _ = on_event.send(DownloadEvent::Finished); + }, + ) + .await?; + Ok(()) } diff --git a/plugins/updater/src/config.rs b/plugins/updater/src/config.rs index 4fa85183..6b16bc01 100644 --- a/plugins/updater/src/config.rs +++ b/plugins/updater/src/config.rs @@ -2,45 +2,157 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT +use std::{ffi::OsString, fmt::Display}; + use serde::{Deserialize, Deserializer}; use url::Url; -/// Updater configuration. -#[derive(Debug, Clone, Deserialize, Default)] -pub struct Config { - #[serde(default)] - pub endpoints: Vec, - /// Additional arguments given to the NSIS or WiX installer. - #[serde(default, alias = "installer-args")] - pub installer_args: Vec, +/// Install modes for the Windows update. +#[derive(Debug, PartialEq, Eq, Clone, Deserialize)] +#[serde(rename_all = "camelCase")] +pub enum WindowsUpdateInstallMode { + /// Specifies there's a basic UI during the installation process, including a final dialog box at the end. + BasicUi, + /// The quiet mode means there's no user interaction required. + /// Requires admin privileges if the installer does. + Quiet, + /// Specifies unattended mode, which means the installation only shows a progress bar. + Passive, } -/// A URL to an updater server. -/// -/// The URL must use the `https` scheme on production. -#[derive(Debug, PartialEq, Eq, Clone)] -pub struct UpdaterEndpoint(pub Url); +impl WindowsUpdateInstallMode { + /// Returns the associated `msiexec.exe` arguments. + pub fn msiexec_args(&self) -> &'static [&'static str] { + match self { + Self::BasicUi => &["/qb+"], + Self::Quiet => &["/quiet"], + Self::Passive => &["/passive"], + } + } -impl std::fmt::Display for UpdaterEndpoint { + /// Returns the associated nsis arguments. + pub fn nsis_args(&self) -> &'static [&'static str] { + // `/P`: Passive + // `/S`: Silent + // `/R`: Restart + match self { + Self::Passive => &["/P", "/R"], + Self::Quiet => &["/S", "/R"], + _ => &[], + } + } +} + +impl Display for WindowsUpdateInstallMode { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", self.0) + write!( + f, + "{}", + match self { + Self::BasicUi => "basicUi", + Self::Quiet => "quiet", + Self::Passive => "passive", + } + ) + } +} + +impl Default for WindowsUpdateInstallMode { + fn default() -> Self { + Self::Passive } } -impl<'de> Deserialize<'de> for UpdaterEndpoint { +#[derive(Debug, Clone, Deserialize, Default)] +#[serde(rename_all = "camelCase")] +pub struct WindowsConfig { + /// Additional arguments given to the NSIS or WiX installer. + #[serde( + default, + alias = "installer-args", + deserialize_with = "deserialize_os_string" + )] + pub installer_args: Vec, + /// Updating mode, defaults to `passive` mode. + /// + /// See [`WindowsUpdateInstallMode`] for more info. + #[serde(default, alias = "install-mode")] + pub install_mode: WindowsUpdateInstallMode, +} + +fn deserialize_os_string<'de, D>(deserializer: D) -> Result, D::Error> +where + D: Deserializer<'de>, +{ + Ok(Vec::::deserialize(deserializer)? + .into_iter() + .map(OsString::from) + .collect::>()) +} + +/// Updater configuration. +#[derive(Debug, Clone, Default)] +pub struct Config { + /// Dangerously allow using insecure transport protocols for update endpoints. + pub dangerous_insecure_transport_protocol: bool, + /// Updater endpoints. + pub endpoints: Vec, + /// Signature public key. + pub pubkey: String, + /// The Windows configuration for the updater. + pub windows: Option, +} + +impl<'de> Deserialize<'de> for Config { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, { - let url = Url::deserialize(deserializer)?; - #[cfg(all(not(debug_assertions), not(feature = "schema")))] - { + #[derive(Deserialize)] + #[serde(rename_all = "camelCase")] + pub struct Config { + #[serde(default, alias = "dangerous-insecure-transport-protocol")] + pub dangerous_insecure_transport_protocol: bool, + #[serde(default)] + pub endpoints: Vec, + pub pubkey: String, + pub windows: Option, + } + + let config = Config::deserialize(deserializer)?; + + validate_endpoints( + &config.endpoints, + config.dangerous_insecure_transport_protocol, + ) + .map_err(serde::de::Error::custom)?; + + Ok(Self { + dangerous_insecure_transport_protocol: config.dangerous_insecure_transport_protocol, + endpoints: config.endpoints, + pubkey: config.pubkey, + windows: config.windows, + }) + } +} + +pub(crate) fn validate_endpoints( + endpoints: &[Url], + dangerous_insecure_transport_protocol: bool, +) -> crate::Result<()> { + if !dangerous_insecure_transport_protocol { + for url in endpoints { if url.scheme() != "https" { - return Err(serde::de::Error::custom( - "The configured updater endpoint must use the `https` protocol.", - )); + #[cfg(debug_assertions)] + { + eprintln!("[\x1b[33mWARNING\x1b[0m] The updater endpoint \"{url}\" doesn't use `https` protocol. This is allowed in development but will fail in release builds."); + eprintln!("[\x1b[33mWARNING\x1b[0m] if this is a desired behavior, you can enable `dangerousInsecureTransportProtocol` in the plugin configuration"); + } + #[cfg(not(debug_assertions))] + return Err(crate::Error::InsecureTransportProtocol); } } - Ok(Self(url)) } + + Ok(()) } diff --git a/plugins/updater/src/error.rs b/plugins/updater/src/error.rs index f12a7e12..b82e7d55 100644 --- a/plugins/updater/src/error.rs +++ b/plugins/updater/src/error.rs @@ -25,9 +25,7 @@ pub enum Error { #[error("Could not fetch a valid release JSON from the remote")] ReleaseNotFound, /// Unsupported app architecture. - #[error( - "Unsupported application architecture, expected one of `x86`, `x86_64`, `arm` or `aarch64`." - )] + #[error("Unsupported application architecture, expected one of `x86`, `x86_64`, `arm` or `aarch64`.")] UnsupportedArch, /// Operating system is not supported. #[error("Unsupported OS, expected one of `linux`, `darwin` or `windows`.")] @@ -56,14 +54,36 @@ pub enum Error { /// UTF8 Errors in signature. #[error("The signature {0} could not be decoded, please check if it is a valid base64 string. The signature must be the contents of the `.sig` file generated by the Tauri bundler, as a string.")] SignatureUtf8(String), + #[cfg(all(target_os = "windows", feature = "zip"))] /// `zip` errors. #[error(transparent)] Extract(#[from] zip::result::ZipError), /// Temp dir is not on same mount mount. This prevents our updater to rename the AppImage to a temp file. #[error("temp directory is not on the same mount point as the AppImage")] TempDirNotOnSameMountPoint, + #[error("binary for the current target not found in the archive")] + BinaryNotFoundInArchive, + #[error("failed to create temporary directory")] + TempDirNotFound, + #[error("Authentication failed or was cancelled")] + AuthenticationFailed, + #[error("Failed to install .deb package")] + DebInstallFailed, + #[error("invalid updater binary format")] + InvalidUpdaterFormat, #[error(transparent)] Http(#[from] http::Error), + #[error(transparent)] + InvalidHeaderValue(#[from] http::header::InvalidHeaderValue), + #[error(transparent)] + InvalidHeaderName(#[from] http::header::InvalidHeaderName), + #[error("Failed to format date")] + FormatDate, + /// The configured updater endpoint must use a secure protocol like `https` + #[error("The configured updater endpoint must use a secure protocol like `https`.")] + InsecureTransportProtocol, + #[error(transparent)] + Tauri(#[from] tauri::Error), } impl Serialize for Error { diff --git a/plugins/updater/src/lib.rs b/plugins/updater/src/lib.rs index 0475620d..fb059e43 100644 --- a/plugins/updater/src/lib.rs +++ b/plugins/updater/src/lib.rs @@ -2,8 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -//! [![](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/updater/banner.png)](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/updater) -//! //! In-app updates for Tauri applications. //! //! - Supported platforms: Windows, Linux and macOS.crypted database and secure runtime. @@ -13,8 +11,11 @@ html_favicon_url = "https://github.com/tauri-apps/tauri/raw/dev/app-icon.png" )] +use std::{ffi::OsString, sync::Arc}; + +use http::{HeaderMap, HeaderName, HeaderValue}; +use semver::Version; use tauri::{ - async_runtime::Mutex, plugin::{Builder as PluginBuilder, TauriPlugin}, Manager, Runtime, }; @@ -28,9 +29,7 @@ pub use config::Config; pub use error::{Error, Result}; pub use updater::*; -struct PendingUpdate(Mutex>); - -/// Extension trait to use the updater on [`tauri::App`], [`tauri::AppHandle`] and [`tauri::Window`]. +/// Extensions to [`tauri::App`], [`tauri::AppHandle`], [`tauri::WebviewWindow`], [`tauri::Webview`] and [`tauri::Window`] to access the updater APIs. pub trait UpdaterExt { /// Gets the updater builder to build and updater /// that can manually check if an update is available. @@ -71,16 +70,26 @@ pub trait UpdaterExt { impl> UpdaterExt for T { fn updater_builder(&self) -> UpdaterBuilder { let app = self.app_handle(); - let version = app.package_info().version.clone(); - let updater_config = app.config().tauri.bundle.updater.clone(); - let UpdaterState { config, target } = self.state::().inner(); + let UpdaterState { + config, + target, + version_comparator, + headers, + } = self.state::().inner(); - let mut builder = UpdaterBuilder::new(version, config.clone(), updater_config); + let mut builder = UpdaterBuilder::new(app, config.clone()).headers(headers.clone()); if let Some(target) = target { builder = builder.target(target); } + let args = self.env().args_os; + if !args.is_empty() { + builder = builder.current_exe_args(args); + } + + builder.version_comparator = version_comparator.clone(); + #[cfg(any( target_os = "linux", target_os = "dragonfly", @@ -95,6 +104,11 @@ impl> UpdaterExt for T { } } + let app_handle = app.app_handle().clone(); + builder = builder.on_before_exit(move || { + app_handle.cleanup_before_exit(); + }); + builder } @@ -106,12 +120,17 @@ impl> UpdaterExt for T { struct UpdaterState { target: Option, config: Config, + version_comparator: Option, + headers: HeaderMap, } #[derive(Default)] pub struct Builder { target: Option, - installer_args: Option>, + pubkey: Option, + installer_args: Vec, + headers: HeaderMap, + default_version_comparator: Option, } impl Builder { @@ -124,33 +143,91 @@ impl Builder { self } + pub fn pubkey>(mut self, pubkey: S) -> Self { + self.pubkey.replace(pubkey.into()); + self + } + pub fn installer_args(mut self, args: I) -> Self where I: IntoIterator, - S: Into, + S: Into, + { + self.installer_args.extend(args.into_iter().map(Into::into)); + self + } + + pub fn installer_arg(mut self, arg: S) -> Self + where + S: Into, { - self.installer_args - .replace(args.into_iter().map(Into::into).collect()); + self.installer_args.push(arg.into()); + self + } + + pub fn clear_installer_args(mut self) -> Self { + self.installer_args.clear(); + self + } + + pub fn header(mut self, key: K, value: V) -> Result + where + HeaderName: TryFrom, + >::Error: Into, + HeaderValue: TryFrom, + >::Error: Into, + { + let key: std::result::Result = key.try_into().map_err(Into::into); + let value: std::result::Result = + value.try_into().map_err(Into::into); + self.headers.insert(key?, value?); + + Ok(self) + } + + pub fn headers(mut self, headers: HeaderMap) -> Self { + self.headers = headers; + self + } + + pub fn default_version_comparator< + F: Fn(Version, RemoteRelease) -> bool + Send + Sync + 'static, + >( + mut self, + f: F, + ) -> Self { + self.default_version_comparator.replace(Arc::new(f)); self } pub fn build(self) -> TauriPlugin { + let pubkey = self.pubkey; let target = self.target; + let version_comparator = self.default_version_comparator; let installer_args = self.installer_args; + let headers = self.headers; PluginBuilder::::new("updater") - .js_init_script(include_str!("api-iife.js").to_string()) .setup(move |app, api| { let mut config = api.config().clone(); - if let Some(installer_args) = installer_args { - config.installer_args = installer_args; + if let Some(pubkey) = pubkey { + config.pubkey = pubkey; + } + if let Some(windows) = &mut config.windows { + windows.installer_args.extend(installer_args); } - app.manage(UpdaterState { target, config }); - app.manage(PendingUpdate(Default::default())); + app.manage(UpdaterState { + target, + config, + version_comparator, + headers, + }); Ok(()) }) .invoke_handler(tauri::generate_handler![ commands::check, - commands::download_and_install + commands::download, + commands::install, + commands::download_and_install, ]) .build() } diff --git a/plugins/updater/src/updater.rs b/plugins/updater/src/updater.rs index 4a6b352a..78fc0a9b 100644 --- a/plugins/updater/src/updater.rs +++ b/plugins/updater/src/updater.rs @@ -4,27 +4,38 @@ use std::{ collections::HashMap, - io::{Cursor, Read}, + ffi::OsString, + io::Cursor, path::{Path, PathBuf}, str::FromStr, + sync::Arc, time::Duration, }; +#[cfg(not(target_os = "macos"))] +use std::ffi::OsStr; + use base64::Engine; use futures_util::StreamExt; -use http::HeaderName; +use http::{header::ACCEPT, HeaderName}; use minisign_verify::{PublicKey, Signature}; +use percent_encoding::{AsciiSet, CONTROLS}; use reqwest::{ header::{HeaderMap, HeaderValue}, - Client, StatusCode, + ClientBuilder, StatusCode, }; use semver::Version; use serde::{de::Error as DeError, Deserialize, Deserializer, Serialize}; -use tauri::utils::{config::UpdaterConfig, platform::current_exe}; +use tauri::{utils::platform::current_exe, AppHandle, Resource, Runtime}; use time::OffsetDateTime; use url::Url; -use crate::error::{Error, Result}; +use crate::{ + error::{Error, Result}, + Config, +}; + +const UPDATER_USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"),); #[derive(Debug, Deserialize, Serialize, Clone)] pub struct ReleaseManifestPlatform { @@ -84,36 +95,56 @@ impl RemoteRelease { } } +pub type OnBeforeExit = Arc; +pub type OnBeforeRequest = Arc ClientBuilder + Send + Sync + 'static>; +pub type VersionComparator = Arc bool + Send + Sync>; +type MainThreadClosure = Box; +type RunOnMainThread = + Box std::result::Result<(), tauri::Error> + Send + Sync + 'static>; + pub struct UpdaterBuilder { + #[allow(dead_code)] + run_on_main_thread: RunOnMainThread, + app_name: String, current_version: Version, - config: crate::Config, - updater_config: UpdaterConfig, - version_comparator: Option bool + Send + Sync>>, + config: Config, + pub(crate) version_comparator: Option, executable_path: Option, target: Option, endpoints: Option>, headers: HeaderMap, timeout: Option, - installer_args: Option>, + proxy: Option, + installer_args: Vec, + current_exe_args: Vec, + on_before_exit: Option, + configure_client: Option, } impl UpdaterBuilder { - pub fn new( - current_version: Version, - config: crate::Config, - updater_config: UpdaterConfig, - ) -> Self { + pub(crate) fn new(app: &AppHandle, config: crate::Config) -> Self { + let app_ = app.clone(); + let run_on_main_thread = move |f| app_.run_on_main_thread(f); Self { - current_version, + run_on_main_thread: Box::new(run_on_main_thread), + installer_args: config + .windows + .as_ref() + .map(|w| w.installer_args.clone()) + .unwrap_or_default(), + current_exe_args: Vec::new(), + app_name: app.package_info().name.clone(), + current_version: app.package_info().version.clone(), config, - updater_config, version_comparator: None, executable_path: None, target: None, endpoints: None, headers: Default::default(), timeout: None, - installer_args: None, + proxy: None, + on_before_exit: None, + configure_client: None, } } @@ -121,7 +152,7 @@ impl UpdaterBuilder { mut self, f: F, ) -> Self { - self.version_comparator = Some(Box::new(f)); + self.version_comparator = Some(Arc::new(f)); self } @@ -130,9 +161,14 @@ impl UpdaterBuilder { self } - pub fn endpoints(mut self, endpoints: Vec) -> Self { + pub fn endpoints(mut self, endpoints: Vec) -> Result { + crate::config::validate_endpoints( + &endpoints, + self.config.dangerous_insecure_transport_protocol, + )?; + self.endpoints.replace(endpoints); - self + Ok(self) } pub fn executable_path>(mut self, p: P) -> Self { @@ -155,25 +191,75 @@ impl UpdaterBuilder { Ok(self) } + pub fn headers(mut self, headers: HeaderMap) -> Self { + self.headers = headers; + self + } + + pub fn clear_headers(mut self) -> Self { + self.headers.clear(); + self + } + pub fn timeout(mut self, timeout: Duration) -> Self { self.timeout = Some(timeout); self } + pub fn proxy(mut self, proxy: Url) -> Self { + self.proxy.replace(proxy); + self + } + + pub fn pubkey>(mut self, pubkey: S) -> Self { + self.config.pubkey = pubkey.into(); + self + } + + pub fn installer_arg(mut self, arg: S) -> Self + where + S: Into, + { + self.installer_args.push(arg.into()); + self + } + pub fn installer_args(mut self, args: I) -> Self where I: IntoIterator, - S: Into, + S: Into, { - self.installer_args - .replace(args.into_iter().map(Into::into).collect()); + self.installer_args.extend(args.into_iter().map(Into::into)); + self + } + + pub fn clear_installer_args(mut self) -> Self { + self.installer_args.clear(); + self + } + + pub fn on_before_exit(mut self, f: F) -> Self { + self.on_before_exit.replace(Arc::new(f)); + self + } + + /// Allows you to modify the `reqwest` client builder before the HTTP request is sent. + /// + /// Note that `reqwest` crate may be updated in minor releases of tauri-plugin-updater. + /// Therefore it's recommended to pin the plugin to at least a minor version when you're using `configure_client`. + /// + pub fn configure_client ClientBuilder + Send + Sync + 'static>( + mut self, + f: F, + ) -> Self { + self.configure_client.replace(Arc::new(f)); self } pub fn build(self) -> Result { let endpoints = self .endpoints - .unwrap_or_else(|| self.config.endpoints.into_iter().map(|e| e.0).collect()); + .unwrap_or_else(|| self.config.endpoints.clone()); if endpoints.is_empty() { return Err(Error::EmptyEndpoints); @@ -197,29 +283,49 @@ impl UpdaterBuilder { }; Ok(Updater { - config: self.updater_config, + run_on_main_thread: Arc::new(self.run_on_main_thread), + config: self.config, + app_name: self.app_name, current_version: self.current_version, version_comparator: self.version_comparator, timeout: self.timeout, + proxy: self.proxy, endpoints, - installer_args: self.installer_args.unwrap_or(self.config.installer_args), + installer_args: self.installer_args, + current_exe_args: self.current_exe_args, arch, target, json_target, headers: self.headers, extract_path, + on_before_exit: self.on_before_exit, + configure_client: self.configure_client, }) } } +impl UpdaterBuilder { + pub(crate) fn current_exe_args(mut self, args: I) -> Self + where + I: IntoIterator, + S: Into, + { + self.current_exe_args + .extend(args.into_iter().map(Into::into)); + self + } +} + pub struct Updater { - config: UpdaterConfig, + #[allow(dead_code)] + run_on_main_thread: Arc, + config: Config, + app_name: String, current_version: Version, - version_comparator: Option bool + Send + Sync>>, + version_comparator: Option, timeout: Option, + proxy: Option, endpoints: Vec, - #[allow(dead_code)] - installer_args: Vec, arch: &'static str, // The `{{target}}` variable we replace in the endpoint target: String, @@ -227,13 +333,21 @@ pub struct Updater { json_target: String, headers: HeaderMap, extract_path: PathBuf, + on_before_exit: Option, + configure_client: Option, + #[allow(unused)] + installer_args: Vec, + #[allow(unused)] + current_exe_args: Vec, } impl Updater { pub async fn check(&self) -> Result> { // we want JSON only let mut headers = self.headers.clone(); - headers.insert("Accept", HeaderValue::from_str("application/json").unwrap()); + if !headers.contains_key(ACCEPT) { + headers.insert(ACCEPT, HeaderValue::from_static("application/json")); + } // Set SSL certs for linux if they aren't available. #[cfg(target_os = "linux")] @@ -247,6 +361,7 @@ impl Updater { } let mut remote_release: Option = None; + let mut raw_json: Option = None; let mut last_error: Option = None; for url in &self.endpoints { // replace {{current_version}}, {{target}} and {{arch}} in the provided URL @@ -256,42 +371,84 @@ impl Updater { // https://releases.myapp.com/update/darwin/aarch64/1.0.0 // The main objective is if the update URL is defined via the Cargo.toml // the URL will be generated dynamically + let version = self.current_version.to_string(); + let version = version.as_bytes(); + const CONTROLS_ADD: &AsciiSet = &CONTROLS.add(b'+'); + let encoded_version = percent_encoding::percent_encode(version, CONTROLS_ADD); + let encoded_version = encoded_version.to_string(); + let url: Url = url .to_string() - // url::Url automatically url-encodes the string - .replace( - "%7B%7Bcurrent_version%7D%7D", - &self.current_version.to_string(), - ) + // url::Url automatically url-encodes the path components + .replace("%7B%7Bcurrent_version%7D%7D", &encoded_version) .replace("%7B%7Btarget%7D%7D", &self.target) .replace("%7B%7Barch%7D%7D", self.arch) + // but not query parameters + .replace("{{current_version}}", &encoded_version) + .replace("{{target}}", &self.target) + .replace("{{arch}}", self.arch) .parse()?; - let mut request = Client::new().get(url).headers(headers.clone()); + log::debug!("checking for updates {url}"); + + let mut request = ClientBuilder::new().user_agent(UPDATER_USER_AGENT); if let Some(timeout) = self.timeout { request = request.timeout(timeout); } - let response = request.send().await; + if let Some(ref proxy) = self.proxy { + log::debug!("using proxy {proxy}"); + let proxy = reqwest::Proxy::all(proxy.as_str())?; + request = request.proxy(proxy); + } - if let Ok(res) = response { - if res.status().is_success() { - // no updates found! - if StatusCode::NO_CONTENT == res.status() { - return Ok(None); - }; + if let Some(ref configure_client) = self.configure_client { + request = configure_client(request); + } - match serde_json::from_value::(res.json().await?) - .map_err(Into::into) - { - Ok(release) => { - last_error = None; - remote_release = Some(release); - // we found a relase, break the loop - break; + let response = request + .build()? + .get(url) + .headers(headers.clone()) + .send() + .await; + + match response { + Ok(res) => { + if res.status().is_success() { + // no updates found! + if StatusCode::NO_CONTENT == res.status() { + log::debug!("update endpoint returned 204 No Content"); + return Ok(None); + }; + + let update_response: serde_json::Value = res.json().await?; + log::debug!("update response: {update_response:?}"); + raw_json = Some(update_response.clone()); + match serde_json::from_value::(update_response) + .map_err(Into::into) + { + Ok(release) => { + log::debug!("parsed release response {release:?}"); + last_error = None; + remote_release = Some(release); + // we found a release, break the loop + break; + } + Err(err) => { + log::error!("failed to deserialize update response: {err}"); + last_error = Some(err) + } } - Err(err) => last_error = Some(err), + } else { + log::error!( + "update endpoint did not respond with a successful status code" + ); } } + Err(err) => { + log::error!("failed to check for updates: {err}"); + last_error = Some(err.into()) + } } } @@ -311,18 +468,25 @@ impl Updater { let update = if should_update { Some(Update { - current_version: self.current_version.to_string(), + run_on_main_thread: self.run_on_main_thread.clone(), config: self.config.clone(), + on_before_exit: self.on_before_exit.clone(), + app_name: self.app_name.clone(), + current_version: self.current_version.to_string(), target: self.target.clone(), extract_path: self.extract_path.clone(), - installer_args: self.installer_args.clone(), version: release.version.to_string(), date: release.pub_date, download_url: release.download_url(&self.json_target)?.to_owned(), - body: release.notes.clone(), signature: release.signature(&self.json_target)?.to_owned(), - timeout: self.timeout, + body: release.notes, + raw_json: raw_json.unwrap(), + timeout: None, + proxy: self.proxy.clone(), headers: self.headers.clone(), + installer_args: self.installer_args.clone(), + current_exe_args: self.current_exe_args.clone(), + configure_client: self.configure_client.clone(), }) } else { None @@ -332,9 +496,13 @@ impl Updater { } } -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct Update { - config: UpdaterConfig, + #[allow(dead_code)] + run_on_main_thread: Arc, + config: Config, + #[allow(unused)] + on_before_exit: Option, /// Update description pub body: Option, /// Version used to check for update @@ -345,48 +513,65 @@ pub struct Update { pub date: Option, /// Target pub target: String, - /// Extract path - #[allow(unused)] - extract_path: PathBuf, - #[allow(unused)] - installer_args: Vec, /// Download URL announced pub download_url: Url, /// Signature announced pub signature: String, + /// The raw version of server's JSON response. Useful if the response contains additional fields that the updater doesn't handle. + pub raw_json: serde_json::Value, /// Request timeout pub timeout: Option, + /// Request proxy + pub proxy: Option, /// Request headers pub headers: HeaderMap, + /// Extract path + #[allow(unused)] + extract_path: PathBuf, + /// App name, used for creating named tempfiles on Windows + #[allow(unused)] + app_name: String, + #[allow(unused)] + installer_args: Vec, + #[allow(unused)] + current_exe_args: Vec, + configure_client: Option, } +impl Resource for Update {} + impl Update { /// Downloads the updater package, verifies it then return it as bytes. /// /// Use [`Update::install`] to install it - pub async fn download), D: FnOnce()>( + pub async fn download), D: FnOnce()>( &self, - on_chunk: C, + mut on_chunk: C, on_download_finish: D, ) -> Result> { // set our headers let mut headers = self.headers.clone(); - headers.insert( - "Accept", - HeaderValue::from_str("application/octet-stream").unwrap(), - ); - headers.insert( - "User-Agent", - HeaderValue::from_str("tauri-updater").unwrap(), - ); + if !headers.contains_key(ACCEPT) { + headers.insert(ACCEPT, HeaderValue::from_static("application/octet-stream")); + } - let mut request = Client::new() - .get(self.download_url.clone()) - .headers(headers); + let mut request = ClientBuilder::new().user_agent(UPDATER_USER_AGENT); if let Some(timeout) = self.timeout { request = request.timeout(timeout); } - let response = request.send().await?; + if let Some(ref proxy) = self.proxy { + let proxy = reqwest::Proxy::all(proxy.as_str())?; + request = request.proxy(proxy); + } + if let Some(ref configure_client) = self.configure_client { + request = configure_client(request); + } + let response = request + .build()? + .get(self.download_url.clone()) + .headers(headers) + .send() + .await?; if !response.status().is_success() { return Err(Error::Network(format!( @@ -406,27 +591,23 @@ impl Update { let mut stream = response.bytes_stream(); while let Some(chunk) = stream.next().await { let chunk = chunk?; - let bytes = chunk.as_ref().to_vec(); - on_chunk(bytes.len(), content_length); - buffer.extend(bytes); + on_chunk(chunk.len(), content_length); + buffer.extend(chunk); } - on_download_finish(); - let mut update_buffer = Cursor::new(&buffer); - - verify_signature(&mut update_buffer, &self.signature, &self.config.pubkey)?; + verify_signature(&buffer, &self.signature, &self.config.pubkey)?; Ok(buffer) } /// Installs the updater package downloaded by [`Update::download`] - pub fn install(&self, bytes: Vec) -> Result<()> { - self.install_inner(bytes) + pub fn install(&self, bytes: impl AsRef<[u8]>) -> Result<()> { + self.install_inner(bytes.as_ref()) } /// Downloads and installs the updater package - pub async fn download_and_install), D: FnOnce()>( + pub async fn download_and_install), D: FnOnce()>( &self, on_chunk: C, on_download_finish: D, @@ -436,176 +617,248 @@ impl Update { } #[cfg(mobile)] - fn install_inner(&self, bytes: Vec) -> Result<()> { + fn install_inner(&self, _bytes: &[u8]) -> Result<()> { Ok(()) } +} - // Windows - // - // ### Expected structure: - // ├── [AppName]_[version]_x64.msi.zip # ZIP generated by tauri-bundler - // │ └──[AppName]_[version]_x64.msi # Application MSI - // ├── [AppName]_[version]_x64-setup.exe.zip # ZIP generated by tauri-bundler - // │ └──[AppName]_[version]_x64-setup.exe # NSIS installer - // └── ... - // - // ## MSI - // Update server can provide a MSI for Windows. (Generated with tauri-bundler from *Wix*) - // To replace current version of the application. In later version we'll offer - // incremental update to push specific binaries. - // - // ## EXE - // Update server can provide a custom EXE (installer) who can run any task. - #[cfg(windows)] - fn install_inner(&self, bytes: Vec) -> Result<()> { - use std::{ffi::OsStr, fs, process::Command}; +#[cfg(windows)] +enum WindowsUpdaterType { + Nsis { + path: PathBuf, + #[allow(unused)] + temp: Option, + }, + Msi { + path: PathBuf, + #[allow(unused)] + temp: Option, + }, +} - // FIXME: We need to create a memory buffer with the MSI and then run it. - // (instead of extracting the MSI to a temp path) - // - // The tricky part is the MSI need to be exposed and spawned so the memory allocation - // shouldn't drop but we should be able to pass the reference so we can drop it once the installation - // is done, otherwise we have a huge memory leak. +#[cfg(windows)] +impl WindowsUpdaterType { + fn nsis(path: PathBuf, temp: Option) -> Self { + Self::Nsis { path, temp } + } - let archive = Cursor::new(bytes); + fn msi(path: PathBuf, temp: Option) -> Self { + Self::Msi { + path: path.wrap_in_quotes(), + temp, + } + } +} - let tmp_dir = tempfile::Builder::new().tempdir()?.into_path(); +#[cfg(windows)] +impl Config { + fn install_mode(&self) -> crate::config::WindowsUpdateInstallMode { + self.windows + .as_ref() + .map(|w| w.install_mode.clone()) + .unwrap_or_default() + } +} - // extract the buffer to the tmp_dir - // we extract our signed archive into our final directory without any temp file - let mut extractor = zip::ZipArchive::new(archive)?; +/// Windows +#[cfg(windows)] +impl Update { + /// ### Expected structure: + /// ├── [AppName]_[version]_x64.msi # Application MSI + /// ├── [AppName]_[version]_x64-setup.exe # NSIS installer + /// ├── [AppName]_[version]_x64.msi.zip # ZIP generated by tauri-bundler + /// │ └──[AppName]_[version]_x64.msi # Application MSI + /// ├── [AppName]_[version]_x64-setup.exe.zip # ZIP generated by tauri-bundler + /// │ └──[AppName]_[version]_x64-setup.exe # NSIS installer + /// └── ... + fn install_inner(&self, bytes: &[u8]) -> Result<()> { + use std::iter::once; + use windows_sys::{ + w, + Win32::UI::{Shell::ShellExecuteW, WindowsAndMessaging::SW_SHOW}, + }; - // extract the msi - extractor.extract(&tmp_dir)?; + let updater_type = self.extract(bytes)?; + + let install_mode = self.config.install_mode(); + let current_args = &self.current_exe_args()[1..]; + let msi_args; + + let installer_args: Vec<&OsStr> = match &updater_type { + WindowsUpdaterType::Nsis { .. } => install_mode + .nsis_args() + .iter() + .map(OsStr::new) + .chain(once(OsStr::new("/UPDATE"))) + .chain(once(OsStr::new("/ARGS"))) + .chain(current_args.to_vec()) + .chain(self.installer_args()) + .collect(), + WindowsUpdaterType::Msi { path, .. } => { + let escaped_args = current_args + .iter() + .map(escape_msi_property_arg) + .collect::>() + .join(" "); + msi_args = OsString::from(format!("LAUNCHAPPARGS=\"{escaped_args}\"")); + + [OsStr::new("/i"), path.as_os_str()] + .into_iter() + .chain(install_mode.msiexec_args().iter().map(OsStr::new)) + .chain(once(OsStr::new("/promptrestart"))) + .chain(self.installer_args()) + .chain(once(OsStr::new("AUTOLAUNCHAPP=True"))) + .chain(once(msi_args.as_os_str())) + .collect() + } + }; - let paths = fs::read_dir(&tmp_dir)?; + if let Some(on_before_exit) = self.on_before_exit.as_ref() { + log::debug!("running on_before_exit hook"); + on_before_exit(); + } - let system_root = std::env::var("SYSTEMROOT"); - let powershell_path = system_root.as_ref().map_or_else( - |_| "powershell.exe".to_string(), - |p| format!("{p}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"), - ); + let file = match &updater_type { + WindowsUpdaterType::Nsis { path, .. } => path.as_os_str().to_os_string(), + WindowsUpdaterType::Msi { .. } => std::env::var("SYSTEMROOT").as_ref().map_or_else( + |_| OsString::from("msiexec.exe"), + |p| OsString::from(format!("{p}\\System32\\msiexec.exe")), + ), + }; + let file = encode_wide(file); + + let parameters = installer_args.join(OsStr::new(" ")); + let parameters = encode_wide(parameters); + + unsafe { + ShellExecuteW( + std::ptr::null_mut(), + w!("open"), + file.as_ptr(), + parameters.as_ptr(), + std::ptr::null(), + SW_SHOW, + ) + }; - for path in paths { - let found_path = path?.path(); - // we support 2 type of files exe & msi for now - // If it's an `exe` we expect an installer not a runtime. - if found_path.extension() == Some(OsStr::new("exe")) { - // we need to wrap the installer path in quotes for Start-Process - let mut installer_arg = std::ffi::OsString::new(); - installer_arg.push("\""); - installer_arg.push(&found_path); - installer_arg.push("\""); - - // Run the installer - Command::new(powershell_path) - .args(["-NoProfile", "-WindowStyle", "Hidden"]) - .args(["Start-Process"]) - .arg(found_path) - .arg("-ArgumentList") - .arg( - [ - self.config.windows.install_mode.nsis_args(), - self.installer_args - .iter() - .map(AsRef::as_ref) - .collect::>() - .as_slice(), - ] - .concat() - .join(", "), - ) - .spawn() - .expect("installer failed to start"); - - std::process::exit(0); - } else if found_path.extension() == Some(OsStr::new("msi")) { - // we need to wrap the current exe path in quotes for Start-Process - let mut current_exe_arg = std::ffi::OsString::new(); - current_exe_arg.push("\""); - current_exe_arg.push(current_exe()?); - current_exe_arg.push("\""); - - let mut msi_path_arg = std::ffi::OsString::new(); - msi_path_arg.push("\"\"\""); - msi_path_arg.push(&found_path); - msi_path_arg.push("\"\"\""); - - let msiexec_args = self - .config - .windows - .install_mode - .msiexec_args() - .iter() - .map(|p| p.to_string()) - .collect::>(); - - // run the installer and relaunch the application - let powershell_install_res = Command::new(powershell_path) - .args(["-NoProfile", "-WindowStyle", "Hidden"]) - .args([ - "Start-Process", - "-Wait", - "-FilePath", - "$env:SYSTEMROOT\\System32\\msiexec.exe", - "-ArgumentList", - ]) - .arg("/i,") - .arg(msi_path_arg) - .arg(format!(", {}, /promptrestart;", msiexec_args.join(", "))) - .arg("Start-Process") - .arg(current_exe_arg) - .spawn(); - if powershell_install_res.is_err() { - // fallback to running msiexec directly - relaunch won't be available - // we use this here in case powershell fails in an older machine somehow - let msiexec_path = system_root.as_ref().map_or_else( - |_| "msiexec.exe".to_string(), - |p| format!("{p}\\System32\\msiexec.exe"), - ); - let _ = Command::new(msiexec_path) - .arg("/i") - .arg(found_path) - .args(msiexec_args) - .arg("/promptrestart") - .spawn(); - } + std::process::exit(0); + } - std::process::exit(0); - } + fn installer_args(&self) -> Vec<&OsStr> { + self.installer_args + .iter() + .map(OsStr::new) + .collect::>() + } + + fn current_exe_args(&self) -> Vec<&OsStr> { + self.current_exe_args + .iter() + .map(OsStr::new) + .collect::>() + } + + fn extract(&self, bytes: &[u8]) -> Result { + #[cfg(feature = "zip")] + if infer::archive::is_zip(bytes) { + return self.extract_zip(bytes); } - Ok(()) + self.extract_exe(bytes) } - // Linux (AppImage) - // - // ### Expected structure: - // ├── [AppName]_[version]_amd64.AppImage.tar.gz # GZ generated by tauri-bundler - // │ └──[AppName]_[version]_amd64.AppImage # Application AppImage - // └── ... - // - // We should have an AppImage already installed to be able to copy and install - // the extract_path is the current AppImage path - // tmp_dir is where our new AppImage is found - #[cfg(any( - target_os = "linux", - target_os = "dragonfly", - target_os = "freebsd", - target_os = "netbsd", - target_os = "openbsd" - ))] - fn install_inner(&self, bytes: Vec) -> Result<()> { - use std::{ - ffi::OsStr, - os::unix::fs::{MetadataExt, PermissionsExt}, - }; + fn make_temp_dir(&self) -> Result { + Ok(tempfile::Builder::new() + .prefix(&format!("{}-{}-updater-", self.app_name, self.version)) + .tempdir()? + .into_path()) + } + + #[cfg(feature = "zip")] + fn extract_zip(&self, bytes: &[u8]) -> Result { + let temp_dir = self.make_temp_dir()?; + let archive = Cursor::new(bytes); + let mut extractor = zip::ZipArchive::new(archive)?; + extractor.extract(&temp_dir)?; + + let paths = std::fs::read_dir(&temp_dir)?; + for path in paths { + let path = path?.path(); + let ext = path.extension(); + if ext == Some(OsStr::new("exe")) { + return Ok(WindowsUpdaterType::nsis(path, None)); + } else if ext == Some(OsStr::new("msi")) { + return Ok(WindowsUpdaterType::msi(path, None)); + } + } + + Err(crate::Error::BinaryNotFoundInArchive) + } + + fn extract_exe(&self, bytes: &[u8]) -> Result { + if infer::app::is_exe(bytes) { + let (path, temp) = self.write_to_temp(bytes, ".exe")?; + Ok(WindowsUpdaterType::nsis(path, temp)) + } else if infer::archive::is_msi(bytes) { + let (path, temp) = self.write_to_temp(bytes, ".msi")?; + Ok(WindowsUpdaterType::msi(path, temp)) + } else { + Err(crate::Error::InvalidUpdaterFormat) + } + } + + fn write_to_temp( + &self, + bytes: &[u8], + ext: &str, + ) -> Result<(PathBuf, Option)> { + use std::io::Write; + + let temp_dir = self.make_temp_dir()?; + let mut temp_file = tempfile::Builder::new() + .prefix(&format!("{}-{}-installer", self.app_name, self.version)) + .suffix(ext) + .rand_bytes(0) + .tempfile_in(temp_dir)?; + temp_file.write_all(bytes)?; + + let temp = temp_file.into_temp_path(); + Ok((temp.to_path_buf(), Some(temp))) + } +} + +/// Linux (AppImage and Deb) +#[cfg(any( + target_os = "linux", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "netbsd", + target_os = "openbsd" +))] +impl Update { + /// ### Expected structure: + /// ├── [AppName]_[version]_amd64.AppImage.tar.gz # GZ generated by tauri-bundler + /// │ └──[AppName]_[version]_amd64.AppImage # Application AppImage + /// ├── [AppName]_[version]_amd64.deb # Debian package + /// └── ... + /// + fn install_inner(&self, bytes: &[u8]) -> Result<()> { + if self.is_deb_package() { + self.install_deb(bytes) + } else { + // Handle AppImage or other formats + self.install_appimage(bytes) + } + } + + fn install_appimage(&self, bytes: &[u8]) -> Result<()> { + use std::os::unix::fs::{MetadataExt, PermissionsExt}; let extract_path_metadata = self.extract_path.metadata()?; let tmp_dir_locations = vec![ Box::new(|| Some(std::env::temp_dir())) as Box Option>, - Box::new(dirs_next::cache_dir), + Box::new(dirs::cache_dir), Box::new(|| Some(self.extract_path.parent().unwrap().to_path_buf())), ]; @@ -623,27 +876,48 @@ impl Update { let tmp_app_image = &tmp_dir.path().join("current_app.AppImage"); + let permissions = std::fs::metadata(&self.extract_path)?.permissions(); + // create a backup of our current app image std::fs::rename(&self.extract_path, tmp_app_image)?; - // extract the buffer to the tmp_dir - // we extract our signed archive into our final directory without any temp file - let mut archive = tar::Archive::new(archive); - for mut entry in archive.entries()?.flatten() { - if let Ok(path) = entry.path() { - if path.extension() == Some(OsStr::new("AppImage")) { - // if something went wrong during the extraction, we should restore previous app - if let Err(err) = entry.unpack(&self.extract_path) { - std::fs::rename(tmp_app_image, &self.extract_path)?; - return Err(err.into()); + #[cfg(feature = "zip")] + if infer::archive::is_gz(bytes) { + log::debug!("extracting AppImage"); + // extract the buffer to the tmp_dir + // we extract our signed archive into our final directory without any temp file + let archive = Cursor::new(bytes); + let decoder = flate2::read::GzDecoder::new(archive); + let mut archive = tar::Archive::new(decoder); + for mut entry in archive.entries()?.flatten() { + if let Ok(path) = entry.path() { + if path.extension() == Some(OsStr::new("AppImage")) { + // if something went wrong during the extraction, we should restore previous app + if let Err(err) = entry.unpack(&self.extract_path) { + std::fs::rename(tmp_app_image, &self.extract_path)?; + return Err(err.into()); + } + // early finish we have everything we need here + return Ok(()); } - // early finish we have everything we need here - return Ok(()); } } + // if we have not returned early we should restore the backup + std::fs::rename(tmp_app_image, &self.extract_path)?; + return Err(Error::BinaryNotFoundInArchive); } - return Ok(()); + log::debug!("rewriting AppImage"); + return match std::fs::write(&self.extract_path, bytes) + .and_then(|_| std::fs::set_permissions(&self.extract_path, permissions)) + { + Err(err) => { + // if something went wrong during the extraction, we should restore previous app + std::fs::rename(tmp_app_image, &self.extract_path)?; + Err(err.into()) + } + Ok(_) => Ok(()), + }; } } } @@ -651,57 +925,262 @@ impl Update { Err(Error::TempDirNotOnSameMountPoint) } - // MacOS - // - // ### Expected structure: - // ├── [AppName]_[version]_x64.app.tar.gz # GZ generated by tauri-bundler - // │ └──[AppName].app # Main application - // │ └── Contents # Application contents... - // │ └── ... - // └── ... - #[cfg(target_os = "macos")] - fn install_inner(&self, bytes: Vec) -> Result<()> { + fn is_deb_package(&self) -> bool { + // First check if we're in a typical Debian installation path + let in_system_path = self + .extract_path + .to_str() + .map(|p| p.starts_with("/usr")) + .unwrap_or(false); + + if !in_system_path { + return false; + } + + // Then verify it's actually a Debian-based system by checking for dpkg + let dpkg_exists = std::path::Path::new("/var/lib/dpkg").exists(); + let apt_exists = std::path::Path::new("/etc/apt").exists(); + + // Additional check for the package in dpkg database + let package_in_dpkg = if let Ok(output) = std::process::Command::new("dpkg") + .args(["-S", &self.extract_path.to_string_lossy()]) + .output() + { + output.status.success() + } else { + false + }; + + // Consider it a deb package only if: + // 1. We're in a system path AND + // 2. We have Debian package management tools AND + // 3. The binary is tracked by dpkg + dpkg_exists && apt_exists && package_in_dpkg + } + + fn install_deb(&self, bytes: &[u8]) -> Result<()> { + // First verify the bytes are actually a .deb package + if !infer::archive::is_deb(bytes) { + log::warn!("update is not a valid deb package"); + return Err(Error::InvalidUpdaterFormat); + } + + // Try different temp directories + let tmp_dir_locations = vec![ + Box::new(|| Some(std::env::temp_dir())) as Box Option>, + Box::new(dirs::cache_dir), + Box::new(|| Some(self.extract_path.parent().unwrap().to_path_buf())), + ]; + + // Try writing to multiple temp locations until one succeeds + for tmp_dir_location in tmp_dir_locations { + if let Some(path) = tmp_dir_location() { + if let Ok(tmp_dir) = tempfile::Builder::new() + .prefix("tauri_deb_update") + .tempdir_in(path) + { + let deb_path = tmp_dir.path().join("package.deb"); + + // Try writing the .deb file + if std::fs::write(&deb_path, bytes).is_ok() { + // If write succeeds, proceed with installation + return self.try_install_with_privileges(&deb_path); + } + // If write fails, continue to next temp location + } + } + } + + // If we get here, all temp locations failed + Err(Error::TempDirNotFound) + } + + fn try_install_with_privileges(&self, deb_path: &Path) -> Result<()> { + // 1. First try using pkexec (graphical sudo prompt) + if let Ok(status) = std::process::Command::new("pkexec") + .arg("dpkg") + .arg("-i") + .arg(deb_path) + .status() + { + if status.success() { + log::debug!("installed deb with pkexec"); + return Ok(()); + } + } + + // 2. Try zenity or kdialog for a graphical sudo experience + if let Ok(password) = self.get_password_graphically() { + if self.install_with_sudo(deb_path, &password)? { + log::debug!("installed deb with GUI sudo"); + return Ok(()); + } + } + + // 3. Final fallback: terminal sudo + let status = std::process::Command::new("sudo") + .arg("dpkg") + .arg("-i") + .arg(deb_path) + .status()?; + + if status.success() { + log::debug!("installed deb with sudo"); + Ok(()) + } else { + Err(Error::DebInstallFailed) + } + } + + fn get_password_graphically(&self) -> Result { + // Try zenity first + let zenity_result = std::process::Command::new("zenity") + .args([ + "--password", + "--title=Authentication Required", + "--text=Enter your password to install the update:", + ]) + .output(); + + if let Ok(output) = zenity_result { + if output.status.success() { + return Ok(String::from_utf8_lossy(&output.stdout).trim().to_string()); + } + } + + // Fall back to kdialog if zenity fails or isn't available + let kdialog_result = std::process::Command::new("kdialog") + .args(["--password", "Enter your password to install the update:"]) + .output(); + + if let Ok(output) = kdialog_result { + if output.status.success() { + return Ok(String::from_utf8_lossy(&output.stdout).trim().to_string()); + } + } + + Err(Error::AuthenticationFailed) + } + + fn install_with_sudo(&self, deb_path: &Path, password: &str) -> Result { + use std::io::Write; + use std::process::{Command, Stdio}; + + let mut child = Command::new("sudo") + .arg("-S") // read password from stdin + .arg("dpkg") + .arg("-i") + .arg(deb_path) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn()?; + + if let Some(mut stdin) = child.stdin.take() { + // Write password to stdin + writeln!(stdin, "{}", password)?; + } + + let status = child.wait()?; + Ok(status.success()) + } +} + +/// MacOS +#[cfg(target_os = "macos")] +impl Update { + /// ### Expected structure: + /// ├── [AppName]_[version]_x64.app.tar.gz # GZ generated by tauri-bundler + /// │ └──[AppName].app # Main application + /// │ └── Contents # Application contents... + /// │ └── ... + /// └── ... + fn install_inner(&self, bytes: &[u8]) -> Result<()> { use flate2::read::GzDecoder; let cursor = Cursor::new(bytes); let mut extracted_files: Vec = Vec::new(); - // the first file in the tar.gz will always be - // /Contents - let tmp_dir = tempfile::Builder::new() + // Create temp directories for backup and extraction + let tmp_backup_dir = tempfile::Builder::new() .prefix("tauri_current_app") .tempdir()?; - // create backup of our current app - std::fs::rename(&self.extract_path, tmp_dir.path())?; + let tmp_extract_dir = tempfile::Builder::new() + .prefix("tauri_updated_app") + .tempdir()?; let decoder = GzDecoder::new(cursor); let mut archive = tar::Archive::new(decoder); - std::fs::create_dir(&self.extract_path)?; - + // Extract files to temporary directory for entry in archive.entries()? { let mut entry = entry?; - - // skip the first folder (should be the app name) let collected_path: PathBuf = entry.path()?.iter().skip(1).collect(); - let extraction_path = &self.extract_path.join(collected_path); - - // if something went wrong during the extraction, we should restore previous app - if let Err(err) = entry.unpack(extraction_path) { - for file in extracted_files.iter().rev() { - // delete all the files we extracted - if file.is_dir() { - std::fs::remove_dir(file)?; - } else { - std::fs::remove_file(file)?; - } - } - std::fs::rename(tmp_dir.path(), &self.extract_path)?; + let extraction_path = tmp_extract_dir.path().join(&collected_path); + + // Ensure parent directories exist + if let Some(parent) = extraction_path.parent() { + std::fs::create_dir_all(parent)?; + } + + if let Err(err) = entry.unpack(&extraction_path) { + // Cleanup on error + std::fs::remove_dir_all(tmp_extract_dir.path()).ok(); + return Err(err.into()); + } + extracted_files.push(extraction_path); + } + + // Try to move the current app to backup + let move_result = std::fs::rename( + &self.extract_path, + tmp_backup_dir.path().join("current_app"), + ); + let need_authorization = if let Err(err) = move_result { + if err.kind() == std::io::ErrorKind::PermissionDenied { + true + } else { + std::fs::remove_dir_all(tmp_extract_dir.path()).ok(); return Err(err.into()); } + } else { + false + }; - extracted_files.push(extraction_path.to_path_buf()); + if need_authorization { + log::debug!("app installation needs admin privileges"); + // Use AppleScript to perform moves with admin privileges + let apple_script = format!( + "do shell script \"rm -rf '{src}' && mv -f '{new}' '{src}'\" with administrator privileges", + src = self.extract_path.display(), + new = tmp_extract_dir.path().display() + ); + + let (tx, rx) = std::sync::mpsc::channel(); + let res = (self.run_on_main_thread)(Box::new(move || { + let mut script = + osakit::Script::new_from_source(osakit::Language::AppleScript, &apple_script); + script.compile().expect("invalid AppleScript"); + let r = script.execute(); + tx.send(r).unwrap(); + })); + let result = rx.recv().unwrap(); + + if res.is_err() || result.is_err() { + std::fs::remove_dir_all(tmp_extract_dir.path()).ok(); + return Err(Error::Io(std::io::Error::new( + std::io::ErrorKind::PermissionDenied, + "Failed to move the new app into place", + ))); + } + } else { + // Remove existing directory if it exists + if self.extract_path.exists() { + std::fs::remove_dir_all(&self.extract_path)?; + } + // Move the new app to the target path + std::fs::rename(tmp_extract_dir.path(), &self.extract_path)?; } let _ = std::process::Command::new("touch") @@ -743,6 +1222,8 @@ pub(crate) fn get_updater_arch() -> Option<&'static str> { Some("armv7") } else if cfg!(target_arch = "aarch64") { Some("aarch64") + } else if cfg!(target_arch = "riscv64") { + Some("riscv64") } else { None } @@ -836,30 +1317,15 @@ where } // Validate signature -// need to be public because its been used -// by our tests in the bundler -// -// NOTE: The buffer position is not reset. -pub fn verify_signature( - archive_reader: &mut R, - release_signature: &str, - pub_key: &str, -) -> Result -where - R: Read, -{ +fn verify_signature(data: &[u8], release_signature: &str, pub_key: &str) -> Result { // we need to convert the pub key let pub_key_decoded = base64_to_string(pub_key)?; let public_key = PublicKey::decode(&pub_key_decoded)?; let signature_base64_decoded = base64_to_string(release_signature)?; let signature = Signature::decode(&signature_base64_decoded)?; - // read all bytes until EOF in the buffer - let mut data = Vec::new(); - archive_reader.read_to_end(&mut data)?; - // Validate signature or bail out - public_key.verify(&data, &signature, true)?; + public_key.verify(data, &signature, true)?; Ok(true) } @@ -870,3 +1336,119 @@ fn base64_to_string(base64_string: &str) -> Result { .to_string(); Ok(result) } + +#[cfg(windows)] +fn encode_wide(string: impl AsRef) -> Vec { + use std::os::windows::ffi::OsStrExt; + + string + .as_ref() + .encode_wide() + .chain(std::iter::once(0)) + .collect() +} + +#[cfg(windows)] +trait PathExt { + fn wrap_in_quotes(&self) -> Self; +} + +#[cfg(windows)] +impl PathExt for PathBuf { + fn wrap_in_quotes(&self) -> Self { + let mut msi_path = OsString::from("\""); + msi_path.push(self.as_os_str()); + msi_path.push("\""); + PathBuf::from(msi_path) + } +} + +#[cfg(windows)] +fn escape_msi_property_arg(arg: impl AsRef) -> String { + let mut arg = arg.as_ref().to_string_lossy().to_string(); + + // Otherwise this argument will get lost in ShellExecute + if arg.is_empty() { + return "\"\"\"\"".to_string(); + } else if !arg.contains(' ') && !arg.contains('"') { + return arg; + } + + if arg.contains('"') { + arg = arg.replace('"', r#""""""#) + } + + if arg.starts_with('-') { + if let Some((a1, a2)) = arg.split_once('=') { + format!("{a1}=\"\"{a2}\"\"") + } else { + format!("\"\"{arg}\"\"") + } + } else { + format!("\"\"{arg}\"\"") + } +} + +#[cfg(test)] +mod tests { + + #[test] + #[cfg(windows)] + fn it_wraps_correctly() { + use super::PathExt; + use std::path::PathBuf; + + assert_eq!( + PathBuf::from("C:\\Users\\Some User\\AppData\\tauri-example.exe").wrap_in_quotes(), + PathBuf::from("\"C:\\Users\\Some User\\AppData\\tauri-example.exe\"") + ) + } + + #[test] + #[cfg(windows)] + fn it_escapes_correctly() { + use crate::updater::escape_msi_property_arg; + + // Explanation for quotes: + // The output of escape_msi_property_args() will be used in `LAUNCHAPPARGS=\"{HERE}\"`. This is the first quote level. + // To escape a quotation mark we use a second quotation mark, so "" is interpreted as " later. + // This means that the escaped strings can't ever have a single quotation mark! + // Now there are 3 major things to look out for to not break the msiexec call: + // 1) Wrap spaces in quotation marks, otherwise it will be interpreted as the end of the msiexec argument. + // 2) Escape escaping quotation marks, otherwise they will either end the msiexec argument or be ignored. + // 3) Escape emtpy args in quotation marks, otherwise the argument will get lost. + let cases = [ + "something", + "--flag", + "--empty=", + "--arg=value", + "some space", // This simulates `./my-app "some string"`. + "--arg value", // -> This simulates `./my-app "--arg value"`. Same as above but it triggers the startsWith(`-`) logic. + "--arg=unwrapped space", // `./my-app --arg="unwrapped space"` + "--arg=\"wrapped\"", // `./my-app --args=""wrapped""` + "--arg=\"wrapped space\"", // `./my-app --args=""wrapped space""` + "--arg=midword\"wrapped space\"", // `./my-app --args=midword""wrapped""` + "", // `./my-app '""'` + ]; + let cases_escaped = [ + "something", + "--flag", + "--empty=", + "--arg=value", + "\"\"some space\"\"", + "\"\"--arg value\"\"", + "--arg=\"\"unwrapped space\"\"", + r#"--arg=""""""wrapped"""""""#, + r#"--arg=""""""wrapped space"""""""#, + r#"--arg=""midword""""wrapped space"""""""#, + "\"\"\"\"", + ]; + + // Just to be sure we didn't mess that up + assert_eq!(cases.len(), cases_escaped.len()); + + for (orig, escaped) in cases.iter().zip(cases_escaped) { + assert_eq!(escape_msi_property_arg(orig), escaped); + } + } +} diff --git a/plugins/updater/tests/app-updater/.gitignore b/plugins/updater/tests/app-updater/.gitignore index e69de29b..6a4bb536 100644 --- a/plugins/updater/tests/app-updater/.gitignore +++ b/plugins/updater/tests/app-updater/.gitignore @@ -0,0 +1 @@ +/gen/schemas diff --git a/plugins/updater/tests/app-updater/Cargo.toml b/plugins/updater/tests/app-updater/Cargo.toml index c80ac920..71b9f900 100644 --- a/plugins/updater/tests/app-updater/Cargo.toml +++ b/plugins/updater/tests/app-updater/Cargo.toml @@ -7,12 +7,12 @@ edition = { workspace = true } tauri-build = { workspace = true } [dependencies] -tauri = { workspace = true } +tauri = { workspace = true, features = ["wry", "compression"] } serde = { workspace = true } serde_json = { workspace = true } tauri-plugin-updater = { path = "../.." } -tiny_http = "0.11" +tiny_http = "0.12" time = { version = "0.3", features = ["formatting"] } [features] -custom-protocol = ["tauri/custom-protocol"] +prod = ["tauri/custom-protocol"] diff --git a/plugins/updater/tests/app-updater/src/main.rs b/plugins/updater/tests/app-updater/src/main.rs index ad145c49..bbe398b5 100644 --- a/plugins/updater/tests/app-updater/src/main.rs +++ b/plugins/updater/tests/app-updater/src/main.rs @@ -42,7 +42,7 @@ fn main() { std::process::exit(0); } Ok(None) => { - std::process::exit(0); + std::process::exit(2); } Err(e) => { println!("{e}"); diff --git a/plugins/updater/tests/app-updater/tauri.conf.json b/plugins/updater/tests/app-updater/tauri.conf.json index bbc72ca6..f2c6df21 100644 --- a/plugins/updater/tests/app-updater/tauri.conf.json +++ b/plugins/updater/tests/app-updater/tauri.conf.json @@ -1,39 +1,33 @@ { - "$schema": "../../../../node_modules/.pnpm/@tauri-apps+cli@2.0.0-alpha.16/node_modules/@tauri-apps/cli/schema.json", - "build": { - "distDir": [], - "devPath": [] - }, - "tauri": { - "bundle": { - "active": true, - "targets": "all", - "identifier": "com.tauri.updater", - "icon": [ - "icons/32x32.png", - "icons/128x128.png", - "icons/128x128@2x.png", - "icons/icon.icns", - "icons/icon.ico" - ], - "category": "DeveloperTool", + "identifier": "com.tauri.updater", + "plugins": { + "updater": { + "endpoints": ["http://localhost:3007"], + "pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEUwNDRGMjkwRjg2MDhCRDAKUldUUWkyRDRrUEpFNEQ4SmdwcU5PaXl6R2ZRUUNvUnhIaVkwVUltV0NMaEx6VTkrWVhpT0ZqeEEK", "windows": { - "wix": { - "skipWebviewInstall": true - } - }, - "updater": { - "active": true, - "pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEMwNjY1MEExMTFBMDU5RTUKUldUbFdhQVJvVkJtd09sZ1ROT25yVGFhU2o0ZnUyd1FlT0ZTQ2ZXamN3SXk4SjZLZmNwRnV5dTMK", - "windows": { - "installMode": "quiet" - } + "installMode": "quiet", + "installerArgs": ["/NS"] } } }, - "plugins": { - "updater": { - "endpoints": ["http://localhost:3007"] + "bundle": { + "active": true, + "targets": "all", + "createUpdaterArtifacts": true, + "icon": [ + "icons/32x32.png", + "icons/128x128.png", + "icons/128x128@2x.png", + "icons/icon.icns", + "icons/icon.ico" + ], + "windows": { + "webviewInstallMode": { + "type": "skip" + }, + "nsis": { + "compression": "none" + } } } } diff --git a/plugins/updater/tests/app-updater/tests/update.rs b/plugins/updater/tests/app-updater/tests/update.rs index 287664e8..d308b317 100644 --- a/plugins/updater/tests/app-updater/tests/update.rs +++ b/plugins/updater/tests/app-updater/tests/update.rs @@ -9,20 +9,26 @@ use std::{ fs::File, path::{Path, PathBuf}, process::Command, + sync::Arc, }; use serde::Serialize; +use tauri::utils::config::{Updater, V1Compatible}; -const UPDATER_PRIVATE_KEY: &str = "dW50cnVzdGVkIGNvbW1lbnQ6IHJzaWduIGVuY3J5cHRlZCBzZWNyZXQga2V5ClJXUlRZMEl5Qm9uUXIyeEM2YkczeGMwZDFENmw1WHEzaFk5aDlOOXNyTWRxRnY4UUpzZ0FBQkFBQUFBQUFBQUFBQUlBQUFBQTVWbWdFYUZRWnNDZmdyUW9ibWExVEFTY0pVTWpVS2xlOHdhR1I3Q3hpd2FTNjg1MXZENEQyZWxnVE5PbnJUYWFTajRmdTJ3UWVPRlNDZldqY3dJeThKNktmY3BGdXl1M1BPdHgwOFhIQzJLSnpqS0Z2cVdmaEs2WWRmK3d4SHVCMlpHVGduaVAzclU9Cg=="; +const UPDATER_PRIVATE_KEY: &str = "dW50cnVzdGVkIGNvbW1lbnQ6IHJzaWduIGVuY3J5cHRlZCBzZWNyZXQga2V5ClJXUlRZMEl5TlFOMFpXYzJFOUdjeHJEVXY4WE1TMUxGNDJVUjNrMmk1WlR3UVJVUWwva0FBQkFBQUFBQUFBQUFBQUlBQUFBQUpVK3ZkM3R3eWhyN3hiUXhQb2hvWFVzUW9FbEs3NlNWYjVkK1F2VGFRU1FEaGxuRUtlell5U0gxYS9DbVRrS0YyZVJGblhjeXJibmpZeGJjS0ZKSUYwYndYc2FCNXpHalM3MHcrODMwN3kwUG9SOWpFNVhCSUd6L0E4TGRUT096TEtLR1JwT1JEVFU9Cg=="; +const UPDATED_EXIT_CODE: i32 = 0; +const UP_TO_DATE_EXIT_CODE: i32 = 2; #[derive(Serialize)] -struct PackageConfig { +struct Config { version: &'static str, + bundle: BundleConfig, } #[derive(Serialize)] -struct Config { - package: PackageConfig, +#[serde(rename_all = "camelCase")] +struct BundleConfig { + create_updater_artifacts: Updater, } #[derive(Serialize)] @@ -39,27 +45,14 @@ struct Update { platforms: HashMap, } -fn get_cli_bin_path(cli_dir: &Path, debug: bool) -> Option { - let mut cli_bin_path = cli_dir.join(format!( - "target/{}/cargo-tauri", - if debug { "debug" } else { "release" } - )); - if cfg!(windows) { - cli_bin_path.set_extension("exe"); - } - if cli_bin_path.exists() { - Some(cli_bin_path) - } else { - None - } -} - fn build_app(cwd: &Path, config: &Config, bundle_updater: bool, target: BundleTarget) { let mut command = Command::new("cargo"); command .args(["tauri", "build", "--debug", "--verbose"]) .arg("--config") .arg(serde_json::to_string(config).unwrap()) + .env("TAURI_SIGNING_PRIVATE_KEY", UPDATER_PRIVATE_KEY) + .env("TAURI_SIGNING_PRIVATE_KEY_PASSWORD", "") .current_dir(cwd); #[cfg(target_os = "linux")] @@ -70,11 +63,6 @@ fn build_app(cwd: &Path, config: &Config, bundle_updater: bool, target: BundleTa if bundle_updater { #[cfg(windows)] command.args(["--bundles", "msi", "nsis"]); - - command - .env("TAURI_SIGNING_PRIVATE_KEY", UPDATER_PRIVATE_KEY) - .env("TAURI_SIGNING_PRIVATE_KEY_PASSWORD", "") - .args(["--bundles", "updater"]); } else { #[cfg(windows)] command.args(["--bundles", target.name()]); @@ -84,7 +72,7 @@ fn build_app(cwd: &Path, config: &Config, bundle_updater: bool, target: BundleTa .status() .expect("failed to run Tauri CLI to bundle app"); - if !status.code().map(|c| c == 0).unwrap_or(true) { + if !status.success() { panic!("failed to bundle app {:?}", status.code()); } } @@ -178,43 +166,83 @@ fn update_app() { let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")); let root_dir = manifest_dir.join("../../../.."); - let mut config = Config { - package: PackageConfig { version: "1.0.0" }, - }; - - // bundle app update - build_app(&manifest_dir, &config, true, Default::default()); - - let updater_zip_ext = if cfg!(windows) { "zip" } else { "tar.gz" }; - - for (bundle_target, out_bundle_path) in bundle_paths(&root_dir, "1.0.0") { - let bundle_updater_ext = out_bundle_path - .extension() - .unwrap() - .to_str() - .unwrap() - .replace("exe", "nsis"); - let signature_path = - out_bundle_path.with_extension(format!("{bundle_updater_ext}.{updater_zip_ext}.sig")); - let signature = std::fs::read_to_string(&signature_path).unwrap_or_else(|_| { - panic!("failed to read signature file {}", signature_path.display()) - }); - let out_updater_path = - out_bundle_path.with_extension(format!("{}.{}", bundle_updater_ext, updater_zip_ext)); - let updater_path = root_dir.join(format!( - "target/debug/{}", - out_updater_path.file_name().unwrap().to_str().unwrap() - )); - std::fs::rename(&out_updater_path, &updater_path).expect("failed to rename bundle"); - - let target = target.clone(); - std::thread::spawn(move || { + for mut config in [ + Config { + version: "1.0.0", + bundle: BundleConfig { + create_updater_artifacts: Updater::Bool(true), + }, + }, + Config { + version: "1.0.0", + bundle: BundleConfig { + create_updater_artifacts: Updater::String(V1Compatible::V1Compatible), + }, + }, + ] { + let v1_compatible = matches!( + config.bundle.create_updater_artifacts, + Updater::String(V1Compatible::V1Compatible) + ); + + // bundle app update + build_app(&manifest_dir, &config, true, Default::default()); + + let updater_zip_ext = if v1_compatible { + if cfg!(windows) { + Some("zip") + } else { + Some("tar.gz") + } + } else if cfg!(target_os = "macos") { + Some("tar.gz") + } else { + None + }; + + for (bundle_target, out_bundle_path) in bundle_paths(&root_dir, "1.0.0") { + let bundle_updater_ext = if v1_compatible { + out_bundle_path + .extension() + .unwrap() + .to_str() + .unwrap() + .replace("exe", "nsis") + } else { + out_bundle_path + .extension() + .unwrap() + .to_str() + .unwrap() + .to_string() + }; + let updater_extension = if let Some(updater_zip_ext) = updater_zip_ext { + format!("{bundle_updater_ext}.{updater_zip_ext}") + } else { + bundle_updater_ext + }; + let signature_extension = format!("{updater_extension}.sig"); + let signature_path = out_bundle_path.with_extension(signature_extension); + let signature = std::fs::read_to_string(&signature_path).unwrap_or_else(|_| { + panic!("failed to read signature file {}", signature_path.display()) + }); + let out_updater_path = out_bundle_path.with_extension(updater_extension); + let updater_path = root_dir.join(format!( + "target/debug/{}", + out_updater_path.file_name().unwrap().to_str().unwrap() + )); + std::fs::rename(&out_updater_path, &updater_path).expect("failed to rename bundle"); + + let target = target.clone(); + // start the updater server - let server = - tiny_http::Server::http("localhost:3007").expect("failed to start updater server"); + let server = Arc::new( + tiny_http::Server::http("localhost:3007").expect("failed to start updater server"), + ); - loop { - if let Ok(request) = server.recv() { + let server_ = server.clone(); + std::thread::spawn(move || { + for request in server_.incoming_requests() { match request.url() { "/" => { let mut platforms = HashMap::new(); @@ -254,45 +282,63 @@ fn update_app() { ) }), )); - // close server - return; } _ => (), } } + }); + + config.version = "0.1.0"; + + // bundle initial app version + build_app(&manifest_dir, &config, false, bundle_target); + + let status_checks = if matches!(bundle_target, BundleTarget::Msi) { + // for msi we can't really check if the app was updated, because we can't change the install path + vec![UPDATED_EXIT_CODE] + } else { + vec![UPDATED_EXIT_CODE, UP_TO_DATE_EXIT_CODE] + }; + + for expected_exit_code in status_checks { + let mut binary_cmd = if cfg!(windows) { + Command::new(root_dir.join("target/debug/app-updater.exe")) + } else if cfg!(target_os = "macos") { + Command::new( + bundle_paths(&root_dir, "0.1.0") + .first() + .unwrap() + .1 + .join("Contents/MacOS/app-updater"), + ) + } else if std::env::var("CI").map(|v| v == "true").unwrap_or_default() { + let mut c = Command::new("xvfb-run"); + c.arg("--auto-servernum") + .arg(&bundle_paths(&root_dir, "0.1.0").first().unwrap().1); + c + } else { + Command::new(&bundle_paths(&root_dir, "0.1.0").first().unwrap().1) + }; + + binary_cmd.env("TARGET", bundle_target.name()); + + let status = binary_cmd.status().expect("failed to run app"); + let code = status.code().unwrap_or(-1); + + if code != expected_exit_code { + panic!( + "failed to run app, expected exit code {expected_exit_code}, got {code}" + ); + } + #[cfg(windows)] + if code == UPDATED_EXIT_CODE { + // wait for the update to finish + std::thread::sleep(std::time::Duration::from_secs(5)); + } } - }); - - config.package.version = "0.1.0"; - - // bundle initial app version - build_app(&manifest_dir, &config, false, bundle_target); - - let mut binary_cmd = if cfg!(windows) { - Command::new(root_dir.join("target/debug/app-updater.exe")) - } else if cfg!(target_os = "macos") { - Command::new( - bundle_paths(&root_dir, "0.1.0") - .first() - .unwrap() - .1 - .join("Contents/MacOS/app-updater"), - ) - } else if std::env::var("CI").map(|v| v == "true").unwrap_or_default() { - let mut c = Command::new("xvfb-run"); - c.arg("--auto-servernum") - .arg(&bundle_paths(&root_dir, "0.1.0").first().unwrap().1); - c - } else { - Command::new(&bundle_paths(&root_dir, "0.1.0").first().unwrap().1) - }; - - binary_cmd.env("TARGET", bundle_target.name()); - - let status = binary_cmd.status().expect("failed to run app"); - if !status.success() { - panic!("failed to run app"); + // graceful shutdown + server.unblock(); } } } diff --git a/plugins/updater/tests/updater-migration/Cargo.toml b/plugins/updater/tests/updater-migration/Cargo.toml new file mode 100644 index 00000000..4edb07da --- /dev/null +++ b/plugins/updater/tests/updater-migration/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "updater-migration-test" +version = "0.1.0" +edition = { workspace = true } + +[build-dependencies] +tauri-build = { workspace = true } + +[dependencies] +tauri = { workspace = true, features = ["wry", "compression"] } +serde = { workspace = true } +serde_json = { workspace = true } +tauri-plugin-updater = { path = "../.." } +tiny_http = "0.12" +time = { version = "0.3", features = ["formatting"] } diff --git a/plugins/updater/tests/updater-migration/icons/128x128.png b/plugins/updater/tests/updater-migration/icons/128x128.png new file mode 100644 index 00000000..77e7d233 Binary files /dev/null and b/plugins/updater/tests/updater-migration/icons/128x128.png differ diff --git a/plugins/updater/tests/updater-migration/icons/128x128@2x.png b/plugins/updater/tests/updater-migration/icons/128x128@2x.png new file mode 100644 index 00000000..0f7976f1 Binary files /dev/null and b/plugins/updater/tests/updater-migration/icons/128x128@2x.png differ diff --git a/plugins/updater/tests/updater-migration/icons/32x32.png b/plugins/updater/tests/updater-migration/icons/32x32.png new file mode 100644 index 00000000..98fda06f Binary files /dev/null and b/plugins/updater/tests/updater-migration/icons/32x32.png differ diff --git a/plugins/updater/tests/updater-migration/icons/icon.icns b/plugins/updater/tests/updater-migration/icons/icon.icns new file mode 100644 index 00000000..5594104c Binary files /dev/null and b/plugins/updater/tests/updater-migration/icons/icon.icns differ diff --git a/plugins/updater/tests/updater-migration/icons/icon.ico b/plugins/updater/tests/updater-migration/icons/icon.ico new file mode 100644 index 00000000..06c23c82 Binary files /dev/null and b/plugins/updater/tests/updater-migration/icons/icon.ico differ diff --git a/plugins/updater/tests/updater-migration/icons/icon.png b/plugins/updater/tests/updater-migration/icons/icon.png new file mode 100644 index 00000000..d1756ce4 Binary files /dev/null and b/plugins/updater/tests/updater-migration/icons/icon.png differ diff --git a/plugins/updater/tests/updater-migration/tests/update.rs b/plugins/updater/tests/updater-migration/tests/update.rs new file mode 100644 index 00000000..813da3c6 --- /dev/null +++ b/plugins/updater/tests/updater-migration/tests/update.rs @@ -0,0 +1,469 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +#![allow(dead_code, unused_imports)] + +use std::{ + collections::HashMap, + fs::File, + path::{Path, PathBuf}, + process::Command, + sync::Arc, +}; + +use serde::Serialize; +use tauri::utils::config::{Updater, V1Compatible}; + +const UPDATER_PRIVATE_KEY: &str = "dW50cnVzdGVkIGNvbW1lbnQ6IHJzaWduIGVuY3J5cHRlZCBzZWNyZXQga2V5ClJXUlRZMEl5TlFOMFpXYzJFOUdjeHJEVXY4WE1TMUxGNDJVUjNrMmk1WlR3UVJVUWwva0FBQkFBQUFBQUFBQUFBQUlBQUFBQUpVK3ZkM3R3eWhyN3hiUXhQb2hvWFVzUW9FbEs3NlNWYjVkK1F2VGFRU1FEaGxuRUtlell5U0gxYS9DbVRrS0YyZVJGblhjeXJibmpZeGJjS0ZKSUYwYndYc2FCNXpHalM3MHcrODMwN3kwUG9SOWpFNVhCSUd6L0E4TGRUT096TEtLR1JwT1JEVFU9Cg=="; +const UPDATED_EXIT_CODE: i32 = 0; +const UP_TO_DATE_EXIT_CODE: i32 = 2; + +fn npm_command() -> Command { + #[cfg(target_os = "windows")] + let cmd = { + let mut cmd = Command::new("cmd"); + cmd.arg("/c").arg("npm"); + cmd + }; + #[cfg(not(target_os = "windows"))] + let cmd = Command::new("npm"); + cmd +} + +mod v1 { + use super::{npm_command, BundleTarget, UPDATER_PRIVATE_KEY}; + use serde::Serialize; + use std::{ + path::{Path, PathBuf}, + process::Command, + }; + + #[derive(Serialize)] + pub struct PackageConfig { + pub version: &'static str, + } + + #[derive(Serialize)] + pub struct Config { + pub package: PackageConfig, + } + + pub fn build_app(cwd: &Path, config: &Config, bundle_updater: bool, target: BundleTarget) { + let mut command = npm_command(); + command + .args(["run", "tauri", "--", "build", "--debug", "--verbose"]) + .arg("--config") + .arg(serde_json::to_string(config).unwrap()) + .env("TAURI_PRIVATE_KEY", UPDATER_PRIVATE_KEY) + .env("TAURI_KEY_PASSWORD", "") + .current_dir(cwd); + + #[cfg(target_os = "linux")] + command.args(["--bundles", target.name()]); + #[cfg(target_os = "macos")] + command.args(["--bundles", target.name()]); + + if bundle_updater { + #[cfg(windows)] + command.args(["--bundles", "msi", "nsis"]); + } else { + #[cfg(windows)] + command.args(["--bundles", target.name()]); + } + + let status = command + .status() + .expect("failed to run Tauri CLI to bundle v1 app"); + + if !status.success() { + panic!("failed to bundle v1 app {:?}", status.code()); + } + } + + #[cfg(target_os = "linux")] + pub fn bundle_paths(root_dir: &Path, version: &str) -> Vec<(BundleTarget, PathBuf)> { + vec![( + BundleTarget::AppImage, + root_dir.join(format!( + "target/debug/bundle/appimage/app-updater-v1_{version}_amd64.AppImage", + )), + )] + } + + #[cfg(target_os = "macos")] + pub fn bundle_paths(root_dir: &Path, _version: &str) -> Vec<(BundleTarget, PathBuf)> { + vec![( + BundleTarget::App, + root_dir.join("target/debug/bundle/macos/app-updater-v1.app"), + )] + } + + #[cfg(target_os = "ios")] + pub fn bundle_paths(root_dir: &Path, _version: &str) -> Vec<(BundleTarget, PathBuf)> { + vec![( + BundleTarget::App, + root_dir.join("target/debug/bundle/ios/app-updater-v1.ipa"), + )] + } + + #[cfg(target_os = "android")] + pub fn bundle_path(root_dir: &Path, _version: &str) -> PathBuf { + root_dir.join("target/debug/bundle/android/app-updater-v1.apk") + } + + #[cfg(windows)] + pub fn bundle_paths(root_dir: &Path, version: &str) -> Vec<(BundleTarget, PathBuf)> { + vec![ + ( + BundleTarget::Nsis, + root_dir.join(format!( + "target/debug/bundle/nsis/app-updater-v1_{version}_x64-setup.exe" + )), + ), + ( + BundleTarget::Msi, + root_dir.join(format!( + "target/debug/bundle/msi/app-updater-v1_{version}_x64_en-US.msi" + )), + ), + ] + } +} + +mod v2 { + + use super::{BundleTarget, UPDATER_PRIVATE_KEY}; + use serde::Serialize; + use std::{ + path::{Path, PathBuf}, + process::Command, + }; + use tauri::utils::config::Updater; + + #[derive(Serialize)] + pub struct Config { + pub version: &'static str, + pub bundle: BundleConfig, + } + + #[derive(Serialize)] + #[serde(rename_all = "camelCase")] + pub struct BundleConfig { + pub create_updater_artifacts: Updater, + } + + pub fn build_app(cwd: &Path, config: &Config, bundle_updater: bool, target: BundleTarget) { + let mut command = Command::new("cargo"); + command + .args(["tauri", "build", "--debug", "--verbose"]) + .arg("--config") + .arg(serde_json::to_string(config).unwrap()) + .env("TAURI_SIGNING_PRIVATE_KEY", UPDATER_PRIVATE_KEY) + .env("TAURI_SIGNING_PRIVATE_KEY_PASSWORD", "") + .current_dir(cwd); + + #[cfg(target_os = "linux")] + command.args(["--bundles", target.name()]); + #[cfg(target_os = "macos")] + command.args(["--bundles", target.name()]); + + if bundle_updater { + #[cfg(windows)] + command.args(["--bundles", "msi", "nsis"]); + } else { + #[cfg(windows)] + command.args(["--bundles", target.name()]); + } + + let status = command + .status() + .expect("failed to run Tauri CLI to bundle v2 app"); + + if !status.success() { + panic!("failed to bundle v2 app {:?}", status.code()); + } + } + + #[cfg(target_os = "linux")] + pub fn bundle_paths(root_dir: &Path, version: &str) -> Vec<(BundleTarget, PathBuf)> { + vec![( + BundleTarget::AppImage, + root_dir.join(format!( + "target/debug/bundle/appimage/app-updater-v2_{version}_amd64.AppImage", + )), + )] + } + + #[cfg(target_os = "macos")] + pub fn bundle_paths(root_dir: &Path, _version: &str) -> Vec<(BundleTarget, PathBuf)> { + vec![( + BundleTarget::App, + root_dir.join("target/debug/bundle/macos/app-updater-v2.app"), + )] + } + + #[cfg(target_os = "ios")] + pub fn bundle_paths(root_dir: &Path, _version: &str) -> Vec<(BundleTarget, PathBuf)> { + vec![( + BundleTarget::App, + root_dir.join("target/debug/bundle/ios/app-updater-v2.ipa"), + )] + } + + #[cfg(target_os = "android")] + pub fn bundle_path(root_dir: &Path, _version: &str) -> PathBuf { + root_dir.join("target/debug/bundle/android/app-updater-v2.apk") + } + + #[cfg(windows)] + pub fn bundle_paths(root_dir: &Path, version: &str) -> Vec<(BundleTarget, PathBuf)> { + vec![ + ( + BundleTarget::Nsis, + root_dir.join(format!( + "target/debug/bundle/nsis/app-updater-v2_{version}_x64-setup.exe" + )), + ), + ( + BundleTarget::Msi, + root_dir.join(format!( + "target/debug/bundle/msi/app-updater-v2_{version}_x64_en-US.msi" + )), + ), + ] + } +} + +#[derive(Serialize)] +struct PlatformUpdate { + signature: String, + url: &'static str, + with_elevated_task: bool, +} + +#[derive(Serialize)] +struct Update { + version: &'static str, + date: String, + platforms: HashMap, +} + +#[derive(Copy, Clone)] +enum BundleTarget { + AppImage, + + App, + + Msi, + Nsis, +} + +impl BundleTarget { + fn name(self) -> &'static str { + match self { + Self::AppImage => "appimage", + Self::App => "app", + Self::Msi => "msi", + Self::Nsis => "nsis", + } + } +} + +impl Default for BundleTarget { + fn default() -> Self { + #[cfg(any(target_os = "macos", target_os = "ios"))] + return Self::App; + #[cfg(target_os = "linux")] + return Self::AppImage; + #[cfg(windows)] + return Self::Nsis; + } +} + +#[test] +#[ignore] +fn update_app() { + let target = + tauri_plugin_updater::target().expect("running updater test in an unsupported platform"); + let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")); + let root_dir = manifest_dir.join("../../../.."); + let v1_root_dir = manifest_dir.join("v1-app"); + let v2_root_dir = manifest_dir.join("v2-app"); + + let status = npm_command() + .arg("install") + .current_dir(&v1_root_dir) + .status() + .expect("failed to run npm install"); + if !status.success() { + panic!("failed to run npm install"); + } + + let v2_config = v2::Config { + version: "1.0.0", + bundle: v2::BundleConfig { + create_updater_artifacts: Updater::String(V1Compatible::V1Compatible), + }, + }; + + // bundle app update (v2) + v2::build_app(&v2_root_dir, &v2_config, true, Default::default()); + + let updater_zip_ext = if cfg!(windows) { "zip" } else { "tar.gz" }; + + for (bundle_target, out_bundle_path) in v2::bundle_paths(&root_dir, "1.0.0") { + let bundle_updater_ext = out_bundle_path + .extension() + .unwrap() + .to_str() + .unwrap() + .replace("exe", "nsis"); + let updater_extension = format!("{bundle_updater_ext}.{updater_zip_ext}"); + let signature_extension = format!("{updater_extension}.sig"); + let signature_path = out_bundle_path.with_extension(signature_extension); + let signature = std::fs::read_to_string(&signature_path).unwrap_or_else(|_| { + panic!("failed to read signature file {}", signature_path.display()) + }); + let out_updater_path = out_bundle_path.with_extension(updater_extension); + let updater_path = root_dir.join(format!( + "target/debug/{}", + out_updater_path.file_name().unwrap().to_str().unwrap() + )); + std::fs::rename(&out_updater_path, &updater_path).expect("failed to rename bundle"); + + let target = target.clone(); + + // start the updater server + let server = Arc::new( + tiny_http::Server::http("localhost:3007").expect("failed to start updater server"), + ); + + let server_ = server.clone(); + std::thread::spawn(move || { + for request in server_.incoming_requests() { + match request.url() { + "/" => { + let mut platforms = HashMap::new(); + + platforms.insert( + target.clone(), + PlatformUpdate { + signature: signature.clone(), + url: "http://localhost:3007/download", + with_elevated_task: false, + }, + ); + let body = serde_json::to_vec(&Update { + version: "1.0.0", + date: time::OffsetDateTime::now_utc() + .format(&time::format_description::well_known::Rfc3339) + .unwrap(), + platforms, + }) + .unwrap(); + let len = body.len(); + let response = tiny_http::Response::new( + tiny_http::StatusCode(200), + Vec::new(), + std::io::Cursor::new(body), + Some(len), + None, + ); + let _ = request.respond(response); + } + "/download" => { + let _ = request.respond(tiny_http::Response::from_file( + File::open(&updater_path).unwrap_or_else(|_| { + panic!("failed to open updater bundle {}", updater_path.display()) + }), + )); + } + _ => (), + } + } + }); + + let v1_config = v1::Config { + package: v1::PackageConfig { version: "0.1.0" }, + }; + + // bundle initial app version (tauri v1) + v1::build_app(&v1_root_dir, &v1_config, false, bundle_target); + + let status_checks = if matches!(bundle_target, BundleTarget::Msi) { + // for msi we can't really check if the app was updated, because we can't change the install path + vec![(UPDATED_EXIT_CODE, 1)] + } else { + vec![(UPDATED_EXIT_CODE, 1), (UP_TO_DATE_EXIT_CODE, 2)] + }; + + for (expected_exit_code, expected_tauri_version) in status_checks { + let (expected_app_version, bundle_paths_fn, app_name_suffix) = + match expected_tauri_version { + 1 => ( + v1_config.package.version, + Box::new(|| v1::bundle_paths(&v1_root_dir, v1_config.package.version)) + as Box Vec<(BundleTarget, PathBuf)>>, + "-v1", + ), + 2 => ( + v2_config.version, + Box::new(|| v2::bundle_paths(&root_dir, v2_config.version)) + as Box Vec<(BundleTarget, PathBuf)>>, + "-v2", + ), + _ => panic!("unknown tauri version"), + }; + let mut binary_cmd = if cfg!(windows) { + let app_root_dir = match expected_tauri_version { + 1 => &v1_root_dir, + 2 => &root_dir, + _ => panic!("unknown tauri version"), + }; + Command::new( + app_root_dir.join(format!("target/debug/app-updater{app_name_suffix}.exe")), + ) + } else if cfg!(target_os = "macos") { + Command::new( + bundle_paths_fn() + .first() + .unwrap() + .1 + .join(format!("Contents/MacOS/app-updater{app_name_suffix}")), + ) + } else if std::env::var("CI").map(|v| v == "true").unwrap_or_default() { + let mut c = Command::new("xvfb-run"); + c.arg("--auto-servernum") + .arg(&bundle_paths_fn().first().unwrap().1); + c + } else { + Command::new(&bundle_paths_fn().first().unwrap().1) + }; + + binary_cmd.env("TARGET", bundle_target.name()); + + let output = binary_cmd.output().expect("failed to run app"); + let stdout = String::from_utf8_lossy(&output.stdout); + + println!("{stdout}"); + eprintln!("{}", String::from_utf8_lossy(&output.stderr)); + + let code = output.status.code().unwrap_or(-1); + + if code != expected_exit_code { + panic!("failed to run app, expected exit code {expected_exit_code}, got {code}"); + } + if !stdout.contains(&format!("version={expected_app_version}")) { + panic!("app version does not match {expected_app_version}"); + } + #[cfg(windows)] + if code == UPDATED_EXIT_CODE { + // wait for the update to finish + std::thread::sleep(std::time::Duration::from_secs(5)); + } + } + + server.unblock(); + } +} diff --git a/plugins/updater/tests/updater-migration/v1-app/.gitignore b/plugins/updater/tests/updater-migration/v1-app/.gitignore new file mode 100644 index 00000000..c6bfc74f --- /dev/null +++ b/plugins/updater/tests/updater-migration/v1-app/.gitignore @@ -0,0 +1,3 @@ +target/ +package-lock.json +node_modules/ \ No newline at end of file diff --git a/plugins/deep-link/examples/app/src-tauri/Cargo.lock b/plugins/updater/tests/updater-migration/v1-app/Cargo.lock similarity index 64% rename from plugins/deep-link/examples/app/src-tauri/Cargo.lock rename to plugins/updater/tests/updater-migration/v1-app/Cargo.lock index 1d80153f..034449e3 100644 --- a/plugins/deep-link/examples/app/src-tauri/Cargo.lock +++ b/plugins/updater/tests/updater-migration/v1-app/Cargo.lock @@ -1,12 +1,12 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" -version = "0.20.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" dependencies = [ "gimli", ] @@ -19,9 +19,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aho-corasick" -version = "1.0.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] @@ -58,173 +58,62 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.71" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" - -[[package]] -name = "async-broadcast" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c48ccdbf6ca6b121e0f586cbc0e73ae440e56c67c30fa0873b4e110d9c26d2b" -dependencies = [ - "event-listener", - "futures-core", -] - -[[package]] -name = "async-channel" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" -dependencies = [ - "concurrent-queue", - "event-listener", - "futures-core", -] - -[[package]] -name = "async-executor" -version = "1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fa3dc5f2a8564f07759c008b9109dc0d39de92a88d5588b8a5036d286383afb" -dependencies = [ - "async-lock", - "async-task", - "concurrent-queue", - "fastrand", - "futures-lite", - "slab", -] - -[[package]] -name = "async-fs" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "279cf904654eeebfa37ac9bb1598880884924aab82e290aa65c9e77a0e142e06" -dependencies = [ - "async-lock", - "autocfg", - "blocking", - "futures-lite", -] - -[[package]] -name = "async-io" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" -dependencies = [ - "async-lock", - "autocfg", - "cfg-if", - "concurrent-queue", - "futures-lite", - "log", - "parking", - "polling", - "rustix", - "slab", - "socket2", - "waker-fn", -] - -[[package]] -name = "async-lock" -version = "2.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa24f727524730b077666307f2734b4a1a1c57acb79193127dcc8914d5242dd7" -dependencies = [ - "event-listener", -] - -[[package]] -name = "async-process" -version = "1.7.0" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a9d28b1d97e08915212e2e45310d47854eafa69600756fc735fb788f75199c9" -dependencies = [ - "async-io", - "async-lock", - "autocfg", - "blocking", - "cfg-if", - "event-listener", - "futures-lite", - "rustix", - "signal-hook", - "windows-sys", -] +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" [[package]] -name = "async-recursion" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e97ce7de6cf12de5d7226c73f5ba9811622f4db3a5b91b55c53e987e5f91cba" +name = "app-updater-v1" +version = "0.1.0" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.25", + "serde", + "serde_json", + "tauri", + "tauri-build", + "tiny_http", ] [[package]] -name = "async-task" -version = "4.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc7ab41815b3c653ccd2978ec3255c81349336702dfdf62ee6f7069b12a3aae" - -[[package]] -name = "async-trait" -version = "0.1.71" +name = "ascii" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a564d521dd56509c4c47480d00b80ee55f7e385ae48db5744c67ad50c92d2ebf" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.25", -] +checksum = "d92bec98840b8f03a5ff5413de5293bfcd8bf96467cf5452609f939ec6f5de16" [[package]] name = "atk" -version = "0.16.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39991bc421ddf72f70159011b323ff49b0f783cc676a7287c59453da2e2531cf" +checksum = "2c3d816ce6f0e2909a96830d6911c2aff044370b1ef92d7f267b43bae5addedd" dependencies = [ "atk-sys", - "bitflags", + "bitflags 1.3.2", "glib", "libc", ] [[package]] name = "atk-sys" -version = "0.16.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11ad703eb64dc058024f0e57ccfa069e15a413b98dbd50a1a950e743b7f11148" +checksum = "58aeb089fb698e06db8089971c7ee317ab9644bade33383f63631437b03aafb6" dependencies = [ "glib-sys", "gobject-sys", "libc", - "system-deps", + "system-deps 6.2.2", ] -[[package]] -name = "atomic-waker" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1181e1e0d1fce796a03db1ae795d67167da795f9cf4a39c37589e85ef57f26d3" - [[package]] name = "autocfg" -version = "1.1.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "backtrace" -version = "0.3.68" +version = "0.3.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" dependencies = [ "addr2line", "cc", @@ -237,9 +126,21 @@ dependencies = [ [[package]] name = "base64" -version = "0.21.2" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "base64" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bitflags" @@ -247,6 +148,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + [[package]] name = "block" version = "0.1.6" @@ -262,26 +169,11 @@ dependencies = [ "generic-array", ] -[[package]] -name = "blocking" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77231a1c8f801696fc0123ec6150ce92cffb8e164a02afb9c8ddee0e9b65ad65" -dependencies = [ - "async-channel", - "async-lock", - "async-task", - "atomic-waker", - "fastrand", - "futures-lite", - "log", -] - [[package]] name = "brotli" -version = "3.3.4" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1a0b1dbcc8ae29329621f8d4f0d835787c1c38bb1401979b49d13b0b305ff68" +checksum = "d640d25bc63c50fb1f0b545ffd80207d2e10a4c965530809b40ba3386825c391" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -290,64 +182,73 @@ dependencies = [ [[package]] name = "brotli-decompressor" -version = "2.3.4" +version = "2.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b6561fd3f895a11e8f72af2cb7d22e08366bebc2b6b57f7744c4bda27034744" +checksum = "4e2e4afe60d7dd600fdd3de8d0f08c2b7ec039712e3b6137ff98b7004e82de4f" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", ] +[[package]] +name = "bstr" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40723b8fb387abc38f4f4a37c09073622e41dd12327033091ef8950659e6dc0c" +dependencies = [ + "memchr", + "serde", +] + [[package]] name = "bumpalo" -version = "3.13.0" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bytemuck" -version = "1.13.1" +version = "1.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea" +checksum = "102087e286b4677862ea56cf8fc58bb2cdfa8725c40ffb80fe3a008eb7f2fc83" [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.4.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" dependencies = [ "serde", ] [[package]] name = "cairo-rs" -version = "0.16.7" +version = "0.15.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3125b15ec28b84c238f6f476c6034016a5f6cc0221cb514ca46c532139fc97d" +checksum = "c76ee391b03d35510d9fa917357c7f1855bd9a6659c95a1b392e33f49b3369bc" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cairo-sys-rs", "glib", "libc", - "once_cell", "thiserror", ] [[package]] name = "cairo-sys-rs" -version = "0.16.3" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c48f4af05fabdcfa9658178e1326efa061853f040ce7d72e33af6885196f421" +checksum = "3c55d429bef56ac9172d25fecb85dc8068307d17acd74b377866b7a1ef25d3c8" dependencies = [ "glib-sys", "libc", - "system-deps", + "system-deps 6.2.2", ] [[package]] @@ -357,14 +258,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "599aa35200ffff8f04c1925aa1acc92fa2e08874379ef42e210a80e527e60838" dependencies = [ "serde", - "toml", + "toml 0.7.8", ] [[package]] name = "cc" -version = "1.0.79" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "504bdec147f2cc13c8b57ed9401fd8a147cc66b67ad5cb241394244f2c947549" [[package]] name = "cesu8" @@ -385,9 +286,18 @@ dependencies = [ [[package]] name = "cfg-expr" -version = "0.15.3" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3431df59f28accaf4cb4eed4a9acc66bea3f3c3753aa6cdc2f024174ef232af7" +dependencies = [ + "smallvec", +] + +[[package]] +name = "cfg-expr" +version = "0.15.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "215c0072ecc28f92eeb0eea38ba63ddfcb65c2828c46311d646f1a3ff5f9841c" +checksum = "d067ad48b8650848b989a59a86c6c36a995d02d2bf778d45c3c5d57bc2718f02" dependencies = [ "smallvec", "target-lexicon", @@ -401,24 +311,30 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.26" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ "android-tzdata", "iana-time-zone", "num-traits", "serde", - "winapi", + "windows-targets 0.52.6", ] +[[package]] +name = "chunked_transfer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e4de3bc4ea267985becf712dc6d9eed8b04c953b3fcfb339ebc87acd9804901" + [[package]] name = "cocoa" version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f425db7937052c684daec3bd6375c8abe2d146dca4b8b143d6db777c39138f3a" dependencies = [ - "bitflags", + "bitflags 1.3.2", "block", "cocoa-foundation", "core-foundation", @@ -430,15 +346,14 @@ dependencies = [ [[package]] name = "cocoa-foundation" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "931d3837c286f56e3c58423ce4eba12d08db2374461a785c86f672b08b5650d6" +checksum = "8c6234cbb2e4c785b456c0644748b1ac416dd045799740356f8363dfe00c93f7" dependencies = [ - "bitflags", + "bitflags 1.3.2", "block", "core-foundation", "core-graphics-types", - "foreign-types", "libc", "objc", ] @@ -451,23 +366,14 @@ checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" [[package]] name = "combine" -version = "4.6.6" +version = "4.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4" +checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd" dependencies = [ "bytes", "memchr", ] -[[package]] -name = "concurrent-queue" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62ec6771ecfa0762d24683ee5a32ad78487a3d3afdc0fb8cae19d2c5deb50b7c" -dependencies = [ - "crossbeam-utils", -] - [[package]] name = "convert_case" version = "0.4.0" @@ -476,9 +382,9 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" [[package]] name = "core-foundation" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" dependencies = [ "core-foundation-sys", "libc", @@ -486,9 +392,9 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.4" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "core-graphics" @@ -496,7 +402,7 @@ version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "core-graphics-types", "foreign-types", @@ -505,52 +411,67 @@ dependencies = [ [[package]] name = "core-graphics-types" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bb142d41022986c1d8ff29103a1411c8a3dfad3552f87a4f8dc50d61d4f4e33" +checksum = "45390e6114f68f718cc7a830514a96f903cccd70d02a8f6d9f643ac4ba45afaf" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "libc", ] [[package]] name = "cpufeatures" -version = "0.2.9" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ "libc", ] [[package]] name = "crc32fast" -version = "1.3.2" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" dependencies = [ "cfg-if", ] [[package]] name = "crossbeam-channel" -version = "0.5.8" +version = "0.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" +checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2" dependencies = [ - "cfg-if", "crossbeam-utils", ] [[package]] -name = "crossbeam-utils" -version = "0.8.16" +name = "crossbeam-deque" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" dependencies = [ - "cfg-if", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", ] +[[package]] +name = "crossbeam-utils" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" + [[package]] name = "crypto-common" version = "0.1.6" @@ -585,24 +506,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331" dependencies = [ "quote", - "syn 2.0.25", + "syn 2.0.72", ] [[package]] name = "ctor" -version = "0.1.26" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096" +checksum = "edb49164822f3ee45b17acd4a208cfc1251410cf0cad9a833234c9890774dd9f" dependencies = [ "quote", - "syn 1.0.109", + "syn 2.0.72", ] [[package]] name = "darling" -version = "0.20.1" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0558d22a7b463ed0241e993f76f09f30b126687447751a8638587b864e4b3944" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" dependencies = [ "darling_core", "darling_macro", @@ -610,62 +531,50 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.1" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab8bfa2e259f8ee1ce5e97824a3c55ec4404a0d772ca7fa96bf19f0752a046eb" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", "strsim", - "syn 2.0.25", + "syn 2.0.72", ] [[package]] name = "darling_macro" -version = "0.20.1" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29a358ff9f12ec09c3e61fef9b5a9902623a695a46a917b07f269bff1445611a" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.25", -] - -[[package]] -name = "deep-link-example" -version = "0.0.0" -dependencies = [ - "serde", - "serde_json", - "tauri", - "tauri-build", - "tauri-plugin-deep-link", + "syn 2.0.72", ] [[package]] -name = "derivative" -version = "2.2.0" +name = "deranged" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", + "powerfmt", + "serde", ] [[package]] name = "derive_more" -version = "0.99.17" +version = "0.99.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" dependencies = [ "convert_case", "proc-macro2", "quote", "rustc_version", - "syn 1.0.109", + "syn 2.0.72", ] [[package]] @@ -707,36 +616,37 @@ checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b" [[package]] name = "dtoa" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "519b83cd10f5f6e969625a409f735182bea5558cd8b64c655806ceaae36f1999" +checksum = "dcbb2bf8e87535c23f7a8a321e364ce21462d0ff10cb6407820e8e96dfff6653" [[package]] name = "dtoa-short" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbaceec3c6e4211c79e7b1800fb9680527106beb2f9c51904a3210c03a448c74" +checksum = "cd1511a7b6a56299bd043a9c167a6d2bfb37bf84a6dfceaba651168adfb43c87" dependencies = [ "dtoa", ] [[package]] name = "dunce" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" [[package]] name = "embed-resource" -version = "2.2.0" +version = "2.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7f1e82a60222fc67bfd50d752a9c89da5cce4c39ed39decc84a443b07bbd69a" +checksum = "4edcacde9351c33139a41e3c97eb2334351a81a2791bebb0b243df837128f602" dependencies = [ "cc", + "memchr", "rustc_version", - "toml", + "toml 0.8.19", "vswhom", - "winreg 0.11.0", + "winreg 0.52.0", ] [[package]] @@ -747,34 +657,13 @@ checksum = "4ef6b89e5b37196644d8796de5268852ff179b44e96276cf4290264843743bb7" [[package]] name = "encoding_rs" -version = "0.8.32" +version = "0.8.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" dependencies = [ "cfg-if", ] -[[package]] -name = "enumflags2" -version = "0.7.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c041f5090df68b32bcd905365fd51769c8b9d553fe87fde0b683534f10c01bd2" -dependencies = [ - "enumflags2_derive", - "serde", -] - -[[package]] -name = "enumflags2_derive" -version = "0.7.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e9a1f9f7d83e59740248a6e14ecf93929ade55027844dfcea78beafccc15745" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.25", -] - [[package]] name = "equivalent" version = "1.0.1" @@ -783,45 +672,25 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" -dependencies = [ - "errno-dragonfly", - "libc", - "windows-sys", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.2" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ - "cc", "libc", + "windows-sys 0.52.0", ] -[[package]] -name = "event-listener" -version = "2.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" - [[package]] name = "fastrand" -version = "1.9.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" -dependencies = [ - "instant", -] +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" [[package]] name = "fdeflate" -version = "0.3.0" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d329bdeac514ee06249dabc27877490f17f5d371ec693360768b838e19f3ae10" +checksum = "4f9bfee30e4dedf0ab8b422f03af778d9612b63f502710fc500a334ebe2de645" dependencies = [ "simd-adler32", ] @@ -832,15 +701,27 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38e2275cc4e4fc009b0669731a1e5ab7ebf11f469eaede2bab9309a5b4d6057f" dependencies = [ - "memoffset 0.9.0", + "memoffset", "rustc_version", ] +[[package]] +name = "filetime" +version = "0.2.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.4.1", + "windows-sys 0.52.0", +] + [[package]] name = "flate2" -version = "1.0.26" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" +checksum = "7f211bbe8e69bbd0cfdea405084f128ae8b4aaa6b0b522fc8f2b009084797920" dependencies = [ "crc32fast", "miniz_oxide", @@ -869,9 +750,9 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "form_urlencoded" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] @@ -888,24 +769,24 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", ] [[package]] name = "futures-core" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-executor" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" dependencies = [ "futures-core", "futures-task", @@ -914,53 +795,38 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" - -[[package]] -name = "futures-lite" -version = "1.13.0" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" -dependencies = [ - "fastrand", - "futures-core", - "futures-io", - "memchr", - "parking", - "pin-project-lite", - "waker-fn", -] +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-macro" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.72", ] [[package]] name = "futures-sink" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] name = "futures-task" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-util" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-core", "futures-io", @@ -984,11 +850,11 @@ dependencies = [ [[package]] name = "gdk" -version = "0.16.2" +version = "0.15.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa9cb33da481c6c040404a11f8212d193889e9b435db2c14fd86987f630d3ce1" +checksum = "a6e05c1f572ab0e1f15be94217f0dc29088c248b14f792a5ff0af0d84bcda9e8" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cairo-rs", "gdk-pixbuf", "gdk-sys", @@ -1000,11 +866,11 @@ dependencies = [ [[package]] name = "gdk-pixbuf" -version = "0.16.7" +version = "0.15.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3578c60dee9d029ad86593ed88cb40f35c1b83360e12498d055022385dd9a05" +checksum = "ad38dd9cc8b099cceecdf41375bb6d481b1b5a7cd5cd603e10a69a9383f8619a" dependencies = [ - "bitflags", + "bitflags 1.3.2", "gdk-pixbuf-sys", "gio", "glib", @@ -1013,22 +879,22 @@ dependencies = [ [[package]] name = "gdk-pixbuf-sys" -version = "0.16.3" +version = "0.15.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3092cf797a5f1210479ea38070d9ae8a5b8e9f8f1be9f32f4643c529c7d70016" +checksum = "140b2f5378256527150350a8346dbdb08fadc13453a7a2d73aecd5fab3c402a7" dependencies = [ "gio-sys", "glib-sys", "gobject-sys", "libc", - "system-deps", + "system-deps 6.2.2", ] [[package]] name = "gdk-sys" -version = "0.16.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d76354f97a913e55b984759a997b693aa7dc71068c9e98bcce51aa167a0a5c5a" +checksum = "32e7a08c1e8f06f4177fb7e51a777b8c1689f743a7bc11ea91d44d2226073a88" dependencies = [ "cairo-sys-rs", "gdk-pixbuf-sys", @@ -1038,33 +904,33 @@ dependencies = [ "libc", "pango-sys", "pkg-config", - "system-deps", + "system-deps 6.2.2", ] [[package]] name = "gdkwayland-sys" -version = "0.16.0" +version = "0.15.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4511710212ed3020b61a8622a37aa6f0dd2a84516575da92e9b96928dcbe83ba" +checksum = "cca49a59ad8cfdf36ef7330fe7bdfbe1d34323220cc16a0de2679ee773aee2c2" dependencies = [ "gdk-sys", "glib-sys", "gobject-sys", "libc", "pkg-config", - "system-deps", + "system-deps 6.2.2", ] [[package]] name = "gdkx11-sys" -version = "0.16.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fa2bf8b5b8c414bc5d05e48b271896d0fd3ddb57464a3108438082da61de6af" +checksum = "b4b7f8c7a84b407aa9b143877e267e848ff34106578b64d1e0a24bf550716178" dependencies = [ "gdk-sys", "glib-sys", "libc", - "system-deps", + "system-deps 6.2.2", "x11", ] @@ -1078,7 +944,7 @@ dependencies = [ "libc", "log", "rustversion", - "windows", + "windows 0.48.0", ] [[package]] @@ -1104,9 +970,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", @@ -1115,56 +981,51 @@ dependencies = [ [[package]] name = "gimli" -version = "0.27.3" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" [[package]] name = "gio" -version = "0.16.7" +version = "0.15.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a1c84b4534a290a29160ef5c6eff2a9c95833111472e824fc5cb78b513dd092" +checksum = "68fdbc90312d462781a395f7a16d96a2b379bb6ef8cd6310a2df272771c4283b" dependencies = [ - "bitflags", + "bitflags 1.3.2", "futures-channel", "futures-core", "futures-io", - "futures-util", "gio-sys", "glib", "libc", "once_cell", - "pin-project-lite", - "smallvec", "thiserror", ] [[package]] name = "gio-sys" -version = "0.16.3" +version = "0.15.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9b693b8e39d042a95547fc258a7b07349b1f0b48f4b2fa3108ba3c51c0b5229" +checksum = "32157a475271e2c4a023382e9cab31c4584ee30a97da41d3c4e9fdd605abcf8d" dependencies = [ "glib-sys", "gobject-sys", "libc", - "system-deps", + "system-deps 6.2.2", "winapi", ] [[package]] name = "glib" -version = "0.16.9" +version = "0.15.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16aa2475c9debed5a32832cb5ff2af5a3f9e1ab9e69df58eaadc1ab2004d6eba" +checksum = "edb0306fbad0ab5428b0ca674a23893db909a98582969c9b537be4ced78c505d" dependencies = [ - "bitflags", + "bitflags 1.3.2", "futures-channel", "futures-core", "futures-executor", "futures-task", - "futures-util", - "gio-sys", "glib-macros", "glib-sys", "gobject-sys", @@ -1176,12 +1037,12 @@ dependencies = [ [[package]] name = "glib-macros" -version = "0.16.8" +version = "0.15.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb1a9325847aa46f1e96ffea37611b9d51fc4827e67f79e7de502a297560a67b" +checksum = "10c6ae9f6fa26f4fb2ac16b528d138d971ead56141de489f8111e259b9df3c4a" dependencies = [ "anyhow", - "heck", + "heck 0.4.1", "proc-macro-crate", "proc-macro-error", "proc-macro2", @@ -1191,12 +1052,12 @@ dependencies = [ [[package]] name = "glib-sys" -version = "0.16.3" +version = "0.15.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61a4f46316d06bfa33a7ac22df6f0524c8be58e3db2d9ca99ccb1f357b62a65" +checksum = "ef4b192f8e65e9cf76cbf4ea71fa8e3be4a0e18ffe3d68b8da6836974cc5bad4" dependencies = [ "libc", - "system-deps", + "system-deps 6.2.2", ] [[package]] @@ -1205,25 +1066,38 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +[[package]] +name = "globset" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1" +dependencies = [ + "aho-corasick", + "bstr", + "log", + "regex-automata 0.4.7", + "regex-syntax 0.8.4", +] + [[package]] name = "gobject-sys" -version = "0.16.3" +version = "0.15.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3520bb9c07ae2a12c7f2fbb24d4efc11231c8146a86956413fb1a79bb760a0f1" +checksum = "0d57ce44246becd17153bd035ab4d32cfee096a657fc01f2231c9278378d1e0a" dependencies = [ "glib-sys", "libc", - "system-deps", + "system-deps 6.2.2", ] [[package]] name = "gtk" -version = "0.16.2" +version = "0.15.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4d3507d43908c866c805f74c9dd593c0ce7ba5c38e576e41846639cdcd4bee6" +checksum = "92e3004a2d5d6d8b5057d2b57b3712c9529b62e82c77f25c1fecde1fd5c23bd0" dependencies = [ "atk", - "bitflags", + "bitflags 1.3.2", "cairo-rs", "field-offset", "futures-channel", @@ -1241,9 +1115,9 @@ dependencies = [ [[package]] name = "gtk-sys" -version = "0.16.0" +version = "0.15.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b5f8946685d5fe44497007786600c2f368ff6b1e61a16251c89f72a97520a3" +checksum = "d5bc2f0587cba247f60246a0ca11fe25fb733eabc3de12d1965fc07efab87c84" dependencies = [ "atk-sys", "cairo-sys-rs", @@ -1254,14 +1128,14 @@ dependencies = [ "gobject-sys", "libc", "pango-sys", - "system-deps", + "system-deps 6.2.2", ] [[package]] name = "gtk3-macros" -version = "0.16.3" +version = "0.15.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "096eb63c6fedf03bafe65e5924595785eaf1bcb7200dac0f2cbe9c9738f05ad8" +checksum = "684c0456c086e8e7e9af73ec5b84e35938df394712054550e81558d21c44ab0d" dependencies = [ "anyhow", "proc-macro-crate", @@ -1273,9 +1147,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.20" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97ec8491ebaf99c8eaa73058b045fe58073cd6be7f596ac993ced0b0a0c01049" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" dependencies = [ "bytes", "fnv", @@ -1283,7 +1157,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 1.9.3", + "indexmap 2.3.0", "slab", "tokio", "tokio-util", @@ -1298,9 +1172,18 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" -version = "0.14.0" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + +[[package]] +name = "heck" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] [[package]] name = "heck" @@ -1308,11 +1191,17 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "hermit-abi" -version = "0.3.2" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "hex" @@ -1320,20 +1209,6 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" -[[package]] -name = "html5ever" -version = "0.25.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5c13fb08e5d4dfc151ee5e88bae63f7773d61852f3bdc73c9f4b9e1bde03148" -dependencies = [ - "log", - "mac", - "markup5ever 0.10.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "html5ever" version = "0.26.0" @@ -1342,7 +1217,7 @@ checksum = "bea68cab48b8459f17cf1c944c67ddc572d272d9f2b274140f223ecb1da4a3b7" dependencies = [ "log", "mac", - "markup5ever 0.11.0", + "markup5ever", "proc-macro2", "quote", "syn 1.0.109", @@ -1350,20 +1225,20 @@ dependencies = [ [[package]] name = "http" -version = "0.2.9" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" dependencies = [ "bytes", "fnv", - "itoa 1.0.8", + "itoa 1.0.11", ] [[package]] name = "http-body" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", "http", @@ -1378,21 +1253,21 @@ checksum = "21dec9db110f5f872ed9699c3ecf50cf16f423502706ba5c72462e28d3157573" [[package]] name = "httparse" -version = "1.8.0" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" [[package]] name = "httpdate" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "0.14.27" +version = "0.14.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" +checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" dependencies = [ "bytes", "futures-channel", @@ -1403,7 +1278,7 @@ dependencies = [ "http-body", "httparse", "httpdate", - "itoa 1.0.8", + "itoa 1.0.11", "pin-project-lite", "socket2", "tokio", @@ -1412,18 +1287,31 @@ dependencies = [ "want", ] +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", +] + [[package]] name = "iana-time-zone" -version = "0.1.57" +version = "0.1.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows", + "windows-core", ] [[package]] @@ -1453,24 +1341,39 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", ] +[[package]] +name = "ignore" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b46810df39e66e925525d6e38ce1e7f6e1d208f72dc39757880fcb66e2c58af1" +dependencies = [ + "crossbeam-deque", + "globset", + "log", + "memchr", + "regex-automata 0.4.7", + "same-file", + "walkdir", + "winapi-util", +] + [[package]] name = "image" -version = "0.24.6" +version = "0.24.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "527909aa81e20ac3a44803521443a765550f09b5130c2c2fa1ea59c2f8f50a3a" +checksum = "5690139d2f55868e080017335e4b94cb7414274c74f1669c84fb5feba2c9f69d" dependencies = [ "bytemuck", "byteorder", "color_quant", - "num-rational", "num-traits", ] @@ -1487,48 +1390,38 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.0.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +checksum = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0" dependencies = [ "equivalent", - "hashbrown 0.14.0", + "hashbrown 0.14.5", + "serde", ] [[package]] name = "infer" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a898e4b7951673fce96614ce5751d13c40fc5674bc2d759288e46c3ab62598b3" +checksum = "f551f8c3a39f68f986517db0d1759de85881894fdc7db798bd2a9df9cb04b7fc" dependencies = [ "cfb", ] [[package]] name = "instant" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" dependencies = [ "cfg-if", ] -[[package]] -name = "io-lifetimes" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" -dependencies = [ - "hermit-abi", - "libc", - "windows-sys", -] - [[package]] name = "ipnet" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "itoa" @@ -1538,31 +1431,31 @@ checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" [[package]] name = "itoa" -version = "1.0.8" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b02a5381cc465bd3041d84623d0fa3b66738b52b8e2fc3bab8ad63ab032f4a" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "javascriptcore-rs" -version = "1.0.0" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cfcc681b896b083864a4a3c3b3ea196f14ff66b8641a68fde209c6d84434056" +checksum = "bf053e7843f2812ff03ef5afe34bb9c06ffee120385caad4f6b9967fcd37d41c" dependencies = [ - "bitflags", + "bitflags 1.3.2", "glib", "javascriptcore-rs-sys", ] [[package]] name = "javascriptcore-rs-sys" -version = "1.0.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0983ba5b3ab9a0c0918de02c42dc71f795d6de08092f88a98ce9fdfdee4ba91" +checksum = "905fbb87419c5cde6e3269537e4ea7d46431f3008c5d057e915ef3f115e7793c" dependencies = [ "glib-sys", "gobject-sys", "libc", - "system-deps", + "system-deps 5.0.0", ] [[package]] @@ -1587,35 +1480,22 @@ checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" [[package]] name = "js-sys" -version = "0.3.64" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" dependencies = [ "wasm-bindgen", ] [[package]] name = "json-patch" -version = "1.0.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f54898088ccb91df1b492cc80029a6fdf1c48ca0db7c6822a8babad69c94658" +checksum = "ec9ad60d674508f3ca8f380a928cfe7b096bc729c4e2dbfe3852bc45da3ab30b" dependencies = [ "serde", "serde_json", "thiserror", - "treediff", -] - -[[package]] -name = "kuchiki" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ea8e9c6e031377cff82ee3001dc8026cdf431ed4e2e6b51f98ab8c73484a358" -dependencies = [ - "cssparser", - "html5ever 0.25.2", - "matches", - "selectors", ] [[package]] @@ -1625,7 +1505,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f29e4755b7b995046f510a7520c42b2fed58b77bd94d5a87a8eb43d2fd126da8" dependencies = [ "cssparser", - "html5ever 0.26.0", + "html5ever", "indexmap 1.9.3", "matches", "selectors", @@ -1633,36 +1513,37 @@ dependencies = [ [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.147" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] -name = "line-wrap" -version = "0.1.1" +name = "libredox" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30344350a2a51da54c1d53be93fade8a237e545dbcc4bdbe635413f2117cab9" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "safemem", + "bitflags 2.6.0", + "libc", ] [[package]] name = "linux-raw-sys" -version = "0.3.8" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "lock_api" -version = "0.4.10" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", @@ -1670,9 +1551,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.19" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "loom" @@ -1704,20 +1585,6 @@ dependencies = [ "libc", ] -[[package]] -name = "markup5ever" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a24f40fb03852d1cdd84330cddcaf98e9ec08a7b7768e952fad3b4cf048ec8fd" -dependencies = [ - "log", - "phf 0.8.0", - "phf_codegen 0.8.0", - "string_cache", - "string_cache_codegen", - "tendril", -] - [[package]] name = "markup5ever" version = "0.11.0" @@ -1749,24 +1616,15 @@ checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" [[package]] name = "memchr" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" - -[[package]] -name = "memoffset" -version = "0.7.1" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" -dependencies = [ - "autocfg", -] +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "memoffset" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" dependencies = [ "autocfg", ] @@ -1777,11 +1635,17 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +[[package]] +name = "minisign-verify" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "933dca44d65cdd53b355d0b73d380a2ff5da71f87f036053188bf1eab6a19881" + [[package]] name = "miniz_oxide" -version = "0.7.1" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" dependencies = [ "adler", "simd-adler32", @@ -1789,26 +1653,43 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.8" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4" dependencies = [ + "hermit-abi", "libc", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "native-tls" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", ] [[package]] name = "ndk" -version = "0.7.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "451422b7e4718271c8b5b3aadf5adedba43dc76312454b387e98fae0fc951aa0" +checksum = "2032c77e030ddee34a6787a64166008da93f6a352b629261d0fee232b8742dd4" dependencies = [ - "bitflags", + "bitflags 1.3.2", "jni-sys", "ndk-sys", "num_enum", - "raw-window-handle", "thiserror", ] @@ -1820,31 +1701,18 @@ checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" [[package]] name = "ndk-sys" -version = "0.4.1+23.1.7779620" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cf2aae958bd232cac5069850591667ad422d263686d75b52a065f9badeee5a3" +checksum = "6e5a6ae77c8ee183dcbbba6150e2e6b9f3f4196a7666c02a715a95692ec1fa97" dependencies = [ "jni-sys", ] [[package]] name = "new_debug_unreachable" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" - -[[package]] -name = "nix" -version = "0.26.2" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" -dependencies = [ - "bitflags", - "cfg-if", - "libc", - "memoffset 0.7.1", - "static_assertions", -] +checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" [[package]] name = "nodrop" @@ -1863,45 +1731,20 @@ dependencies = [ ] [[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.1" +name = "num-conv" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi", - "libc", -] - [[package]] name = "num_enum" version = "0.5.11" @@ -1933,6 +1776,17 @@ dependencies = [ "objc_exception", ] +[[package]] +name = "objc-foundation" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9" +dependencies = [ + "block", + "objc", + "objc_id", +] + [[package]] name = "objc_exception" version = "0.1.2" @@ -1953,27 +1807,61 @@ dependencies = [ [[package]] name = "object" -version = "0.31.1" +version = "0.36.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1" +checksum = "27b64972346851a39438c60b341ebc01bba47464ae329e55cf343eb93964efd9" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] -name = "ordered-stream" -version = "0.2.0" +name = "openssl" +version = "0.10.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aa2b01e1d916879f73a53d01d1d6cee68adbb31d6d9177a8cfce093cced1d50" +checksum = "fedfea7d58a1f73118430a55da6a286e7b044961736ce96a16a17068ea25e5da" dependencies = [ - "futures-core", - "pin-project-lite", + "bitflags 2.6.0", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8288979acd84749c744a9014b4382d42b8f7b2592847b5afb2ed29e5d16ede07" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", ] [[package]] @@ -1984,12 +1872,11 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "pango" -version = "0.16.5" +version = "0.15.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdff66b271861037b89d028656184059e03b0b6ccb36003820be19f7200b1e94" +checksum = "22e4045548659aee5313bde6c582b0d83a627b7904dd20dc2d9ef0895d414e4f" dependencies = [ - "bitflags", - "gio", + "bitflags 1.3.2", "glib", "libc", "once_cell", @@ -1998,27 +1885,21 @@ dependencies = [ [[package]] name = "pango-sys" -version = "0.16.3" +version = "0.15.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e134909a9a293e04d2cc31928aa95679c5e4df954d0b85483159bd20d8f047f" +checksum = "d2a00081cde4661982ed91d80ef437c20eacaf6aa1a5962c0279ae194662c3aa" dependencies = [ "glib-sys", "gobject-sys", "libc", - "system-deps", + "system-deps 6.2.2", ] -[[package]] -name = "parking" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14f2252c834a40ed9bb5422029649578e63aa341ac401f74e719dd1afda8394e" - [[package]] name = "parking_lot" -version = "0.12.1" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" dependencies = [ "lock_api", "parking_lot_core", @@ -2026,22 +1907,22 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.8" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.3.5", + "redox_syscall 0.5.3", "smallvec", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] name = "percent-encoding" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "phf" @@ -2060,9 +1941,17 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259" dependencies = [ - "phf_macros 0.10.0", "phf_shared 0.10.0", - "proc-macro-hack", +] + +[[package]] +name = "phf" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" +dependencies = [ + "phf_macros 0.11.2", + "phf_shared 0.11.2", ] [[package]] @@ -2105,6 +1994,16 @@ dependencies = [ "rand 0.8.5", ] +[[package]] +name = "phf_generator" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" +dependencies = [ + "phf_shared 0.11.2", + "rand 0.8.5", +] + [[package]] name = "phf_macros" version = "0.8.0" @@ -2121,16 +2020,15 @@ dependencies = [ [[package]] name = "phf_macros" -version = "0.10.0" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58fdf3184dd560f160dd73922bea2d5cd6e8f064bf4b13110abd81b03697b4e0" +checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b" dependencies = [ - "phf_generator 0.10.0", - "phf_shared 0.10.0", - "proc-macro-hack", + "phf_generator 0.11.2", + "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.72", ] [[package]] @@ -2151,11 +2049,20 @@ dependencies = [ "siphasher", ] +[[package]] +name = "phf_shared" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b" +dependencies = [ + "siphasher", +] + [[package]] name = "pin-project-lite" -version = "0.2.10" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c40d25201921e5ff0c862a505c6557ea88568a4e3ace775ab55e93f2f4f9d57" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -2165,19 +2072,18 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.27" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "plist" -version = "1.5.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdc0001cfea3db57a2e24bc0d818e9e20e554b5f97fabb9bc231dc240269ae06" +checksum = "42cf17e9a1800f5f396bc67d193dc9411b59012a5876445ef450d449881e1016" dependencies = [ - "base64", - "indexmap 1.9.3", - "line-wrap", + "base64 0.22.1", + "indexmap 2.3.0", "quick-xml", "serde", "time", @@ -2185,11 +2091,11 @@ dependencies = [ [[package]] name = "png" -version = "0.17.9" +version = "0.17.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59871cc5b6cce7eaccca5a802b4173377a1c2ba90654246789a8fa2334426d11" +checksum = "06e4b0d3d1312775e782c86c91a111aa1f910cbb65e1337f9975b5f9a554b5e1" dependencies = [ - "bitflags", + "bitflags 1.3.2", "crc32fast", "fdeflate", "flate2", @@ -2197,26 +2103,19 @@ dependencies = [ ] [[package]] -name = "polling" -version = "2.8.0" +name = "powerfmt" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" -dependencies = [ - "autocfg", - "bitflags", - "cfg-if", - "concurrent-queue", - "libc", - "log", - "pin-project-lite", - "windows-sys", -] +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] [[package]] name = "precomputed-hash" @@ -2231,7 +2130,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell", - "toml_edit", + "toml_edit 0.19.15", ] [[package]] @@ -2266,27 +2165,27 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" [[package]] name = "proc-macro2" -version = "1.0.64" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78803b62cbf1f46fde80d7c0e803111524b9877184cfe7c3033659490ac7a7da" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] [[package]] name = "quick-xml" -version = "0.29.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81b9228215d82c7b61490fec1de287136b5de6f5700f6e58ea9ad61a7964ca51" +checksum = "1d3a6e5838b60e0e8fa7a43f22ade549a37d61f8bdbe636d0d7816191de969c2" dependencies = [ "memchr", ] [[package]] name = "quote" -version = "1.0.29" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -2351,7 +2250,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.10", + "getrandom 0.2.15", ] [[package]] @@ -2380,43 +2279,43 @@ checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9" [[package]] name = "redox_syscall" -version = "0.2.16" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] name = "redox_syscall" -version = "0.3.5" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" dependencies = [ - "bitflags", + "bitflags 2.6.0", ] [[package]] name = "redox_users" -version = "0.4.3" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" dependencies = [ - "getrandom 0.2.10", - "redox_syscall 0.2.16", + "getrandom 0.2.15", + "libredox", "thiserror", ] [[package]] name = "regex" -version = "1.9.1" +version = "1.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2eae68fc220f7cf2532e4494aded17545fce192d59cd996e0fe7887f4ceb575" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.3.2", - "regex-syntax 0.7.4", + "regex-automata 0.4.7", + "regex-syntax 0.8.4", ] [[package]] @@ -2430,13 +2329,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.2" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83d3daa6976cffb758ec878f108ba0e062a45b2d6ca3a2cca965338855476caf" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.7.4", + "regex-syntax 0.8.4", ] [[package]] @@ -2447,17 +2346,17 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.7.4" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "reqwest" -version = "0.11.18" +version = "0.11.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde824a14b7c14f85caff81225f411faacc04a2013f41670f41443742b1c1c55" +checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" dependencies = [ - "base64", + "base64 0.21.7", "bytes", "encoding_rs", "futures-core", @@ -2466,17 +2365,23 @@ dependencies = [ "http", "http-body", "hyper", + "hyper-tls", "ipnet", "js-sys", "log", "mime", + "native-tls", "once_cell", "percent-encoding", "pin-project-lite", + "rustls-pemfile", "serde", "serde_json", "serde_urlencoded", + "sync_wrapper", + "system-configuration", "tokio", + "tokio-native-tls", "tokio-util", "tower-service", "url", @@ -2484,14 +2389,38 @@ dependencies = [ "wasm-bindgen-futures", "wasm-streams", "web-sys", - "winreg 0.10.1", + "winreg 0.50.0", +] + +[[package]] +name = "rfd" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0149778bd99b6959285b0933288206090c50e2327f47a9c463bfdbf45c8823ea" +dependencies = [ + "block", + "dispatch", + "glib-sys", + "gobject-sys", + "gtk-sys", + "js-sys", + "lazy_static", + "log", + "objc", + "objc-foundation", + "objc_id", + "raw-window-handle", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "windows 0.37.0", ] [[package]] name = "rustc-demangle" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc_version" @@ -2504,35 +2433,37 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.23" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "bitflags", + "bitflags 2.6.0", "errno", - "io-lifetimes", "libc", "linux-raw-sys", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] -name = "rustversion" -version = "1.0.13" +name = "rustls-pemfile" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc31bd9b61a32c31f9650d18add92aa83a49ba979c143eefd27fe7177b05bd5f" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +dependencies = [ + "base64 0.21.7", +] [[package]] -name = "ryu" -version = "1.0.14" +name = "rustversion" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe232bdf6be8c8de797b22184ee71118d63780ea42ac85b61d1baa6d3b782ae9" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" [[package]] -name = "safemem" -version = "0.3.3" +name = "ryu" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "same-file" @@ -2544,16 +2475,48 @@ dependencies = [ ] [[package]] -name = "scoped-tls" +name = "schannel" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "scoped-tls" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" [[package]] name = "scopeguard" -version = "1.1.0" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "security-framework" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +dependencies = [ + "bitflags 2.6.0", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" +dependencies = [ + "core-foundation-sys", + "libc", +] [[package]] name = "selectors" @@ -2561,7 +2524,7 @@ version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df320f1889ac4ba6bc0cdc9c9af7af4bd64bb927bccdf32d81140dc1f9be12fe" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cssparser", "derive_more", "fxhash", @@ -2577,57 +2540,62 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.17" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" +dependencies = [ + "serde", +] [[package]] name = "serde" -version = "1.0.171" +version = "1.0.205" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30e27d1e4fd7659406c492fd6cfaf2066ba8773de45ca75e855590f856dc34a9" +checksum = "e33aedb1a7135da52b7c21791455563facbbcc43d0f0f66165b42c21b3dfb150" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.171" +version = "1.0.205" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "389894603bd18c46fa56231694f8d827779c0951a667087194cf9de94ed24682" +checksum = "692d6f5ac90220161d6774db30c662202721e64aed9058d2c394f451261420c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.72", ] [[package]] name = "serde_json" -version = "1.0.100" +version = "1.0.122" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f1e14e89be7aa4c4b78bdbdc9eb5bf8517829a600ae8eaa39a6e1d960b5185c" +checksum = "784b6203951c57ff748476b126ccb5e8e2959a5c19e5c617ab1956be3dbc68da" dependencies = [ - "itoa 1.0.8", + "indexmap 2.3.0", + "itoa 1.0.11", + "memchr", "ryu", "serde", ] [[package]] name = "serde_repr" -version = "0.1.14" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d89a8107374290037607734c0b73a85db7ed80cae314b3c5791f192a496e731" +checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.72", ] [[package]] name = "serde_spanned" -version = "0.6.3" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" +checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" dependencies = [ "serde", ] @@ -2639,22 +2607,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" dependencies = [ "form_urlencoded", - "itoa 1.0.8", + "itoa 1.0.11", "ryu", "serde", ] [[package]] name = "serde_with" -version = "3.0.0" +version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f02d8aa6e3c385bf084924f660ce2a3a6bd333ba55b35e8590b321f35d88513" +checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" dependencies = [ - "base64", + "base64 0.22.1", "chrono", "hex", "indexmap 1.9.3", + "indexmap 2.3.0", "serde", + "serde_derive", "serde_json", "serde_with_macros", "time", @@ -2662,14 +2632,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.0.0" +version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edc7d5d3932fb12ce722ee5e64dd38c504efba37567f0c402f6ca728c3b8b070" +checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.72", ] [[package]] @@ -2704,22 +2674,11 @@ dependencies = [ "stable_deref_trait", ] -[[package]] -name = "sha1" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - [[package]] name = "sha2" -version = "0.10.7" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", @@ -2728,95 +2687,76 @@ dependencies = [ [[package]] name = "sharded-slab" -version = "0.1.4" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" dependencies = [ "lazy_static", ] -[[package]] -name = "signal-hook" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801" -dependencies = [ - "libc", - "signal-hook-registry", -] - -[[package]] -name = "signal-hook-registry" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" -dependencies = [ - "libc", -] - [[package]] name = "simd-adler32" -version = "0.3.5" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "238abfbb77c1915110ad968465608b68e869e0772622c9656714e73e5a1a522f" +checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" [[package]] name = "siphasher" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" [[package]] name = "slab" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ "autocfg", ] [[package]] name = "smallvec" -version = "1.11.0" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "socket2" -version = "0.4.9" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" dependencies = [ "libc", - "winapi", + "windows-sys 0.52.0", ] [[package]] -name = "soup3" -version = "0.3.2" +name = "soup2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82bc46048125fefd69d30b32b9d263d6556c9ffe82a7a7df181a86d912da5616" +checksum = "b2b4d76501d8ba387cf0fefbe055c3e0a59891d09f0f995ae4e4b16f6b60f3c0" dependencies = [ - "bitflags", - "futures-channel", + "bitflags 1.3.2", "gio", "glib", "libc", "once_cell", - "soup3-sys", + "soup2-sys", ] [[package]] -name = "soup3-sys" -version = "0.3.1" +name = "soup2-sys" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "014bbeb1c4cdb30739dc181e8d98b7908f124d9555843afa89b5570aaf4ec62b" +checksum = "009ef427103fcb17f802871647a7fa6c60cbb654b4c4e4c0ac60a31c5f6dc9cf" dependencies = [ + "bitflags 1.3.2", "gio-sys", "glib-sys", "gobject-sys", "libc", - "system-deps", + "system-deps 5.0.0", ] [[package]] @@ -2827,19 +2767,13 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "state" -version = "0.6.0" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b8c4a4445d81357df8b1a650d0d0d6fbbbfe99d064aa5e02f3e4022061476d8" +checksum = "dbe866e1e51e8260c9eed836a042a5e7f6726bb2b411dffeaa712e19c388f23b" dependencies = [ "loom", ] -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - [[package]] name = "string_cache" version = "0.8.7" @@ -2868,20 +2802,9 @@ dependencies = [ [[package]] name = "strsim" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - -[[package]] -name = "swift-rs" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05e51d6f2b5fff4808614f429f8a7655ac8bcfe218185413f3a60c508482c2d6" -dependencies = [ - "base64", - "serde", - "serde_json", -] +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" @@ -2896,35 +2819,75 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.25" +version = "2.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15e3fc8c0c74267e2df136e5e5fb656a464158aa57624053375eb9c8c6e25ae2" +checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "system-deps" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18db855554db7bd0e73e06cf7ba3df39f97812cb11d3f75e71c39bf45171797e" +dependencies = [ + "cfg-expr 0.9.1", + "heck 0.3.3", + "pkg-config", + "toml 0.5.11", + "version-compare 0.0.11", +] + [[package]] name = "system-deps" -version = "6.1.1" +version = "6.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30c2de8a4d8f4b823d634affc9cd2a74ec98c53a756f317e529a48046cbf71f3" +checksum = "a3e535eb8dded36d55ec13eddacd30dec501792ff23a0b1682c38601b8cf2349" dependencies = [ - "cfg-expr", - "heck", + "cfg-expr 0.15.8", + "heck 0.5.0", "pkg-config", - "toml", - "version-compare", + "toml 0.8.19", + "version-compare 0.2.0", ] [[package]] name = "tao" -version = "0.21.0" +version = "0.16.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b87728a671df8520c274fa9bed48d7384f5a965ef2fc364f01a942f6ff1ae6d2" +checksum = "575c856fc21e551074869dcfaad8f706412bd5b803dfa0fbf6881c4ff4bfafab" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cairo-rs", "cc", "cocoa", @@ -2959,90 +2922,109 @@ dependencies = [ "serde", "tao-macros", "unicode-segmentation", - "url", "uuid", - "windows", + "windows 0.39.0", "windows-implement", "x11-dl", - "zbus", ] [[package]] name = "tao-macros" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b27a4bcc5eb524658234589bdffc7e7bfb996dbae6ce9393bfd39cb4159b445" +checksum = "ec114582505d158b669b136e6851f85840c109819d77c42bb7c0709f727d18c2" dependencies = [ "proc-macro2", "quote", "syn 1.0.109", ] +[[package]] +name = "tar" +version = "0.4.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb797dad5fb5b76fcf519e702f4a589483b5ef06567f160c392832c1f5e44909" +dependencies = [ + "filetime", + "libc", + "xattr", +] + [[package]] name = "target-lexicon" -version = "0.12.8" +version = "0.12.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1c7f239eb94671427157bd93b3694320f3668d4e1eff08c7285366fd777fac" +checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "tauri" -version = "2.0.0-alpha.10" -source = "git+https://github.com/lucasfernog/tauri?branch=feat/ipc-custom-protocol#46e7d58fc1ec2265324606689e2b528e6b6b739d" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "336bc661a3f3250853fa83c6e5245449ed1c26dce5dcb28bdee7efedf6278806" dependencies = [ "anyhow", + "base64 0.21.7", "bytes", "cocoa", "dirs-next", + "dunce", "embed_plist", + "encoding_rs", + "flate2", "futures-util", + "getrandom 0.2.15", "glib", "glob", "gtk", - "heck", + "heck 0.5.0", "http", - "jni", - "libc", - "log", + "ignore", + "indexmap 1.9.3", + "minisign-verify", "objc", "once_cell", "percent-encoding", "rand 0.8.5", "raw-window-handle", "reqwest", + "rfd", + "semver", "serde", "serde_json", "serde_repr", "serialize-to-javascript", "state", - "swift-rs", - "tauri-build", + "tar", "tauri-macros", "tauri-runtime", "tauri-runtime-wry", "tauri-utils", + "tempfile", "thiserror", + "time", "tokio", "url", "uuid", "webkit2gtk", "webview2-com", - "windows", + "windows 0.39.0", + "zip", ] [[package]] name = "tauri-build" -version = "2.0.0-alpha.6" -source = "git+https://github.com/lucasfernog/tauri?branch=feat/ipc-custom-protocol#46e7d58fc1ec2265324606689e2b528e6b6b739d" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0c6ec7a5c3296330c7818478948b422967ce4649094696c985f61d50076d29c" dependencies = [ "anyhow", "cargo_toml", - "heck", + "dirs-next", + "heck 0.5.0", "json-patch", - "plist", "semver", "serde", "serde_json", - "swift-rs", "tauri-utils", "tauri-winres", "walkdir", @@ -3050,10 +3032,11 @@ dependencies = [ [[package]] name = "tauri-codegen" -version = "2.0.0-alpha.6" -source = "git+https://github.com/lucasfernog/tauri?branch=feat/ipc-custom-protocol#46e7d58fc1ec2265324606689e2b528e6b6b739d" +version = "1.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1aed706708ff1200ec12de9cfbf2582b5d8ec05f6a7293911091effbd22036b" dependencies = [ - "base64", + "base64 0.21.7", "brotli", "ico", "json-patch", @@ -3068,17 +3051,17 @@ dependencies = [ "tauri-utils", "thiserror", "time", - "url", "uuid", "walkdir", ] [[package]] name = "tauri-macros" -version = "2.0.0-alpha.6" -source = "git+https://github.com/lucasfernog/tauri?branch=feat/ipc-custom-protocol#46e7d58fc1ec2265324606689e2b528e6b6b739d" +version = "1.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b88f831d2973ae4f81a706a0004e67dac87f2e4439973bbe98efbd73825d8ede" dependencies = [ - "heck", + "heck 0.5.0", "proc-macro2", "quote", "syn 1.0.109", @@ -3086,28 +3069,15 @@ dependencies = [ "tauri-utils", ] -[[package]] -name = "tauri-plugin-deep-link" -version = "0.0.0" -dependencies = [ - "log", - "serde", - "serde_json", - "tauri", - "tauri-build", - "thiserror", - "url", -] - [[package]] name = "tauri-runtime" -version = "0.13.0-alpha.6" -source = "git+https://github.com/lucasfernog/tauri?branch=feat/ipc-custom-protocol#46e7d58fc1ec2265324606689e2b528e6b6b739d" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3068ed62b63dedc705558f4248c7ecbd5561f0f8050949859ea0db2326f26012" dependencies = [ "gtk", "http", "http-range", - "jni", "rand 0.8.5", "raw-window-handle", "serde", @@ -3116,17 +3086,18 @@ dependencies = [ "thiserror", "url", "uuid", - "windows", + "webview2-com", + "windows 0.39.0", ] [[package]] name = "tauri-runtime-wry" -version = "0.13.0-alpha.6" -source = "git+https://github.com/lucasfernog/tauri?branch=feat/ipc-custom-protocol#46e7d58fc1ec2265324606689e2b528e6b6b739d" +version = "0.14.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4c3db170233096aa30330feadcd895bf9317be97e624458560a20e814db7955" dependencies = [ "cocoa", "gtk", - "jni", "percent-encoding", "rand 0.8.5", "raw-window-handle", @@ -3135,26 +3106,28 @@ dependencies = [ "uuid", "webkit2gtk", "webview2-com", - "windows", + "windows 0.39.0", "wry", ] [[package]] name = "tauri-utils" -version = "2.0.0-alpha.6" -source = "git+https://github.com/lucasfernog/tauri?branch=feat/ipc-custom-protocol#46e7d58fc1ec2265324606689e2b528e6b6b739d" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2826db448309d382dac14d520f0c0a40839b87b57b977e59cf5f296b3ace6a93" dependencies = [ "brotli", "ctor", "dunce", "glob", - "heck", - "html5ever 0.26.0", + "heck 0.5.0", + "html5ever", "infer", "json-patch", "kuchikiki", + "log", "memchr", - "phf 0.10.1", + "phf 0.11.2", "proc-macro2", "quote", "semver", @@ -3164,7 +3137,7 @@ dependencies = [ "thiserror", "url", "walkdir", - "windows", + "windows-version", ] [[package]] @@ -3174,21 +3147,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5993dc129e544393574288923d1ec447c857f3f644187f4fbf7d9a875fbfc4fb" dependencies = [ "embed-resource", - "toml", + "toml 0.7.8", ] [[package]] name = "tempfile" -version = "3.6.0" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31c0432476357e58790aaa47a8efb0c5138f137343f3b5f23bd36a27e3b0a6d6" +checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" dependencies = [ - "autocfg", "cfg-if", "fastrand", - "redox_syscall 0.3.5", + "once_cell", "rustix", - "windows-sys", + "windows-sys 0.59.0", ] [[package]] @@ -3210,29 +3182,29 @@ checksum = "8eaa81235c7058867fa8c0e7314f33dcce9c215f535d1913822a2b3f5e289f3c" [[package]] name = "thiserror" -version = "1.0.43" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a35fc5b8971143ca348fa6df4f024d4d55264f3468c71ad1c2f365b0a4d58c42" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.43" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "463fe12d7993d3b327787537ce8dd4dfa058de32fc2b195ef3cde03dc4771e8f" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.72", ] [[package]] name = "thread_local" -version = "1.1.7" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" dependencies = [ "cfg-if", "once_cell", @@ -3240,11 +3212,14 @@ dependencies = [ [[package]] name = "time" -version = "0.3.23" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59e399c068f43a5d116fedaf73b203fa4f9c519f17e2b34f63221d3792f81446" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ - "itoa 1.0.8", + "deranged", + "itoa 1.0.11", + "num-conv", + "powerfmt", "serde", "time-core", "time-macros", @@ -3252,24 +3227,38 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.10" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96ba15a897f3c86766b757e5ac7221554c6750054d74d5b28844fce5fb36a6c4" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ + "num-conv", "time-core", ] +[[package]] +name = "tiny_http" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0d6ef4e10d23c1efb862eecad25c5054429a71958b4eeef85eb5e7170b477ca" +dependencies = [ + "ascii", + "chunked_transfer", + "log", + "time", + "url", +] + [[package]] name = "tinyvec" -version = "1.6.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" dependencies = [ "tinyvec_macros", ] @@ -3282,67 +3271,108 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.29.1" +version = "1.39.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "532826ff75199d5833b9d2c5fe410f29235e25704ee5f0ef599fb51c21f4a4da" +checksum = "daa4fb1bc778bd6f04cbfc4bb2d06a7396a8f299dc33ea1900cedaa316f467b1" dependencies = [ - "autocfg", "backtrace", "bytes", "libc", "mio", - "num_cpus", "pin-project-lite", "socket2", - "windows-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", ] [[package]] name = "tokio-util" -version = "0.7.8" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" dependencies = [ "bytes", "futures-core", "futures-sink", "pin-project-lite", "tokio", - "tracing", ] [[package]] name = "toml" -version = "0.7.6" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + +[[package]] +name = "toml" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit 0.19.15", +] + +[[package]] +name = "toml" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542" +checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit", + "toml_edit 0.22.20", ] [[package]] name = "toml_datetime" -version = "0.6.3" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.19.12" +version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c500344a19072298cd05a7224b3c0c629348b78692bf48466c5238656e315a78" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.0.0", + "indexmap 2.3.0", "serde", "serde_spanned", "toml_datetime", - "winnow", + "winnow 0.5.40", +] + +[[package]] +name = "toml_edit" +version = "0.22.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" +dependencies = [ + "indexmap 2.3.0", + "serde", + "serde_spanned", + "toml_datetime", + "winnow 0.6.18", ] [[package]] @@ -3353,11 +3383,10 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" -version = "0.1.37" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "cfg-if", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -3365,20 +3394,20 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.72", ] [[package]] name = "tracing-core" -version = "0.1.31" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", "valuable", @@ -3386,20 +3415,20 @@ dependencies = [ [[package]] name = "tracing-log" -version = "0.1.3" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" dependencies = [ - "lazy_static", "log", + "once_cell", "tracing-core", ] [[package]] name = "tracing-subscriber" -version = "0.3.17" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ "matchers", "nu-ansi-term", @@ -3413,69 +3442,50 @@ dependencies = [ "tracing-log", ] -[[package]] -name = "treediff" -version = "4.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52984d277bdf2a751072b5df30ec0377febdb02f7696d64c2d7d54630bac4303" -dependencies = [ - "serde_json", -] - [[package]] name = "try-lock" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "typenum" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" - -[[package]] -name = "uds_windows" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce65604324d3cce9b966701489fbd0cf318cb1f7bd9dd07ac9a4ee6fb791930d" -dependencies = [ - "tempfile", - "winapi", -] +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicode-bidi" -version = "0.3.13" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" -version = "1.0.10" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22049a19f4a68748a168c0fc439f9516686aa045927ff767eca0a85101fb6e73" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" dependencies = [ "tinyvec", ] [[package]] name = "unicode-segmentation" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "url" -version = "2.4.0" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", "idna", @@ -3491,11 +3501,11 @@ checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" [[package]] name = "uuid" -version = "1.4.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d023da39d1fde5a8a3fe1f3e01ca9632ada0a63e9797de55a879d6e2236277be" +checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" dependencies = [ - "getrandom 0.2.10", + "getrandom 0.2.15", ] [[package]] @@ -3504,17 +3514,29 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "version-compare" -version = "0.1.1" +version = "0.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c18c859eead79d8b95d09e4678566e8d70105c4e7b251f707a03df32442661b" + +[[package]] +name = "version-compare" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "579a42fc0b8e0c63b76519a339be31bed574929511fa53c1a3acae26eb258f29" +checksum = "852e951cb7832cb45cb1169900d19760cfa39b82bc0ea9c0e5a14ae88411c98b" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "vswhom" @@ -3536,17 +3558,11 @@ dependencies = [ "libc", ] -[[package]] -name = "waker-fn" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" - [[package]] name = "walkdir" -version = "2.3.3" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" dependencies = [ "same-file", "winapi-util", @@ -3575,9 +3591,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.87" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -3585,24 +3601,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.87" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.72", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.37" +version = "0.4.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" +checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" dependencies = [ "cfg-if", "js-sys", @@ -3612,9 +3628,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.87" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3622,28 +3638,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.87" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.72", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.87" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "wasm-streams" -version = "0.2.3" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bbae3363c08332cadccd13b67db371814cd214c2524020932f0804b8cf7c078" +checksum = "b65dc4c90b63b118468cf747d8bf3566c1913ef60be765b5730ead9e0a3ba129" dependencies = [ "futures-util", "js-sys", @@ -3654,9 +3670,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.64" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" dependencies = [ "js-sys", "wasm-bindgen", @@ -3664,11 +3680,11 @@ dependencies = [ [[package]] name = "webkit2gtk" -version = "1.1.0" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ba4cce9085e0fb02575cfd45c328740dde78253cba516b1e8be2ca0f57bd8bf" +checksum = "b8f859735e4a452aeb28c6c56a852967a8a76c8eb1cc32dbf931ad28a13d6370" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cairo-rs", "gdk", "gdk-sys", @@ -3682,18 +3698,20 @@ dependencies = [ "javascriptcore-rs", "libc", "once_cell", - "soup3", + "soup2", "webkit2gtk-sys", ] [[package]] name = "webkit2gtk-sys" -version = "1.1.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4489eb24e8cf0a3d0555fd3a8f7adec2a5ece34c1e7b7c9a62da7822fd40a59" +checksum = "4d76ca6ecc47aeba01ec61e480139dda143796abcae6f83bcddf50d6b5b1dcf3" dependencies = [ - "bitflags", + "atk-sys", + "bitflags 1.3.2", "cairo-sys-rs", + "gdk-pixbuf-sys", "gdk-sys", "gio-sys", "glib-sys", @@ -3701,46 +3719,46 @@ dependencies = [ "gtk-sys", "javascriptcore-rs-sys", "libc", + "pango-sys", "pkg-config", - "soup3-sys", - "system-deps", + "soup2-sys", + "system-deps 6.2.2", ] [[package]] name = "webview2-com" -version = "0.25.0" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79e563ffe8e84d42e43ffacbace8780c0244fc8910346f334613559d92e203ad" +checksum = "b4a769c9f1a64a8734bde70caafac2b96cada12cd4aefa49196b3a386b8b4178" dependencies = [ "webview2-com-macros", "webview2-com-sys", - "windows", + "windows 0.39.0", "windows-implement", - "windows-interface", ] [[package]] name = "webview2-com-macros" -version = "0.7.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac1345798ecd8122468840bcdf1b95e5dc6d2206c5e4b0eafa078d061f59c9bc" +checksum = "eaebe196c01691db62e9e4ca52c5ef1e4fd837dcae27dae3ada599b5a8fd05ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 1.0.109", ] [[package]] name = "webview2-com-sys" -version = "0.25.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19d39576804304cf9ead192467ef47f7859a1a12fec3bd459d5ba34b8cd65ed5" +checksum = "aac48ef20ddf657755fdcda8dfed2a7b4fc7e4581acce6fe9b88c3d64f29dee7" dependencies = [ "regex", "serde", "serde_json", "thiserror", - "windows", + "windows 0.39.0", "windows-bindgen", "windows-metadata", ] @@ -3763,11 +3781,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.5" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "winapi", + "windows-sys 0.59.0", ] [[package]] @@ -3776,54 +3794,76 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57b543186b344cc61c85b5aab0d2e3adf4e0f99bc076eff9aa5927bcc0b8a647" +dependencies = [ + "windows_aarch64_msvc 0.37.0", + "windows_i686_gnu 0.37.0", + "windows_i686_msvc 0.37.0", + "windows_x86_64_gnu 0.37.0", + "windows_x86_64_msvc 0.37.0", +] + +[[package]] +name = "windows" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1c4bd0a50ac6020f65184721f758dba47bb9fbc2133df715ec74a237b26794a" +dependencies = [ + "windows-implement", + "windows_aarch64_msvc 0.39.0", + "windows_i686_gnu 0.39.0", + "windows_i686_msvc 0.39.0", + "windows_x86_64_gnu 0.39.0", + "windows_x86_64_msvc 0.39.0", +] + [[package]] name = "windows" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ - "windows-implement", - "windows-interface", - "windows-targets", + "windows-targets 0.48.5", ] [[package]] name = "windows-bindgen" -version = "0.48.0" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fe21a77bc54b7312dbd66f041605e098990c98be48cd52967b85b5e60e75ae6" +checksum = "68003dbd0e38abc0fb85b939240f4bce37c43a5981d3df37ccbaaa981b47cb41" dependencies = [ "windows-metadata", "windows-tokens", ] [[package]] -name = "windows-implement" -version = "0.48.0" +name = "windows-core" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e2ee588991b9e7e6c8338edf3333fbe4da35dc72092643958ebb43f0ab2c49c" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", + "windows-targets 0.52.6", ] [[package]] -name = "windows-interface" -version = "0.48.0" +name = "windows-implement" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6fb8df20c9bcaa8ad6ab513f7b40104840c8867d5751126e4df3b08388d0cc7" +checksum = "ba01f98f509cb5dc05f4e5fc95e535f78260f15fea8fe1a8abdd08f774f1cee7" dependencies = [ - "proc-macro2", - "quote", "syn 1.0.109", + "windows-tokens", ] [[package]] name = "windows-metadata" -version = "0.48.0" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "422ee0e5f0e2cc372bb6addbfff9a8add712155cd743df9c15f6ab000f31432d" +checksum = "9ee5e275231f07c6e240d14f34e1b635bf1faa1c76c57cfd59a5cdb9848e4278" [[package]] name = "windows-sys" @@ -3831,107 +3871,268 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] name = "windows-targets" -version = "0.48.1" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] name = "windows-tokens" -version = "0.48.0" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f838de2fe15fe6bac988e74b798f26499a8b21a9d97edec321e79b28d1d7f597" + +[[package]] +name = "windows-version" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b34c9a3b28cb41db7385546f7f9a8179348dffc89923dde66857b1ba5312f6b4" +checksum = "6998aa457c9ba8ff2fb9f13e9d2a930dabcea28f1d0ab94d687d8b3654844515" +dependencies = [ + "windows-targets 0.52.6", +] [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" -version = "0.48.0" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2623277cb2d1c216ba3b578c0f3cf9cdebeddb6e66b1b218bb33596ea7769c3a" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "ec7711666096bd4096ffa835238905bb33fb87267910e154b18b44eaabb340f2" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" -version = "0.48.0" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3925fd0b0b804730d44d4b6278c50f9699703ec49bcd628020f46f4ba07d9e1" + +[[package]] +name = "windows_i686_gnu" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "763fc57100a5f7042e3057e7e8d9bdd7860d330070251a73d003563a3bb49e1b" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" -version = "0.48.0" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce907ac74fe331b524c1298683efbf598bb031bc84d5e274db2083696d07c57c" + +[[package]] +name = "windows_i686_msvc" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bc7cbfe58828921e10a9f446fcaaf649204dcfe6c1ddd712c5eebae6bda1106" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" -version = "0.48.0" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2babfba0828f2e6b32457d5341427dcbb577ceef556273229959ac23a10af33d" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6868c165637d653ae1e8dc4d82c25d4f97dd6605eaa8d784b5c6e0ab2a252b65" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.0" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" -version = "0.48.0" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4dd6dc7df2d84cf7b33822ed5b86318fb1781948e9663bacd047fc9dd52259d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e4d40883ae9cae962787ca76ba76390ffa29214667a111db9e0a1ad8377e809" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.4.9" +version = "0.5.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +dependencies = [ + "memchr", +] + +[[package]] +name = "winnow" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81a2094c43cc94775293eaa0e499fbc30048a6d824ac82c0351a8c0bf9112529" +checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" dependencies = [ "memchr", ] [[package]] name = "winreg" -version = "0.10.1" +version = "0.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" dependencies = [ - "winapi", + "cfg-if", + "windows-sys 0.48.0", ] [[package]] name = "winreg" -version = "0.11.0" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76a1a57ff50e9b408431e8f97d5456f2807f8eb2a2cd79b06068fc87f8ecf189" +checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" dependencies = [ "cfg-if", - "winapi", + "windows-sys 0.48.0", ] [[package]] name = "wry" -version = "0.30.0" +version = "0.24.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "430d086d4626265e9427fe2908a06fb2e10ea2ff37d4a711eb9461b6ea3511dd" +checksum = "00711278ed357350d44c749c286786ecac644e044e4da410d466212152383b45" dependencies = [ - "base64", + "base64 0.13.1", "block", "cocoa", "core-graphics", @@ -3941,10 +4142,9 @@ dependencies = [ "gio", "glib", "gtk", - "html5ever 0.25.2", + "html5ever", "http", - "javascriptcore-rs", - "kuchiki", + "kuchikiki", "libc", "log", "objc", @@ -3953,14 +4153,14 @@ dependencies = [ "serde", "serde_json", "sha2", - "soup3", + "soup2", "tao", "thiserror", "url", "webkit2gtk", "webkit2gtk-sys", "webview2-com", - "windows", + "windows 0.39.0", "windows-implement", ] @@ -3986,115 +4186,44 @@ dependencies = [ ] [[package]] -name = "xdg-home" -version = "1.0.0" +name = "xattr" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2769203cd13a0c6015d515be729c526d041e9cf2c0cc478d57faee85f40c6dcd" +checksum = "8da84f1a25939b27f6820d92aed108f83ff920fdf11a7b19366c27c4cda81d4f" dependencies = [ - "nix", - "winapi", + "libc", + "linux-raw-sys", + "rustix", ] [[package]] -name = "zbus" -version = "3.14.1" +name = "zerocopy" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31de390a2d872e4cd04edd71b425e29853f786dc99317ed72d73d6fcf5ebb948" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ - "async-broadcast", - "async-executor", - "async-fs", - "async-io", - "async-lock", - "async-process", - "async-recursion", - "async-task", - "async-trait", - "blocking", "byteorder", - "derivative", - "enumflags2", - "event-listener", - "futures-core", - "futures-sink", - "futures-util", - "hex", - "nix", - "once_cell", - "ordered-stream", - "rand 0.8.5", - "serde", - "serde_repr", - "sha1", - "static_assertions", - "tracing", - "uds_windows", - "winapi", - "xdg-home", - "zbus_macros", - "zbus_names", - "zvariant", + "zerocopy-derive", ] [[package]] -name = "zbus_macros" -version = "3.14.1" +name = "zerocopy-derive" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d1794a946878c0e807f55a397187c11fc7a038ba5d868e7db4f3bd7760bc9d" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ - "proc-macro-crate", "proc-macro2", "quote", - "regex", - "syn 1.0.109", - "zvariant_utils", + "syn 2.0.72", ] [[package]] -name = "zbus_names" -version = "2.6.0" +name = "zip" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb80bb776dbda6e23d705cf0123c3b95df99c4ebeaec6c2599d4a5419902b4a9" -dependencies = [ - "serde", - "static_assertions", - "zvariant", -] - -[[package]] -name = "zvariant" -version = "3.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44b291bee0d960c53170780af148dca5fa260a63cdd24f1962fa82e03e53338c" +checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" dependencies = [ "byteorder", - "enumflags2", - "libc", - "serde", - "static_assertions", - "zvariant_derive", -] - -[[package]] -name = "zvariant_derive" -version = "3.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "934d7a7dfc310d6ee06c87ffe88ef4eca7d3e37bb251dece2ef93da8f17d8ecd" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 1.0.109", - "zvariant_utils", -] - -[[package]] -name = "zvariant_utils" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7234f0d811589db492d16893e3f21e8e2fd282e6d01b0cddee310322062cc200" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", + "crc32fast", + "crossbeam-utils", ] diff --git a/plugins/updater/tests/updater-migration/v1-app/Cargo.toml b/plugins/updater/tests/updater-migration/v1-app/Cargo.toml new file mode 100644 index 00000000..e99e4108 --- /dev/null +++ b/plugins/updater/tests/updater-migration/v1-app/Cargo.toml @@ -0,0 +1,18 @@ +workspace = {} + +[package] +name = "app-updater-v1" +version = "0.1.0" +edition = "2021" + +[build-dependencies] +tauri-build = { version = "1", features = [] } + +[dependencies] +serde = { version = "1", features = ["derive"] } +serde_json = "1" +tiny_http = "0.11" +tauri = { version = "1", features = ["updater"] } + +[features] +custom-protocol = ["tauri/custom-protocol"] diff --git a/plugins/updater/tests/updater-migration/v1-app/build.rs b/plugins/updater/tests/updater-migration/v1-app/build.rs new file mode 100644 index 00000000..5ebf8d2f --- /dev/null +++ b/plugins/updater/tests/updater-migration/v1-app/build.rs @@ -0,0 +1,7 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +fn main() { + tauri_build::build() +} diff --git a/plugins/updater/tests/updater-migration/v1-app/package.json b/plugins/updater/tests/updater-migration/v1-app/package.json new file mode 100644 index 00000000..2379b094 --- /dev/null +++ b/plugins/updater/tests/updater-migration/v1-app/package.json @@ -0,0 +1,10 @@ +{ + "name": "v1-app", + "version": "0.0.0", + "dependencies": { + "@tauri-apps/cli": "^1.0.0" + }, + "scripts": { + "tauri": "tauri" + } +} diff --git a/plugins/updater/tests/updater-migration/v1-app/src/main.rs b/plugins/updater/tests/updater-migration/v1-app/src/main.rs new file mode 100644 index 00000000..3c3138dd --- /dev/null +++ b/plugins/updater/tests/updater-migration/v1-app/src/main.rs @@ -0,0 +1,50 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] + +fn main() { + let mut context = tauri::generate_context!(); + if std::env::var("TARGET").unwrap_or_default() == "nsis" { + // /D sets the default installation directory ($INSTDIR), + // overriding InstallDir and InstallDirRegKey. + // It must be the last parameter used in the command line and must not contain any quotes, even if the path contains spaces. + // Only absolute paths are supported. + // NOTE: we only need this because this is an integration test and we don't want to install the app in the programs folder + context.config_mut().tauri.updater.windows.installer_args = vec![format!( + "/D={}", + tauri::utils::platform::current_exe() + .unwrap() + .parent() + .unwrap() + .display() + )]; + } + tauri::Builder::default() + .setup(|app| { + println!("version={}", app.package_info().version); + let handle = app.handle(); + tauri::async_runtime::spawn(async move { + match handle.updater().check().await { + Ok(update) => { + if update.is_update_available() { + if let Err(e) = update.download_and_install().await { + println!("{e}"); + std::process::exit(1); + } + std::process::exit(0); + } + std::process::exit(2); + } + Err(e) => { + println!("{e}"); + std::process::exit(1); + } + } + }); + Ok(()) + }) + .run(context) + .expect("error while running tauri application"); +} diff --git a/plugins/updater/tests/updater-migration/v1-app/tauri.conf.json b/plugins/updater/tests/updater-migration/v1-app/tauri.conf.json new file mode 100644 index 00000000..13e79887 --- /dev/null +++ b/plugins/updater/tests/updater-migration/v1-app/tauri.conf.json @@ -0,0 +1,39 @@ +{ + "$schema": "../../../core/tauri-config-schema/schema.json", + "build": { + "distDir": [], + "devPath": [] + }, + "tauri": { + "bundle": { + "active": true, + "targets": "all", + "identifier": "com.tauri.updater", + "icon": [ + "../icons/32x32.png", + "../icons/128x128.png", + "../icons/128x128@2x.png", + "../icons/icon.icns", + "../icons/icon.ico" + ], + "category": "DeveloperTool", + "windows": { + "wix": { + "skipWebviewInstall": true + } + } + }, + "allowlist": { + "all": false + }, + "updater": { + "active": true, + "dialog": false, + "pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEUwNDRGMjkwRjg2MDhCRDAKUldUUWkyRDRrUEpFNEQ4SmdwcU5PaXl6R2ZRUUNvUnhIaVkwVUltV0NMaEx6VTkrWVhpT0ZqeEEK", + "endpoints": ["http://localhost:3007"], + "windows": { + "installMode": "quiet" + } + } + } +} diff --git a/plugins/updater/tests/updater-migration/v2-app/.gitignore b/plugins/updater/tests/updater-migration/v2-app/.gitignore new file mode 100644 index 00000000..6a4bb536 --- /dev/null +++ b/plugins/updater/tests/updater-migration/v2-app/.gitignore @@ -0,0 +1 @@ +/gen/schemas diff --git a/plugins/updater/tests/updater-migration/v2-app/Cargo.toml b/plugins/updater/tests/updater-migration/v2-app/Cargo.toml new file mode 100644 index 00000000..d74275b1 --- /dev/null +++ b/plugins/updater/tests/updater-migration/v2-app/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "app-updater-v2" +version = "0.1.0" +edition = { workspace = true } + +[build-dependencies] +tauri-build = { workspace = true } + +[dependencies] +tauri = { workspace = true, features = ["wry", "compression"] } +serde = { workspace = true } +serde_json = { workspace = true } +tauri-plugin-updater = { path = "../../.." } +tiny_http = "0.12" diff --git a/plugins/updater/tests/updater-migration/v2-app/build.rs b/plugins/updater/tests/updater-migration/v2-app/build.rs new file mode 100644 index 00000000..5ebf8d2f --- /dev/null +++ b/plugins/updater/tests/updater-migration/v2-app/build.rs @@ -0,0 +1,7 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +fn main() { + tauri_build::build() +} diff --git a/plugins/updater/tests/updater-migration/v2-app/src/main.rs b/plugins/updater/tests/updater-migration/v2-app/src/main.rs new file mode 100644 index 00000000..b2bbe04b --- /dev/null +++ b/plugins/updater/tests/updater-migration/v2-app/src/main.rs @@ -0,0 +1,58 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] + +use tauri_plugin_updater::UpdaterExt; + +fn main() { + #[allow(unused_mut)] + let mut context = tauri::generate_context!(); + + tauri::Builder::default() + .plugin(tauri_plugin_updater::Builder::new().build()) + .setup(|app| { + println!("version={}", app.package_info().version); + let handle = app.handle().clone(); + tauri::async_runtime::spawn(async move { + let mut builder = handle.updater_builder(); + if std::env::var("TARGET").unwrap_or_default() == "nsis" { + // /D sets the default installation directory ($INSTDIR), + // overriding InstallDir and InstallDirRegKey. + // It must be the last parameter used in the command line and must not contain any quotes, even if the path contains spaces. + // Only absolute paths are supported. + // NOTE: we only need this because this is an integration test and we don't want to install the app in the programs folder + builder = builder.installer_args(vec![format!( + "/D={}", + tauri::utils::platform::current_exe() + .unwrap() + .parent() + .unwrap() + .display() + )]); + } + let updater = builder.build().unwrap(); + + match updater.check().await { + Ok(Some(update)) => { + if let Err(e) = update.download_and_install(|_, _| {}, || {}).await { + println!("{e}"); + std::process::exit(1); + } + std::process::exit(0); + } + Ok(None) => { + std::process::exit(2); + } + Err(e) => { + println!("{e}"); + std::process::exit(1); + } + } + }); + Ok(()) + }) + .run(context) + .expect("error while running tauri application"); +} diff --git a/plugins/updater/tests/updater-migration/v2-app/tauri.conf.json b/plugins/updater/tests/updater-migration/v2-app/tauri.conf.json new file mode 100644 index 00000000..d6cff85f --- /dev/null +++ b/plugins/updater/tests/updater-migration/v2-app/tauri.conf.json @@ -0,0 +1,33 @@ +{ + "identifier": "com.tauri.updater", + "plugins": { + "updater": { + "endpoints": ["http://localhost:3007"], + "pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEUwNDRGMjkwRjg2MDhCRDAKUldUUWkyRDRrUEpFNEQ4SmdwcU5PaXl6R2ZRUUNvUnhIaVkwVUltV0NMaEx6VTkrWVhpT0ZqeEEK", + "windows": { + "installMode": "quiet", + "installerArgs": ["/NS"] + } + } + }, + "bundle": { + "active": true, + "targets": "all", + "createUpdaterArtifacts": true, + "icon": [ + "../icons/32x32.png", + "../icons/128x128.png", + "../icons/128x128@2x.png", + "../icons/icon.icns", + "../icons/icon.ico" + ], + "windows": { + "webviewInstallMode": { + "type": "skip" + }, + "nsis": { + "compression": "none" + } + } + } +} diff --git a/plugins/upload/.gitignore b/plugins/upload/.gitignore deleted file mode 100644 index b512c09d..00000000 --- a/plugins/upload/.gitignore +++ /dev/null @@ -1 +0,0 @@ -node_modules \ No newline at end of file diff --git a/plugins/upload/CHANGELOG.md b/plugins/upload/CHANGELOG.md index 3109c03f..927256bc 100644 --- a/plugins/upload/CHANGELOG.md +++ b/plugins/upload/CHANGELOG.md @@ -1,5 +1,104 @@ # Changelog +## \[2.2.1] + +- [`ca7395a5`](https://github.com/tauri-apps/plugins-workspace/commit/ca7395a5ce971cbac25fb54285056edf3dd84e1f) ([#2378](https://github.com/tauri-apps/plugins-workspace/pull/2378) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) the `rustls-tls` feature is now enabled by default + +## \[2.2.1] + +- [`05c62d73`](https://github.com/tauri-apps/plugins-workspace/commit/05c62d731fa48fd06b8cb3694a962d8cb0db8619) ([#1523](https://github.com/tauri-apps/plugins-workspace/pull/1523) by [@enri90](https://github.com/tauri-apps/plugins-workspace/../../enri90)) Added post request on download function + +## \[2.2.0] + +- [`5dadd205`](https://github.com/tauri-apps/plugins-workspace/commit/5dadd205f5596c9607457dd015a2f9d7fc48a2db) ([#2033](https://github.com/tauri-apps/plugins-workspace/pull/2033) by [@514sid](https://github.com/tauri-apps/plugins-workspace/../../514sid)) Added a new field `progressTotal` to track the total amount of data transferred during the upload/download process. + +## \[2.1.0] + +- [`87cc5852`](https://github.com/tauri-apps/plugins-workspace/commit/87cc58527d769960427a2f46bb10532f5dcf7ace) ([#1797](https://github.com/tauri-apps/plugins-workspace/pull/1797) by [@VirtualPirate](https://github.com/tauri-apps/plugins-workspace/../../VirtualPirate)) Added feature for calculating `transfer_speed` during file uploads and downloads + +## \[2.0.1] + +- [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. + +## \[2.0.0] + +- [`e2c4dfb6`](https://github.com/tauri-apps/plugins-workspace/commit/e2c4dfb6af43e5dd8d9ceba232c315f5febd55c1) Update to tauri v2 stable release. + +## \[2.0.0-rc.2] + +### bug + +- [`1d9741b5`](https://github.com/tauri-apps/plugins-workspace/commit/1d9741b52bb242d32b2ffd46fb4343a501cbd54b) ([#1783](https://github.com/tauri-apps/plugins-workspace/pull/1783) by [@fxsalazar](https://github.com/tauri-apps/plugins-workspace/../../fxsalazar)) fix download content to file when unsuccessful response + +## \[2.0.0-rc.1] + +- [`e2e97db5`](https://github.com/tauri-apps/plugins-workspace/commit/e2e97db51983267f5be84d4f6f0278d58834d1f5) ([#1701](https://github.com/tauri-apps/plugins-workspace/pull/1701) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri 2.0.0-rc.8 + +## \[2.0.0-rc.0] + +- [`9887d1`](https://github.com/tauri-apps/plugins-workspace/commit/9887d14bd0e971c4c0f5c1188fc4005d3fc2e29e) Update to tauri RC. + +## \[2.0.0-beta.9] + +- [`99d6ac0f`](https://github.com/tauri-apps/plugins-workspace/commit/99d6ac0f9506a6a4a1aa59c728157190a7441af6) ([#1606](https://github.com/tauri-apps/plugins-workspace/pull/1606) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) The JS packages now specify the *minimum* `@tauri-apps/api` version instead of a single exact version. +- [`6de87966`](https://github.com/tauri-apps/plugins-workspace/commit/6de87966ecc00ad9d91c25be452f1f46bd2b7e1f) ([#1597](https://github.com/tauri-apps/plugins-workspace/pull/1597) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Update to tauri beta.25. + +## \[2.0.0-beta.8] + +- [`22a17980`](https://github.com/tauri-apps/plugins-workspace/commit/22a17980ff4f6f8c40adb1b8f4ffc6dae2fe7e30) ([#1537](https://github.com/tauri-apps/plugins-workspace/pull/1537) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri beta.24. + +## \[2.0.0-beta.7] + +- [`76daee7a`](https://github.com/tauri-apps/plugins-workspace/commit/76daee7aafece34de3092c86e531cf9eb1138989) ([#1512](https://github.com/tauri-apps/plugins-workspace/pull/1512) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Update to tauri beta.23. + +## \[2.0.0-beta.6] + +- [`9013854f`](https://github.com/tauri-apps/plugins-workspace/commit/9013854f42a49a230b9dbb9d02774765528a923f)([#1382](https://github.com/tauri-apps/plugins-workspace/pull/1382)) Update to tauri beta.22. + +## \[2.0.0-beta.5] + +- [`430bd6f4`](https://github.com/tauri-apps/plugins-workspace/commit/430bd6f4f379bee5d232ae6b098ae131db7f178a)([#1363](https://github.com/tauri-apps/plugins-workspace/pull/1363)) Update to tauri beta.20. + +## \[2.0.0-beta.4] + +- [`bd1ed590`](https://github.com/tauri-apps/plugins-workspace/commit/bd1ed5903ffcce5500310dac1e59e8c67674ef1e)([#1237](https://github.com/tauri-apps/plugins-workspace/pull/1237)) Update to tauri beta.17. + +## \[2.0.0-beta.3] + +- [`4a5ab18`](https://github.com/tauri-apps/plugins-workspace/commit/4a5ab18a229b902314f242d656b3a2290a8b9065)([#976](https://github.com/tauri-apps/plugins-workspace/pull/976)) Return the upload response as a string and error out if the status code is not within 200-299. + +## \[2.0.0-beta.3] + +- [`a04ea2f`](https://github.com/tauri-apps/plugins-workspace/commit/a04ea2f38294d5a3987578283badc8eec87a7752)([#1071](https://github.com/tauri-apps/plugins-workspace/pull/1071)) The global API script is now only added to the binary when the `withGlobalTauri` config is true. + +## \[2.0.0-beta.2] + +- [`99bea25`](https://github.com/tauri-apps/plugins-workspace/commit/99bea2559c2c0648c2519c50a18cd124dacef57b)([#1005](https://github.com/tauri-apps/plugins-workspace/pull/1005)) Update to tauri beta.8. + +## \[2.0.0-beta.1] + +- [`569defb`](https://github.com/tauri-apps/plugins-workspace/commit/569defbe9492e38938554bb7bdc1be9151456d21) Update to tauri beta.4. + +## \[2.0.0-beta.0] + +- [`d198c01`](https://github.com/tauri-apps/plugins-workspace/commit/d198c014863ee260cb0de88a14b7fc4356ef7474)([#862](https://github.com/tauri-apps/plugins-workspace/pull/862)) Update to tauri beta. + +## \[2.0.0-alpha.5] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.13. + +## \[2.0.0-alpha.4] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.12. + +## \[2.0.0-alpha.3] + +- [`e438e0a`](https://github.com/tauri-apps/plugins-workspace/commit/e438e0a62d4b430a5159f05f13ecd397dd891a0d)([#676](https://github.com/tauri-apps/plugins-workspace/pull/676)) Update to @tauri-apps/api v2.0.0-alpha.11. + +## \[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.9. + ## \[2.0.0-alpha.2] - [`4e2cef9`](https://github.com/tauri-apps/plugins-workspace/commit/4e2cef9b702bbbb9cf4ee17de50791cb21f1b2a4)([#593](https://github.com/tauri-apps/plugins-workspace/pull/593)) Update to alpha.12. @@ -10,9 +109,4 @@ ## \[2.0.0-alpha.0] -- [`717ae67`](https://github.com/tauri-apps/plugins-workspace/commit/717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! - te to alpha.11. - -## \[2.0.0-alpha.0] - - [`717ae67`](https://github.com/tauri-apps/plugins-workspace/commit/717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! diff --git a/plugins/upload/Cargo.toml b/plugins/upload/Cargo.toml index 96974206..c95658b5 100644 --- a/plugins/upload/Cargo.toml +++ b/plugins/upload/Cargo.toml @@ -1,14 +1,27 @@ [package] name = "tauri-plugin-upload" -version = "2.0.0-alpha.2" +version = "2.2.1" description = "Upload files from disk to a remote server over HTTP." authors = { workspace = true } license = { workspace = true } edition = { workspace = true } rust-version = { workspace = true } +repository = { workspace = true } +links = "tauri-plugin-upload" [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] + +[package.metadata.platforms.support] +windows = { level = "full", notes = "" } +linux = { level = "full", notes = "" } +macos = { level = "full", notes = "" } +android = { level = "full", notes = "" } +ios = { level = "full", notes = "" } + +[build-dependencies] +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } @@ -16,13 +29,22 @@ serde_json = { workspace = true } tauri = { workspace = true } log = { workspace = true } thiserror = { workspace = true } -tokio = { version = "1", features = [ "fs" ] } -tokio-util = { version = "0.7", features = [ "codec" ] } -reqwest = { version = "0.11", default-features = false, features = [ "json", "stream" ] } +tokio = { version = "1", features = ["fs"] } +tokio-util = { version = "0.7", features = ["codec"] } +reqwest = { version = "0.12", default-features = false, features = [ + "macos-system-configuration", + "json", + "stream", +] } futures-util = "0.3" read-progress-stream = "1.0.0" [features] -native-tls = [ "reqwest/native-tls" ] -native-tls-vendored = [ "reqwest/native-tls-vendored" ] -rustls-tls = [ "reqwest/rustls-tls" ] +default = ["rustls-tls"] +native-tls = ["reqwest/native-tls"] +native-tls-vendored = ["reqwest/native-tls-vendored"] +rustls-tls = ["reqwest/rustls-tls"] + +[dev-dependencies] +mockito = "1.6.1" +tokio = { version = "1", features = ["macros"] } diff --git a/plugins/upload/README.md b/plugins/upload/README.md index 67fcdf90..d6169097 100644 --- a/plugins/upload/README.md +++ b/plugins/upload/README.md @@ -3,9 +3,17 @@ Upload files from disk to a remote server over HTTP. Download files from a remote HTTP server to disk. +| Platform | Supported | +| -------- | --------- | +| Linux | ✓ | +| Windows | ✓ | +| macOS | ✓ | +| Android | ✓ | +| iOS | ✓ | + ## Install -_This plugin requires a Rust version of at least **1.70**_ +_This plugin requires a Rust version of at least **1.77.2**_ There are three general methods of installation that we can recommend. @@ -19,7 +27,7 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] -tauri-plugin-upload = "2.0.0-alpha" +tauri-plugin-upload = "2.0.0" # alternatively with Git: tauri-plugin-upload = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -47,7 +55,7 @@ yarn add https://github.com/tauri-apps/tauri-plugin-upload#v2 First you need to register the core plugin with Tauri: -`src-tauri/src/main.rs` +`src-tauri/src/lib.rs` ```rust fn main() { @@ -61,31 +69,47 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import { upload } from "@tauri-apps/plugin-upload"; +import { upload } from '@tauri-apps/plugin-upload' upload( - "https://example.com/file-upload", - "./path/to/my/file.txt", + 'https://example.com/file-upload', + './path/to/my/file.txt', (progress, total) => console.log(`Uploaded ${progress} of ${total} bytes`), // a callback that will be called with the upload progress - { "Content-Type": "text/plain" }, // optional headers to send with the request -); + { 'Content-Type': 'text/plain' } // optional headers to send with the request +) ``` ```javascript -import { download } from "tauri-plugin-upload-api"; +import { download } from '@tauri-apps/plugin-upload' download( - "https://example.com/file-download-link", - "./path/to/save/my/file.txt", + 'https://example.com/file-download-link', + './path/to/save/my/file.txt', (progress, total) => console.log(`Downloaded ${progress} of ${total} bytes`), // a callback that will be called with the download progress - { "Content-Type": "text/plain" }, // optional headers to send with the request -); + { 'Content-Type': 'text/plain' } // optional headers to send with the request +) ``` ## Contributing PRs accepted. Please make sure to read the Contributing Guide before making a pull request. +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + ## License Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. diff --git a/plugins/upload/SECURITY.md b/plugins/upload/SECURITY.md new file mode 100644 index 00000000..4f09bbac --- /dev/null +++ b/plugins/upload/SECURITY.md @@ -0,0 +1,23 @@ +# Security Policy + +**Do not report security vulnerabilities through public GitHub issues.** + +**Please use the [Private Vulnerability Disclosure](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) feature of GitHub.** + +Include as much of the following information: + +- Type of issue (e.g. improper input parsing, privilege escalation, etc.) +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- The distribution affected or used to help us with reproduction of the issue +- Step-by-step instructions to reproduce the issue +- Ideally a reproduction repository +- Impact of the issue, including how an attacker might exploit the issue + +We prefer to receive reports in English. + +## Contact + +Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). + +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/upload/api-iife.js b/plugins/upload/api-iife.js new file mode 100644 index 00000000..960e2b83 --- /dev/null +++ b/plugins/upload/api-iife.js @@ -0,0 +1 @@ +if("__TAURI__"in window){var __TAURI_PLUGIN_UPLOAD__=function(t){"use strict";function e(t,e,n,s){if("function"==typeof e||!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?s:"a"===n?s.call(t):s?s.value:e.get(t)}function n(t,e,n,s,i){if("function"==typeof e||!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,n),n}var s,i,o,a;"function"==typeof SuppressedError&&SuppressedError;const r="__TAURI_TO_IPC_KEY__";class c{constructor(t){s.set(this,void 0),i.set(this,0),o.set(this,[]),a.set(this,void 0),n(this,s,t||(()=>{})),this.id=function(t,e=!1){return window.__TAURI_INTERNALS__.transformCallback(t,e)}((t=>{const r=t.index;if("end"in t)return void(r==e(this,i,"f")?this.cleanupCallback():n(this,a,r));const c=t.message;if(r==e(this,i,"f")){for(e(this,s,"f").call(this,c),n(this,i,e(this,i,"f")+1);e(this,i,"f")in e(this,o,"f");){const t=e(this,o,"f")[e(this,i,"f")];e(this,s,"f").call(this,t),delete e(this,o,"f")[e(this,i,"f")],n(this,i,e(this,i,"f")+1)}e(this,i,"f")===e(this,a,"f")&&this.cleanupCallback()}else e(this,o,"f")[r]=c}))}cleanupCallback(){Reflect.deleteProperty(window,`_${this.id}`)}set onmessage(t){n(this,s,t)}get onmessage(){return e(this,s,"f")}[(s=new WeakMap,i=new WeakMap,o=new WeakMap,a=new WeakMap,r)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[r]()}}async function d(t,e={},n){return window.__TAURI_INTERNALS__.invoke(t,e,n)}return t.download=async function(t,e,n,s,i){const o=new Uint32Array(1);window.crypto.getRandomValues(o);const a=o[0],r=new c;n&&(r.onmessage=n),await d("plugin:upload|download",{id:a,url:t,filePath:e,headers:s??{},onProgress:r,body:i})},t.upload=async function(t,e,n,s){const i=new Uint32Array(1);window.crypto.getRandomValues(i);const o=i[0],a=new c;return n&&(a.onmessage=n),await d("plugin:upload|upload",{id:o,url:t,filePath:e,headers:s??{},onProgress:a})},t}({});Object.defineProperty(window.__TAURI__,"upload",{value:__TAURI_PLUGIN_UPLOAD__})} diff --git a/plugins/upload/build.rs b/plugins/upload/build.rs new file mode 100644 index 00000000..96b5a90a --- /dev/null +++ b/plugins/upload/build.rs @@ -0,0 +1,11 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +const COMMANDS: &[&str] = &["download", "upload"]; + +fn main() { + tauri_plugin::Builder::new(COMMANDS) + .global_api_script_path("./api-iife.js") + .build(); +} diff --git a/plugins/upload/guest-js/index.ts b/plugins/upload/guest-js/index.ts index 0f830b49..03129db4 100644 --- a/plugins/upload/guest-js/index.ts +++ b/plugins/upload/guest-js/index.ts @@ -2,37 +2,39 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { invoke, Channel } from "@tauri-apps/api/primitives"; +import { invoke, Channel } from '@tauri-apps/api/core' interface ProgressPayload { - progress: number; - total: number; + progress: number + progressTotal: number + total: number + transferSpeed: number } -type ProgressHandler = (progress: ProgressPayload) => void; +type ProgressHandler = (progress: ProgressPayload) => void async function upload( url: string, filePath: string, progressHandler?: ProgressHandler, - headers?: Map, -): Promise { - const ids = new Uint32Array(1); - window.crypto.getRandomValues(ids); - const id = ids[0]; + headers?: Map +): Promise { + const ids = new Uint32Array(1) + window.crypto.getRandomValues(ids) + const id = ids[0] - const onProgress = new Channel(); - if (progressHandler != null) { - onProgress.onmessage = progressHandler; + const onProgress = new Channel() + if (progressHandler) { + onProgress.onmessage = progressHandler } - await invoke("plugin:upload|upload", { + return await invoke('plugin:upload|upload', { id, url, filePath, headers: headers ?? {}, - onProgress, - }); + onProgress + }) } /// Download file from given url. @@ -44,23 +46,25 @@ async function download( filePath: string, progressHandler?: ProgressHandler, headers?: Map, + body?: string ): Promise { - const ids = new Uint32Array(1); - window.crypto.getRandomValues(ids); - const id = ids[0]; + const ids = new Uint32Array(1) + window.crypto.getRandomValues(ids) + const id = ids[0] - const onProgress = new Channel(); - if (progressHandler != null) { - onProgress.onmessage = progressHandler; + const onProgress = new Channel() + if (progressHandler) { + onProgress.onmessage = progressHandler } - await invoke("plugin:upload|download", { + await invoke('plugin:upload|download', { id, url, filePath, headers: headers ?? {}, onProgress, - }); + body + }) } -export { download, upload }; +export { download, upload } diff --git a/plugins/upload/package.json b/plugins/upload/package.json index 6081d00f..60fe24d0 100644 --- a/plugins/upload/package.json +++ b/plugins/upload/package.json @@ -1,33 +1,30 @@ { "name": "@tauri-apps/plugin-upload", - "version": "2.0.0-alpha.1", + "version": "2.2.1", "description": "Upload files from disk to a remote server over HTTP.", - "license": "MIT or APACHE-2.0", + "license": "MIT OR Apache-2.0", "authors": [ "Tauri Programme within The Commons Conservancy" ], + "repository": "https://github.com/tauri-apps/plugins-workspace", "type": "module", - "browser": "dist-js/index.min.js", - "module": "dist-js/index.mjs", - "types": "dist-js/index.d.ts", + "types": "./dist-js/index.d.ts", + "main": "./dist-js/index.cjs", + "module": "./dist-js/index.js", "exports": { - "import": "./dist-js/index.mjs", "types": "./dist-js/index.d.ts", - "browser": "./dist-js/index.min.js" + "import": "./dist-js/index.js", + "require": "./dist-js/index.cjs" }, "scripts": { "build": "rollup -c" }, "files": [ "dist-js", - "!dist-js/**/*.map", "README.md", "LICENSE" ], - "devDependencies": { - "tslib": "2.6.0" - }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.9" + "@tauri-apps/api": "^2.0.0" } } diff --git a/plugins/upload/permissions/autogenerated/commands/download.toml b/plugins/upload/permissions/autogenerated/commands/download.toml new file mode 100644 index 00000000..896b30ce --- /dev/null +++ b/plugins/upload/permissions/autogenerated/commands/download.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-download" +description = "Enables the download command without any pre-configured scope." +commands.allow = ["download"] + +[[permission]] +identifier = "deny-download" +description = "Denies the download command without any pre-configured scope." +commands.deny = ["download"] diff --git a/plugins/upload/permissions/autogenerated/commands/upload.toml b/plugins/upload/permissions/autogenerated/commands/upload.toml new file mode 100644 index 00000000..d36081c9 --- /dev/null +++ b/plugins/upload/permissions/autogenerated/commands/upload.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-upload" +description = "Enables the upload command without any pre-configured scope." +commands.allow = ["upload"] + +[[permission]] +identifier = "deny-upload" +description = "Denies the upload command without any pre-configured scope." +commands.deny = ["upload"] diff --git a/plugins/upload/permissions/autogenerated/reference.md b/plugins/upload/permissions/autogenerated/reference.md new file mode 100644 index 00000000..698399b8 --- /dev/null +++ b/plugins/upload/permissions/autogenerated/reference.md @@ -0,0 +1,77 @@ +## Default Permission + +This permission set configures what kind of +operations are available from the upload plugin. + +#### Granted Permissions + +All operations are enabled by default. + + + +#### This default permission set includes the following: + +- `allow-upload` +- `allow-download` + +## Permission Table + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IdentifierDescription
+ +`upload:allow-download` + + + +Enables the download command without any pre-configured scope. + +
+ +`upload:deny-download` + + + +Denies the download command without any pre-configured scope. + +
+ +`upload:allow-upload` + + + +Enables the upload command without any pre-configured scope. + +
+ +`upload:deny-upload` + + + +Denies the upload command without any pre-configured scope. + +
diff --git a/plugins/upload/permissions/default.toml b/plugins/upload/permissions/default.toml new file mode 100644 index 00000000..74a2eb9f --- /dev/null +++ b/plugins/upload/permissions/default.toml @@ -0,0 +1,13 @@ +"$schema" = "schemas/schema.json" + +[default] +description = """ +This permission set configures what kind of +operations are available from the upload plugin. + +#### Granted Permissions + +All operations are enabled by default. + +""" +permissions = ["allow-upload", "allow-download"] diff --git a/plugins/upload/permissions/schemas/schema.json b/plugins/upload/permissions/schemas/schema.json new file mode 100644 index 00000000..8b524649 --- /dev/null +++ b/plugins/upload/permissions/schemas/schema.json @@ -0,0 +1,330 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "PermissionFile", + "description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.", + "type": "object", + "properties": { + "default": { + "description": "The default permission set for the plugin", + "anyOf": [ + { + "$ref": "#/definitions/DefaultPermission" + }, + { + "type": "null" + } + ] + }, + "set": { + "description": "A list of permissions sets defined", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionSet" + } + }, + "permission": { + "description": "A list of inlined permissions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Permission" + } + } + }, + "definitions": { + "DefaultPermission": { + "description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.", + "type": "object", + "required": [ + "permissions" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "PermissionSet": { + "description": "A set of direct permissions grouped together under a new name.", + "type": "object", + "required": [ + "description", + "identifier", + "permissions" + ], + "properties": { + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does.", + "type": "string" + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionKind" + } + } + } + }, + "Permission": { + "description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.", + "type": "object", + "required": [ + "identifier" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri internal convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "commands": { + "description": "Allowed or denied commands when using this permission.", + "default": { + "allow": [], + "deny": [] + }, + "allOf": [ + { + "$ref": "#/definitions/Commands" + } + ] + }, + "scope": { + "description": "Allowed or denied scoped when using this permission.", + "allOf": [ + { + "$ref": "#/definitions/Scopes" + } + ] + }, + "platforms": { + "description": "Target platforms this permission applies. By default all platforms are affected by this permission.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Target" + } + } + } + }, + "Commands": { + "description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.", + "type": "object", + "properties": { + "allow": { + "description": "Allowed command.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "deny": { + "description": "Denied command, which takes priority.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "Scopes": { + "description": "An argument for fine grained behavior control of Tauri commands.\n\nIt can be of any serde serializable type and is used to allow or prevent certain actions inside a Tauri command. The configured scope is passed to the command and will be enforced by the command implementation.\n\n## Example\n\n```json { \"allow\": [{ \"path\": \"$HOME/**\" }], \"deny\": [{ \"path\": \"$HOME/secret.txt\" }] } ```", + "type": "object", + "properties": { + "allow": { + "description": "Data that defines what is allowed by the scope.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + }, + "deny": { + "description": "Data that defines what is denied by the scope. This should be prioritized by validation logic.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + } + } + }, + "Value": { + "description": "All supported ACL values.", + "anyOf": [ + { + "description": "Represents a null JSON value.", + "type": "null" + }, + { + "description": "Represents a [`bool`].", + "type": "boolean" + }, + { + "description": "Represents a valid ACL [`Number`].", + "allOf": [ + { + "$ref": "#/definitions/Number" + } + ] + }, + { + "description": "Represents a [`String`].", + "type": "string" + }, + { + "description": "Represents a list of other [`Value`]s.", + "type": "array", + "items": { + "$ref": "#/definitions/Value" + } + }, + { + "description": "Represents a map of [`String`] keys to [`Value`]s.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/Value" + } + } + ] + }, + "Number": { + "description": "A valid ACL number.", + "anyOf": [ + { + "description": "Represents an [`i64`].", + "type": "integer", + "format": "int64" + }, + { + "description": "Represents a [`f64`].", + "type": "number", + "format": "double" + } + ] + }, + "Target": { + "description": "Platform target.", + "oneOf": [ + { + "description": "MacOS.", + "type": "string", + "enum": [ + "macOS" + ] + }, + { + "description": "Windows.", + "type": "string", + "enum": [ + "windows" + ] + }, + { + "description": "Linux.", + "type": "string", + "enum": [ + "linux" + ] + }, + { + "description": "Android.", + "type": "string", + "enum": [ + "android" + ] + }, + { + "description": "iOS.", + "type": "string", + "enum": [ + "iOS" + ] + } + ] + }, + "PermissionKind": { + "type": "string", + "oneOf": [ + { + "description": "Enables the download command without any pre-configured scope.", + "type": "string", + "const": "allow-download", + "markdownDescription": "Enables the download command without any pre-configured scope." + }, + { + "description": "Denies the download command without any pre-configured scope.", + "type": "string", + "const": "deny-download", + "markdownDescription": "Denies the download command without any pre-configured scope." + }, + { + "description": "Enables the upload command without any pre-configured scope.", + "type": "string", + "const": "allow-upload", + "markdownDescription": "Enables the upload command without any pre-configured scope." + }, + { + "description": "Denies the upload command without any pre-configured scope.", + "type": "string", + "const": "deny-upload", + "markdownDescription": "Denies the upload command without any pre-configured scope." + }, + { + "description": "This permission set configures what kind of\noperations are available from the upload plugin.\n\n#### Granted Permissions\n\nAll operations are enabled by default.\n\n\n#### This default permission set includes:\n\n- `allow-upload`\n- `allow-download`", + "type": "string", + "const": "default", + "markdownDescription": "This permission set configures what kind of\noperations are available from the upload plugin.\n\n#### Granted Permissions\n\nAll operations are enabled by default.\n\n\n#### This default permission set includes:\n\n- `allow-upload`\n- `allow-download`" + } + ] + } + } +} \ No newline at end of file diff --git a/plugins/upload/rollup.config.js b/plugins/upload/rollup.config.js new file mode 100644 index 00000000..1f349ec8 --- /dev/null +++ b/plugins/upload/rollup.config.js @@ -0,0 +1,7 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import { createConfig } from '../../shared/rollup.config.js' + +export default createConfig() diff --git a/plugins/upload/rollup.config.mjs b/plugins/upload/rollup.config.mjs deleted file mode 100644 index 99a3dd31..00000000 --- a/plugins/upload/rollup.config.mjs +++ /dev/null @@ -1,11 +0,0 @@ -import { readFileSync } from "fs"; - -import { createConfig } from "../../shared/rollup.config.mjs"; - -export default createConfig({ - input: "guest-js/index.ts", - pkg: JSON.parse( - readFileSync(new URL("./package.json", import.meta.url), "utf8"), - ), - external: [/^@tauri-apps\/api/], -}); diff --git a/plugins/upload/src/api-iife.js b/plugins/upload/src/api-iife.js deleted file mode 100644 index 64b3b89d..00000000 --- a/plugins/upload/src/api-iife.js +++ /dev/null @@ -1 +0,0 @@ -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__})} diff --git a/plugins/upload/src/lib.rs b/plugins/upload/src/lib.rs index 83f2d479..23c33b11 100644 --- a/plugins/upload/src/lib.rs +++ b/plugins/upload/src/lib.rs @@ -2,8 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -//! [![](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/upload/banner.png)](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/upload) -//! //! Upload files from disk to a remote server over HTTP. //! //! Download files from a remote HTTP server to disk. @@ -13,6 +11,9 @@ html_favicon_url = "https://github.com/tauri-apps/tauri/raw/dev/app-icon.png" )] +mod transfer_stats; +use transfer_stats::TransferStats; + use futures_util::TryStreamExt; use serde::{ser::Serializer, Serialize}; use tauri::{ @@ -21,7 +22,10 @@ use tauri::{ plugin::{Builder as PluginBuilder, TauriPlugin}, Runtime, }; -use tokio::{fs::File, io::AsyncWriteExt}; +use tokio::{ + fs::File, + io::{AsyncWriteExt, BufWriter}, +}; use tokio_util::codec::{BytesCodec, FramedRead}; use read_progress_stream::ReadProgressStream; @@ -38,6 +42,8 @@ pub enum Error { Request(#[from] reqwest::Error), #[error("{0}")] ContentLength(String), + #[error("request failed with status code {0}: {1}")] + HttpErrorCode(u16, String), } impl Serialize for Error { @@ -50,9 +56,12 @@ impl Serialize for Error { } #[derive(Clone, Serialize)] +#[serde(rename_all = "camelCase")] struct ProgressPayload { progress: u64, + progress_total: u64, total: u64, + transfer_speed: u64, } #[command] @@ -60,11 +69,15 @@ async fn download( url: &str, file_path: &str, headers: HashMap, - on_progress: Channel, + body: Option, + on_progress: Channel, ) -> Result<()> { let client = reqwest::Client::new(); - - let mut request = client.get(url); + let mut request = if let Some(body) = body { + client.post(url).body(body) + } else { + client.get(url) + }; // Loop trought the headers keys and values // and add them to the request object. for (key, value) in headers { @@ -72,18 +85,29 @@ async fn download( } let response = request.send().await?; + if !response.status().is_success() { + return Err(Error::HttpErrorCode( + response.status().as_u16(), + response.text().await.unwrap_or_default(), + )); + } let total = response.content_length().unwrap_or(0); - let mut file = File::create(file_path).await?; + let mut file = BufWriter::new(File::create(file_path).await?); let mut stream = response.bytes_stream(); + let mut stats = TransferStats::default(); while let Some(chunk) = stream.try_next().await? { file.write_all(&chunk).await?; - let _ = on_progress.send(&ProgressPayload { + stats.record_chunk_transfer(chunk.len()); + let _ = on_progress.send(ProgressPayload { progress: chunk.len() as u64, + progress_total: stats.total_transferred, total, + transfer_speed: stats.transfer_speed, }); } + file.flush().await?; Ok(()) } @@ -93,40 +117,117 @@ async fn upload( url: &str, file_path: &str, headers: HashMap, - on_progress: Channel, -) -> Result { + on_progress: Channel, +) -> Result { // Read the file let file = File::open(file_path).await?; + let file_len = file.metadata().await.unwrap().len(); // Create the request and attach the file to the body let client = reqwest::Client::new(); - let mut request = client.post(url).body(file_to_body(on_progress, file)); + let mut request = client + .post(url) + .header(reqwest::header::CONTENT_LENGTH, file_len) + .body(file_to_body(on_progress, file)); - // Loop trought the headers keys and values + // Loop through the headers keys and values // and add them to the request object. for (key, value) in headers { request = request.header(&key, value); } let response = request.send().await?; - - response.json().await.map_err(Into::into) + if response.status().is_success() { + response.text().await.map_err(Into::into) + } else { + Err(Error::HttpErrorCode( + response.status().as_u16(), + response.text().await.unwrap_or_default(), + )) + } } -fn file_to_body(channel: Channel, file: File) -> reqwest::Body { +fn file_to_body(channel: Channel, file: File) -> reqwest::Body { let stream = FramedRead::new(file, BytesCodec::new()).map_ok(|r| r.freeze()); + let mut stats = TransferStats::default(); reqwest::Body::wrap_stream(ReadProgressStream::new( stream, Box::new(move |progress, total| { - let _ = channel.send(ProgressPayload { progress, total }); + stats.record_chunk_transfer(progress as usize); + let _ = channel.send(ProgressPayload { + progress, + progress_total: stats.total_transferred, + total, + transfer_speed: stats.transfer_speed, + }); }), )) } pub fn init() -> TauriPlugin { PluginBuilder::new("upload") - .js_init_script(include_str!("api-iife.js").to_string()) .invoke_handler(tauri::generate_handler![download, upload]) .build() } + +#[cfg(test)] +mod tests { + use super::*; + use mockito::{self, Mock, Server, ServerGuard}; + use tauri::ipc::InvokeResponseBody; + struct MockedServer { + _server: ServerGuard, + url: String, + mocked_endpoint: Mock, + } + + #[tokio::test] + async fn should_error_if_status_not_success() { + let mocked_server = spawn_server_mocked(400).await; + let result = download_file(&mocked_server.url).await; + mocked_server.mocked_endpoint.assert(); + assert!(result.is_err()); + } + + #[tokio::test] + async fn should_download_file_successfully() { + let mocked_server = spawn_server_mocked(200).await; + let result = download_file(&mocked_server.url).await; + mocked_server.mocked_endpoint.assert(); + assert!( + result.is_ok(), + "failed to download file: {}", + result.unwrap_err() + ); + } + + async fn download_file(url: &str) -> Result<()> { + let file_path = concat!(env!("CARGO_MANIFEST_DIR"), "/test/test.txt"); + let headers = HashMap::new(); + let sender: Channel = + Channel::new(|msg: InvokeResponseBody| -> tauri::Result<()> { + let _ = msg; + Ok(()) + }); + download(url, file_path, headers, None, sender).await + } + + async fn spawn_server_mocked(return_status: usize) -> MockedServer { + let mut _server = Server::new_async().await; + let path = "/mock_test"; + let mock = _server + .mock("GET", path) + .with_status(return_status) + .with_body("mocked response body") + .create_async() + .await; + + let url = _server.url() + path; + MockedServer { + _server, + url, + mocked_endpoint: mock, + } + } +} diff --git a/plugins/upload/src/transfer_stats.rs b/plugins/upload/src/transfer_stats.rs new file mode 100644 index 00000000..2f3a3946 --- /dev/null +++ b/plugins/upload/src/transfer_stats.rs @@ -0,0 +1,55 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use std::time::Instant; + +// The TransferStats struct tracks both transfer speed and cumulative transfer progress. +pub struct TransferStats { + accumulated_chunk_len: usize, // Total length of chunks transferred in the current period + accumulated_time: u128, // Total time taken for the transfers in the current period + pub transfer_speed: u64, // Calculated transfer speed in bytes per second + pub total_transferred: u64, // Cumulative total of all transferred data + start_time: Instant, // Time when the current period started + granularity: u32, // Time period (in milliseconds) over which the transfer speed is calculated +} + +impl TransferStats { + // Initializes a new TransferStats instance with the specified granularity. + pub fn start(granularity: u32) -> Self { + Self { + accumulated_chunk_len: 0, + accumulated_time: 0, + transfer_speed: 0, + total_transferred: 0, + start_time: Instant::now(), + granularity, + } + } + // Records the transfer of a data chunk and updates both transfer speed and total progress. + pub fn record_chunk_transfer(&mut self, chunk_len: usize) { + let now = Instant::now(); + let it_took = now.duration_since(self.start_time).as_millis(); + self.accumulated_chunk_len += chunk_len; + self.total_transferred += chunk_len as u64; + self.accumulated_time += it_took; + + // Calculate transfer speed if accumulated time exceeds granularity. + if self.accumulated_time >= self.granularity as u128 { + self.transfer_speed = + (self.accumulated_chunk_len as u128 / self.accumulated_time * 1024) as u64; + self.accumulated_chunk_len = 0; + self.accumulated_time = 0; + } + + // Reset the start time for the next period. + self.start_time = now; + } +} + +// Provides a default implementation for TransferStats with a granularity of 500 milliseconds. +impl Default for TransferStats { + fn default() -> Self { + Self::start(500) // Default granularity is 500 ms + } +} diff --git a/plugins/upload/test/test.txt b/plugins/upload/test/test.txt new file mode 100644 index 00000000..629b997b --- /dev/null +++ b/plugins/upload/test/test.txt @@ -0,0 +1 @@ +mocked response body \ No newline at end of file diff --git a/plugins/websocket/.gitignore b/plugins/websocket/.gitignore deleted file mode 100644 index 3c3629e6..00000000 --- a/plugins/websocket/.gitignore +++ /dev/null @@ -1 +0,0 @@ -node_modules diff --git a/plugins/websocket/CHANGELOG.md b/plugins/websocket/CHANGELOG.md index 3109c03f..905fa644 100644 --- a/plugins/websocket/CHANGELOG.md +++ b/plugins/websocket/CHANGELOG.md @@ -1,5 +1,96 @@ # Changelog +## \[2.3.0] + +- [`78acfa45`](https://github.com/tauri-apps/plugins-workspace/commit/78acfa456f343c0af5fbf35660802d14ff7a5eca) ([#2027](https://github.com/tauri-apps/plugins-workspace/pull/2027) by [@twlite](https://github.com/tauri-apps/plugins-workspace/../../twlite)) `addListener` now returns a cleanup function instead of `void` to remove the listener. + +## \[2.2.1] + +- [`05cca602`](https://github.com/tauri-apps/plugins-workspace/commit/05cca602d927c30014d3892438ca28d99bc4e1d3) ([#2210](https://github.com/tauri-apps/plugins-workspace/pull/2210) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) **Breaking change:** Updated tokio_tungstenite to `0.26`. This may be a breaking change if you use the `tls_connector` Builder method in Rust. + **Breaking change:** Removed the accidental `ConnectionConfig` struct re-export (in rust). This should not affect anyone since the Config was not used in any public API. + +## \[2.2.0] + +- [`3a79266b`](https://github.com/tauri-apps/plugins-workspace/commit/3a79266b8cf96a55b1ae6339d725567d45a44b1d) ([#2173](https://github.com/tauri-apps/plugins-workspace/pull/2173) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Bumped all plugins to `v2.2.0`. From now, the versions for the Rust and JavaScript packages of each plugin will be in sync with each other. + +## \[2.0.1] + +- [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. + +## \[2.0.0] + +- [`e2c4dfb6`](https://github.com/tauri-apps/plugins-workspace/commit/e2c4dfb6af43e5dd8d9ceba232c315f5febd55c1) Update to tauri v2 stable release. + +## \[2.0.0-rc.1] + +- [`e2e97db5`](https://github.com/tauri-apps/plugins-workspace/commit/e2e97db51983267f5be84d4f6f0278d58834d1f5) ([#1701](https://github.com/tauri-apps/plugins-workspace/pull/1701) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri 2.0.0-rc.8 + +## \[2.0.0-rc.0] + +- [`9887d1`](https://github.com/tauri-apps/plugins-workspace/commit/9887d14bd0e971c4c0f5c1188fc4005d3fc2e29e) Update to tauri RC. + +## \[2.0.0-beta.8] + +- [`99d6ac0f`](https://github.com/tauri-apps/plugins-workspace/commit/99d6ac0f9506a6a4a1aa59c728157190a7441af6) ([#1606](https://github.com/tauri-apps/plugins-workspace/pull/1606) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) The JS packages now specify the *minimum* `@tauri-apps/api` version instead of a single exact version. +- [`6de87966`](https://github.com/tauri-apps/plugins-workspace/commit/6de87966ecc00ad9d91c25be452f1f46bd2b7e1f) ([#1597](https://github.com/tauri-apps/plugins-workspace/pull/1597) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Update to tauri beta.25. + +## \[2.0.0-beta.7] + +- [`22a17980`](https://github.com/tauri-apps/plugins-workspace/commit/22a17980ff4f6f8c40adb1b8f4ffc6dae2fe7e30) ([#1537](https://github.com/tauri-apps/plugins-workspace/pull/1537) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri beta.24. + +## \[2.0.0-beta.6] + +- [`76daee7a`](https://github.com/tauri-apps/plugins-workspace/commit/76daee7aafece34de3092c86e531cf9eb1138989) ([#1512](https://github.com/tauri-apps/plugins-workspace/pull/1512) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Update to tauri beta.23. + +## \[2.0.0-beta.5] + +- [`9013854f`](https://github.com/tauri-apps/plugins-workspace/commit/9013854f42a49a230b9dbb9d02774765528a923f)([#1382](https://github.com/tauri-apps/plugins-workspace/pull/1382)) Update to tauri beta.22. + +## \[2.0.0-beta.4] + +- [`430bd6f4`](https://github.com/tauri-apps/plugins-workspace/commit/430bd6f4f379bee5d232ae6b098ae131db7f178a)([#1363](https://github.com/tauri-apps/plugins-workspace/pull/1363)) Update to tauri beta.20. + +## \[2.0.0-beta.3] + +- [`bd1ed590`](https://github.com/tauri-apps/plugins-workspace/commit/bd1ed5903ffcce5500310dac1e59e8c67674ef1e)([#1237](https://github.com/tauri-apps/plugins-workspace/pull/1237)) Update to tauri beta.17. + +## \[2.0.0-beta.4] + +- [`ed46dca`](https://github.com/tauri-apps/plugins-workspace/commit/ed46dca74ff3947dbbcb26a7b571c129bf925698) **Breaking change:** Enable rustls by default and added a method to configure the TLS Connector for tungstenite. + +## \[2.0.0-beta.3] + +- [`a04ea2f`](https://github.com/tauri-apps/plugins-workspace/commit/a04ea2f38294d5a3987578283badc8eec87a7752)([#1071](https://github.com/tauri-apps/plugins-workspace/pull/1071)) The global API script is now only added to the binary when the `withGlobalTauri` config is true. + +## \[2.0.0-beta.2] + +- [`99bea25`](https://github.com/tauri-apps/plugins-workspace/commit/99bea2559c2c0648c2519c50a18cd124dacef57b)([#1005](https://github.com/tauri-apps/plugins-workspace/pull/1005)) Update to tauri beta.8. + +## \[2.0.0-beta.1] + +- [`569defb`](https://github.com/tauri-apps/plugins-workspace/commit/569defbe9492e38938554bb7bdc1be9151456d21) Update to tauri beta.4. + +## \[2.0.0-beta.0] + +- [`d198c01`](https://github.com/tauri-apps/plugins-workspace/commit/d198c014863ee260cb0de88a14b7fc4356ef7474)([#862](https://github.com/tauri-apps/plugins-workspace/pull/862)) Update to tauri beta. + +## \[2.0.0-alpha.5] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.13. + +## \[2.0.0-alpha.4] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.12. +- [`251852c`](https://github.com/tauri-apps/plugins-workspace/commit/251852ccbc97abe5765fb9663aab27701f3d7c7c)([#702](https://github.com/tauri-apps/plugins-workspace/pull/702)) Add support for custom request headers. + +## \[2.0.0-alpha.3] + +- [`e438e0a`](https://github.com/tauri-apps/plugins-workspace/commit/e438e0a62d4b430a5159f05f13ecd397dd891a0d)([#676](https://github.com/tauri-apps/plugins-workspace/pull/676)) Update to @tauri-apps/api v2.0.0-alpha.11. + +## \[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.9. + ## \[2.0.0-alpha.2] - [`4e2cef9`](https://github.com/tauri-apps/plugins-workspace/commit/4e2cef9b702bbbb9cf4ee17de50791cb21f1b2a4)([#593](https://github.com/tauri-apps/plugins-workspace/pull/593)) Update to alpha.12. @@ -10,9 +101,4 @@ ## \[2.0.0-alpha.0] -- [`717ae67`](https://github.com/tauri-apps/plugins-workspace/commit/717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! - te to alpha.11. - -## \[2.0.0-alpha.0] - - [`717ae67`](https://github.com/tauri-apps/plugins-workspace/commit/717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! diff --git a/plugins/websocket/Cargo.toml b/plugins/websocket/Cargo.toml index aca62dc2..34130573 100644 --- a/plugins/websocket/Cargo.toml +++ b/plugins/websocket/Cargo.toml @@ -1,15 +1,28 @@ [package] name = "tauri-plugin-websocket" -version = "2.0.0-alpha.2" +version = "2.3.0" description = "Expose a WebSocket server to your Tauri frontend." authors = { workspace = true } license = { workspace = true } edition = { workspace = true } rust-version = { workspace = true } -exclude = [ "/examples" ] +repository = { workspace = true } +links = "tauri-plugin-websocket" +exclude = ["/examples"] [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] + +[package.metadata.platforms.support] +windows = { level = "full", notes = "" } +linux = { level = "full", notes = "" } +macos = { level = "full", notes = "" } +android = { level = "full", notes = "" } +ios = { level = "full", notes = "" } + +[build-dependencies] +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } @@ -17,12 +30,15 @@ serde_json = { workspace = true } tauri = { workspace = true } log = { workspace = true } thiserror = { workspace = true } +http = "1" rand = "0.8" futures-util = "0.3" -tokio = { version = "1", features = [ "net", "sync" ] } -tokio-tungstenite = { version = "0.20" } +tokio = { version = "1", features = ["net", "sync"] } +tokio-tungstenite = { version = "0.26" } [features] -native-tls = [ "tokio-tungstenite/native-tls" ] -native-tls-vendored = [ "tokio-tungstenite/native-tls-vendored" ] -rustls-tls-webpki-roots = [ "tokio-tungstenite/rustls-tls-webpki-roots" ] +default = ["rustls-tls"] +native-tls = ["tokio-tungstenite/native-tls"] +native-tls-vendored = ["native-tls", "tokio-tungstenite/native-tls-vendored"] +rustls-tls = ["tokio-tungstenite/rustls-tls-webpki-roots"] +rustls-tls-native-roots = ["tokio-tungstenite/rustls-tls-native-roots"] diff --git a/plugins/websocket/README.md b/plugins/websocket/README.md index c6ec3d2b..ec5fce9b 100644 --- a/plugins/websocket/README.md +++ b/plugins/websocket/README.md @@ -1,10 +1,18 @@ ![plugin-websocket](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/websocket/banner.png) -Expose a WebSocket server to your Tauri frontend. +Open a WebSocket connection using a Rust client in JS. + +| Platform | Supported | +| -------- | --------- | +| Linux | ✓ | +| Windows | ✓ | +| macOS | ✓ | +| Android | ✓ | +| iOS | ✓ | ## Install -_This plugin requires a Rust version of at least **1.70**_ +_This plugin requires a Rust version of at least **1.77.2**_ There are three general methods of installation that we can recommend. @@ -18,7 +26,7 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] -tauri-plugin-websocket = "2.0.0-alpha" +tauri-plugin-websocket = "2.0.0" # alternatively with Git: tauri-plugin-websocket = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -46,7 +54,7 @@ yarn add https://github.com/tauri-apps/tauri-plugin-websocket#v2 First you need to register the core plugin with Tauri: -`src-tauri/src/main.rs` +`src-tauri/src/lib.rs` ```rust fn main() { @@ -60,19 +68,35 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import WebSocket from "@tauri-apps/plugin-websocket"; +import WebSocket from '@tauri-apps/plugin-websocket' -const ws = await WebSocket.connect("wss://example.com"); +const ws = await WebSocket.connect('wss://example.com') -await ws.send("Hello World"); +await ws.send('Hello World') -await ws.disconnect(); +await ws.disconnect() ``` ## Contributing PRs accepted. Please make sure to read the Contributing Guide before making a pull request. +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + ## License Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. diff --git a/plugins/websocket/SECURITY.md b/plugins/websocket/SECURITY.md new file mode 100644 index 00000000..4f09bbac --- /dev/null +++ b/plugins/websocket/SECURITY.md @@ -0,0 +1,23 @@ +# Security Policy + +**Do not report security vulnerabilities through public GitHub issues.** + +**Please use the [Private Vulnerability Disclosure](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) feature of GitHub.** + +Include as much of the following information: + +- Type of issue (e.g. improper input parsing, privilege escalation, etc.) +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- The distribution affected or used to help us with reproduction of the issue +- Step-by-step instructions to reproduce the issue +- Ideally a reproduction repository +- Impact of the issue, including how an attacker might exploit the issue + +We prefer to receive reports in English. + +## Contact + +Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). + +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/websocket/api-iife.js b/plugins/websocket/api-iife.js new file mode 100644 index 00000000..bcb71df0 --- /dev/null +++ b/plugins/websocket/api-iife.js @@ -0,0 +1 @@ +if("__TAURI__"in window){var __TAURI_PLUGIN_WEBSOCKET__=function(){"use strict";function e(e,t,s,i){if("function"==typeof t||!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?i:"a"===s?i.call(e):i?i.value:t.get(e)}function t(e,t,s,i,n){if("function"==typeof t||!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,s),s}var s,i,n,r;"function"==typeof SuppressedError&&SuppressedError;const a="__TAURI_TO_IPC_KEY__";class o{constructor(a){s.set(this,void 0),i.set(this,0),n.set(this,[]),r.set(this,void 0),t(this,s,a||(()=>{})),this.id=function(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}((a=>{const o=a.index;if("end"in a)return void(o==e(this,i,"f")?this.cleanupCallback():t(this,r,o));const c=a.message;if(o==e(this,i,"f")){for(e(this,s,"f").call(this,c),t(this,i,e(this,i,"f")+1);e(this,i,"f")in e(this,n,"f");){const r=e(this,n,"f")[e(this,i,"f")];e(this,s,"f").call(this,r),delete e(this,n,"f")[e(this,i,"f")],t(this,i,e(this,i,"f")+1)}e(this,i,"f")===e(this,r,"f")&&this.cleanupCallback()}else e(this,n,"f")[o]=c}))}cleanupCallback(){Reflect.deleteProperty(window,`_${this.id}`)}set onmessage(e){t(this,s,e)}get onmessage(){return e(this,s,"f")}[(s=new WeakMap,i=new WeakMap,n=new WeakMap,r=new WeakMap,a)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[a]()}}async function c(e,t={},s){return window.__TAURI_INTERNALS__.invoke(e,t,s)}class h{constructor(e,t){this.id=e,this.listeners=t}static async connect(e,t){const s=new Set,i=new o;return i.onmessage=e=>{s.forEach((t=>{t(e)}))},t?.headers&&(t.headers=Array.from(new Headers(t.headers).entries())),await c("plugin:websocket|connect",{url:e,onMessage:i,config:t}).then((e=>new h(e,s)))}addListener(e){return this.listeners.add(e),()=>{this.listeners.delete(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}}await c("plugin:websocket|send",{id:this.id,message:t})}async disconnect(){await this.send({type:"Close",data:{code:1e3,reason:"Disconnected by client"}})}}return h}();Object.defineProperty(window.__TAURI__,"websocket",{value:__TAURI_PLUGIN_WEBSOCKET__})} diff --git a/plugins/websocket/build.rs b/plugins/websocket/build.rs new file mode 100644 index 00000000..deadb78f --- /dev/null +++ b/plugins/websocket/build.rs @@ -0,0 +1,11 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +const COMMANDS: &[&str] = &["connect", "send"]; + +fn main() { + tauri_plugin::Builder::new(COMMANDS) + .global_api_script_path("./api-iife.js") + .build(); +} diff --git a/plugins/websocket/examples/svelte-app/.gitignore b/plugins/websocket/examples/svelte-app/.gitignore deleted file mode 100644 index 6635cf55..00000000 --- a/plugins/websocket/examples/svelte-app/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -.DS_Store -node_modules -/build -/.svelte-kit -/package -.env -.env.* -!.env.example -vite.config.js.timestamp-* -vite.config.ts.timestamp-* diff --git a/plugins/websocket/examples/svelte-app/package.json b/plugins/websocket/examples/svelte-app/package.json deleted file mode 100644 index 66d842e4..00000000 --- a/plugins/websocket/examples/svelte-app/package.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "svelte-app", - "version": "0.0.1", - "private": true, - "scripts": { - "dev": "vite dev", - "build": "vite build", - "preview": "vite preview", - "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", - "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", - "tauri": "tauri" - }, - "devDependencies": { - "@sveltejs/adapter-static": "2.0.3", - "@sveltejs/kit": "1.26.0", - "@tauri-apps/cli": "2.0.0-alpha.16", - "svelte": "4.2.2", - "svelte-check": "3.5.2", - "tslib": "2.6.2", - "typescript": "5.2.2", - "vite": "4.5.0" - }, - "dependencies": { - "@tauri-apps/plugin-websocket": "link:../../" - }, - "type": "module" -} diff --git a/plugins/websocket/examples/svelte-app/src-tauri/tauri.conf.json b/plugins/websocket/examples/svelte-app/src-tauri/tauri.conf.json deleted file mode 100644 index 205771f4..00000000 --- a/plugins/websocket/examples/svelte-app/src-tauri/tauri.conf.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "build": { - "distDir": "../build", - "devPath": "http://localhost:5173/", - "beforeDevCommand": "pnpm dev", - "beforeBuildCommand": "pnpm build", - "withGlobalTauri": false - }, - "tauri": { - "bundle": { - "active": true, - "targets": "all", - "identifier": "com.tauri.dev", - "icon": [ - "icons/32x32.png", - "icons/128x128.png", - "icons/128x128@2x.png", - "icons/icon.icns", - "icons/icon.ico" - ], - "resources": [], - "externalBin": [], - "copyright": "", - "category": "DeveloperTool", - "shortDescription": "", - "longDescription": "", - "deb": { - "depends": [] - }, - "macOS": { - "frameworks": [], - "minimumSystemVersion": "", - "exceptionDomain": "" - } - }, - "windows": [ - { - "title": "Tauri App", - "width": 800, - "height": 600, - "resizable": true, - "fullscreen": false - } - ], - "security": { - "csp": null - } - } -} diff --git a/plugins/websocket/examples/svelte-app/src/app.d.ts b/plugins/websocket/examples/svelte-app/src/app.d.ts deleted file mode 100644 index caf34f1d..00000000 --- a/plugins/websocket/examples/svelte-app/src/app.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2019-2023 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - -// See https://kit.svelte.dev/docs/types#app -// for information about these interfaces -// and what to do when importing types -declare namespace App { - // interface Error {} - // interface Locals {} - // interface PageData {} - // interface Platform {} -} diff --git a/plugins/websocket/examples/svelte-app/src/app.html b/plugins/websocket/examples/svelte-app/src/app.html deleted file mode 100644 index 73cf3cd3..00000000 --- a/plugins/websocket/examples/svelte-app/src/app.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - %sveltekit.head% - - -
%sveltekit.body%
- - diff --git a/plugins/websocket/examples/svelte-app/src/routes/+page.svelte b/plugins/websocket/examples/svelte-app/src/routes/+page.svelte deleted file mode 100644 index d41d6389..00000000 --- a/plugins/websocket/examples/svelte-app/src/routes/+page.svelte +++ /dev/null @@ -1,44 +0,0 @@ - - -
- - - -
-
{@html response}
diff --git a/plugins/websocket/examples/svelte-app/static/favicon.png b/plugins/websocket/examples/svelte-app/static/favicon.png deleted file mode 100644 index 825b9e65..00000000 Binary files a/plugins/websocket/examples/svelte-app/static/favicon.png and /dev/null differ diff --git a/plugins/websocket/examples/svelte-app/svelte.config.js b/plugins/websocket/examples/svelte-app/svelte.config.js deleted file mode 100644 index 3aae82d7..00000000 --- a/plugins/websocket/examples/svelte-app/svelte.config.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2019-2023 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - -import adapter from "@sveltejs/adapter-static"; -import { vitePreprocess } from "@sveltejs/kit/vite"; - -/** @type {import('@sveltejs/kit').Config} */ -const config = { - // Consult https://kit.svelte.dev/docs/integrations#preprocessors - // for more information about preprocessors - preprocess: vitePreprocess(), - - kit: { - adapter: adapter(), - }, -}; - -export default config; diff --git a/plugins/websocket/examples/svelte-app/tsconfig.json b/plugins/websocket/examples/svelte-app/tsconfig.json deleted file mode 100644 index 794b95b6..00000000 --- a/plugins/websocket/examples/svelte-app/tsconfig.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "extends": "./.svelte-kit/tsconfig.json", - "compilerOptions": { - "allowJs": true, - "checkJs": true, - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "resolveJsonModule": true, - "skipLibCheck": true, - "sourceMap": true, - "strict": true - } - // Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias - // - // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes - // from the referenced tsconfig.json - TypeScript does not merge them in -} diff --git a/plugins/websocket/examples/svelte-app/vite.config.ts b/plugins/websocket/examples/svelte-app/vite.config.ts deleted file mode 100644 index 2b08f961..00000000 --- a/plugins/websocket/examples/svelte-app/vite.config.ts +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2019-2023 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - -import { sveltekit } from "@sveltejs/kit/vite"; -import type { UserConfig } from "vite"; - -const config: UserConfig = { - plugins: [sveltekit()], -}; - -export default config; diff --git a/plugins/websocket/examples/tauri-app/.gitignore b/plugins/websocket/examples/tauri-app/.gitignore new file mode 100644 index 00000000..e030fa6c --- /dev/null +++ b/plugins/websocket/examples/tauri-app/.gitignore @@ -0,0 +1,25 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist/** +!dist/.gitkeep +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/plugins/websocket/examples/tauri-app/dist/.gitkeep b/plugins/websocket/examples/tauri-app/dist/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/plugins/websocket/examples/tauri-app/index.html b/plugins/websocket/examples/tauri-app/index.html new file mode 100644 index 00000000..3f4c7d9a --- /dev/null +++ b/plugins/websocket/examples/tauri-app/index.html @@ -0,0 +1,20 @@ + + + + + + + WebSocket Plugin Example + + +
+
+ + + +
+
+
+ + + diff --git a/plugins/websocket/examples/tauri-app/package.json b/plugins/websocket/examples/tauri-app/package.json new file mode 100644 index 00000000..afa67edf --- /dev/null +++ b/plugins/websocket/examples/tauri-app/package.json @@ -0,0 +1,19 @@ +{ + "name": "tauri-app", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "tsc && vite build", + "preview": "vite preview" + }, + "devDependencies": { + "@tauri-apps/cli": "2.5.0", + "typescript": "^5.7.3", + "vite": "^6.2.6" + }, + "dependencies": { + "tauri-plugin-websocket-api": "link:..\\.." + } +} diff --git a/plugins/websocket/examples/tauri-app/public/vite.svg b/plugins/websocket/examples/tauri-app/public/vite.svg new file mode 100644 index 00000000..e7b8dfb1 --- /dev/null +++ b/plugins/websocket/examples/tauri-app/public/vite.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/plugins/websocket/examples/svelte-app/src-tauri/.gitignore b/plugins/websocket/examples/tauri-app/src-tauri/.gitignore similarity index 90% rename from plugins/websocket/examples/svelte-app/src-tauri/.gitignore rename to plugins/websocket/examples/tauri-app/src-tauri/.gitignore index c10605e5..6bc5d6f4 100644 --- a/plugins/websocket/examples/svelte-app/src-tauri/.gitignore +++ b/plugins/websocket/examples/tauri-app/src-tauri/.gitignore @@ -3,5 +3,7 @@ /target/ WixTools +/gen/schemas + # These are backup files generated by rustfmt **/*.rs.bk diff --git a/plugins/websocket/examples/svelte-app/src-tauri/Cargo.toml b/plugins/websocket/examples/tauri-app/src-tauri/Cargo.toml similarity index 74% rename from plugins/websocket/examples/svelte-app/src-tauri/Cargo.toml rename to plugins/websocket/examples/tauri-app/src-tauri/Cargo.toml index 86ea4c54..3b56008f 100644 --- a/plugins/websocket/examples/svelte-app/src-tauri/Cargo.toml +++ b/plugins/websocket/examples/tauri-app/src-tauri/Cargo.toml @@ -7,14 +7,14 @@ edition = "2021" [dependencies] serde = { workspace = true } serde_json = { workspace = true } -tauri = { workspace = true } +tauri = { workspace = true, features = ["wry", "compression"] } tokio = { version = "1", features = ["net"] } futures-util = "0.3" tauri-plugin-websocket = { path = "../../../" } -tokio-tungstenite = "0.20" +tokio-tungstenite = "0.26" [build-dependencies] tauri-build = { workspace = true } [features] -custom-protocol = [ "tauri/custom-protocol" ] +prod = ["tauri/custom-protocol"] diff --git a/plugins/websocket/examples/svelte-app/src-tauri/build.rs b/plugins/websocket/examples/tauri-app/src-tauri/build.rs similarity index 100% rename from plugins/websocket/examples/svelte-app/src-tauri/build.rs rename to plugins/websocket/examples/tauri-app/src-tauri/build.rs diff --git a/plugins/websocket/examples/svelte-app/src-tauri/icons/128x128.png b/plugins/websocket/examples/tauri-app/src-tauri/icons/128x128.png similarity index 100% rename from plugins/websocket/examples/svelte-app/src-tauri/icons/128x128.png rename to plugins/websocket/examples/tauri-app/src-tauri/icons/128x128.png diff --git a/plugins/websocket/examples/svelte-app/src-tauri/icons/128x128@2x.png b/plugins/websocket/examples/tauri-app/src-tauri/icons/128x128@2x.png similarity index 100% rename from plugins/websocket/examples/svelte-app/src-tauri/icons/128x128@2x.png rename to plugins/websocket/examples/tauri-app/src-tauri/icons/128x128@2x.png diff --git a/plugins/websocket/examples/svelte-app/src-tauri/icons/32x32.png b/plugins/websocket/examples/tauri-app/src-tauri/icons/32x32.png similarity index 100% rename from plugins/websocket/examples/svelte-app/src-tauri/icons/32x32.png rename to plugins/websocket/examples/tauri-app/src-tauri/icons/32x32.png diff --git a/plugins/websocket/examples/svelte-app/src-tauri/icons/Square107x107Logo.png b/plugins/websocket/examples/tauri-app/src-tauri/icons/Square107x107Logo.png similarity index 100% rename from plugins/websocket/examples/svelte-app/src-tauri/icons/Square107x107Logo.png rename to plugins/websocket/examples/tauri-app/src-tauri/icons/Square107x107Logo.png diff --git a/plugins/websocket/examples/svelte-app/src-tauri/icons/Square142x142Logo.png b/plugins/websocket/examples/tauri-app/src-tauri/icons/Square142x142Logo.png similarity index 100% rename from plugins/websocket/examples/svelte-app/src-tauri/icons/Square142x142Logo.png rename to plugins/websocket/examples/tauri-app/src-tauri/icons/Square142x142Logo.png diff --git a/plugins/websocket/examples/svelte-app/src-tauri/icons/Square150x150Logo.png b/plugins/websocket/examples/tauri-app/src-tauri/icons/Square150x150Logo.png similarity index 100% rename from plugins/websocket/examples/svelte-app/src-tauri/icons/Square150x150Logo.png rename to plugins/websocket/examples/tauri-app/src-tauri/icons/Square150x150Logo.png diff --git a/plugins/websocket/examples/svelte-app/src-tauri/icons/Square284x284Logo.png b/plugins/websocket/examples/tauri-app/src-tauri/icons/Square284x284Logo.png similarity index 100% rename from plugins/websocket/examples/svelte-app/src-tauri/icons/Square284x284Logo.png rename to plugins/websocket/examples/tauri-app/src-tauri/icons/Square284x284Logo.png diff --git a/plugins/websocket/examples/svelte-app/src-tauri/icons/Square30x30Logo.png b/plugins/websocket/examples/tauri-app/src-tauri/icons/Square30x30Logo.png similarity index 100% rename from plugins/websocket/examples/svelte-app/src-tauri/icons/Square30x30Logo.png rename to plugins/websocket/examples/tauri-app/src-tauri/icons/Square30x30Logo.png diff --git a/plugins/websocket/examples/svelte-app/src-tauri/icons/Square310x310Logo.png b/plugins/websocket/examples/tauri-app/src-tauri/icons/Square310x310Logo.png similarity index 100% rename from plugins/websocket/examples/svelte-app/src-tauri/icons/Square310x310Logo.png rename to plugins/websocket/examples/tauri-app/src-tauri/icons/Square310x310Logo.png diff --git a/plugins/websocket/examples/svelte-app/src-tauri/icons/Square44x44Logo.png b/plugins/websocket/examples/tauri-app/src-tauri/icons/Square44x44Logo.png similarity index 100% rename from plugins/websocket/examples/svelte-app/src-tauri/icons/Square44x44Logo.png rename to plugins/websocket/examples/tauri-app/src-tauri/icons/Square44x44Logo.png diff --git a/plugins/websocket/examples/svelte-app/src-tauri/icons/Square71x71Logo.png b/plugins/websocket/examples/tauri-app/src-tauri/icons/Square71x71Logo.png similarity index 100% rename from plugins/websocket/examples/svelte-app/src-tauri/icons/Square71x71Logo.png rename to plugins/websocket/examples/tauri-app/src-tauri/icons/Square71x71Logo.png diff --git a/plugins/websocket/examples/svelte-app/src-tauri/icons/Square89x89Logo.png b/plugins/websocket/examples/tauri-app/src-tauri/icons/Square89x89Logo.png similarity index 100% rename from plugins/websocket/examples/svelte-app/src-tauri/icons/Square89x89Logo.png rename to plugins/websocket/examples/tauri-app/src-tauri/icons/Square89x89Logo.png diff --git a/plugins/websocket/examples/svelte-app/src-tauri/icons/StoreLogo.png b/plugins/websocket/examples/tauri-app/src-tauri/icons/StoreLogo.png similarity index 100% rename from plugins/websocket/examples/svelte-app/src-tauri/icons/StoreLogo.png rename to plugins/websocket/examples/tauri-app/src-tauri/icons/StoreLogo.png diff --git a/plugins/websocket/examples/svelte-app/src-tauri/icons/icon.icns b/plugins/websocket/examples/tauri-app/src-tauri/icons/icon.icns similarity index 100% rename from plugins/websocket/examples/svelte-app/src-tauri/icons/icon.icns rename to plugins/websocket/examples/tauri-app/src-tauri/icons/icon.icns diff --git a/plugins/websocket/examples/svelte-app/src-tauri/icons/icon.ico b/plugins/websocket/examples/tauri-app/src-tauri/icons/icon.ico similarity index 100% rename from plugins/websocket/examples/svelte-app/src-tauri/icons/icon.ico rename to plugins/websocket/examples/tauri-app/src-tauri/icons/icon.ico diff --git a/plugins/websocket/examples/svelte-app/src-tauri/icons/icon.png b/plugins/websocket/examples/tauri-app/src-tauri/icons/icon.png similarity index 100% rename from plugins/websocket/examples/svelte-app/src-tauri/icons/icon.png rename to plugins/websocket/examples/tauri-app/src-tauri/icons/icon.png diff --git a/plugins/websocket/examples/svelte-app/src-tauri/rustfmt.toml b/plugins/websocket/examples/tauri-app/src-tauri/rustfmt.toml similarity index 100% rename from plugins/websocket/examples/svelte-app/src-tauri/rustfmt.toml rename to plugins/websocket/examples/tauri-app/src-tauri/rustfmt.toml diff --git a/plugins/websocket/examples/svelte-app/src-tauri/src/main.rs b/plugins/websocket/examples/tauri-app/src-tauri/src/main.rs similarity index 100% rename from plugins/websocket/examples/svelte-app/src-tauri/src/main.rs rename to plugins/websocket/examples/tauri-app/src-tauri/src/main.rs diff --git a/plugins/websocket/examples/tauri-app/src-tauri/tauri.conf.json b/plugins/websocket/examples/tauri-app/src-tauri/tauri.conf.json new file mode 100644 index 00000000..6647b5e6 --- /dev/null +++ b/plugins/websocket/examples/tauri-app/src-tauri/tauri.conf.json @@ -0,0 +1,34 @@ +{ + "identifier": "com.tauri.dev", + "build": { + "devUrl": "http://localhost:5173/", + "frontendDist": "../dist", + "beforeDevCommand": "pnpm dev", + "beforeBuildCommand": "pnpm build" + }, + "app": { + "windows": [ + { + "title": "Tauri App", + "width": 800, + "height": 600, + "resizable": true, + "fullscreen": false + } + ], + "security": { + "csp": null + } + }, + "bundle": { + "active": true, + "targets": "all", + "icon": [ + "icons/32x32.png", + "icons/128x128.png", + "icons/128x128@2x.png", + "icons/icon.icns", + "icons/icon.ico" + ] + } +} diff --git a/plugins/websocket/examples/tauri-app/src/main.ts b/plugins/websocket/examples/tauri-app/src/main.ts new file mode 100644 index 00000000..05fecfe8 --- /dev/null +++ b/plugins/websocket/examples/tauri-app/src/main.ts @@ -0,0 +1,58 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import WebSocket from 'tauri-plugin-websocket-api' +import './style.css' + +let ws: WebSocket + +document.addEventListener('DOMContentLoaded', async () => { + document.querySelector('#send')?.addEventListener('click', send) + document.querySelector('#disconnect')?.addEventListener('click', disconnect) + await connect() +}) + +function _updateResponse(returnValue: unknown) { + const msg = document.createElement('p') + msg.textContent = + typeof returnValue === 'string' ? returnValue : JSON.stringify(returnValue) + document.querySelector('#response-container')?.appendChild(msg) +} + +async function connect() { + try { + ws = await WebSocket.connect('ws://127.0.0.1:8080').then((r) => { + _updateResponse('Connected') + return r + }) + } catch (e) { + _updateResponse(e) + } + ws.addListener(_updateResponse) +} + +function send() { + ws.send(document.querySelector('#msg-input')?.textContent || '') + .then(() => { + _updateResponse('Message sent') + }) + .catch(_updateResponse) +} + +function disconnect() { + ws.disconnect() + .then(() => { + _updateResponse('Disconnected') + }) + .catch(_updateResponse) +} + +document.querySelector('#app')!.innerHTML = ` +
+ + + +
+
+` diff --git a/plugins/websocket/examples/svelte-app/static/global.css b/plugins/websocket/examples/tauri-app/src/style.css similarity index 82% rename from plugins/websocket/examples/svelte-app/static/global.css rename to plugins/websocket/examples/tauri-app/src/style.css index d8d4fb96..04e208d3 100644 --- a/plugins/websocket/examples/svelte-app/static/global.css +++ b/plugins/websocket/examples/tauri-app/src/style.css @@ -10,8 +10,9 @@ body { margin: 0; padding: 8px; box-sizing: border-box; - font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, - Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; + font-family: + -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, + Cantarell, 'Helvetica Neue', sans-serif; } a { @@ -66,3 +67,7 @@ button:not(:disabled):active { button:focus { border-color: #666; } + +p { + margin: 3px 0; +} diff --git a/plugins/websocket/examples/tauri-app/src/typescript.svg b/plugins/websocket/examples/tauri-app/src/typescript.svg new file mode 100644 index 00000000..d91c910c --- /dev/null +++ b/plugins/websocket/examples/tauri-app/src/typescript.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/plugins/websocket/examples/tauri-app/src/vite-env.d.ts b/plugins/websocket/examples/tauri-app/src/vite-env.d.ts new file mode 100644 index 00000000..044b89cc --- /dev/null +++ b/plugins/websocket/examples/tauri-app/src/vite-env.d.ts @@ -0,0 +1,5 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +/// diff --git a/plugins/websocket/examples/tauri-app/tsconfig.json b/plugins/websocket/examples/tauri-app/tsconfig.json new file mode 100644 index 00000000..75abdef2 --- /dev/null +++ b/plugins/websocket/examples/tauri-app/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "module": "ESNext", + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src"] +} diff --git a/plugins/websocket/guest-js/index.ts b/plugins/websocket/guest-js/index.ts index 13774f4a..7ea7b326 100644 --- a/plugins/websocket/guest-js/index.ts +++ b/plugins/websocket/guest-js/index.ts @@ -2,91 +2,127 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { invoke, Channel } from "@tauri-apps/api/primitives"; +import { invoke, Channel } from '@tauri-apps/api/core' export interface ConnectionConfig { - writeBufferSize?: number; - maxWriteBufferSize?: number; - maxMessageSize?: number; - maxFrameSize?: number; - acceptUnmaskedFrames?: boolean; - headers?: HeadersInit; + /** + * Read buffer capacity. The default value is 128 KiB. + */ + readBufferSize?: number + /** The target minimum size of the write buffer to reach before writing the data to the underlying stream. The default value is 128 KiB. + * + * If set to 0 each message will be eagerly written to the underlying stream. It is often more optimal to allow them to buffer a little, hence the default value. + */ + writeBufferSize?: number + /** The max size of the write buffer in bytes. Setting this can provide backpressure in the case the write buffer is filling up due to write errors. The default value is unlimited. + * + * Note: The write buffer only builds up past write_buffer_size when writes to the underlying stream are failing. So the write buffer can not fill up if you are not observing write errors. + * + * Note: Should always be at least write_buffer_size + 1 message and probably a little more depending on error handling strategy. + */ + maxWriteBufferSize?: number + /** + * The maximum size of an incoming message. The string "none" means no size limit. The default value is 64 MiB which should be reasonably big for all normal use-cases but small enough to prevent memory eating by a malicious user. + */ + maxMessageSize?: number | 'none' + /** + * The maximum size of a single incoming message frame. The string "none" means no size limit. The limit is for frame payload NOT including the frame header. The default value is 16 MiB which should be reasonably big for all normal use-cases but small enough to prevent memory eating by a malicious user. + */ + maxFrameSize?: number | 'none' + /** + * When set to true, the server will accept and handle unmasked frames from the client. According to the RFC 6455, the server must close the connection to the client in such cases, however it seems like there are some popular libraries that are sending unmasked frames, ignoring the RFC. By default this option is set to false, i.e. according to RFC 6455. + */ + acceptUnmaskedFrames?: boolean + /** + * Additional connect request headers. + */ + headers?: HeadersInit } export interface MessageKind { - type: T; - data: D; + type: T + data: D } export interface CloseFrame { - code: number; - reason: string; + code: number + reason: string } export type Message = - | MessageKind<"Text", string> - | MessageKind<"Binary", number[]> - | MessageKind<"Ping", number[]> - | MessageKind<"Pong", number[]> - | MessageKind<"Close", CloseFrame | null>; + | MessageKind<'Text', string> + | MessageKind<'Binary', number[]> + | MessageKind<'Ping', number[]> + | MessageKind<'Pong', number[]> + | MessageKind<'Close', CloseFrame | null> export default class WebSocket { - id: number; - private readonly listeners: Array<(arg: Message) => void>; + id: number + private readonly listeners: Set<(arg: Message) => void> - constructor(id: number, listeners: Array<(arg: Message) => void>) { - this.id = id; - this.listeners = listeners; + constructor(id: number, listeners: Set<(arg: Message) => void>) { + this.id = id + this.listeners = listeners } static async connect( url: string, - config?: ConnectionConfig, + config?: ConnectionConfig ): Promise { - const listeners: Array<(arg: Message) => void> = []; + const listeners: Set<(arg: Message) => void> = new Set() - const onMessage = new Channel(); + const onMessage = new Channel() onMessage.onmessage = (message: Message): void => { - listeners.forEach((l) => l(message)); - }; + listeners.forEach((l) => { + l(message) + }) + } + + if (config?.headers) { + config.headers = Array.from(new Headers(config.headers).entries()) + } - return await invoke("plugin:websocket|connect", { + return await invoke('plugin:websocket|connect', { url, onMessage, - config, - }).then((id) => new WebSocket(id, listeners)); + config + }).then((id) => new WebSocket(id, listeners)) } - addListener(cb: (arg: Message) => void): void { - this.listeners.push(cb); + addListener(cb: (arg: Message) => void): () => void { + this.listeners.add(cb) + + return () => { + this.listeners.delete(cb) + } } async send(message: Message | string | number[]): Promise { - let m: Message; - if (typeof message === "string") { - m = { type: "Text", data: message }; - } else if (typeof message === "object" && "type" in message) { - m = message; + let m: Message + if (typeof message === 'string') { + m = { type: 'Text', data: message } + } else if (typeof message === 'object' && 'type' in message) { + m = message } else if (Array.isArray(message)) { - m = { type: "Binary", data: message }; + m = { type: 'Binary', data: message } } else { throw new Error( - "invalid `message` type, expected a `{ type: string, data: any }` object, a string or a numeric array", - ); + 'invalid `message` type, expected a `{ type: string, data: any }` object, a string or a numeric array' + ) } - return await invoke("plugin:websocket|send", { + await invoke('plugin:websocket|send', { id: this.id, - message: m, - }); + message: m + }) } async disconnect(): Promise { - return await this.send({ - type: "Close", + await this.send({ + type: 'Close', data: { code: 1000, - reason: "Disconnected by client", - }, - }); + reason: 'Disconnected by client' + } + }) } } diff --git a/plugins/websocket/package.json b/plugins/websocket/package.json index 5fe7b09e..e6496faa 100644 --- a/plugins/websocket/package.json +++ b/plugins/websocket/package.json @@ -1,32 +1,29 @@ { "name": "@tauri-apps/plugin-websocket", - "version": "2.0.0-alpha.1", - "license": "MIT or APACHE-2.0", + "version": "2.3.0", + "license": "MIT OR Apache-2.0", "authors": [ "Tauri Programme within The Commons Conservancy" ], + "repository": "https://github.com/tauri-apps/plugins-workspace", "type": "module", - "browser": "dist-js/index.min.js", - "module": "dist-js/index.mjs", - "types": "dist-js/index.d.ts", + "types": "./dist-js/index.d.ts", + "main": "./dist-js/index.cjs", + "module": "./dist-js/index.js", "exports": { - "import": "./dist-js/index.mjs", "types": "./dist-js/index.d.ts", - "browser": "./dist-js/index.min.js" + "import": "./dist-js/index.js", + "require": "./dist-js/index.cjs" }, "scripts": { "build": "rollup -c" }, "files": [ "dist-js", - "!dist-js/**/*.map", "README.md", "LICENSE" ], - "devDependencies": { - "tslib": "2.6.0" - }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.9" + "@tauri-apps/api": "^2.0.0" } } diff --git a/plugins/websocket/permissions/autogenerated/commands/connect.toml b/plugins/websocket/permissions/autogenerated/commands/connect.toml new file mode 100644 index 00000000..49ce9ad3 --- /dev/null +++ b/plugins/websocket/permissions/autogenerated/commands/connect.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-connect" +description = "Enables the connect command without any pre-configured scope." +commands.allow = ["connect"] + +[[permission]] +identifier = "deny-connect" +description = "Denies the connect command without any pre-configured scope." +commands.deny = ["connect"] diff --git a/plugins/websocket/permissions/autogenerated/commands/send.toml b/plugins/websocket/permissions/autogenerated/commands/send.toml new file mode 100644 index 00000000..a7bac8f5 --- /dev/null +++ b/plugins/websocket/permissions/autogenerated/commands/send.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-send" +description = "Enables the send command without any pre-configured scope." +commands.allow = ["send"] + +[[permission]] +identifier = "deny-send" +description = "Denies the send command without any pre-configured scope." +commands.deny = ["send"] diff --git a/plugins/websocket/permissions/autogenerated/reference.md b/plugins/websocket/permissions/autogenerated/reference.md new file mode 100644 index 00000000..e86cedcb --- /dev/null +++ b/plugins/websocket/permissions/autogenerated/reference.md @@ -0,0 +1,70 @@ +## Default Permission + +Allows connecting and sending data to a WebSocket server + +#### This default permission set includes the following: + +- `allow-connect` +- `allow-send` + +## Permission Table + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IdentifierDescription
+ +`websocket:allow-connect` + + + +Enables the connect command without any pre-configured scope. + +
+ +`websocket:deny-connect` + + + +Denies the connect command without any pre-configured scope. + +
+ +`websocket:allow-send` + + + +Enables the send command without any pre-configured scope. + +
+ +`websocket:deny-send` + + + +Denies the send command without any pre-configured scope. + +
diff --git a/plugins/websocket/permissions/default.toml b/plugins/websocket/permissions/default.toml new file mode 100644 index 00000000..5fc8962b --- /dev/null +++ b/plugins/websocket/permissions/default.toml @@ -0,0 +1,4 @@ +"$schema" = "schemas/schema.json" +[default] +description = "Allows connecting and sending data to a WebSocket server" +permissions = ["allow-connect", "allow-send"] diff --git a/plugins/websocket/permissions/schemas/schema.json b/plugins/websocket/permissions/schemas/schema.json new file mode 100644 index 00000000..e0c9a4af --- /dev/null +++ b/plugins/websocket/permissions/schemas/schema.json @@ -0,0 +1,330 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "PermissionFile", + "description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.", + "type": "object", + "properties": { + "default": { + "description": "The default permission set for the plugin", + "anyOf": [ + { + "$ref": "#/definitions/DefaultPermission" + }, + { + "type": "null" + } + ] + }, + "set": { + "description": "A list of permissions sets defined", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionSet" + } + }, + "permission": { + "description": "A list of inlined permissions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Permission" + } + } + }, + "definitions": { + "DefaultPermission": { + "description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.", + "type": "object", + "required": [ + "permissions" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "PermissionSet": { + "description": "A set of direct permissions grouped together under a new name.", + "type": "object", + "required": [ + "description", + "identifier", + "permissions" + ], + "properties": { + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does.", + "type": "string" + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionKind" + } + } + } + }, + "Permission": { + "description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.", + "type": "object", + "required": [ + "identifier" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri internal convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "commands": { + "description": "Allowed or denied commands when using this permission.", + "default": { + "allow": [], + "deny": [] + }, + "allOf": [ + { + "$ref": "#/definitions/Commands" + } + ] + }, + "scope": { + "description": "Allowed or denied scoped when using this permission.", + "allOf": [ + { + "$ref": "#/definitions/Scopes" + } + ] + }, + "platforms": { + "description": "Target platforms this permission applies. By default all platforms are affected by this permission.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Target" + } + } + } + }, + "Commands": { + "description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.", + "type": "object", + "properties": { + "allow": { + "description": "Allowed command.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "deny": { + "description": "Denied command, which takes priority.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "Scopes": { + "description": "An argument for fine grained behavior control of Tauri commands.\n\nIt can be of any serde serializable type and is used to allow or prevent certain actions inside a Tauri command. The configured scope is passed to the command and will be enforced by the command implementation.\n\n## Example\n\n```json { \"allow\": [{ \"path\": \"$HOME/**\" }], \"deny\": [{ \"path\": \"$HOME/secret.txt\" }] } ```", + "type": "object", + "properties": { + "allow": { + "description": "Data that defines what is allowed by the scope.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + }, + "deny": { + "description": "Data that defines what is denied by the scope. This should be prioritized by validation logic.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + } + } + }, + "Value": { + "description": "All supported ACL values.", + "anyOf": [ + { + "description": "Represents a null JSON value.", + "type": "null" + }, + { + "description": "Represents a [`bool`].", + "type": "boolean" + }, + { + "description": "Represents a valid ACL [`Number`].", + "allOf": [ + { + "$ref": "#/definitions/Number" + } + ] + }, + { + "description": "Represents a [`String`].", + "type": "string" + }, + { + "description": "Represents a list of other [`Value`]s.", + "type": "array", + "items": { + "$ref": "#/definitions/Value" + } + }, + { + "description": "Represents a map of [`String`] keys to [`Value`]s.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/Value" + } + } + ] + }, + "Number": { + "description": "A valid ACL number.", + "anyOf": [ + { + "description": "Represents an [`i64`].", + "type": "integer", + "format": "int64" + }, + { + "description": "Represents a [`f64`].", + "type": "number", + "format": "double" + } + ] + }, + "Target": { + "description": "Platform target.", + "oneOf": [ + { + "description": "MacOS.", + "type": "string", + "enum": [ + "macOS" + ] + }, + { + "description": "Windows.", + "type": "string", + "enum": [ + "windows" + ] + }, + { + "description": "Linux.", + "type": "string", + "enum": [ + "linux" + ] + }, + { + "description": "Android.", + "type": "string", + "enum": [ + "android" + ] + }, + { + "description": "iOS.", + "type": "string", + "enum": [ + "iOS" + ] + } + ] + }, + "PermissionKind": { + "type": "string", + "oneOf": [ + { + "description": "Enables the connect command without any pre-configured scope.", + "type": "string", + "const": "allow-connect", + "markdownDescription": "Enables the connect command without any pre-configured scope." + }, + { + "description": "Denies the connect command without any pre-configured scope.", + "type": "string", + "const": "deny-connect", + "markdownDescription": "Denies the connect command without any pre-configured scope." + }, + { + "description": "Enables the send command without any pre-configured scope.", + "type": "string", + "const": "allow-send", + "markdownDescription": "Enables the send command without any pre-configured scope." + }, + { + "description": "Denies the send command without any pre-configured scope.", + "type": "string", + "const": "deny-send", + "markdownDescription": "Denies the send command without any pre-configured scope." + }, + { + "description": "Allows connecting and sending data to a WebSocket server\n#### This default permission set includes:\n\n- `allow-connect`\n- `allow-send`", + "type": "string", + "const": "default", + "markdownDescription": "Allows connecting and sending data to a WebSocket server\n#### This default permission set includes:\n\n- `allow-connect`\n- `allow-send`" + } + ] + } + } +} \ No newline at end of file diff --git a/plugins/websocket/rollup.config.js b/plugins/websocket/rollup.config.js new file mode 100644 index 00000000..1f349ec8 --- /dev/null +++ b/plugins/websocket/rollup.config.js @@ -0,0 +1,7 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import { createConfig } from '../../shared/rollup.config.js' + +export default createConfig() diff --git a/plugins/websocket/rollup.config.mjs b/plugins/websocket/rollup.config.mjs deleted file mode 100644 index 99a3dd31..00000000 --- a/plugins/websocket/rollup.config.mjs +++ /dev/null @@ -1,11 +0,0 @@ -import { readFileSync } from "fs"; - -import { createConfig } from "../../shared/rollup.config.mjs"; - -export default createConfig({ - input: "guest-js/index.ts", - pkg: JSON.parse( - readFileSync(new URL("./package.json", import.meta.url), "utf8"), - ), - external: [/^@tauri-apps\/api/], -}); diff --git a/plugins/websocket/src/api-iife.js b/plugins/websocket/src/api-iife.js deleted file mode 100644 index 1e89a84f..00000000 --- a/plugins/websocket/src/api-iife.js +++ /dev/null @@ -1 +0,0 @@ -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__})} diff --git a/plugins/websocket/src/lib.rs b/plugins/websocket/src/lib.rs index a738dc27..f75817b6 100644 --- a/plugins/websocket/src/lib.rs +++ b/plugins/websocket/src/lib.rs @@ -2,9 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -//! [![](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/websocket/banner.png)](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/websocket) -//! -//! Expose a WebSocket server to your Tauri frontend. +//! Open a WebSocket connection using a Rust client in JS. #![doc( html_logo_url = "https://github.com/tauri-apps/tauri/raw/dev/app-icon.png", @@ -12,6 +10,7 @@ )] use futures_util::{stream::SplitSink, SinkExt, StreamExt}; +use http::header::{HeaderName, HeaderValue}; use serde::{ser::Serializer, Deserialize, Serialize}; use tauri::{ ipc::Channel, @@ -19,16 +18,21 @@ use tauri::{ Manager, Runtime, State, Window, }; use tokio::{net::TcpStream, sync::Mutex}; +#[cfg(any(feature = "rustls-tls", feature = "native-tls"))] +use tokio_tungstenite::connect_async_tls_with_config; +#[cfg(not(any(feature = "rustls-tls", feature = "native-tls")))] +use tokio_tungstenite::connect_async_with_config; use tokio_tungstenite::{ - connect_async_with_config, tungstenite::{ + client::IntoClientRequest, protocol::{CloseFrame as ProtocolCloseFrame, WebSocketConfig}, Message, }, - MaybeTlsStream, WebSocketStream, + Connector, MaybeTlsStream, WebSocketStream, }; use std::collections::HashMap; +use std::str::FromStr; type Id = u32; type WebSocket = WebSocketStream>; @@ -41,6 +45,10 @@ enum Error { Websocket(#[from] tokio_tungstenite::tungstenite::Error), #[error("connection not found for the given id: {0}")] ConnectionNotFound(Id), + #[error(transparent)] + InvalidHeaderValue(#[from] tokio_tungstenite::tungstenite::http::header::InvalidHeaderValue), + #[error(transparent)] + InvalidHeaderName(#[from] tokio_tungstenite::tungstenite::http::header::InvalidHeaderName), } impl Serialize for Error { @@ -55,13 +63,24 @@ impl Serialize for Error { #[derive(Default)] struct ConnectionManager(Mutex>); +#[cfg(any(feature = "rustls-tls", feature = "native-tls"))] +struct TlsConnector(Mutex>); + +#[derive(Deserialize)] +#[serde(untagged, rename_all = "camelCase")] +enum Max { + None, + Number(usize), +} + #[derive(Deserialize)] #[serde(rename_all = "camelCase")] -pub struct ConnectionConfig { +pub(crate) struct ConnectionConfig { + pub read_buffer_size: Option, pub write_buffer_size: Option, pub max_write_buffer_size: Option, - pub max_message_size: Option, - pub max_frame_size: Option, + pub max_message_size: Option, + pub max_frame_size: Option, #[serde(default)] pub accept_unmasked_frames: bool, pub headers: Option>, @@ -69,18 +88,38 @@ pub struct ConnectionConfig { impl From for WebSocketConfig { fn from(config: ConnectionConfig) -> Self { - // Disabling the warning on max_send_queue which we don't use anymore since it was deprecated. - #[allow(deprecated)] - Self { - max_send_queue: None, - write_buffer_size: config.write_buffer_size.unwrap_or(128 * 1024), - max_write_buffer_size: config.max_write_buffer_size.unwrap_or(usize::MAX), - // This may be harmful since if it's not provided from js we're overwriting the default value with None, meaning no size limit. - max_message_size: config.max_message_size, - // This may be harmful since if it's not provided from js we're overwriting the default value with None, meaning no size limit. - max_frame_size: config.max_frame_size, - accept_unmasked_frames: config.accept_unmasked_frames, + let mut builder = + WebSocketConfig::default().accept_unmasked_frames(config.accept_unmasked_frames); + + if let Some(read_buffer_size) = config.read_buffer_size { + builder = builder.read_buffer_size(read_buffer_size) + } + + if let Some(write_buffer_size) = config.write_buffer_size { + builder = builder.write_buffer_size(write_buffer_size) } + + if let Some(max_write_buffer_size) = config.max_write_buffer_size { + builder = builder.max_write_buffer_size(max_write_buffer_size) + } + + if let Some(max_message_size) = config.max_message_size { + let max_size = match max_message_size { + Max::None => Option::None, + Max::Number(n) => Some(n), + }; + builder = builder.max_message_size(max_size); + } + + if let Some(max_frame_size) = config.max_frame_size { + let max_size = match max_frame_size { + Max::None => Option::None, + Max::Number(n) => Some(n), + }; + builder = builder.max_frame_size(max_size); + } + + builder } } @@ -104,11 +143,32 @@ enum WebSocketMessage { async fn connect( window: Window, url: String, - on_message: Channel, + on_message: Channel, config: Option, ) -> Result { let id = rand::random(); - let (ws_stream, _) = connect_async_with_config(url, config.map(Into::into), false).await?; + let mut request = url.into_client_request()?; + + if let Some(headers) = config.as_ref().and_then(|c| c.headers.as_ref()) { + for (k, v) in headers { + let header_name = HeaderName::from_str(k.as_str())?; + let header_value = HeaderValue::from_str(v.as_str())?; + request.headers_mut().insert(header_name, header_value); + } + } + + #[cfg(any(feature = "rustls-tls", feature = "native-tls"))] + let tls_connector = match window.try_state::() { + Some(tls_connector) => tls_connector.0.lock().await.clone(), + None => None, + }; + + #[cfg(any(feature = "rustls-tls", feature = "native-tls"))] + let (ws_stream, _) = + connect_async_tls_with_config(request, config.map(Into::into), false, tls_connector) + .await?; + #[cfg(not(any(feature = "rustls-tls", feature = "native-tls")))] + let (ws_stream, _) = connect_async_with_config(request, config.map(Into::into), false).await?; tauri::async_runtime::spawn(async move { let (write, read) = ws_stream.split(); @@ -125,21 +185,21 @@ async fn connect( let response = match message { Ok(Message::Text(t)) => { - serde_json::to_value(WebSocketMessage::Text(t)).unwrap() + serde_json::to_value(WebSocketMessage::Text(t.to_string())).unwrap() } Ok(Message::Binary(t)) => { - serde_json::to_value(WebSocketMessage::Binary(t)).unwrap() + serde_json::to_value(WebSocketMessage::Binary(t.to_vec())).unwrap() } Ok(Message::Ping(t)) => { - serde_json::to_value(WebSocketMessage::Ping(t)).unwrap() + serde_json::to_value(WebSocketMessage::Ping(t.to_vec())).unwrap() } Ok(Message::Pong(t)) => { - serde_json::to_value(WebSocketMessage::Pong(t)).unwrap() + serde_json::to_value(WebSocketMessage::Pong(t.to_vec())).unwrap() } Ok(Message::Close(t)) => { serde_json::to_value(WebSocketMessage::Close(t.map(|v| CloseFrame { code: v.code.into(), - reason: v.reason.into_owned(), + reason: v.reason.to_string(), }))) .unwrap() } @@ -165,13 +225,13 @@ async fn send( if let Some(write) = manager.0.lock().await.get_mut(&id) { write .send(match message { - WebSocketMessage::Text(t) => Message::Text(t), - WebSocketMessage::Binary(t) => Message::Binary(t), - WebSocketMessage::Ping(t) => Message::Ping(t), - WebSocketMessage::Pong(t) => Message::Pong(t), + WebSocketMessage::Text(t) => Message::Text(t.into()), + WebSocketMessage::Binary(t) => Message::Binary(t.into()), + WebSocketMessage::Ping(t) => Message::Ping(t.into()), + WebSocketMessage::Pong(t) => Message::Pong(t.into()), WebSocketMessage::Close(t) => Message::Close(t.map(|v| ProtocolCloseFrame { code: v.code.into(), - reason: std::borrow::Cow::Owned(v.reason), + reason: v.reason.into(), })), }) .await?; @@ -182,12 +242,35 @@ async fn send( } pub fn init() -> TauriPlugin { - PluginBuilder::new("websocket") - .js_init_script(include_str!("api-iife.js").to_string()) - .invoke_handler(tauri::generate_handler![connect, send]) - .setup(|app, _api| { - app.manage(ConnectionManager::default()); - Ok(()) - }) - .build() + Builder::default().build() +} + +#[derive(Default)] +pub struct Builder { + tls_connector: Option, +} + +impl Builder { + pub fn new() -> Self { + Self { + tls_connector: None, + } + } + + pub fn tls_connector(mut self, connector: Connector) -> Self { + self.tls_connector.replace(connector); + self + } + + pub fn build(self) -> TauriPlugin { + PluginBuilder::new("websocket") + .invoke_handler(tauri::generate_handler![connect, send]) + .setup(|app, _api| { + app.manage(ConnectionManager::default()); + #[cfg(any(feature = "rustls-tls", feature = "native-tls"))] + app.manage(TlsConnector(Mutex::new(self.tls_connector))); + Ok(()) + }) + .build() + } } diff --git a/plugins/window-state/.gitignore b/plugins/window-state/.gitignore deleted file mode 100644 index 3c3629e6..00000000 --- a/plugins/window-state/.gitignore +++ /dev/null @@ -1 +0,0 @@ -node_modules diff --git a/plugins/window-state/CHANGELOG.md b/plugins/window-state/CHANGELOG.md index 021cb42a..cfd02a55 100644 --- a/plugins/window-state/CHANGELOG.md +++ b/plugins/window-state/CHANGELOG.md @@ -1,5 +1,132 @@ # Changelog +## \[2.2.2] + +- [`a35fea50`](https://github.com/tauri-apps/plugins-workspace/commit/a35fea501560a3d126aad09b59600d9f1a731a9e) ([#2583](https://github.com/tauri-apps/plugins-workspace/pull/2583)) Fix window size gets bigger/smaller on secondary monitor with a different scaling than the primary one + +## \[2.2.1] + +- [`0ec895c3`](https://github.com/tauri-apps/plugins-workspace/commit/0ec895c378d4700cf8d7a002c6d9829f3c015b9f) ([#2330](https://github.com/tauri-apps/plugins-workspace/pull/2330) by [@thewh1teagle](https://github.com/tauri-apps/plugins-workspace/../../thewh1teagle)) Add `Builder::with_filter` callback to exclude specific windows from saving their state. This allows for more flexibility by enabling dynamic exclusion of windows based on custom logic. + +## \[2.2.0] + +- [`3a79266b`](https://github.com/tauri-apps/plugins-workspace/commit/3a79266b8cf96a55b1ae6339d725567d45a44b1d) ([#2173](https://github.com/tauri-apps/plugins-workspace/pull/2173) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Bumped all plugins to `v2.2.0`. From now, the versions for the Rust and JavaScript packages of each plugin will be in sync with each other. + +## \[2.0.2] + +- [`cfb3ec0e`](https://github.com/tauri-apps/plugins-workspace/commit/cfb3ec0e21cab8010fbc1d7ef82aa65d86c3cfa9) ([#2007](https://github.com/tauri-apps/plugins-workspace/pull/2007) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) On macOS the plugin now (temporarily) ignores the maximized state for undecorated windows on resize events to fix app freezes. + +## \[2.0.1] + +- [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. + +## \[2.0.0] + +- [`e2c4dfb6`](https://github.com/tauri-apps/plugins-workspace/commit/e2c4dfb6af43e5dd8d9ceba232c315f5febd55c1) Update to tauri v2 stable release. + +## \[2.0.0-rc.5] + +- [`7a37355e`](https://github.com/tauri-apps/plugins-workspace/commit/7a37355e177772cbddf24397d5a23280e00558af) ([#1787](https://github.com/tauri-apps/plugins-workspace/pull/1787) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Fix deadlock when trying to restore window states on initial load + +## \[2.0.0-rc.4] + +- [`204e5aac`](https://github.com/tauri-apps/plugins-workspace/commit/204e5aacad7e8f99a9a08f4a45cfed83643c1cc0) ([#1743](https://github.com/tauri-apps/plugins-workspace/pull/1743)) Fix can't restore a minimized window's size and position properly + +### breaking + +- [`204e5aac`](https://github.com/tauri-apps/plugins-workspace/commit/204e5aacad7e8f99a9a08f4a45cfed83643c1cc0) ([#1743](https://github.com/tauri-apps/plugins-workspace/pull/1743)) Window's size is now stored in physical size instead of logical size + +## \[2.0.0-rc.3] + +- [`17e8014b`](https://github.com/tauri-apps/plugins-workspace/commit/17e8014b6993602ddad21e8f5dcb625de1eea2c0) ([#1702](https://github.com/tauri-apps/plugins-workspace/pull/1702) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Fix saving a minimized window's state changes its position to -32000 + +## \[2.0.0-rc.1] + +- [`e2e97db5`](https://github.com/tauri-apps/plugins-workspace/commit/e2e97db51983267f5be84d4f6f0278d58834d1f5) ([#1701](https://github.com/tauri-apps/plugins-workspace/pull/1701) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri 2.0.0-rc.8 + +## \[2.0.0-rc.1] + +- [`2c00c029`](https://github.com/tauri-apps/plugins-workspace/commit/2c00c0292c9127b81567de46691e8c0f73557261) ([#1630](https://github.com/tauri-apps/plugins-workspace/pull/1630) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Fixed an issue that caused multi-word IIFE names to not be formatted correctly. For example the `barcode-scanner` was defined as `window.__TAURI_PLUGIN_CLIPBOARDMANAGER__` instead of `window.__TAURI_PLUGIN_CLIPBOARD_MANAGER__`. + +## \[2.0.0-rc.0] + +- [`9887d1`](https://github.com/tauri-apps/plugins-workspace/commit/9887d14bd0e971c4c0f5c1188fc4005d3fc2e29e) Update to tauri RC. + +## \[2.0.0-beta.9] + +- [`99d6ac0f`](https://github.com/tauri-apps/plugins-workspace/commit/99d6ac0f9506a6a4a1aa59c728157190a7441af6) ([#1606](https://github.com/tauri-apps/plugins-workspace/pull/1606) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) The JS packages now specify the *minimum* `@tauri-apps/api` version instead of a single exact version. +- [`6de87966`](https://github.com/tauri-apps/plugins-workspace/commit/6de87966ecc00ad9d91c25be452f1f46bd2b7e1f) ([#1597](https://github.com/tauri-apps/plugins-workspace/pull/1597) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Update to tauri beta.25. + +## \[2.0.0-beta.8] + +- [`22a17980`](https://github.com/tauri-apps/plugins-workspace/commit/22a17980ff4f6f8c40adb1b8f4ffc6dae2fe7e30) ([#1537](https://github.com/tauri-apps/plugins-workspace/pull/1537) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri beta.24. + +## \[2.0.0-beta.7] + +- [`76daee7a`](https://github.com/tauri-apps/plugins-workspace/commit/76daee7aafece34de3092c86e531cf9eb1138989) ([#1512](https://github.com/tauri-apps/plugins-workspace/pull/1512) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Update to tauri beta.23. + +## \[2.0.0-beta.6] + +- [`9013854f`](https://github.com/tauri-apps/plugins-workspace/commit/9013854f42a49a230b9dbb9d02774765528a923f)([#1382](https://github.com/tauri-apps/plugins-workspace/pull/1382)) Update to tauri beta.22. + +## \[2.0.0-beta.5] + +- [`430bd6f4`](https://github.com/tauri-apps/plugins-workspace/commit/430bd6f4f379bee5d232ae6b098ae131db7f178a)([#1363](https://github.com/tauri-apps/plugins-workspace/pull/1363)) Update to tauri beta.20. + +## \[2.0.0-beta.7] + +- [`d9de5b19`](https://github.com/tauri-apps/plugins-workspace/commit/d9de5b19d1e950c06f0915ae92a862acb266d108)([#1283](https://github.com/tauri-apps/plugins-workspace/pull/1283)) Implement `WindowExt` for `WebviewWindow`. + +## \[2.0.0-beta.4] + +- [`bd1ed590`](https://github.com/tauri-apps/plugins-workspace/commit/bd1ed5903ffcce5500310dac1e59e8c67674ef1e)([#1237](https://github.com/tauri-apps/plugins-workspace/pull/1237)) Update to tauri beta.17. + +## \[2.0.0-beta.3] + +- [`0e9541f`](https://github.com/tauri-apps/plugins-workspace/commit/0e9541fe8990395de7cc8887bc46b3f3665b44e1)([#1138](https://github.com/tauri-apps/plugins-workspace/pull/1138)) Add `Builder::with_filename` to support using a custom filename. Also add `AppHandleExt::file_name` and a similar function in JS, to retrieve it later. + +## \[2.0.0-beta.4] + +- [`c013fa5`](https://github.com/tauri-apps/plugins-workspace/commit/c013fa52cd66885cf457a64e75373cb2066bc849)([#1078](https://github.com/tauri-apps/plugins-workspace/pull/1078)) **Breaking change**: Changed the format of the state file from bincode to json. Also changed the filename to from `.window-state` to `.window-state.json`. + +## \[2.0.0-beta.3] + +- [`a04ea2f`](https://github.com/tauri-apps/plugins-workspace/commit/a04ea2f38294d5a3987578283badc8eec87a7752)([#1071](https://github.com/tauri-apps/plugins-workspace/pull/1071)) The global API script is now only added to the binary when the `withGlobalTauri` config is true. + +## \[2.0.0-beta.2] + +- [`99bea25`](https://github.com/tauri-apps/plugins-workspace/commit/99bea2559c2c0648c2519c50a18cd124dacef57b)([#1005](https://github.com/tauri-apps/plugins-workspace/pull/1005)) Update to tauri beta.8. + +## \[2.0.0-beta.1] + +- [`569defb`](https://github.com/tauri-apps/plugins-workspace/commit/569defbe9492e38938554bb7bdc1be9151456d21) Update to tauri beta.4. + +## \[2.0.0-beta.0] + +- [`d198c01`](https://github.com/tauri-apps/plugins-workspace/commit/d198c014863ee260cb0de88a14b7fc4356ef7474)([#862](https://github.com/tauri-apps/plugins-workspace/pull/862)) Update to tauri beta. + +- [`14f59615`](https://github.com/tauri-apps/plugins-workspace/commit/14f5961569c7d759d8d6d836352c787484594bd5) Address a couple of issues with restoring positions: + + - Fix restoring window positions correctly when the top-left corner of the window was outside of the monitor. + - Fix restore maximization state only maximized on main monitor. + +## \[2.0.0-alpha.5] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.13. + +## \[2.0.0-alpha.4] + +- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.12. + +## \[2.0.0-alpha.3] + +- [`e438e0a`](https://github.com/tauri-apps/plugins-workspace/commit/e438e0a62d4b430a5159f05f13ecd397dd891a0d)([#676](https://github.com/tauri-apps/plugins-workspace/pull/676)) Update to @tauri-apps/api v2.0.0-alpha.11. + +## \[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.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] - [`4e2cef9`](https://github.com/tauri-apps/plugins-workspace/commit/4e2cef9b702bbbb9cf4ee17de50791cb21f1b2a4)([#593](https://github.com/tauri-apps/plugins-workspace/pull/593)) Update to alpha.12. @@ -12,4 +139,11 @@ ## \[2.0.0-alpha.0] - [`717ae67`](https://github.com/tauri-apps/plugins-workspace/commit/717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! - lugins-workspace/commit/717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! + +## \[0.1.1] + +- Address a couple of issues with restoring positions: + +- Fix restoring window positions correctly when the top-left corner of the window was outside of the monitor. + +- Fix restore maximization state only maximized on main monitor. diff --git a/plugins/window-state/Cargo.toml b/plugins/window-state/Cargo.toml index d86e7774..180808b8 100644 --- a/plugins/window-state/Cargo.toml +++ b/plugins/window-state/Cargo.toml @@ -1,14 +1,27 @@ [package] name = "tauri-plugin-window-state" -version = "2.0.0-alpha.2" +version = "2.2.2" description = "Save window positions and sizes and restore them when the app is reopened." authors = { workspace = true } license = { workspace = true } edition = { workspace = true } rust-version = { workspace = true } +repository = { workspace = true } +links = "tauri-plugin-window-state" [package.metadata.docs.rs] -features = [ "tauri/dox" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] + +[package.metadata.platforms.support] +windows = { level = "full", notes = "" } +linux = { level = "full", notes = "" } +macos = { level = "full", notes = "" } +android = { level = "none", notes = "" } +ios = { level = "none", notes = "" } + +[build-dependencies] +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } @@ -16,5 +29,4 @@ serde_json = { workspace = true } tauri = { workspace = true } log = { workspace = true } thiserror = { workspace = true } -bincode = "1.3" bitflags = "2" diff --git a/plugins/window-state/README.md b/plugins/window-state/README.md index 2e771846..4af93de2 100644 --- a/plugins/window-state/README.md +++ b/plugins/window-state/README.md @@ -2,9 +2,17 @@ Save window positions and sizes and restore them when the app is reopened. +| Platform | Supported | +| -------- | --------- | +| Linux | ✓ | +| Windows | ✓ | +| macOS | ✓ | +| Android | x | +| iOS | x | + ## Install -_This plugin requires a Rust version of at least **1.70**_ +_This plugin requires a Rust version of at least **1.77.2**_ There are three general methods of installation that we can recommend. @@ -18,7 +26,7 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] -tauri-plugin-window-state = "2.0.0-alpha" +tauri-plugin-window-state = "2.0.0" # alternatively with Git: tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -46,7 +54,7 @@ yarn add https://github.com/tauri-apps/tauri-plugin-window-state#v2 First you need to register the core plugin with Tauri: -`src-tauri/src/main.rs` +`src-tauri/src/lib.rs` ```rust fn main() { @@ -71,9 +79,9 @@ app.save_window_state(StateFlags::all()); // will save the state of all open win or through Javascript ```javascript -import { saveWindowState, StateFlags } from "@tauri-apps/plugin-window-state"; +import { saveWindowState, StateFlags } from '@tauri-apps/plugin-window-state' -saveWindowState(StateFlags.ALL); +saveWindowState(StateFlags.ALL) ``` To manually restore a windows state from disk you can call the `restore_state()` method exposed by the `WindowExt` trait: @@ -90,16 +98,32 @@ or through Javascript ```javascript import { restoreStateCurrent, - StateFlags, -} from "@tauri-apps/plugin-window-state"; + StateFlags +} from '@tauri-apps/plugin-window-state' -restoreStateCurrent(StateFlags.ALL); +restoreStateCurrent(StateFlags.ALL) ``` ## Contributing PRs accepted. Please make sure to read the Contributing Guide before making a pull request. +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + ## License Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. diff --git a/plugins/window-state/SECURITY.md b/plugins/window-state/SECURITY.md new file mode 100644 index 00000000..4f09bbac --- /dev/null +++ b/plugins/window-state/SECURITY.md @@ -0,0 +1,23 @@ +# Security Policy + +**Do not report security vulnerabilities through public GitHub issues.** + +**Please use the [Private Vulnerability Disclosure](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) feature of GitHub.** + +Include as much of the following information: + +- Type of issue (e.g. improper input parsing, privilege escalation, etc.) +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- The distribution affected or used to help us with reproduction of the issue +- Step-by-step instructions to reproduce the issue +- Ideally a reproduction repository +- Impact of the issue, including how an attacker might exploit the issue + +We prefer to receive reports in English. + +## Contact + +Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). + +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/window-state/api-iife.js b/plugins/window-state/api-iife.js new file mode 100644 index 00000000..e0082b5c --- /dev/null +++ b/plugins/window-state/api-iife.js @@ -0,0 +1 @@ +if("__TAURI__"in window){var __TAURI_PLUGIN_WINDOW_STATE__=function(e){"use strict";var t;"function"==typeof SuppressedError&&SuppressedError;const i="__TAURI_TO_IPC_KEY__";function n(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}async function a(e,t={},i){return window.__TAURI_INTERNALS__.invoke(e,t,i)}class l{get rid(){return function(e,t,i,n){if("function"==typeof t||!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)}(this,t,"f")}constructor(e){t.set(this,void 0),function(e,t,i){if("function"==typeof t||!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");t.set(e,i)}(this,t,e)}async close(){return a("plugin:resources|close",{rid:this.rid})}}t=new WeakMap;class s{constructor(...e){this.type="Logical",1===e.length?"Logical"in e[0]?(this.width=e[0].Logical.width,this.height=e[0].Logical.height):(this.width=e[0].width,this.height=e[0].height):(this.width=e[0],this.height=e[1])}toPhysical(e){return new r(this.width*e,this.height*e)}[i](){return{width:this.width,height:this.height}}toJSON(){return this[i]()}}class r{constructor(...e){this.type="Physical",1===e.length?"Physical"in e[0]?(this.width=e[0].Physical.width,this.height=e[0].Physical.height):(this.width=e[0].width,this.height=e[0].height):(this.width=e[0],this.height=e[1])}toLogical(e){return new s(this.width/e,this.height/e)}[i](){return{width:this.width,height:this.height}}toJSON(){return this[i]()}}class o{constructor(e){this.size=e}toLogical(e){return this.size instanceof s?this.size:this.size.toLogical(e)}toPhysical(e){return this.size instanceof r?this.size:this.size.toPhysical(e)}[i](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[i]()}}class u{constructor(...e){this.type="Logical",1===e.length?"Logical"in e[0]?(this.x=e[0].Logical.x,this.y=e[0].Logical.y):(this.x=e[0].x,this.y=e[0].y):(this.x=e[0],this.y=e[1])}toPhysical(e){return new c(this.x*e,this.y*e)}[i](){return{x:this.x,y:this.y}}toJSON(){return this[i]()}}class c{constructor(...e){this.type="Physical",1===e.length?"Physical"in e[0]?(this.x=e[0].Physical.x,this.y=e[0].Physical.y):(this.x=e[0].x,this.y=e[0].y):(this.x=e[0],this.y=e[1])}toLogical(e){return new u(this.x/e,this.y/e)}[i](){return{x:this.x,y:this.y}}toJSON(){return this[i]()}}class h{constructor(e){this.position=e}toLogical(e){return this.position instanceof u?this.position:this.position.toLogical(e)}toPhysical(e){return this.position instanceof c?this.position:this.position.toPhysical(e)}[i](){return{[`${this.position.type}`]:{x:this.position.x,y:this.position.y}}}toJSON(){return this[i]()}}var d,w,b;async function g(e,t){await a("plugin:event|unlisten",{event:e,eventId:t})}async function y(e,t,i){var l;const s="string"==typeof(null==i?void 0:i.target)?{kind:"AnyLabel",label:i.target}:null!==(l=null==i?void 0:i.target)&&void 0!==l?l:{kind:"Any"};return a("plugin:event|listen",{event:e,target:s,handler:n(t)}).then((t=>async()=>g(e,t)))}!function(e){e.WINDOW_RESIZED="tauri://resize",e.WINDOW_MOVED="tauri://move",e.WINDOW_CLOSE_REQUESTED="tauri://close-requested",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_CREATED="tauri://window-created",e.WEBVIEW_CREATED="tauri://webview-created",e.DRAG_ENTER="tauri://drag-enter",e.DRAG_OVER="tauri://drag-over",e.DRAG_DROP="tauri://drag-drop",e.DRAG_LEAVE="tauri://drag-leave"}(d||(d={}));class p extends l{constructor(e){super(e)}static async new(e,t,i){return a("plugin:image|new",{rgba:_(e),width:t,height:i}).then((e=>new p(e)))}static async fromBytes(e){return a("plugin:image|from_bytes",{bytes:_(e)}).then((e=>new p(e)))}static async fromPath(e){return a("plugin:image|from_path",{path:e}).then((e=>new p(e)))}async rgba(){return a("plugin:image|rgba",{rid:this.rid}).then((e=>new Uint8Array(e)))}async size(){return a("plugin:image|size",{rid:this.rid})}}function _(e){return null==e?null:"string"==typeof e?e:e instanceof p?e.rid:e}!function(e){e[e.Critical=1]="Critical",e[e.Informational=2]="Informational"}(w||(w={}));class v{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}}function f(){return new D(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function m(){return a("plugin:window|get_all_windows").then((e=>e.map((e=>new D(e,{skip:!0})))))}!function(e){e.None="none",e.Normal="normal",e.Indeterminate="indeterminate",e.Paused="paused",e.Error="error"}(b||(b={}));const E=["tauri://created","tauri://error"];class D{constructor(e,t={}){var i;this.label=e,this.listeners=Object.create(null),(null==t?void 0:t.skip)||a("plugin:window|create",{options:{...t,parent:"string"==typeof t.parent?t.parent:null===(i=t.parent)||void 0===i?void 0:i.label,label:e}}).then((async()=>this.emit("tauri://created"))).catch((async e=>this.emit("tauri://error",e)))}static async getByLabel(e){var t;return null!==(t=(await m()).find((t=>t.label===e)))&&void 0!==t?t:null}static getCurrent(){return f()}static async getAll(){return m()}static async getFocusedWindow(){for(const e of await m())if(await e.isFocused())return e;return null}async listen(e,t){return this._handleTauriEvent(e,t)?()=>{const i=this.listeners[e];i.splice(i.indexOf(t),1)}:y(e,t,{target:{kind:"Window",label:this.label}})}async once(e,t){return this._handleTauriEvent(e,t)?()=>{const i=this.listeners[e];i.splice(i.indexOf(t),1)}:async function(e,t,i){return y(e,(i=>{g(e,i.id),t(i)}),i)}(e,t,{target:{kind:"Window",label:this.label}})}async emit(e,t){if(!E.includes(e))return async function(e,t){await a("plugin:event|emit",{event:e,payload:t})}(e,t);for(const i of this.listeners[e]||[])i({event:e,id:-1,payload:t})}async emitTo(e,t,i){if(!E.includes(t))return async function(e,t,i){const n="string"==typeof e?{kind:"AnyLabel",label:e}:e;await a("plugin:event|emit_to",{target:n,event:t,payload:i})}(e,t,i);for(const e of this.listeners[t]||[])e({event:t,id:-1,payload:i})}_handleTauriEvent(e,t){return!!E.includes(e)&&(e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t],!0)}async scaleFactor(){return a("plugin:window|scale_factor",{label:this.label})}async innerPosition(){return a("plugin:window|inner_position",{label:this.label}).then((e=>new c(e)))}async outerPosition(){return a("plugin:window|outer_position",{label:this.label}).then((e=>new c(e)))}async innerSize(){return a("plugin:window|inner_size",{label:this.label}).then((e=>new r(e)))}async outerSize(){return a("plugin:window|outer_size",{label:this.label}).then((e=>new r(e)))}async isFullscreen(){return a("plugin:window|is_fullscreen",{label:this.label})}async isMinimized(){return a("plugin:window|is_minimized",{label:this.label})}async isMaximized(){return a("plugin:window|is_maximized",{label:this.label})}async isFocused(){return a("plugin:window|is_focused",{label:this.label})}async isDecorated(){return a("plugin:window|is_decorated",{label:this.label})}async isResizable(){return a("plugin:window|is_resizable",{label:this.label})}async isMaximizable(){return a("plugin:window|is_maximizable",{label:this.label})}async isMinimizable(){return a("plugin:window|is_minimizable",{label:this.label})}async isClosable(){return a("plugin:window|is_closable",{label:this.label})}async isVisible(){return a("plugin:window|is_visible",{label:this.label})}async title(){return a("plugin:window|title",{label:this.label})}async theme(){return a("plugin:window|theme",{label:this.label})}async isAlwaysOnTop(){return a("plugin:window|is_always_on_top",{label:this.label})}async center(){return a("plugin:window|center",{label:this.label})}async requestUserAttention(e){let t=null;return e&&(t=e===w.Critical?{type:"Critical"}:{type:"Informational"}),a("plugin:window|request_user_attention",{label:this.label,value:t})}async setResizable(e){return a("plugin:window|set_resizable",{label:this.label,value:e})}async setEnabled(e){return a("plugin:window|set_enabled",{label:this.label,value:e})}async isEnabled(){return a("plugin:window|is_enabled",{label:this.label})}async setMaximizable(e){return a("plugin:window|set_maximizable",{label:this.label,value:e})}async setMinimizable(e){return a("plugin:window|set_minimizable",{label:this.label,value:e})}async setClosable(e){return a("plugin:window|set_closable",{label:this.label,value:e})}async setTitle(e){return a("plugin:window|set_title",{label:this.label,value:e})}async maximize(){return a("plugin:window|maximize",{label:this.label})}async unmaximize(){return a("plugin:window|unmaximize",{label:this.label})}async toggleMaximize(){return a("plugin:window|toggle_maximize",{label:this.label})}async minimize(){return a("plugin:window|minimize",{label:this.label})}async unminimize(){return a("plugin:window|unminimize",{label:this.label})}async show(){return a("plugin:window|show",{label:this.label})}async hide(){return a("plugin:window|hide",{label:this.label})}async close(){return a("plugin:window|close",{label:this.label})}async destroy(){return a("plugin:window|destroy",{label:this.label})}async setDecorations(e){return a("plugin:window|set_decorations",{label:this.label,value:e})}async setShadow(e){return a("plugin:window|set_shadow",{label:this.label,value:e})}async setEffects(e){return a("plugin:window|set_effects",{label:this.label,value:e})}async clearEffects(){return a("plugin:window|set_effects",{label:this.label,value:null})}async setAlwaysOnTop(e){return a("plugin:window|set_always_on_top",{label:this.label,value:e})}async setAlwaysOnBottom(e){return a("plugin:window|set_always_on_bottom",{label:this.label,value:e})}async setContentProtected(e){return a("plugin:window|set_content_protected",{label:this.label,value:e})}async setSize(e){return a("plugin:window|set_size",{label:this.label,value:e instanceof o?e:new o(e)})}async setMinSize(e){return a("plugin:window|set_min_size",{label:this.label,value:e instanceof o?e:e?new o(e):null})}async setMaxSize(e){return a("plugin:window|set_max_size",{label:this.label,value:e instanceof o?e:e?new o(e):null})}async setSizeConstraints(e){function t(e){return e?{Logical:e}:null}return a("plugin:window|set_size_constraints",{label:this.label,value:{minWidth:t(null==e?void 0:e.minWidth),minHeight:t(null==e?void 0:e.minHeight),maxWidth:t(null==e?void 0:e.maxWidth),maxHeight:t(null==e?void 0:e.maxHeight)}})}async setPosition(e){return a("plugin:window|set_position",{label:this.label,value:e instanceof h?e:new h(e)})}async setFullscreen(e){return a("plugin:window|set_fullscreen",{label:this.label,value:e})}async setFocus(){return a("plugin:window|set_focus",{label:this.label})}async setIcon(e){return a("plugin:window|set_icon",{label:this.label,value:_(e)})}async setSkipTaskbar(e){return a("plugin:window|set_skip_taskbar",{label:this.label,value:e})}async setCursorGrab(e){return a("plugin:window|set_cursor_grab",{label:this.label,value:e})}async setCursorVisible(e){return a("plugin:window|set_cursor_visible",{label:this.label,value:e})}async setCursorIcon(e){return a("plugin:window|set_cursor_icon",{label:this.label,value:e})}async setBackgroundColor(e){return a("plugin:window|set_background_color",{color:e})}async setCursorPosition(e){return a("plugin:window|set_cursor_position",{label:this.label,value:e instanceof h?e:new h(e)})}async setIgnoreCursorEvents(e){return a("plugin:window|set_ignore_cursor_events",{label:this.label,value:e})}async startDragging(){return a("plugin:window|start_dragging",{label:this.label})}async startResizeDragging(e){return a("plugin:window|start_resize_dragging",{label:this.label,value:e})}async setBadgeCount(e){return a("plugin:window|set_badge_count",{label:this.label,value:e})}async setBadgeLabel(e){return a("plugin:window|set_badge_label",{label:this.label,value:e})}async setOverlayIcon(e){return a("plugin:window|set_overlay_icon",{label:this.label,value:e?_(e):void 0})}async setProgressBar(e){return a("plugin:window|set_progress_bar",{label:this.label,value:e})}async setVisibleOnAllWorkspaces(e){return a("plugin:window|set_visible_on_all_workspaces",{label:this.label,value:e})}async setTitleBarStyle(e){return a("plugin:window|set_title_bar_style",{label:this.label,value:e})}async setTheme(e){return a("plugin:window|set_theme",{label:this.label,value:e})}async onResized(e){return this.listen(d.WINDOW_RESIZED,(t=>{t.payload=new r(t.payload),e(t)}))}async onMoved(e){return this.listen(d.WINDOW_MOVED,(t=>{t.payload=new c(t.payload),e(t)}))}async onCloseRequested(e){return this.listen(d.WINDOW_CLOSE_REQUESTED,(async t=>{const i=new v(t);await e(i),i.isPreventDefault()||await this.destroy()}))}async onDragDropEvent(e){const t=await this.listen(d.DRAG_ENTER,(t=>{e({...t,payload:{type:"enter",paths:t.payload.paths,position:new c(t.payload.position)}})})),i=await this.listen(d.DRAG_OVER,(t=>{e({...t,payload:{type:"over",position:new c(t.payload.position)}})})),n=await this.listen(d.DRAG_DROP,(t=>{e({...t,payload:{type:"drop",paths:t.payload.paths,position:new c(t.payload.position)}})})),a=await this.listen(d.DRAG_LEAVE,(t=>{e({...t,payload:{type:"leave"}})}));return()=>{t(),n(),i(),a()}}async onFocusChanged(e){const t=await this.listen(d.WINDOW_FOCUS,(t=>{e({...t,payload:!0})})),i=await this.listen(d.WINDOW_BLUR,(t=>{e({...t,payload:!1})}));return()=>{t(),i()}}async onScaleChanged(e){return this.listen(d.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(d.WINDOW_THEME_CHANGED,e)}}var I,S,W,O;async function z(e,t){await a("plugin:window-state|restore_state",{label:e,flags:t})}return function(e){e.Disabled="disabled",e.Throttle="throttle",e.Suspend="suspend"}(I||(I={})),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"}(S||(S={})),function(e){e.FollowsWindowActiveState="followsWindowActiveState",e.Active="active",e.Inactive="inactive"}(W||(W={})),e.StateFlags=void 0,(O=e.StateFlags||(e.StateFlags={}))[O.SIZE=1]="SIZE",O[O.POSITION=2]="POSITION",O[O.MAXIMIZED=4]="MAXIMIZED",O[O.VISIBLE=8]="VISIBLE",O[O.DECORATIONS=16]="DECORATIONS",O[O.FULLSCREEN=32]="FULLSCREEN",O[O.ALL=63]="ALL",e.filename=async function(){return await a("plugin:window-state|filename")},e.restoreState=z,e.restoreStateCurrent=async function(e){await z(f().label,e)},e.saveWindowState=async function(e){await a("plugin:window-state|save_window_state",{flags:e})},e}({});Object.defineProperty(window.__TAURI__,"windowState",{value:__TAURI_PLUGIN_WINDOW_STATE__})} diff --git a/plugins/window-state/build.rs b/plugins/window-state/build.rs new file mode 100644 index 00000000..2a9354c9 --- /dev/null +++ b/plugins/window-state/build.rs @@ -0,0 +1,11 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +const COMMANDS: &[&str] = &["save_window_state", "restore_state", "filename"]; + +fn main() { + tauri_plugin::Builder::new(COMMANDS) + .global_api_script_path("./api-iife.js") + .build(); +} diff --git a/plugins/window-state/guest-js/index.ts b/plugins/window-state/guest-js/index.ts index 4d84f898..f922f3f0 100644 --- a/plugins/window-state/guest-js/index.ts +++ b/plugins/window-state/guest-js/index.ts @@ -2,8 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { invoke } from "@tauri-apps/api/primitives"; -import { getCurrent } from "@tauri-apps/api/window"; +import { invoke } from '@tauri-apps/api/core' +import { type WindowLabel, getCurrentWindow } from '@tauri-apps/api/window' export enum StateFlags { SIZE = 1 << 0, @@ -12,33 +12,37 @@ export enum StateFlags { VISIBLE = 1 << 3, DECORATIONS = 1 << 4, FULLSCREEN = 1 << 5, - ALL = SIZE | POSITION | MAXIMIZED | VISIBLE | DECORATIONS | FULLSCREEN, + ALL = SIZE | POSITION | MAXIMIZED | VISIBLE | DECORATIONS | FULLSCREEN } /** * Save the state of all open windows to disk. */ async function saveWindowState(flags: StateFlags): Promise { - return invoke("plugin:window-state|save_window_state", { - flags, - }); + await invoke('plugin:window-state|save_window_state', { flags }) } /** * Restore the state for the specified window from disk. */ -async function restoreState(label: string, flags: StateFlags): Promise { - return invoke("plugin:window-state|restore_state", { - label, - flags, - }); +async function restoreState( + label: WindowLabel, + flags: StateFlags +): Promise { + await invoke('plugin:window-state|restore_state', { label, flags }) } /** * Restore the state for the current window from disk. */ async function restoreStateCurrent(flags: StateFlags): Promise { - return restoreState(getCurrent().label, flags); + await restoreState(getCurrentWindow().label, flags) +} +/** + * Get the name of the file used to store window state. + */ +async function filename(): Promise { + return await invoke('plugin:window-state|filename') } -export { restoreState, restoreStateCurrent, saveWindowState }; +export { restoreState, restoreStateCurrent, saveWindowState, filename } diff --git a/plugins/window-state/package.json b/plugins/window-state/package.json index b1b41669..fd0eccd1 100644 --- a/plugins/window-state/package.json +++ b/plugins/window-state/package.json @@ -1,33 +1,30 @@ { "name": "@tauri-apps/plugin-window-state", - "version": "2.0.0-alpha.1", + "version": "2.2.2", "description": "Save window positions and sizes and restore them when the app is reopened.", - "license": "MIT or APACHE-2.0", + "license": "MIT OR Apache-2.0", "authors": [ "Tauri Programme within The Commons Conservancy" ], + "repository": "https://github.com/tauri-apps/plugins-workspace", "type": "module", - "browser": "dist-js/index.min.js", - "module": "dist-js/index.mjs", - "types": "dist-js/index.d.ts", + "types": "./dist-js/index.d.ts", + "main": "./dist-js/index.cjs", + "module": "./dist-js/index.js", "exports": { - "import": "./dist-js/index.mjs", "types": "./dist-js/index.d.ts", - "browser": "./dist-js/index.min.js" + "import": "./dist-js/index.js", + "require": "./dist-js/index.cjs" }, "scripts": { "build": "rollup -c" }, "files": [ "dist-js", - "!dist-js/**/*.map", "README.md", "LICENSE" ], - "devDependencies": { - "tslib": "2.6.0" - }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.9" + "@tauri-apps/api": "^2.0.0" } } diff --git a/plugins/window-state/permissions/autogenerated/commands/filename.toml b/plugins/window-state/permissions/autogenerated/commands/filename.toml new file mode 100644 index 00000000..1cfcee45 --- /dev/null +++ b/plugins/window-state/permissions/autogenerated/commands/filename.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-filename" +description = "Enables the filename command without any pre-configured scope." +commands.allow = ["filename"] + +[[permission]] +identifier = "deny-filename" +description = "Denies the filename command without any pre-configured scope." +commands.deny = ["filename"] diff --git a/plugins/window-state/permissions/autogenerated/commands/restore_state.toml b/plugins/window-state/permissions/autogenerated/commands/restore_state.toml new file mode 100644 index 00000000..61df5cd4 --- /dev/null +++ b/plugins/window-state/permissions/autogenerated/commands/restore_state.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-restore-state" +description = "Enables the restore_state command without any pre-configured scope." +commands.allow = ["restore_state"] + +[[permission]] +identifier = "deny-restore-state" +description = "Denies the restore_state command without any pre-configured scope." +commands.deny = ["restore_state"] diff --git a/plugins/window-state/permissions/autogenerated/commands/save_window_state.toml b/plugins/window-state/permissions/autogenerated/commands/save_window_state.toml new file mode 100644 index 00000000..b29e1bf3 --- /dev/null +++ b/plugins/window-state/permissions/autogenerated/commands/save_window_state.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-save-window-state" +description = "Enables the save_window_state command without any pre-configured scope." +commands.allow = ["save_window_state"] + +[[permission]] +identifier = "deny-save-window-state" +description = "Denies the save_window_state command without any pre-configured scope." +commands.deny = ["save_window_state"] diff --git a/plugins/window-state/permissions/autogenerated/reference.md b/plugins/window-state/permissions/autogenerated/reference.md new file mode 100644 index 00000000..64cd7d88 --- /dev/null +++ b/plugins/window-state/permissions/autogenerated/reference.md @@ -0,0 +1,104 @@ +## Default Permission + +This permission set configures what kind of +operations are available from the window state plugin. + +#### Granted Permissions + +All operations are enabled by default. + + + +#### This default permission set includes the following: + +- `allow-filename` +- `allow-restore-state` +- `allow-save-window-state` + +## Permission Table + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IdentifierDescription
+ +`window-state:allow-filename` + + + +Enables the filename command without any pre-configured scope. + +
+ +`window-state:deny-filename` + + + +Denies the filename command without any pre-configured scope. + +
+ +`window-state:allow-restore-state` + + + +Enables the restore_state command without any pre-configured scope. + +
+ +`window-state:deny-restore-state` + + + +Denies the restore_state command without any pre-configured scope. + +
+ +`window-state:allow-save-window-state` + + + +Enables the save_window_state command without any pre-configured scope. + +
+ +`window-state:deny-save-window-state` + + + +Denies the save_window_state command without any pre-configured scope. + +
diff --git a/plugins/window-state/permissions/default.toml b/plugins/window-state/permissions/default.toml new file mode 100644 index 00000000..1823e198 --- /dev/null +++ b/plugins/window-state/permissions/default.toml @@ -0,0 +1,17 @@ +"$schema" = "schemas/schema.json" + +[default] +description = """ +This permission set configures what kind of +operations are available from the window state plugin. + +#### Granted Permissions + +All operations are enabled by default. + +""" +permissions = [ + "allow-filename", + "allow-restore-state", + "allow-save-window-state", +] diff --git a/plugins/window-state/permissions/schemas/schema.json b/plugins/window-state/permissions/schemas/schema.json new file mode 100644 index 00000000..d9cbe0f0 --- /dev/null +++ b/plugins/window-state/permissions/schemas/schema.json @@ -0,0 +1,342 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "PermissionFile", + "description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.", + "type": "object", + "properties": { + "default": { + "description": "The default permission set for the plugin", + "anyOf": [ + { + "$ref": "#/definitions/DefaultPermission" + }, + { + "type": "null" + } + ] + }, + "set": { + "description": "A list of permissions sets defined", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionSet" + } + }, + "permission": { + "description": "A list of inlined permissions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Permission" + } + } + }, + "definitions": { + "DefaultPermission": { + "description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.", + "type": "object", + "required": [ + "permissions" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "PermissionSet": { + "description": "A set of direct permissions grouped together under a new name.", + "type": "object", + "required": [ + "description", + "identifier", + "permissions" + ], + "properties": { + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does.", + "type": "string" + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionKind" + } + } + } + }, + "Permission": { + "description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.", + "type": "object", + "required": [ + "identifier" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri internal convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "commands": { + "description": "Allowed or denied commands when using this permission.", + "default": { + "allow": [], + "deny": [] + }, + "allOf": [ + { + "$ref": "#/definitions/Commands" + } + ] + }, + "scope": { + "description": "Allowed or denied scoped when using this permission.", + "allOf": [ + { + "$ref": "#/definitions/Scopes" + } + ] + }, + "platforms": { + "description": "Target platforms this permission applies. By default all platforms are affected by this permission.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Target" + } + } + } + }, + "Commands": { + "description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.", + "type": "object", + "properties": { + "allow": { + "description": "Allowed command.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "deny": { + "description": "Denied command, which takes priority.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "Scopes": { + "description": "An argument for fine grained behavior control of Tauri commands.\n\nIt can be of any serde serializable type and is used to allow or prevent certain actions inside a Tauri command. The configured scope is passed to the command and will be enforced by the command implementation.\n\n## Example\n\n```json { \"allow\": [{ \"path\": \"$HOME/**\" }], \"deny\": [{ \"path\": \"$HOME/secret.txt\" }] } ```", + "type": "object", + "properties": { + "allow": { + "description": "Data that defines what is allowed by the scope.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + }, + "deny": { + "description": "Data that defines what is denied by the scope. This should be prioritized by validation logic.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + } + } + }, + "Value": { + "description": "All supported ACL values.", + "anyOf": [ + { + "description": "Represents a null JSON value.", + "type": "null" + }, + { + "description": "Represents a [`bool`].", + "type": "boolean" + }, + { + "description": "Represents a valid ACL [`Number`].", + "allOf": [ + { + "$ref": "#/definitions/Number" + } + ] + }, + { + "description": "Represents a [`String`].", + "type": "string" + }, + { + "description": "Represents a list of other [`Value`]s.", + "type": "array", + "items": { + "$ref": "#/definitions/Value" + } + }, + { + "description": "Represents a map of [`String`] keys to [`Value`]s.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/Value" + } + } + ] + }, + "Number": { + "description": "A valid ACL number.", + "anyOf": [ + { + "description": "Represents an [`i64`].", + "type": "integer", + "format": "int64" + }, + { + "description": "Represents a [`f64`].", + "type": "number", + "format": "double" + } + ] + }, + "Target": { + "description": "Platform target.", + "oneOf": [ + { + "description": "MacOS.", + "type": "string", + "enum": [ + "macOS" + ] + }, + { + "description": "Windows.", + "type": "string", + "enum": [ + "windows" + ] + }, + { + "description": "Linux.", + "type": "string", + "enum": [ + "linux" + ] + }, + { + "description": "Android.", + "type": "string", + "enum": [ + "android" + ] + }, + { + "description": "iOS.", + "type": "string", + "enum": [ + "iOS" + ] + } + ] + }, + "PermissionKind": { + "type": "string", + "oneOf": [ + { + "description": "Enables the filename command without any pre-configured scope.", + "type": "string", + "const": "allow-filename", + "markdownDescription": "Enables the filename command without any pre-configured scope." + }, + { + "description": "Denies the filename command without any pre-configured scope.", + "type": "string", + "const": "deny-filename", + "markdownDescription": "Denies the filename command without any pre-configured scope." + }, + { + "description": "Enables the restore_state command without any pre-configured scope.", + "type": "string", + "const": "allow-restore-state", + "markdownDescription": "Enables the restore_state command without any pre-configured scope." + }, + { + "description": "Denies the restore_state command without any pre-configured scope.", + "type": "string", + "const": "deny-restore-state", + "markdownDescription": "Denies the restore_state command without any pre-configured scope." + }, + { + "description": "Enables the save_window_state command without any pre-configured scope.", + "type": "string", + "const": "allow-save-window-state", + "markdownDescription": "Enables the save_window_state command without any pre-configured scope." + }, + { + "description": "Denies the save_window_state command without any pre-configured scope.", + "type": "string", + "const": "deny-save-window-state", + "markdownDescription": "Denies the save_window_state command without any pre-configured scope." + }, + { + "description": "This permission set configures what kind of\noperations are available from the window state plugin.\n\n#### Granted Permissions\n\nAll operations are enabled by default.\n\n\n#### This default permission set includes:\n\n- `allow-filename`\n- `allow-restore-state`\n- `allow-save-window-state`", + "type": "string", + "const": "default", + "markdownDescription": "This permission set configures what kind of\noperations are available from the window state plugin.\n\n#### Granted Permissions\n\nAll operations are enabled by default.\n\n\n#### This default permission set includes:\n\n- `allow-filename`\n- `allow-restore-state`\n- `allow-save-window-state`" + } + ] + } + } +} \ No newline at end of file diff --git a/plugins/window-state/rollup.config.js b/plugins/window-state/rollup.config.js new file mode 100644 index 00000000..1f349ec8 --- /dev/null +++ b/plugins/window-state/rollup.config.js @@ -0,0 +1,7 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import { createConfig } from '../../shared/rollup.config.js' + +export default createConfig() diff --git a/plugins/window-state/rollup.config.mjs b/plugins/window-state/rollup.config.mjs deleted file mode 100644 index 99a3dd31..00000000 --- a/plugins/window-state/rollup.config.mjs +++ /dev/null @@ -1,11 +0,0 @@ -import { readFileSync } from "fs"; - -import { createConfig } from "../../shared/rollup.config.mjs"; - -export default createConfig({ - input: "guest-js/index.ts", - pkg: JSON.parse( - readFileSync(new URL("./package.json", import.meta.url), "utf8"), - ), - external: [/^@tauri-apps\/api/], -}); diff --git a/plugins/window-state/src/api-iife.js b/plugins/window-state/src/api-iife.js deleted file mode 100644 index 680f61cd..00000000 --- a/plugins/window-state/src/api-iife.js +++ /dev/null @@ -1 +0,0 @@ -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__})} diff --git a/plugins/window-state/src/cmd.rs b/plugins/window-state/src/cmd.rs index 17486505..99d41a82 100644 --- a/plugins/window-state/src/cmd.rs +++ b/plugins/window-state/src/cmd.rs @@ -24,9 +24,14 @@ pub async fn restore_state( ) -> std::result::Result<(), String> { let flags = StateFlags::from_bits(flags) .ok_or_else(|| format!("Invalid state flags bits: {}", flags))?; - app.get_window(&label) + app.get_webview_window(&label) .ok_or_else(|| format!("Couldn't find window with label: {}", label))? .restore_state(flags) .map_err(|e| e.to_string())?; Ok(()) } + +#[command] +pub fn filename(app: AppHandle) -> String { + app.filename() +} diff --git a/plugins/window-state/src/lib.rs b/plugins/window-state/src/lib.rs index bf2bcd57..50345b64 100644 --- a/plugins/window-state/src/lib.rs +++ b/plugins/window-state/src/lib.rs @@ -2,8 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -//! [![](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/window-state/banner.png)](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/window-state) -//! //! Save window positions and sizes and restore them when the app is reopened. #![doc( @@ -16,20 +14,26 @@ use bitflags::bitflags; use serde::{Deserialize, Serialize}; use tauri::{ plugin::{Builder as PluginBuilder, TauriPlugin}, - LogicalSize, Manager, Monitor, PhysicalPosition, PhysicalSize, RunEvent, Runtime, Window, - WindowEvent, + AppHandle, Manager, Monitor, PhysicalPosition, PhysicalSize, RunEvent, Runtime, WebviewWindow, + Window, WindowEvent, }; use std::{ collections::{HashMap, HashSet}, - fs::{create_dir_all, File}, - io::Write, + fs::create_dir_all, + io::BufReader, sync::{Arc, Mutex}, }; mod cmd; -pub const STATE_FILENAME: &str = ".window-state"; +type LabelMapperFn = dyn Fn(&str) -> &str + Send + Sync; +type FilterCallbackFn = dyn Fn(&str) -> bool + Send + Sync; + +/// Default filename used to store window state. +/// +/// If using a custom filename, you should probably use [`AppHandleExt::filename`] instead. +pub const DEFAULT_FILENAME: &str = ".window-state.json"; #[derive(Debug, thiserror::Error)] pub enum Error { @@ -38,7 +42,7 @@ pub enum Error { #[error(transparent)] Tauri(#[from] tauri::Error), #[error(transparent)] - Bincode(#[from] Box), + SerdeJson(#[from] serde_json::Error), } pub type Result = std::result::Result; @@ -61,12 +65,22 @@ impl Default for StateFlags { } } +struct PluginState { + filename: String, + map_label: Option>, +} + #[derive(Debug, Deserialize, Serialize, PartialEq)] struct WindowState { - width: f64, - height: f64, + width: u32, + height: u32, x: i32, y: i32, + // prev_x and prev_y are used to store position + // before maximization happened, because maximization + // will set x and y to the top-left corner of the monitor + prev_x: i32, + prev_y: i32, maximized: bool, visible: bool, decorated: bool, @@ -80,6 +94,8 @@ impl Default for WindowState { height: Default::default(), x: Default::default(), y: Default::default(), + prev_x: Default::default(), + prev_y: Default::default(), maximized: Default::default(), visible: true, decorated: true, @@ -89,33 +105,47 @@ impl Default for WindowState { } struct WindowStateCache(Arc>>); +/// Used to prevent deadlocks from resize and position event listeners setting the cached state on restoring states +struct RestoringWindowState(Mutex<()>); + pub trait AppHandleExt { /// Saves all open windows state to disk fn save_window_state(&self, flags: StateFlags) -> Result<()>; + /// Get the name of the file used to store window state. + fn filename(&self) -> String; } impl AppHandleExt for tauri::AppHandle { fn save_window_state(&self, flags: StateFlags) -> Result<()> { - if let Ok(app_dir) = self.path().app_config_dir() { - let state_path = app_dir.join(STATE_FILENAME); - let cache = self.state::(); - let mut state = cache.0.lock().unwrap(); - for (label, s) in state.iter_mut() { - if let Some(window) = self.get_window(label) { - window.update_state(s, flags)?; - } + let app_dir = self.path().app_config_dir()?; + let plugin_state = self.state::(); + let state_path = app_dir.join(&plugin_state.filename); + let windows = self.webview_windows(); + let cache = self.state::(); + let mut state = cache.0.lock().unwrap(); + + for (label, s) in state.iter_mut() { + let window = if let Some(map) = &plugin_state.map_label { + windows + .iter() + .find_map(|(l, window)| (map(l) == label).then_some(window)) + } else { + windows.get(label) + }; + + if let Some(window) = window { + window.update_state(s, flags)?; } - - create_dir_all(&app_dir) - .map_err(Error::Io) - .and_then(|_| File::create(state_path).map_err(Into::into)) - .and_then(|mut f| { - f.write_all(&bincode::serialize(&*state).map_err(Error::Bincode)?) - .map_err(Into::into) - }) - } else { - Ok(()) } + + create_dir_all(app_dir)?; + std::fs::write(state_path, serde_json::to_vec_pretty(&*state)?)?; + + Ok(()) + } + + fn filename(&self) -> String { + self.state::().filename.clone() } } @@ -124,43 +154,66 @@ pub trait WindowExt { fn restore_state(&self, flags: StateFlags) -> tauri::Result<()>; } +impl WindowExt for WebviewWindow { + fn restore_state(&self, flags: StateFlags) -> tauri::Result<()> { + self.as_ref().window().restore_state(flags) + } +} + impl WindowExt for Window { fn restore_state(&self, flags: StateFlags) -> tauri::Result<()> { + let plugin_state = self.app_handle().state::(); + let label = plugin_state + .map_label + .as_ref() + .map(|map| map(self.label())) + .unwrap_or_else(|| self.label()); + + let restoring_window_state = self.state::(); + let _restoring_window_lock = restoring_window_state.0.lock().unwrap(); let cache = self.state::(); let mut c = cache.0.lock().unwrap(); let mut should_show = true; - if let Some(state) = c.get(self.label()) { - // avoid restoring the default zeroed state - if *state == WindowState::default() { - return Ok(()); - } - + if let Some(state) = c + .get(label) + .filter(|state| state != &&WindowState::default()) + { if flags.contains(StateFlags::DECORATIONS) { self.set_decorations(state.decorated)?; } - if flags.contains(StateFlags::SIZE) { - self.set_size(LogicalSize { - width: state.width, - height: state.height, - })?; - } - if flags.contains(StateFlags::POSITION) { + let position = (state.x, state.y).into(); + let size = (state.width, state.height).into(); // restore position to saved value if saved monitor exists // otherwise, let the OS decide where to place the window for m in self.available_monitors()? { - if m.contains((state.x, state.y).into()) { + if m.intersects(position, size) { self.set_position(PhysicalPosition { - x: state.x, - y: state.y, + x: if state.maximized { + state.prev_x + } else { + state.x + }, + y: if state.maximized { + state.prev_y + } else { + state.y + }, })?; } } } + if flags.contains(StateFlags::SIZE) { + self.set_size(PhysicalSize { + width: state.width, + height: state.height, + })?; + } + if flags.contains(StateFlags::MAXIMIZED) && state.maximized { self.maximize()?; } @@ -174,11 +227,7 @@ impl WindowExt for Window { let mut metadata = WindowState::default(); if flags.contains(StateFlags::SIZE) { - let scale_factor = self - .current_monitor()? - .map(|m| m.scale_factor()) - .unwrap_or(1.); - let size = self.inner_size()?.to_logical(scale_factor); + let size = self.inner_size()?; metadata.width = size.width; metadata.height = size.height; } @@ -205,7 +254,7 @@ impl WindowExt for Window { metadata.fullscreen = self.is_fullscreen()?; } - c.insert(self.label().into(), metadata); + c.insert(label.into(), metadata); } if flags.contains(StateFlags::VISIBLE) && should_show { @@ -221,12 +270,19 @@ trait WindowExtInternal { fn update_state(&self, state: &mut WindowState, flags: StateFlags) -> tauri::Result<()>; } +impl WindowExtInternal for WebviewWindow { + fn update_state(&self, state: &mut WindowState, flags: StateFlags) -> tauri::Result<()> { + self.as_ref().window().update_state(state, flags) + } +} + impl WindowExtInternal for Window { fn update_state(&self, state: &mut WindowState, flags: StateFlags) -> tauri::Result<()> { - let is_maximized = match flags.intersects(StateFlags::MAXIMIZED | StateFlags::SIZE) { - true => self.is_maximized()?, - false => false, - }; + let is_maximized = flags + .intersects(StateFlags::MAXIMIZED | StateFlags::POSITION | StateFlags::SIZE) + && self.is_maximized()?; + let is_minimized = + flags.intersects(StateFlags::POSITION | StateFlags::SIZE) && self.is_minimized()?; if flags.contains(StateFlags::MAXIMIZED) { state.maximized = is_maximized; @@ -244,29 +300,19 @@ impl WindowExtInternal for Window { state.visible = self.is_visible()?; } - if flags.contains(StateFlags::SIZE) { - let scale_factor = self - .current_monitor()? - .map(|m| m.scale_factor()) - .unwrap_or(1.); - let size = self.inner_size()?.to_logical(scale_factor); - - // It doesn't make sense to save a self with 0 height or width - if size.width > 0. && size.height > 0. && !is_maximized { + if flags.contains(StateFlags::SIZE) && !is_maximized && !is_minimized { + let size = self.inner_size()?; + // It doesn't make sense to save a window with 0 height or width + if size.width > 0 && size.height > 0 { state.width = size.width; state.height = size.height; } } - if flags.contains(StateFlags::POSITION) { + if flags.contains(StateFlags::POSITION) && !is_maximized && !is_minimized { let position = self.outer_position()?; - if let Ok(Some(monitor)) = self.current_monitor() { - // save only window positions that are inside the current monitor - if monitor.contains(position) && !is_maximized { - state.x = position.x; - state.y = position.y; - } - } + state.x = position.x; + state.y = position.y; } Ok(()) @@ -276,71 +322,113 @@ impl WindowExtInternal for Window { #[derive(Default)] pub struct Builder { denylist: HashSet, + filter_callback: Option>, skip_initial_state: HashSet, state_flags: StateFlags, + map_label: Option>, + filename: Option, } impl Builder { + pub fn new() -> Self { + Self::default() + } + /// Sets the state flags to control what state gets restored and saved. pub fn with_state_flags(mut self, flags: StateFlags) -> Self { self.state_flags = flags; self } + /// Sets a custom filename to use when saving and restoring window states from disk. + pub fn with_filename(mut self, filename: impl Into) -> Self { + self.filename.replace(filename.into()); + self + } + /// Sets a list of windows that shouldn't be tracked and managed by this plugin - /// for example splash screen windows. + /// For example, splash screen windows. pub fn with_denylist(mut self, denylist: &[&str]) -> Self { self.denylist = denylist.iter().map(|l| l.to_string()).collect(); self } + /// Sets a filter callback to exclude specific windows from being tracked. + /// Return `true` to save the state, or `false` to skip and not save it. + pub fn with_filter(mut self, filter_callback: F) -> Self + where + F: Fn(&str) -> bool + Send + Sync + 'static, + { + self.filter_callback = Some(Box::new(filter_callback)); + self + } + /// Adds the given window label to a list of windows to skip initial state restore. pub fn skip_initial_state(mut self, label: &str) -> Self { self.skip_initial_state.insert(label.into()); self } + /// Transforms the window label when saving the window state. + /// + /// This can be used to group different windows to use the same state. + pub fn map_label(mut self, map_fn: F) -> Self + where + F: Fn(&str) -> &str + Sync + Send + 'static, + { + self.map_label = Some(Box::new(map_fn)); + self + } + pub fn build(self) -> TauriPlugin { let flags = self.state_flags; + let filename = self.filename.unwrap_or_else(|| DEFAULT_FILENAME.into()); + let map_label = self.map_label; + PluginBuilder::new("window-state") - .js_init_script(include_str!("api-iife.js").to_string()) .invoke_handler(tauri::generate_handler![ cmd::save_window_state, - cmd::restore_state + cmd::restore_state, + cmd::filename ]) .setup(|app, _api| { - let cache: Arc>> = if let Ok(app_dir) = - app.path().app_config_dir() - { - let state_path = app_dir.join(STATE_FILENAME); - if state_path.exists() { - Arc::new(Mutex::new( - std::fs::read(state_path) - .map_err(Error::from) - .and_then(|state| bincode::deserialize(&state).map_err(Into::into)) - .unwrap_or_default(), - )) - } else { - Default::default() - } - } else { - Default::default() - }; - app.manage(WindowStateCache(cache)); + let cache = load_saved_window_states(app, &filename).unwrap_or_default(); + app.manage(WindowStateCache(Arc::new(Mutex::new(cache)))); + app.manage(RestoringWindowState(Mutex::new(()))); + app.manage(PluginState { + filename, + map_label, + }); Ok(()) }) - .on_webview_ready(move |window| { - if self.denylist.contains(window.label()) { + .on_window_ready(move |window| { + let plugin_state = window.app_handle().state::(); + let label = plugin_state + .map_label + .as_ref() + .map(|map| map(window.label())) + .unwrap_or_else(|| window.label()); + + // Check deny list names + if self.denylist.contains(label) { return; } - if !self.skip_initial_state.contains(window.label()) { + // Check deny list callback + if let Some(filter_callback) = &self.filter_callback { + // Don't save the state if the callback returns false + if !filter_callback(label) { + return; + } + } + + if !self.skip_initial_state.contains(label) { let _ = window.restore_state(self.state_flags); } let cache = window.state::(); let cache = cache.0.clone(); - let label = window.label().to_string(); + let label = label.to_string(); let window_clone = window.clone(); let flags = self.state_flags; @@ -354,13 +442,59 @@ impl Builder { .or_insert_with(WindowState::default); } - window.on_window_event(move |e| { - if let WindowEvent::CloseRequested { .. } = e { + window.on_window_event(move |e| match e { + WindowEvent::CloseRequested { .. } => { let mut c = cache.lock().unwrap(); if let Some(state) = c.get_mut(&label) { let _ = window_clone.update_state(state, flags); } } + + WindowEvent::Moved(position) if flags.contains(StateFlags::POSITION) => { + if window_clone + .state::() + .0 + .try_lock() + .is_ok() + && !window_clone.is_minimized().unwrap_or_default() + { + let mut c = cache.lock().unwrap(); + if let Some(state) = c.get_mut(&label) { + state.prev_x = state.x; + state.prev_y = state.y; + + state.x = position.x; + state.y = position.y; + } + } + } + WindowEvent::Resized(size) if flags.contains(StateFlags::SIZE) => { + if window_clone + .state::() + .0 + .try_lock() + .is_ok() + { + // TODO: Remove once https://github.com/tauri-apps/tauri/issues/5812 is resolved. + let is_maximized = if cfg!(target_os = "macos") + && (!window_clone.is_decorated().unwrap_or_default() + || !window_clone.is_resizable().unwrap_or_default()) + { + false + } else { + window_clone.is_maximized().unwrap_or_default() + }; + + if !window_clone.is_minimized().unwrap_or_default() && !is_maximized { + let mut c = cache.lock().unwrap(); + if let Some(state) = c.get_mut(&label) { + state.width = size.width; + state.height = size.height; + } + } + } + } + _ => {} }); }) .on_event(move |app, event| { @@ -372,18 +506,42 @@ impl Builder { } } +fn load_saved_window_states( + app: &AppHandle, + filename: &String, +) -> Result> { + let app_dir = app.path().app_config_dir()?; + let state_path = app_dir.join(filename); + let file = std::fs::File::open(state_path)?; + let reader = BufReader::new(file); + let states = serde_json::from_reader(reader)?; + Ok(states) +} + trait MonitorExt { - fn contains(&self, position: PhysicalPosition) -> bool; + fn intersects(&self, position: PhysicalPosition, size: PhysicalSize) -> bool; } impl MonitorExt for Monitor { - fn contains(&self, position: PhysicalPosition) -> bool { + fn intersects(&self, position: PhysicalPosition, size: PhysicalSize) -> bool { let PhysicalPosition { x, y } = *self.position(); let PhysicalSize { width, height } = *self.size(); - x < position.x as _ - && position.x < (x + width as i32) - && y < position.y as _ - && position.y < (y + height as i32) + let left = x; + let right = x + width as i32; + let top = y; + let bottom = y + height as i32; + + [ + (position.x, position.y), + (position.x + size.width as i32, position.y), + (position.x, position.y + size.height as i32), + ( + position.x + size.width as i32, + position.y + size.height as i32, + ), + ] + .into_iter() + .any(|(x, y)| x >= left && x < right && y >= top && y < bottom) } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index dc59b7ee..94fb8e88 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,982 +1,714 @@ -lockfileVersion: '6.0' +lockfileVersion: '9.0' settings: autoInstallPeers: true excludeLinksFromLockfile: false overrides: - semver: '>=7.5.2' - optionator: '>=0.9.3' + esbuild@<0.25.0: '>=0.25.0' importers: .: devDependencies: + '@eslint/js': + specifier: 9.28.0 + version: 9.28.0 '@rollup/plugin-node-resolve': - specifier: 15.2.3 - version: 15.2.3(rollup@4.1.4) + specifier: 16.0.1 + version: 16.0.1(rollup@4.41.1) '@rollup/plugin-terser': specifier: 0.4.4 - version: 0.4.4(rollup@4.1.4) + version: 0.4.4(rollup@4.41.1) '@rollup/plugin-typescript': - specifier: 11.1.5 - version: 11.1.5(rollup@4.1.4)(typescript@5.2.2) - '@typescript-eslint/eslint-plugin': - specifier: 6.8.0 - version: 6.8.0(@typescript-eslint/parser@6.8.0)(eslint@8.51.0)(typescript@5.2.2) - '@typescript-eslint/parser': - specifier: 6.8.0 - version: 6.8.0(eslint@8.51.0)(typescript@5.2.2) + specifier: 12.1.2 + version: 12.1.2(rollup@4.41.1)(tslib@2.8.1)(typescript@5.8.3) covector: - specifier: ^0.10.2 - version: 0.10.2(mocha@10.2.0) + specifier: ^0.12.4 + version: 0.12.4(mocha@10.8.2) eslint: - specifier: 8.51.0 - version: 8.51.0 + specifier: 9.28.0 + version: 9.28.0(jiti@2.4.2) eslint-config-prettier: - specifier: 9.0.0 - version: 9.0.0(eslint@8.51.0) - eslint-config-standard-with-typescript: - specifier: 39.1.1 - version: 39.1.1(@typescript-eslint/eslint-plugin@6.8.0)(eslint-plugin-import@2.28.1)(eslint-plugin-n@16.2.0)(eslint-plugin-promise@6.1.1)(eslint@8.51.0)(typescript@5.2.2) - eslint-plugin-import: - specifier: 2.28.1 - version: 2.28.1(@typescript-eslint/parser@6.8.0)(eslint@8.51.0) - eslint-plugin-n: - specifier: 16.2.0 - version: 16.2.0(eslint@8.51.0) - eslint-plugin-promise: - specifier: 6.1.1 - version: 6.1.1(eslint@8.51.0) + specifier: 10.1.5 + version: 10.1.5(eslint@9.28.0(jiti@2.4.2)) eslint-plugin-security: - specifier: 1.7.1 - version: 1.7.1 + specifier: 3.0.1 + version: 3.0.1 prettier: - specifier: 3.0.3 - version: 3.0.3 + specifier: 3.5.3 + version: 3.5.3 rollup: - specifier: 4.1.4 - version: 4.1.4 + specifier: 4.41.1 + version: 4.41.1 + tslib: + specifier: 2.8.1 + version: 2.8.1 typescript: - specifier: 5.2.2 - version: 5.2.2 + specifier: 5.8.3 + version: 5.8.3 + typescript-eslint: + specifier: 8.34.0 + version: 8.34.0(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3) examples/api: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 + specifier: 2.5.0 + version: 2.5.0 '@tauri-apps/plugin-barcode-scanner': - specifier: 2.0.0-alpha.0 + specifier: ^2.2.0 version: link:../../plugins/barcode-scanner + '@tauri-apps/plugin-biometric': + specifier: ^2.2.1 + version: link:../../plugins/biometric '@tauri-apps/plugin-cli': - specifier: 2.0.0-alpha.1 + specifier: ^2.2.0 version: link:../../plugins/cli '@tauri-apps/plugin-clipboard-manager': - specifier: 2.0.0-alpha.1 + specifier: ^2.2.2 version: link:../../plugins/clipboard-manager '@tauri-apps/plugin-dialog': - specifier: 2.0.0-alpha.1 + specifier: ^2.2.2 version: link:../../plugins/dialog '@tauri-apps/plugin-fs': - specifier: 2.0.0-alpha.1 + specifier: ^2.3.0 version: link:../../plugins/fs + '@tauri-apps/plugin-geolocation': + specifier: ^2.2.0 + version: link:../../plugins/geolocation '@tauri-apps/plugin-global-shortcut': - specifier: 2.0.0-alpha.1 + specifier: ^2.2.1 version: link:../../plugins/global-shortcut + '@tauri-apps/plugin-haptics': + specifier: ^2.2.0 + version: link:../../plugins/haptics '@tauri-apps/plugin-http': - specifier: 2.0.0-alpha.1 + specifier: ^2.4.4 version: link:../../plugins/http + '@tauri-apps/plugin-nfc': + specifier: ^2.2.0 + version: link:../../plugins/nfc '@tauri-apps/plugin-notification': - specifier: 2.0.0-alpha.1 + specifier: ^2.2.2 version: link:../../plugins/notification + '@tauri-apps/plugin-opener': + specifier: ^2.2.7 + version: link:../../plugins/opener '@tauri-apps/plugin-os': - specifier: 2.0.0-alpha.2 + specifier: ^2.2.1 version: link:../../plugins/os '@tauri-apps/plugin-process': - specifier: 2.0.0-alpha.1 + specifier: ^2.2.1 version: link:../../plugins/process '@tauri-apps/plugin-shell': - specifier: 2.0.0-alpha.1 + specifier: ^2.2.1 version: link:../../plugins/shell + '@tauri-apps/plugin-store': + specifier: ^2.2.0 + version: link:../../plugins/store '@tauri-apps/plugin-updater': - specifier: 2.0.0-alpha.1 + specifier: ^2.7.1 version: link:../../plugins/updater '@zerodevx/svelte-json-view': - specifier: 1.0.7 - version: 1.0.7(svelte@4.2.2) + specifier: 1.0.11 + version: 1.0.11(svelte@5.28.2) devDependencies: '@iconify-json/codicon': - specifier: ^1.1.31 - version: 1.1.31 + specifier: ^1.2.12 + version: 1.2.15 '@iconify-json/ph': - specifier: ^1.1.6 - version: 1.1.6 + specifier: ^1.2.2 + version: 1.2.2 '@sveltejs/vite-plugin-svelte': - specifier: ^2.4.6 - version: 2.4.6(svelte@4.2.2)(vite@4.5.0) + specifier: ^5.0.3 + version: 5.0.3(svelte@5.28.2)(vite@6.3.4(jiti@2.4.2)(terser@5.39.0)(tsx@4.19.2)) '@tauri-apps/cli': - specifier: 2.0.0-alpha.16 - version: 2.0.0-alpha.16 + specifier: 2.5.0 + version: 2.5.0 '@unocss/extractor-svelte': - specifier: ^0.56.5 - version: 0.56.5 - internal-ip: - specifier: ^8.0.0 - version: 8.0.0 + specifier: ^66.0.0 + version: 66.0.0 svelte: - specifier: ^4.2.2 - version: 4.2.2 + specifier: ^5.20.4 + version: 5.28.2 unocss: - specifier: ^0.56.5 - version: 0.56.5(postcss@8.4.31)(rollup@4.1.4)(vite@4.5.0) + specifier: ^66.0.0 + version: 66.0.0(postcss@8.5.3)(vite@6.3.4(jiti@2.4.2)(terser@5.39.0)(tsx@4.19.2))(vue@3.5.13(typescript@5.8.3)) vite: - specifier: ^4.5.0 - version: 4.5.0 + specifier: ^6.2.6 + version: 6.3.4(jiti@2.4.2)(terser@5.39.0)(tsx@4.19.2) - plugins/authenticator: + plugins/autostart: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 - devDependencies: - tslib: - specifier: 2.6.0 - version: 2.6.0 + specifier: ^2.0.0 + version: 2.5.0 - plugins/autostart: + plugins/barcode-scanner: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 - devDependencies: - tslib: - specifier: 2.6.0 - version: 2.6.0 + specifier: ^2.0.0 + version: 2.5.0 - plugins/barcode-scanner: + plugins/biometric: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 - devDependencies: - tslib: - specifier: ^2.5.0 - version: 2.6.0 + specifier: ^2.0.0 + version: 2.5.0 plugins/cli: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 - devDependencies: - tslib: - specifier: ^2.4.1 - version: 2.6.0 + specifier: ^2.0.0 + version: 2.5.0 plugins/clipboard-manager: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 - devDependencies: - tslib: - specifier: ^2.4.1 - version: 2.6.0 + specifier: ^2.0.0 + version: 2.5.0 plugins/deep-link: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 - devDependencies: - tslib: - specifier: ^2.5.0 - version: 2.6.0 + specifier: ^2.0.0 + version: 2.5.0 plugins/deep-link/examples/app: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.6 - version: 2.0.0-alpha.6 + specifier: 2.5.0 + version: 2.5.0 '@tauri-apps/plugin-deep-link': - specifier: 2.0.0-alpha.0 + specifier: 2.3.0 version: link:../.. devDependencies: '@tauri-apps/cli': - specifier: 2.0.0-alpha.16 - version: 2.0.0-alpha.16 - internal-ip: - specifier: ^8.0.0 - version: 8.0.0 + specifier: 2.5.0 + version: 2.5.0 typescript: - specifier: ^5.2.2 - version: 5.2.2 + specifier: ^5.7.3 + version: 5.8.3 vite: - specifier: ^4.5.0 - version: 4.5.0 + specifier: ^6.2.6 + version: 6.3.4(jiti@2.4.2)(terser@5.39.0)(tsx@4.19.2) plugins/dialog: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 - devDependencies: - tslib: - specifier: ^2.4.1 - version: 2.6.0 + specifier: ^2.0.0 + version: 2.5.0 plugins/fs: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 - devDependencies: - tslib: - specifier: ^2.4.1 - version: 2.6.0 + specifier: ^2.0.0 + version: 2.5.0 + + plugins/geolocation: + dependencies: + '@tauri-apps/api': + specifier: ^2.0.0 + version: 2.5.0 plugins/global-shortcut: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 - devDependencies: - tslib: - specifier: ^2.4.1 - version: 2.6.0 + specifier: ^2.0.0 + version: 2.5.0 + + plugins/haptics: + dependencies: + '@tauri-apps/api': + specifier: ^2.0.0 + version: 2.5.0 plugins/http: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 - devDependencies: - tslib: - specifier: ^2.5.0 - version: 2.6.0 + specifier: ^2.0.0 + version: 2.5.0 plugins/log: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 - devDependencies: - tslib: - specifier: 2.6.0 - version: 2.6.0 + specifier: ^2.0.0 + version: 2.5.0 + + plugins/nfc: + dependencies: + '@tauri-apps/api': + specifier: ^2.0.0 + version: 2.5.0 plugins/notification: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 - devDependencies: - tslib: - specifier: ^2.4.1 - version: 2.6.0 + specifier: ^2.0.0 + version: 2.5.0 + + plugins/opener: + dependencies: + '@tauri-apps/api': + specifier: ^2.0.0 + version: 2.5.0 plugins/os: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 - devDependencies: - tslib: - specifier: 2.6.0 - version: 2.6.0 + specifier: ^2.0.0 + version: 2.5.0 plugins/positioner: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 - devDependencies: - tslib: - specifier: 2.6.0 - version: 2.6.0 + specifier: ^2.0.0 + version: 2.5.0 plugins/process: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 - devDependencies: - tslib: - specifier: 2.6.0 - version: 2.6.0 + specifier: ^2.0.0 + version: 2.5.0 plugins/shell: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 - devDependencies: - tslib: - specifier: ^2.4.1 - version: 2.6.0 + specifier: ^2.0.0 + version: 2.5.0 plugins/single-instance/examples/vanilla: devDependencies: '@tauri-apps/cli': - specifier: 2.0.0-alpha.16 - version: 2.0.0-alpha.16 + specifier: 2.5.0 + version: 2.5.0 plugins/sql: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 - devDependencies: - tslib: - specifier: 2.6.0 - version: 2.6.0 + specifier: ^2.0.0 + version: 2.5.0 plugins/store: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 + specifier: ^2.0.0 + version: 2.5.0 + + plugins/store/examples/AppSettingsManager: devDependencies: - tslib: - specifier: 2.6.0 - version: 2.6.0 + '@tauri-apps/cli': + specifier: 2.5.0 + version: 2.5.0 + typescript: + specifier: ^5.7.3 + version: 5.8.3 + vite: + specifier: ^6.2.6 + version: 6.3.4(jiti@2.4.2)(terser@5.39.0)(tsx@4.19.2) plugins/stronghold: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 - devDependencies: - tslib: - specifier: 2.6.0 - version: 2.6.0 + specifier: ^2.0.0 + version: 2.5.0 plugins/updater: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 - devDependencies: - tslib: - specifier: ^2.5.0 - version: 2.6.0 + specifier: ^2.0.0 + version: 2.5.0 plugins/upload: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 - devDependencies: - tslib: - specifier: 2.6.0 - version: 2.6.0 + specifier: ^2.0.0 + version: 2.5.0 plugins/websocket: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 - devDependencies: - tslib: - specifier: 2.6.0 - version: 2.6.0 + specifier: ^2.0.0 + version: 2.5.0 - plugins/websocket/examples/svelte-app: + plugins/websocket/examples/tauri-app: dependencies: - '@tauri-apps/plugin-websocket': - specifier: link:../../ + tauri-plugin-websocket-api: + specifier: link:..\.. version: link:../.. devDependencies: - '@sveltejs/adapter-static': - specifier: 2.0.3 - version: 2.0.3(@sveltejs/kit@1.26.0) - '@sveltejs/kit': - 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 - svelte: - specifier: 4.2.2 - version: 4.2.2 - svelte-check: - specifier: 3.5.2 - version: 3.5.2(svelte@4.2.2) - tslib: - specifier: 2.6.2 - version: 2.6.2 + specifier: 2.5.0 + version: 2.5.0 typescript: - specifier: 5.2.2 - version: 5.2.2 + specifier: ^5.7.3 + version: 5.8.3 vite: - specifier: 4.5.0 - version: 4.5.0 + specifier: ^6.2.6 + version: 6.3.4(jiti@2.4.2)(terser@5.39.0)(tsx@4.19.2) plugins/window-state: dependencies: '@tauri-apps/api': - specifier: 2.0.0-alpha.9 - version: 2.0.0-alpha.9 - devDependencies: - tslib: - specifier: 2.6.0 - version: 2.6.0 + specifier: ^2.0.0 + version: 2.5.0 packages: - /@aashutoshrathi/word-wrap@1.2.6: - resolution: {integrity: sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==} - engines: {node: '>=0.10.0'} - dev: true - - /@ampproject/remapping@2.2.1: - resolution: {integrity: sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg==} + '@ampproject/remapping@2.3.0': + resolution: {integrity: sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==} engines: {node: '>=6.0.0'} - dependencies: - '@jridgewell/gen-mapping': 0.3.3 - '@jridgewell/trace-mapping': 0.3.18 - /@antfu/install-pkg@0.1.1: - resolution: {integrity: sha512-LyB/8+bSfa0DFGC06zpCEfs89/XoWZwws5ygEa5D+Xsm3OfI+aXQ86VgVG7Acyef+rSZ5HE7J8rrxzrQeM3PjQ==} - dependencies: - execa: 5.1.1 - find-up: 5.0.0 - dev: true + '@antfu/install-pkg@1.0.0': + resolution: {integrity: sha512-xvX6P/lo1B3ej0OsaErAjqgFYzYVcJpamjLAFLYh9vRJngBrMoUG7aVnrGTeqM7yxbyTD5p3F2+0/QUEh8Vzhw==} + + '@antfu/utils@8.1.1': + resolution: {integrity: sha512-Mex9nXf9vR6AhcXmMrlz/HVgYYZpVGJ6YlPgwl7UnaFpnshXs6EK/oa5Gpf3CzENMjkvEx2tQtntGnb7UtSTOQ==} + + '@babel/helper-string-parser@7.27.1': + resolution: {integrity: sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==} + engines: {node: '>=6.9.0'} + + '@babel/helper-validator-identifier@7.27.1': + resolution: {integrity: sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==} + engines: {node: '>=6.9.0'} - /@antfu/utils@0.7.5: - resolution: {integrity: sha512-dlR6LdS+0SzOAPx/TPRhnoi7hE251OVeT2Snw0RguNbBSbjUHdWr0l3vcUUDg26rEysT89kCbtw1lVorBXLLCg==} - dev: true + '@babel/parser@7.27.1': + resolution: {integrity: sha512-I0dZ3ZpCrJ1c04OqlNsQcKiZlsrXf/kkE4FXzID9rIOYICsAbA8mMDzhW/luRNAHdCNt7os/u8wenklZDlUVUQ==} + engines: {node: '>=6.0.0'} + hasBin: true - /@antfu/utils@0.7.6: - resolution: {integrity: sha512-pvFiLP2BeOKA/ZOS6jxx4XhKzdVLHDhGlFEaZ2flWWYf2xOqVniqpk38I04DFRyz+L0ASggl7SkItTc+ZLju4w==} - dev: true + '@babel/types@7.27.1': + resolution: {integrity: sha512-+EzkxvLNfiUeKMgy/3luqfsCWFRXLb7U6wNQTk60tovuckwB15B191tJWvpp4HjiQWdJkCxO3Wbvc6jlk3Xb2Q==} + engines: {node: '>=6.9.0'} - /@chainsafe/abort-controller@3.0.1: + '@chainsafe/abort-controller@3.0.1': resolution: {integrity: sha512-oyq0qgFJDIIgLpyPwTv4j/sHX/MITatFzY3/b42VSldyZfnUC1lYBx5RwFvzBv1Sq4APOj2VCZO23pDRwy5kew==} engines: {node: '>=6.5'} - dependencies: - event-target-shim: 5.0.1 - dev: true - /@covector/apply@0.9.2(mocha@10.2.0): - resolution: {integrity: sha512-XrNujG6ERUq8bwPCQgOEzuwBCSLKV5nC4AuO+QBpuC0xA9Qz9w025YKYNMIsXxVf0SBscMXKzhBAo9iUDTzKFw==} - dependencies: - '@covector/files': 0.7.1 - effection: 2.0.7(mocha@10.2.0) - semver: 7.5.4 - transitivePeerDependencies: - - encoding - - mocha - dev: true + '@clack/core@0.3.5': + resolution: {integrity: sha512-5cfhQNH+1VQ2xLQlmzXMqUoiaH0lRBq9/CLW9lTyMbuKLC3+xEK01tHVvyut++mLOn5urSHmkm6I0Lg9MaJSTQ==} - /@covector/assemble@0.10.3(mocha@10.2.0): - resolution: {integrity: sha512-LcltbmTDHeCouIGvDJ268UQ2T/JGOjt/vE4lT15BOq3F+RjTdE3B+1XmhhkFzP6Ebp6hnU5mZXFDmWqqrQKWFA==} - dependencies: - '@covector/command': 0.7.0(mocha@10.2.0) - '@covector/files': 0.7.1 - effection: 2.0.7(mocha@10.2.0) - js-yaml: 4.1.0 - lodash: 4.17.21 - remark-frontmatter: 3.0.0 - remark-parse: 9.0.0 - remark-stringify: 9.0.1 - unified: 9.2.2 - transitivePeerDependencies: - - encoding - - mocha - - supports-color - dev: true + '@clack/prompts@0.7.0': + resolution: {integrity: sha512-0MhX9/B4iL6Re04jPrttDm+BsP8y6mS7byuv0BvXgdXhbV5PdlsHt55dvNsuBCPZ7xq1oTAOOuotR9NFbQyMSA==} + bundledDependencies: + - is-unicode-supported - /@covector/changelog@0.10.1(mocha@10.2.0): - resolution: {integrity: sha512-p1kDf6abq8TAKIzLMcieMD+hoP4RamykoPpk3PYHUhZnz0xi1+8sVGEPByCQGb3SI9PCg8CZPuyIA91YtuiTsQ==} - dependencies: - '@covector/files': 0.7.1 - effection: 2.0.7(mocha@10.2.0) - lodash: 4.17.21 - remark-parse: 9.0.0 - remark-stringify: 9.0.1 - unified: 9.2.2 - transitivePeerDependencies: - - encoding - - mocha - - supports-color - dev: true + '@covector/apply@0.10.0': + resolution: {integrity: sha512-/LB0kG0RGsqcQopjg6FX94fUDaVrPSpsU5CaKbdOWXGzRBwMa4MZxiGu1S8mji3xcLE6ALUBQNZpyOKsfxXaGQ==} - /@covector/command@0.7.0(mocha@10.2.0): - resolution: {integrity: sha512-9DGx4tOY9Fkd4AlYbOE0rnesYAYJm7Wr6BUBJlRxErtA0vDAejZ0+jVHZbemB1MbLOaYWXkDf/wD7SLnf06gfw==} - dependencies: - '@effection/process': 2.1.3(mocha@10.2.0) - effection: 2.0.7(mocha@10.2.0) - strip-ansi: 6.0.1 - transitivePeerDependencies: - - encoding - - mocha - dev: true + '@covector/assemble@0.12.0': + resolution: {integrity: sha512-lBXUzc3aIWKW6Xf5I2WhWNi4Eabteu+3GmrKwrxIs5ofBBZDi8ZDd1Sfuh7yraPV7+ytDm2CHc+cJFLzoJYWAQ==} - /@covector/files@0.7.1: - resolution: {integrity: sha512-fGMNfTkjTvgXyj5ctfGxPhxW05SNlLK3V0eiSjP2nMVLEapPtp9ZMJNGqvvoHIs1R2IxURh0iUOjA8O2zQaCfQ==} - dependencies: - '@iarna/toml': 2.2.5 - '@tauri-apps/toml': 2.2.4 - globby: 11.1.0 - js-yaml: 4.1.0 - semver: 7.5.4 - zod: 3.22.4 - zod-validation-error: 1.5.0(zod@3.22.4) - dev: true + '@covector/changelog@0.12.0': + resolution: {integrity: sha512-cWjCdhpRpyeYPh1sRmc+5nAKBNiu/3aYOWt2uEmviDemM2PPa3lMQwn3snmH717MNE+68vhWjKd/9/dhBM1W4Q==} - /@effection/channel@2.0.5: - resolution: {integrity: sha512-Tq1BHVOKcH2Gd5Wsp1kqW1uKU+ZnXxb/wAXeRx57ciOY3bB6+0uOf1GdL9U8YQW5h2WQPBx76RykYLBhgVs9Cw==} - dependencies: - '@effection/core': 2.2.2 - '@effection/events': 2.0.5 - '@effection/stream': 2.0.5 - dev: true + '@covector/command@0.8.0': + resolution: {integrity: sha512-6KDgmQXc8/lSrTJsSfw+zjl+qcW9jy71UXFf1sJ49jUDBKs3dh6RTW3fjjIxYQ9SG1mZ0eGOZbuG5pI1mYvn1Q==} - /@effection/core@2.2.2: - resolution: {integrity: sha512-JdOTXLrflRyBTgvTHwX9l0ItWfcEPUGiUFKhqnMDJT6lf2FUnQ85oKTrDZXco2sQjXKuMtO0dwzmKngos2cTIQ==} - dependencies: - '@chainsafe/abort-controller': 3.0.1 - dev: true + '@covector/files@0.8.0': + resolution: {integrity: sha512-cx0bexTWFYdBnta55U8+c4p7ekzS5AZ8A2R9OXWZDVFajvH7LzPEXgvwi0IfVO26zzWxMyMFhHyugwUF6i+wKg==} - /@effection/events@2.0.5: - resolution: {integrity: sha512-xhF5hX8+ZmCvLuRSSCHwVudm/vm1/U9M9xi8+h0jwECt/2PV26vz+8ZDXbJGh9eF+0TZ+tIHto/X+7bTiRtQxg==} - dependencies: - '@effection/core': 2.2.2 - '@effection/stream': 2.0.5 - dev: true + '@covector/toml@0.2.0': + resolution: {integrity: sha512-bIKZQLaUU1hoXiN1fvae7gNB3eT/8kLo/XlPtYmj/wY+UpukrvDkoWyMz+SRwWlUOjHU2ogrhkaoWCq1BpS43Q==} + engines: {node: '>=18'} - /@effection/fetch@2.0.6(mocha@10.2.0): - resolution: {integrity: sha512-b0fUUe4vWCVopp8GyaP67L7EttGVA1NAYFm+4aLQntR0R3ybfl1uPGz164tM4eVXGwHYEwEkArFV9/oaXePyKA==} - dependencies: - '@effection/core': 2.2.2 - '@effection/mocha': 2.0.7(mocha@10.2.0) - cross-fetch: 3.1.5 - transitivePeerDependencies: - - encoding - - mocha - dev: true + '@effection/channel@2.0.6': + resolution: {integrity: sha512-ugBR6GfhUo1Ltqz472h+48k+s72hkU8x8QI9Zd7FZRuS4z1xdv8I795QgQWD5hBTgl8o36zMVCzyICQpfwwkMw==} + + '@effection/core@2.2.3': + resolution: {integrity: sha512-arg67zzGS+24CkSSn86cDOU80XwlBv9yM4lEJEd19DZhu9J9bkf8Lktm1AP1W5UXLM5mjGjEpIeYo1k/uYF5Fw==} + + '@effection/events@2.0.6': + resolution: {integrity: sha512-G3gHqFIvfa9b2vozkUSvRttjcnqbU+nSGbbXcU4I3lxVcvMPEaMlt4MtuM2E6KNGvABuPYLZMWFxgBmW1BzUqA==} + + '@effection/fetch@2.0.7': + resolution: {integrity: sha512-1lZTmhhtaGjEOMPS6UNhmKjXoJXh8n5hmSAM2d1oZUOPGMnuJaYlyqjCusdlnJF8SgJbwuek9Hux3TEyLV3c1g==} - /@effection/main@2.1.2: + '@effection/main@2.1.2': resolution: {integrity: sha512-202JariBwP210C3Ka+ZHLGymcAuXs8Lg8TECbawpMFhA2w58AZhQB/oc0SOGvHWDarfRjVCMmB2dvQchCAGgnQ==} - dependencies: - '@effection/core': 2.2.2 - chalk: 4.1.2 - stacktrace-parser: 0.1.10 - dev: true - /@effection/mocha@2.0.7(mocha@10.2.0): - resolution: {integrity: sha512-CSb0GEWUDL3BhvQw1FAT79xAypNOFYtQFaBozq2daM8E1Ej4DSJFCixDZahQBbXgLAmftSffeHdhYLDlr4pY/g==} + '@effection/mocha@2.0.8': + resolution: {integrity: sha512-XXL3Vhhu6w8tQNv4EJI6H0+JZBzzi8FI6caCbQdiS7M3FOON9WI3EnorpIsOtZyZoKXaH+8d9543+ufRGzyP+Q==} peerDependencies: mocha: ^10.0.0 - dependencies: - effection: 2.0.7(mocha@10.2.0) - mocha: 10.2.0 - dev: true - /@effection/process@2.1.3(mocha@10.2.0): - resolution: {integrity: sha512-LsSpstWbT0aBMITXR7VyNt4xpdhYQ8Uxc2cw98j7cXbadfnvRN7J7/KJHY97g3g98aDbREPex713bp4G7ef8wQ==} - dependencies: - cross-spawn: 7.0.3 - ctrlc-windows: 2.1.0 - effection: 2.0.7(mocha@10.2.0) - shellwords: 0.1.1 - transitivePeerDependencies: - - encoding - - mocha - dev: true + '@effection/process@2.1.4': + resolution: {integrity: sha512-MBvcCwUzxma2Luk+JSc8we3qDeFEf7rt6XYg6krpytICODHs6VMp1xl8YJhfLqGFza7/WR70FPAoK34BidiIIA==} - /@effection/stream@2.0.5: - resolution: {integrity: sha512-uALkQhCjgc7moeY3H8FG/plfYvgVTmxGOyJscgopRKYJIIuagswD0HD8RiSu1C21PuaUDCqfjMO3LIyNamcIqQ==} - dependencies: - '@effection/core': 2.2.2 - '@effection/subscription': 2.0.5 - dev: true + '@effection/stream@2.0.6': + resolution: {integrity: sha512-cAg6p5S2NKbRF418J9Df3biMY+f0vEjgW46IOyShkMyg0AK/fYXMT6GIiMB5oNGiALkTuj/xsi3DDnEcO4Of+w==} - /@effection/subscription@2.0.5: - resolution: {integrity: sha512-Vsufl5Ywum2HgIjruhh4OJefvFnxYCWXtWZY/yVK3X2rovgdXr2IKphfO00VsXKeP4Uez4BhuiuFF5tq2DKDnw==} - dependencies: - '@effection/core': 2.2.2 - dev: true + '@effection/subscription@2.0.6': + resolution: {integrity: sha512-znTi75JFyC1S0YjyTtFEWNRQbhk01UxOapWELlIkZOwjGIEjcx6+G8y6n9JpZ8OGKmJQ0GBlRMZozsR5gcQvBg==} - /@esbuild/android-arm64@0.18.14: - resolution: {integrity: sha512-rZ2v+Luba5/3D6l8kofWgTnqE+qsC/L5MleKIKFyllHTKHrNBMqeRCnZI1BtRx8B24xMYxeU32iIddRQqMsOsg==} - engines: {node: '>=12'} + '@esbuild/aix-ppc64@0.25.3': + resolution: {integrity: sha512-W8bFfPA8DowP8l//sxjJLSLkD8iEjMc7cBVyP+u4cEv9sM7mdUCkgsj+t0n/BWPFtv7WWCN5Yzj0N6FJNUUqBQ==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [aix] + + '@esbuild/android-arm64@0.25.3': + resolution: {integrity: sha512-XelR6MzjlZuBM4f5z2IQHK6LkK34Cvv6Rj2EntER3lwCBFdg6h2lKbtRjpTTsdEjD/WSe1q8UyPBXP1x3i/wYQ==} + engines: {node: '>=18'} cpu: [arm64] os: [android] - requiresBuild: true - dev: true - optional: true - /@esbuild/android-arm@0.18.14: - resolution: {integrity: sha512-blODaaL+lngG5bdK/t4qZcQvq2BBqrABmYwqPPcS5VRxrCSGHb9R/rA3fqxh7R18I7WU4KKv+NYkt22FDfalcg==} - engines: {node: '>=12'} + '@esbuild/android-arm@0.25.3': + resolution: {integrity: sha512-PuwVXbnP87Tcff5I9ngV0lmiSu40xw1At6i3GsU77U7cjDDB4s0X2cyFuBiDa1SBk9DnvWwnGvVaGBqoFWPb7A==} + engines: {node: '>=18'} cpu: [arm] os: [android] - requiresBuild: true - dev: true - optional: true - /@esbuild/android-x64@0.18.14: - resolution: {integrity: sha512-qSwh8y38QKl+1Iqg+YhvCVYlSk3dVLk9N88VO71U4FUjtiSFylMWK3Ugr8GC6eTkkP4Tc83dVppt2n8vIdlSGg==} - engines: {node: '>=12'} + '@esbuild/android-x64@0.25.3': + resolution: {integrity: sha512-ogtTpYHT/g1GWS/zKM0cc/tIebFjm1F9Aw1boQ2Y0eUQ+J89d0jFY//s9ei9jVIlkYi8AfOjiixcLJSGNSOAdQ==} + engines: {node: '>=18'} cpu: [x64] os: [android] - requiresBuild: true - dev: true - optional: true - /@esbuild/darwin-arm64@0.18.14: - resolution: {integrity: sha512-9Hl2D2PBeDYZiNbnRKRWuxwHa9v5ssWBBjisXFkVcSP5cZqzZRFBUWEQuqBHO4+PKx4q4wgHoWtfQ1S7rUqJ2Q==} - engines: {node: '>=12'} + '@esbuild/darwin-arm64@0.25.3': + resolution: {integrity: sha512-eESK5yfPNTqpAmDfFWNsOhmIOaQA59tAcF/EfYvo5/QWQCzXn5iUSOnqt3ra3UdzBv073ykTtmeLJZGt3HhA+w==} + engines: {node: '>=18'} cpu: [arm64] os: [darwin] - requiresBuild: true - dev: true - optional: true - /@esbuild/darwin-x64@0.18.14: - resolution: {integrity: sha512-ZnI3Dg4ElQ6tlv82qLc/UNHtFsgZSKZ7KjsUNAo1BF1SoYDjkGKHJyCrYyWjFecmXpvvG/KJ9A/oe0H12odPLQ==} - engines: {node: '>=12'} + '@esbuild/darwin-x64@0.25.3': + resolution: {integrity: sha512-Kd8glo7sIZtwOLcPbW0yLpKmBNWMANZhrC1r6K++uDR2zyzb6AeOYtI6udbtabmQpFaxJ8uduXMAo1gs5ozz8A==} + engines: {node: '>=18'} cpu: [x64] os: [darwin] - requiresBuild: true - dev: true - optional: true - /@esbuild/freebsd-arm64@0.18.14: - resolution: {integrity: sha512-h3OqR80Da4oQCIa37zl8tU5MwHQ7qgPV0oVScPfKJK21fSRZEhLE4IIVpmcOxfAVmqjU6NDxcxhYaM8aDIGRLw==} - engines: {node: '>=12'} + '@esbuild/freebsd-arm64@0.25.3': + resolution: {integrity: sha512-EJiyS70BYybOBpJth3M0KLOus0n+RRMKTYzhYhFeMwp7e/RaajXvP+BWlmEXNk6uk+KAu46j/kaQzr6au+JcIw==} + engines: {node: '>=18'} cpu: [arm64] os: [freebsd] - requiresBuild: true - dev: true - optional: true - /@esbuild/freebsd-x64@0.18.14: - resolution: {integrity: sha512-ha4BX+S6CZG4BoH9tOZTrFIYC1DH13UTCRHzFc3GWX74nz3h/N6MPF3tuR3XlsNjMFUazGgm35MPW5tHkn2lzQ==} - engines: {node: '>=12'} + '@esbuild/freebsd-x64@0.25.3': + resolution: {integrity: sha512-Q+wSjaLpGxYf7zC0kL0nDlhsfuFkoN+EXrx2KSB33RhinWzejOd6AvgmP5JbkgXKmjhmpfgKZq24pneodYqE8Q==} + engines: {node: '>=18'} cpu: [x64] os: [freebsd] - requiresBuild: true - dev: true - optional: true - /@esbuild/linux-arm64@0.18.14: - resolution: {integrity: sha512-IXORRe22In7U65NZCzjwAUc03nn8SDIzWCnfzJ6t/8AvGx5zBkcLfknI+0P+hhuftufJBmIXxdSTbzWc8X/V4w==} - engines: {node: '>=12'} + '@esbuild/linux-arm64@0.25.3': + resolution: {integrity: sha512-xCUgnNYhRD5bb1C1nqrDV1PfkwgbswTTBRbAd8aH5PhYzikdf/ddtsYyMXFfGSsb/6t6QaPSzxtbfAZr9uox4A==} + engines: {node: '>=18'} cpu: [arm64] os: [linux] - requiresBuild: true - dev: true - optional: true - /@esbuild/linux-arm@0.18.14: - resolution: {integrity: sha512-5+7vehI1iqru5WRtJyU2XvTOvTGURw3OZxe3YTdE9muNNIdmKAVmSHpB3Vw2LazJk2ifEdIMt/wTWnVe5V98Kg==} - engines: {node: '>=12'} + '@esbuild/linux-arm@0.25.3': + resolution: {integrity: sha512-dUOVmAUzuHy2ZOKIHIKHCm58HKzFqd+puLaS424h6I85GlSDRZIA5ycBixb3mFgM0Jdh+ZOSB6KptX30DD8YOQ==} + engines: {node: '>=18'} cpu: [arm] os: [linux] - requiresBuild: true - dev: true - optional: true - /@esbuild/linux-ia32@0.18.14: - resolution: {integrity: sha512-BfHlMa0nibwpjG+VXbOoqJDmFde4UK2gnW351SQ2Zd4t1N3zNdmUEqRkw/srC1Sa1DRBE88Dbwg4JgWCbNz/FQ==} - engines: {node: '>=12'} + '@esbuild/linux-ia32@0.25.3': + resolution: {integrity: sha512-yplPOpczHOO4jTYKmuYuANI3WhvIPSVANGcNUeMlxH4twz/TeXuzEP41tGKNGWJjuMhotpGabeFYGAOU2ummBw==} + engines: {node: '>=18'} cpu: [ia32] os: [linux] - requiresBuild: true - dev: true - optional: true - /@esbuild/linux-loong64@0.18.14: - resolution: {integrity: sha512-j2/Ex++DRUWIAaUDprXd3JevzGtZ4/d7VKz+AYDoHZ3HjJzCyYBub9CU1wwIXN+viOP0b4VR3RhGClsvyt/xSw==} - engines: {node: '>=12'} + '@esbuild/linux-loong64@0.25.3': + resolution: {integrity: sha512-P4BLP5/fjyihmXCELRGrLd793q/lBtKMQl8ARGpDxgzgIKJDRJ/u4r1A/HgpBpKpKZelGct2PGI4T+axcedf6g==} + engines: {node: '>=18'} cpu: [loong64] os: [linux] - requiresBuild: true - dev: true - optional: true - /@esbuild/linux-mips64el@0.18.14: - resolution: {integrity: sha512-qn2+nc+ZCrJmiicoAnJXJJkZWt8Nwswgu1crY7N+PBR8ChBHh89XRxj38UU6Dkthl2yCVO9jWuafZ24muzDC/A==} - engines: {node: '>=12'} + '@esbuild/linux-mips64el@0.25.3': + resolution: {integrity: sha512-eRAOV2ODpu6P5divMEMa26RRqb2yUoYsuQQOuFUexUoQndm4MdpXXDBbUoKIc0iPa4aCO7gIhtnYomkn2x+bag==} + engines: {node: '>=18'} cpu: [mips64el] os: [linux] - requiresBuild: true - dev: true - optional: true - /@esbuild/linux-ppc64@0.18.14: - resolution: {integrity: sha512-aGzXzd+djqeEC5IRkDKt3kWzvXoXC6K6GyYKxd+wsFJ2VQYnOWE954qV2tvy5/aaNrmgPTb52cSCHFE+Z7Z0yg==} - engines: {node: '>=12'} + '@esbuild/linux-ppc64@0.25.3': + resolution: {integrity: sha512-ZC4jV2p7VbzTlnl8nZKLcBkfzIf4Yad1SJM4ZMKYnJqZFD4rTI+pBG65u8ev4jk3/MPwY9DvGn50wi3uhdaghg==} + engines: {node: '>=18'} cpu: [ppc64] os: [linux] - requiresBuild: true - dev: true - optional: true - /@esbuild/linux-riscv64@0.18.14: - resolution: {integrity: sha512-8C6vWbfr0ygbAiMFLS6OPz0BHvApkT2gCboOGV76YrYw+sD/MQJzyITNsjZWDXJwPu9tjrFQOVG7zijRzBCnLw==} - engines: {node: '>=12'} + '@esbuild/linux-riscv64@0.25.3': + resolution: {integrity: sha512-LDDODcFzNtECTrUUbVCs6j9/bDVqy7DDRsuIXJg6so+mFksgwG7ZVnTruYi5V+z3eE5y+BJZw7VvUadkbfg7QA==} + engines: {node: '>=18'} cpu: [riscv64] os: [linux] - requiresBuild: true - dev: true - optional: true - /@esbuild/linux-s390x@0.18.14: - resolution: {integrity: sha512-G/Lf9iu8sRMM60OVGOh94ZW2nIStksEcITkXdkD09/T6QFD/o+g0+9WVyR/jajIb3A0LvBJ670tBnGe1GgXMgw==} - engines: {node: '>=12'} + '@esbuild/linux-s390x@0.25.3': + resolution: {integrity: sha512-s+w/NOY2k0yC2p9SLen+ymflgcpRkvwwa02fqmAwhBRI3SC12uiS10edHHXlVWwfAagYSY5UpmT/zISXPMW3tQ==} + engines: {node: '>=18'} cpu: [s390x] os: [linux] - requiresBuild: true - dev: true - optional: true - /@esbuild/linux-x64@0.18.14: - resolution: {integrity: sha512-TBgStYBQaa3EGhgqIDM+ECnkreb0wkcKqL7H6m+XPcGUoU4dO7dqewfbm0mWEQYH3kzFHrzjOFNpSAVzDZRSJw==} - engines: {node: '>=12'} + '@esbuild/linux-x64@0.25.3': + resolution: {integrity: sha512-nQHDz4pXjSDC6UfOE1Fw9Q8d6GCAd9KdvMZpfVGWSJztYCarRgSDfOVBY5xwhQXseiyxapkiSJi/5/ja8mRFFA==} + engines: {node: '>=18'} cpu: [x64] os: [linux] - requiresBuild: true - dev: true - optional: true - /@esbuild/netbsd-x64@0.18.14: - resolution: {integrity: sha512-stvCcjyCQR2lMTroqNhAbvROqRjxPEq0oQ380YdXxA81TaRJEucH/PzJ/qsEtsHgXlWFW6Ryr/X15vxQiyRXVg==} - engines: {node: '>=12'} + '@esbuild/netbsd-arm64@0.25.3': + resolution: {integrity: sha512-1QaLtOWq0mzK6tzzp0jRN3eccmN3hezey7mhLnzC6oNlJoUJz4nym5ZD7mDnS/LZQgkrhEbEiTn515lPeLpgWA==} + engines: {node: '>=18'} + cpu: [arm64] + os: [netbsd] + + '@esbuild/netbsd-x64@0.25.3': + resolution: {integrity: sha512-i5Hm68HXHdgv8wkrt+10Bc50zM0/eonPb/a/OFVfB6Qvpiirco5gBA5bz7S2SHuU+Y4LWn/zehzNX14Sp4r27g==} + engines: {node: '>=18'} cpu: [x64] os: [netbsd] - requiresBuild: true - dev: true - optional: true - /@esbuild/openbsd-x64@0.18.14: - resolution: {integrity: sha512-apAOJF14CIsN5ht1PA57PboEMsNV70j3FUdxLmA2liZ20gEQnfTG5QU0FhENo5nwbTqCB2O3WDsXAihfODjHYw==} - engines: {node: '>=12'} + '@esbuild/openbsd-arm64@0.25.3': + resolution: {integrity: sha512-zGAVApJEYTbOC6H/3QBr2mq3upG/LBEXr85/pTtKiv2IXcgKV0RT0QA/hSXZqSvLEpXeIxah7LczB4lkiYhTAQ==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openbsd] + + '@esbuild/openbsd-x64@0.25.3': + resolution: {integrity: sha512-fpqctI45NnCIDKBH5AXQBsD0NDPbEFczK98hk/aa6HJxbl+UtLkJV2+Bvy5hLSLk3LHmqt0NTkKNso1A9y1a4w==} + engines: {node: '>=18'} cpu: [x64] os: [openbsd] - requiresBuild: true - dev: true - optional: true - /@esbuild/sunos-x64@0.18.14: - resolution: {integrity: sha512-fYRaaS8mDgZcGybPn2MQbn1ZNZx+UXFSUoS5Hd2oEnlsyUcr/l3c6RnXf1bLDRKKdLRSabTmyCy7VLQ7VhGdOQ==} - engines: {node: '>=12'} + '@esbuild/sunos-x64@0.25.3': + resolution: {integrity: sha512-ROJhm7d8bk9dMCUZjkS8fgzsPAZEjtRJqCAmVgB0gMrvG7hfmPmz9k1rwO4jSiblFjYmNvbECL9uhaPzONMfgA==} + engines: {node: '>=18'} cpu: [x64] os: [sunos] - requiresBuild: true - dev: true - optional: true - /@esbuild/win32-arm64@0.18.14: - resolution: {integrity: sha512-1c44RcxKEJPrVj62XdmYhxXaU/V7auELCmnD+Ri+UCt+AGxTvzxl9uauQhrFso8gj6ZV1DaORV0sT9XSHOAk8Q==} - engines: {node: '>=12'} + '@esbuild/win32-arm64@0.25.3': + resolution: {integrity: sha512-YWcow8peiHpNBiIXHwaswPnAXLsLVygFwCB3A7Bh5jRkIBFWHGmNQ48AlX4xDvQNoMZlPYzjVOQDYEzWCqufMQ==} + engines: {node: '>=18'} cpu: [arm64] os: [win32] - requiresBuild: true - dev: true - optional: true - /@esbuild/win32-ia32@0.18.14: - resolution: {integrity: sha512-EXAFttrdAxZkFQmpvcAQ2bywlWUsONp/9c2lcfvPUhu8vXBBenCXpoq9YkUvVP639ld3YGiYx0YUQ6/VQz3Maw==} - engines: {node: '>=12'} + '@esbuild/win32-ia32@0.25.3': + resolution: {integrity: sha512-qspTZOIGoXVS4DpNqUYUs9UxVb04khS1Degaw/MnfMe7goQ3lTfQ13Vw4qY/Nj0979BGvMRpAYbs/BAxEvU8ew==} + engines: {node: '>=18'} cpu: [ia32] os: [win32] - requiresBuild: true - dev: true - optional: true - /@esbuild/win32-x64@0.18.14: - resolution: {integrity: sha512-K0QjGbcskx+gY+qp3v4/940qg8JitpXbdxFhRDA1aYoNaPff88+aEwoq45aqJ+ogpxQxmU0ZTjgnrQD/w8iiUg==} - engines: {node: '>=12'} + '@esbuild/win32-x64@0.25.3': + resolution: {integrity: sha512-ICgUR+kPimx0vvRzf+N/7L7tVSQeE3BYY+NhHRHXS1kBuPO7z2+7ea2HbhDyZdTephgvNvKrlDDKUexuCVBVvg==} + engines: {node: '>=18'} cpu: [x64] os: [win32] - requiresBuild: true - dev: true - optional: true - /@eslint-community/eslint-utils@4.4.0(eslint@8.51.0): - resolution: {integrity: sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==} + '@eslint-community/eslint-utils@4.7.0': + resolution: {integrity: sha512-dyybb3AcajC7uha6CvhdVRJqaKyn7w2YKqKyAN37NKYgZT36w+iRb0Dymmc5qEJ549c/S31cMMSFd75bteCpCw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 - dependencies: - eslint: 8.51.0 - eslint-visitor-keys: 3.4.3 - dev: true - /@eslint-community/regexpp@4.5.1: - resolution: {integrity: sha512-Z5ba73P98O1KUYCCJTUeVpja9RcGoMdncZ6T49FCUl2lN38JtCJ+3WgIDBv0AuY4WChU5PmtJmOCTlN6FZTFKQ==} + '@eslint-community/regexpp@4.12.1': + resolution: {integrity: sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==} engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} - dev: true - /@eslint-community/regexpp@4.9.1: - resolution: {integrity: sha512-Y27x+MBLjXa+0JWDhykM3+JE+il3kHKAEqabfEWq3SDhZjLYb6/BHL/JKFnH3fe207JaXkyDo685Oc2Glt6ifA==} - engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} - dev: true + '@eslint/config-array@0.20.0': + resolution: {integrity: sha512-fxlS1kkIjx8+vy2SjuCB94q3htSNrufYTXubwiBFeaQHbH6Ipi43gFJq2zCMt6PHhImH3Xmr0NksKDvchWlpQQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - /@eslint/eslintrc@2.1.2: - resolution: {integrity: sha512-+wvgpDsrB1YqAMdEUCcnTlpfVBH7Vqn6A/NT3D8WVXFIaKMlErPIZT3oCIAVCOtarRpMtelZLqJeU3t7WY6X6g==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - dependencies: - ajv: 6.12.6 - debug: 4.3.4(supports-color@8.1.1) - espree: 9.6.1 - globals: 13.20.0 - ignore: 5.2.4 - import-fresh: 3.3.0 - js-yaml: 4.1.0 - minimatch: 3.1.2 - strip-json-comments: 3.1.1 - transitivePeerDependencies: - - supports-color - dev: true + '@eslint/config-helpers@0.2.1': + resolution: {integrity: sha512-RI17tsD2frtDu/3dmI7QRrD4bedNKPM08ziRYaC5AhkGrzIAJelm9kJU1TznK+apx6V+cqRz8tfpEeG3oIyjxw==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - /@eslint/js@8.51.0: - resolution: {integrity: sha512-HxjQ8Qn+4SI3/AFv6sOrDB+g6PpUTDwSJiQqOrnneEk8L71161srI9gjzzZvYVbzHiVg/BvcH95+cK/zfIt4pg==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - dev: true + '@eslint/core@0.14.0': + resolution: {integrity: sha512-qIbV0/JZr7iSDjqAc60IqbLdsj9GDt16xQtWD+B78d/HAlvysGdZZ6rpJHGAc2T0FQx1X6thsSPdnoiGKdNtdg==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - /@fastify/busboy@2.0.0: - resolution: {integrity: sha512-JUFJad5lv7jxj926GPgymrWQxxjPYuJNiNjNMzqT+HiuP6Vl3dk5xzG+8sTX96np0ZAluvaMzPsjhHZ5rNuNQQ==} - engines: {node: '>=14'} - dev: true + '@eslint/eslintrc@3.3.1': + resolution: {integrity: sha512-gtF186CXhIl1p4pJNGZw8Yc6RlshoePRvE0X91oPGb3vZ8pM3qOS9W9NGPat9LziaBV7XrJWGylNQXkGcnM3IQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - /@humanwhocodes/config-array@0.11.12: - resolution: {integrity: sha512-NlGesA1usRNn6ctHCZ21M4/dKPgW9Nn1FypRdIKKgZOKzkVV4T1FlK5mBiLhHBCDmEbdQG0idrcXlbZfksJ+RA==} - engines: {node: '>=10.10.0'} - dependencies: - '@humanwhocodes/object-schema': 2.0.0 - debug: 4.3.4(supports-color@8.1.1) - minimatch: 3.1.2 - transitivePeerDependencies: - - supports-color - dev: true + '@eslint/js@9.28.0': + resolution: {integrity: sha512-fnqSjGWd/CoIp4EXIxWVK/sHA6DOHN4+8Ix2cX5ycOY7LG0UY8nHCU5pIp2eaE1Mc7Qd8kHspYNzYXT2ojPLzg==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + '@eslint/object-schema@2.1.6': + resolution: {integrity: sha512-RBMg5FRL0I0gs51M/guSAj5/e14VQ4tpZnQNWwuDT66P14I43ItmPfIZRhO9fUVIPOAQXU47atlywZ/czoqFPA==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - /@humanwhocodes/module-importer@1.0.1: + '@eslint/plugin-kit@0.3.1': + resolution: {integrity: sha512-0J+zgWxHN+xXONWIyPWKFMgVuJoZuGiIFu8yxk7RJjxkzpGmyja5wRFqZIVtjDVOQpV+Rw0iOAjYPE2eQyjr0w==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + '@humanfs/core@0.19.1': + resolution: {integrity: sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA==} + engines: {node: '>=18.18.0'} + + '@humanfs/node@0.16.6': + resolution: {integrity: sha512-YuI2ZHQL78Q5HbhDiBA1X4LmYdXCKCMQIfw0pw7piHJwyREFebJUvrQN4cMssyES6x+vfUbx1CIpaQUKYdQZOw==} + engines: {node: '>=18.18.0'} + + '@humanwhocodes/module-importer@1.0.1': resolution: {integrity: sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==} engines: {node: '>=12.22'} - dev: true - /@humanwhocodes/object-schema@2.0.0: - resolution: {integrity: sha512-9S9QrXY2K0L4AGDcSgTi9vgiCcG8VcBv4Mp7/1hDPYoswIy6Z6KO5blYto82BT8M0MZNRWmCFLpCs3HlpYGGdw==} - dev: true + '@humanwhocodes/retry@0.3.1': + resolution: {integrity: sha512-JBxkERygn7Bv/GbN5Rv8Ul6LVknS+5Bp6RgDC/O8gEBU/yeH5Ui5C/OlWrTb6qct7LjjfT6Re2NxB0ln0yYybA==} + engines: {node: '>=18.18'} - /@iarna/toml@2.2.5: - resolution: {integrity: sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==} - dev: true + '@humanwhocodes/retry@0.4.2': + resolution: {integrity: sha512-xeO57FpIu4p1Ri3Jq/EXq4ClRm86dVF2z/+kvFnyqVYRavTZmaFaUBbWCOuuTh0o/g7DSsk6kc2vrS4Vl5oPOQ==} + engines: {node: '>=18.18'} - /@iconify-json/codicon@1.1.31: - resolution: {integrity: sha512-UO59/uCcnt6sscsAH6TBdNJiMn34luXmYKSA3lm9QwMWASSbdJl2DpuooSa6OK8g2HMESvUXObTEyp5v9xpxXg==} - dependencies: - '@iconify/types': 2.0.0 - dev: true + '@iconify-json/codicon@1.2.15': + resolution: {integrity: sha512-k1jFRFAQHWkYcKVja4Bc6GItN4AobOXqqKodZdG1o6zOX7qXXBNVLhyea4ctYomj+F4nrfgxn7Zp8iruHYOOEw==} - /@iconify-json/ph@1.1.6: - resolution: {integrity: sha512-dexzEndlXQX/sbQhnEpA94Pby6JCGV2tZToSGcPPQpbilDGyk5VMd0ymusYoocRAn6+qLpGRvMoz5XFKGqP+VA==} - dependencies: - '@iconify/types': 2.0.0 - dev: true + '@iconify-json/ph@1.2.2': + resolution: {integrity: sha512-PgkEZNtqa8hBGjHXQa4pMwZa93hmfu8FUSjs/nv4oUU6yLsgv+gh9nu28Kqi8Fz9CCVu4hj1MZs9/60J57IzFw==} - /@iconify/types@2.0.0: + '@iconify/types@2.0.0': resolution: {integrity: sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg==} - dev: true - /@iconify/utils@2.1.11: - resolution: {integrity: sha512-M/w3PkN8zQYXi8N6qK/KhnYMfEbbb6Sk8RZVn8g+Pmmu5ybw177RpsaGwpziyHeUsu4etrexYSWq3rwnIqzYCg==} - dependencies: - '@antfu/install-pkg': 0.1.1 - '@antfu/utils': 0.7.5 - '@iconify/types': 2.0.0 - debug: 4.3.4(supports-color@8.1.1) - kolorist: 1.8.0 - local-pkg: 0.4.3 - transitivePeerDependencies: - - supports-color - dev: true + '@iconify/utils@2.3.0': + resolution: {integrity: sha512-GmQ78prtwYW6EtzXRU1rY+KwOKfz32PD7iJh6Iyqw68GiKuoZ2A6pRtzWONz5VQJbp50mEjXh/7NkumtrAgRKA==} - /@jridgewell/gen-mapping@0.3.3: - resolution: {integrity: sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==} + '@jridgewell/gen-mapping@0.3.8': + resolution: {integrity: sha512-imAbBGkb+ebQyxKgzv5Hu2nmROxoDOXHh80evxdoXNOrvAnVx7zimzc1Oo5h9RlfV4vPXaE2iM5pOFbvOCClWA==} engines: {node: '>=6.0.0'} - dependencies: - '@jridgewell/set-array': 1.1.2 - '@jridgewell/sourcemap-codec': 1.4.15 - '@jridgewell/trace-mapping': 0.3.18 - /@jridgewell/resolve-uri@3.1.0: - resolution: {integrity: sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==} + '@jridgewell/resolve-uri@3.1.2': + resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==} engines: {node: '>=6.0.0'} - /@jridgewell/set-array@1.1.2: - resolution: {integrity: sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==} + '@jridgewell/set-array@1.2.1': + resolution: {integrity: sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==} engines: {node: '>=6.0.0'} - /@jridgewell/source-map@0.3.5: - resolution: {integrity: sha512-UTYAUj/wviwdsMfzoSJspJxbkH5o1snzwX0//0ENX1u/55kkZZkcTZP6u9bwKGkv+dkk9at4m1Cpt0uY80kcpQ==} - dependencies: - '@jridgewell/gen-mapping': 0.3.3 - '@jridgewell/trace-mapping': 0.3.18 - dev: true - - /@jridgewell/sourcemap-codec@1.4.14: - resolution: {integrity: sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==} + '@jridgewell/source-map@0.3.6': + resolution: {integrity: sha512-1ZJTZebgqllO79ue2bm3rIGud/bOe0pP5BjSRCRxxYkEZS8STV7zN84UBbiYu7jy+eCKSnVIUgoWWE/tt+shMQ==} - /@jridgewell/sourcemap-codec@1.4.15: - resolution: {integrity: sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==} + '@jridgewell/sourcemap-codec@1.5.0': + resolution: {integrity: sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==} - /@jridgewell/trace-mapping@0.3.18: - resolution: {integrity: sha512-w+niJYzMHdd7USdiH2U6869nqhD2nbfZXND5Yp93qIbEmnDNk7PD48o+YchRVpzMU7M6jVCbenTR7PA1FLQ9pA==} - dependencies: - '@jridgewell/resolve-uri': 3.1.0 - '@jridgewell/sourcemap-codec': 1.4.14 + '@jridgewell/trace-mapping@0.3.25': + resolution: {integrity: sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==} - /@nodelib/fs.scandir@2.1.5: + '@nodelib/fs.scandir@2.1.5': resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} - dependencies: - '@nodelib/fs.stat': 2.0.5 - run-parallel: 1.2.0 - dev: true - /@nodelib/fs.stat@2.0.5: + '@nodelib/fs.stat@2.0.5': resolution: {integrity: sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==} engines: {node: '>= 8'} - dev: true - /@nodelib/fs.walk@1.2.8: + '@nodelib/fs.walk@1.2.8': resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} engines: {node: '>= 8'} - dependencies: - '@nodelib/fs.scandir': 2.1.5 - fastq: 1.15.0 - dev: true - /@polka/url@1.0.0-next.21: - resolution: {integrity: sha512-a5Sab1C4/icpTZVzZc5Ghpz88yQtGOyNqYXcZgOssB2uuAr+wF/MvN6bgtW32q7HHrvBki+BsZ0OuNv6EV3K9g==} - dev: true + '@polka/url@1.0.0-next.28': + resolution: {integrity: sha512-8LduaNlMZGwdZ6qWrKlfa+2M4gahzFkprZiAt2TF8uS0qQgBizKXpXURqvTJ4WtmupWxaLqjRb2UCTe72mu+Aw==} - /@rollup/plugin-node-resolve@15.2.3(rollup@4.1.4): - resolution: {integrity: sha512-j/lym8nf5E21LwBT4Df1VD6hRO2L2iwUeUmP7litikRsVp1H6NWx20NEp0Y7su+7XGc476GnXXc4kFeZNGmaSQ==} + '@rollup/plugin-node-resolve@16.0.1': + resolution: {integrity: sha512-tk5YCxJWIG81umIvNkSod2qK5KyQW19qcBF/B78n1bjtOON6gzKoVeSzAE8yHCZEDmqkHKkxplExA8KzdJLJpA==} engines: {node: '>=14.0.0'} peerDependencies: rollup: ^2.78.0||^3.0.0||^4.0.0 peerDependenciesMeta: rollup: optional: true - dependencies: - '@rollup/pluginutils': 5.0.2(rollup@4.1.4) - '@types/resolve': 1.20.2 - deepmerge: 4.3.1 - is-builtin-module: 3.2.1 - is-module: 1.0.0 - resolve: 1.22.2 - rollup: 4.1.4 - dev: true - /@rollup/plugin-terser@0.4.4(rollup@4.1.4): + '@rollup/plugin-terser@0.4.4': resolution: {integrity: sha512-XHeJC5Bgvs8LfukDwWZp7yeqin6ns8RTl2B9avbejt6tZqsqvVoWI7ZTQrcNsfKEDWBTnTxM8nMDkO2IFFbd0A==} engines: {node: '>=14.0.0'} peerDependencies: @@ -984,15 +716,9 @@ packages: peerDependenciesMeta: rollup: optional: true - dependencies: - rollup: 4.1.4 - serialize-javascript: 6.0.1 - smob: 1.4.0 - terser: 5.19.1 - dev: true - /@rollup/plugin-typescript@11.1.5(rollup@4.1.4)(typescript@5.2.2): - resolution: {integrity: sha512-rnMHrGBB0IUEv69Q8/JGRD/n4/n6b3nfpufUu26axhUcboUzv/twfZU8fIBbTOphRAe0v8EyxzeDpKXqGHfyDA==} + '@rollup/plugin-typescript@12.1.2': + resolution: {integrity: sha512-cdtSp154H5sv637uMr1a8OTWB0L1SWDSm1rDGiyfcGcvQ6cuTs4MDk2BVEBGysUWago4OJN4EQZqOTl/QY3Jgg==} engines: {node: '>=14.0.0'} peerDependencies: rollup: ^2.14.0||^3.0.0||^4.0.0 @@ -1003,2806 +729,3058 @@ packages: optional: true tslib: optional: true - dependencies: - '@rollup/pluginutils': 5.0.2(rollup@4.1.4) - resolve: 1.22.2 - rollup: 4.1.4 - typescript: 5.2.2 - dev: true - - /@rollup/pluginutils@5.0.2(rollup@4.1.4): - resolution: {integrity: sha512-pTd9rIsP92h+B6wWwFbW8RkZv4hiR/xKsqre4SIuAOaOEQRxi0lqLke9k2/7WegC85GgUs9pjmOjCUi3In4vwA==} - engines: {node: '>=14.0.0'} - peerDependencies: - rollup: ^1.20.0||^2.0.0||^3.0.0 - peerDependenciesMeta: - rollup: - optional: true - dependencies: - '@types/estree': 1.0.1 - estree-walker: 2.0.2 - picomatch: 2.3.1 - rollup: 4.1.4 - dev: true - /@rollup/pluginutils@5.0.5(rollup@4.1.4): - resolution: {integrity: sha512-6aEYR910NyP73oHiJglti74iRyOwgFU4x3meH/H8OJx6Ry0j6cOVZ5X/wTvub7G7Ao6qaHBEaNsV3GLJkSsF+Q==} + '@rollup/pluginutils@5.1.4': + resolution: {integrity: sha512-USm05zrsFxYLPdWWq+K3STlWiT/3ELn3RcV5hJMghpeAIhxfsUIg6mt12CBJBInWMV4VneoV7SfGv8xIwo2qNQ==} engines: {node: '>=14.0.0'} peerDependencies: rollup: ^1.20.0||^2.0.0||^3.0.0||^4.0.0 peerDependenciesMeta: rollup: optional: true - dependencies: - '@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: - resolution: {integrity: sha512-WlzkuFvpKl6CLFdc3V6ESPt7gq5Vrimd2Yv9IzKXdOpgbH4cdDSS1JLiACX8toygihtH5OlxyQzhXOph7Ovlpw==} + '@rollup/rollup-android-arm-eabi@4.41.1': + resolution: {integrity: sha512-NELNvyEWZ6R9QMkiytB4/L4zSEaBC03KIXEghptLGLZWJ6VPrL63ooZQCOnlx36aQPGhzuOMwDerC1Eb2VmrLw==} cpu: [arm] os: [android] - requiresBuild: true - dev: true - optional: true - /@rollup/rollup-android-arm64@4.1.4: - resolution: {integrity: sha512-D1e+ABe56T9Pq2fD+R3ybe1ylCDzu3tY4Qm2Mj24R9wXNCq35+JbFbOpc2yrroO2/tGhTobmEl2Bm5xfE/n8RA==} + '@rollup/rollup-android-arm64@4.41.1': + resolution: {integrity: sha512-DXdQe1BJ6TK47ukAoZLehRHhfKnKg9BjnQYUu9gzhI8Mwa1d2fzxA1aw2JixHVl403bwp1+/o/NhhHtxWJBgEA==} cpu: [arm64] os: [android] - requiresBuild: true - dev: true - optional: true - /@rollup/rollup-darwin-arm64@4.1.4: - resolution: {integrity: sha512-7vTYrgEiOrjxnjsgdPB+4i7EMxbVp7XXtS+50GJYj695xYTTEMn3HZVEvgtwjOUkAP/Q4HDejm4fIAjLeAfhtg==} + '@rollup/rollup-darwin-arm64@4.41.1': + resolution: {integrity: sha512-5afxvwszzdulsU2w8JKWwY8/sJOLPzf0e1bFuvcW5h9zsEg+RQAojdW0ux2zyYAz7R8HvvzKCjLNJhVq965U7w==} cpu: [arm64] os: [darwin] - requiresBuild: true - dev: true - optional: true - /@rollup/rollup-darwin-x64@4.1.4: - resolution: {integrity: sha512-eGJVZScKSLZkYjhTAESCtbyTBq9SXeW9+TX36ki5gVhDqJtnQ5k0f9F44jNK5RhAMgIj0Ht9+n6HAgH0gUUyWQ==} + '@rollup/rollup-darwin-x64@4.41.1': + resolution: {integrity: sha512-egpJACny8QOdHNNMZKf8xY0Is6gIMz+tuqXlusxquWu3F833DcMwmGM7WlvCO9sB3OsPjdC4U0wHw5FabzCGZg==} cpu: [x64] os: [darwin] - requiresBuild: true - dev: true - optional: true - /@rollup/rollup-linux-arm-gnueabihf@4.1.4: - resolution: {integrity: sha512-HnigYSEg2hOdX1meROecbk++z1nVJDpEofw9V2oWKqOWzTJlJf1UXVbDE6Hg30CapJxZu5ga4fdAQc/gODDkKg==} + '@rollup/rollup-freebsd-arm64@4.41.1': + resolution: {integrity: sha512-DBVMZH5vbjgRk3r0OzgjS38z+atlupJ7xfKIDJdZZL6sM6wjfDNo64aowcLPKIx7LMQi8vybB56uh1Ftck/Atg==} + cpu: [arm64] + os: [freebsd] + + '@rollup/rollup-freebsd-x64@4.41.1': + resolution: {integrity: sha512-3FkydeohozEskBxNWEIbPfOE0aqQgB6ttTkJ159uWOFn42VLyfAiyD9UK5mhu+ItWzft60DycIN1Xdgiy8o/SA==} + cpu: [x64] + os: [freebsd] + + '@rollup/rollup-linux-arm-gnueabihf@4.41.1': + resolution: {integrity: sha512-wC53ZNDgt0pqx5xCAgNunkTzFE8GTgdZ9EwYGVcg+jEjJdZGtq9xPjDnFgfFozQI/Xm1mh+D9YlYtl+ueswNEg==} cpu: [arm] os: [linux] - requiresBuild: true - dev: true - optional: true - /@rollup/rollup-linux-arm64-gnu@4.1.4: - resolution: {integrity: sha512-TzJ+N2EoTLWkaClV2CUhBlj6ljXofaYzF/R9HXqQ3JCMnCHQZmQnbnZllw7yTDp0OG5whP4gIPozR4QiX+00MQ==} - cpu: [arm64] + '@rollup/rollup-linux-arm-musleabihf@4.41.1': + resolution: {integrity: sha512-jwKCca1gbZkZLhLRtsrka5N8sFAaxrGz/7wRJ8Wwvq3jug7toO21vWlViihG85ei7uJTpzbXZRcORotE+xyrLA==} + cpu: [arm] os: [linux] - requiresBuild: true - dev: true - optional: true - /@rollup/rollup-linux-arm64-musl@4.1.4: - resolution: {integrity: sha512-aVPmNMdp6Dlo2tWkAduAD/5TL/NT5uor290YvjvFvCv0Q3L7tVdlD8MOGDL+oRSw5XKXKAsDzHhUOPUNPRHVTQ==} + '@rollup/rollup-linux-arm64-gnu@4.41.1': + resolution: {integrity: sha512-g0UBcNknsmmNQ8V2d/zD2P7WWfJKU0F1nu0k5pW4rvdb+BIqMm8ToluW/eeRmxCared5dD76lS04uL4UaNgpNA==} cpu: [arm64] os: [linux] - requiresBuild: true - dev: true - optional: true - /@rollup/rollup-linux-x64-gnu@4.1.4: - resolution: {integrity: sha512-77Fb79ayiDad0grvVsz4/OB55wJRyw9Ao+GdOBA9XywtHpuq5iRbVyHToGxWquYWlEf6WHFQQnFEttsAzboyKg==} + '@rollup/rollup-linux-arm64-musl@4.41.1': + resolution: {integrity: sha512-XZpeGB5TKEZWzIrj7sXr+BEaSgo/ma/kCgrZgL0oo5qdB1JlTzIYQKel/RmhT6vMAvOdM2teYlAaOGJpJ9lahg==} + cpu: [arm64] + os: [linux] + + '@rollup/rollup-linux-loongarch64-gnu@4.41.1': + resolution: {integrity: sha512-bkCfDJ4qzWfFRCNt5RVV4DOw6KEgFTUZi2r2RuYhGWC8WhCA8lCAJhDeAmrM/fdiAH54m0mA0Vk2FGRPyzI+tw==} + cpu: [loong64] + os: [linux] + + '@rollup/rollup-linux-powerpc64le-gnu@4.41.1': + resolution: {integrity: sha512-3mr3Xm+gvMX+/8EKogIZSIEF0WUu0HL9di+YWlJpO8CQBnoLAEL/roTCxuLncEdgcfJcvA4UMOf+2dnjl4Ut1A==} + cpu: [ppc64] + os: [linux] + + '@rollup/rollup-linux-riscv64-gnu@4.41.1': + resolution: {integrity: sha512-3rwCIh6MQ1LGrvKJitQjZFuQnT2wxfU+ivhNBzmxXTXPllewOF7JR1s2vMX/tWtUYFgphygxjqMl76q4aMotGw==} + cpu: [riscv64] + os: [linux] + + '@rollup/rollup-linux-riscv64-musl@4.41.1': + resolution: {integrity: sha512-LdIUOb3gvfmpkgFZuccNa2uYiqtgZAz3PTzjuM5bH3nvuy9ty6RGc/Q0+HDFrHrizJGVpjnTZ1yS5TNNjFlklw==} + cpu: [riscv64] + os: [linux] + + '@rollup/rollup-linux-s390x-gnu@4.41.1': + resolution: {integrity: sha512-oIE6M8WC9ma6xYqjvPhzZYk6NbobIURvP/lEbh7FWplcMO6gn7MM2yHKA1eC/GvYwzNKK/1LYgqzdkZ8YFxR8g==} + cpu: [s390x] + os: [linux] + + '@rollup/rollup-linux-x64-gnu@4.41.1': + resolution: {integrity: sha512-cWBOvayNvA+SyeQMp79BHPK8ws6sHSsYnK5zDcsC3Hsxr1dgTABKjMnMslPq1DvZIp6uO7kIWhiGwaTdR4Og9A==} cpu: [x64] os: [linux] - requiresBuild: true - dev: true - optional: true - /@rollup/rollup-linux-x64-musl@4.1.4: - resolution: {integrity: sha512-/t6C6niEQTqmQTVTD9TDwUzxG91Mlk69/v0qodIPUnjjB3wR4UA3klg+orR2SU3Ux2Cgf2pWPL9utK80/1ek8g==} + '@rollup/rollup-linux-x64-musl@4.41.1': + resolution: {integrity: sha512-y5CbN44M+pUCdGDlZFzGGBSKCA4A/J2ZH4edTYSSxFg7ce1Xt3GtydbVKWLlzL+INfFIZAEg1ZV6hh9+QQf9YQ==} cpu: [x64] os: [linux] - requiresBuild: true - dev: true - optional: true - /@rollup/rollup-win32-arm64-msvc@4.1.4: - resolution: {integrity: sha512-ZY5BHHrOPkMbCuGWFNpJH0t18D2LU6GMYKGaqaWTQ3CQOL57Fem4zE941/Ek5pIsVt70HyDXssVEFQXlITI5Gg==} + '@rollup/rollup-win32-arm64-msvc@4.41.1': + resolution: {integrity: sha512-lZkCxIrjlJlMt1dLO/FbpZbzt6J/A8p4DnqzSa4PWqPEUUUnzXLeki/iyPLfV0BmHItlYgHUqJe+3KiyydmiNQ==} cpu: [arm64] os: [win32] - requiresBuild: true - dev: true - optional: true - /@rollup/rollup-win32-ia32-msvc@4.1.4: - resolution: {integrity: sha512-XG2mcRfFrJvYyYaQmvCIvgfkaGinfXrpkBuIbJrTl9SaIQ8HumheWTIwkNz2mktCKwZfXHQNpO7RgXLIGQ7HXA==} + '@rollup/rollup-win32-ia32-msvc@4.41.1': + resolution: {integrity: sha512-+psFT9+pIh2iuGsxFYYa/LhS5MFKmuivRsx9iPJWNSGbh2XVEjk90fmpUEjCnILPEPJnikAU6SFDiEUyOv90Pg==} cpu: [ia32] os: [win32] - requiresBuild: true - dev: true - optional: true - /@rollup/rollup-win32-x64-msvc@4.1.4: - resolution: {integrity: sha512-ANFqWYPwkhIqPmXw8vm0GpBEHiPpqcm99jiiAp71DbCSqLDhrtr019C5vhD0Bw4My+LmMvciZq6IsWHqQpl2ZQ==} + '@rollup/rollup-win32-x64-msvc@4.41.1': + resolution: {integrity: sha512-Wq2zpapRYLfi4aKxf2Xff0tN+7slj2d4R87WEzqw7ZLsVvO5zwYCIuEGSZYiK41+GlwUo1HiR+GdkLEJnCKTCw==} cpu: [x64] os: [win32] - requiresBuild: true - dev: true - optional: true - - /@sveltejs/adapter-static@2.0.3(@sveltejs/kit@1.26.0): - resolution: {integrity: sha512-VUqTfXsxYGugCpMqQv1U0LIdbR3S5nBkMMDmpjGVJyM6Q2jHVMFtdWJCkeHMySc6mZxJ+0eZK3T7IgmUCDrcUQ==} - peerDependencies: - '@sveltejs/kit': ^1.5.0 - dependencies: - '@sveltejs/kit': 1.26.0(svelte@4.2.2)(vite@4.5.0) - dev: true - /@sveltejs/kit@1.26.0(svelte@4.2.2)(vite@4.5.0): - resolution: {integrity: sha512-CV/AlTziC05yrz7UjVqEd0pH6+2dnrbmcnHGr2d3jXtmOgzNnlDkXtX8g3BfJ6nntsPD+0jtS2PzhvRHblRz4A==} - engines: {node: ^16.14 || >=18} - hasBin: true - requiresBuild: true + '@sveltejs/acorn-typescript@1.0.5': + resolution: {integrity: sha512-IwQk4yfwLdibDlrXVE04jTZYlLnwsTT2PIOQQGNLWfjavGifnk1JD1LcZjZaBTRcxZu2FfPfNLOE04DSu9lqtQ==} peerDependencies: - svelte: ^3.54.0 || ^4.0.0-next.0 - vite: ^4.0.0 - dependencies: - '@sveltejs/vite-plugin-svelte': 2.4.6(svelte@4.2.2)(vite@4.5.0) - '@types/cookie': 0.5.1 - cookie: 0.5.0 - devalue: 4.3.2 - esm-env: 1.0.0 - kleur: 4.1.5 - magic-string: 0.30.5 - mrmime: 1.0.1 - sade: 1.8.1 - set-cookie-parser: 2.6.0 - sirv: 2.0.3 - svelte: 4.2.2 - tiny-glob: 0.2.9 - undici: 5.26.4 - vite: 4.5.0 - transitivePeerDependencies: - - supports-color - dev: true + acorn: ^8.9.0 - /@sveltejs/vite-plugin-svelte-inspector@1.0.4(@sveltejs/vite-plugin-svelte@2.4.6)(svelte@4.2.2)(vite@4.5.0): - resolution: {integrity: sha512-zjiuZ3yydBtwpF3bj0kQNV0YXe+iKE545QGZVTaylW3eAzFr+pJ/cwK8lZEaRp4JtaJXhD5DyWAV4AxLh6DgaQ==} - engines: {node: ^14.18.0 || >= 16} + '@sveltejs/vite-plugin-svelte-inspector@4.0.1': + resolution: {integrity: sha512-J/Nmb2Q2y7mck2hyCX4ckVHcR5tu2J+MtBEQqpDrrgELZ2uvraQcK/ioCV61AqkdXFgriksOKIceDcQmqnGhVw==} + engines: {node: ^18.0.0 || ^20.0.0 || >=22} peerDependencies: - '@sveltejs/vite-plugin-svelte': ^2.2.0 - svelte: ^3.54.0 || ^4.0.0 - vite: ^4.0.0 - dependencies: - '@sveltejs/vite-plugin-svelte': 2.4.6(svelte@4.2.2)(vite@4.5.0) - debug: 4.3.4(supports-color@8.1.1) - svelte: 4.2.2 - vite: 4.5.0 - transitivePeerDependencies: - - supports-color - dev: true + '@sveltejs/vite-plugin-svelte': ^5.0.0 + svelte: ^5.0.0 + vite: ^6.0.0 - /@sveltejs/vite-plugin-svelte@2.4.6(svelte@4.2.2)(vite@4.5.0): - resolution: {integrity: sha512-zO79p0+DZnXPnF0ltIigWDx/ux7Ni+HRaFOw720Qeivc1azFUrJxTl0OryXVibYNx1hCboGia1NRV3x8RNv4cA==} - engines: {node: ^14.18.0 || >= 16} + '@sveltejs/vite-plugin-svelte@5.0.3': + resolution: {integrity: sha512-MCFS6CrQDu1yGwspm4qtli0e63vaPCehf6V7pIMP15AsWgMKrqDGCPFF/0kn4SP0ii4aySu4Pa62+fIRGFMjgw==} + engines: {node: ^18.0.0 || ^20.0.0 || >=22} peerDependencies: - svelte: ^3.54.0 || ^4.0.0 - 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(supports-color@8.1.1) - deepmerge: 4.3.1 - kleur: 4.1.5 - magic-string: 0.30.5 - svelte: 4.2.2 - svelte-hmr: 0.15.3(svelte@4.2.2) - vite: 4.5.0 - vitefu: 0.2.4(vite@4.5.0) - transitivePeerDependencies: - - 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 + svelte: ^5.0.0 + vite: ^6.0.0 - /@tauri-apps/api@2.0.0-alpha.9: - resolution: {integrity: sha512-Q5BiIQa2ToICdaJSYZdmtwbKSfdk+uQbQ7xMnbWI5C5C3frEVFlT92kVXgZFKIwrTLZBWHfiowkPR6rbFqAHIg==} - engines: {node: '>= 18', npm: '>= 6.6.0', yarn: '>= 1.19.1'} - dev: false + '@tauri-apps/api@2.5.0': + resolution: {integrity: sha512-Ldux4ip+HGAcPUmuLT8EIkk6yafl5vK0P0c0byzAKzxJh7vxelVtdPONjfgTm96PbN24yjZNESY8CKo8qniluA==} - /@tauri-apps/cli-darwin-arm64@2.0.0-alpha.16: - resolution: {integrity: sha512-T/yu8+m4XrI1Ja5aVnsv4v5aGqIvwz1egHarMgh4LXrlMioJ60BoxDPfenaUokO6NVee212woFSmH6p4S7V8PA==} + '@tauri-apps/cli-darwin-arm64@2.5.0': + resolution: {integrity: sha512-VuVAeTFq86dfpoBDNYAdtQVLbP0+2EKCHIIhkaxjeoPARR0sLpFHz2zs0PcFU76e+KAaxtEtAJAXGNUc8E1PzQ==} engines: {node: '>= 10'} cpu: [arm64] os: [darwin] - requiresBuild: true - 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.5.0': + resolution: {integrity: sha512-hUF01sC06cZVa8+I0/VtsHOk9BbO75rd+YdtHJ48xTdcYaQ5QIwL4yZz9OR1AKBTaUYhBam8UX9Pvd5V2/4Dpw==} engines: {node: '>= 10'} cpu: [x64] os: [darwin] - requiresBuild: true - 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.5.0': + resolution: {integrity: sha512-LQKqttsK252LlqYyX8R02MinUsfFcy3+NZiJwHFgi5Y3+ZUIAED9cSxJkyNtuY5KMnR4RlpgWyLv4P6akN1xhg==} engines: {node: '>= 10'} cpu: [arm] os: [linux] - requiresBuild: true - 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.5.0': + resolution: {integrity: sha512-mTQufsPcpdHg5RW0zypazMo4L55EfeE5snTzrPqbLX4yCK2qalN7+rnP8O8GT06xhp6ElSP/Ku1M2MR297SByQ==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] - requiresBuild: true - 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.5.0': + resolution: {integrity: sha512-rQO1HhRUQqyEaal5dUVOQruTRda/TD36s9kv1hTxZiFuSq3558lsTjAcUEnMAtBcBkps20sbyTJNMT0AwYIk8Q==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] - requiresBuild: true - 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-riscv64-gnu@2.5.0': + resolution: {integrity: sha512-7oS18FN46yDxyw1zX/AxhLAd7T3GrLj3Ai6s8hZKd9qFVzrAn36ESL7d3G05s8wEtsJf26qjXnVF4qleS3dYsA==} + engines: {node: '>= 10'} + cpu: [riscv64] + os: [linux] + + '@tauri-apps/cli-linux-x64-gnu@2.5.0': + resolution: {integrity: sha512-SG5sFNL7VMmDBdIg3nO3EzNRT306HsiEQ0N90ILe3ZABYAVoPDO/ttpCO37ApLInTzrq/DLN+gOlC/mgZvLw1w==} engines: {node: '>= 10'} cpu: [x64] os: [linux] - requiresBuild: true - 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.5.0': + resolution: {integrity: sha512-QXDM8zp/6v05PNWju5ELsVwF0VH1n6b5pk2E6W/jFbbiwz80Vs1lACl9pv5kEHkrxBj+aWU/03JzGuIj2g3SkQ==} engines: {node: '>= 10'} cpu: [x64] os: [linux] - requiresBuild: true - 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.5.0': + resolution: {integrity: sha512-pFSHFK6b+o9y4Un8w0gGLwVyFTZaC3P0kQ7umRt/BLDkzD5RnQ4vBM7CF8BCU5nkwmEBUCZd7Wt3TWZxe41o6Q==} engines: {node: '>= 10'} cpu: [arm64] os: [win32] - requiresBuild: true - 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.5.0': + resolution: {integrity: sha512-EArv1IaRlogdLAQyGlKmEqZqm5RfHCUMhJoedWu7GtdbOMUfSAz6FMX2boE1PtEmNO4An+g188flLeVErrxEKg==} engines: {node: '>= 10'} cpu: [ia32] os: [win32] - requiresBuild: true - 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.5.0': + resolution: {integrity: sha512-lj43EFYbnAta8pd9JnUq87o+xRUR0odz+4rixBtTUwUgdRdwQ2V9CzFtsMu6FQKpFQ6mujRK6P1IEwhL6ADRsQ==} engines: {node: '>= 10'} cpu: [x64] os: [win32] - requiresBuild: true - dev: true - optional: true - /@tauri-apps/cli@2.0.0-alpha.16: - resolution: {integrity: sha512-zh2psjmHLkoHZkzUN1aPqcOE4KTLRTRJdd+K8CsD/y5nbQdek8qjc8ToohV2FNHDkBq0O/yETsPmPPLgQfhVhg==} + '@tauri-apps/cli@2.5.0': + resolution: {integrity: sha512-rAtHqG0Gh/IWLjN2zTf3nZqYqbo81oMbqop56rGTjrlWk9pTTAjkqOjSL9XQLIMZ3RbeVjveCqqCA0s8RnLdMg==} 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 - dev: true - - /@tauri-apps/toml@2.2.4: - resolution: {integrity: sha512-NJV/pdgJObDlDWi5+MTHZ2qyNvdL0dlHqQ72nzQYXWbW1LHMPXgCJYl0pLqL1XxxLtxtInYbtVCGVAcwhGxdkw==} - dev: true - - /@types/cookie@0.5.1: - resolution: {integrity: sha512-COUnqfB2+ckwXXSFInsFdOAWQzCCx+a5hq2ruyj+Vjund94RJQd4LG2u9hnvJrTgunKAaax7ancBYlDrNYxA0g==} - dev: true - - /@types/estree@1.0.1: - resolution: {integrity: sha512-LG4opVs2ANWZ1TJoKc937iMmNstM/d0ae1vNbnBvBhqCSezgVUOzcLCqbI5elV8Vy6WKwKjaqR+zO9VKirBBCA==} - - /@types/json-schema@7.0.12: - resolution: {integrity: sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA==} - dev: true - - /@types/json5@0.0.29: - resolution: {integrity: sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==} - dev: true - - /@types/mdast@3.0.12: - resolution: {integrity: sha512-DT+iNIRNX884cx0/Q1ja7NyUPpZuv0KPyL5rGNxm1WC1OtHstl7n4Jb7nk+xacNShQMbczJjt8uFzznpp6kYBg==} - dependencies: - '@types/unist': 2.0.7 - dev: true - - /@types/pug@2.0.6: - resolution: {integrity: sha512-SnHmG9wN1UVmagJOnyo/qkk0Z7gejYxOYYmaAwr5u2yFYfsupN3sg10kyzN8Hep/2zbHxCnsumxOoRIRMBwKCg==} - dev: true - - /@types/resolve@1.20.2: + + '@types/estree@1.0.7': + resolution: {integrity: sha512-w28IoSUCJpidD/TGviZwwMJckNESJZXFu7NBZ5YJ4mEUnNraUn9Pm8HSZm/jDF1pDWYKspWE7oVphigUPRakIQ==} + + '@types/json-schema@7.0.15': + resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} + + '@types/mdast@3.0.15': + resolution: {integrity: sha512-LnwD+mUEfxWMa1QpDraczIn6k0Ee3SMicuYSSzS6ZYl2gKS09EClnJYGd8Du6rfc5r/GZEk5o1mRb8TaTj03sQ==} + + '@types/resolve@1.20.2': resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==} - dev: true - /@types/semver@7.5.0: - resolution: {integrity: sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw==} - dev: true + '@types/unist@2.0.11': + resolution: {integrity: sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA==} - /@types/unist@2.0.7: - resolution: {integrity: sha512-cputDpIbFgLUaGQn6Vqg3/YsJwxUwHLO13v3i5ouxT4lat0khip9AEWxtERujXV9wxIB1EyF97BSJFt6vpdI8g==} - dev: true + '@typescript-eslint/eslint-plugin@8.34.0': + resolution: {integrity: sha512-QXwAlHlbcAwNlEEMKQS2RCgJsgXrTJdjXT08xEgbPFa2yYQgVjBymxP5DrfrE7X7iodSzd9qBUHUycdyVJTW1w==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + '@typescript-eslint/parser': ^8.34.0 + eslint: ^8.57.0 || ^9.0.0 + typescript: '>=4.8.4 <5.9.0' - /@typescript-eslint/eslint-plugin@6.8.0(@typescript-eslint/parser@6.8.0)(eslint@8.51.0)(typescript@5.2.2): - resolution: {integrity: sha512-GosF4238Tkes2SHPQ1i8f6rMtG6zlKwMEB0abqSJ3Npvos+doIlc/ATG+vX1G9coDF3Ex78zM3heXHLyWEwLUw==} - engines: {node: ^16.0.0 || >=18.0.0} + '@typescript-eslint/parser@8.34.0': + resolution: {integrity: sha512-vxXJV1hVFx3IXz/oy2sICsJukaBrtDEQSBiV48/YIV5KWjX1dO+bcIr/kCPrW6weKXvsaGKFNlwH0v2eYdRRbA==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: - '@typescript-eslint/parser': ^6.0.0 || ^6.0.0-alpha - eslint: ^7.0.0 || ^8.0.0 - typescript: '*' - peerDependenciesMeta: - typescript: - optional: true - dependencies: - '@eslint-community/regexpp': 4.5.1 - '@typescript-eslint/parser': 6.8.0(eslint@8.51.0)(typescript@5.2.2) - '@typescript-eslint/scope-manager': 6.8.0 - '@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(supports-color@8.1.1) - eslint: 8.51.0 - graphemer: 1.4.0 - ignore: 5.2.4 - natural-compare: 1.4.0 - semver: 7.5.4 - ts-api-utils: 1.0.1(typescript@5.2.2) - typescript: 5.2.2 - transitivePeerDependencies: - - supports-color - dev: true + eslint: ^8.57.0 || ^9.0.0 + typescript: '>=4.8.4 <5.9.0' - /@typescript-eslint/parser@6.8.0(eslint@8.51.0)(typescript@5.2.2): - resolution: {integrity: sha512-5tNs6Bw0j6BdWuP8Fx+VH4G9fEPDxnVI7yH1IAPkQH5RUtvKwRoqdecAPdQXv4rSOADAaz1LFBZvZG7VbXivSg==} - engines: {node: ^16.0.0 || >=18.0.0} + '@typescript-eslint/project-service@8.34.0': + resolution: {integrity: sha512-iEgDALRf970/B2YExmtPMPF54NenZUf4xpL3wsCRx/lgjz6ul/l13R81ozP/ZNuXfnLCS+oPmG7JIxfdNYKELw==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: - eslint: ^7.0.0 || ^8.0.0 - typescript: '*' - peerDependenciesMeta: - typescript: - optional: true - dependencies: - '@typescript-eslint/scope-manager': 6.8.0 - '@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(supports-color@8.1.1) - eslint: 8.51.0 - typescript: 5.2.2 - transitivePeerDependencies: - - supports-color - dev: true + typescript: '>=4.8.4 <5.9.0' - /@typescript-eslint/scope-manager@6.8.0: - resolution: {integrity: sha512-xe0HNBVwCph7rak+ZHcFD6A+q50SMsFwcmfdjs9Kz4qDh5hWhaPhFjRs/SODEhroBI5Ruyvyz9LfwUJ624O40g==} - engines: {node: ^16.0.0 || >=18.0.0} - dependencies: - '@typescript-eslint/types': 6.8.0 - '@typescript-eslint/visitor-keys': 6.8.0 - dev: true + '@typescript-eslint/scope-manager@8.34.0': + resolution: {integrity: sha512-9Ac0X8WiLykl0aj1oYQNcLZjHgBojT6cW68yAgZ19letYu+Hxd0rE0veI1XznSSst1X5lwnxhPbVdwjDRIomRw==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - /@typescript-eslint/type-utils@6.8.0(eslint@8.51.0)(typescript@5.2.2): - resolution: {integrity: sha512-RYOJdlkTJIXW7GSldUIHqc/Hkto8E+fZN96dMIFhuTJcQwdRoGN2rEWA8U6oXbLo0qufH7NPElUb+MceHtz54g==} - engines: {node: ^16.0.0 || >=18.0.0} + '@typescript-eslint/tsconfig-utils@8.34.0': + resolution: {integrity: sha512-+W9VYHKFIzA5cBeooqQxqNriAP0QeQ7xTiDuIOr71hzgffm3EL2hxwWBIIj4GuofIbKxGNarpKqIq6Q6YrShOA==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: - eslint: ^7.0.0 || ^8.0.0 - typescript: '*' - peerDependenciesMeta: - typescript: - optional: true - 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(supports-color@8.1.1) - eslint: 8.51.0 - ts-api-utils: 1.0.1(typescript@5.2.2) - typescript: 5.2.2 - transitivePeerDependencies: - - supports-color - dev: true + typescript: '>=4.8.4 <5.9.0' - /@typescript-eslint/types@6.8.0: - resolution: {integrity: sha512-p5qOxSum7W3k+llc7owEStXlGmSl8FcGvhYt8Vjy7FqEnmkCVlM3P57XQEGj58oqaBWDQXbJDZxwUWMS/EAPNQ==} - engines: {node: ^16.0.0 || >=18.0.0} - dev: true + '@typescript-eslint/type-utils@8.34.0': + resolution: {integrity: sha512-n7zSmOcUVhcRYC75W2pnPpbO1iwhJY3NLoHEtbJwJSNlVAZuwqu05zY3f3s2SDWWDSo9FdN5szqc73DCtDObAg==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 + typescript: '>=4.8.4 <5.9.0' + + '@typescript-eslint/types@8.34.0': + resolution: {integrity: sha512-9V24k/paICYPniajHfJ4cuAWETnt7Ssy+R0Rbcqo5sSFr3QEZ/8TSoUi9XeXVBGXCaLtwTOKSLGcInCAvyZeMA==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - /@typescript-eslint/typescript-estree@6.8.0(typescript@5.2.2): - resolution: {integrity: sha512-ISgV0lQ8XgW+mvv5My/+iTUdRmGspducmQcDw5JxznasXNnZn3SKNrTRuMsEXv+V/O+Lw9AGcQCfVaOPCAk/Zg==} - engines: {node: ^16.0.0 || >=18.0.0} + '@typescript-eslint/typescript-estree@8.34.0': + resolution: {integrity: sha512-rOi4KZxI7E0+BMqG7emPSK1bB4RICCpF7QD3KCLXn9ZvWoESsOMlHyZPAHyG04ujVplPaHbmEvs34m+wjgtVtg==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: - typescript: '*' - peerDependenciesMeta: - typescript: - optional: true - dependencies: - '@typescript-eslint/types': 6.8.0 - '@typescript-eslint/visitor-keys': 6.8.0 - debug: 4.3.4(supports-color@8.1.1) - globby: 11.1.0 - is-glob: 4.0.3 - semver: 7.5.4 - ts-api-utils: 1.0.1(typescript@5.2.2) - typescript: 5.2.2 - transitivePeerDependencies: - - supports-color - dev: true + typescript: '>=4.8.4 <5.9.0' - /@typescript-eslint/utils@6.8.0(eslint@8.51.0)(typescript@5.2.2): - resolution: {integrity: sha512-dKs1itdE2qFG4jr0dlYLQVppqTE+Itt7GmIf/vX6CSvsW+3ov8PbWauVKyyfNngokhIO9sKZeRGCUo1+N7U98Q==} - engines: {node: ^16.0.0 || >=18.0.0} + '@typescript-eslint/utils@8.34.0': + resolution: {integrity: sha512-8L4tWatGchV9A1cKbjaavS6mwYwp39jql8xUmIIKJdm+qiaeHy5KMKlBrf30akXAWBzn2SqKsNOtSENWUwg7XQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: - eslint: ^7.0.0 || ^8.0.0 - dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@8.51.0) - '@types/json-schema': 7.0.12 - '@types/semver': 7.5.0 - '@typescript-eslint/scope-manager': 6.8.0 - '@typescript-eslint/types': 6.8.0 - '@typescript-eslint/typescript-estree': 6.8.0(typescript@5.2.2) - eslint: 8.51.0 - semver: 7.5.4 - transitivePeerDependencies: - - supports-color - - typescript - dev: true + eslint: ^8.57.0 || ^9.0.0 + typescript: '>=4.8.4 <5.9.0' - /@typescript-eslint/visitor-keys@6.8.0: - resolution: {integrity: sha512-oqAnbA7c+pgOhW2OhGvxm0t1BULX5peQI/rLsNDpGM78EebV3C9IGbX5HNZabuZ6UQrYveCLjKo8Iy/lLlBkkg==} - engines: {node: ^16.0.0 || >=18.0.0} - dependencies: - '@typescript-eslint/types': 6.8.0 - eslint-visitor-keys: 3.4.1 - dev: true + '@typescript-eslint/visitor-keys@8.34.0': + resolution: {integrity: sha512-qHV7pW7E85A0x6qyrFn+O+q1k1p3tQCsqIZ1KZ5ESLXY57aTvUd3/a4rdPTeXisvhXn2VQG0VSKUqs8KHF2zcA==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - /@unocss/astro@0.56.5(rollup@4.1.4)(vite@4.5.0): - resolution: {integrity: sha512-nkxyGV9mA7DZ5LEr4Gap/SggM60MFNUfn56ngpxCqjQHJOMRJrAcR99hCVn+78vZ9xuZl9HxdIwgZLzn41thMw==} + '@unocss/astro@66.0.0': + resolution: {integrity: sha512-GBhXT6JPqXjDXoJZTXhySk83NgOt0UigChqrUUdG4x7Z+DVYkDBION8vZUJjw0OdIaxNQ4euGWu4GDsMF6gQQg==} peerDependencies: - vite: ^2.9.0 || ^3.0.0-0 || ^4.0.0 + vite: ^2.9.0 || ^3.0.0-0 || ^4.0.0 || ^5.0.0-0 || ^6.0.0-0 peerDependenciesMeta: vite: optional: true - dependencies: - '@unocss/core': 0.56.5 - '@unocss/reset': 0.56.5 - '@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(rollup@4.1.4): - resolution: {integrity: sha512-VYaqu7Dr1n9ebFFdQM+9Jyg/o9BVKRShlV8bQsBS58gkXiWsA/uAl1Uy2vzpLSrT0F6uGyDmYUF6p4DaUnUO+w==} + '@unocss/cli@66.0.0': + resolution: {integrity: sha512-KVQiskoOjVkLVpNaG6WpLa4grPplrZROYZJVIUYSTqZyZRFNSvjttHcsCwpoWUEUdEombPtVZl8FrXePjY5IiQ==} engines: {node: '>=14'} hasBin: true - dependencies: - '@ampproject/remapping': 2.2.1 - '@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 - cac: 6.7.14 - chokidar: 3.5.3 - colorette: 2.0.20 - consola: 3.2.3 - fast-glob: 3.3.1 - magic-string: 0.30.5 - pathe: 1.1.1 - perfect-debounce: 1.0.0 - transitivePeerDependencies: - - rollup - dev: true - /@unocss/config@0.56.5: - resolution: {integrity: sha512-rscnFIYgUlN/0hXHdhANyjFcDjDutt3JO0ZRITdNLzoglh7GVNiDTURBJwUZejF/vGJ7IkMd3qOdNhPFuRY1Bg==} + '@unocss/config@66.0.0': + resolution: {integrity: sha512-nFRGop/guBa4jLkrgXjaRDm5JPz4x3YpP10m5IQkHpHwlnHUVn1L9smyPl04ohYWhYn9ZcAHgR28Ih2jwta8hw==} engines: {node: '>=14'} - dependencies: - '@unocss/core': 0.56.5 - unconfig: 0.3.11 - dev: true - /@unocss/core@0.56.5: - resolution: {integrity: sha512-fx5VhOjSHn0HdV2D34pEwFMAHJcJQRTCp1xEE4GzxY1irXzaa+m2aYf5PZjmDxehiOC16IH7TO9FOWANXk1E0w==} - dev: true + '@unocss/core@66.0.0': + resolution: {integrity: sha512-PdVbSMHNDDkr++9nkqzsZRAkaU84gxMTEgYbqI7dt2p1DXp/5tomVtmMsr2/whXGYKRiUc0xZ3p4Pzraz8TcXA==} - /@unocss/extractor-arbitrary-variants@0.56.5: - resolution: {integrity: sha512-p2pyzz/ONvc5CGcaB9OZvWE8qkRSgyuhaQqFQLdBFeUhveHC0CGP0iSnXwBgAFHWM7DJo4/JpWeZ+mBt0ogVLA==} - dependencies: - '@unocss/core': 0.56.5 - dev: true + '@unocss/extractor-arbitrary-variants@66.0.0': + resolution: {integrity: sha512-vlkOIOuwBfaFBJcN6o7+obXjigjOlzVFN/jT6pG1WXbQDTRZ021jeF3i9INdb9D/0cQHSeDvNgi1TJ5oUxfiow==} - /@unocss/extractor-svelte@0.56.5: - resolution: {integrity: sha512-nE5yOTHZf00zfnrDADaw3PiLoHwu/lQ1j/xOgzCZC6SzCoxq7yyQAP6/IVZrk7D3qkINFUku/5i7Cug+/CviIw==} - dev: true + '@unocss/extractor-svelte@66.0.0': + resolution: {integrity: sha512-iUrdW6dVV08gOjs16+wjucvfy9VK7+KSWxiOVUmL4dB2jHsiaUG63AG+JgoEwEJu2UEatfEVblQvBXQFCl9/SA==} - /@unocss/inspector@0.56.5: - resolution: {integrity: sha512-UK/X2JyqxB1uueIFlffFsBioxMptanBbJYjrmOoLPdAFoOPp9o8IIFkFs3OKWc8imvyl3w+F0opncmdJnDMllw==} - dependencies: - '@unocss/rule-utils': 0.56.5 - gzip-size: 6.0.0 - sirv: 2.0.3 - dev: true + '@unocss/inspector@66.0.0': + resolution: {integrity: sha512-mkIxieVm0kMOKw+E4ABpIerihYMdjgq9A92RD5h2+W/ebpxTEw5lTTK1xcMLiAlmOrVYMQKjpgPeu3vQmDyGZQ==} - /@unocss/postcss@0.56.5(postcss@8.4.31): - resolution: {integrity: sha512-oDY1vCdrCQZx/oxDkq3z77a0RoO+WVQT090oDZzLFO/cPWH3elSOHwnoJU/KzrpJLbUFpyTQKZ/k3VbBaEdGTA==} + '@unocss/postcss@66.0.0': + resolution: {integrity: sha512-6bi+ujzh8I1PJwtmHX71LH8z/H9+vPxeYD4XgFihyU1k4Y6MVhjr7giGjLX4yP27IP+NsVyotD22V7by/dBVEA==} engines: {node: '>=14'} peerDependencies: postcss: ^8.4.21 - dependencies: - '@unocss/config': 0.56.5 - '@unocss/core': 0.56.5 - '@unocss/rule-utils': 0.56.5 - css-tree: 2.3.1 - fast-glob: 3.3.1 - magic-string: 0.30.5 - postcss: 8.4.31 - dev: true - /@unocss/preset-attributify@0.56.5: - resolution: {integrity: sha512-476NVv1kUmiD0ObtJceUB1ldiQvGStEUlwoHFOFl8srZbRuRlwq8Uz4sxCePf3sn2FP8UHw+By+nxwxMQuHpww==} - dependencies: - '@unocss/core': 0.56.5 - dev: true + '@unocss/preset-attributify@66.0.0': + resolution: {integrity: sha512-eYsOgmcDoiIgGAepIwRX+DKGYxc/wm0r4JnDuZdz29AB+A6oY/FGHS1BVt4rq9ny4B5PofP4p6Rty+vwD9rigw==} - /@unocss/preset-icons@0.56.5: - resolution: {integrity: sha512-Pc973z/M7+TsIPRli9xSE+rjzQnX9r0PppTOD5lrD8PqvNSGIrSWZUFDc5NqL09hKHkIdVrDLC+2ouLYqTI7iA==} - dependencies: - '@iconify/utils': 2.1.11 - '@unocss/core': 0.56.5 - ofetch: 1.3.3 - transitivePeerDependencies: - - supports-color - dev: true + '@unocss/preset-icons@66.0.0': + resolution: {integrity: sha512-6ObwTvEGuPBbKWRoMMiDioHtwwQTFI5oojFLJ32Y8tW6TdXvBLkO88d7qpgQxEjgVt4nJrqF1WEfR4niRgBm0Q==} - /@unocss/preset-mini@0.56.5: - resolution: {integrity: sha512-/KhlThhs1ilauM7MwRSpahLbIPZ5VGeGvaUsU8+ZlNT3sis4yoVYkPtR14tL2IT6jhOU05N/uu3aBj+1bP8GjQ==} - dependencies: - '@unocss/core': 0.56.5 - '@unocss/extractor-arbitrary-variants': 0.56.5 - '@unocss/rule-utils': 0.56.5 - dev: true + '@unocss/preset-mini@66.0.0': + resolution: {integrity: sha512-d62eACnuKtR0dwCFOQXgvw5VLh5YSyK56xCzpHkh0j0GstgfDLfKTys0T/XVAAvdSvAy/8A8vhSNJ4PlIc9V2A==} - /@unocss/preset-tagify@0.56.5: - resolution: {integrity: sha512-ANtI7E92fuzF40MD/3V72myNqrcGNXAD3TjXHIxAPQP2F+DcYIl2TBPHVsGUt2Rc5Kid2kvvsWan6sRAQVGPng==} - dependencies: - '@unocss/core': 0.56.5 - dev: true + '@unocss/preset-tagify@66.0.0': + resolution: {integrity: sha512-GGYGyWxaevh0jN0NoATVO1Qe7DFXM3ykLxchlXmG6/zy963pZxItg/njrKnxE9la4seCdxpFH7wQBa68imwwdA==} - /@unocss/preset-typography@0.56.5: - resolution: {integrity: sha512-fA/q5S+s7BV3TRWRvXqG7xpa8WNfG19uaZx288FcKauMR0TX4jUM0EkkngpwrTgeXXohh5awx4OEW3E1s1Q2oA==} - dependencies: - '@unocss/core': 0.56.5 - '@unocss/preset-mini': 0.56.5 - dev: true + '@unocss/preset-typography@66.0.0': + resolution: {integrity: sha512-apjckP5nPU5mtaHTCzz5u/dK9KJWwJ2kOFCVk0+a/KhUWmnqnzmjRYZlEuWxxr5QxTdCW+9cIoRDSA0lYZS5tg==} - /@unocss/preset-uno@0.56.5: - resolution: {integrity: sha512-3hzE0X1oxMbHLvWyTj/4BrJQ7OAL428BpzEJos0RsxifM04vOJX4GC4khIbmTl8KIMECMtATK3ren3JqzD2bFw==} - dependencies: - '@unocss/core': 0.56.5 - '@unocss/preset-mini': 0.56.5 - '@unocss/preset-wind': 0.56.5 - '@unocss/rule-utils': 0.56.5 - dev: true + '@unocss/preset-uno@66.0.0': + resolution: {integrity: sha512-qgoZ/hzTI32bQvcyjcwvv1X/dbPlmQNehzgjUaL7QFT0q0/CN/SRpysfzoQ8DLl2se9T+YCOS9POx3KrpIiYSQ==} - /@unocss/preset-web-fonts@0.56.5: - resolution: {integrity: sha512-1YPbqpHK6NaXWHceNJTl2A+dNbliB6FeU5Tvkox1KOLTTwvzUF80uWHAE/l05Oc9EZyolZ8OsM37p2eJAb0wpw==} - dependencies: - '@unocss/core': 0.56.5 - ofetch: 1.3.3 - dev: true + '@unocss/preset-web-fonts@66.0.0': + resolution: {integrity: sha512-9MzfDc6AJILN4Kq7Z91FfFbizBOYgw3lJd2UwqIs3PDYWG5iH5Zv5zhx6jelZVqEW5uWcIARYEEg2m4stZO1ZA==} - /@unocss/preset-wind@0.56.5: - resolution: {integrity: sha512-iyMPvCEZkrGLHFXXlcqxDo/UcSK7KWw4x7/QUz7irrvc78cxYVuPm98QZgpCRcCwKerKVyFLjGOtwQ0kmVSVsQ==} - dependencies: - '@unocss/core': 0.56.5 - '@unocss/preset-mini': 0.56.5 - '@unocss/rule-utils': 0.56.5 - dev: true + '@unocss/preset-wind3@66.0.0': + resolution: {integrity: sha512-WAGRmpi1sb2skvYn9DBQUvhfqrJ+VmQmn5ZGsT2ewvsk7HFCvVLAMzZeKrrTQepeNBRhg6HzFDDi8yg6yB5c9g==} - /@unocss/reset@0.56.5: - resolution: {integrity: sha512-//Pv2ITAdnpWB9FIr0JiQVl1rL1XgISR8mu3OikhCfi6d/4OH+o6/WyE7evF1pOmk1JjsQlznOABIZXQlcpbHQ==} - dev: true + '@unocss/preset-wind@66.0.0': + resolution: {integrity: sha512-FtvGpHnGC7FiyKJavPnn5y9lsaoWRhXlujCqlT5Bw63kKhMNr0ogKySBpenUhJOhWhVM0OQXn2nZ3GZRxW2qpw==} - /@unocss/rule-utils@0.56.5: - resolution: {integrity: sha512-CXIGHCIC9B8WUl9KbbFMSZHcsIgfmI/+X0bjBv6xrgBVC1EQ2Acq4PYnJIbaRGBRAhl9wYjNL7Zq2UWOdowHAw==} + '@unocss/reset@66.0.0': + resolution: {integrity: sha512-YLFz/5yT7mFJC8JSmIUA5+bS3CBCJbtztOw+8rWzjQr/BEVSGuihWUUpI2Df6VVxXIXxKanZR6mIl59yvf+GEA==} + + '@unocss/rule-utils@66.0.0': + resolution: {integrity: sha512-UJ51YHbwxYTGyj35ugsPlOT4gaa7tCbXdywZ3m5Nn0JgywwIqGmBFyiN9ZjHBHfJuDxmmPd6lxojoBscih/WMQ==} engines: {node: '>=14'} - dependencies: - '@unocss/core': 0.56.5 - dev: true - /@unocss/scope@0.56.5: - resolution: {integrity: sha512-q2eHYLuqF7RZEVGti205X2JOKSH6lBJGoQIjPtWgodNTg3S7qmUinHG0XzikI30L3EF3VljIh5TbtwGPcvbNsA==} - dev: true + '@unocss/transformer-attributify-jsx@66.0.0': + resolution: {integrity: sha512-jS7szFXXC6RjTv9wo0NACskf618w981bkbyQ5izRO7Ha47sNpHhHDpaltnG7SR9qV4cCtGalOw4onVMHsRKwRg==} - /@unocss/transformer-attributify-jsx-babel@0.56.5: - resolution: {integrity: sha512-QUlbmWpdfzdgEXNcOJwSvKDHB/ID/X3zlpK+fXyCKTkqiYgCwMFmLXll2HtNhIgH2E1gWo/lDlwpiW/QjQb/rw==} - dependencies: - '@unocss/core': 0.56.5 - dev: true + '@unocss/transformer-compile-class@66.0.0': + resolution: {integrity: sha512-ytUIE0nAcHRMACuTXkHp8auZ483DXrOZw99jk3FJ+aFjpD/pVSFmX14AWJ7bqPFObxb4SLFs6KhQma30ESC22A==} - /@unocss/transformer-attributify-jsx@0.56.5: - resolution: {integrity: sha512-SQW7t58s26qHYuD8v3covXtWoXlflw3FV5dlBCw/2iOfNo3OTVUWReAB5y0XQIT3828nHnPqeQq4IhmnuOENdw==} - dependencies: - '@unocss/core': 0.56.5 - dev: true + '@unocss/transformer-directives@66.0.0': + resolution: {integrity: sha512-utcg7m2Foi7uHrU5WHadNuJ0a3qWG8tZNkQMi+m0DQpX6KWfuDtDn0zDZ1X+z5lmiB3WGSJERRrsvZbj1q50Mw==} - /@unocss/transformer-compile-class@0.56.5: - resolution: {integrity: sha512-uT/+bVDN26hJ4a5FtbOT4PxAVDUTxwZCEVCesPAE5RnGd7f+KYUnk3XdDa77xyklPQsxPhr4MEjA0HGPHtSH8Q==} - dependencies: - '@unocss/core': 0.56.5 - dev: true + '@unocss/transformer-variant-group@66.0.0': + resolution: {integrity: sha512-1BLjNWtAnR1JAcQGw0TS+nGrVoB9aznzvVZRoTx23dtRr3btvgKPHb8LrD48eD/p8Dtw9j3WfuxMDKXKegKDLg==} - /@unocss/transformer-directives@0.56.5: - resolution: {integrity: sha512-ykXbvG1LbqTqlYImMtkJUeH8BtuiE+8T/txUVyooUoVgr2qSELUu2FxC6rTX2EUx+F5BZhaQd6GsdzgaDwXgIg==} - dependencies: - '@unocss/core': 0.56.5 - '@unocss/rule-utils': 0.56.5 - css-tree: 2.3.1 - dev: true + '@unocss/vite@66.0.0': + resolution: {integrity: sha512-IVcPX8xL+2edyXKt4tp9yu5A6gcbPVCsspfcL0XgziCr01kS+4qSoZ90F3IUs3hXc/AyO5eCpRtGFMPLpOjXQg==} + peerDependencies: + vite: ^2.9.0 || ^3.0.0-0 || ^4.0.0 || ^5.0.0-0 || ^6.0.0-0 - /@unocss/transformer-variant-group@0.56.5: - resolution: {integrity: sha512-e+7XtICuOtcOgGyxI06i0LK6R446KLFvzv+lw3WbwhD8OcsSFUAtCaAw0l+cyyiiZ/k2tLdUR0O4hYwQVa8f1A==} - dependencies: - '@unocss/core': 0.56.5 - dev: true + '@vue/compiler-core@3.5.13': + resolution: {integrity: sha512-oOdAkwqUfW1WqpwSYJce06wvt6HljgY3fGeM9NcVA1HaYOij3mZG9Rkysn0OHuyUAGMbEbARIpsG+LPVlBJ5/Q==} - /@unocss/vite@0.56.5(rollup@4.1.4)(vite@4.5.0): - resolution: {integrity: sha512-X4nvIukXTH//d+Oc97nJogK04sVGw4fc5LhVV1DjHQVmAOAmhTJCG6SxWGoSeqqUMx5X3gI9fVILK+5O8yl5EA==} + '@vue/compiler-dom@3.5.13': + resolution: {integrity: sha512-ZOJ46sMOKUjO3e94wPdCzQ6P1Lx/vhp2RSvfaab88Ajexs0AHeV0uasYhi99WPaogmBlRHNRuly8xV75cNTMDA==} + + '@vue/compiler-sfc@3.5.13': + resolution: {integrity: sha512-6VdaljMpD82w6c2749Zhf5T9u5uLBWKnVue6XWxprDobftnletJ8+oel7sexFfM3qIxNmVE7LSFGTpv6obNyaQ==} + + '@vue/compiler-ssr@3.5.13': + resolution: {integrity: sha512-wMH6vrYHxQl/IybKJagqbquvxpWCuVYpoUJfCqFZwa/JY1GdATAQ+TgVtgrwwMZ0D07QhA99rs/EAAWfvG6KpA==} + + '@vue/reactivity@3.5.13': + resolution: {integrity: sha512-NaCwtw8o48B9I6L1zl2p41OHo/2Z4wqYGGIK1Khu5T7yxrn+ATOixn/Udn2m+6kZKB/J7cuT9DbWWhRxqixACg==} + + '@vue/runtime-core@3.5.13': + resolution: {integrity: sha512-Fj4YRQ3Az0WTZw1sFe+QDb0aXCerigEpw418pw1HBUKFtnQHWzwojaukAs2X/c9DQz4MQ4bsXTGlcpGxU/RCIw==} + + '@vue/runtime-dom@3.5.13': + resolution: {integrity: sha512-dLaj94s93NYLqjLiyFzVs9X6dWhTdAlEAciC3Moq7gzAc13VJUdCnjjRurNM6uTLFATRHexHCTu/Xp3eW6yoog==} + + '@vue/server-renderer@3.5.13': + resolution: {integrity: sha512-wAi4IRJV/2SAW3htkTlB+dHeRmpTiVIK1OGLWV1yeStVSebSQQOwGwIq0D3ZIoBj2C2qpgz5+vX9iEBkTdk5YA==} peerDependencies: - vite: ^2.9.0 || ^3.0.0-0 || ^4.0.0 - dependencies: - '@ampproject/remapping': 2.2.1 - '@rollup/pluginutils': 5.0.5(rollup@4.1.4) - '@unocss/config': 0.56.5 - '@unocss/core': 0.56.5 - '@unocss/inspector': 0.56.5 - '@unocss/scope': 0.56.5 - '@unocss/transformer-directives': 0.56.5 - chokidar: 3.5.3 - fast-glob: 3.3.1 - magic-string: 0.30.5 - vite: 4.5.0 - transitivePeerDependencies: - - rollup - dev: true + vue: 3.5.13 + + '@vue/shared@3.5.13': + resolution: {integrity: sha512-/hnE/qP5ZoGpol0a5mDi45bOd7t3tjYJBjsgCsivow7D48cJeV5l05RD82lPqi7gRiphZM37rnhW1l6ZoCNNnQ==} - /@zerodevx/svelte-json-view@1.0.7(svelte@4.2.2): - resolution: {integrity: sha512-yW0MV+9BCKOwzt3h86y3xDqYdI5st+Rxk+L5pa0Utq7nlPD+VvxyhL7R1gJoLxQvWwjyAvY/fyUCFTdwDyI14w==} + '@zerodevx/svelte-json-view@1.0.11': + resolution: {integrity: sha512-mIjj0H1al/P4FPlbeDoiey93lNEUqBEAe5LIdD5GttZfEYt3awexD2lHwKNfUeY4jHizOJkoWTPN/2iO0GBqpw==} peerDependencies: - svelte: ^3.57.0 || ^4.0.0 - dependencies: - svelte: 4.2.2 - dev: false + svelte: ^3.57.0 || ^4.0.0 || ^5.0.0 + + abort-controller@3.0.0: + resolution: {integrity: sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==} + engines: {node: '>=6.5'} - /acorn-jsx@5.3.2(acorn@8.10.0): + acorn-jsx@5.3.2: resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==} peerDependencies: acorn: ^6.0.0 || ^7.0.0 || ^8.0.0 - dependencies: - acorn: 8.10.0 - dev: true - /acorn@8.10.0: - resolution: {integrity: sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==} + acorn@8.14.0: + resolution: {integrity: sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==} engines: {node: '>=0.4.0'} hasBin: true - /ajv@6.12.6: + ajv@6.12.6: resolution: {integrity: sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==} - dependencies: - fast-deep-equal: 3.1.3 - fast-json-stable-stringify: 2.1.0 - json-schema-traverse: 0.4.1 - uri-js: 4.4.1 - dev: true - /ansi-colors@4.1.1: - resolution: {integrity: sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==} + ansi-colors@4.1.3: + resolution: {integrity: sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==} engines: {node: '>=6'} - dev: true - - /ansi-escapes@4.3.2: - resolution: {integrity: sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==} - engines: {node: '>=8'} - dependencies: - type-fest: 0.21.3 - dev: true - /ansi-regex@5.0.1: + ansi-regex@5.0.1: resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} engines: {node: '>=8'} - dev: true - /ansi-styles@4.3.0: + ansi-styles@4.3.0: resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==} engines: {node: '>=8'} - dependencies: - color-convert: 2.0.1 - dev: true - /anymatch@3.1.3: + anymatch@3.1.3: resolution: {integrity: sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==} engines: {node: '>= 8'} - dependencies: - normalize-path: 3.0.0 - picomatch: 2.3.1 - dev: true - /argparse@2.0.1: + argparse@2.0.1: resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} - dev: true - - /aria-query@5.3.0: - resolution: {integrity: sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==} - dependencies: - dequal: 2.0.3 - - /array-buffer-byte-length@1.0.0: - resolution: {integrity: sha512-LPuwb2P+NrQw3XhxGc36+XSvuBPopovXYTR9Ew++Du9Yb/bx5AzBfrIsBoj0EZUifjQU+sHL21sseZ3jerWO/A==} - dependencies: - call-bind: 1.0.2 - is-array-buffer: 3.0.2 - dev: true - /array-includes@3.1.6: - resolution: {integrity: sha512-sgTbLvL6cNnw24FnbaDyjmvddQ2ML8arZsgaJhoABMoplz/4QRhtrYS+alr1BUM1Bwp6dhx8vVCBSLG+StwOFw==} + aria-query@5.3.2: + resolution: {integrity: sha512-COROpnaoap1E2F000S62r6A60uHZnmlvomhfyT2DlTcrY1OrBKn2UhH7qn5wTC9zMvD0AY7csdPSNwKP+7WiQw==} engines: {node: '>= 0.4'} - dependencies: - call-bind: 1.0.2 - define-properties: 1.2.0 - es-abstract: 1.22.1 - get-intrinsic: 1.2.1 - is-string: 1.0.7 - dev: true - /array-union@2.1.0: + array-union@2.1.0: resolution: {integrity: sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==} engines: {node: '>=8'} - dev: true - - /array.prototype.findlastindex@1.2.3: - resolution: {integrity: sha512-LzLoiOMAxvy+Gd3BAq3B7VeIgPdo+Q8hthvKtXybMvRV0jrXfJM/t8mw7nNlpEcVlVUnCnM2KSX4XU5HmpodOA==} - engines: {node: '>= 0.4'} - dependencies: - call-bind: 1.0.2 - define-properties: 1.2.0 - es-abstract: 1.22.1 - es-shim-unscopables: 1.0.0 - get-intrinsic: 1.2.1 - dev: true - - /array.prototype.flat@1.3.1: - resolution: {integrity: sha512-roTU0KWIOmJ4DRLmwKd19Otg0/mT3qPNt0Qb3GWW8iObuZXxrjB/pzn0R3hqpRSWg4HCwqx+0vwOnWnvlOyeIA==} - engines: {node: '>= 0.4'} - dependencies: - call-bind: 1.0.2 - define-properties: 1.2.0 - es-abstract: 1.22.1 - es-shim-unscopables: 1.0.0 - dev: true - /array.prototype.flatmap@1.3.1: - resolution: {integrity: sha512-8UGn9O1FDVvMNB0UlLv4voxRMze7+FpHyF5mSMRjWHUMlpoDViniy05870VlxhfgTnLbpuwTzvD76MTtWxB/mQ==} - engines: {node: '>= 0.4'} - dependencies: - call-bind: 1.0.2 - define-properties: 1.2.0 - es-abstract: 1.22.1 - es-shim-unscopables: 1.0.0 - dev: true - - /arraybuffer.prototype.slice@1.0.1: - resolution: {integrity: sha512-09x0ZWFEjj4WD8PDbykUwo3t9arLn8NIzmmYEJFpYekOAQjpkGSyrQhNoRTcwwcFRu+ycWF78QZ63oWTqSjBcw==} - engines: {node: '>= 0.4'} - dependencies: - array-buffer-byte-length: 1.0.0 - call-bind: 1.0.2 - define-properties: 1.2.0 - get-intrinsic: 1.2.1 - is-array-buffer: 3.0.2 - is-shared-array-buffer: 1.0.2 - dev: true + atomic-sleep@1.0.0: + resolution: {integrity: sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==} + engines: {node: '>=8.0.0'} - /available-typed-arrays@1.0.5: - resolution: {integrity: sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==} + axobject-query@4.1.0: + resolution: {integrity: sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ==} engines: {node: '>= 0.4'} - dev: true - - /axobject-query@3.2.1: - resolution: {integrity: sha512-jsyHu61e6N4Vbz/v18DHwWYKK0bSWLqn47eeDSKPB7m8tqMHF9YJ+mhIk2lVteyZrY8tnSj/jHOv4YiTCuCJgg==} - dependencies: - dequal: 2.0.3 - /bail@1.0.5: + bail@1.0.5: resolution: {integrity: sha512-xFbRxM1tahm08yHBP16MMjVUAvDaBMD38zsM9EMAUN61omwLmKlOpB/Zku5QkjZ8TZ4vn53pj+t518cH0S03RQ==} - dev: true - /balanced-match@1.0.2: + balanced-match@1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} - dev: true - /base64-js@1.5.1: + base64-js@1.5.1: resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} - dev: true - /binary-extensions@2.2.0: - resolution: {integrity: sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==} + binary-extensions@2.3.0: + resolution: {integrity: sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==} engines: {node: '>=8'} - dev: true - - /bl@4.1.0: - resolution: {integrity: sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==} - dependencies: - buffer: 5.7.1 - inherits: 2.0.4 - readable-stream: 3.6.2 - dev: true - /brace-expansion@1.1.11: + brace-expansion@1.1.11: resolution: {integrity: sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==} - dependencies: - balanced-match: 1.0.2 - concat-map: 0.0.1 - dev: true - /brace-expansion@2.0.1: + brace-expansion@2.0.1: resolution: {integrity: sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==} - dependencies: - balanced-match: 1.0.2 - dev: true - /braces@3.0.2: - resolution: {integrity: sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==} + braces@3.0.3: + resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==} engines: {node: '>=8'} - dependencies: - fill-range: 7.0.1 - dev: true - /browser-stdout@1.3.1: + browser-stdout@1.3.1: resolution: {integrity: sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==} - dev: true - /buffer-crc32@0.2.13: - resolution: {integrity: sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==} - dev: true - - /buffer-from@1.1.2: + buffer-from@1.1.2: resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} - dev: true - - /buffer@5.7.1: - resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==} - dependencies: - base64-js: 1.5.1 - ieee754: 1.2.1 - dev: true - - /builtin-modules@3.3.0: - resolution: {integrity: sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==} - engines: {node: '>=6'} - dev: true - /builtins@5.0.1: - resolution: {integrity: sha512-qwVpFEHNfhYJIzNRBvd2C1kyo6jz3ZSMPyyuR47OPdiKWlbYnZNyDWuyR175qDnAJLiCo5fBBqPb3RiXgWlkOQ==} - dependencies: - semver: 7.5.4 - dev: true + buffer@6.0.3: + resolution: {integrity: sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==} - /cac@6.7.14: + cac@6.7.14: resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==} engines: {node: '>=8'} - dev: true - /call-bind@1.0.2: - resolution: {integrity: sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==} - dependencies: - function-bind: 1.1.1 - get-intrinsic: 1.2.1 - dev: true - - /callsites@3.1.0: + callsites@3.1.0: resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==} engines: {node: '>=6'} - dev: true - /camelcase@6.3.0: + camelcase@6.3.0: resolution: {integrity: sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==} engines: {node: '>=10'} - dev: true - /chalk@4.1.2: + chalk@4.1.2: resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} engines: {node: '>=10'} - dependencies: - ansi-styles: 4.3.0 - supports-color: 7.2.0 - dev: true - /character-entities-legacy@1.1.4: + character-entities-legacy@1.1.4: resolution: {integrity: sha512-3Xnr+7ZFS1uxeiUDvV02wQ+QDbc55o97tIV5zHScSPJpcLm/r0DFPcoY3tYRp+VZukxuMeKgXYmsXQHO05zQeA==} - dev: true - /character-entities@1.2.4: + character-entities@1.2.4: resolution: {integrity: sha512-iBMyeEHxfVnIakwOuDXpVkc54HijNgCyQB2w0VfGQThle6NXn50zU6V/u+LDhxHcDUPojn6Kpga3PTAD8W1bQw==} - dev: true - /character-reference-invalid@1.1.4: + character-reference-invalid@1.1.4: resolution: {integrity: sha512-mKKUkUbhPpQlCOfIuZkvSEgktjPFIsZKRRbC6KWVEMvlzblj3i3asQv5ODsrwt0N3pHAEvjP8KTQPHkp0+6jOg==} - dev: true - - /chardet@0.7.0: - resolution: {integrity: sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==} - dev: true - /chokidar@3.5.3: - resolution: {integrity: sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==} + chokidar@3.6.0: + resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==} engines: {node: '>= 8.10.0'} - dependencies: - anymatch: 3.1.3 - braces: 3.0.2 - glob-parent: 5.1.2 - is-binary-path: 2.1.0 - is-glob: 4.0.3 - normalize-path: 3.0.0 - readdirp: 3.6.0 - optionalDependencies: - fsevents: 2.3.3 - dev: true - - /cidr-regex@4.0.3: - resolution: {integrity: sha512-HOwDIy/rhKeMf6uOzxtv7FAbrz8zPjmVKfSpM+U7/bNBXC5rtOyr758jxcptiSx6ZZn5LOhPJT5WWxPAGDV8dw==} - engines: {node: '>=14'} - dependencies: - ip-regex: 5.0.0 - dev: true - - /cidr-tools@6.4.1: - resolution: {integrity: sha512-s8JNDwWgc2e0roEF6KDkQfHkZgEnehoap5hK7swPlEQMb9f8msrWqpgVCVKiDm3ARxpesOru9Tu49N8UpJjmDA==} - engines: {node: '>=16'} - dependencies: - cidr-regex: 4.0.3 - ip-bigint: 7.2.1 - ip-regex: 5.0.0 - string-natural-compare: 3.0.1 - dev: true - - /cli-cursor@3.1.0: - resolution: {integrity: sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==} - engines: {node: '>=8'} - dependencies: - restore-cursor: 3.1.0 - dev: true - - /cli-spinners@2.9.0: - resolution: {integrity: sha512-4/aL9X3Wh0yiMQlE+eeRhWP6vclO3QRtw1JHKIT0FFUs5FjpFmESqtMvYZ0+lbzBw900b95mS0hohy+qn2VK/g==} - engines: {node: '>=6'} - dev: true - - /cli-width@3.0.0: - resolution: {integrity: sha512-FxqpkPPwu1HjuN93Omfm4h8uIanXofW0RxVEW3k5RKx+mJJYSthzNhp32Kzxxy3YAEZ/Dc/EWN1vZRY0+kOhbw==} - engines: {node: '>= 10'} - dev: true - /cliui@7.0.4: + cliui@7.0.4: resolution: {integrity: sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==} - dependencies: - string-width: 4.2.3 - strip-ansi: 6.0.1 - wrap-ansi: 7.0.0 - dev: true - /cliui@8.0.1: + cliui@8.0.1: resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==} engines: {node: '>=12'} - dependencies: - string-width: 4.2.3 - strip-ansi: 6.0.1 - wrap-ansi: 7.0.0 - dev: true - - /clone-regexp@3.0.0: - resolution: {integrity: sha512-ujdnoq2Kxb8s3ItNBtnYeXdm07FcU0u8ARAT1lQ2YdMwQC+cdiXX8KoqMVuglztILivceTtp4ivqGSmEmhBUJw==} - engines: {node: '>=12'} - dependencies: - is-regexp: 3.1.0 - dev: true - - /clone@1.0.4: - resolution: {integrity: sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg==} - engines: {node: '>=0.8'} - dev: true - /code-red@1.0.3: - resolution: {integrity: sha512-kVwJELqiILQyG5aeuyKFbdsI1fmQy1Cmf7dQ8eGmVuJoaRVdwey7WaMknr2ZFeVSYSKT0rExsa8EGw0aoI/1QQ==} - dependencies: - '@jridgewell/sourcemap-codec': 1.4.15 - '@types/estree': 1.0.1 - acorn: 8.10.0 - estree-walker: 3.0.3 - periscopic: 3.1.0 + clsx@2.1.1: + resolution: {integrity: sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==} + engines: {node: '>=6'} - /color-convert@2.0.1: + color-convert@2.0.1: resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} engines: {node: '>=7.0.0'} - dependencies: - color-name: 1.1.4 - dev: true - /color-name@1.1.4: + color-name@1.1.4: resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} - dev: true - /colorette@2.0.20: + colorette@2.0.20: resolution: {integrity: sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==} - dev: true - /commander@2.20.3: + commander@2.20.3: resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==} - dev: true - /concat-map@0.0.1: + concat-map@0.0.1: resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} - dev: true - /consola@3.2.3: - resolution: {integrity: sha512-I5qxpzLv+sJhTVEoLYNcTW+bThDCPsit0vLNKShZx6rLtpilNpmmeTPaeqJb9ZE9dV3DGaeby6Vuhrw38WjeyQ==} - engines: {node: ^14.18.0 || >=16.10.0} - dev: true - - /convert-hrtime@5.0.0: - resolution: {integrity: sha512-lOETlkIeYSJWcbbcvjRKGxVMXJR+8+OQb/mTPbA4ObPMytYIsUbuOE0Jzy60hjARYszq1id0j8KgVhC+WGZVTg==} - engines: {node: '>=12'} - dev: true + confbox@0.1.8: + resolution: {integrity: sha512-RMtmw0iFkeR4YV+fUOSucriAQNb9g8zFR52MWCtl+cCZOFRNL6zeB395vPzFhEjjn4fMxXudmELnl/KF/WrK6w==} - /cookie@0.5.0: - resolution: {integrity: sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==} - engines: {node: '>= 0.6'} - dev: true + consola@3.4.0: + resolution: {integrity: sha512-EiPU8G6dQG0GFHNR8ljnZFki/8a+cQwEQ+7wpxdChl02Q8HXlwEZWD5lqAF8vC2sEC3Tehr8hy7vErz88LHyUA==} + engines: {node: ^14.18.0 || >=16.10.0} - /covector@0.10.2(mocha@10.2.0): - resolution: {integrity: sha512-Nbz2x5cnS7F0fTT/raNKo0UYbI6rjaDoCrAJNoOpsSHdztnlFi7Bb6lU6kOBEeEH1zHVJk5F3ChBs0VNAuf5mg==} + covector@0.12.4: + resolution: {integrity: sha512-qRK0Qg1FaRkB7dFDzzKiTn9H3EAMb83N5Hl6KVol2zpenmkKz8A7aa+7C49Z7LHtSgKkIWkqxIut8qcN6pRnag==} + engines: {node: '>=18'} hasBin: true - dependencies: - '@covector/apply': 0.9.2(mocha@10.2.0) - '@covector/assemble': 0.10.3(mocha@10.2.0) - '@covector/changelog': 0.10.1(mocha@10.2.0) - '@covector/command': 0.7.0(mocha@10.2.0) - '@covector/files': 0.7.1 - effection: 2.0.7(mocha@10.2.0) - globby: 11.1.0 - inquirer: 8.2.5 - yargs: 17.7.2 - transitivePeerDependencies: - - encoding - - mocha - - supports-color - dev: true - /cross-fetch@3.1.5: + cross-fetch@3.1.5: resolution: {integrity: sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw==} - dependencies: - node-fetch: 2.6.7 - transitivePeerDependencies: - - encoding - dev: true - /cross-spawn@7.0.3: - resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==} + cross-spawn@7.0.6: + resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==} engines: {node: '>= 8'} - dependencies: - path-key: 3.1.1 - shebang-command: 2.0.0 - which: 2.0.2 - dev: true - /css-tree@2.3.1: - resolution: {integrity: sha512-6Fv1DV/TYw//QF5IzQdqsNDjx/wc8TrMBZsqjL9eW01tWb7R7k/mq+/VXfJCl7SoD5emsJop9cOByJZfs8hYIw==} + css-tree@3.1.0: + resolution: {integrity: sha512-0eW44TGN5SQXU1mWSkKwFstI/22X2bG1nYzZTYMAWjylYURhse752YgbE4Cx46AC+bAvI+/dYTPRk1LqSUnu6w==} engines: {node: ^10 || ^12.20.0 || ^14.13.0 || >=15.0.0} - dependencies: - mdn-data: 2.0.30 - source-map-js: 1.0.2 - /ctrlc-windows@2.1.0: - resolution: {integrity: sha512-OrX5KI+K+2NMN91QIhYZdW7VDO2YsSdTZW494pA7Nvw/wBdU2hz+MGP006bR978zOTrG6Q8EIeJvLJmLqc6MsQ==} - dev: true + csstype@3.1.3: + resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==} - /debug@3.2.7: - resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==} + ctrlc-windows@2.2.0: + resolution: {integrity: sha512-t9y568r+T8FUuBaqKK60YGFJdj3b3ktdJW9WXIT3CuBdQhAOYdSZu75jFUN0Ay4Yz5HHicVQqAYCwcnqhOn23g==} + + debug@4.4.0: + resolution: {integrity: sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==} + engines: {node: '>=6.0'} peerDependencies: supports-color: '*' peerDependenciesMeta: supports-color: optional: true - dependencies: - ms: 2.1.3 - dev: true - /debug@4.3.4(supports-color@8.1.1): - resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} - engines: {node: '>=6.0'} - peerDependencies: - supports-color: '*' - peerDependenciesMeta: - supports-color: - optional: true - dependencies: - ms: 2.1.2 - supports-color: 8.1.1 - dev: true - - /decamelize@4.0.0: + decamelize@4.0.0: resolution: {integrity: sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==} engines: {node: '>=10'} - dev: true - /deep-is@0.1.4: + deep-is@0.1.4: resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} - dev: true - /deepmerge@4.3.1: + deepmerge@4.3.1: resolution: {integrity: sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==} engines: {node: '>=0.10.0'} - dev: true - - /default-gateway@7.2.2: - resolution: {integrity: sha512-AD7TrdNNPXRZIGw63dw+lnGmT4v7ggZC5NHNJgAYWm5njrwoze1q5JSAW9YuLy2tjnoLUG/r8FEB93MCh9QJPg==} - engines: {node: '>= 16'} - dependencies: - execa: 7.1.1 - dev: true - - /defaults@1.0.4: - resolution: {integrity: sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A==} - dependencies: - clone: 1.0.4 - dev: true - - /define-properties@1.2.0: - resolution: {integrity: sha512-xvqAVKGfT1+UAvPwKTVw/njhdQ8ZhXK4lI0bCIuCMrp2up9nPnaDftrLtmpTazqd1o+UY4zgzU+avtMbDP+ldA==} - engines: {node: '>= 0.4'} - dependencies: - has-property-descriptors: 1.0.0 - object-keys: 1.1.1 - dev: true - /defu@6.1.2: - resolution: {integrity: sha512-+uO4+qr7msjNNWKYPHqN/3+Dx3NFkmIzayk2L1MyZQlvgZb/J1A0fo410dpKrN2SnqFjt8n4JL8fDJE0wIgjFQ==} - dev: true + defu@6.1.4: + resolution: {integrity: sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg==} - /dequal@2.0.3: - resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==} - engines: {node: '>=6'} - - /destr@2.0.1: - resolution: {integrity: sha512-M1Ob1zPSIvlARiJUkKqvAZ3VAqQY6Jcuth/pBKQ2b1dX/Qx0OnJ8Vux6J2H5PTMQeRzWrrbTu70VxBfv/OPDJA==} - dev: true - - /detect-indent@6.1.0: - resolution: {integrity: sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA==} - engines: {node: '>=8'} - dev: true + destr@2.0.3: + resolution: {integrity: sha512-2N3BOUU4gYMpTP24s5rF5iP7BDr7uNTCs4ozw3kf/eKfvWSIu93GEBi5m427YoyJoeOzQ5smuu4nNAPGb8idSQ==} - /devalue@4.3.2: - resolution: {integrity: sha512-KqFl6pOgOW+Y6wJgu80rHpo2/3H07vr8ntR9rkkFIRETewbf5GaYYcakYfiKz89K+sLsuPkQIZaXDMjUObZwWg==} - dev: true - - /diff@5.0.0: - resolution: {integrity: sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==} + diff@5.2.0: + resolution: {integrity: sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==} engines: {node: '>=0.3.1'} - dev: true - /dir-glob@3.0.1: + dir-glob@3.0.1: resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==} engines: {node: '>=8'} - dependencies: - path-type: 4.0.0 - dev: true - - /doctrine@2.1.0: - resolution: {integrity: sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==} - engines: {node: '>=0.10.0'} - dependencies: - esutils: 2.0.3 - dev: true - - /doctrine@3.0.0: - resolution: {integrity: sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==} - engines: {node: '>=6.0.0'} - dependencies: - esutils: 2.0.3 - dev: true - /duplexer@0.1.2: + duplexer@0.1.2: resolution: {integrity: sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg==} - dev: true - /effection@2.0.7(mocha@10.2.0): - 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 - transitivePeerDependencies: - - encoding - - mocha - dev: true + effection@2.0.8: + resolution: {integrity: sha512-/v7cbPIXGGylInQgHHjJutzqUn6VIfcP13hh2X0hXf04wwAlSI+lVjUBKpr5TX3+v9dXV/JLHO/pqQ9Cp1QAnQ==} - /emoji-regex@8.0.0: + emoji-regex@8.0.0: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} - dev: true - - /es-abstract@1.22.1: - resolution: {integrity: sha512-ioRRcXMO6OFyRpyzV3kE1IIBd4WG5/kltnzdxSCqoP8CMGs/Li+M1uF5o7lOkZVFjDs+NLesthnF66Pg/0q0Lw==} - engines: {node: '>= 0.4'} - dependencies: - array-buffer-byte-length: 1.0.0 - arraybuffer.prototype.slice: 1.0.1 - available-typed-arrays: 1.0.5 - call-bind: 1.0.2 - es-set-tostringtag: 2.0.1 - es-to-primitive: 1.2.1 - function.prototype.name: 1.1.5 - get-intrinsic: 1.2.1 - get-symbol-description: 1.0.0 - globalthis: 1.0.3 - gopd: 1.0.1 - has: 1.0.3 - has-property-descriptors: 1.0.0 - has-proto: 1.0.1 - has-symbols: 1.0.3 - internal-slot: 1.0.5 - is-array-buffer: 3.0.2 - is-callable: 1.2.7 - is-negative-zero: 2.0.2 - is-regex: 1.1.4 - is-shared-array-buffer: 1.0.2 - is-string: 1.0.7 - is-typed-array: 1.1.12 - is-weakref: 1.0.2 - object-inspect: 1.12.3 - object-keys: 1.1.1 - object.assign: 4.1.4 - regexp.prototype.flags: 1.5.0 - safe-array-concat: 1.0.0 - safe-regex-test: 1.0.0 - string.prototype.trim: 1.2.7 - string.prototype.trimend: 1.0.6 - string.prototype.trimstart: 1.0.6 - typed-array-buffer: 1.0.0 - typed-array-byte-length: 1.0.0 - typed-array-byte-offset: 1.0.0 - typed-array-length: 1.0.4 - unbox-primitive: 1.0.2 - which-typed-array: 1.1.11 - dev: true - - /es-set-tostringtag@2.0.1: - resolution: {integrity: sha512-g3OMbtlwY3QewlqAiMLI47KywjWZoEytKr8pf6iTC8uJq5bIAH52Z9pnQ8pVL6whrCto53JZDuUIsifGeLorTg==} - engines: {node: '>= 0.4'} - dependencies: - get-intrinsic: 1.2.1 - has: 1.0.3 - has-tostringtag: 1.0.0 - dev: true - - /es-shim-unscopables@1.0.0: - resolution: {integrity: sha512-Jm6GPcCdC30eMLbZ2x8z2WuRwAws3zTBBKuusffYVUrNj/GVSUAZ+xKMaUpfNDR5IbyNA5LJbaecoUVbmUcB1w==} - dependencies: - has: 1.0.3 - dev: true - - /es-to-primitive@1.2.1: - resolution: {integrity: sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==} - engines: {node: '>= 0.4'} - dependencies: - is-callable: 1.2.7 - is-date-object: 1.0.5 - is-symbol: 1.0.4 - dev: true - /es6-promise@3.3.1: - resolution: {integrity: sha512-SOp9Phqvqn7jtEUxPWdWfWoLmyt2VaJ6MpvP9Comy1MceMXqE6bxvaTu4iaxpYYPzhny28Lc+M87/c2cPK6lDg==} - dev: true + entities@4.5.0: + resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==} + engines: {node: '>=0.12'} - /esbuild@0.18.14: - resolution: {integrity: sha512-uNPj5oHPYmj+ZhSQeYQVFZ+hAlJZbAGOmmILWIqrGvPVlNLbyOvU5Bu6Woi8G8nskcx0vwY0iFoMPrzT86Ko+w==} - engines: {node: '>=12'} + esbuild@0.25.3: + resolution: {integrity: sha512-qKA6Pvai73+M2FtftpNKRxJ78GIjmFXFxd/1DVBqGo/qNhLSfv+G12n9pNoWdytJC8U00TrViOwpjT0zgqQS8Q==} + engines: {node: '>=18'} hasBin: true - requiresBuild: true - optionalDependencies: - '@esbuild/android-arm': 0.18.14 - '@esbuild/android-arm64': 0.18.14 - '@esbuild/android-x64': 0.18.14 - '@esbuild/darwin-arm64': 0.18.14 - '@esbuild/darwin-x64': 0.18.14 - '@esbuild/freebsd-arm64': 0.18.14 - '@esbuild/freebsd-x64': 0.18.14 - '@esbuild/linux-arm': 0.18.14 - '@esbuild/linux-arm64': 0.18.14 - '@esbuild/linux-ia32': 0.18.14 - '@esbuild/linux-loong64': 0.18.14 - '@esbuild/linux-mips64el': 0.18.14 - '@esbuild/linux-ppc64': 0.18.14 - '@esbuild/linux-riscv64': 0.18.14 - '@esbuild/linux-s390x': 0.18.14 - '@esbuild/linux-x64': 0.18.14 - '@esbuild/netbsd-x64': 0.18.14 - '@esbuild/openbsd-x64': 0.18.14 - '@esbuild/sunos-x64': 0.18.14 - '@esbuild/win32-arm64': 0.18.14 - '@esbuild/win32-ia32': 0.18.14 - '@esbuild/win32-x64': 0.18.14 - dev: true - - /escalade@3.1.1: - resolution: {integrity: sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==} - engines: {node: '>=6'} - dev: true - /escape-string-regexp@1.0.5: - resolution: {integrity: sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==} - engines: {node: '>=0.8.0'} - dev: true + escalade@3.2.0: + resolution: {integrity: sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==} + engines: {node: '>=6'} - /escape-string-regexp@4.0.0: + escape-string-regexp@4.0.0: resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==} engines: {node: '>=10'} - dev: true - /eslint-config-prettier@9.0.0(eslint@8.51.0): - resolution: {integrity: sha512-IcJsTkJae2S35pRsRAwoCE+925rJJStOdkKnLVgtE+tEpqU0EVVM7OqrwxqgptKdX29NUwC82I5pXsGFIgSevw==} + eslint-config-prettier@10.1.5: + resolution: {integrity: sha512-zc1UmCpNltmVY34vuLRV61r1K27sWuX39E+uyUnY8xS2Bex88VV9cugG+UZbRSRGtGyFboj+D8JODyme1plMpw==} hasBin: true peerDependencies: eslint: '>=7.0.0' - dependencies: - eslint: 8.51.0 - dev: true - /eslint-config-standard-with-typescript@39.1.1(@typescript-eslint/eslint-plugin@6.8.0)(eslint-plugin-import@2.28.1)(eslint-plugin-n@16.2.0)(eslint-plugin-promise@6.1.1)(eslint@8.51.0)(typescript@5.2.2): - resolution: {integrity: sha512-t6B5Ep8E4I18uuoYeYxINyqcXb2UbC0SOOTxRtBSt2JUs+EzeXbfe2oaiPs71AIdnoWhXDO2fYOHz8df3kV84A==} - peerDependencies: - '@typescript-eslint/eslint-plugin': ^6.4.0 - eslint: ^8.0.1 - eslint-plugin-import: ^2.25.2 - eslint-plugin-n: '^15.0.0 || ^16.0.0 ' - eslint-plugin-promise: ^6.0.0 - typescript: '*' - dependencies: - '@typescript-eslint/eslint-plugin': 6.8.0(@typescript-eslint/parser@6.8.0)(eslint@8.51.0)(typescript@5.2.2) - '@typescript-eslint/parser': 6.8.0(eslint@8.51.0)(typescript@5.2.2) - eslint: 8.51.0 - eslint-config-standard: 17.1.0(eslint-plugin-import@2.28.1)(eslint-plugin-n@16.2.0)(eslint-plugin-promise@6.1.1)(eslint@8.51.0) - eslint-plugin-import: 2.28.1(@typescript-eslint/parser@6.8.0)(eslint@8.51.0) - eslint-plugin-n: 16.2.0(eslint@8.51.0) - eslint-plugin-promise: 6.1.1(eslint@8.51.0) - typescript: 5.2.2 - transitivePeerDependencies: - - supports-color - dev: true + eslint-plugin-security@3.0.1: + resolution: {integrity: sha512-XjVGBhtDZJfyuhIxnQ/WMm385RbX3DBu7H1J7HNNhmB2tnGxMeqVSnYv79oAj992ayvIBZghsymwkYFS6cGH4Q==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - /eslint-config-standard@17.1.0(eslint-plugin-import@2.28.1)(eslint-plugin-n@16.2.0)(eslint-plugin-promise@6.1.1)(eslint@8.51.0): - resolution: {integrity: sha512-IwHwmaBNtDK4zDHQukFDW5u/aTb8+meQWZvNFWkiGmbWjD6bqyuSSBxxXKkCftCUzc1zwCH2m/baCNDLGmuO5Q==} - engines: {node: '>=12.0.0'} - peerDependencies: - eslint: ^8.0.1 - eslint-plugin-import: ^2.25.2 - eslint-plugin-n: '^15.0.0 || ^16.0.0 ' - eslint-plugin-promise: ^6.0.0 - dependencies: - eslint: 8.51.0 - eslint-plugin-import: 2.28.1(@typescript-eslint/parser@6.8.0)(eslint@8.51.0) - eslint-plugin-n: 16.2.0(eslint@8.51.0) - eslint-plugin-promise: 6.1.1(eslint@8.51.0) - dev: true - - /eslint-import-resolver-node@0.3.7: - resolution: {integrity: sha512-gozW2blMLJCeFpBwugLTGyvVjNoeo1knonXAcatC6bjPBZitotxdWf7Gimr25N4c0AAOo4eOUfaG82IJPDpqCA==} - dependencies: - debug: 3.2.7 - is-core-module: 2.13.0 - resolve: 1.22.2 - transitivePeerDependencies: - - supports-color - dev: true + eslint-scope@8.3.0: + resolution: {integrity: sha512-pUNxi75F8MJ/GdeKtVLSbYg4ZI34J6C0C7sbL4YOp2exGwen7ZsuBqKzUhXd0qMQ362yET3z+uPwKeg/0C2XCQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - /eslint-module-utils@2.8.0(@typescript-eslint/parser@6.8.0)(eslint-import-resolver-node@0.3.7)(eslint@8.51.0): - resolution: {integrity: sha512-aWajIYfsqCKRDgUfjEXNN/JlrzauMuSEy5sbd7WXbtW3EH6A6MpwEh42c7qD+MqQo9QMJ6fWLAeIJynx0g6OAw==} - engines: {node: '>=4'} - peerDependencies: - '@typescript-eslint/parser': '*' - eslint: '*' - eslint-import-resolver-node: '*' - eslint-import-resolver-typescript: '*' - eslint-import-resolver-webpack: '*' - peerDependenciesMeta: - '@typescript-eslint/parser': - optional: true - eslint: - optional: true - eslint-import-resolver-node: - optional: true - eslint-import-resolver-typescript: - optional: true - eslint-import-resolver-webpack: - optional: true - dependencies: - '@typescript-eslint/parser': 6.8.0(eslint@8.51.0)(typescript@5.2.2) - debug: 3.2.7 - eslint: 8.51.0 - eslint-import-resolver-node: 0.3.7 - transitivePeerDependencies: - - supports-color - dev: true + eslint-visitor-keys@3.4.3: + resolution: {integrity: sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - /eslint-plugin-es-x@7.1.0(eslint@8.51.0): - resolution: {integrity: sha512-AhiaF31syh4CCQ+C5ccJA0VG6+kJK8+5mXKKE7Qs1xcPRg02CDPOj3mWlQxuWS/AYtg7kxrDNgW9YW3vc0Q+Mw==} - engines: {node: ^14.18.0 || >=16.0.0} - peerDependencies: - eslint: '>=8' - dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@8.51.0) - '@eslint-community/regexpp': 4.5.1 - eslint: 8.51.0 - dev: true + eslint-visitor-keys@4.2.0: + resolution: {integrity: sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - /eslint-plugin-import@2.28.1(@typescript-eslint/parser@6.8.0)(eslint@8.51.0): - resolution: {integrity: sha512-9I9hFlITvOV55alzoKBI+K9q74kv0iKMeY6av5+umsNwayt59fz692daGyjR+oStBQgx6nwR9rXldDev3Clw+A==} - engines: {node: '>=4'} + eslint@9.28.0: + resolution: {integrity: sha512-ocgh41VhRlf9+fVpe7QKzwLj9c92fDiqOj8Y3Sd4/ZmVA4Btx4PlUYPq4pp9JDyupkf1upbEXecxL2mwNV7jPQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + hasBin: true peerDependencies: - '@typescript-eslint/parser': '*' - eslint: ^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8 + jiti: '*' peerDependenciesMeta: - '@typescript-eslint/parser': + jiti: optional: true - dependencies: - '@typescript-eslint/parser': 6.8.0(eslint@8.51.0)(typescript@5.2.2) - array-includes: 3.1.6 - array.prototype.findlastindex: 1.2.3 - array.prototype.flat: 1.3.1 - array.prototype.flatmap: 1.3.1 - debug: 3.2.7 - doctrine: 2.1.0 - eslint: 8.51.0 - eslint-import-resolver-node: 0.3.7 - eslint-module-utils: 2.8.0(@typescript-eslint/parser@6.8.0)(eslint-import-resolver-node@0.3.7)(eslint@8.51.0) - has: 1.0.3 - is-core-module: 2.13.0 - is-glob: 4.0.3 - minimatch: 3.1.2 - object.fromentries: 2.0.7 - object.groupby: 1.0.1 - object.values: 1.1.6 - semver: 7.5.4 - tsconfig-paths: 3.14.2 - transitivePeerDependencies: - - eslint-import-resolver-typescript - - eslint-import-resolver-webpack - - supports-color - dev: true - - /eslint-plugin-n@16.2.0(eslint@8.51.0): - resolution: {integrity: sha512-AQER2jEyQOt1LG6JkGJCCIFotzmlcCZFur2wdKrp1JX2cNotC7Ae0BcD/4lLv3lUAArM9uNS8z/fsvXTd0L71g==} - engines: {node: '>=16.0.0'} - peerDependencies: - eslint: '>=7.0.0' - dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@8.51.0) - builtins: 5.0.1 - eslint: 8.51.0 - eslint-plugin-es-x: 7.1.0(eslint@8.51.0) - get-tsconfig: 4.7.2 - ignore: 5.2.4 - is-core-module: 2.12.1 - minimatch: 3.1.2 - resolve: 1.22.2 - semver: 7.5.4 - dev: true - - /eslint-plugin-promise@6.1.1(eslint@8.51.0): - resolution: {integrity: sha512-tjqWDwVZQo7UIPMeDReOpUgHCmCiH+ePnVT+5zVapL0uuHnegBUs2smM13CzOs2Xb5+MHMRFTs9v24yjba4Oig==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - peerDependencies: - eslint: ^7.0.0 || ^8.0.0 - dependencies: - eslint: 8.51.0 - dev: true - - /eslint-plugin-security@1.7.1: - resolution: {integrity: sha512-sMStceig8AFglhhT2LqlU5r+/fn9OwsA72O5bBuQVTssPCdQAOQzL+oMn/ZcpeUY6KcNfLJArgcrsSULNjYYdQ==} - dependencies: - safe-regex: 2.1.1 - dev: true - - /eslint-scope@7.2.2: - resolution: {integrity: sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - dependencies: - esrecurse: 4.3.0 - estraverse: 5.3.0 - dev: true - - /eslint-visitor-keys@3.4.1: - resolution: {integrity: sha512-pZnmmLwYzf+kWaM/Qgrvpen51upAktaaiI01nsJD/Yr3lMOdNtq0cxkrrg16w64VtisN6okbs7Q8AfGqj4c9fA==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - dev: true - - /eslint-visitor-keys@3.4.3: - resolution: {integrity: sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - dev: true - - /eslint@8.51.0: - resolution: {integrity: sha512-2WuxRZBrlwnXi+/vFSJyjMqrNjtJqiasMzehF0shoLaW7DzS3/9Yvrmq5JiT66+pNjiX4UBnLDiKHcWAr/OInA==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - hasBin: true - dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@8.51.0) - '@eslint-community/regexpp': 4.9.1 - '@eslint/eslintrc': 2.1.2 - '@eslint/js': 8.51.0 - '@humanwhocodes/config-array': 0.11.12 - '@humanwhocodes/module-importer': 1.0.1 - '@nodelib/fs.walk': 1.2.8 - ajv: 6.12.6 - chalk: 4.1.2 - cross-spawn: 7.0.3 - debug: 4.3.4(supports-color@8.1.1) - doctrine: 3.0.0 - escape-string-regexp: 4.0.0 - eslint-scope: 7.2.2 - eslint-visitor-keys: 3.4.3 - espree: 9.6.1 - esquery: 1.5.0 - esutils: 2.0.3 - fast-deep-equal: 3.1.3 - file-entry-cache: 6.0.1 - find-up: 5.0.0 - glob-parent: 6.0.2 - globals: 13.20.0 - graphemer: 1.4.0 - ignore: 5.2.4 - imurmurhash: 0.1.4 - is-glob: 4.0.3 - is-path-inside: 3.0.3 - js-yaml: 4.1.0 - json-stable-stringify-without-jsonify: 1.0.1 - levn: 0.4.1 - lodash.merge: 4.6.2 - minimatch: 3.1.2 - natural-compare: 1.4.0 - optionator: 0.9.3 - strip-ansi: 6.0.1 - text-table: 0.2.0 - transitivePeerDependencies: - - supports-color - dev: true - /esm-env@1.0.0: - resolution: {integrity: sha512-Cf6VksWPsTuW01vU9Mk/3vRue91Zevka5SjyNf3nEpokFRuqt/KjUQoGAwq9qMmhpLTHmXzSIrFRw8zxWzmFBA==} - dev: true + esm-env@1.2.2: + resolution: {integrity: sha512-Epxrv+Nr/CaL4ZcFGPJIYLWFom+YeV1DqMLHJoEd9SYRxNbaFruBwfEX/kkHUJf55j2+TUbmDcmuilbP1TmXHA==} - /espree@9.6.1: - resolution: {integrity: sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - dependencies: - acorn: 8.10.0 - acorn-jsx: 5.3.2(acorn@8.10.0) - eslint-visitor-keys: 3.4.3 - dev: true + espree@10.3.0: + resolution: {integrity: sha512-0QYC8b24HWY8zjRnDTL6RiHfDbAWn63qb4LMj1Z4b076A4une81+z03Kg7l7mn/48PUTqoLptSXez8oknU8Clg==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - /esquery@1.5.0: - resolution: {integrity: sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==} + esquery@1.6.0: + resolution: {integrity: sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg==} engines: {node: '>=0.10'} - dependencies: - estraverse: 5.3.0 - dev: true - /esrecurse@4.3.0: + esrap@1.4.6: + resolution: {integrity: sha512-F/D2mADJ9SHY3IwksD4DAXjTt7qt7GWUf3/8RhCNWmC/67tyb55dpimHmy7EplakFaflV0R/PC+fdSPqrRHAQw==} + + esrecurse@4.3.0: resolution: {integrity: sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==} engines: {node: '>=4.0'} - dependencies: - estraverse: 5.3.0 - dev: true - /estraverse@5.3.0: + estraverse@5.3.0: resolution: {integrity: sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==} engines: {node: '>=4.0'} - dev: true - /estree-walker@2.0.2: + estree-walker@2.0.2: resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==} - dev: true - /estree-walker@3.0.3: - resolution: {integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==} - dependencies: - '@types/estree': 1.0.1 - - /esutils@2.0.3: + esutils@2.0.3: resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==} engines: {node: '>=0.10.0'} - dev: true - /event-target-shim@5.0.1: + event-target-shim@5.0.1: resolution: {integrity: sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==} engines: {node: '>=6'} - dev: true - /execa@5.1.1: - resolution: {integrity: sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==} - engines: {node: '>=10'} - dependencies: - cross-spawn: 7.0.3 - get-stream: 6.0.1 - human-signals: 2.1.0 - is-stream: 2.0.1 - merge-stream: 2.0.0 - npm-run-path: 4.0.1 - onetime: 5.1.2 - signal-exit: 3.0.7 - strip-final-newline: 2.0.0 - dev: true - - /execa@7.1.1: - resolution: {integrity: sha512-wH0eMf/UXckdUYnO21+HDztteVv05rq2GXksxT4fCGeHkBhw1DROXh40wcjMcRqDOWE7iPJ4n3M7e2+YFP+76Q==} - engines: {node: ^14.18.0 || ^16.14.0 || >=18.0.0} - dependencies: - cross-spawn: 7.0.3 - get-stream: 6.0.1 - human-signals: 4.3.1 - is-stream: 3.0.0 - merge-stream: 2.0.0 - npm-run-path: 5.1.0 - onetime: 6.0.0 - signal-exit: 3.0.7 - strip-final-newline: 3.0.0 - dev: true - - /extend@3.0.2: - resolution: {integrity: sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==} - dev: true + events@3.3.0: + resolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==} + engines: {node: '>=0.8.x'} - /external-editor@3.1.0: - resolution: {integrity: sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==} - engines: {node: '>=4'} - dependencies: - chardet: 0.7.0 - iconv-lite: 0.4.24 - tmp: 0.0.33 - dev: true + extend@3.0.2: + resolution: {integrity: sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==} - /fast-deep-equal@3.1.3: + fast-deep-equal@3.1.3: resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} - dev: true - - /fast-glob@3.3.0: - resolution: {integrity: sha512-ChDuvbOypPuNjO8yIDf36x7BlZX1smcUMTTcyoIjycexOxd6DFsKsg21qVBzEmr3G7fUKIRy2/psii+CIUt7FA==} - engines: {node: '>=8.6.0'} - dependencies: - '@nodelib/fs.stat': 2.0.5 - '@nodelib/fs.walk': 1.2.8 - glob-parent: 5.1.2 - merge2: 1.4.1 - micromatch: 4.0.5 - dev: true - /fast-glob@3.3.1: - resolution: {integrity: sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==} + fast-glob@3.3.3: + resolution: {integrity: sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==} engines: {node: '>=8.6.0'} - dependencies: - '@nodelib/fs.stat': 2.0.5 - '@nodelib/fs.walk': 1.2.8 - glob-parent: 5.1.2 - merge2: 1.4.1 - micromatch: 4.0.5 - dev: true - /fast-json-stable-stringify@2.1.0: + fast-json-stable-stringify@2.1.0: resolution: {integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==} - dev: true - /fast-levenshtein@2.0.6: + fast-levenshtein@2.0.6: resolution: {integrity: sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==} - dev: true - /fastq@1.15.0: - resolution: {integrity: sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==} - dependencies: - reusify: 1.0.4 - dev: true + fast-redact@3.5.0: + resolution: {integrity: sha512-dwsoQlS7h9hMeYUq1W++23NDcBLV4KqONnITDV9DjfS3q1SgDGVrBdvvTLUotWtPSD7asWDV9/CmsZPy8Hf70A==} + engines: {node: '>=6'} - /fault@1.0.4: + fastq@1.19.1: + resolution: {integrity: sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ==} + + fault@1.0.4: resolution: {integrity: sha512-CJ0HCB5tL5fYTEA7ToAq5+kTwd++Borf1/bifxd9iT70QcXr4MRrO3Llf8Ifs70q+SJcGHFtnIE/Nw6giCtECA==} - dependencies: - format: 0.2.2 - dev: true - /figures@3.2.0: - resolution: {integrity: sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg==} - engines: {node: '>=8'} - dependencies: - escape-string-regexp: 1.0.5 - dev: true + fdir@6.4.4: + resolution: {integrity: sha512-1NZP+GK4GfuAv3PqKvxQRDMjdSRZjnkq7KfhlNrCNNlZ0ygQFpebfrnfnq/W7fpUnAv9aGWmY1zKx7FYL3gwhg==} + peerDependencies: + picomatch: ^3 || ^4 + peerDependenciesMeta: + picomatch: + optional: true - /file-entry-cache@6.0.1: - resolution: {integrity: sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==} - engines: {node: ^10.12.0 || >=12.0.0} - dependencies: - flat-cache: 3.0.4 - dev: true + file-entry-cache@8.0.0: + resolution: {integrity: sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==} + engines: {node: '>=16.0.0'} - /fill-range@7.0.1: - resolution: {integrity: sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==} + fill-range@7.1.1: + resolution: {integrity: sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==} engines: {node: '>=8'} - dependencies: - to-regex-range: 5.0.1 - dev: true - /find-up@5.0.0: + find-up@5.0.0: resolution: {integrity: sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==} engines: {node: '>=10'} - dependencies: - locate-path: 6.0.0 - path-exists: 4.0.0 - dev: true - /flat-cache@3.0.4: - resolution: {integrity: sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==} - engines: {node: ^10.12.0 || >=12.0.0} - dependencies: - flatted: 3.2.7 - rimraf: 3.0.2 - dev: true + flat-cache@4.0.1: + resolution: {integrity: sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==} + engines: {node: '>=16'} - /flat@5.0.2: + flat@5.0.2: resolution: {integrity: sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==} hasBin: true - dev: true - - /flatted@3.2.7: - resolution: {integrity: sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==} - dev: true - /for-each@0.3.3: - resolution: {integrity: sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==} - dependencies: - is-callable: 1.2.7 - dev: true + flatted@3.3.3: + resolution: {integrity: sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg==} - /format@0.2.2: + format@0.2.2: resolution: {integrity: sha512-wzsgA6WOq+09wrU1tsJ09udeR/YZRaeArL9e1wPbFg3GG2yDnC2ldKpxs4xunpFF9DgqCqOIra3bc1HWrJ37Ww==} engines: {node: '>=0.4.x'} - dev: true - /fs.realpath@1.0.0: + fs.realpath@1.0.0: resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} - dev: true - /fsevents@2.3.3: + fsevents@2.3.3: resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} os: [darwin] - requiresBuild: true - dev: true - optional: true - - /function-bind@1.1.1: - resolution: {integrity: sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==} - dev: true - - /function-timeout@0.1.1: - resolution: {integrity: sha512-0NVVC0TaP7dSTvn1yMiy6d6Q8gifzbvQafO46RtLG/kHJUBNd+pVRGOBoK44wNBvtSPUJRfdVvkFdD3p0xvyZg==} - engines: {node: '>=14.16'} - dev: true - /function.prototype.name@1.1.5: - resolution: {integrity: sha512-uN7m/BzVKQnCUF/iW8jYea67v++2u7m5UgENbHRtdDVclOUP+FMPlCNdmk0h/ysGyo2tavMJEDqJAkJdRa1vMA==} - engines: {node: '>= 0.4'} - dependencies: - call-bind: 1.0.2 - define-properties: 1.2.0 - es-abstract: 1.22.1 - functions-have-names: 1.2.3 - dev: true + function-bind@1.1.2: + resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==} - /functions-have-names@1.2.3: - resolution: {integrity: sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==} - dev: true - - /get-caller-file@2.0.5: + get-caller-file@2.0.5: resolution: {integrity: sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==} engines: {node: 6.* || 8.* || >= 10.*} - dev: true - - /get-intrinsic@1.2.1: - resolution: {integrity: sha512-2DcsyfABl+gVHEfCOaTrWgyt+tb6MSEGmKq+kI5HwLbIYgjgmMcV8KQ41uaKz1xxUcn9tJtgFbQUEVcEbd0FYw==} - dependencies: - function-bind: 1.1.1 - has: 1.0.3 - has-proto: 1.0.1 - has-symbols: 1.0.3 - dev: true - - /get-stream@6.0.1: - resolution: {integrity: sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==} - engines: {node: '>=10'} - dev: true - - /get-symbol-description@1.0.0: - resolution: {integrity: sha512-2EmdH1YvIQiZpltCNgkuiUnyukzxM/R6NDJX31Ke3BG1Nq5b0S2PhX59UKi9vZpPDQVdqn+1IcaAwnzTT5vCjw==} - engines: {node: '>= 0.4'} - dependencies: - call-bind: 1.0.2 - get-intrinsic: 1.2.1 - dev: true - /get-tsconfig@4.7.2: - resolution: {integrity: sha512-wuMsz4leaj5hbGgg4IvDU0bqJagpftG5l5cXIAvo8uZrqn0NJqwtfupTN00VnkQJPcIRrxYrm1Ue24btpCha2A==} - dependencies: - resolve-pkg-maps: 1.0.0 - dev: true + get-tsconfig@4.10.0: + resolution: {integrity: sha512-kGzZ3LWWQcGIAmg6iWvXn0ei6WDtV26wzHRMwDSzmAbcXrTEXxHy6IehI6/4eT6VRKyMP1eF1VqwrVUmE/LR7A==} - /glob-parent@5.1.2: + glob-parent@5.1.2: resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} engines: {node: '>= 6'} - dependencies: - is-glob: 4.0.3 - dev: true - /glob-parent@6.0.2: + glob-parent@6.0.2: resolution: {integrity: sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==} engines: {node: '>=10.13.0'} - dependencies: - is-glob: 4.0.3 - dev: true - - /glob@7.2.0: - resolution: {integrity: sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==} - dependencies: - fs.realpath: 1.0.0 - inflight: 1.0.6 - inherits: 2.0.4 - minimatch: 3.1.2 - once: 1.4.0 - path-is-absolute: 1.0.1 - dev: true - - /glob@7.2.3: - resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} - dependencies: - fs.realpath: 1.0.0 - inflight: 1.0.6 - inherits: 2.0.4 - minimatch: 3.1.2 - once: 1.4.0 - path-is-absolute: 1.0.1 - dev: true - /globals@13.20.0: - resolution: {integrity: sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==} - engines: {node: '>=8'} - dependencies: - type-fest: 0.20.2 - dev: true + glob@8.1.0: + resolution: {integrity: sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==} + engines: {node: '>=12'} + deprecated: Glob versions prior to v9 are no longer supported - /globalthis@1.0.3: - resolution: {integrity: sha512-sFdI5LyBiNTHjRd7cGPWapiHWMOXKyuBNX/cWJ3NfzrZQVa8GI/8cofCl74AOVqq9W5kNmguTIzJ/1s2gyI9wA==} - engines: {node: '>= 0.4'} - dependencies: - define-properties: 1.2.0 - dev: true + globals@14.0.0: + resolution: {integrity: sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==} + engines: {node: '>=18'} - /globalyzer@0.1.0: - resolution: {integrity: sha512-40oNTM9UfG6aBmuKxk/giHn5nQ8RVz/SS4Ir6zgzOv9/qC3kKZ9v4etGTcJbEl/NyVQH7FGU7d+X1egr57Md2Q==} - dev: true + globals@15.15.0: + resolution: {integrity: sha512-7ACyT3wmyp3I61S4fG682L0VA2RGD9otkqGJIwNUMF1SWUombIIk+af1unuDYgMm082aHYwD+mzJvv9Iu8dsgg==} + engines: {node: '>=18'} - /globby@11.1.0: + globby@11.1.0: resolution: {integrity: sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==} engines: {node: '>=10'} - dependencies: - array-union: 2.1.0 - dir-glob: 3.0.1 - fast-glob: 3.3.0 - ignore: 5.2.4 - merge2: 1.4.1 - slash: 3.0.0 - dev: true - /globrex@0.1.2: - resolution: {integrity: sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==} - dev: true - - /gopd@1.0.1: - resolution: {integrity: sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==} - dependencies: - get-intrinsic: 1.2.1 - dev: true - - /graceful-fs@4.2.11: - resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} - dev: true - - /graphemer@1.4.0: + graphemer@1.4.0: resolution: {integrity: sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==} - dev: true - /gzip-size@6.0.0: + gzip-size@6.0.0: resolution: {integrity: sha512-ax7ZYomf6jqPTQ4+XCpUGyXKHk5WweS+e05MBO4/y3WJ5RkmPXNKvX+bx1behVILVwr6JSQvZAku021CHPXG3Q==} engines: {node: '>=10'} - dependencies: - duplexer: 0.1.2 - dev: true - /has-bigints@1.0.2: - resolution: {integrity: sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==} - dev: true - - /has-flag@4.0.0: + has-flag@4.0.0: resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==} engines: {node: '>=8'} - dev: true - - /has-property-descriptors@1.0.0: - resolution: {integrity: sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ==} - dependencies: - get-intrinsic: 1.2.1 - dev: true - - /has-proto@1.0.1: - resolution: {integrity: sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==} - engines: {node: '>= 0.4'} - dev: true - - /has-symbols@1.0.3: - resolution: {integrity: sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==} - engines: {node: '>= 0.4'} - dev: true - /has-tostringtag@1.0.0: - resolution: {integrity: sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ==} + hasown@2.0.2: + resolution: {integrity: sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==} engines: {node: '>= 0.4'} - dependencies: - has-symbols: 1.0.3 - dev: true - - /has@1.0.3: - resolution: {integrity: sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==} - engines: {node: '>= 0.4.0'} - dependencies: - function-bind: 1.1.1 - dev: true - /he@1.2.0: + he@1.2.0: resolution: {integrity: sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==} hasBin: true - dev: true - /human-signals@2.1.0: - resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==} - engines: {node: '>=10.17.0'} - dev: true - - /human-signals@4.3.1: - resolution: {integrity: sha512-nZXjEF2nbo7lIw3mgYjItAfgQXog3OjJogSbKa2CQIIvSGWcKgeJnQlNXip6NglNzYH45nSRiEVimMvYL8DDqQ==} - engines: {node: '>=14.18.0'} - dev: true - - /iconv-lite@0.4.24: - resolution: {integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==} - engines: {node: '>=0.10.0'} - dependencies: - safer-buffer: 2.1.2 - dev: true - - /ieee754@1.2.1: + ieee754@1.2.1: resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} - dev: true - /ignore@5.2.4: - resolution: {integrity: sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==} + ignore@5.3.2: + resolution: {integrity: sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==} + engines: {node: '>= 4'} + + ignore@7.0.4: + resolution: {integrity: sha512-gJzzk+PQNznz8ysRrC0aOkBNVRBDtE1n53IqyqEf3PXrYwomFs5q4pGMizBMJF+ykh03insJ27hB8gSrD2Hn8A==} engines: {node: '>= 4'} - dev: true - /import-fresh@3.3.0: - resolution: {integrity: sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==} + import-fresh@3.3.1: + resolution: {integrity: sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==} engines: {node: '>=6'} - dependencies: - parent-module: 1.0.1 - resolve-from: 4.0.0 - dev: true - /imurmurhash@0.1.4: + imurmurhash@0.1.4: resolution: {integrity: sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==} engines: {node: '>=0.8.19'} - dev: true - /inflight@1.0.6: + inflight@1.0.6: resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==} - dependencies: - once: 1.4.0 - wrappy: 1.0.2 - dev: true + deprecated: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful. - /inherits@2.0.4: + inherits@2.0.4: resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} - dev: true - /inquirer@8.2.5: - resolution: {integrity: sha512-QAgPDQMEgrDssk1XiwwHoOGYF9BAbUcc1+j+FhEvaOt8/cKRqyLn0U5qA6F74fGhTMGxf92pOvPBeh29jQJDTQ==} - engines: {node: '>=12.0.0'} - dependencies: - ansi-escapes: 4.3.2 - chalk: 4.1.2 - cli-cursor: 3.1.0 - cli-width: 3.0.0 - external-editor: 3.1.0 - figures: 3.2.0 + is-alphabetical@1.0.4: + resolution: {integrity: sha512-DwzsA04LQ10FHTZuL0/grVDk4rFoVH1pjAToYwBrHSxcrBIGQuXrQMtD5U1b0U2XVgKZCTLLP8u2Qxqhy3l2Vg==} + + is-alphanumerical@1.0.4: + resolution: {integrity: sha512-UzoZUr+XfVz3t3v4KyGEniVL9BDRoQtY7tOyrRybkVNjDFWyo1yhXNGrrBTQxp3ib9BLAWs7k2YKBQsFRkZG9A==} + + is-binary-path@2.1.0: + resolution: {integrity: sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==} + engines: {node: '>=8'} + + is-buffer@2.0.5: + resolution: {integrity: sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ==} + engines: {node: '>=4'} + + is-core-module@2.16.1: + resolution: {integrity: sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==} + engines: {node: '>= 0.4'} + + is-decimal@1.0.4: + resolution: {integrity: sha512-RGdriMmQQvZ2aqaQq3awNA6dCGtKpiDFcOzrTWrDAT2MiWrKQVPmxLGHl7Y2nNu6led0kEyoX0enY0qXYsv9zw==} + + is-extglob@2.1.1: + resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==} + engines: {node: '>=0.10.0'} + + is-fullwidth-code-point@3.0.0: + resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==} + engines: {node: '>=8'} + + is-glob@4.0.3: + resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==} + engines: {node: '>=0.10.0'} + + is-hexadecimal@1.0.4: + resolution: {integrity: sha512-gyPJuv83bHMpocVYoqof5VDiZveEoGoFL8m3BXNb2VW8Xs+rz9kqO8LOQ5DH6EsuvilT1ApazU0pyl+ytbPtlw==} + + is-module@1.0.0: + resolution: {integrity: sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==} + + is-number@7.0.0: + resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} + engines: {node: '>=0.12.0'} + + is-plain-obj@2.1.0: + resolution: {integrity: sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==} + engines: {node: '>=8'} + + is-reference@3.0.3: + resolution: {integrity: sha512-ixkJoqQvAP88E6wLydLGGqCJsrFUnqoH6HnaczB8XmDH1oaWU+xxdptvikTgaEhtZ53Ky6YXiBuUI2WXLMCwjw==} + + is-unicode-supported@0.1.0: + resolution: {integrity: sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==} + engines: {node: '>=10'} + + isexe@2.0.0: + resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} + + jiti@2.4.2: + resolution: {integrity: sha512-rg9zJN+G4n2nfJl5MW3BMygZX56zKPNVEYYqq7adpmMh4Jn2QNEwhvQlFy6jPVdcod7txZtKHWnyZiA3a0zP7A==} + hasBin: true + + js-yaml@4.1.0: + resolution: {integrity: sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==} + hasBin: true + + json-buffer@3.0.1: + resolution: {integrity: sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==} + + json-schema-traverse@0.4.1: + resolution: {integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==} + + json-stable-stringify-without-jsonify@1.0.1: + resolution: {integrity: sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==} + + keyv@4.5.4: + resolution: {integrity: sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==} + + kleur@4.1.5: + resolution: {integrity: sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==} + engines: {node: '>=6'} + + kolorist@1.8.0: + resolution: {integrity: sha512-Y+60/zizpJ3HRH8DCss+q95yr6145JXZo46OTpFvDZWLfRCE4qChOyk1b26nMaNpfHHgxagk9dXT5OP0Tfe+dQ==} + + levn@0.4.1: + resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==} + engines: {node: '>= 0.8.0'} + + local-pkg@1.0.0: + resolution: {integrity: sha512-bbgPw/wmroJsil/GgL4qjDzs5YLTBMQ99weRsok1XCDccQeehbHA/I1oRvk2NPtr7KGZgT/Y5tPRnAtMqeG2Kg==} + engines: {node: '>=14'} + + locate-character@3.0.0: + resolution: {integrity: sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==} + + locate-path@6.0.0: + resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==} + engines: {node: '>=10'} + + lodash.merge@4.6.2: + resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==} + + lodash@4.17.21: + resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} + + log-symbols@4.1.0: + resolution: {integrity: sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==} + engines: {node: '>=10'} + + longest-streak@2.0.4: + resolution: {integrity: sha512-vM6rUVCVUJJt33bnmHiZEvr7wPT78ztX7rojL+LW51bHtLh6HTjx84LA5W4+oa6aKEJA7jJu5LR6vQRBpA5DVg==} + + magic-string@0.30.17: + resolution: {integrity: sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA==} + + mdast-util-from-markdown@0.8.5: + resolution: {integrity: sha512-2hkTXtYYnr+NubD/g6KGBS/0mFmBcifAsI0yIWRiRo0PjVs6SSOSOdtzbp6kSGnShDN6G5aWZpKQ2lWRy27mWQ==} + + mdast-util-frontmatter@0.2.0: + resolution: {integrity: sha512-FHKL4w4S5fdt1KjJCwB0178WJ0evnyyQr5kXTM3wrOVpytD0hrkvd+AOOjU9Td8onOejCkmZ+HQRT3CZ3coHHQ==} + + mdast-util-to-markdown@0.6.5: + resolution: {integrity: sha512-XeV9sDE7ZlOQvs45C9UKMtfTcctcaj/pGwH8YLbMHoMOXNNCn2LsqVQOqrF1+/NU8lKDAqozme9SCXWyo9oAcQ==} + + mdast-util-to-string@2.0.0: + resolution: {integrity: sha512-AW4DRS3QbBayY/jJmD8437V1Gombjf8RSOUCMFBuo5iHi58AGEgVCKQ+ezHkZZDpAQS75hcBMpLqjpJTjtUL7w==} + + mdn-data@2.12.2: + resolution: {integrity: sha512-IEn+pegP1aManZuckezWCO+XZQDplx1366JoVhTpMpBB1sPey/SbveZQUosKiKiGYjg1wH4pMlNgXbCiYgihQA==} + + merge2@1.4.1: + resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==} + engines: {node: '>= 8'} + + micromark-extension-frontmatter@0.2.2: + resolution: {integrity: sha512-q6nPLFCMTLtfsctAuS0Xh4vaolxSFUWUWR6PZSrXXiRy+SANGllpcqdXFv2z07l0Xz/6Hl40hK0ffNCJPH2n1A==} + + micromark@2.11.4: + resolution: {integrity: sha512-+WoovN/ppKolQOFIAajxi7Lu9kInbPxFuTBVEavFcL8eAfVstoc5MocPmqBeAdBOJV00uaVjegzH4+MA0DN/uA==} + + micromatch@4.0.8: + resolution: {integrity: sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==} + engines: {node: '>=8.6'} + + minimatch@3.1.2: + resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==} + + minimatch@5.1.6: + resolution: {integrity: sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==} + engines: {node: '>=10'} + + minimatch@9.0.5: + resolution: {integrity: sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==} + engines: {node: '>=16 || 14 >=14.17'} + + mlly@1.7.4: + resolution: {integrity: sha512-qmdSIPC4bDJXgZTCR7XosJiNKySV7O215tsPtDN9iEO/7q/76b/ijtgRu/+epFXSJhijtTCCGp3DWS549P3xKw==} + + mocha@10.8.2: + resolution: {integrity: sha512-VZlYo/WE8t1tstuRmqgeyBgCbJc/lEdopaa+axcKzTBJ+UIdlAB9XnmvTCAH4pwR4ElNInaedhEBmZD8iCSVEg==} + engines: {node: '>= 14.0.0'} + hasBin: true + + mrmime@2.0.1: + resolution: {integrity: sha512-Y3wQdFg2Va6etvQ5I82yUhGdsKrcYox6p7FfL1LbK2J4V01F9TGlepTIhnK24t7koZibmg82KGglhA1XK5IsLQ==} + engines: {node: '>=10'} + + ms@2.1.3: + resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} + + nanoid@3.3.11: + resolution: {integrity: sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==} + engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} + hasBin: true + + natural-compare@1.4.0: + resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} + + node-fetch-native@1.6.6: + resolution: {integrity: sha512-8Mc2HhqPdlIfedsuZoc3yioPuzp6b+L5jRCRY1QzuWZh2EGJVQrGppC6V6cF0bLdbW0+O2YpqCA25aF/1lvipQ==} + + node-fetch@2.6.7: + resolution: {integrity: sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==} + engines: {node: 4.x || >=6.0.0} + peerDependencies: + encoding: ^0.1.0 + peerDependenciesMeta: + encoding: + optional: true + + normalize-path@3.0.0: + resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==} + engines: {node: '>=0.10.0'} + + ofetch@1.4.1: + resolution: {integrity: sha512-QZj2DfGplQAr2oj9KzceK9Hwz6Whxazmn85yYeVuS3u9XTMOGMRx0kO95MQ+vLsj/S/NwBDMMLU5hpxvI6Tklw==} + + on-exit-leak-free@2.1.2: + resolution: {integrity: sha512-0eJJY6hXLGf1udHwfNftBqH+g73EU4B504nZeKpz1sYRKafAghwxEJunB2O7rDZkL4PGfsMVnTXZ2EjibbqcsA==} + engines: {node: '>=14.0.0'} + + once@1.4.0: + resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} + + optionator@0.9.4: + resolution: {integrity: sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==} + engines: {node: '>= 0.8.0'} + + p-limit@3.1.0: + resolution: {integrity: sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==} + engines: {node: '>=10'} + + p-locate@5.0.0: + resolution: {integrity: sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==} + engines: {node: '>=10'} + + package-manager-detector@0.2.9: + resolution: {integrity: sha512-+vYvA/Y31l8Zk8dwxHhL3JfTuHPm6tlxM2A3GeQyl7ovYnSp1+mzAxClxaOr0qO1TtPxbQxetI7v5XqKLJZk7Q==} + + parent-module@1.0.1: + resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==} + engines: {node: '>=6'} + + parse-entities@2.0.0: + resolution: {integrity: sha512-kkywGpCcRYhqQIchaWqZ875wzpS/bMKhz5HnN3p7wveJTkTtyAB/AlnS0f8DFSqYW1T82t6yEAkEcB+A1I3MbQ==} + + path-exists@4.0.0: + resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==} + engines: {node: '>=8'} + + path-key@3.1.1: + resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} + engines: {node: '>=8'} + + path-parse@1.0.7: + resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} + + path-type@4.0.0: + resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} + engines: {node: '>=8'} + + pathe@2.0.3: + resolution: {integrity: sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==} + + perfect-debounce@1.0.0: + resolution: {integrity: sha512-xCy9V055GLEqoFaHoC1SoLIaLmWctgCUaBaWxDZ7/Zx4CTyX7cJQLJOok/orfjZAh9kEYpjJa4d0KcJmCbctZA==} + + picocolors@1.1.1: + resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} + + picomatch@2.3.1: + resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} + engines: {node: '>=8.6'} + + picomatch@4.0.2: + resolution: {integrity: sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==} + engines: {node: '>=12'} + + pino-abstract-transport@1.2.0: + resolution: {integrity: sha512-Guhh8EZfPCfH+PMXAb6rKOjGQEoy0xlAIn+irODG5kgfYV+BQ0rGYYWTIel3P5mmyXqkYkPmdIkywsn6QKUR1Q==} + + pino-abstract-transport@2.0.0: + resolution: {integrity: sha512-F63x5tizV6WCh4R6RHyi2Ml+M70DNRXt/+HANowMflpgGFMAym/VKm6G7ZOQRjqN7XbGxK1Lg9t6ZrtzOaivMw==} + + pino-std-serializers@7.0.0: + resolution: {integrity: sha512-e906FRY0+tV27iq4juKzSYPbUj2do2X2JX4EzSca1631EB2QJQUqGbDuERal7LCtOpxl6x3+nvo9NPZcmjkiFA==} + + pino@9.6.0: + resolution: {integrity: sha512-i85pKRCt4qMjZ1+L7sy2Ag4t1atFcdbEt76+7iRJn1g2BvsnRMGu9p8pivl9fs63M2kF/A0OacFZhTub+m/qMg==} + hasBin: true + + pkg-types@1.3.1: + resolution: {integrity: sha512-/Jm5M4RvtBFVkKWRu2BLUTNP8/M2a+UwuAX+ae4770q1qVGtfjG+WTCupoZixokjmHiry8uI+dlY8KXYV5HVVQ==} + + postcss@8.5.3: + resolution: {integrity: sha512-dle9A3yYxlBSrt8Fu+IpjGT8SY8hN0mlaA6GY8t0P5PjIOZemULz/E2Bnm/2dcUOena75OTNkHI76uZBNUUq3A==} + engines: {node: ^10 || ^12 || >=14} + + prelude-ls@1.2.1: + resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} + engines: {node: '>= 0.8.0'} + + prettier@3.5.3: + resolution: {integrity: sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==} + engines: {node: '>=14'} + hasBin: true + + process-warning@4.0.1: + resolution: {integrity: sha512-3c2LzQ3rY9d0hc1emcsHhfT9Jwz0cChib/QN89oME2R451w5fy3f0afAhERFZAwrbDU43wk12d0ORBpDVME50Q==} + + process@0.11.10: + resolution: {integrity: sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==} + engines: {node: '>= 0.6.0'} + + punycode@2.3.1: + resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==} + engines: {node: '>=6'} + + queue-microtask@1.2.3: + resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} + + quick-format-unescaped@4.0.4: + resolution: {integrity: sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg==} + + randombytes@2.1.0: + resolution: {integrity: sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==} + + readable-stream@4.7.0: + resolution: {integrity: sha512-oIGGmcpTLwPga8Bn6/Z75SVaH1z5dUut2ibSyAMVhmUggWpmDn2dapB0n7f8nwaSiRtepAsfJyfXIO5DCVAODg==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + + readdirp@3.6.0: + resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==} + engines: {node: '>=8.10.0'} + + real-require@0.2.0: + resolution: {integrity: sha512-57frrGM/OCTLqLOAh0mhVA9VBMHd+9U7Zb2THMGdBUoZVOtGbJzjxsYGDJ3A9AYYCP4hn6y1TVbaOfzWtm5GFg==} + engines: {node: '>= 12.13.0'} + + regexp-tree@0.1.27: + resolution: {integrity: sha512-iETxpjK6YoRWJG5o6hXLwvjYAoW+FEZn9os0PD/b6AP6xQwsa/Y7lCVgIixBbUPMfhu+i2LtdeAqVTgGlQarfA==} + hasBin: true + + remark-frontmatter@3.0.0: + resolution: {integrity: sha512-mSuDd3svCHs+2PyO29h7iijIZx4plX0fheacJcAoYAASfgzgVIcXGYSq9GFyYocFLftQs8IOmmkgtOovs6d4oA==} + + remark-parse@9.0.0: + resolution: {integrity: sha512-geKatMwSzEXKHuzBNU1z676sGcDcFoChMK38TgdHJNAYfFtsfHDQG7MoJAjs6sgYMqyLduCYWDIWZIxiPeafEw==} + + remark-stringify@9.0.1: + resolution: {integrity: sha512-mWmNg3ZtESvZS8fv5PTvaPckdL4iNlCHTt8/e/8oN08nArHRHjNZMKzA/YW3+p7/lYqIw4nx1XsjCBo/AxNChg==} + + repeat-string@1.6.1: + resolution: {integrity: sha512-PV0dzCYDNfRi1jCDbJzpW7jNNDRuCOG/jI5ctQcGKt/clZD+YcPS3yIlWuTJMmESC8aevCFmWJy5wjAFgNqN6w==} + engines: {node: '>=0.10'} + + require-directory@2.1.1: + resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==} + engines: {node: '>=0.10.0'} + + resolve-from@4.0.0: + resolution: {integrity: sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==} + engines: {node: '>=4'} + + resolve-pkg-maps@1.0.0: + resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==} + + resolve@1.22.10: + resolution: {integrity: sha512-NPRy+/ncIMeDlTAsuqwKIiferiawhefFJtkNSW0qZJEqMEb+qBt/77B/jGeeek+F0uOeN05CDa6HXbbIgtVX4w==} + engines: {node: '>= 0.4'} + hasBin: true + + reusify@1.1.0: + resolution: {integrity: sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==} + engines: {iojs: '>=1.0.0', node: '>=0.10.0'} + + rollup@4.41.1: + resolution: {integrity: sha512-cPmwD3FnFv8rKMBc1MxWCwVQFxwf1JEmSX3iQXrRVVG15zerAIXRjMFVWnd5Q5QvgKF7Aj+5ykXFhUl+QGnyOw==} + engines: {node: '>=18.0.0', npm: '>=8.0.0'} + hasBin: true + + run-parallel@1.2.0: + resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} + + safe-buffer@5.2.1: + resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} + + safe-regex@2.1.1: + resolution: {integrity: sha512-rx+x8AMzKb5Q5lQ95Zoi6ZbJqwCLkqi3XuJXp5P3rT8OEc6sZCJG5AE5dU3lsgRr/F4Bs31jSlVN+j5KrsGu9A==} + + safe-stable-stringify@2.5.0: + resolution: {integrity: sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA==} + engines: {node: '>=10'} + + semver@7.7.1: + resolution: {integrity: sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==} + engines: {node: '>=10'} + hasBin: true + + serialize-javascript@6.0.2: + resolution: {integrity: sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==} + + shebang-command@2.0.0: + resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} + engines: {node: '>=8'} + + shebang-regex@3.0.0: + resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} + engines: {node: '>=8'} + + shellwords@0.1.1: + resolution: {integrity: sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==} + + sirv@3.0.1: + resolution: {integrity: sha512-FoqMu0NCGBLCcAkS1qA+XJIQTR6/JHfQXl+uGteNCQ76T91DMUjPa9xfmeqMY3z80nLSg9yQmNjK0Px6RWsH/A==} + engines: {node: '>=18'} + + sisteransi@1.0.5: + resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==} + + slash@3.0.0: + resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} + engines: {node: '>=8'} + + smob@1.5.0: + resolution: {integrity: sha512-g6T+p7QO8npa+/hNx9ohv1E5pVCmWrVCUzUXJyLdMmftX6ER0oiWY/w9knEonLpnOp6b6FenKnMfR8gqwWdwig==} + + sonic-boom@4.2.0: + resolution: {integrity: sha512-INb7TM37/mAcsGmc9hyyI6+QR3rR1zVRu36B0NeGXKnOOLiZOfER5SA+N7X7k3yUYRzLWafduTDvJAfDswwEww==} + + source-map-js@1.2.1: + resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==} + engines: {node: '>=0.10.0'} + + source-map-support@0.5.21: + resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==} + + source-map@0.6.1: + resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} + engines: {node: '>=0.10.0'} + + split2@4.2.0: + resolution: {integrity: sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==} + engines: {node: '>= 10.x'} + + stacktrace-parser@0.1.11: + resolution: {integrity: sha512-WjlahMgHmCJpqzU8bIBy4qtsZdU9lRlcZE3Lvyej6t4tuOuv1vk57OW3MBrj6hXBFx/nNoC9MPMTcr5YA7NQbg==} + engines: {node: '>=6'} + + string-width@4.2.3: + resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} + engines: {node: '>=8'} + + string_decoder@1.3.0: + resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==} + + strip-ansi@6.0.1: + resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} + engines: {node: '>=8'} + + strip-json-comments@3.1.1: + resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==} + engines: {node: '>=8'} + + supports-color@7.2.0: + resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} + engines: {node: '>=8'} + + supports-color@8.1.1: + resolution: {integrity: sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==} + engines: {node: '>=10'} + + supports-preserve-symlinks-flag@1.0.0: + resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==} + engines: {node: '>= 0.4'} + + svelte@5.28.2: + resolution: {integrity: sha512-FbWBxgWOpQfhKvoGJv/TFwzqb4EhJbwCD17dB0tEpQiw1XyUEKZJtgm4nA4xq3LLsMo7hu5UY/BOFmroAxKTMg==} + engines: {node: '>=18'} + + terser@5.39.0: + resolution: {integrity: sha512-LBAhFyLho16harJoWMg/nZsQYgTrg5jXOn2nCYjRUcZZEdE3qa2zb8QEDRUGVZBW4rlazf2fxkg8tztybTaqWw==} + engines: {node: '>=10'} + hasBin: true + + thread-stream@3.1.0: + resolution: {integrity: sha512-OqyPZ9u96VohAyMfJykzmivOrY2wfMSf3C5TtFJVgN+Hm6aj+voFhlK+kZEIv2FBh1X6Xp3DlnCOfEQ3B2J86A==} + + tinyexec@0.3.2: + resolution: {integrity: sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==} + + tinyglobby@0.2.13: + resolution: {integrity: sha512-mEwzpUgrLySlveBwEVDMKk5B57bhLPYovRfPAXD5gA/98Opn0rCDj3GtLwFvCvH5RK9uPCExUROW5NjDwvqkxw==} + engines: {node: '>=12.0.0'} + + to-regex-range@5.0.1: + resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} + engines: {node: '>=8.0'} + + totalist@3.0.1: + resolution: {integrity: sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==} + engines: {node: '>=6'} + + tr46@0.0.3: + resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} + + trough@1.0.5: + resolution: {integrity: sha512-rvuRbTarPXmMb79SmzEp8aqXNKcK+y0XaB298IXueQ8I2PsrATcPBCSPyK/dDNa2iWOhKlfNnOjdAOTBU/nkFA==} + + ts-api-utils@2.1.0: + resolution: {integrity: sha512-CUgTZL1irw8u29bzrOD/nH85jqyc74D6SshFgujOIA7osm2Rz7dYH77agkx7H4FBNxDq7Cjf+IjaX/8zwFW+ZQ==} + engines: {node: '>=18.12'} + peerDependencies: + typescript: '>=4.8.4' + + tslib@2.8.1: + resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==} + + tsx@4.19.2: + resolution: {integrity: sha512-pOUl6Vo2LUq/bSa8S5q7b91cgNSjctn9ugq/+Mvow99qW6x/UZYwzxy/3NmqoT66eHYfCVvFvACC58UBPFf28g==} + engines: {node: '>=18.0.0'} + hasBin: true + + type-check@0.4.0: + resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} + engines: {node: '>= 0.8.0'} + + type-fest@0.7.1: + resolution: {integrity: sha512-Ne2YiiGN8bmrmJJEuTWTLJR32nh/JdL1+PSicowtNb0WFpn59GK8/lfD61bVtzguz7b3PBt74nxpv/Pw5po5Rg==} + engines: {node: '>=8'} + + typescript-eslint@8.34.0: + resolution: {integrity: sha512-MRpfN7uYjTrTGigFCt8sRyNqJFhjN0WwZecldaqhWm+wy0gaRt8Edb/3cuUy0zdq2opJWT6iXINKAtewnDOltQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 + typescript: '>=4.8.4 <5.9.0' + + typescript@5.8.3: + resolution: {integrity: sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==} + engines: {node: '>=14.17'} + hasBin: true + + ufo@1.5.4: + resolution: {integrity: sha512-UsUk3byDzKd04EyoZ7U4DOlxQaD14JUKQl6/P7wiX4FNvUfm3XL246n9W5AmqwW5RSFJ27NAuM0iLscAOYUiGQ==} + + unconfig@7.0.0: + resolution: {integrity: sha512-G5CJSoG6ZTxgzCJblEfgpdRK2tos9+UdD2WtecDUVfImzQ0hFjwpH5RVvGMhP4pRpC9ML7NrC4qBsBl0Ttj35A==} + + unified@9.2.2: + resolution: {integrity: sha512-Sg7j110mtefBD+qunSLO1lqOEKdrwBFBrR6Qd8f4uwkhWNlbkaqwHse6e7QvD3AP/MNoJdEDLaf8OxYyoWgorQ==} + + unist-util-stringify-position@2.0.3: + resolution: {integrity: sha512-3faScn5I+hy9VleOq/qNbAd6pAx7iH5jYBMS9I1HgQVijz/4mv5Bvw5iw1sC/90CODiKo81G/ps8AJrISn687g==} + + unocss@66.0.0: + resolution: {integrity: sha512-SHstiv1s7zGPSjzOsADzlwRhQM+6817+OqQE3Fv+N/nn2QLNx1bi3WXybFfz5tWkzBtyTZlwdPmeecsIs1yOCA==} + engines: {node: '>=14'} + peerDependencies: + '@unocss/webpack': 66.0.0 + vite: ^2.9.0 || ^3.0.0-0 || ^4.0.0 || ^5.0.0-0 || ^6.0.0-0 + peerDependenciesMeta: + '@unocss/webpack': + optional: true + vite: + optional: true + + unplugin-utils@0.2.4: + resolution: {integrity: sha512-8U/MtpkPkkk3Atewj1+RcKIjb5WBimZ/WSLhhR3w6SsIj8XJuKTacSP8g+2JhfSGw0Cb125Y+2zA/IzJZDVbhA==} + engines: {node: '>=18.12.0'} + + uri-js@4.4.1: + resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} + + vfile-message@2.0.4: + resolution: {integrity: sha512-DjssxRGkMvifUOJre00juHoP9DPWuzjxKuMDrhNbk2TdaYYBNMStsNhEOt3idrtI12VQYM/1+iM0KOzXi4pxwQ==} + + vfile@4.2.1: + resolution: {integrity: sha512-O6AE4OskCG5S1emQ/4gl8zK586RqA3srz3nfK/Viy0UPToBc5Trp9BVFb1u0CjsKrAWwnpr4ifM/KBXPWwJbCA==} + + vite@6.3.4: + resolution: {integrity: sha512-BiReIiMS2fyFqbqNT/Qqt4CVITDU9M9vE+DKcVAsB+ZV0wvTKd+3hMbkpxz1b+NmEDMegpVbisKiAZOnvO92Sw==} + engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0} + hasBin: true + peerDependencies: + '@types/node': ^18.0.0 || ^20.0.0 || >=22.0.0 + jiti: '>=1.21.0' + less: '*' + lightningcss: ^1.21.0 + sass: '*' + sass-embedded: '*' + stylus: '*' + sugarss: '*' + terser: ^5.16.0 + tsx: ^4.8.1 + yaml: ^2.4.2 + peerDependenciesMeta: + '@types/node': + optional: true + jiti: + optional: true + less: + optional: true + lightningcss: + optional: true + sass: + optional: true + sass-embedded: + optional: true + stylus: + optional: true + sugarss: + optional: true + terser: + optional: true + tsx: + optional: true + yaml: + optional: true + + vitefu@1.0.6: + resolution: {integrity: sha512-+Rex1GlappUyNN6UfwbVZne/9cYC4+R2XDk9xkNXBKMw6HQagdX9PgZ8V2v1WUSK1wfBLp7qbI1+XSNIlB1xmA==} + peerDependencies: + vite: ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 + peerDependenciesMeta: + vite: + optional: true + + vue-flow-layout@0.1.1: + resolution: {integrity: sha512-JdgRRUVrN0Y2GosA0M68DEbKlXMqJ7FQgsK8CjQD2vxvNSqAU6PZEpi4cfcTVtfM2GVOMjHo7GKKLbXxOBqDqA==} + peerDependencies: + vue: ^3.4.37 + + vue@3.5.13: + resolution: {integrity: sha512-wmeiSMxkZCSc+PM2w2VRsOYAZC8GdipNFRTsLSfodVqI9mbejKeXEGr8SckuLnrQPGe3oJN5c3K0vpoU9q/wCQ==} + peerDependencies: + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + + webidl-conversions@3.0.1: + resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} + + whatwg-url@5.0.0: + resolution: {integrity: sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==} + + which@2.0.2: + resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} + engines: {node: '>= 8'} + hasBin: true + + word-wrap@1.2.5: + resolution: {integrity: sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==} + engines: {node: '>=0.10.0'} + + workerpool@6.5.1: + resolution: {integrity: sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA==} + + wrap-ansi@7.0.0: + resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==} + engines: {node: '>=10'} + + wrappy@1.0.2: + resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} + + y18n@5.0.8: + resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==} + engines: {node: '>=10'} + + yargs-parser@20.2.9: + resolution: {integrity: sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==} + engines: {node: '>=10'} + + yargs-parser@21.1.1: + resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==} + engines: {node: '>=12'} + + yargs-unparser@2.0.0: + resolution: {integrity: sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==} + engines: {node: '>=10'} + + yargs@16.2.0: + resolution: {integrity: sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==} + engines: {node: '>=10'} + + yargs@17.7.2: + resolution: {integrity: sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==} + engines: {node: '>=12'} + + yocto-queue@0.1.0: + resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} + engines: {node: '>=10'} + + zimmerframe@1.1.2: + resolution: {integrity: sha512-rAbqEGa8ovJy4pyBxZM70hg4pE6gDgaQ0Sl9M3enG3I0d6H4XSAM3GeNGLKnsBpuijUow064sf7ww1nutC5/3w==} + + zod-validation-error@1.5.0: + resolution: {integrity: sha512-/7eFkAI4qV0tcxMBB/3+d2c1P6jzzZYdYSlBuAklzMuCrJu5bzJfHS0yVAS87dRHVlhftd6RFJDIvv03JgkSbw==} + engines: {node: '>=16.0.0'} + peerDependencies: + zod: ^3.18.0 + + zod@3.24.2: + resolution: {integrity: sha512-lY7CDW43ECgW9u1TcT3IoXHflywfVqDYze4waEz812jR/bZ8FHDsl7pFQoSZTz5N+2NqRXs8GBwnAwo3ZNxqhQ==} + + zwitch@1.0.5: + resolution: {integrity: sha512-V50KMwwzqJV0NpZIZFwfOD5/lyny3WlSzRiXgA0G7VUnRlqttta1L6UQIHzd6EuBY/cHGfwTIck7w1yH6Q5zUw==} + +snapshots: + + '@ampproject/remapping@2.3.0': + dependencies: + '@jridgewell/gen-mapping': 0.3.8 + '@jridgewell/trace-mapping': 0.3.25 + + '@antfu/install-pkg@1.0.0': + dependencies: + package-manager-detector: 0.2.9 + tinyexec: 0.3.2 + + '@antfu/utils@8.1.1': {} + + '@babel/helper-string-parser@7.27.1': {} + + '@babel/helper-validator-identifier@7.27.1': {} + + '@babel/parser@7.27.1': + dependencies: + '@babel/types': 7.27.1 + + '@babel/types@7.27.1': + dependencies: + '@babel/helper-string-parser': 7.27.1 + '@babel/helper-validator-identifier': 7.27.1 + + '@chainsafe/abort-controller@3.0.1': + dependencies: + event-target-shim: 5.0.1 + + '@clack/core@0.3.5': + dependencies: + picocolors: 1.1.1 + sisteransi: 1.0.5 + + '@clack/prompts@0.7.0': + dependencies: + '@clack/core': 0.3.5 + picocolors: 1.1.1 + sisteransi: 1.0.5 + + '@covector/apply@0.10.0(mocha@10.8.2)': + dependencies: + '@covector/files': 0.8.0 + effection: 2.0.8(mocha@10.8.2) + semver: 7.7.1 + transitivePeerDependencies: + - encoding + - mocha + + '@covector/assemble@0.12.0': + dependencies: + '@covector/command': 0.8.0 + '@covector/files': 0.8.0 + effection: 2.0.8(mocha@10.8.2) + js-yaml: 4.1.0 lodash: 4.17.21 - mute-stream: 0.0.8 - ora: 5.4.1 - run-async: 2.4.1 - rxjs: 7.8.1 + remark-frontmatter: 3.0.0 + remark-parse: 9.0.0 + remark-stringify: 9.0.1 + unified: 9.2.2 + transitivePeerDependencies: + - encoding + - supports-color + + '@covector/changelog@0.12.0': + dependencies: + '@covector/files': 0.8.0 + effection: 2.0.8(mocha@10.8.2) + lodash: 4.17.21 + remark-parse: 9.0.0 + remark-stringify: 9.0.1 + unified: 9.2.2 + transitivePeerDependencies: + - encoding + - supports-color + + '@covector/command@0.8.0': + dependencies: + '@effection/process': 2.1.4 + effection: 2.0.8(mocha@10.8.2) + transitivePeerDependencies: + - encoding + + '@covector/files@0.8.0': + dependencies: + '@covector/toml': 0.2.0 + globby: 11.1.0 + js-yaml: 4.1.0 + semver: 7.7.1 + zod: 3.24.2 + zod-validation-error: 1.5.0(zod@3.24.2) + + '@covector/toml@0.2.0': {} + + '@effection/channel@2.0.6': + dependencies: + '@effection/core': 2.2.3 + '@effection/events': 2.0.6 + '@effection/stream': 2.0.6 + + '@effection/core@2.2.3': + dependencies: + '@chainsafe/abort-controller': 3.0.1 + + '@effection/events@2.0.6': + dependencies: + '@effection/core': 2.2.3 + '@effection/stream': 2.0.6 + + '@effection/fetch@2.0.7(mocha@10.8.2)': + dependencies: + '@effection/core': 2.2.3 + '@effection/mocha': 2.0.8(mocha@10.8.2) + cross-fetch: 3.1.5 + transitivePeerDependencies: + - encoding + - mocha + + '@effection/main@2.1.2': + dependencies: + '@effection/core': 2.2.3 + chalk: 4.1.2 + stacktrace-parser: 0.1.11 + + '@effection/mocha@2.0.8(mocha@10.8.2)': + dependencies: + effection: 2.0.8(mocha@10.8.2) + mocha: 10.8.2 + transitivePeerDependencies: + - encoding + + '@effection/process@2.1.4': + dependencies: + cross-spawn: 7.0.6 + ctrlc-windows: 2.2.0 + effection: 2.0.8(mocha@10.8.2) + shellwords: 0.1.1 + transitivePeerDependencies: + - encoding + + '@effection/stream@2.0.6': + dependencies: + '@effection/core': 2.2.3 + '@effection/subscription': 2.0.6 + + '@effection/subscription@2.0.6': + dependencies: + '@effection/core': 2.2.3 + + '@esbuild/aix-ppc64@0.25.3': + optional: true + + '@esbuild/android-arm64@0.25.3': + optional: true + + '@esbuild/android-arm@0.25.3': + optional: true + + '@esbuild/android-x64@0.25.3': + optional: true + + '@esbuild/darwin-arm64@0.25.3': + optional: true + + '@esbuild/darwin-x64@0.25.3': + optional: true + + '@esbuild/freebsd-arm64@0.25.3': + optional: true + + '@esbuild/freebsd-x64@0.25.3': + optional: true + + '@esbuild/linux-arm64@0.25.3': + optional: true + + '@esbuild/linux-arm@0.25.3': + optional: true + + '@esbuild/linux-ia32@0.25.3': + optional: true + + '@esbuild/linux-loong64@0.25.3': + optional: true + + '@esbuild/linux-mips64el@0.25.3': + optional: true + + '@esbuild/linux-ppc64@0.25.3': + optional: true + + '@esbuild/linux-riscv64@0.25.3': + optional: true + + '@esbuild/linux-s390x@0.25.3': + optional: true + + '@esbuild/linux-x64@0.25.3': + optional: true + + '@esbuild/netbsd-arm64@0.25.3': + optional: true + + '@esbuild/netbsd-x64@0.25.3': + optional: true + + '@esbuild/openbsd-arm64@0.25.3': + optional: true + + '@esbuild/openbsd-x64@0.25.3': + optional: true + + '@esbuild/sunos-x64@0.25.3': + optional: true + + '@esbuild/win32-arm64@0.25.3': + optional: true + + '@esbuild/win32-ia32@0.25.3': + optional: true + + '@esbuild/win32-x64@0.25.3': + optional: true + + '@eslint-community/eslint-utils@4.7.0(eslint@9.28.0(jiti@2.4.2))': + dependencies: + eslint: 9.28.0(jiti@2.4.2) + eslint-visitor-keys: 3.4.3 + + '@eslint-community/regexpp@4.12.1': {} + + '@eslint/config-array@0.20.0': + dependencies: + '@eslint/object-schema': 2.1.6 + debug: 4.4.0(supports-color@8.1.1) + minimatch: 3.1.2 + transitivePeerDependencies: + - supports-color + + '@eslint/config-helpers@0.2.1': {} + + '@eslint/core@0.14.0': + dependencies: + '@types/json-schema': 7.0.15 + + '@eslint/eslintrc@3.3.1': + dependencies: + ajv: 6.12.6 + debug: 4.4.0(supports-color@8.1.1) + espree: 10.3.0 + globals: 14.0.0 + ignore: 5.3.2 + import-fresh: 3.3.1 + js-yaml: 4.1.0 + minimatch: 3.1.2 + strip-json-comments: 3.1.1 + transitivePeerDependencies: + - supports-color + + '@eslint/js@9.28.0': {} + + '@eslint/object-schema@2.1.6': {} + + '@eslint/plugin-kit@0.3.1': + dependencies: + '@eslint/core': 0.14.0 + levn: 0.4.1 + + '@humanfs/core@0.19.1': {} + + '@humanfs/node@0.16.6': + dependencies: + '@humanfs/core': 0.19.1 + '@humanwhocodes/retry': 0.3.1 + + '@humanwhocodes/module-importer@1.0.1': {} + + '@humanwhocodes/retry@0.3.1': {} + + '@humanwhocodes/retry@0.4.2': {} + + '@iconify-json/codicon@1.2.15': + dependencies: + '@iconify/types': 2.0.0 + + '@iconify-json/ph@1.2.2': + dependencies: + '@iconify/types': 2.0.0 + + '@iconify/types@2.0.0': {} + + '@iconify/utils@2.3.0': + dependencies: + '@antfu/install-pkg': 1.0.0 + '@antfu/utils': 8.1.1 + '@iconify/types': 2.0.0 + debug: 4.4.0(supports-color@8.1.1) + globals: 15.15.0 + kolorist: 1.8.0 + local-pkg: 1.0.0 + mlly: 1.7.4 + transitivePeerDependencies: + - supports-color + + '@jridgewell/gen-mapping@0.3.8': + dependencies: + '@jridgewell/set-array': 1.2.1 + '@jridgewell/sourcemap-codec': 1.5.0 + '@jridgewell/trace-mapping': 0.3.25 + + '@jridgewell/resolve-uri@3.1.2': {} + + '@jridgewell/set-array@1.2.1': {} + + '@jridgewell/source-map@0.3.6': + dependencies: + '@jridgewell/gen-mapping': 0.3.8 + '@jridgewell/trace-mapping': 0.3.25 + + '@jridgewell/sourcemap-codec@1.5.0': {} + + '@jridgewell/trace-mapping@0.3.25': + dependencies: + '@jridgewell/resolve-uri': 3.1.2 + '@jridgewell/sourcemap-codec': 1.5.0 + + '@nodelib/fs.scandir@2.1.5': + dependencies: + '@nodelib/fs.stat': 2.0.5 + run-parallel: 1.2.0 + + '@nodelib/fs.stat@2.0.5': {} + + '@nodelib/fs.walk@1.2.8': + dependencies: + '@nodelib/fs.scandir': 2.1.5 + fastq: 1.19.1 + + '@polka/url@1.0.0-next.28': {} + + '@rollup/plugin-node-resolve@16.0.1(rollup@4.41.1)': + dependencies: + '@rollup/pluginutils': 5.1.4(rollup@4.41.1) + '@types/resolve': 1.20.2 + deepmerge: 4.3.1 + is-module: 1.0.0 + resolve: 1.22.10 + optionalDependencies: + rollup: 4.41.1 + + '@rollup/plugin-terser@0.4.4(rollup@4.41.1)': + dependencies: + serialize-javascript: 6.0.2 + smob: 1.5.0 + terser: 5.39.0 + optionalDependencies: + rollup: 4.41.1 + + '@rollup/plugin-typescript@12.1.2(rollup@4.41.1)(tslib@2.8.1)(typescript@5.8.3)': + dependencies: + '@rollup/pluginutils': 5.1.4(rollup@4.41.1) + resolve: 1.22.10 + typescript: 5.8.3 + optionalDependencies: + rollup: 4.41.1 + tslib: 2.8.1 + + '@rollup/pluginutils@5.1.4(rollup@4.41.1)': + dependencies: + '@types/estree': 1.0.7 + estree-walker: 2.0.2 + picomatch: 4.0.2 + optionalDependencies: + rollup: 4.41.1 + + '@rollup/rollup-android-arm-eabi@4.41.1': + optional: true + + '@rollup/rollup-android-arm64@4.41.1': + optional: true + + '@rollup/rollup-darwin-arm64@4.41.1': + optional: true + + '@rollup/rollup-darwin-x64@4.41.1': + optional: true + + '@rollup/rollup-freebsd-arm64@4.41.1': + optional: true + + '@rollup/rollup-freebsd-x64@4.41.1': + optional: true + + '@rollup/rollup-linux-arm-gnueabihf@4.41.1': + optional: true + + '@rollup/rollup-linux-arm-musleabihf@4.41.1': + optional: true + + '@rollup/rollup-linux-arm64-gnu@4.41.1': + optional: true + + '@rollup/rollup-linux-arm64-musl@4.41.1': + optional: true + + '@rollup/rollup-linux-loongarch64-gnu@4.41.1': + optional: true + + '@rollup/rollup-linux-powerpc64le-gnu@4.41.1': + optional: true + + '@rollup/rollup-linux-riscv64-gnu@4.41.1': + optional: true + + '@rollup/rollup-linux-riscv64-musl@4.41.1': + optional: true + + '@rollup/rollup-linux-s390x-gnu@4.41.1': + optional: true + + '@rollup/rollup-linux-x64-gnu@4.41.1': + optional: true + + '@rollup/rollup-linux-x64-musl@4.41.1': + optional: true + + '@rollup/rollup-win32-arm64-msvc@4.41.1': + optional: true + + '@rollup/rollup-win32-ia32-msvc@4.41.1': + optional: true + + '@rollup/rollup-win32-x64-msvc@4.41.1': + optional: true + + '@sveltejs/acorn-typescript@1.0.5(acorn@8.14.0)': + dependencies: + acorn: 8.14.0 + + '@sveltejs/vite-plugin-svelte-inspector@4.0.1(@sveltejs/vite-plugin-svelte@5.0.3(svelte@5.28.2)(vite@6.3.4(jiti@2.4.2)(terser@5.39.0)(tsx@4.19.2)))(svelte@5.28.2)(vite@6.3.4(jiti@2.4.2)(terser@5.39.0)(tsx@4.19.2))': + dependencies: + '@sveltejs/vite-plugin-svelte': 5.0.3(svelte@5.28.2)(vite@6.3.4(jiti@2.4.2)(terser@5.39.0)(tsx@4.19.2)) + debug: 4.4.0(supports-color@8.1.1) + svelte: 5.28.2 + vite: 6.3.4(jiti@2.4.2)(terser@5.39.0)(tsx@4.19.2) + transitivePeerDependencies: + - supports-color + + '@sveltejs/vite-plugin-svelte@5.0.3(svelte@5.28.2)(vite@6.3.4(jiti@2.4.2)(terser@5.39.0)(tsx@4.19.2))': + dependencies: + '@sveltejs/vite-plugin-svelte-inspector': 4.0.1(@sveltejs/vite-plugin-svelte@5.0.3(svelte@5.28.2)(vite@6.3.4(jiti@2.4.2)(terser@5.39.0)(tsx@4.19.2)))(svelte@5.28.2)(vite@6.3.4(jiti@2.4.2)(terser@5.39.0)(tsx@4.19.2)) + debug: 4.4.0(supports-color@8.1.1) + deepmerge: 4.3.1 + kleur: 4.1.5 + magic-string: 0.30.17 + svelte: 5.28.2 + vite: 6.3.4(jiti@2.4.2)(terser@5.39.0)(tsx@4.19.2) + vitefu: 1.0.6(vite@6.3.4(jiti@2.4.2)(terser@5.39.0)(tsx@4.19.2)) + transitivePeerDependencies: + - supports-color + + '@tauri-apps/api@2.5.0': {} + + '@tauri-apps/cli-darwin-arm64@2.5.0': + optional: true + + '@tauri-apps/cli-darwin-x64@2.5.0': + optional: true + + '@tauri-apps/cli-linux-arm-gnueabihf@2.5.0': + optional: true + + '@tauri-apps/cli-linux-arm64-gnu@2.5.0': + optional: true + + '@tauri-apps/cli-linux-arm64-musl@2.5.0': + optional: true + + '@tauri-apps/cli-linux-riscv64-gnu@2.5.0': + optional: true + + '@tauri-apps/cli-linux-x64-gnu@2.5.0': + optional: true + + '@tauri-apps/cli-linux-x64-musl@2.5.0': + optional: true + + '@tauri-apps/cli-win32-arm64-msvc@2.5.0': + optional: true + + '@tauri-apps/cli-win32-ia32-msvc@2.5.0': + optional: true + + '@tauri-apps/cli-win32-x64-msvc@2.5.0': + optional: true + + '@tauri-apps/cli@2.5.0': + optionalDependencies: + '@tauri-apps/cli-darwin-arm64': 2.5.0 + '@tauri-apps/cli-darwin-x64': 2.5.0 + '@tauri-apps/cli-linux-arm-gnueabihf': 2.5.0 + '@tauri-apps/cli-linux-arm64-gnu': 2.5.0 + '@tauri-apps/cli-linux-arm64-musl': 2.5.0 + '@tauri-apps/cli-linux-riscv64-gnu': 2.5.0 + '@tauri-apps/cli-linux-x64-gnu': 2.5.0 + '@tauri-apps/cli-linux-x64-musl': 2.5.0 + '@tauri-apps/cli-win32-arm64-msvc': 2.5.0 + '@tauri-apps/cli-win32-ia32-msvc': 2.5.0 + '@tauri-apps/cli-win32-x64-msvc': 2.5.0 + + '@types/estree@1.0.7': {} + + '@types/json-schema@7.0.15': {} + + '@types/mdast@3.0.15': + dependencies: + '@types/unist': 2.0.11 + + '@types/resolve@1.20.2': {} + + '@types/unist@2.0.11': {} + + '@typescript-eslint/eslint-plugin@8.34.0(@typescript-eslint/parser@8.34.0(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3))(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3)': + dependencies: + '@eslint-community/regexpp': 4.12.1 + '@typescript-eslint/parser': 8.34.0(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3) + '@typescript-eslint/scope-manager': 8.34.0 + '@typescript-eslint/type-utils': 8.34.0(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3) + '@typescript-eslint/utils': 8.34.0(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3) + '@typescript-eslint/visitor-keys': 8.34.0 + eslint: 9.28.0(jiti@2.4.2) + graphemer: 1.4.0 + ignore: 7.0.4 + natural-compare: 1.4.0 + ts-api-utils: 2.1.0(typescript@5.8.3) + typescript: 5.8.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/parser@8.34.0(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3)': + dependencies: + '@typescript-eslint/scope-manager': 8.34.0 + '@typescript-eslint/types': 8.34.0 + '@typescript-eslint/typescript-estree': 8.34.0(typescript@5.8.3) + '@typescript-eslint/visitor-keys': 8.34.0 + debug: 4.4.0(supports-color@8.1.1) + eslint: 9.28.0(jiti@2.4.2) + typescript: 5.8.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/project-service@8.34.0(typescript@5.8.3)': + dependencies: + '@typescript-eslint/tsconfig-utils': 8.34.0(typescript@5.8.3) + '@typescript-eslint/types': 8.34.0 + debug: 4.4.0(supports-color@8.1.1) + typescript: 5.8.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/scope-manager@8.34.0': + dependencies: + '@typescript-eslint/types': 8.34.0 + '@typescript-eslint/visitor-keys': 8.34.0 + + '@typescript-eslint/tsconfig-utils@8.34.0(typescript@5.8.3)': + dependencies: + typescript: 5.8.3 + + '@typescript-eslint/type-utils@8.34.0(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3)': + dependencies: + '@typescript-eslint/typescript-estree': 8.34.0(typescript@5.8.3) + '@typescript-eslint/utils': 8.34.0(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3) + debug: 4.4.0(supports-color@8.1.1) + eslint: 9.28.0(jiti@2.4.2) + ts-api-utils: 2.1.0(typescript@5.8.3) + typescript: 5.8.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/types@8.34.0': {} + + '@typescript-eslint/typescript-estree@8.34.0(typescript@5.8.3)': + dependencies: + '@typescript-eslint/project-service': 8.34.0(typescript@5.8.3) + '@typescript-eslint/tsconfig-utils': 8.34.0(typescript@5.8.3) + '@typescript-eslint/types': 8.34.0 + '@typescript-eslint/visitor-keys': 8.34.0 + debug: 4.4.0(supports-color@8.1.1) + fast-glob: 3.3.3 + is-glob: 4.0.3 + minimatch: 9.0.5 + semver: 7.7.1 + ts-api-utils: 2.1.0(typescript@5.8.3) + typescript: 5.8.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/utils@8.34.0(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3)': + dependencies: + '@eslint-community/eslint-utils': 4.7.0(eslint@9.28.0(jiti@2.4.2)) + '@typescript-eslint/scope-manager': 8.34.0 + '@typescript-eslint/types': 8.34.0 + '@typescript-eslint/typescript-estree': 8.34.0(typescript@5.8.3) + eslint: 9.28.0(jiti@2.4.2) + typescript: 5.8.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/visitor-keys@8.34.0': + dependencies: + '@typescript-eslint/types': 8.34.0 + eslint-visitor-keys: 4.2.0 + + '@unocss/astro@66.0.0(vite@6.3.4(jiti@2.4.2)(terser@5.39.0)(tsx@4.19.2))(vue@3.5.13(typescript@5.8.3))': + dependencies: + '@unocss/core': 66.0.0 + '@unocss/reset': 66.0.0 + '@unocss/vite': 66.0.0(vite@6.3.4(jiti@2.4.2)(terser@5.39.0)(tsx@4.19.2))(vue@3.5.13(typescript@5.8.3)) + optionalDependencies: + vite: 6.3.4(jiti@2.4.2)(terser@5.39.0)(tsx@4.19.2) + transitivePeerDependencies: + - vue + + '@unocss/cli@66.0.0': + dependencies: + '@ampproject/remapping': 2.3.0 + '@unocss/config': 66.0.0 + '@unocss/core': 66.0.0 + '@unocss/preset-uno': 66.0.0 + cac: 6.7.14 + chokidar: 3.6.0 + colorette: 2.0.20 + consola: 3.4.0 + magic-string: 0.30.17 + pathe: 2.0.3 + perfect-debounce: 1.0.0 + tinyglobby: 0.2.13 + unplugin-utils: 0.2.4 + + '@unocss/config@66.0.0': + dependencies: + '@unocss/core': 66.0.0 + unconfig: 7.0.0 + + '@unocss/core@66.0.0': {} + + '@unocss/extractor-arbitrary-variants@66.0.0': + dependencies: + '@unocss/core': 66.0.0 + + '@unocss/extractor-svelte@66.0.0': {} + + '@unocss/inspector@66.0.0(vue@3.5.13(typescript@5.8.3))': + dependencies: + '@unocss/core': 66.0.0 + '@unocss/rule-utils': 66.0.0 + colorette: 2.0.20 + gzip-size: 6.0.0 + sirv: 3.0.1 + vue-flow-layout: 0.1.1(vue@3.5.13(typescript@5.8.3)) + transitivePeerDependencies: + - vue + + '@unocss/postcss@66.0.0(postcss@8.5.3)': + dependencies: + '@unocss/config': 66.0.0 + '@unocss/core': 66.0.0 + '@unocss/rule-utils': 66.0.0 + css-tree: 3.1.0 + postcss: 8.5.3 + tinyglobby: 0.2.13 + + '@unocss/preset-attributify@66.0.0': + dependencies: + '@unocss/core': 66.0.0 + + '@unocss/preset-icons@66.0.0': + dependencies: + '@iconify/utils': 2.3.0 + '@unocss/core': 66.0.0 + ofetch: 1.4.1 + transitivePeerDependencies: + - supports-color + + '@unocss/preset-mini@66.0.0': + dependencies: + '@unocss/core': 66.0.0 + '@unocss/extractor-arbitrary-variants': 66.0.0 + '@unocss/rule-utils': 66.0.0 + + '@unocss/preset-tagify@66.0.0': + dependencies: + '@unocss/core': 66.0.0 + + '@unocss/preset-typography@66.0.0': + dependencies: + '@unocss/core': 66.0.0 + '@unocss/preset-mini': 66.0.0 + '@unocss/rule-utils': 66.0.0 + + '@unocss/preset-uno@66.0.0': + dependencies: + '@unocss/core': 66.0.0 + '@unocss/preset-wind3': 66.0.0 + + '@unocss/preset-web-fonts@66.0.0': + dependencies: + '@unocss/core': 66.0.0 + ofetch: 1.4.1 + + '@unocss/preset-wind3@66.0.0': + dependencies: + '@unocss/core': 66.0.0 + '@unocss/preset-mini': 66.0.0 + '@unocss/rule-utils': 66.0.0 + + '@unocss/preset-wind@66.0.0': + dependencies: + '@unocss/core': 66.0.0 + '@unocss/preset-wind3': 66.0.0 + + '@unocss/reset@66.0.0': {} + + '@unocss/rule-utils@66.0.0': + dependencies: + '@unocss/core': 66.0.0 + magic-string: 0.30.17 + + '@unocss/transformer-attributify-jsx@66.0.0': + dependencies: + '@unocss/core': 66.0.0 + + '@unocss/transformer-compile-class@66.0.0': + dependencies: + '@unocss/core': 66.0.0 + + '@unocss/transformer-directives@66.0.0': + dependencies: + '@unocss/core': 66.0.0 + '@unocss/rule-utils': 66.0.0 + css-tree: 3.1.0 + + '@unocss/transformer-variant-group@66.0.0': + dependencies: + '@unocss/core': 66.0.0 + + '@unocss/vite@66.0.0(vite@6.3.4(jiti@2.4.2)(terser@5.39.0)(tsx@4.19.2))(vue@3.5.13(typescript@5.8.3))': + dependencies: + '@ampproject/remapping': 2.3.0 + '@unocss/config': 66.0.0 + '@unocss/core': 66.0.0 + '@unocss/inspector': 66.0.0(vue@3.5.13(typescript@5.8.3)) + chokidar: 3.6.0 + magic-string: 0.30.17 + tinyglobby: 0.2.13 + unplugin-utils: 0.2.4 + vite: 6.3.4(jiti@2.4.2)(terser@5.39.0)(tsx@4.19.2) + transitivePeerDependencies: + - vue + + '@vue/compiler-core@3.5.13': + dependencies: + '@babel/parser': 7.27.1 + '@vue/shared': 3.5.13 + entities: 4.5.0 + estree-walker: 2.0.2 + source-map-js: 1.2.1 + + '@vue/compiler-dom@3.5.13': + dependencies: + '@vue/compiler-core': 3.5.13 + '@vue/shared': 3.5.13 + + '@vue/compiler-sfc@3.5.13': + dependencies: + '@babel/parser': 7.27.1 + '@vue/compiler-core': 3.5.13 + '@vue/compiler-dom': 3.5.13 + '@vue/compiler-ssr': 3.5.13 + '@vue/shared': 3.5.13 + estree-walker: 2.0.2 + magic-string: 0.30.17 + postcss: 8.5.3 + source-map-js: 1.2.1 + + '@vue/compiler-ssr@3.5.13': + dependencies: + '@vue/compiler-dom': 3.5.13 + '@vue/shared': 3.5.13 + + '@vue/reactivity@3.5.13': + dependencies: + '@vue/shared': 3.5.13 + + '@vue/runtime-core@3.5.13': + dependencies: + '@vue/reactivity': 3.5.13 + '@vue/shared': 3.5.13 + + '@vue/runtime-dom@3.5.13': + dependencies: + '@vue/reactivity': 3.5.13 + '@vue/runtime-core': 3.5.13 + '@vue/shared': 3.5.13 + csstype: 3.1.3 + + '@vue/server-renderer@3.5.13(vue@3.5.13(typescript@5.8.3))': + dependencies: + '@vue/compiler-ssr': 3.5.13 + '@vue/shared': 3.5.13 + vue: 3.5.13(typescript@5.8.3) + + '@vue/shared@3.5.13': {} + + '@zerodevx/svelte-json-view@1.0.11(svelte@5.28.2)': + dependencies: + svelte: 5.28.2 + + abort-controller@3.0.0: + dependencies: + event-target-shim: 5.0.1 + + acorn-jsx@5.3.2(acorn@8.14.0): + dependencies: + acorn: 8.14.0 + + acorn@8.14.0: {} + + ajv@6.12.6: + dependencies: + fast-deep-equal: 3.1.3 + fast-json-stable-stringify: 2.1.0 + json-schema-traverse: 0.4.1 + uri-js: 4.4.1 + + ansi-colors@4.1.3: {} + + ansi-regex@5.0.1: {} + + ansi-styles@4.3.0: + dependencies: + color-convert: 2.0.1 + + anymatch@3.1.3: + dependencies: + normalize-path: 3.0.0 + picomatch: 2.3.1 + + argparse@2.0.1: {} + + aria-query@5.3.2: {} + + array-union@2.1.0: {} + + atomic-sleep@1.0.0: {} + + axobject-query@4.1.0: {} + + bail@1.0.5: {} + + balanced-match@1.0.2: {} + + base64-js@1.5.1: {} + + binary-extensions@2.3.0: {} + + brace-expansion@1.1.11: + dependencies: + balanced-match: 1.0.2 + concat-map: 0.0.1 + + brace-expansion@2.0.1: + dependencies: + balanced-match: 1.0.2 + + braces@3.0.3: + dependencies: + fill-range: 7.1.1 + + browser-stdout@1.3.1: {} + + buffer-from@1.1.2: {} + + buffer@6.0.3: + dependencies: + base64-js: 1.5.1 + ieee754: 1.2.1 + + cac@6.7.14: {} + + callsites@3.1.0: {} + + camelcase@6.3.0: {} + + chalk@4.1.2: + dependencies: + ansi-styles: 4.3.0 + supports-color: 7.2.0 + + character-entities-legacy@1.1.4: {} + + character-entities@1.2.4: {} + + character-reference-invalid@1.1.4: {} + + chokidar@3.6.0: + dependencies: + anymatch: 3.1.3 + braces: 3.0.3 + glob-parent: 5.1.2 + is-binary-path: 2.1.0 + is-glob: 4.0.3 + normalize-path: 3.0.0 + readdirp: 3.6.0 + optionalDependencies: + fsevents: 2.3.3 + + cliui@7.0.4: + dependencies: string-width: 4.2.3 strip-ansi: 6.0.1 - through: 2.3.8 wrap-ansi: 7.0.0 - dev: true - /internal-ip@8.0.0: - resolution: {integrity: sha512-e6c3zxr9COnnc29PIz9LffmALOt0XhIJdR7f83DyHcQksL3B40KGmU3Sr1lrHja3i7Zyqo+AbwKZ+nZiMvg/OA==} - engines: {node: '>=16'} + cliui@8.0.1: + dependencies: + string-width: 4.2.3 + strip-ansi: 6.0.1 + wrap-ansi: 7.0.0 + + clsx@2.1.1: {} + + color-convert@2.0.1: + dependencies: + color-name: 1.1.4 + + color-name@1.1.4: {} + + colorette@2.0.20: {} + + commander@2.20.3: {} + + concat-map@0.0.1: {} + + confbox@0.1.8: {} + + consola@3.4.0: {} + + covector@0.12.4(mocha@10.8.2): + dependencies: + '@clack/prompts': 0.7.0 + '@covector/apply': 0.10.0(mocha@10.8.2) + '@covector/assemble': 0.12.0 + '@covector/changelog': 0.12.0 + '@covector/command': 0.8.0 + '@covector/files': 0.8.0 + effection: 2.0.8(mocha@10.8.2) + globby: 11.1.0 + js-yaml: 4.1.0 + lodash: 4.17.21 + pino: 9.6.0 + pino-abstract-transport: 1.2.0 + strip-ansi: 6.0.1 + yargs: 17.7.2 + transitivePeerDependencies: + - encoding + - mocha + - supports-color + + cross-fetch@3.1.5: + dependencies: + node-fetch: 2.6.7 + transitivePeerDependencies: + - encoding + + cross-spawn@7.0.6: + dependencies: + path-key: 3.1.1 + shebang-command: 2.0.0 + which: 2.0.2 + + css-tree@3.1.0: + dependencies: + mdn-data: 2.12.2 + source-map-js: 1.2.1 + + csstype@3.1.3: {} + + ctrlc-windows@2.2.0: {} + + debug@4.4.0(supports-color@8.1.1): + dependencies: + ms: 2.1.3 + optionalDependencies: + supports-color: 8.1.1 + + decamelize@4.0.0: {} + + deep-is@0.1.4: {} + + deepmerge@4.3.1: {} + + defu@6.1.4: {} + + destr@2.0.3: {} + + diff@5.2.0: {} + + dir-glob@3.0.1: + dependencies: + path-type: 4.0.0 + + duplexer@0.1.2: {} + + effection@2.0.8(mocha@10.8.2): + dependencies: + '@effection/channel': 2.0.6 + '@effection/core': 2.2.3 + '@effection/events': 2.0.6 + '@effection/fetch': 2.0.7(mocha@10.8.2) + '@effection/main': 2.1.2 + '@effection/stream': 2.0.6 + '@effection/subscription': 2.0.6 + transitivePeerDependencies: + - encoding + - mocha + + emoji-regex@8.0.0: {} + + entities@4.5.0: {} + + esbuild@0.25.3: + optionalDependencies: + '@esbuild/aix-ppc64': 0.25.3 + '@esbuild/android-arm': 0.25.3 + '@esbuild/android-arm64': 0.25.3 + '@esbuild/android-x64': 0.25.3 + '@esbuild/darwin-arm64': 0.25.3 + '@esbuild/darwin-x64': 0.25.3 + '@esbuild/freebsd-arm64': 0.25.3 + '@esbuild/freebsd-x64': 0.25.3 + '@esbuild/linux-arm': 0.25.3 + '@esbuild/linux-arm64': 0.25.3 + '@esbuild/linux-ia32': 0.25.3 + '@esbuild/linux-loong64': 0.25.3 + '@esbuild/linux-mips64el': 0.25.3 + '@esbuild/linux-ppc64': 0.25.3 + '@esbuild/linux-riscv64': 0.25.3 + '@esbuild/linux-s390x': 0.25.3 + '@esbuild/linux-x64': 0.25.3 + '@esbuild/netbsd-arm64': 0.25.3 + '@esbuild/netbsd-x64': 0.25.3 + '@esbuild/openbsd-arm64': 0.25.3 + '@esbuild/openbsd-x64': 0.25.3 + '@esbuild/sunos-x64': 0.25.3 + '@esbuild/win32-arm64': 0.25.3 + '@esbuild/win32-ia32': 0.25.3 + '@esbuild/win32-x64': 0.25.3 + + escalade@3.2.0: {} + + escape-string-regexp@4.0.0: {} + + eslint-config-prettier@10.1.5(eslint@9.28.0(jiti@2.4.2)): + dependencies: + eslint: 9.28.0(jiti@2.4.2) + + eslint-plugin-security@3.0.1: + dependencies: + safe-regex: 2.1.1 + + eslint-scope@8.3.0: + dependencies: + esrecurse: 4.3.0 + estraverse: 5.3.0 + + eslint-visitor-keys@3.4.3: {} + + eslint-visitor-keys@4.2.0: {} + + eslint@9.28.0(jiti@2.4.2): + dependencies: + '@eslint-community/eslint-utils': 4.7.0(eslint@9.28.0(jiti@2.4.2)) + '@eslint-community/regexpp': 4.12.1 + '@eslint/config-array': 0.20.0 + '@eslint/config-helpers': 0.2.1 + '@eslint/core': 0.14.0 + '@eslint/eslintrc': 3.3.1 + '@eslint/js': 9.28.0 + '@eslint/plugin-kit': 0.3.1 + '@humanfs/node': 0.16.6 + '@humanwhocodes/module-importer': 1.0.1 + '@humanwhocodes/retry': 0.4.2 + '@types/estree': 1.0.7 + '@types/json-schema': 7.0.15 + ajv: 6.12.6 + chalk: 4.1.2 + cross-spawn: 7.0.6 + debug: 4.4.0(supports-color@8.1.1) + escape-string-regexp: 4.0.0 + eslint-scope: 8.3.0 + eslint-visitor-keys: 4.2.0 + espree: 10.3.0 + esquery: 1.6.0 + esutils: 2.0.3 + fast-deep-equal: 3.1.3 + file-entry-cache: 8.0.0 + find-up: 5.0.0 + glob-parent: 6.0.2 + ignore: 5.3.2 + imurmurhash: 0.1.4 + is-glob: 4.0.3 + json-stable-stringify-without-jsonify: 1.0.1 + lodash.merge: 4.6.2 + minimatch: 3.1.2 + natural-compare: 1.4.0 + optionator: 0.9.4 + optionalDependencies: + jiti: 2.4.2 + transitivePeerDependencies: + - supports-color + + esm-env@1.2.2: {} + + espree@10.3.0: + dependencies: + acorn: 8.14.0 + acorn-jsx: 5.3.2(acorn@8.14.0) + eslint-visitor-keys: 4.2.0 + + esquery@1.6.0: + dependencies: + estraverse: 5.3.0 + + esrap@1.4.6: dependencies: - cidr-tools: 6.4.1 - default-gateway: 7.2.2 - is-ip: 5.0.0 - p-event: 5.0.1 - dev: true + '@jridgewell/sourcemap-codec': 1.5.0 - /internal-slot@1.0.5: - resolution: {integrity: sha512-Y+R5hJrzs52QCG2laLn4udYVnxsfny9CpOhNhUvk/SSSVyF6T27FzRbF0sroPidSu3X8oEAkOn2K804mjpt6UQ==} - engines: {node: '>= 0.4'} + esrecurse@4.3.0: dependencies: - get-intrinsic: 1.2.1 - has: 1.0.3 - side-channel: 1.0.4 - dev: true + estraverse: 5.3.0 - /ip-bigint@7.2.1: - resolution: {integrity: sha512-AftDIrlM5ZQM+qQ31IQ5MsL3tJWleeN3r0VqhmkB9oLvwcaDLeLNPtX4d9hahzExTFtz69eRv6LsGAoH20/8/g==} - engines: {node: '>=16'} - dev: true + estraverse@5.3.0: {} - /ip-regex@5.0.0: - resolution: {integrity: sha512-fOCG6lhoKKakwv+C6KdsOnGvgXnmgfmp0myi3bcNwj3qfwPAxRKWEuFhvEFF7ceYIz6+1jRZ+yguLFAmUNPEfw==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - dev: true + estree-walker@2.0.2: {} - /is-alphabetical@1.0.4: - resolution: {integrity: sha512-DwzsA04LQ10FHTZuL0/grVDk4rFoVH1pjAToYwBrHSxcrBIGQuXrQMtD5U1b0U2XVgKZCTLLP8u2Qxqhy3l2Vg==} - dev: true + esutils@2.0.3: {} - /is-alphanumerical@1.0.4: - resolution: {integrity: sha512-UzoZUr+XfVz3t3v4KyGEniVL9BDRoQtY7tOyrRybkVNjDFWyo1yhXNGrrBTQxp3ib9BLAWs7k2YKBQsFRkZG9A==} + event-target-shim@5.0.1: {} + + events@3.3.0: {} + + extend@3.0.2: {} + + fast-deep-equal@3.1.3: {} + + fast-glob@3.3.3: dependencies: - is-alphabetical: 1.0.4 - is-decimal: 1.0.4 - dev: true + '@nodelib/fs.stat': 2.0.5 + '@nodelib/fs.walk': 1.2.8 + glob-parent: 5.1.2 + merge2: 1.4.1 + micromatch: 4.0.8 + + fast-json-stable-stringify@2.1.0: {} - /is-array-buffer@3.0.2: - resolution: {integrity: sha512-y+FyyR/w8vfIRq4eQcM1EYgSTnmHXPqaF+IgzgraytCFq5Xh8lllDVmAZolPJiZttZLeFSINPYMaEJ7/vWUa1w==} + fast-levenshtein@2.0.6: {} + + fast-redact@3.5.0: {} + + fastq@1.19.1: dependencies: - call-bind: 1.0.2 - get-intrinsic: 1.2.1 - is-typed-array: 1.1.12 - dev: true + reusify: 1.1.0 - /is-bigint@1.0.4: - resolution: {integrity: sha512-zB9CruMamjym81i2JZ3UMn54PKGsQzsJeo6xvN3HJJ4CAsQNB6iRutp2To77OfCNuoxspsIhzaPoO1zyCEhFOg==} + fault@1.0.4: dependencies: - has-bigints: 1.0.2 - dev: true + format: 0.2.2 - /is-binary-path@2.1.0: - resolution: {integrity: sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==} - engines: {node: '>=8'} + fdir@6.4.4(picomatch@4.0.2): + optionalDependencies: + picomatch: 4.0.2 + + file-entry-cache@8.0.0: dependencies: - binary-extensions: 2.2.0 - dev: true + flat-cache: 4.0.1 - /is-boolean-object@1.1.2: - resolution: {integrity: sha512-gDYaKHJmnj4aWxyj6YHyXVpdQawtVLHU5cb+eztPGczf6cjuTdwve5ZIEfgXqH4e57An1D1AKf8CZ3kYrQRqYA==} - engines: {node: '>= 0.4'} + fill-range@7.1.1: dependencies: - call-bind: 1.0.2 - has-tostringtag: 1.0.0 - dev: true + to-regex-range: 5.0.1 - /is-buffer@2.0.5: - resolution: {integrity: sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ==} - engines: {node: '>=4'} - dev: true + find-up@5.0.0: + dependencies: + locate-path: 6.0.0 + path-exists: 4.0.0 - /is-builtin-module@3.2.1: - resolution: {integrity: sha512-BSLE3HnV2syZ0FK0iMA/yUGplUeMmNz4AW5fnTunbCIqZi4vG3WjJT9FHMy5D69xmAYBHXQhJdALdpwVxV501A==} - engines: {node: '>=6'} + flat-cache@4.0.1: dependencies: - builtin-modules: 3.3.0 - dev: true + flatted: 3.3.3 + keyv: 4.5.4 - /is-callable@1.2.7: - resolution: {integrity: sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==} - engines: {node: '>= 0.4'} - dev: true + flat@5.0.2: {} - /is-core-module@2.12.1: - resolution: {integrity: sha512-Q4ZuBAe2FUsKtyQJoQHlvP8OvBERxO3jEmy1I7hcRXcJBGGHFh/aJBswbXuS9sgrDH2QUO8ilkwNPHvHMd8clg==} + flatted@3.3.3: {} + + format@0.2.2: {} + + fs.realpath@1.0.0: {} + + fsevents@2.3.3: + optional: true + + function-bind@1.1.2: {} + + get-caller-file@2.0.5: {} + + get-tsconfig@4.10.0: dependencies: - has: 1.0.3 - dev: true + resolve-pkg-maps: 1.0.0 + optional: true - /is-core-module@2.13.0: - resolution: {integrity: sha512-Z7dk6Qo8pOCp3l4tsX2C5ZVas4V+UxwQodwZhLopL91TX8UyyHEXafPcyoeeWuLrwzHcr3igO78wNLwHJHsMCQ==} + glob-parent@5.1.2: dependencies: - has: 1.0.3 - dev: true + is-glob: 4.0.3 - /is-date-object@1.0.5: - resolution: {integrity: sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ==} - engines: {node: '>= 0.4'} + glob-parent@6.0.2: dependencies: - has-tostringtag: 1.0.0 - dev: true + is-glob: 4.0.3 - /is-decimal@1.0.4: - resolution: {integrity: sha512-RGdriMmQQvZ2aqaQq3awNA6dCGtKpiDFcOzrTWrDAT2MiWrKQVPmxLGHl7Y2nNu6led0kEyoX0enY0qXYsv9zw==} - dev: true + glob@8.1.0: + dependencies: + fs.realpath: 1.0.0 + inflight: 1.0.6 + inherits: 2.0.4 + minimatch: 5.1.6 + once: 1.4.0 - /is-extglob@2.1.1: - resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==} - engines: {node: '>=0.10.0'} - dev: true + globals@14.0.0: {} - /is-fullwidth-code-point@3.0.0: - resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==} - engines: {node: '>=8'} - dev: true + globals@15.15.0: {} - /is-glob@4.0.3: - resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==} - engines: {node: '>=0.10.0'} + globby@11.1.0: dependencies: - is-extglob: 2.1.1 - dev: true + array-union: 2.1.0 + dir-glob: 3.0.1 + fast-glob: 3.3.3 + ignore: 5.3.2 + merge2: 1.4.1 + slash: 3.0.0 - /is-hexadecimal@1.0.4: - resolution: {integrity: sha512-gyPJuv83bHMpocVYoqof5VDiZveEoGoFL8m3BXNb2VW8Xs+rz9kqO8LOQ5DH6EsuvilT1ApazU0pyl+ytbPtlw==} - dev: true + graphemer@1.4.0: {} - /is-interactive@1.0.0: - resolution: {integrity: sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==} - engines: {node: '>=8'} - dev: true + gzip-size@6.0.0: + dependencies: + duplexer: 0.1.2 + + has-flag@4.0.0: {} - /is-ip@5.0.0: - resolution: {integrity: sha512-uhmKwcdWJ1nTmBdoBxdHilfJs4qdLBIvVHKRels2+UCZmfcfefuQWziadaYLpN7t/bUrJOjJHv+R1di1q7Q1HQ==} - engines: {node: '>=14.16'} + hasown@2.0.2: dependencies: - ip-regex: 5.0.0 - super-regex: 0.2.0 - dev: true + function-bind: 1.1.2 - /is-module@1.0.0: - resolution: {integrity: sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==} - dev: true + he@1.2.0: {} - /is-negative-zero@2.0.2: - resolution: {integrity: sha512-dqJvarLawXsFbNDeJW7zAz8ItJ9cd28YufuuFzh0G8pNHjJMnY08Dv7sYX2uF5UpQOwieAeOExEYAWWfu7ZZUA==} - engines: {node: '>= 0.4'} - dev: true + ieee754@1.2.1: {} - /is-number-object@1.0.7: - resolution: {integrity: sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ==} - engines: {node: '>= 0.4'} + ignore@5.3.2: {} + + ignore@7.0.4: {} + + import-fresh@3.3.1: dependencies: - has-tostringtag: 1.0.0 - dev: true + parent-module: 1.0.1 + resolve-from: 4.0.0 - /is-number@7.0.0: - resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} - engines: {node: '>=0.12.0'} - dev: true + imurmurhash@0.1.4: {} - /is-path-inside@3.0.3: - resolution: {integrity: sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==} - engines: {node: '>=8'} - dev: true + inflight@1.0.6: + dependencies: + once: 1.4.0 + wrappy: 1.0.2 - /is-plain-obj@2.1.0: - resolution: {integrity: sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==} - engines: {node: '>=8'} - dev: true + inherits@2.0.4: {} + + is-alphabetical@1.0.4: {} - /is-reference@3.0.1: - resolution: {integrity: sha512-baJJdQLiYaJdvFbJqXrcGv3WU3QCzBlUcI5QhbesIm6/xPsvmO+2CDoi/GMOFBQEQm+PXkwOPrp9KK5ozZsp2w==} + is-alphanumerical@1.0.4: dependencies: - '@types/estree': 1.0.1 + is-alphabetical: 1.0.4 + is-decimal: 1.0.4 - /is-regex@1.1.4: - resolution: {integrity: sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg==} - engines: {node: '>= 0.4'} + is-binary-path@2.1.0: dependencies: - call-bind: 1.0.2 - has-tostringtag: 1.0.0 - dev: true + binary-extensions: 2.3.0 - /is-regexp@3.1.0: - resolution: {integrity: sha512-rbku49cWloU5bSMI+zaRaXdQHXnthP6DZ/vLnfdSKyL4zUzuWnomtOEiZZOd+ioQ+avFo/qau3KPTc7Fjy1uPA==} - engines: {node: '>=12'} - dev: true + is-buffer@2.0.5: {} - /is-shared-array-buffer@1.0.2: - resolution: {integrity: sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA==} + is-core-module@2.16.1: dependencies: - call-bind: 1.0.2 - dev: true + hasown: 2.0.2 - /is-stream@2.0.1: - resolution: {integrity: sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==} - engines: {node: '>=8'} - dev: true + is-decimal@1.0.4: {} - /is-stream@3.0.0: - resolution: {integrity: sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - dev: true + is-extglob@2.1.1: {} - /is-string@1.0.7: - resolution: {integrity: sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==} - engines: {node: '>= 0.4'} - dependencies: - has-tostringtag: 1.0.0 - dev: true + is-fullwidth-code-point@3.0.0: {} - /is-symbol@1.0.4: - resolution: {integrity: sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg==} - engines: {node: '>= 0.4'} + is-glob@4.0.3: dependencies: - has-symbols: 1.0.3 - dev: true + is-extglob: 2.1.1 - /is-typed-array@1.1.12: - resolution: {integrity: sha512-Z14TF2JNG8Lss5/HMqt0//T9JeHXttXy5pH/DBU4vi98ozO2btxzq9MwYDZYnKwU8nRsz/+GVFVRDq3DkVuSPg==} - engines: {node: '>= 0.4'} - dependencies: - which-typed-array: 1.1.11 - dev: true + is-hexadecimal@1.0.4: {} - /is-unicode-supported@0.1.0: - resolution: {integrity: sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==} - engines: {node: '>=10'} - dev: true + is-module@1.0.0: {} + + is-number@7.0.0: {} - /is-weakref@1.0.2: - resolution: {integrity: sha512-qctsuLZmIQ0+vSSMfoVvyFe2+GSEvnmZ2ezTup1SBse9+twCCeial6EEi3Nc2KFcf6+qz2FBPnjXsk8xhKSaPQ==} + is-plain-obj@2.1.0: {} + + is-reference@3.0.3: dependencies: - call-bind: 1.0.2 - dev: true + '@types/estree': 1.0.7 - /isarray@2.0.5: - resolution: {integrity: sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==} - dev: true + is-unicode-supported@0.1.0: {} - /isexe@2.0.0: - resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} - dev: true + isexe@2.0.0: {} - /jiti@1.20.0: - resolution: {integrity: sha512-3TV69ZbrvV6U5DfQimop50jE9Dl6J8O1ja1dvBbMba/sZ3YBEQqJ2VZRoQPVnhlzjNtU1vaXRZVrVjU4qtm8yA==} - hasBin: true - dev: true + jiti@2.4.2: {} - /js-yaml@4.1.0: - resolution: {integrity: sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==} - hasBin: true + js-yaml@4.1.0: dependencies: argparse: 2.0.1 - dev: true - /json-schema-traverse@0.4.1: - resolution: {integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==} - dev: true + json-buffer@3.0.1: {} - /json-stable-stringify-without-jsonify@1.0.1: - resolution: {integrity: sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==} - dev: true + json-schema-traverse@0.4.1: {} - /json5@1.0.2: - resolution: {integrity: sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==} - hasBin: true - dependencies: - minimist: 1.2.8 - dev: true + json-stable-stringify-without-jsonify@1.0.1: {} - /jsonc-parser@3.2.0: - resolution: {integrity: sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==} - dev: true + keyv@4.5.4: + dependencies: + json-buffer: 3.0.1 - /kleur@4.1.5: - resolution: {integrity: sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==} - engines: {node: '>=6'} - dev: true + kleur@4.1.5: {} - /kolorist@1.8.0: - resolution: {integrity: sha512-Y+60/zizpJ3HRH8DCss+q95yr6145JXZo46OTpFvDZWLfRCE4qChOyk1b26nMaNpfHHgxagk9dXT5OP0Tfe+dQ==} - dev: true + kolorist@1.8.0: {} - /levn@0.4.1: - resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==} - engines: {node: '>= 0.8.0'} + levn@0.4.1: dependencies: prelude-ls: 1.2.1 type-check: 0.4.0 - dev: true - /local-pkg@0.4.3: - resolution: {integrity: sha512-SFppqq5p42fe2qcZQqqEOiVRXl+WCP1MdT6k7BDEW1j++sp5fIY+/fdRQitvKgB5BrBcmrs5m/L0v2FrU5MY1g==} - engines: {node: '>=14'} - dev: true + local-pkg@1.0.0: + dependencies: + mlly: 1.7.4 + pkg-types: 1.3.1 - /locate-character@3.0.0: - resolution: {integrity: sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==} + locate-character@3.0.0: {} - /locate-path@6.0.0: - resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==} - engines: {node: '>=10'} + locate-path@6.0.0: dependencies: p-locate: 5.0.0 - dev: true - /lodash.merge@4.6.2: - resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==} - dev: true + lodash.merge@4.6.2: {} - /lodash@4.17.21: - resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} - dev: true + lodash@4.17.21: {} - /log-symbols@4.1.0: - resolution: {integrity: sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==} - engines: {node: '>=10'} + log-symbols@4.1.0: dependencies: chalk: 4.1.2 is-unicode-supported: 0.1.0 - dev: true - /longest-streak@2.0.4: - resolution: {integrity: sha512-vM6rUVCVUJJt33bnmHiZEvr7wPT78ztX7rojL+LW51bHtLh6HTjx84LA5W4+oa6aKEJA7jJu5LR6vQRBpA5DVg==} - dev: true - - /lru-cache@6.0.0: - resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==} - engines: {node: '>=10'} - dependencies: - yallist: 4.0.0 - dev: true + longest-streak@2.0.4: {} - /magic-string@0.27.0: - resolution: {integrity: sha512-8UnnX2PeRAPZuN12svgR9j7M1uWMovg/CEnIwIG0LFkXSJJe4PdfUGiTGl8V9bsBHFUtfVINcSyYxd7q+kx9fA==} - engines: {node: '>=12'} - dependencies: - '@jridgewell/sourcemap-codec': 1.4.15 - dev: true - - /magic-string@0.30.5: - resolution: {integrity: sha512-7xlpfBaQaP/T6Vh8MO/EqXSW5En6INHEvEXQiuff7Gku0PWjU3uf6w/j9o7O+SpB5fOAkrI5HeoNgwjEO0pFsA==} - engines: {node: '>=12'} + magic-string@0.30.17: dependencies: - '@jridgewell/sourcemap-codec': 1.4.15 + '@jridgewell/sourcemap-codec': 1.5.0 - /mdast-util-from-markdown@0.8.5: - resolution: {integrity: sha512-2hkTXtYYnr+NubD/g6KGBS/0mFmBcifAsI0yIWRiRo0PjVs6SSOSOdtzbp6kSGnShDN6G5aWZpKQ2lWRy27mWQ==} + mdast-util-from-markdown@0.8.5: dependencies: - '@types/mdast': 3.0.12 + '@types/mdast': 3.0.15 mdast-util-to-string: 2.0.0 micromark: 2.11.4 parse-entities: 2.0.0 unist-util-stringify-position: 2.0.3 transitivePeerDependencies: - supports-color - dev: true - /mdast-util-frontmatter@0.2.0: - resolution: {integrity: sha512-FHKL4w4S5fdt1KjJCwB0178WJ0evnyyQr5kXTM3wrOVpytD0hrkvd+AOOjU9Td8onOejCkmZ+HQRT3CZ3coHHQ==} + mdast-util-frontmatter@0.2.0: dependencies: micromark-extension-frontmatter: 0.2.2 - dev: true - /mdast-util-to-markdown@0.6.5: - resolution: {integrity: sha512-XeV9sDE7ZlOQvs45C9UKMtfTcctcaj/pGwH8YLbMHoMOXNNCn2LsqVQOqrF1+/NU8lKDAqozme9SCXWyo9oAcQ==} + mdast-util-to-markdown@0.6.5: dependencies: - '@types/unist': 2.0.7 + '@types/unist': 2.0.11 longest-streak: 2.0.4 mdast-util-to-string: 2.0.0 parse-entities: 2.0.0 repeat-string: 1.6.1 zwitch: 1.0.5 - dev: true - - /mdast-util-to-string@2.0.0: - resolution: {integrity: sha512-AW4DRS3QbBayY/jJmD8437V1Gombjf8RSOUCMFBuo5iHi58AGEgVCKQ+ezHkZZDpAQS75hcBMpLqjpJTjtUL7w==} - dev: true - /mdn-data@2.0.30: - resolution: {integrity: sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA==} + mdast-util-to-string@2.0.0: {} - /merge-stream@2.0.0: - resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==} - dev: true + mdn-data@2.12.2: {} - /merge2@1.4.1: - resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==} - engines: {node: '>= 8'} - dev: true + merge2@1.4.1: {} - /micromark-extension-frontmatter@0.2.2: - resolution: {integrity: sha512-q6nPLFCMTLtfsctAuS0Xh4vaolxSFUWUWR6PZSrXXiRy+SANGllpcqdXFv2z07l0Xz/6Hl40hK0ffNCJPH2n1A==} + micromark-extension-frontmatter@0.2.2: dependencies: fault: 1.0.4 - dev: true - /micromark@2.11.4: - resolution: {integrity: sha512-+WoovN/ppKolQOFIAajxi7Lu9kInbPxFuTBVEavFcL8eAfVstoc5MocPmqBeAdBOJV00uaVjegzH4+MA0DN/uA==} + micromark@2.11.4: dependencies: - debug: 4.3.4(supports-color@8.1.1) + debug: 4.4.0(supports-color@8.1.1) parse-entities: 2.0.0 transitivePeerDependencies: - supports-color - dev: true - /micromatch@4.0.5: - resolution: {integrity: sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==} - engines: {node: '>=8.6'} + micromatch@4.0.8: dependencies: - braces: 3.0.2 + braces: 3.0.3 picomatch: 2.3.1 - dev: true - - /mimic-fn@2.1.0: - resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==} - engines: {node: '>=6'} - dev: true - - /mimic-fn@4.0.0: - resolution: {integrity: sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==} - engines: {node: '>=12'} - dev: true - - /min-indent@1.0.1: - resolution: {integrity: sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==} - engines: {node: '>=4'} - dev: true - /minimatch@3.1.2: - resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==} + minimatch@3.1.2: dependencies: brace-expansion: 1.1.11 - dev: true - /minimatch@5.0.1: - resolution: {integrity: sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==} - engines: {node: '>=10'} + minimatch@5.1.6: dependencies: brace-expansion: 2.0.1 - dev: true - /minimist@1.2.8: - resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} - dev: true - - /mkdirp@0.5.6: - resolution: {integrity: sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==} - hasBin: true + minimatch@9.0.5: dependencies: - minimist: 1.2.8 - dev: true + brace-expansion: 2.0.1 - /mlly@1.4.2: - resolution: {integrity: sha512-i/Ykufi2t1EZ6NaPLdfnZk2AX8cs0d+mTzVKuPfqPKPatxLApaBoxJQ9x1/uckXtrS/U5oisPMDkNs0yQTaBRg==} + mlly@1.7.4: dependencies: - acorn: 8.10.0 - pathe: 1.1.1 - pkg-types: 1.0.3 - ufo: 1.3.1 - dev: true + acorn: 8.14.0 + pathe: 2.0.3 + pkg-types: 1.3.1 + ufo: 1.5.4 - /mocha@10.2.0: - resolution: {integrity: sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg==} - engines: {node: '>= 14.0.0'} - hasBin: true + mocha@10.8.2: dependencies: - ansi-colors: 4.1.1 + ansi-colors: 4.1.3 browser-stdout: 1.3.1 - chokidar: 3.5.3 - debug: 4.3.4(supports-color@8.1.1) - diff: 5.0.0 + chokidar: 3.6.0 + debug: 4.4.0(supports-color@8.1.1) + diff: 5.2.0 escape-string-regexp: 4.0.0 find-up: 5.0.0 - glob: 7.2.0 + glob: 8.1.0 he: 1.2.0 js-yaml: 4.1.0 log-symbols: 4.1.0 - minimatch: 5.0.1 + minimatch: 5.1.6 ms: 2.1.3 - nanoid: 3.3.3 - serialize-javascript: 6.0.0 + serialize-javascript: 6.0.2 strip-json-comments: 3.1.1 supports-color: 8.1.1 - workerpool: 6.2.1 + workerpool: 6.5.1 yargs: 16.2.0 - yargs-parser: 20.2.4 + yargs-parser: 20.2.9 yargs-unparser: 2.0.0 - dev: true - - /mri@1.2.0: - resolution: {integrity: sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==} - engines: {node: '>=4'} - dev: true - - /mrmime@1.0.1: - resolution: {integrity: sha512-hzzEagAgDyoU1Q6yg5uI+AorQgdvMCur3FcKf7NhMKWsaYg+RnbTyHRa/9IlLF9rf455MOCtcqqrQQ83pPP7Uw==} - engines: {node: '>=10'} - dev: true - - /ms@2.1.2: - resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} - dev: true - /ms@2.1.3: - resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} - dev: true - - /mute-stream@0.0.8: - resolution: {integrity: sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==} - dev: true + mrmime@2.0.1: {} - /nanoid@3.3.3: - resolution: {integrity: sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==} - engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} - hasBin: true - dev: true + ms@2.1.3: {} - /nanoid@3.3.6: - resolution: {integrity: sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==} - engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} - hasBin: true - dev: true + nanoid@3.3.11: {} - /natural-compare@1.4.0: - resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} - dev: true + natural-compare@1.4.0: {} - /node-fetch-native@1.4.0: - resolution: {integrity: sha512-F5kfEj95kX8tkDhUCYdV8dg3/8Olx/94zB8+ZNthFs6Bz31UpUi8Xh40TN3thLwXgrwXry1pEg9lJ++tLWTcqA==} - dev: true + node-fetch-native@1.6.6: {} - /node-fetch@2.6.7: - resolution: {integrity: sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==} - engines: {node: 4.x || >=6.0.0} - peerDependencies: - encoding: ^0.1.0 - peerDependenciesMeta: - encoding: - optional: true + node-fetch@2.6.7: dependencies: whatwg-url: 5.0.0 - dev: true - - /normalize-path@3.0.0: - resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==} - engines: {node: '>=0.10.0'} - dev: true - - /npm-run-path@4.0.1: - resolution: {integrity: sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==} - engines: {node: '>=8'} - dependencies: - path-key: 3.1.1 - dev: true - - /npm-run-path@5.1.0: - resolution: {integrity: sha512-sJOdmRGrY2sjNTRMbSvluQqg+8X7ZK61yvzBEIDhz4f8z1TZFYABsqjjCBd/0PUNE9M6QDgHJXQkGUEm7Q+l9Q==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - dependencies: - path-key: 4.0.0 - dev: true - - /object-inspect@1.12.3: - resolution: {integrity: sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==} - dev: true - - /object-keys@1.1.1: - resolution: {integrity: sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==} - engines: {node: '>= 0.4'} - dev: true - - /object.assign@4.1.4: - resolution: {integrity: sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ==} - engines: {node: '>= 0.4'} - dependencies: - call-bind: 1.0.2 - define-properties: 1.2.0 - has-symbols: 1.0.3 - object-keys: 1.1.1 - dev: true - - /object.fromentries@2.0.7: - resolution: {integrity: sha512-UPbPHML6sL8PI/mOqPwsH4G6iyXcCGzLin8KvEPenOZN5lpCNBZZQ+V62vdjB1mQHrmqGQt5/OJzemUA+KJmEA==} - engines: {node: '>= 0.4'} - dependencies: - call-bind: 1.0.2 - define-properties: 1.2.0 - es-abstract: 1.22.1 - dev: true - /object.groupby@1.0.1: - resolution: {integrity: sha512-HqaQtqLnp/8Bn4GL16cj+CUYbnpe1bh0TtEaWvybszDG4tgxCJuRpV8VGuvNaI1fAnI4lUJzDG55MXcOH4JZcQ==} - dependencies: - call-bind: 1.0.2 - define-properties: 1.2.0 - es-abstract: 1.22.1 - get-intrinsic: 1.2.1 - dev: true + normalize-path@3.0.0: {} - /object.values@1.1.6: - resolution: {integrity: sha512-FVVTkD1vENCsAcwNs9k6jea2uHC/X0+JcjG8YA60FN5CMaJmG95wT9jek/xX9nornqGRrBkKtzuAu2wuHpKqvw==} - engines: {node: '>= 0.4'} + ofetch@1.4.1: dependencies: - call-bind: 1.0.2 - define-properties: 1.2.0 - es-abstract: 1.22.1 - dev: true + destr: 2.0.3 + node-fetch-native: 1.6.6 + ufo: 1.5.4 - /ofetch@1.3.3: - resolution: {integrity: sha512-s1ZCMmQWXy4b5K/TW9i/DtiN8Ku+xCiHcjQ6/J/nDdssirrQNOoB165Zu8EqLMA2lln1JUth9a0aW9Ap2ctrUg==} - dependencies: - destr: 2.0.1 - node-fetch-native: 1.4.0 - ufo: 1.3.1 - dev: true + on-exit-leak-free@2.1.2: {} - /once@1.4.0: - resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} + once@1.4.0: dependencies: wrappy: 1.0.2 - dev: true - /onetime@5.1.2: - resolution: {integrity: sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==} - engines: {node: '>=6'} - dependencies: - mimic-fn: 2.1.0 - dev: true - - /onetime@6.0.0: - resolution: {integrity: sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==} - engines: {node: '>=12'} + optionator@0.9.4: dependencies: - mimic-fn: 4.0.0 - dev: true - - /optionator@0.9.3: - resolution: {integrity: sha512-JjCoypp+jKn1ttEFExxhetCKeJt9zhAgAve5FXHixTvFDW/5aEktX9bufBKLRRMdU7bNtpLfcGu94B3cdEJgjg==} - engines: {node: '>= 0.8.0'} - dependencies: - '@aashutoshrathi/word-wrap': 1.2.6 deep-is: 0.1.4 fast-levenshtein: 2.0.6 levn: 0.4.1 prelude-ls: 1.2.1 type-check: 0.4.0 - dev: true - - /ora@5.4.1: - resolution: {integrity: sha512-5b6Y85tPxZZ7QytO+BQzysW31HJku27cRIlkbAXaNx+BdcVi+LlRFmVXzeF6a7JCwJpyw5c4b+YSVImQIrBpuQ==} - engines: {node: '>=10'} - dependencies: - bl: 4.1.0 - chalk: 4.1.2 - cli-cursor: 3.1.0 - cli-spinners: 2.9.0 - is-interactive: 1.0.0 - is-unicode-supported: 0.1.0 - log-symbols: 4.1.0 - strip-ansi: 6.0.1 - wcwidth: 1.0.1 - dev: true - - /os-tmpdir@1.0.2: - resolution: {integrity: sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==} - engines: {node: '>=0.10.0'} - dev: true + word-wrap: 1.2.5 - /p-event@5.0.1: - resolution: {integrity: sha512-dd589iCQ7m1L0bmC5NLlVYfy3TbBEsMUfWx9PyAgPeIcFZ/E2yaTZ4Rz4MiBmmJShviiftHVXOqfnfzJ6kyMrQ==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - dependencies: - p-timeout: 5.1.0 - dev: true - - /p-limit@3.1.0: - resolution: {integrity: sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==} - engines: {node: '>=10'} + p-limit@3.1.0: dependencies: yocto-queue: 0.1.0 - dev: true - /p-locate@5.0.0: - resolution: {integrity: sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==} - engines: {node: '>=10'} + p-locate@5.0.0: dependencies: p-limit: 3.1.0 - dev: true - /p-timeout@5.1.0: - resolution: {integrity: sha512-auFDyzzzGZZZdHz3BtET9VEz0SE/uMEAx7uWfGPucfzEwwe/xH0iVeZibQmANYE/hp9T2+UUZT5m+BKyrDp3Ew==} - engines: {node: '>=12'} - dev: true + package-manager-detector@0.2.9: {} - /parent-module@1.0.1: - resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==} - engines: {node: '>=6'} + parent-module@1.0.1: dependencies: callsites: 3.1.0 - dev: true - /parse-entities@2.0.0: - resolution: {integrity: sha512-kkywGpCcRYhqQIchaWqZ875wzpS/bMKhz5HnN3p7wveJTkTtyAB/AlnS0f8DFSqYW1T82t6yEAkEcB+A1I3MbQ==} + parse-entities@2.0.0: dependencies: character-entities: 1.2.4 character-entities-legacy: 1.1.4 @@ -3810,1059 +3788,480 @@ packages: is-alphanumerical: 1.0.4 is-decimal: 1.0.4 is-hexadecimal: 1.0.4 - dev: true - /path-exists@4.0.0: - resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==} - engines: {node: '>=8'} - dev: true + path-exists@4.0.0: {} - /path-is-absolute@1.0.1: - resolution: {integrity: sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==} - engines: {node: '>=0.10.0'} - dev: true + path-key@3.1.1: {} - /path-key@3.1.1: - resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} - engines: {node: '>=8'} - dev: true + path-parse@1.0.7: {} - /path-key@4.0.0: - resolution: {integrity: sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==} - engines: {node: '>=12'} - dev: true + path-type@4.0.0: {} - /path-parse@1.0.7: - resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} - dev: true + pathe@2.0.3: {} - /path-type@4.0.0: - resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} - engines: {node: '>=8'} - dev: true + perfect-debounce@1.0.0: {} - /pathe@1.1.1: - resolution: {integrity: sha512-d+RQGp0MAYTIaDBIMmOfMwz3E+LOZnxx1HZd5R18mmCZY0QBlK0LDZfPc8FW8Ed2DlvsuE6PRjroDY+wg4+j/Q==} - dev: true + picocolors@1.1.1: {} - /perfect-debounce@1.0.0: - resolution: {integrity: sha512-xCy9V055GLEqoFaHoC1SoLIaLmWctgCUaBaWxDZ7/Zx4CTyX7cJQLJOok/orfjZAh9kEYpjJa4d0KcJmCbctZA==} - dev: true + picomatch@2.3.1: {} - /periscopic@3.1.0: - resolution: {integrity: sha512-vKiQ8RRtkl9P+r/+oefh25C3fhybptkHKCZSPlcXiJux2tJF55GnEj3BVn4A5gKfq9NWWXXrxkHBwVPUfH0opw==} + picomatch@4.0.2: {} + + pino-abstract-transport@1.2.0: dependencies: - '@types/estree': 1.0.1 - estree-walker: 3.0.3 - is-reference: 3.0.1 + readable-stream: 4.7.0 + split2: 4.2.0 - /picocolors@1.0.0: - resolution: {integrity: sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==} - dev: true + pino-abstract-transport@2.0.0: + dependencies: + split2: 4.2.0 - /picomatch@2.3.1: - resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} - engines: {node: '>=8.6'} - dev: true + pino-std-serializers@7.0.0: {} - /pkg-types@1.0.3: - resolution: {integrity: sha512-nN7pYi0AQqJnoLPC9eHFQ8AcyaixBUOwvqc5TDnIKCMEE6I0y8P7OKA7fPexsXGCGxQDl/cmrLAp26LhcwxZ4A==} + pino@9.6.0: dependencies: - jsonc-parser: 3.2.0 - mlly: 1.4.2 - pathe: 1.1.1 - dev: true + atomic-sleep: 1.0.0 + fast-redact: 3.5.0 + on-exit-leak-free: 2.1.2 + pino-abstract-transport: 2.0.0 + pino-std-serializers: 7.0.0 + process-warning: 4.0.1 + quick-format-unescaped: 4.0.4 + real-require: 0.2.0 + safe-stable-stringify: 2.5.0 + sonic-boom: 4.2.0 + thread-stream: 3.1.0 - /postcss@8.4.31: - resolution: {integrity: sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==} - engines: {node: ^10 || ^12 || >=14} + pkg-types@1.3.1: dependencies: - nanoid: 3.3.6 - picocolors: 1.0.0 - source-map-js: 1.0.2 - dev: true + confbox: 0.1.8 + mlly: 1.7.4 + pathe: 2.0.3 - /prelude-ls@1.2.1: - resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} - engines: {node: '>= 0.8.0'} - dev: true + postcss@8.5.3: + dependencies: + nanoid: 3.3.11 + picocolors: 1.1.1 + source-map-js: 1.2.1 - /prettier@3.0.3: - resolution: {integrity: sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==} - engines: {node: '>=14'} - hasBin: true - dev: true + prelude-ls@1.2.1: {} - /punycode@2.3.0: - resolution: {integrity: sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==} - engines: {node: '>=6'} - dev: true + prettier@3.5.3: {} - /queue-microtask@1.2.3: - resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} - dev: true + process-warning@4.0.1: {} - /randombytes@2.1.0: - resolution: {integrity: sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==} + process@0.11.10: {} + + punycode@2.3.1: {} + + queue-microtask@1.2.3: {} + + quick-format-unescaped@4.0.4: {} + + randombytes@2.1.0: dependencies: safe-buffer: 5.2.1 - dev: true - /readable-stream@3.6.2: - resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==} - engines: {node: '>= 6'} + readable-stream@4.7.0: dependencies: - inherits: 2.0.4 + abort-controller: 3.0.0 + buffer: 6.0.3 + events: 3.3.0 + process: 0.11.10 string_decoder: 1.3.0 - util-deprecate: 1.0.2 - dev: true - - /readdirp@3.6.0: - resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==} - engines: {node: '>=8.10.0'} - dependencies: - picomatch: 2.3.1 - dev: true - /regexp-tree@0.1.27: - resolution: {integrity: sha512-iETxpjK6YoRWJG5o6hXLwvjYAoW+FEZn9os0PD/b6AP6xQwsa/Y7lCVgIixBbUPMfhu+i2LtdeAqVTgGlQarfA==} - hasBin: true - dev: true - - /regexp.prototype.flags@1.5.0: - resolution: {integrity: sha512-0SutC3pNudRKgquxGoRGIz946MZVHqbNfPjBdxeOhBrdgDKlRoXmYLQN9xRbrR09ZXWeGAdPuif7egofn6v5LA==} - engines: {node: '>= 0.4'} + readdirp@3.6.0: dependencies: - call-bind: 1.0.2 - define-properties: 1.2.0 - functions-have-names: 1.2.3 - dev: true + picomatch: 2.3.1 - /remark-frontmatter@3.0.0: - resolution: {integrity: sha512-mSuDd3svCHs+2PyO29h7iijIZx4plX0fheacJcAoYAASfgzgVIcXGYSq9GFyYocFLftQs8IOmmkgtOovs6d4oA==} + real-require@0.2.0: {} + + regexp-tree@0.1.27: {} + + remark-frontmatter@3.0.0: dependencies: mdast-util-frontmatter: 0.2.0 micromark-extension-frontmatter: 0.2.2 - dev: true - /remark-parse@9.0.0: - resolution: {integrity: sha512-geKatMwSzEXKHuzBNU1z676sGcDcFoChMK38TgdHJNAYfFtsfHDQG7MoJAjs6sgYMqyLduCYWDIWZIxiPeafEw==} + remark-parse@9.0.0: dependencies: mdast-util-from-markdown: 0.8.5 transitivePeerDependencies: - supports-color - dev: true - /remark-stringify@9.0.1: - resolution: {integrity: sha512-mWmNg3ZtESvZS8fv5PTvaPckdL4iNlCHTt8/e/8oN08nArHRHjNZMKzA/YW3+p7/lYqIw4nx1XsjCBo/AxNChg==} + remark-stringify@9.0.1: dependencies: mdast-util-to-markdown: 0.6.5 - dev: true - /repeat-string@1.6.1: - resolution: {integrity: sha512-PV0dzCYDNfRi1jCDbJzpW7jNNDRuCOG/jI5ctQcGKt/clZD+YcPS3yIlWuTJMmESC8aevCFmWJy5wjAFgNqN6w==} - engines: {node: '>=0.10'} - dev: true + repeat-string@1.6.1: {} - /require-directory@2.1.1: - resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==} - engines: {node: '>=0.10.0'} - dev: true + require-directory@2.1.1: {} - /resolve-from@4.0.0: - resolution: {integrity: sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==} - engines: {node: '>=4'} - dev: true + resolve-from@4.0.0: {} - /resolve-pkg-maps@1.0.0: - resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==} - dev: true + resolve-pkg-maps@1.0.0: + optional: true - /resolve@1.22.2: - resolution: {integrity: sha512-Sb+mjNHOULsBv818T40qSPeRiuWLyaGMa5ewydRLFimneixmVy2zdivRl+AF6jaYPC8ERxGDmFSiqui6SfPd+g==} - hasBin: true + resolve@1.22.10: dependencies: - is-core-module: 2.12.1 + is-core-module: 2.16.1 path-parse: 1.0.7 supports-preserve-symlinks-flag: 1.0.0 - dev: true - - /restore-cursor@3.1.0: - resolution: {integrity: sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==} - engines: {node: '>=8'} - dependencies: - onetime: 5.1.2 - signal-exit: 3.0.7 - dev: true - - /reusify@1.0.4: - resolution: {integrity: sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==} - engines: {iojs: '>=1.0.0', node: '>=0.10.0'} - dev: true - /rimraf@2.7.1: - resolution: {integrity: sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==} - hasBin: true - dependencies: - glob: 7.2.3 - dev: true + reusify@1.1.0: {} - /rimraf@3.0.2: - resolution: {integrity: sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==} - hasBin: true + rollup@4.41.1: dependencies: - glob: 7.2.3 - dev: true - - /rollup@3.29.4: - resolution: {integrity: sha512-oWzmBZwvYrU0iJHtDmhsm662rC15FRXmcjCk1xD771dFDx5jJ02ufAQQTn0etB2emNk4J9EZg/yWKpsn9BWGRw==} - engines: {node: '>=14.18.0', npm: '>=8.0.0'} - hasBin: true - optionalDependencies: - fsevents: 2.3.3 - dev: true - - /rollup@4.1.4: - resolution: {integrity: sha512-U8Yk1lQRKqCkDBip/pMYT+IKaN7b7UesK3fLSTuHBoBJacCE+oBqo/dfG/gkUdQNNB2OBmRP98cn2C2bkYZkyw==} - engines: {node: '>=18.0.0', npm: '>=8.0.0'} - hasBin: true + '@types/estree': 1.0.7 optionalDependencies: - '@rollup/rollup-android-arm-eabi': 4.1.4 - '@rollup/rollup-android-arm64': 4.1.4 - '@rollup/rollup-darwin-arm64': 4.1.4 - '@rollup/rollup-darwin-x64': 4.1.4 - '@rollup/rollup-linux-arm-gnueabihf': 4.1.4 - '@rollup/rollup-linux-arm64-gnu': 4.1.4 - '@rollup/rollup-linux-arm64-musl': 4.1.4 - '@rollup/rollup-linux-x64-gnu': 4.1.4 - '@rollup/rollup-linux-x64-musl': 4.1.4 - '@rollup/rollup-win32-arm64-msvc': 4.1.4 - '@rollup/rollup-win32-ia32-msvc': 4.1.4 - '@rollup/rollup-win32-x64-msvc': 4.1.4 + '@rollup/rollup-android-arm-eabi': 4.41.1 + '@rollup/rollup-android-arm64': 4.41.1 + '@rollup/rollup-darwin-arm64': 4.41.1 + '@rollup/rollup-darwin-x64': 4.41.1 + '@rollup/rollup-freebsd-arm64': 4.41.1 + '@rollup/rollup-freebsd-x64': 4.41.1 + '@rollup/rollup-linux-arm-gnueabihf': 4.41.1 + '@rollup/rollup-linux-arm-musleabihf': 4.41.1 + '@rollup/rollup-linux-arm64-gnu': 4.41.1 + '@rollup/rollup-linux-arm64-musl': 4.41.1 + '@rollup/rollup-linux-loongarch64-gnu': 4.41.1 + '@rollup/rollup-linux-powerpc64le-gnu': 4.41.1 + '@rollup/rollup-linux-riscv64-gnu': 4.41.1 + '@rollup/rollup-linux-riscv64-musl': 4.41.1 + '@rollup/rollup-linux-s390x-gnu': 4.41.1 + '@rollup/rollup-linux-x64-gnu': 4.41.1 + '@rollup/rollup-linux-x64-musl': 4.41.1 + '@rollup/rollup-win32-arm64-msvc': 4.41.1 + '@rollup/rollup-win32-ia32-msvc': 4.41.1 + '@rollup/rollup-win32-x64-msvc': 4.41.1 fsevents: 2.3.3 - dev: true - - /run-async@2.4.1: - resolution: {integrity: sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ==} - engines: {node: '>=0.12.0'} - dev: true - /run-parallel@1.2.0: - resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} + run-parallel@1.2.0: dependencies: queue-microtask: 1.2.3 - dev: true - - /rxjs@7.8.1: - resolution: {integrity: sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==} - dependencies: - tslib: 2.6.2 - dev: true - - /sade@1.8.1: - resolution: {integrity: sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==} - engines: {node: '>=6'} - dependencies: - mri: 1.2.0 - dev: true - - /safe-array-concat@1.0.0: - resolution: {integrity: sha512-9dVEFruWIsnie89yym+xWTAYASdpw3CJV7Li/6zBewGf9z2i1j31rP6jnY0pHEO4QZh6N0K11bFjWmdR8UGdPQ==} - engines: {node: '>=0.4'} - dependencies: - call-bind: 1.0.2 - get-intrinsic: 1.2.1 - has-symbols: 1.0.3 - isarray: 2.0.5 - dev: true - /safe-buffer@5.2.1: - resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} - dev: true - - /safe-regex-test@1.0.0: - resolution: {integrity: sha512-JBUUzyOgEwXQY1NuPtvcj/qcBDbDmEvWufhlnXZIm75DEHp+afM1r1ujJpJsV/gSM4t59tpDyPi1sd6ZaPFfsA==} - dependencies: - call-bind: 1.0.2 - get-intrinsic: 1.2.1 - is-regex: 1.1.4 - dev: true + safe-buffer@5.2.1: {} - /safe-regex@2.1.1: - resolution: {integrity: sha512-rx+x8AMzKb5Q5lQ95Zoi6ZbJqwCLkqi3XuJXp5P3rT8OEc6sZCJG5AE5dU3lsgRr/F4Bs31jSlVN+j5KrsGu9A==} + safe-regex@2.1.1: dependencies: regexp-tree: 0.1.27 - dev: true - /safer-buffer@2.1.2: - resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==} - dev: true - - /sander@0.5.1: - resolution: {integrity: sha512-3lVqBir7WuKDHGrKRDn/1Ye3kwpXaDOMsiRP1wd6wpZW56gJhsbp5RqQpA6JG/P+pkXizygnr1dKR8vzWaVsfA==} - dependencies: - es6-promise: 3.3.1 - graceful-fs: 4.2.11 - mkdirp: 0.5.6 - rimraf: 2.7.1 - dev: true - - /semver@7.5.4: - resolution: {integrity: sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==} - engines: {node: '>=10'} - hasBin: true - dependencies: - lru-cache: 6.0.0 - dev: true + safe-stable-stringify@2.5.0: {} - /serialize-javascript@6.0.0: - resolution: {integrity: sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==} - dependencies: - randombytes: 2.1.0 - dev: true + semver@7.7.1: {} - /serialize-javascript@6.0.1: - resolution: {integrity: sha512-owoXEFjWRllis8/M1Q+Cw5k8ZH40e3zhp/ovX+Xr/vi1qj6QesbyXXViFbpNvWvPNAD62SutwEXavefrLJWj7w==} + serialize-javascript@6.0.2: dependencies: randombytes: 2.1.0 - dev: true - /set-cookie-parser@2.6.0: - resolution: {integrity: sha512-RVnVQxTXuerk653XfuliOxBP81Sf0+qfQE73LIYKcyMYHG94AuH0kgrQpRDuTZnSmjpysHmzxJXKNfa6PjFhyQ==} - dev: true - - /shebang-command@2.0.0: - resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} - engines: {node: '>=8'} + shebang-command@2.0.0: dependencies: shebang-regex: 3.0.0 - dev: true - - /shebang-regex@3.0.0: - resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} - engines: {node: '>=8'} - dev: true - - /shellwords@0.1.1: - resolution: {integrity: sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==} - dev: true - /side-channel@1.0.4: - resolution: {integrity: sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==} - dependencies: - call-bind: 1.0.2 - get-intrinsic: 1.2.1 - object-inspect: 1.12.3 - dev: true + shebang-regex@3.0.0: {} - /signal-exit@3.0.7: - resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==} - dev: true + shellwords@0.1.1: {} - /sirv@2.0.3: - resolution: {integrity: sha512-O9jm9BsID1P+0HOi81VpXPoDxYP374pkOLzACAoyUQ/3OUVndNpsz6wMnY2z+yOxzbllCKZrM+9QrWsv4THnyA==} - engines: {node: '>= 10'} + sirv@3.0.1: dependencies: - '@polka/url': 1.0.0-next.21 - mrmime: 1.0.1 + '@polka/url': 1.0.0-next.28 + mrmime: 2.0.1 totalist: 3.0.1 - dev: true - /slash@3.0.0: - resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} - engines: {node: '>=8'} - dev: true + sisteransi@1.0.5: {} - /smob@1.4.0: - resolution: {integrity: sha512-MqR3fVulhjWuRNSMydnTlweu38UhQ0HXM4buStD/S3mc/BzX3CuM9OmhyQpmtYCvoYdl5ris6TI0ZqH355Ymqg==} - dev: true + slash@3.0.0: {} - /sorcery@0.11.0: - resolution: {integrity: sha512-J69LQ22xrQB1cIFJhPfgtLuI6BpWRiWu1Y3vSsIwK/eAScqJxd/+CJlUuHQRdX2C9NGFamq+KqNywGgaThwfHw==} - hasBin: true + smob@1.5.0: {} + + sonic-boom@4.2.0: dependencies: - '@jridgewell/sourcemap-codec': 1.4.15 - buffer-crc32: 0.2.13 - minimist: 1.2.8 - sander: 0.5.1 - dev: true + atomic-sleep: 1.0.0 - /source-map-js@1.0.2: - resolution: {integrity: sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==} - engines: {node: '>=0.10.0'} + source-map-js@1.2.1: {} - /source-map-support@0.5.21: - resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==} + source-map-support@0.5.21: dependencies: buffer-from: 1.1.2 source-map: 0.6.1 - dev: true - /source-map@0.6.1: - resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} - engines: {node: '>=0.10.0'} - dev: true + source-map@0.6.1: {} - /stacktrace-parser@0.1.10: - resolution: {integrity: sha512-KJP1OCML99+8fhOHxwwzyWrlUuVX5GQ0ZpJTd1DFXhdkrvg1szxfHhawXUZ3g9TkXORQd4/WG68jMlQZ2p8wlg==} - engines: {node: '>=6'} + split2@4.2.0: {} + + stacktrace-parser@0.1.11: dependencies: type-fest: 0.7.1 - dev: true - /string-natural-compare@3.0.1: - resolution: {integrity: sha512-n3sPwynL1nwKi3WJ6AIsClwBMa0zTi54fn2oLU6ndfTSIO05xaznjSf15PcBZU6FNWbmN5Q6cxT4V5hGvB4taw==} - dev: true - - /string-width@4.2.3: - resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} - engines: {node: '>=8'} + string-width@4.2.3: dependencies: emoji-regex: 8.0.0 is-fullwidth-code-point: 3.0.0 strip-ansi: 6.0.1 - dev: true - - /string.prototype.trim@1.2.7: - resolution: {integrity: sha512-p6TmeT1T3411M8Cgg9wBTMRtY2q9+PNy9EV1i2lIXUN/btt763oIfxwN3RR8VU6wHX8j/1CFy0L+YuThm6bgOg==} - engines: {node: '>= 0.4'} - dependencies: - call-bind: 1.0.2 - define-properties: 1.2.0 - es-abstract: 1.22.1 - dev: true - - /string.prototype.trimend@1.0.6: - resolution: {integrity: sha512-JySq+4mrPf9EsDBEDYMOb/lM7XQLulwg5R/m1r0PXEFqrV0qHvl58sdTilSXtKOflCsK2E8jxf+GKC0T07RWwQ==} - dependencies: - call-bind: 1.0.2 - define-properties: 1.2.0 - es-abstract: 1.22.1 - dev: true - /string.prototype.trimstart@1.0.6: - resolution: {integrity: sha512-omqjMDaY92pbn5HOX7f9IccLA+U1tA9GvtU4JrodiXFfYB7jPzzHpRzpglLAjtUV6bB557zwClJezTqnAiYnQA==} - dependencies: - call-bind: 1.0.2 - define-properties: 1.2.0 - es-abstract: 1.22.1 - dev: true - - /string_decoder@1.3.0: - resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==} + string_decoder@1.3.0: dependencies: safe-buffer: 5.2.1 - dev: true - /strip-ansi@6.0.1: - resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} - engines: {node: '>=8'} + strip-ansi@6.0.1: dependencies: ansi-regex: 5.0.1 - dev: true - - /strip-bom@3.0.0: - resolution: {integrity: sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==} - engines: {node: '>=4'} - dev: true - - /strip-final-newline@2.0.0: - resolution: {integrity: sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==} - engines: {node: '>=6'} - dev: true - - /strip-final-newline@3.0.0: - resolution: {integrity: sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==} - engines: {node: '>=12'} - dev: true - - /strip-indent@3.0.0: - resolution: {integrity: sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==} - engines: {node: '>=8'} - dependencies: - min-indent: 1.0.1 - dev: true - - /strip-json-comments@3.1.1: - resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==} - engines: {node: '>=8'} - dev: true - /super-regex@0.2.0: - resolution: {integrity: sha512-WZzIx3rC1CvbMDloLsVw0lkZVKJWbrkJ0k1ghKFmcnPrW1+jWbgTkTEWVtD9lMdmI4jZEz40+naBxl1dCUhXXw==} - engines: {node: '>=14.16'} - dependencies: - clone-regexp: 3.0.0 - function-timeout: 0.1.1 - time-span: 5.1.0 - dev: true + strip-json-comments@3.1.1: {} - /supports-color@7.2.0: - resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} - engines: {node: '>=8'} + supports-color@7.2.0: dependencies: has-flag: 4.0.0 - dev: true - /supports-color@8.1.1: - resolution: {integrity: sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==} - engines: {node: '>=10'} + supports-color@8.1.1: dependencies: has-flag: 4.0.0 - dev: true - - /supports-preserve-symlinks-flag@1.0.0: - resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==} - engines: {node: '>= 0.4'} - dev: true - - /svelte-check@3.5.2(svelte@4.2.2): - resolution: {integrity: sha512-5a/YWbiH4c+AqAUP+0VneiV5bP8YOk9JL3jwvN+k2PEPLgpu85bjQc5eE67+eIZBBwUEJzmO3I92OqKcqbp3fw==} - hasBin: true - peerDependencies: - svelte: ^3.55.0 || ^4.0.0-next.0 || ^4.0.0 - dependencies: - '@jridgewell/trace-mapping': 0.3.18 - chokidar: 3.5.3 - fast-glob: 3.3.1 - import-fresh: 3.3.0 - picocolors: 1.0.0 - sade: 1.8.1 - svelte: 4.2.2 - svelte-preprocess: 5.0.4(svelte@4.2.2)(typescript@5.2.2) - typescript: 5.2.2 - transitivePeerDependencies: - - '@babel/core' - - coffeescript - - less - - postcss - - postcss-load-config - - pug - - sass - - stylus - - sugarss - dev: true - - /svelte-hmr@0.15.3(svelte@4.2.2): - resolution: {integrity: sha512-41snaPswvSf8TJUhlkoJBekRrABDXDMdpNpT2tfHIv4JuhgvHqLMhEPGtaQn0BmbNSTkuz2Ed20DF2eHw0SmBQ==} - engines: {node: ^12.20 || ^14.13.1 || >= 16} - peerDependencies: - svelte: ^3.19.0 || ^4.0.0 - dependencies: - svelte: 4.2.2 - dev: true - /svelte-preprocess@5.0.4(svelte@4.2.2)(typescript@5.2.2): - resolution: {integrity: sha512-ABia2QegosxOGsVlsSBJvoWeXy1wUKSfF7SWJdTjLAbx/Y3SrVevvvbFNQqrSJw89+lNSsM58SipmZJ5SRi5iw==} - engines: {node: '>= 14.10.0'} - requiresBuild: true - peerDependencies: - '@babel/core': ^7.10.2 - coffeescript: ^2.5.1 - less: ^3.11.3 || ^4.0.0 - postcss: ^7 || ^8 - postcss-load-config: ^2.1.0 || ^3.0.0 || ^4.0.0 - pug: ^3.0.0 - sass: ^1.26.8 - stylus: ^0.55.0 - sugarss: ^2.0.0 || ^3.0.0 || ^4.0.0 - svelte: ^3.23.0 || ^4.0.0-next.0 || ^4.0.0 - typescript: '>=3.9.5 || ^4.0.0 || ^5.0.0' - peerDependenciesMeta: - '@babel/core': - optional: true - coffeescript: - optional: true - less: - optional: true - postcss: - optional: true - postcss-load-config: - optional: true - pug: - optional: true - sass: - optional: true - stylus: - optional: true - sugarss: - optional: true - typescript: - optional: true - dependencies: - '@types/pug': 2.0.6 - detect-indent: 6.1.0 - magic-string: 0.27.0 - sorcery: 0.11.0 - strip-indent: 3.0.0 - svelte: 4.2.2 - typescript: 5.2.2 - dev: true - - /svelte@4.2.2: - resolution: {integrity: sha512-My2tytF2e2NnHSpn2M7/3VdXT4JdTglYVUuSuK/mXL2XtulPYbeBfl8Dm1QiaKRn0zoULRnL+EtfZHHP0k4H3A==} - engines: {node: '>=16'} - dependencies: - '@ampproject/remapping': 2.2.1 - '@jridgewell/sourcemap-codec': 1.4.15 - '@jridgewell/trace-mapping': 0.3.18 - acorn: 8.10.0 - aria-query: 5.3.0 - axobject-query: 3.2.1 - code-red: 1.0.3 - css-tree: 2.3.1 - estree-walker: 3.0.3 - is-reference: 3.0.1 + supports-preserve-symlinks-flag@1.0.0: {} + + svelte@5.28.2: + dependencies: + '@ampproject/remapping': 2.3.0 + '@jridgewell/sourcemap-codec': 1.5.0 + '@sveltejs/acorn-typescript': 1.0.5(acorn@8.14.0) + '@types/estree': 1.0.7 + acorn: 8.14.0 + aria-query: 5.3.2 + axobject-query: 4.1.0 + clsx: 2.1.1 + esm-env: 1.2.2 + esrap: 1.4.6 + is-reference: 3.0.3 locate-character: 3.0.0 - magic-string: 0.30.5 - periscopic: 3.1.0 + magic-string: 0.30.17 + zimmerframe: 1.1.2 - /terser@5.19.1: - resolution: {integrity: sha512-27hxBUVdV6GoNg1pKQ7Z5cbR6V9txPVyBA+FQw3BaZ1Wuzvztce5p156DaP0NVZNrMZZ+6iG9Syf7WgMNKDg2Q==} - engines: {node: '>=10'} - hasBin: true + terser@5.39.0: dependencies: - '@jridgewell/source-map': 0.3.5 - acorn: 8.10.0 + '@jridgewell/source-map': 0.3.6 + acorn: 8.14.0 commander: 2.20.3 source-map-support: 0.5.21 - dev: true - - /text-table@0.2.0: - resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==} - dev: true - - /through@2.3.8: - resolution: {integrity: sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==} - dev: true - /time-span@5.1.0: - resolution: {integrity: sha512-75voc/9G4rDIJleOo4jPvN4/YC4GRZrY8yy1uU4lwrB3XEQbWve8zXoO5No4eFrGcTAMYyoY67p8jRQdtA1HbA==} - engines: {node: '>=12'} + thread-stream@3.1.0: dependencies: - convert-hrtime: 5.0.0 - dev: true + real-require: 0.2.0 - /tiny-glob@0.2.9: - resolution: {integrity: sha512-g/55ssRPUjShh+xkfx9UPDXqhckHEsHr4Vd9zX55oSdGZc/MD0m3sferOkwWtp98bv+kcVfEHtRJgBVJzelrzg==} - dependencies: - globalyzer: 0.1.0 - globrex: 0.1.2 - dev: true + tinyexec@0.3.2: {} - /tmp@0.0.33: - resolution: {integrity: sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==} - engines: {node: '>=0.6.0'} + tinyglobby@0.2.13: dependencies: - os-tmpdir: 1.0.2 - dev: true + fdir: 6.4.4(picomatch@4.0.2) + picomatch: 4.0.2 - /to-regex-range@5.0.1: - resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} - engines: {node: '>=8.0'} + to-regex-range@5.0.1: dependencies: is-number: 7.0.0 - dev: true - - /totalist@3.0.1: - resolution: {integrity: sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==} - engines: {node: '>=6'} - dev: true - - /tr46@0.0.3: - resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} - dev: true - - /trough@1.0.5: - resolution: {integrity: sha512-rvuRbTarPXmMb79SmzEp8aqXNKcK+y0XaB298IXueQ8I2PsrATcPBCSPyK/dDNa2iWOhKlfNnOjdAOTBU/nkFA==} - dev: true - - /ts-api-utils@1.0.1(typescript@5.2.2): - resolution: {integrity: sha512-lC/RGlPmwdrIBFTX59wwNzqh7aR2otPNPR/5brHZm/XKFYKsfqxihXUe9pU3JI+3vGkl+vyCoNNnPhJn3aLK1A==} - engines: {node: '>=16.13.0'} - peerDependencies: - typescript: '>=4.2.0' - dependencies: - typescript: 5.2.2 - dev: true - /tsconfig-paths@3.14.2: - resolution: {integrity: sha512-o/9iXgCYc5L/JxCHPe3Hvh8Q/2xm5Z+p18PESBU6Ff33695QnCHBEjcytY2q19ua7Mbl/DavtBOLq+oG0RCL+g==} - dependencies: - '@types/json5': 0.0.29 - json5: 1.0.2 - minimist: 1.2.8 - strip-bom: 3.0.0 - dev: true + totalist@3.0.1: {} - /tslib@2.6.0: - resolution: {integrity: sha512-7At1WUettjcSRHXCyYtTselblcHl9PJFFVKiCAy/bY97+BPZXSQ2wbq0P9s8tK2G7dFQfNnlJnPAiArVBVBsfA==} - dev: true + tr46@0.0.3: {} - /tslib@2.6.2: - resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} - dev: true + trough@1.0.5: {} - /type-check@0.4.0: - resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} - engines: {node: '>= 0.8.0'} + ts-api-utils@2.1.0(typescript@5.8.3): dependencies: - prelude-ls: 1.2.1 - dev: true - - /type-fest@0.20.2: - resolution: {integrity: sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==} - engines: {node: '>=10'} - dev: true + typescript: 5.8.3 - /type-fest@0.21.3: - resolution: {integrity: sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==} - engines: {node: '>=10'} - dev: true - - /type-fest@0.7.1: - resolution: {integrity: sha512-Ne2YiiGN8bmrmJJEuTWTLJR32nh/JdL1+PSicowtNb0WFpn59GK8/lfD61bVtzguz7b3PBt74nxpv/Pw5po5Rg==} - engines: {node: '>=8'} - dev: true + tslib@2.8.1: {} - /typed-array-buffer@1.0.0: - resolution: {integrity: sha512-Y8KTSIglk9OZEr8zywiIHG/kmQ7KWyjseXs1CbSo8vC42w7hg2HgYTxSWwP0+is7bWDc1H+Fo026CpHFwm8tkw==} - engines: {node: '>= 0.4'} + tsx@4.19.2: dependencies: - call-bind: 1.0.2 - get-intrinsic: 1.2.1 - is-typed-array: 1.1.12 - dev: true + esbuild: 0.25.3 + get-tsconfig: 4.10.0 + optionalDependencies: + fsevents: 2.3.3 + optional: true - /typed-array-byte-length@1.0.0: - resolution: {integrity: sha512-Or/+kvLxNpeQ9DtSydonMxCx+9ZXOswtwJn17SNLvhptaXYDJvkFFP5zbfU/uLmvnBJlI4yrnXRxpdWH/M5tNA==} - engines: {node: '>= 0.4'} + type-check@0.4.0: dependencies: - call-bind: 1.0.2 - for-each: 0.3.3 - has-proto: 1.0.1 - is-typed-array: 1.1.12 - dev: true + prelude-ls: 1.2.1 - /typed-array-byte-offset@1.0.0: - resolution: {integrity: sha512-RD97prjEt9EL8YgAgpOkf3O4IF9lhJFr9g0htQkm0rchFp/Vx7LW5Q8fSXXub7BXAODyUQohRMyOc3faCPd0hg==} - engines: {node: '>= 0.4'} - dependencies: - available-typed-arrays: 1.0.5 - call-bind: 1.0.2 - for-each: 0.3.3 - has-proto: 1.0.1 - is-typed-array: 1.1.12 - dev: true + type-fest@0.7.1: {} - /typed-array-length@1.0.4: - resolution: {integrity: sha512-KjZypGq+I/H7HI5HlOoGHkWUUGq+Q0TPhQurLbyrVrvnKTBgzLhIJ7j6J/XTQOi0d1RjyZ0wdas8bKs2p0x3Ng==} + typescript-eslint@8.34.0(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3): dependencies: - call-bind: 1.0.2 - for-each: 0.3.3 - is-typed-array: 1.1.12 - dev: true - - /typescript@5.2.2: - resolution: {integrity: sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==} - engines: {node: '>=14.17'} - hasBin: true - dev: true - - /ufo@1.3.1: - resolution: {integrity: sha512-uY/99gMLIOlJPwATcMVYfqDSxUR9//AUcgZMzwfSTJPDKzA1S8mX4VLqa+fiAtveraQUBCz4FFcwVZBGbwBXIw==} - dev: true + '@typescript-eslint/eslint-plugin': 8.34.0(@typescript-eslint/parser@8.34.0(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3))(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3) + '@typescript-eslint/parser': 8.34.0(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3) + '@typescript-eslint/utils': 8.34.0(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3) + eslint: 9.28.0(jiti@2.4.2) + typescript: 5.8.3 + transitivePeerDependencies: + - supports-color - /unbox-primitive@1.0.2: - resolution: {integrity: sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==} - dependencies: - call-bind: 1.0.2 - has-bigints: 1.0.2 - has-symbols: 1.0.3 - which-boxed-primitive: 1.0.2 - dev: true + typescript@5.8.3: {} - /unconfig@0.3.11: - resolution: {integrity: sha512-bV/nqePAKv71v3HdVUn6UefbsDKQWRX+bJIkiSm0+twIds6WiD2bJLWWT3i214+J/B4edufZpG2w7Y63Vbwxow==} - dependencies: - '@antfu/utils': 0.7.6 - defu: 6.1.2 - jiti: 1.20.0 - mlly: 1.4.2 - dev: true + ufo@1.5.4: {} - /undici@5.26.4: - resolution: {integrity: sha512-OG+QOf0fTLtazL9P9X7yqWxQ+Z0395Wk6DSkyTxtaq3wQEjIroVe7Y4asCX/vcCxYpNGMnwz8F0qbRYUoaQVMw==} - engines: {node: '>=14.0'} + unconfig@7.0.0: dependencies: - '@fastify/busboy': 2.0.0 - dev: true + '@antfu/utils': 8.1.1 + defu: 6.1.4 + jiti: 2.4.2 - /unified@9.2.2: - resolution: {integrity: sha512-Sg7j110mtefBD+qunSLO1lqOEKdrwBFBrR6Qd8f4uwkhWNlbkaqwHse6e7QvD3AP/MNoJdEDLaf8OxYyoWgorQ==} + unified@9.2.2: dependencies: - '@types/unist': 2.0.7 + '@types/unist': 2.0.11 bail: 1.0.5 extend: 3.0.2 is-buffer: 2.0.5 is-plain-obj: 2.1.0 trough: 1.0.5 vfile: 4.2.1 - dev: true - - /unist-util-stringify-position@2.0.3: - resolution: {integrity: sha512-3faScn5I+hy9VleOq/qNbAd6pAx7iH5jYBMS9I1HgQVijz/4mv5Bvw5iw1sC/90CODiKo81G/ps8AJrISn687g==} - dependencies: - '@types/unist': 2.0.7 - dev: true - /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: - '@unocss/webpack': 0.56.5 - vite: ^2.9.0 || ^3.0.0-0 || ^4.0.0 - peerDependenciesMeta: - '@unocss/webpack': - optional: true - vite: - optional: true - dependencies: - '@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) - '@unocss/preset-attributify': 0.56.5 - '@unocss/preset-icons': 0.56.5 - '@unocss/preset-mini': 0.56.5 - '@unocss/preset-tagify': 0.56.5 - '@unocss/preset-typography': 0.56.5 - '@unocss/preset-uno': 0.56.5 - '@unocss/preset-web-fonts': 0.56.5 - '@unocss/preset-wind': 0.56.5 - '@unocss/reset': 0.56.5 - '@unocss/transformer-attributify-jsx': 0.56.5 - '@unocss/transformer-attributify-jsx-babel': 0.56.5 - '@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(rollup@4.1.4)(vite@4.5.0) - vite: 4.5.0 + unist-util-stringify-position@2.0.3: + dependencies: + '@types/unist': 2.0.11 + + unocss@66.0.0(postcss@8.5.3)(vite@6.3.4(jiti@2.4.2)(terser@5.39.0)(tsx@4.19.2))(vue@3.5.13(typescript@5.8.3)): + dependencies: + '@unocss/astro': 66.0.0(vite@6.3.4(jiti@2.4.2)(terser@5.39.0)(tsx@4.19.2))(vue@3.5.13(typescript@5.8.3)) + '@unocss/cli': 66.0.0 + '@unocss/core': 66.0.0 + '@unocss/postcss': 66.0.0(postcss@8.5.3) + '@unocss/preset-attributify': 66.0.0 + '@unocss/preset-icons': 66.0.0 + '@unocss/preset-mini': 66.0.0 + '@unocss/preset-tagify': 66.0.0 + '@unocss/preset-typography': 66.0.0 + '@unocss/preset-uno': 66.0.0 + '@unocss/preset-web-fonts': 66.0.0 + '@unocss/preset-wind': 66.0.0 + '@unocss/preset-wind3': 66.0.0 + '@unocss/transformer-attributify-jsx': 66.0.0 + '@unocss/transformer-compile-class': 66.0.0 + '@unocss/transformer-directives': 66.0.0 + '@unocss/transformer-variant-group': 66.0.0 + '@unocss/vite': 66.0.0(vite@6.3.4(jiti@2.4.2)(terser@5.39.0)(tsx@4.19.2))(vue@3.5.13(typescript@5.8.3)) + optionalDependencies: + vite: 6.3.4(jiti@2.4.2)(terser@5.39.0)(tsx@4.19.2) transitivePeerDependencies: - postcss - - rollup - supports-color - dev: true + - vue - /uri-js@4.4.1: - resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} + unplugin-utils@0.2.4: dependencies: - punycode: 2.3.0 - dev: true + pathe: 2.0.3 + picomatch: 4.0.2 - /util-deprecate@1.0.2: - resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} - dev: true + uri-js@4.4.1: + dependencies: + punycode: 2.3.1 - /vfile-message@2.0.4: - resolution: {integrity: sha512-DjssxRGkMvifUOJre00juHoP9DPWuzjxKuMDrhNbk2TdaYYBNMStsNhEOt3idrtI12VQYM/1+iM0KOzXi4pxwQ==} + vfile-message@2.0.4: dependencies: - '@types/unist': 2.0.7 + '@types/unist': 2.0.11 unist-util-stringify-position: 2.0.3 - dev: true - /vfile@4.2.1: - resolution: {integrity: sha512-O6AE4OskCG5S1emQ/4gl8zK586RqA3srz3nfK/Viy0UPToBc5Trp9BVFb1u0CjsKrAWwnpr4ifM/KBXPWwJbCA==} + vfile@4.2.1: dependencies: - '@types/unist': 2.0.7 + '@types/unist': 2.0.11 is-buffer: 2.0.5 unist-util-stringify-position: 2.0.3 vfile-message: 2.0.4 - dev: true - /vite@4.5.0: - resolution: {integrity: sha512-ulr8rNLA6rkyFAlVWw2q5YJ91v098AFQ2R0PRFwPzREXOUJQPtFUG0t+/ZikhaOCDqFoDhN6/v8Sq0o4araFAw==} - engines: {node: ^14.18.0 || >=16.0.0} - hasBin: true - peerDependencies: - '@types/node': '>= 14' - less: '*' - lightningcss: ^1.21.0 - sass: '*' - stylus: '*' - sugarss: '*' - terser: ^5.4.0 - peerDependenciesMeta: - '@types/node': - optional: true - less: - optional: true - lightningcss: - optional: true - sass: - optional: true - stylus: - optional: true - sugarss: - optional: true - terser: - optional: true + vite@6.3.4(jiti@2.4.2)(terser@5.39.0)(tsx@4.19.2): dependencies: - esbuild: 0.18.14 - postcss: 8.4.31 - rollup: 3.29.4 + esbuild: 0.25.3 + fdir: 6.4.4(picomatch@4.0.2) + picomatch: 4.0.2 + postcss: 8.5.3 + rollup: 4.41.1 + tinyglobby: 0.2.13 optionalDependencies: fsevents: 2.3.3 - dev: true + jiti: 2.4.2 + terser: 5.39.0 + tsx: 4.19.2 - /vitefu@0.2.4(vite@4.5.0): - resolution: {integrity: sha512-fanAXjSaf9xXtOOeno8wZXIhgia+CZury481LsDaV++lSvcU2R9Ch2bPh3PYFyoHW+w9LqAeYRISVQjUIew14g==} - peerDependencies: - vite: ^3.0.0 || ^4.0.0 - peerDependenciesMeta: - vite: - optional: true + vitefu@1.0.6(vite@6.3.4(jiti@2.4.2)(terser@5.39.0)(tsx@4.19.2)): + optionalDependencies: + vite: 6.3.4(jiti@2.4.2)(terser@5.39.0)(tsx@4.19.2) + + vue-flow-layout@0.1.1(vue@3.5.13(typescript@5.8.3)): dependencies: - vite: 4.5.0 - dev: true + vue: 3.5.13(typescript@5.8.3) - /wcwidth@1.0.1: - resolution: {integrity: sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==} + vue@3.5.13(typescript@5.8.3): dependencies: - defaults: 1.0.4 - dev: true + '@vue/compiler-dom': 3.5.13 + '@vue/compiler-sfc': 3.5.13 + '@vue/runtime-dom': 3.5.13 + '@vue/server-renderer': 3.5.13(vue@3.5.13(typescript@5.8.3)) + '@vue/shared': 3.5.13 + optionalDependencies: + typescript: 5.8.3 - /webidl-conversions@3.0.1: - resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} - dev: true + webidl-conversions@3.0.1: {} - /whatwg-url@5.0.0: - resolution: {integrity: sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==} + whatwg-url@5.0.0: dependencies: tr46: 0.0.3 webidl-conversions: 3.0.1 - dev: true - /which-boxed-primitive@1.0.2: - resolution: {integrity: sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==} - dependencies: - is-bigint: 1.0.4 - is-boolean-object: 1.1.2 - is-number-object: 1.0.7 - is-string: 1.0.7 - is-symbol: 1.0.4 - dev: true - - /which-typed-array@1.1.11: - resolution: {integrity: sha512-qe9UWWpkeG5yzZ0tNYxDmd7vo58HDBc39mZ0xWWpolAGADdFOzkfamWLDxkOWcvHQKVmdTyQdLD4NOfjLWTKew==} - engines: {node: '>= 0.4'} - dependencies: - available-typed-arrays: 1.0.5 - call-bind: 1.0.2 - for-each: 0.3.3 - gopd: 1.0.1 - has-tostringtag: 1.0.0 - dev: true - - /which@2.0.2: - resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} - engines: {node: '>= 8'} - hasBin: true + which@2.0.2: dependencies: isexe: 2.0.0 - dev: true - /workerpool@6.2.1: - resolution: {integrity: sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==} - dev: true + word-wrap@1.2.5: {} - /wrap-ansi@7.0.0: - resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==} - engines: {node: '>=10'} + workerpool@6.5.1: {} + + wrap-ansi@7.0.0: dependencies: ansi-styles: 4.3.0 string-width: 4.2.3 strip-ansi: 6.0.1 - dev: true - - /wrappy@1.0.2: - resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} - dev: true - /y18n@5.0.8: - resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==} - engines: {node: '>=10'} - dev: true + wrappy@1.0.2: {} - /yallist@4.0.0: - resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==} - dev: true + y18n@5.0.8: {} - /yargs-parser@20.2.4: - resolution: {integrity: sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==} - engines: {node: '>=10'} - dev: true + yargs-parser@20.2.9: {} - /yargs-parser@21.1.1: - resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==} - engines: {node: '>=12'} - dev: true + yargs-parser@21.1.1: {} - /yargs-unparser@2.0.0: - resolution: {integrity: sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==} - engines: {node: '>=10'} + yargs-unparser@2.0.0: dependencies: camelcase: 6.3.0 decamelize: 4.0.0 flat: 5.0.2 is-plain-obj: 2.1.0 - dev: true - /yargs@16.2.0: - resolution: {integrity: sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==} - engines: {node: '>=10'} + yargs@16.2.0: dependencies: cliui: 7.0.4 - escalade: 3.1.1 + escalade: 3.2.0 get-caller-file: 2.0.5 require-directory: 2.1.1 string-width: 4.2.3 y18n: 5.0.8 - yargs-parser: 20.2.4 - dev: true + yargs-parser: 20.2.9 - /yargs@17.7.2: - resolution: {integrity: sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==} - engines: {node: '>=12'} + yargs@17.7.2: dependencies: cliui: 8.0.1 - escalade: 3.1.1 + escalade: 3.2.0 get-caller-file: 2.0.5 require-directory: 2.1.1 string-width: 4.2.3 y18n: 5.0.8 yargs-parser: 21.1.1 - dev: true - /yocto-queue@0.1.0: - resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} - engines: {node: '>=10'} - dev: true + yocto-queue@0.1.0: {} - /zod-validation-error@1.5.0(zod@3.22.4): - resolution: {integrity: sha512-/7eFkAI4qV0tcxMBB/3+d2c1P6jzzZYdYSlBuAklzMuCrJu5bzJfHS0yVAS87dRHVlhftd6RFJDIvv03JgkSbw==} - engines: {node: '>=16.0.0'} - peerDependencies: - zod: ^3.18.0 + zimmerframe@1.1.2: {} + + zod-validation-error@1.5.0(zod@3.24.2): dependencies: - zod: 3.22.4 - dev: true + zod: 3.24.2 - /zod@3.22.4: - resolution: {integrity: sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==} - dev: true + zod@3.24.2: {} - /zwitch@1.0.5: - resolution: {integrity: sha512-V50KMwwzqJV0NpZIZFwfOD5/lyny3WlSzRiXgA0G7VUnRlqttta1L6UQIHzd6EuBY/cHGfwTIck7w1yH6Q5zUw==} - dev: true + zwitch@1.0.5: {} diff --git a/renovate.json b/renovate.json index 2eddfb44..f0c3d6ea 100644 --- a/renovate.json +++ b/renovate.json @@ -1,7 +1,8 @@ { - "extends": ["config:base"], + "extends": ["config:recommended"], + "baseBranches": ["v2", "v1"], "enabledManagers": ["cargo", "npm"], - "semanticCommitType": "chore", + "labels": ["dependencies"], "ignorePaths": [ "**/node_modules/**", "**/bower_components/**", @@ -9,14 +10,21 @@ "**/__tests__/**", "**/test/**", "**/tests/**", - "**/__fixtures__/**" + "**/__fixtures__/**", + "shared/**" ], + "rangeStrategy": "replace", "packageRules": [ + { + "semanticCommitType": "chore", + "matchPackageNames": ["*"] + }, { "description": "Disable node/pnpm version updates", "matchPackageNames": ["node", "pnpm"], "matchDepTypes": ["engines", "packageManager"], "enabled": false } - ] + ], + "postUpdateOptions": ["pnpmDedupe"] } diff --git a/shared/rollup.config.js b/shared/rollup.config.js new file mode 100644 index 00000000..3afb1b89 --- /dev/null +++ b/shared/rollup.config.js @@ -0,0 +1,92 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import { readFileSync } from 'node:fs' +import { dirname, join } from 'node:path' +import { cwd } from 'node:process' +import { nodeResolve } from '@rollup/plugin-node-resolve' +import typescript from '@rollup/plugin-typescript' +import terser from '@rollup/plugin-terser' + +/** + * Create a base rollup config + * + * @param {object} [options] Configuration object + * @param {string} [options.input] Input path + * @param {import('rollup').ExternalOption} [options.external] External dependencies list + * @param {import('rollup').RollupOptions | import('rollup').RollupOptions[]} [options.additionalConfigs] Additional rollup configurations + * + * @returns {import('rollup').RollupOptions} + */ +export function createConfig(options = {}) { + const { + input = 'guest-js/index.ts', + external = [/^@tauri-apps\/api/], + additionalConfigs = [] + } = options + + // eslint-disable-next-line security/detect-non-literal-fs-filename + const pkg = JSON.parse(readFileSync(join(cwd(), 'package.json'), 'utf8')) + + const pluginJsName = pkg.name + .replace('@tauri-apps/plugin-', '') + .replace(/-./g, (x) => x[1].toUpperCase()) + const iifeVarName = `__TAURI_PLUGIN_${pkg.name + .replace('@tauri-apps/plugin-', '') + .replace('-', (x) => '_') + .toUpperCase()}__` + + return [ + { + input, + output: [ + { + file: pkg.exports.import, + format: 'esm' + }, + { + file: pkg.exports.require, + format: 'cjs' + } + ], + plugins: [ + typescript({ + declaration: true, + declarationDir: dirname(pkg.exports.import) + }) + ], + external: [ + ...external, + ...Object.keys(pkg.dependencies || {}), + ...Object.keys(pkg.peerDependencies || {}) + ], + onwarn: (warning) => { + throw Object.assign(new Error(), warning) + } + }, + + { + input, + output: { + format: 'iife', + name: iifeVarName, + // IIFE is in the format `var ${iifeVarName} = (() => {})()` + // we check if __TAURI__ exists and inject the API object + banner: "if ('__TAURI__' in window) {", + // the last `}` closes the if in the banner + footer: `Object.defineProperty(window.__TAURI__, '${pluginJsName}', { value: ${iifeVarName} }) }`, + file: 'api-iife.js' + }, + // and var is not guaranteed to assign to the global `window` object so we make sure to assign it + plugins: [typescript(), terser(), nodeResolve()], + onwarn: (warning) => { + throw Object.assign(new Error(), warning) + } + }, + + ...(Array.isArray(additionalConfigs) + ? additionalConfigs + : [additionalConfigs]) + ] +} diff --git a/shared/rollup.config.mjs b/shared/rollup.config.mjs deleted file mode 100644 index 95042f8c..00000000 --- a/shared/rollup.config.mjs +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2019-2023 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - -import { builtinModules } from "module"; - -import typescript from "@rollup/plugin-typescript"; -import resolve from "@rollup/plugin-node-resolve"; -import terser from "@rollup/plugin-terser"; - -/** - * Create a base rollup config - * @param {Record} pkg Imported package.json - * @param {string[]} external Imported package.json - * @returns {import('rollup').RollupOptions} - */ -export function createConfig({ input = "index.ts", pkg, external = [] }) { - const pluginJsName = pkg.name - .replace("@tauri-apps/plugin-", "") - .replace(/-./g, (x) => x[1].toUpperCase()); - const iifeVarName = `__TAURI_${pluginJsName.toUpperCase()}__`; - return [ - { - input, - external: Object.keys(pkg.dependencies || {}) - .concat(Object.keys(pkg.peerDependencies || {})) - .concat(builtinModules) - .concat(external), - onwarn: (warning) => { - throw Object.assign(new Error(), warning); - }, - strictDeprecations: true, - output: { - file: pkg.module, - format: "es", - sourcemap: true, - }, - plugins: [typescript({ sourceMap: true })], - }, - { - input, - onwarn: (warning) => { - throw Object.assign(new Error(), warning); - }, - strictDeprecations: true, - output: { - file: pkg.browser, - format: "es", - sourcemap: true, - entryFileNames: "[name].min.js", - }, - plugins: [ - resolve(), - // terser(), - typescript({ sourceMap: true }), - ], - }, - { - input, - output: { - file: "src/api-iife.js", - format: "iife", - name: iifeVarName, - // IIFE is in the format `var ${iifeVarName} = (() => {})()` - // we check if __TAURI__ exists and inject the API object - banner: "if ('__TAURI__' in window) {", - // the last `}` closes the if in the banner - footer: `Object.defineProperty(window.__TAURI__, '${pluginJsName}', { value: ${iifeVarName} }) }`, - }, - // and var is not guaranteed to assign to the global `window` object so we make sure to assign it - plugins: [ - resolve(), - typescript({ - sourceMap: false, - declaration: false, - declarationDir: undefined, - }), - terser(), - ], - }, - ]; -} diff --git a/shared/template/.gitignore b/shared/template/.gitignore deleted file mode 100644 index 1b0b469d..00000000 --- a/shared/template/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/.tauri diff --git a/shared/template/Cargo.toml b/shared/template/Cargo.toml index 22fa8075..a672132d 100644 --- a/shared/template/Cargo.toml +++ b/shared/template/Cargo.toml @@ -1,18 +1,31 @@ [package] -name = "tauri-plugin-{{name}}" +name = "tauri-plugin-PLUGIN_NAME" version = "1.0.0" edition = { workspace = true } authors = { workspace = true } license = { workspace = true } -links = "tauri-plugin-{{name}}" +repository = { workspace = true } +links = "tauri-plugin-PLUGIN_NAME" [package.metadata.docs.rs] -features = [ "dox" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] + +# Platforms supported by the plugin +# Support levels are "full", "partial", "none", "unknown" +# Details of the support level are left to plugin maintainer +[package.metadata.platforms] +windows = { level = "unknown", notes = "" } +linux = { level = "unknown", notes = "" } +macos = { level = "unknown", notes = "" } +android = { level = "unknown", notes = "" } +ios = { level = "unknown", notes = "" } -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [build-dependencies] -tauri-build = { workspace = true } +tauri-plugin = { workspace = true, features = ["build"] } + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] serde = { workspace = true } @@ -20,6 +33,3 @@ serde_json = { workspace = true } tauri = { workspace = true } log = { workspace = true } thiserror = { workspace = true } - -[features] -dox = [ "tauri/dox" ] diff --git a/shared/template/README.md b/shared/template/README.md index b7348e9d..5d153499 100644 --- a/shared/template/README.md +++ b/shared/template/README.md @@ -1,10 +1,18 @@ -![{{plugin-name}}](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/{{plugin-name}}/banner.png) +![PLUGIN_NAME](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/PLUGIN_NAME/banner.png) +| Platform | Supported | +| -------- | --------- | +| Linux | ✓ | +| Windows | ✓ | +| macOS | ✓ | +| Android | ✓ | +| iOS | ✓ | + ## Install -_This plugin requires a Rust version of at least **1.70**_ +_This plugin requires a Rust version of at least **1.77.2**_ There are three general methods of installation that we can recommend. @@ -18,9 +26,9 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] -tauri-plugin-{{plugin-name}} = "2.0.0-alpha" +tauri-plugin-PLUGIN_NAME = "2.0.0" # alternatively with Git: -tauri-plugin-{{plugin-name}} = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } +tauri-plugin-PLUGIN_NAME = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` You can install the JavaScript Guest bindings using your preferred JavaScript package manager: @@ -30,30 +38,30 @@ You can install the JavaScript Guest bindings using your preferred JavaScript pa ```sh -pnpm add @tauri-apps/plugin-{{plugin-name}} +pnpm add @tauri-apps/plugin-PLUGIN_NAME # or -npm add @tauri-apps/plugin-{{plugin-name}} +npm add @tauri-apps/plugin-PLUGIN_NAME # or -yarn add @tauri-apps/plugin-{{plugin-name}} +yarn add @tauri-apps/plugin-PLUGIN_NAME # alternatively with Git: -pnpm add https://github.com/tauri-apps/tauri-plugin-{{plugin-name}}#v2 +pnpm add https://github.com/tauri-apps/tauri-plugin-PLUGIN_NAME#v2 # or -npm add https://github.com/tauri-apps/tauri-plugin-{{plugin-name}}#v2 +npm add https://github.com/tauri-apps/tauri-plugin-PLUGIN_NAME#v2 # or -yarn add https://github.com/tauri-apps/tauri-plugin-{{plugin-name}}#v2 +yarn add https://github.com/tauri-apps/tauri-plugin-PLUGIN_NAME#v2 ``` ## Usage First you need to register the core plugin with Tauri: -`src-tauri/src/main.rs` +`src-tauri/src/lib.rs` ```rust fn main() { tauri::Builder::default() - .plugin(tauri_plugin_{{plugin-name}}::init()) + .plugin(tauri_plugin_PLUGIN_NAME::init()) .run(tauri::generate_context!()) .expect("error while running tauri application"); } @@ -69,6 +77,22 @@ Afterwards all the plugin's APIs are available through the JavaScript guest bind PRs accepted. Please make sure to read the Contributing Guide before making a pull request. +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + ## License Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. diff --git a/shared/template/SECURITY.md b/shared/template/SECURITY.md new file mode 100644 index 00000000..4f09bbac --- /dev/null +++ b/shared/template/SECURITY.md @@ -0,0 +1,23 @@ +# Security Policy + +**Do not report security vulnerabilities through public GitHub issues.** + +**Please use the [Private Vulnerability Disclosure](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) feature of GitHub.** + +Include as much of the following information: + +- Type of issue (e.g. improper input parsing, privilege escalation, etc.) +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- The distribution affected or used to help us with reproduction of the issue +- Step-by-step instructions to reproduce the issue +- Ideally a reproduction repository +- Impact of the issue, including how an attacker might exploit the issue + +We prefer to receive reports in English. + +## Contact + +Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). + +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/shared/template/android/build.gradle.kts b/shared/template/android/build.gradle.kts index 804384c3..1d0e9d8e 100644 --- a/shared/template/android/build.gradle.kts +++ b/shared/template/android/build.gradle.kts @@ -5,11 +5,10 @@ plugins { android { namespace = "{{android_package_id}}" - compileSdk = 32 + compileSdk = 34 defaultConfig { - minSdk = 24 - targetSdk = 32 + minSdk = 24 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles("consumer-rules.pro") diff --git a/shared/template/android/src/main/java/ExamplePlugin.kt b/shared/template/android/src/main/java/ExamplePlugin.kt index 9fed811c..2f172974 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 ea12ef85..16a1438a 100644 --- a/shared/template/build.rs +++ b/shared/template/build.rs @@ -2,16 +2,17 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT +const COMMANDS: &[&str] = &["execute"]; + fn main() { - if let Err(error) = tauri_build::mobile::PluginBuilder::new() + let result = tauri_plugin::Builder::new(COMMANDS) + .global_api_script_path("./api-iife.js") .android_path("android") .ios_path("ios") - .run() - { - 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")) { - std::process::exit(1); - } + .try_build(); + + // when building documentation for Android the plugin build result is always Err() and is irrelevant to the crate documentation build + if !(cfg!(docsrs) && std::env::var("TARGET").unwrap().contains("android")) { + result.unwrap(); } } diff --git a/shared/template/ios/Package.swift b/shared/template/ios/Package.swift index e4f53f0b..e4ebd067 100644 --- a/shared/template/ios/Package.swift +++ b/shared/template/ios/Package.swift @@ -6,28 +6,29 @@ import PackageDescription let package = Package( - name: "tauri-plugin-{{ plugin_name }}", - platforms: [ - .iOS(.v13), - ], - products: [ - // Products define the executables and libraries a package produces, and make them visible to other packages. - .library( - name: "tauri-plugin-{{ plugin_name }}", - type: .static, - targets: ["tauri-plugin-{{ plugin_name }}"]), - ], - dependencies: [ - .package(name: "Tauri", path: "../.tauri/tauri-api") - ], - targets: [ - // Targets are the basic building blocks of a package. A target can define a module or a test suite. - // Targets can depend on other targets in this package, and on products in packages this package depends on. - .target( - name: "tauri-plugin-{{ plugin_name }}", - dependencies: [ - .byName(name: "Tauri") - ], - path: "Sources") - ] + name: "tauri-plugin-{{ plugin_name }}", + platforms: [ + .macOS(.v10_13), + .iOS(.v13), + ], + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .library( + name: "tauri-plugin-{{ plugin_name }}", + type: .static, + targets: ["tauri-plugin-{{ plugin_name }}"]) + ], + dependencies: [ + .package(name: "Tauri", path: "../.tauri/tauri-api") + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .target( + name: "tauri-plugin-{{ plugin_name }}", + dependencies: [ + .byName(name: "Tauri") + ], + path: "Sources") + ] ) diff --git a/shared/template/ios/Sources/ExamplePlugin.swift b/shared/template/ios/Sources/ExamplePlugin.swift index 7a36b76b..2a1055de 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 { + var 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 76ba8ee2..75ce480a 100644 --- a/shared/template/package.json +++ b/shared/template/package.json @@ -1,32 +1,29 @@ { - "name": "@tauri-apps/plugin-{{name}}", + "name": "@tauri-apps/plugin-PLUGIN_NAME", "version": "1.0.0", - "license": "MIT or APACHE-2.0", + "license": "MIT OR Apache-2.0", "authors": [ "Tauri Programme within The Commons Conservancy" ], + "repository": "https://github.com/tauri-apps/plugins-workspace", "type": "module", - "browser": "dist-js/index.min.js", - "module": "dist-js/index.mjs", - "types": "dist-js/index.d.ts", + "types": "./dist-js/index.d.ts", + "main": "./dist-js/index.cjs", + "module": "./dist-js/index.js", "exports": { - "import": "./dist-js/index.mjs", "types": "./dist-js/index.d.ts", - "browser": "./dist-js/index.min.js" + "import": "./dist-js/index.js", + "require": "./dist-js/index.cjs" }, "scripts": { "build": "rollup -c" }, "files": [ "dist-js", - "!dist-js/**/*.map", "README.md", "LICENSE" ], - "devDependencies": { - "tslib": "2.6.0" - }, "dependencies": { - "@tauri-apps/api": "2.0.0-alpha.9" + "@tauri-apps/api": "^2.0.0" } } diff --git a/shared/template/rollup.config.js b/shared/template/rollup.config.js new file mode 100644 index 00000000..1f349ec8 --- /dev/null +++ b/shared/template/rollup.config.js @@ -0,0 +1,7 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import { createConfig } from '../../shared/rollup.config.js' + +export default createConfig() diff --git a/shared/template/rollup.config.mjs b/shared/template/rollup.config.mjs deleted file mode 100644 index a71590d2..00000000 --- a/shared/template/rollup.config.mjs +++ /dev/null @@ -1,11 +0,0 @@ -import { readFileSync } from "fs"; - -import { createConfig } from "../rollup.config.mjs"; - -export default createConfig({ - input: "guest-js/index.ts", - pkg: JSON.parse( - readFileSync(new URL("./package.json", import.meta.url), "utf8"), - ), - external: [/^@tauri-apps\/api/], -}); diff --git a/shared/template/src/lib.rs b/shared/template/src/lib.rs index 3e0f7618..5eb337bd 100644 --- a/shared/template/src/lib.rs +++ b/shared/template/src/lib.rs @@ -21,11 +21,11 @@ mod models; pub use error::{Error, Result}; #[cfg(desktop)] -use desktop::{{ plugin_name_pascal_case }}; +pub use desktop::{{ plugin_name_pascal_case }}; #[cfg(mobile)] -use mobile::{{ plugin_name_pascal_case }}; +pub use mobile::{{ plugin_name_pascal_case }}; -/// Extensions to [`tauri::App`], [`tauri::AppHandle`] and [`tauri::Window`] to access the {{ plugin_name }} APIs. +/// Extensions to [`tauri::App`], [`tauri::AppHandle`], [`tauri::WebviewWindow`], [`tauri::Webview`] and [`tauri::Window`] to access the {{ plugin_name }} APIs. pub trait {{ plugin_name_pascal_case }}Ext { fn {{ plugin_name_snake_case }}(&self) -> &{{ plugin_name_pascal_case }}; } @@ -39,7 +39,6 @@ impl> crate::{{ plugin_name_pascal_case }}Ext for T /// Initializes the plugin. pub fn init() -> TauriPlugin { Builder::new("{{ plugin_name }}") - .js_init_script(include_str!("api-iife.js").to_string()) .invoke_handler(tauri::generate_handler![commands::execute]) .setup(|app, api| { #[cfg(mobile)] diff --git a/shared/template/tsconfig.json b/shared/template/tsconfig.json deleted file mode 120000 index 5098169a..00000000 --- a/shared/template/tsconfig.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "include": ["guest-js/*.ts"] -} diff --git a/shared/template/tsconfig.json b/shared/template/tsconfig.json new file mode 100644 index 00000000..5098169a --- /dev/null +++ b/shared/template/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.base.json", + "include": ["guest-js/*.ts"] +} diff --git a/taplo.toml b/taplo.toml new file mode 100644 index 00000000..e628d268 --- /dev/null +++ b/taplo.toml @@ -0,0 +1 @@ +exclude = ["plugins/*/permissions/autogenerated/**.toml"] diff --git a/tsconfig.base.json b/tsconfig.base.json index 629a7c96..b5e2c519 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -1,20 +1,13 @@ { "compilerOptions": { - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "lib": ["ES2019", "ES2020.Promise", "ES2020.String", "DOM", "DOM.Iterable"], - "module": "ESNext", - "moduleResolution": "node", - "noEmit": true, - "noEmitOnError": false, - "noUnusedLocals": true, - "noUnusedParameters": true, - "pretty": true, - "sourceMap": true, + "target": "es2021", + "module": "esnext", + "moduleResolution": "bundler", + "skipLibCheck": true, "strict": true, - "target": "ES2019", - "declaration": true, - "declarationDir": "./" + "noUnusedLocals": true, + "noImplicitAny": true, + "noEmit": true }, "exclude": ["dist-js", "node_modules", "test/types"] }

+

Welcome to Tauri!

+ +
+ +

Click on the Tauri logo to learn more about the framework

+ + + +

+