mirror of
https://github.com/mii443/vrclipboard-ime-gui.git
synced 2025-08-22 16:15:32 +00:00
UI implement
This commit is contained in:
27
.gitignore
vendored
27
.gitignore
vendored
@ -1,24 +1,3 @@
|
||||
# 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?
|
||||
/dist/
|
||||
/target/
|
||||
/Cargo.lock
|
||||
|
3
.taurignore
Normal file
3
.taurignore
Normal file
@ -0,0 +1,3 @@
|
||||
/src
|
||||
/public
|
||||
/Cargo.toml
|
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"emmet.includeLanguages": {
|
||||
"rust": "html"
|
||||
}
|
||||
}
|
20
Cargo.toml
Normal file
20
Cargo.toml
Normal file
@ -0,0 +1,20 @@
|
||||
[package]
|
||||
name = "vrclipboard-ime-gui-ui"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
[dependencies]
|
||||
leptos = { version = "0.7", features = ["csr"] }
|
||||
wasm-bindgen = "0.2"
|
||||
wasm-bindgen-futures = "0.4"
|
||||
js-sys = "0.3"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde-wasm-bindgen = "0.6"
|
||||
console_error_panic_hook = "0.1.7"
|
||||
leptos_router = "0.7"
|
||||
lucide-leptos = "=1.0.0"
|
||||
uuid = { version = "1.0", features = ["v4", "js"] }
|
||||
|
||||
[workspace]
|
||||
members = ["src-tauri"]
|
@ -1,5 +1,7 @@
|
||||
# VRClipboard-IME
|
||||
# Tauri + Leptos
|
||||
|
||||
このソフトウェアはVRChat上のChatBoxで日本語入力を行うためのツールです。
|
||||
This template should help get you started developing with Tauri and Leptos.
|
||||
|
||||
ダウンロードは[こちら](https://vrime.mii.dev)から行えます。
|
||||
## 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).
|
||||
|
9
Trunk.toml
Normal file
9
Trunk.toml
Normal file
@ -0,0 +1,9 @@
|
||||
[build]
|
||||
target = "./index.html"
|
||||
|
||||
[watch]
|
||||
ignore = ["./src-tauri"]
|
||||
|
||||
[serve]
|
||||
port = 1420
|
||||
open = false
|
24
index.html
24
index.html
@ -1,14 +1,14 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Tauri + React + Typescript</title>
|
||||
</head>
|
||||
<html>
|
||||
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Tauri + Leptos App</title>
|
||||
<link data-trunk rel="copy-dir" href="public" />
|
||||
<link data-trunk rel="rust" data-wasm-opt="z" />
|
||||
<link data-trunk rel="tailwind-css" href="style/tailwind.css" />
|
||||
</head>
|
||||
|
||||
<body></body>
|
||||
|
||||
</html>
|
33
node_modules/.package-lock.json
generated
vendored
Normal file
33
node_modules/.package-lock.json
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "vrclipboard-ime-gui",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"node_modules/@tauri-apps/api": {
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@tauri-apps/api/-/api-2.5.0.tgz",
|
||||
"integrity": "sha512-Ldux4ip+HGAcPUmuLT8EIkk6yafl5vK0P0c0byzAKzxJh7vxelVtdPONjfgTm96PbN24yjZNESY8CKo8qniluA==",
|
||||
"license": "Apache-2.0 OR MIT",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/tauri"
|
||||
}
|
||||
},
|
||||
"node_modules/@tauri-apps/plugin-opener": {
|
||||
"version": "2.2.7",
|
||||
"resolved": "https://registry.npmjs.org/@tauri-apps/plugin-opener/-/plugin-opener-2.2.7.tgz",
|
||||
"integrity": "sha512-uduEyvOdjpPOEeDRrhwlCspG/f9EQalHumWBtLBnp3fRp++fKGLqDOyUhSIn7PzX45b/rKep//ZQSAQoIxobLA==",
|
||||
"license": "MIT OR Apache-2.0",
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/tailwindcss": {
|
||||
"version": "4.1.8",
|
||||
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.1.8.tgz",
|
||||
"integrity": "sha512-kjeW8gjdxasbmFKpVGrGd5T4i40mV5J2Rasw48QARfYeQ8YS9x02ON9SFWax3Qf616rt4Cp3nVNIj6Hd1mP3og==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
}
|
960
node_modules/@tauri-apps/api/CHANGELOG.md
generated
vendored
Normal file
960
node_modules/@tauri-apps/api/CHANGELOG.md
generated
vendored
Normal file
@ -0,0 +1,960 @@
|
||||
# Changelog
|
||||
|
||||
## \[2.5.0]
|
||||
|
||||
### New Features
|
||||
|
||||
- [`66e6325f4`](https://www.github.com/tauri-apps/tauri/commit/66e6325f43efa49ec2165c45afec911a1a14ecfb) ([#13136](https://www.github.com/tauri-apps/tauri/pull/13136)) Allow passing the callback as the parameter of constructor of `Channel` so you can use it like this `new Channel((message) => console.log(message))`
|
||||
- [`ea36294cb`](https://www.github.com/tauri-apps/tauri/commit/ea36294cbca98f7725c91d1464fd92e77c89698a) ([#13208](https://www.github.com/tauri-apps/tauri/pull/13208)) Added `disableInputAccessoryView: bool` config for iOS.
|
||||
- [`c1cd0a2dd`](https://www.github.com/tauri-apps/tauri/commit/c1cd0a2ddb5bc3e99451cbe399b5fc9f0035f571) ([#13090](https://www.github.com/tauri-apps/tauri/pull/13090)) macOS/iOS: add option to disable or enable link previews when building a webview (the webkit api has it enabled by default)
|
||||
|
||||
- `WindowOptions::allowLinkPreview`
|
||||
- `WebviewOptions::allowLinkPreview`
|
||||
- [`b072e2b29`](https://www.github.com/tauri-apps/tauri/commit/b072e2b2967640ae4fa1af466ae878c156551edd) ([#9687](https://www.github.com/tauri-apps/tauri/pull/9687)) Add `preventOverflow` config option to prevent the window from overflowing the monitor size on creation
|
||||
- [`dd4f13ce4`](https://www.github.com/tauri-apps/tauri/commit/dd4f13ce4b3cd89cde2fa3f18a063c272f215621) ([#13185](https://www.github.com/tauri-apps/tauri/pull/13185)) Added `app.setDockVisibility` for macOS.
|
||||
|
||||
### Enhancements
|
||||
|
||||
- [`b8f86669a`](https://www.github.com/tauri-apps/tauri/commit/b8f86669ab05f7dbdd15839a20999e63dc43bda6) ([#13145](https://www.github.com/tauri-apps/tauri/pull/13145)) `core.isTauri` now leverages `globalThis` instead of `window` in order to be used in unit tests.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- [`66e6325f4`](https://www.github.com/tauri-apps/tauri/commit/66e6325f43efa49ec2165c45afec911a1a14ecfb) ([#13136](https://www.github.com/tauri-apps/tauri/pull/13136)) Fix `Channel`'s callback attached to `window` never cleaned up
|
||||
|
||||
## \[2.4.1]
|
||||
|
||||
### Enhancements
|
||||
|
||||
- [`dd1372833`](https://www.github.com/tauri-apps/tauri/commit/dd137283341ce0e6aabfd158d07d77c6feeb920e) ([#13066](https://www.github.com/tauri-apps/tauri/pull/13066) by [@ahaoboy](https://www.github.com/tauri-apps/tauri/../../ahaoboy)) Add a generic to `emit` and `emitTo` functions for the `payload` instead of the previously used type (`unknown`).
|
||||
|
||||
## \[2.4.0]
|
||||
|
||||
### New Features
|
||||
|
||||
- [`d8059bad3`](https://www.github.com/tauri-apps/tauri/commit/d8059bad3cc922dc369c39ca1cfa49aaec31322e) ([#12900](https://www.github.com/tauri-apps/tauri/pull/12900) by [@Simon-Laux](https://www.github.com/tauri-apps/tauri/../../Simon-Laux)) add `AppHandle.fetch_data_store_identifiers` and `AppHandle.remove_data_store` (macOS and iOS only)
|
||||
- [`20c190691`](https://www.github.com/tauri-apps/tauri/commit/20c19069125c89b2d45a2127278c9ffc2df35fc2) ([#12821](https://www.github.com/tauri-apps/tauri/pull/12821) by [@Simon-Laux](https://www.github.com/tauri-apps/tauri/../../Simon-Laux)) Added `WindowOptions::javascriptDisabled` and `WebviewOptions::javascriptDisabled`.
|
||||
- [`060de5bbd`](https://www.github.com/tauri-apps/tauri/commit/060de5bbdddca384e3965a8938d89840f27c581d) ([#12837](https://www.github.com/tauri-apps/tauri/pull/12837) by [@niladrix719](https://www.github.com/tauri-apps/tauri/../../niladrix719)) Added `getIdentifier()` function to get the application identifier configured in tauri.conf.json
|
||||
- [`be2e6b85f`](https://www.github.com/tauri-apps/tauri/commit/be2e6b85fed226732b4a98f68cc5d72b4f8f5a13) ([#12944](https://www.github.com/tauri-apps/tauri/pull/12944) by [@Simon-Laux](https://www.github.com/tauri-apps/tauri/../../Simon-Laux)) Added `Window#isAlwaysOnTop` and `WebviewWindow#isAlwaysOnTop` methods.
|
||||
- [`bcdd51025`](https://www.github.com/tauri-apps/tauri/commit/bcdd510254ebe37827e22a5ffeb944321361e97c) ([#13012](https://www.github.com/tauri-apps/tauri/pull/13012) by [@lucasfernog](https://www.github.com/tauri-apps/tauri/../../lucasfernog)) The `path` basename and extname APIs now accept Android content URIs, such as the paths returned by the dialog plugin.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- [`3a74dc8f3`](https://www.github.com/tauri-apps/tauri/commit/3a74dc8f3421112b1d0a32b6a432606b1f33cc25) ([#12935](https://www.github.com/tauri-apps/tauri/pull/12935) by [@tk103331](https://www.github.com/tauri-apps/tauri/../../tk103331)) Fix `Webview.close` always fail with command not found
|
||||
|
||||
## \[2.3.0]
|
||||
|
||||
### Enhancements
|
||||
|
||||
- [`a2d36b8c3`](https://www.github.com/tauri-apps/tauri/commit/a2d36b8c34a8dcfc6736797ca5cd4665faf75e7e) ([#12181](https://www.github.com/tauri-apps/tauri/pull/12181) by [@bastiankistner](https://www.github.com/tauri-apps/tauri/../../bastiankistner)) Add an option to change the default background throttling policy (currently for WebKit only).
|
||||
|
||||
## \[2.2.0]
|
||||
|
||||
### New Features
|
||||
|
||||
- [`020ea0556`](https://www.github.com/tauri-apps/tauri/commit/020ea05561348dcd6d2a7df358f8a5190f661ba2) ([#11661](https://www.github.com/tauri-apps/tauri/pull/11661) by [@ahqsoftwares](https://www.github.com/tauri-apps/tauri/../../ahqsoftwares)) Add badging APIs:
|
||||
|
||||
- `Window/WebviewWindow::set_badge_count` for Linux, macOS and IOS.
|
||||
- `Window/WebviewWindow::set_overlay_icon` for Windows Only.
|
||||
- `Window/WebviewWindow::set_badge_label`for macOS Only.
|
||||
- [`fc30b20be`](https://www.github.com/tauri-apps/tauri/commit/fc30b20bea125f647db00ca824663f8e1da4d61f) ([#11726](https://www.github.com/tauri-apps/tauri/pull/11726) by [@amrbashir](https://www.github.com/tauri-apps/tauri/../../amrbashir)) Add `TrayIcon.setShowMenuOnLeftClick` method and deprecate `TrayIcon.setMenuOnLeftClick` to match the Rust API.
|
||||
- [`fc30b20be`](https://www.github.com/tauri-apps/tauri/commit/fc30b20bea125f647db00ca824663f8e1da4d61f) ([#11726](https://www.github.com/tauri-apps/tauri/pull/11726) by [@amrbashir](https://www.github.com/tauri-apps/tauri/../../amrbashir)) Add `TrayIconOptions.showMenuOnLeftClick` field and deprecate `TrayIconOptions.menuOnLeftClick` to match the Rust API.
|
||||
|
||||
### Enhancements
|
||||
|
||||
- [`fc30b20be`](https://www.github.com/tauri-apps/tauri/commit/fc30b20bea125f647db00ca824663f8e1da4d61f) ([#11726](https://www.github.com/tauri-apps/tauri/pull/11726) by [@amrbashir](https://www.github.com/tauri-apps/tauri/../../amrbashir)) Add support for `TrayIconOptions.menuOnLeftClick` option and `TrayIcon.setMenuOnLeftClick` on Windows.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- [`a16796a55`](https://www.github.com/tauri-apps/tauri/commit/a16796a55592cf5be80043edfbb630dd2e32efab) ([#12069](https://www.github.com/tauri-apps/tauri/pull/12069) by [@Legend-Master](https://www.github.com/tauri-apps/tauri/../../Legend-Master)) Fix `Channel` never calls `onmessage` in some cases
|
||||
- [`12a48d1e2`](https://www.github.com/tauri-apps/tauri/commit/12a48d1e26a83c3915eaa0687b196fbc8f2d457a) ([#11741](https://www.github.com/tauri-apps/tauri/pull/11741) by [@amrbashir](https://www.github.com/tauri-apps/tauri/../../amrbashir)) Fix error when calling `PredefinedMenuItem.new` to create an `About` menu item that uses an `Image` instance for the about icon.
|
||||
- [`12a48d1e2`](https://www.github.com/tauri-apps/tauri/commit/12a48d1e26a83c3915eaa0687b196fbc8f2d457a) ([#11741](https://www.github.com/tauri-apps/tauri/pull/11741) by [@amrbashir](https://www.github.com/tauri-apps/tauri/../../amrbashir)) Fix error when calling `IconMenuItem.new` using an `Image` instance for the icon.
|
||||
- [`b63262cd4`](https://www.github.com/tauri-apps/tauri/commit/b63262cd4d6a3667ca1664607a0a5444ad79fe0e) ([#11724](https://www.github.com/tauri-apps/tauri/pull/11724) by [@FabianLars](https://www.github.com/tauri-apps/tauri/../../FabianLars)) Removed the generic in the type of the callback function argument in `mockIPC` which prevented its proper use in tests using TypeScript.
|
||||
- [`a6e84f7d2`](https://www.github.com/tauri-apps/tauri/commit/a6e84f7d2c1d5fdc65901fce683502be3f47833f) ([#11835](https://www.github.com/tauri-apps/tauri/pull/11835) by [@ilittlebig](https://www.github.com/tauri-apps/tauri/../../ilittlebig)) Fix error where using `isAbsolute` would return `Command not found`.
|
||||
|
||||
## \[2.1.1]
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- [`7f81f0523`](https://www.github.com/tauri-apps/tauri/commit/7f81f052365675721312aafba297a7b67fb872d2) Fix regression in `toLogical` and `toPhysical` for position types in `dpi` module returning incorrect `y` value.
|
||||
- [`e8a50f6d7`](https://www.github.com/tauri-apps/tauri/commit/e8a50f6d760fad4529e7abb400302a1b487f11dd) ([#11645](https://www.github.com/tauri-apps/tauri/pull/11645)) Fix integer values of `BasDirectory.Home` and `BaseDirectory.Font` regression which broke path APIs in JS.
|
||||
|
||||
## \[2.1.0]
|
||||
|
||||
### New Features
|
||||
|
||||
- [`5c4b83084`](https://www.github.com/tauri-apps/tauri/commit/5c4b830843ab085f8ff9db9e08d832223b027e4e) ([#11191](https://www.github.com/tauri-apps/tauri/pull/11191) by [@amrbashir](https://www.github.com/tauri-apps/tauri/../../amrbashir)) Improved support for `dpi` module types to allow these types to be used without manual conversions with `invoke`:
|
||||
|
||||
- Added `SERIALIZE_TO_IPC_FN` const in `core` module which can be used to implement custom IPC serialization for types passed to `invoke`.
|
||||
- Added `Size` and `Position` classes in `dpi` module.
|
||||
- Implementd `SERIALIZE_TO_IPC_FN` method on `PhysicalSize`, `PhysicalPosition`, `LogicalSize` and `LogicalPosition` to convert it into a valid IPC-compatible value that can be deserialized correctly on the Rust side into its equivalent struct.
|
||||
- [`4d545ab3c`](https://www.github.com/tauri-apps/tauri/commit/4d545ab3ca228c8a21b966b709f84a0da2864479) ([#11486](https://www.github.com/tauri-apps/tauri/pull/11486) by [@amrbashir](https://www.github.com/tauri-apps/tauri/../../amrbashir)) Added `Webview::setBackgroundColor`, `WebviewWindow::setBackgroundColor` APIs to set the window background color dynamically
|
||||
and a `backgroundColor` window option to set the background color on window creation.
|
||||
- [`cbc095ec5`](https://www.github.com/tauri-apps/tauri/commit/cbc095ec5fe7de29b5c9265576d4e071ec159c1c) ([#11451](https://www.github.com/tauri-apps/tauri/pull/11451) by [@amrbashir](https://www.github.com/tauri-apps/tauri/../../amrbashir)) Add `app > windows > devtools` config option and when creating the webview from JS, to enable or disable devtools for a specific webview.
|
||||
- [`2a75c64b5`](https://www.github.com/tauri-apps/tauri/commit/2a75c64b5431284e7340e8743d4ea56a62c75466) ([#11469](https://www.github.com/tauri-apps/tauri/pull/11469) by [@amrbashir](https://www.github.com/tauri-apps/tauri/../../amrbashir)) Added `windowClassname` option, when constructing a `Webview` or `WebviewWindow`, to specify the name of the window class on Windows.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- [`54cbf59b5`](https://www.github.com/tauri-apps/tauri/commit/54cbf59b5a572570a47237a3b5e6505f2a9e5d5d) ([#11441](https://www.github.com/tauri-apps/tauri/pull/11441) by [@amrbashir](https://www.github.com/tauri-apps/tauri/../../amrbashir)) Fix submenu created as a menu item instead of a submenu when created by using an object in the `items` field in the options object passed to `Menu.new` or `Submenu.new`.
|
||||
|
||||
## \[2.0.3]
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- [`fbb45c674`](https://www.github.com/tauri-apps/tauri/commit/fbb45c674ca92fbbe04f1a8360e5f2e477dd4297) ([#11423](https://www.github.com/tauri-apps/tauri/pull/11423) by [@lucasfernog](https://www.github.com/tauri-apps/tauri/../../lucasfernog)) Fixes `addPluginListener` not working.
|
||||
|
||||
### What's Changed
|
||||
|
||||
- [`2e88633ba`](https://www.github.com/tauri-apps/tauri/commit/2e88633ba4da8fc289c6d8a29c36f3327f9b576e) ([#11369](https://www.github.com/tauri-apps/tauri/pull/11369) by [@lucasfernog](https://www.github.com/tauri-apps/tauri/../../lucasfernog)) Remove references to no longer used `__TAURI_INTERNALS__.metadata.windows` and `__TAURI_INTERNALS__.metadata.webviews`.
|
||||
|
||||
## \[2.0.2]
|
||||
|
||||
### What's Changed
|
||||
|
||||
- [`e968b3d25`](https://www.github.com/tauri-apps/tauri/commit/e968b3d2527b8edf7653e6cf7284dc4a8889b5fe) ([#11219](https://www.github.com/tauri-apps/tauri/pull/11219) by [@lucasfernog](https://www.github.com/tauri-apps/tauri/../../lucasfernog)) Actually publish package with the latest tag.
|
||||
|
||||
## \[2.0.1]
|
||||
|
||||
### What's Changed
|
||||
|
||||
- [`be683e2ac`](https://www.github.com/tauri-apps/tauri/commit/be683e2ac36df9c51a5c050d9d500247bd019090) ([#11199](https://www.github.com/tauri-apps/tauri/pull/11199) by [@lucasfernog](https://www.github.com/tauri-apps/tauri/../../lucasfernog)) Publish package with the latest NPM tag.
|
||||
|
||||
## \[2.0.0]
|
||||
|
||||
### What's Changed
|
||||
|
||||
- [`637285790`](https://www.github.com/tauri-apps/tauri/commit/6372857905ae9c0aedb7f482ddf6cf9f9836c9f2) Promote to v2 stable!
|
||||
|
||||
## \[2.0.0-rc.6]
|
||||
|
||||
### New Features
|
||||
|
||||
- [`9014a3f17`](https://www.github.com/tauri-apps/tauri/commit/9014a3f1765ca406ea5c3e5224267a79c52cd53d) ([#11066](https://www.github.com/tauri-apps/tauri/pull/11066) by [@amrbashir](https://www.github.com/tauri-apps/tauri/../../amrbashir)) Add `WebviewWindow.clearAllBrowsingData` and `Webview.clearAllBrowsingData` to clear the webview browsing data.
|
||||
- [`95df53a2e`](https://www.github.com/tauri-apps/tauri/commit/95df53a2ed96873cd35a4b14a5e312d07e4e3004) ([#11143](https://www.github.com/tauri-apps/tauri/pull/11143) by [@Legend-Master](https://www.github.com/tauri-apps/tauri/../../Legend-Master)) Add the ability to set theme dynamically using `Window.setTheme` or `setTheme` function from the `app` module
|
||||
- [`d9d2502b4`](https://www.github.com/tauri-apps/tauri/commit/d9d2502b41e39efde679e30c8955006e2ba9ea64) ([#11140](https://www.github.com/tauri-apps/tauri/pull/11140) by [@amrbashir](https://www.github.com/tauri-apps/tauri/../../amrbashir)) Add `Webview.hide` and `Webview.show` methods.
|
||||
- [`de7414aab`](https://www.github.com/tauri-apps/tauri/commit/de7414aab935e45540594ea930eb60bae4dbc979) ([#11154](https://www.github.com/tauri-apps/tauri/pull/11154) by [@amrbashir](https://www.github.com/tauri-apps/tauri/../../amrbashir)) Add `Window::setEnabled` and `Window::isEnabled` methods
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- [`948772a65`](https://www.github.com/tauri-apps/tauri/commit/948772a657eb3caf20843628abac9109e3b67d41) ([#11114](https://www.github.com/tauri-apps/tauri/pull/11114) by [@lucasfernog](https://www.github.com/tauri-apps/tauri/../../lucasfernog)) Change the `button_state` tray event field to camelCase `buttonState`.
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- [`0b4495996`](https://www.github.com/tauri-apps/tauri/commit/0b4495996d3131a5ee80fbb2c71a28203e491ee7) ([#11121](https://www.github.com/tauri-apps/tauri/pull/11121) by [@amrbashir](https://www.github.com/tauri-apps/tauri/../../amrbashir)) Simplified emitted tray event JS value and updated `TrayIconEvent` type definition to match it.
|
||||
|
||||
## \[2.0.0-rc.5]
|
||||
|
||||
### New Features
|
||||
|
||||
- [`ddf69157b`](https://www.github.com/tauri-apps/tauri/commit/ddf69157b54249f3321ca72db6703812019f1ab9) ([#11031](https://www.github.com/tauri-apps/tauri/pull/11031) by [@amrbashir](https://www.github.com/tauri-apps/tauri/../../amrbashir)) Add `toPhysical` method on `LogicalPositon` and `LogicalSize` classes.
|
||||
|
||||
## \[2.0.0-rc.4]
|
||||
|
||||
### Enhancements
|
||||
|
||||
- [`f81929e25`](https://www.github.com/tauri-apps/tauri/commit/f81929e25104aa1091e464bd012c80649dedf9e5) ([#10799](https://www.github.com/tauri-apps/tauri/pull/10799) by [@lucasfernog](https://www.github.com/tauri-apps/tauri/../../lucasfernog)) Added `PermissionState`, `checkPermissions` and `requestPermissions` base APIs to the core module, designed for plugin authors to extend.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- [`fbe76a955`](https://www.github.com/tauri-apps/tauri/commit/fbe76a955a63af9fb33f66d5f747caf858cf179b) ([#10797](https://www.github.com/tauri-apps/tauri/pull/10797) by [@lucasfernog](https://www.github.com/tauri-apps/tauri/../../lucasfernog)) Uint8Arrays and ArrayBuffers are now properly serialized as an array of numbers.
|
||||
|
||||
## \[2.0.0-rc.3]
|
||||
|
||||
### What's Changed
|
||||
|
||||
- [`f4d5241b3`](https://www.github.com/tauri-apps/tauri/commit/f4d5241b377d0f7a1b58100ee19f7843384634ac) ([#10731](https://www.github.com/tauri-apps/tauri/pull/10731) by [@amrbashir](https://www.github.com/tauri-apps/tauri/../../amrbashir)) Update documentation icon path.
|
||||
|
||||
## \[2.0.0-rc.2]
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- [`c689521a7`](https://www.github.com/tauri-apps/tauri/commit/c689521a7674b6562b5dfd4f5cacd12138d99d85) ([#10681](https://www.github.com/tauri-apps/tauri/pull/10681) by [@lucasfernog](https://www.github.com/tauri-apps/tauri/../../lucasfernog)) Fix tslib path in dist.
|
||||
|
||||
## \[2.0.0-rc.1]
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- [`b6dca99ff`](https://www.github.com/tauri-apps/tauri/commit/b6dca99fff73816a39380b288c299b47b493cfdb) ([#10630](https://www.github.com/tauri-apps/tauri/pull/10630) by [@lucasfernog](https://www.github.com/tauri-apps/tauri/../../lucasfernog)) Changed `WebviewWindow.getAll`, `WebviewWindow.getByLabel`, `getAllWebviewWindows`,
|
||||
`Window.getAll`, `Window.getByLabel`, `getAllWindows`,
|
||||
`Webview.getAll`, `Webview.getByLabel`, `getAllWebviews`
|
||||
to be async so their return value are synchronized with the state from the Rust side,
|
||||
meaning new and destroyed windows are reflected.
|
||||
|
||||
## \[2.0.0-rc.0]
|
||||
|
||||
### Changes
|
||||
|
||||
- Promoted to RC!
|
||||
|
||||
## \[2.0.0-beta.16]
|
||||
|
||||
### New Features
|
||||
|
||||
- [`da25f7353`](https://www.github.com/tauri-apps/tauri/commit/da25f7353070477ba969851e974379d7666d6806) ([#10242](https://www.github.com/tauri-apps/tauri/pull/10242) by [@amrbashir](https://www.github.com/tauri-apps/tauri/../../amrbashir)) Add APIs to enable setting window size constraints separately:
|
||||
|
||||
- Added `WindowSizeConstraints` interface in `window` and `webviewWindow` modules.
|
||||
- Added `Window.setSizeConstraints` and `WebviewWindow.setSizeConstraints`
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- [`3c17fb64f`](https://www.github.com/tauri-apps/tauri/commit/3c17fb64fd822597d5cc16ee7e7b3f9e1023637b) ([#10277](https://www.github.com/tauri-apps/tauri/pull/10277) by [@Legend-Master](https://www.github.com/tauri-apps/tauri/../../Legend-Master)) Fix `Webview.reparent` pointing to `set_webview_focus` instead of `reparent` Rust API
|
||||
- [`da25f7353`](https://www.github.com/tauri-apps/tauri/commit/da25f7353070477ba969851e974379d7666d6806) ([#10242](https://www.github.com/tauri-apps/tauri/pull/10242) by [@amrbashir](https://www.github.com/tauri-apps/tauri/../../amrbashir)) Apply `minWidth`, `minHieght`, `maxWidth` and `maxHeight` constraints separately, which fixes a long standing bug where these constraints were never applied unless width and height were constrained together.
|
||||
|
||||
## \[2.0.0-beta.15]
|
||||
|
||||
### New Features
|
||||
|
||||
- [`7bc6a2a1d`](https://www.github.com/tauri-apps/tauri/commit/7bc6a2a1d6d2c5406d91cac94d33bce76443c28f) ([#9788](https://www.github.com/tauri-apps/tauri/pull/9788) by [@pewsheen](https://www.github.com/tauri-apps/tauri/../../pewsheen)) Add a new method to set title bar style dynamically on macOS.
|
||||
|
||||
### Enhancements
|
||||
|
||||
- [`080b6e127`](https://www.github.com/tauri-apps/tauri/commit/080b6e12720b89d839c686d7067cc94d276ed7e4) ([#10246](https://www.github.com/tauri-apps/tauri/pull/10246) by [@Legend-Master](https://www.github.com/tauri-apps/tauri/../../Legend-Master)) Use `EventName` on `Window`, `Webview` and `WebviewWindow`'s `once` so you can get auto complete for tauri's built-in events
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- [`080b6e127`](https://www.github.com/tauri-apps/tauri/commit/080b6e12720b89d839c686d7067cc94d276ed7e4) ([#10246](https://www.github.com/tauri-apps/tauri/pull/10246) by [@Legend-Master](https://www.github.com/tauri-apps/tauri/../../Legend-Master)) Fix `once` doesn't detached after one callback if event handler throws
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- [`261c9f942`](https://www.github.com/tauri-apps/tauri/commit/261c9f942de9a598b5c6cc504de6bddd1306113b) ([#10170](https://www.github.com/tauri-apps/tauri/pull/10170) by [@amrbashir](https://www.github.com/tauri-apps/tauri/../../amrbashir)) Renamed drag and drop events in `TauriEvent` enum to better convey when they are triggered:
|
||||
|
||||
- `TauriEvent.DRAG` -> `TauriEvent.DRAG_ENTER`
|
||||
- `TauriEvent.DROP_OVER` -> `TauriEvent.DRAG_OVER`
|
||||
- `TauriEvent.DROP` -> `TauriEvent.DRAG_DROP`
|
||||
- `TauriEvent.DROP_CANCELLED` -> `TauriEvent::DRAG_LEAVE`
|
||||
|
||||
Also the `type` field values in `Window/Webview/WebviewWindow.onDropEvent` and `DragDropEvent` have changed:
|
||||
|
||||
- `dragged` -> `enter`
|
||||
- `dragOver` -> `over`
|
||||
- `dropped` -> `drop`
|
||||
- `cancelled` -> `leave`
|
||||
- [`2b1ceb40d`](https://www.github.com/tauri-apps/tauri/commit/2b1ceb40d345aef42dd79438fa69ca7989ee0194) ([#10229](https://www.github.com/tauri-apps/tauri/pull/10229) by [@amrbashir](https://www.github.com/tauri-apps/tauri/../../amrbashir)) Renamed the JS `getCurrent` and `getAll` functions to a clearer name to avoid ambiguity:
|
||||
|
||||
- `getCurrent` in `window` module has been renamed to `getCurrentWindow`
|
||||
- `getCurrent` in `webview` module has been renamed to `getCurrentWebview`
|
||||
- `getCurrent` in `webviewWindow` module has been renamed to `getCurrentWebviewWindow`
|
||||
- `getAll` in `window` module has been renamed to `getAllWindows`
|
||||
- `getAll` in `webview` module has been renamed to `getAllWebviews`
|
||||
- `getAll` in `webviewWindow` module has been renamed to `getAllWebviewWindows`
|
||||
|
||||
## \[2.0.0-beta.14]
|
||||
|
||||
### New Features
|
||||
|
||||
- [`148f04887`](https://www.github.com/tauri-apps/tauri/commit/148f048871caee21498b236c058b8890f2b66cc7) ([#9979](https://www.github.com/tauri-apps/tauri/pull/9979)) Add `defaultWindowIcon` to the JS `app` module to retrieve the default window icon in JS.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- [`c98f385cb`](https://www.github.com/tauri-apps/tauri/commit/c98f385cb5da4d72968df24b1fc0b58212d59653) ([#10044](https://www.github.com/tauri-apps/tauri/pull/10044)) Export `mocks` module in `@tauri-apps/api` npm package.
|
||||
|
||||
## \[2.0.0-beta.13]
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- [`c4410daa8`](https://www.github.com/tauri-apps/tauri/commit/c4410daa85616340e911c8243fdaa69e6906fd49)([#9777](https://www.github.com/tauri-apps/tauri/pull/9777)) This release contains breaking changes to the tray event structure because of newly added events:
|
||||
|
||||
- Changed `TrayIconEvent` to be an enum instead of a struct.
|
||||
- Added `MouseButtonState` and `MouseButton` enums.
|
||||
- Removed `ClickType` enum and replaced it with `MouseButton` enum.
|
||||
- Added `MouseButtonState` enum.
|
||||
|
||||
## \[2.0.0-beta.12]
|
||||
|
||||
### New Features
|
||||
|
||||
- [`ec0e092ec`](https://www.github.com/tauri-apps/tauri/commit/ec0e092ecd23b547c756c7476f23a0d95be6db80)([#9770](https://www.github.com/tauri-apps/tauri/pull/9770)) Add `monitorFromPoint` function in `window` module to get the monitor from a given point.
|
||||
|
||||
## \[2.0.0-beta.11]
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- [`aa080696e`](https://www.github.com/tauri-apps/tauri/commit/aa080696e0952abff416dd9088d519eaf2587a3a)([#9618](https://www.github.com/tauri-apps/tauri/pull/9618)) Fix `isTauri` incorrect return type.
|
||||
|
||||
## \[2.0.0-beta.10]
|
||||
|
||||
### New Features
|
||||
|
||||
- [`477bb8cd4`](https://www.github.com/tauri-apps/tauri/commit/477bb8cd4ea88ade3f6c1f268ad1701a68150161)([#9297](https://www.github.com/tauri-apps/tauri/pull/9297)) Add `cursorPosition` function in `window` module to get the current cursor position.
|
||||
|
||||
## \[2.0.0-beta.9]
|
||||
|
||||
### New Features
|
||||
|
||||
- [`70c51371e`](https://www.github.com/tauri-apps/tauri/commit/70c51371e01184223312de3dba8030394a5a9406)([#9539](https://www.github.com/tauri-apps/tauri/pull/9539)) Add `isTauri` function in `core` module to check whether running inside tauri or not.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- [`be7eab209`](https://www.github.com/tauri-apps/tauri/commit/be7eab209c60c45e140f7bcb4bab1037d62d4c03)([#9486](https://www.github.com/tauri-apps/tauri/pull/9486)) Set the `exports > types` package.json field.
|
||||
- [`cf615e8e4`](https://www.github.com/tauri-apps/tauri/commit/cf615e8e4d5008ee1ac3f77e530ba26fb91e8977)([#9463](https://www.github.com/tauri-apps/tauri/pull/9463)) Fixes a bug when processing channel messages out of order.
|
||||
- [`35b25f7e5`](https://www.github.com/tauri-apps/tauri/commit/35b25f7e5c0fe03af4ed3582e22a626863f035f0)([#9530](https://www.github.com/tauri-apps/tauri/pull/9530)) Do not use JS optional chaining to prevent script errors on older webviews such as macOS 10.14.
|
||||
|
||||
## \[2.0.0-beta.8]
|
||||
|
||||
### New Features
|
||||
|
||||
- [`58a7a552d`](https://www.github.com/tauri-apps/tauri/commit/58a7a552d739b77b71d61af11c53f7f2dc7a6e7e)([#9378](https://www.github.com/tauri-apps/tauri/pull/9378)) Added the `set_zoom` function to the webview API.
|
||||
- [`58a7a552d`](https://www.github.com/tauri-apps/tauri/commit/58a7a552d739b77b71d61af11c53f7f2dc7a6e7e)([#9378](https://www.github.com/tauri-apps/tauri/pull/9378)) Add `zoom_hotkeys_enabled` to enable browser native zoom controls on creating webviews.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- [`48a7a78f8`](https://www.github.com/tauri-apps/tauri/commit/48a7a78f8094d08e5e403e88050391642d29151b)([#9376](https://www.github.com/tauri-apps/tauri/pull/9376)) Fix `Window/Webview/WebviewWindow.setSize`, `Window/Webview/WebviewWindow.setPostion`, `Window/WebviewWindow.setMinSize`, `Window/WebviewWindow.setMaxSize`, `Window/WebviewWindow.setCursorPosition` and `Menu/Submenu.popup` methods failing with invalid args.
|
||||
|
||||
## \[2.0.0-beta.7]
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- [`c33f6e6cf`](https://www.github.com/tauri-apps/tauri/commit/c33f6e6cf35a0d34b5598875a2e5b642a01c8b38)([#9211](https://www.github.com/tauri-apps/tauri/pull/9211)) Re-added the `TauriEvent.WINDOW_CREATED` (`tauri://window-created`) event.
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- [`06833f4fa`](https://www.github.com/tauri-apps/tauri/commit/06833f4fa8e63ecc55fe3fc874a9e397e77a5709)([#9100](https://www.github.com/tauri-apps/tauri/pull/9100)) Rename `FileDrop` to `DragDrop` on structs, enums and enum variants. Also renamed `file_drop` to `drag_drop` on fields and function names.
|
||||
|
||||
## \[2.0.0-beta.6]
|
||||
|
||||
### New Features
|
||||
|
||||
- [`acdd76833`](https://www.github.com/tauri-apps/tauri/commit/acdd76833db6d81f4012418133d0042220de100b)([#9155](https://www.github.com/tauri-apps/tauri/pull/9155)) Add `TrayIcon.getById` and `TrayIcon.removeById` static methods.
|
||||
|
||||
### Enhancements
|
||||
|
||||
- [`ea0242db4`](https://www.github.com/tauri-apps/tauri/commit/ea0242db4aa6c127d2bb4a2e275000ba47c9e68c)([#9179](https://www.github.com/tauri-apps/tauri/pull/9179)) The `Image` constructor is now public (for internal use only).
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- [`379cc2b35`](https://www.github.com/tauri-apps/tauri/commit/379cc2b3547395474d4b66b4222679cf4538428d)([#9165](https://www.github.com/tauri-apps/tauri/pull/9165)) Fix `basename(path, 'ext')` JS API when removing all occurances of `ext` where it should only remove the last one.
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- [`ea0242db4`](https://www.github.com/tauri-apps/tauri/commit/ea0242db4aa6c127d2bb4a2e275000ba47c9e68c)([#9179](https://www.github.com/tauri-apps/tauri/pull/9179)) `Image::rgba()` now returns `Promise<Uint8Array>`.
|
||||
- [`ea0242db4`](https://www.github.com/tauri-apps/tauri/commit/ea0242db4aa6c127d2bb4a2e275000ba47c9e68c)([#9179](https://www.github.com/tauri-apps/tauri/pull/9179)) Removed `width` and `height` methods on the JS `Image` class, use `size` instead.
|
||||
|
||||
## \[2.0.0-beta.5]
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- [`db0a24a97`](https://www.github.com/tauri-apps/tauri/commit/db0a24a973191752aeecfbd556faa254b0f17e79)([#9132](https://www.github.com/tauri-apps/tauri/pull/9132)) Remove the `Image.fromPngBytes` and `Image.fromIcoBytes` APIs. Use `Image.fromBytes` instead.
|
||||
|
||||
## \[2.0.0-beta.4]
|
||||
|
||||
### New Features
|
||||
|
||||
- [`d1e77acd8`](https://www.github.com/tauri-apps/tauri/commit/d1e77acd8dfdf554b90b542513a58a2de1ef2360)([#9011](https://www.github.com/tauri-apps/tauri/pull/9011)) Add a new `Image` type in Rust and JS.
|
||||
|
||||
### Enhancements
|
||||
|
||||
- [`e62ca4ee9`](https://www.github.com/tauri-apps/tauri/commit/e62ca4ee95f4308a6ad128d0f100c85634e28223)([#9070](https://www.github.com/tauri-apps/tauri/pull/9070)) Added a mechanism to preserve channel message order.
|
||||
|
||||
## \[2.0.0-beta.3]
|
||||
|
||||
### New Features
|
||||
|
||||
- [`fdcaf935`](https://www.github.com/tauri-apps/tauri/commit/fdcaf935fa75ecfa2806939c4faad4fe9e880386)([#8939](https://www.github.com/tauri-apps/tauri/pull/8939)) Added the `reparent` function to the webview API.
|
||||
|
||||
## \[2.0.0-beta.2]
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- [`361ec37f`](https://www.github.com/tauri-apps/tauri/commit/361ec37fd4a5caa5b6630b9563ef079f53c6c336)([#8932](https://www.github.com/tauri-apps/tauri/pull/8932)) Removed the `unityUri` option from the progress bar state, no longer required.
|
||||
|
||||
## \[2.0.0-beta.1]
|
||||
|
||||
### New Features
|
||||
|
||||
- [`16e550ec`](https://www.github.com/tauri-apps/tauri/commit/16e550ec1503765158cdc3bb2a20e70ec710e981)([#8844](https://www.github.com/tauri-apps/tauri/pull/8844)) Add a new `webviewWindow` module that exports `WebviewWindow` class and related methods such as `getCurrent` and `getAll`.
|
||||
- [`16e550ec`](https://www.github.com/tauri-apps/tauri/commit/16e550ec1503765158cdc3bb2a20e70ec710e981)([#8844](https://www.github.com/tauri-apps/tauri/pull/8844)) Add `Window.onFileDropEvent` method.
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- [`16e550ec`](https://www.github.com/tauri-apps/tauri/commit/16e550ec1503765158cdc3bb2a20e70ec710e981)([#8844](https://www.github.com/tauri-apps/tauri/pull/8844)) Renamed the following enum variants of `TauriEvent` enum:
|
||||
|
||||
- `TauriEvent.WEBVIEW_FILE_DROP` -> `TauriEvent.FILE_DROP`
|
||||
- `TauriEvent.WEBVIEW_FILE_DROP_HOVER` -> `TauriEvent.FILE_DROP_HOVER`
|
||||
- `TauriEvent.WEBVIEW_FILE_DROP_CANCELLED` -> `TauriEvent.FILE_DROP_CANCELLED`
|
||||
- [`16e550ec`](https://www.github.com/tauri-apps/tauri/commit/16e550ec1503765158cdc3bb2a20e70ec710e981)([#8844](https://www.github.com/tauri-apps/tauri/pull/8844)) Move `WebviewWindow` class from `webview` module to a new `webviewWindow` module.
|
||||
|
||||
## \[2.0.0-beta.0]
|
||||
|
||||
### New Features
|
||||
|
||||
- [`74a2a603`](https://www.github.com/tauri-apps/tauri/commit/74a2a6036a5e57462f161d728cbd8a6f121028ca)([#8661](https://www.github.com/tauri-apps/tauri/pull/8661)) Implement access control list for IPC usage.
|
||||
- [`a093682d`](https://www.github.com/tauri-apps/tauri/commit/a093682d2df7169b024bb4f736c7f1fd2ea8b327)([#8621](https://www.github.com/tauri-apps/tauri/pull/8621)) Added `emitTo` api to `event` module which is equivalent to the rust `emit_to` method. Also added `emitTo` method on `Window`, `Webivew` and `WebviewWindow` classes.
|
||||
- [`a2fc3a63`](https://www.github.com/tauri-apps/tauri/commit/a2fc3a63579ca739646d696870cbecbb3a169d33)([#8657](https://www.github.com/tauri-apps/tauri/pull/8657)) Add `visibleOnAllWorkspaces` option when creating the window in JS and `Window.setVisibleOnAllWorkspaces` method.
|
||||
- [`7f033f6d`](https://www.github.com/tauri-apps/tauri/commit/7f033f6dcd54c69a4193765a5c1584755ba92c61)([#8537](https://www.github.com/tauri-apps/tauri/pull/8537)) Add `Window.startResizeDragging`.
|
||||
- [`9eaeb5a8`](https://www.github.com/tauri-apps/tauri/commit/9eaeb5a8cd95ae24b5e66205bdc2763cb7f965ce)([#8622](https://www.github.com/tauri-apps/tauri/pull/8622)) Add `parent` option when creating a window.
|
||||
- [`af610232`](https://www.github.com/tauri-apps/tauri/commit/af6102327376884364b2075b468bdf08ee0d02aa)([#8710](https://www.github.com/tauri-apps/tauri/pull/8710)) Added `Window::destroy` to force close a window.
|
||||
- [`c77b4032`](https://www.github.com/tauri-apps/tauri/commit/c77b40324ea9bf580871fc11aed69ba0c9b6b8cf)([#8280](https://www.github.com/tauri-apps/tauri/pull/8280)) Added support to multiwebview via the new `window` and `webview` modules.
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- [`c77b4032`](https://www.github.com/tauri-apps/tauri/commit/c77b40324ea9bf580871fc11aed69ba0c9b6b8cf)([#8280](https://www.github.com/tauri-apps/tauri/pull/8280)) Removed event callback's `windowLabel`.
|
||||
- [`c77b4032`](https://www.github.com/tauri-apps/tauri/commit/c77b40324ea9bf580871fc11aed69ba0c9b6b8cf)([#8280](https://www.github.com/tauri-apps/tauri/pull/8280)) The event target is now an object so you can target either a window or a webview.
|
||||
- [`c77b4032`](https://www.github.com/tauri-apps/tauri/commit/c77b40324ea9bf580871fc11aed69ba0c9b6b8cf)([#8280](https://www.github.com/tauri-apps/tauri/pull/8280)) Moved webview-specific APIs from the `Window` class to the `Webview` class.
|
||||
- [`c77b4032`](https://www.github.com/tauri-apps/tauri/commit/c77b40324ea9bf580871fc11aed69ba0c9b6b8cf)([#8280](https://www.github.com/tauri-apps/tauri/pull/8280)) Renamed `TauriEvent.WINDOW_FILE_DROP` to `TauriEvent.WEBVIEW_FILE_DROP`, `TauriEvent.WINDOW_FILE_DROP_HOVER` to `TauriEvent.WEBVIEW_FILE_DROP_HOVER` and `TauriEvent.WINDOW_FILE_DROP_CANCELLED` to `TauriEvent.WEBVIEW_FILE_DROP_CANCELLED`.
|
||||
- [`c77b4032`](https://www.github.com/tauri-apps/tauri/commit/c77b40324ea9bf580871fc11aed69ba0c9b6b8cf)([#8280](https://www.github.com/tauri-apps/tauri/pull/8280)) Added back the `WebviewWindow` API that exposes functionality of a window that hosts a single webview. The dedicated `Window` and `Webview` types are exposed for multiwebview features.
|
||||
- [`af610232`](https://www.github.com/tauri-apps/tauri/commit/af6102327376884364b2075b468bdf08ee0d02aa)([#8710](https://www.github.com/tauri-apps/tauri/pull/8710)) `Window::close` now triggers a close requested event instead of forcing the window to be closed.
|
||||
|
||||
## \[2.0.0-alpha.14]
|
||||
|
||||
- [`97e33412`](https://www.github.com/tauri-apps/tauri/commit/97e334129956159bbd60e1c531b6acd3bc6139a6)([#8534](https://www.github.com/tauri-apps/tauri/pull/8534)) `mockIPC` and `mockWindows` no longer crash if `window.__TAURI_INTERNALS__` is undefined.
|
||||
|
||||
## \[2.0.0-alpha.13]
|
||||
|
||||
### New Features
|
||||
|
||||
- [`428ea652`](https://www.github.com/tauri-apps/tauri/commit/428ea6524c70545be33aac96d7c22b21f25caa4c)([#8370](https://www.github.com/tauri-apps/tauri/pull/8370)) Exposed `Resource` class which should be extended for Rust-backed resources created through `tauri::Manager::resources_table`.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- [`ef21b681`](https://www.github.com/tauri-apps/tauri/commit/ef21b681e237a80592c9118b9c023c1d57231bac)([#8391](https://www.github.com/tauri-apps/tauri/pull/8391)) Fix a regression where typescript could not find types when using `"moduleResolution": "node"`
|
||||
- [`46451aee`](https://www.github.com/tauri-apps/tauri/commit/46451aee1318f63a6cd861a12b63929b38c64eb6)([#8268](https://www.github.com/tauri-apps/tauri/pull/8268)) Add top-level `main`, `module` and `types` fields in `package.json` to be compliant with typescripts's `"moduleResolution": "node"`
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- [`c2ad4d28`](https://www.github.com/tauri-apps/tauri/commit/c2ad4d28c481b2d7ed643458db56210cd44a2e0c)([#8273](https://www.github.com/tauri-apps/tauri/pull/8273)) Changed former `tauri` module from `primitives` to `core`.
|
||||
|
||||
## \[2.0.0-alpha.12]
|
||||
|
||||
### New Features
|
||||
|
||||
- [`f93148ea`](https://www.github.com/tauri-apps/tauri/commit/f93148eac05a1428e038bd9351a8149b2464ff4c)([#7709](https://www.github.com/tauri-apps/tauri/pull/7709)) Add `tray` and `menu` modules to create and manage tray icons and menus from Javascript.
|
||||
|
||||
### Enhancements
|
||||
|
||||
- [`b7add750`](https://www.github.com/tauri-apps/tauri/commit/b7add750ef9f32d959de613ab35063ff240281c2)([#8204](https://www.github.com/tauri-apps/tauri/pull/8204)) Added `position` field to the `FileDropEvent` payload.
|
||||
|
||||
## \[2.0.0-alpha.11]
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- [`822bf15d`](https://www.github.com/tauri-apps/tauri/commit/822bf15d6b258556b689ca55ac2ac224897e913a)([#8130](https://www.github.com/tauri-apps/tauri/pull/8130)) Fix tslib missing in the distributed api package.
|
||||
|
||||
## \[2.0.0-alpha.10]
|
||||
|
||||
### Enhancements
|
||||
|
||||
- [`c6c59cf2`](https://www.github.com/tauri-apps/tauri/commit/c6c59cf2373258b626b00a26f4de4331765dd487) Pull changes from Tauri 1.5 release.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- [`287066b2`](https://www.github.com/tauri-apps/tauri/commit/287066b279f503dd09bfd43d5da37d1f471451fb)([#8071](https://www.github.com/tauri-apps/tauri/pull/8071)) No longer crashing in tests without mocks when `clearMocks` is defined in `afterEach` hook.
|
||||
|
||||
## \[2.0.0-alpha.9]
|
||||
|
||||
### New Features
|
||||
|
||||
- [`c1ec0f15`](https://www.github.com/tauri-apps/tauri/commit/c1ec0f155118527361dd5645d920becbc8afd569)([#7933](https://www.github.com/tauri-apps/tauri/pull/7933)) Added `setAlwaysOnBottom` function on `Window` and the `alwaysOnBottom` option when creating a window.
|
||||
- [`fb10b879`](https://www.github.com/tauri-apps/tauri/commit/fb10b87970a43320ef4d14564f45e7579b774eaf)([#8039](https://www.github.com/tauri-apps/tauri/pull/8039)) Add the `app` module back.
|
||||
- [`ed32257d`](https://www.github.com/tauri-apps/tauri/commit/ed32257d044f90b5eb15053efd1667125def2d2b)([#7794](https://www.github.com/tauri-apps/tauri/pull/7794)) On Windows, add `Effect.Tabbed`,`Effect.TabbedDark` and `Effect.TabbedLight` effects.
|
||||
- [`c9a9246c`](https://www.github.com/tauri-apps/tauri/commit/c9a9246c37bdf190661355c8ee406dac6c427344)([#8007](https://www.github.com/tauri-apps/tauri/pull/8007)) Add the `window` module back.
|
||||
- [`c085adda`](https://www.github.com/tauri-apps/tauri/commit/c085addab58ba851398373c6fd13f9cb026d71e8)([#8009](https://www.github.com/tauri-apps/tauri/pull/8009)) Added the `setProgressBar` API on the `Window` class.
|
||||
|
||||
### What's Changed
|
||||
|
||||
- [`5c0eeb40`](https://www.github.com/tauri-apps/tauri/commit/5c0eeb40c1003583290ff3aebfa02e2b5f5b9c41)([#7638](https://www.github.com/tauri-apps/tauri/pull/7638)) Updated minimum Node.js version to 18.
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- [`a63e71f9`](https://www.github.com/tauri-apps/tauri/commit/a63e71f9799e9bbc82521d2f17b5238fbf690e89)([#7942](https://www.github.com/tauri-apps/tauri/pull/7942)) Changed `tauri` module to `primitives` and removed the undocumented `invoke` export from the root module.
|
||||
|
||||
## \[2.0.0-alpha.8]
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- [`d5074af5`](https://www.github.com/tauri-apps/tauri/commit/d5074af562b2b5cb6c5711442097c4058af32db6)([#7801](https://www.github.com/tauri-apps/tauri/pull/7801)) The custom protocol on Android now uses the `http` scheme instead of `https`.
|
||||
|
||||
## \[2.0.0-alpha.7]
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- [`4cb51a2d`](https://www.github.com/tauri-apps/tauri/commit/4cb51a2d56cfcae0749062c79ede5236bd8c02c2)([#7779](https://www.github.com/tauri-apps/tauri/pull/7779)) The custom protocol on Windows now uses the `http` scheme instead of `https`.
|
||||
|
||||
## \[2.0.0-alpha.6]
|
||||
|
||||
### New Features
|
||||
|
||||
- [`4af5c5a8`](https://www.github.com/tauri-apps/tauri/commit/4af5c5a8293263c16f8a65e8d232f2de52f41701)([#7170](https://www.github.com/tauri-apps/tauri/pull/7170)) Change the IPC call to align with the new format for the custom protocol based API.
|
||||
|
||||
## \[2.0.0-alpha.5]
|
||||
|
||||
### New Features
|
||||
|
||||
- [`e0f0dce2`](https://www.github.com/tauri-apps/tauri/commit/e0f0dce220730e2822fc202463aedf0166145de7)([#6442](https://www.github.com/tauri-apps/tauri/pull/6442)) Added the `windowEffects` option when creating a window and `setWindowEffects` method to change it at runtime.
|
||||
|
||||
### Enhancements
|
||||
|
||||
- [`9e3a18e0`](https://www.github.com/tauri-apps/tauri/commit/9e3a18e04672edad15d0ec654bd8632544871967)([#7132](https://www.github.com/tauri-apps/tauri/pull/7132)) Expose the window target option on event APIs.
|
||||
- [`6d3f3138`](https://www.github.com/tauri-apps/tauri/commit/6d3f3138b9e2f41cda712c7d9caba0f0e65dfd3c)([#7160](https://www.github.com/tauri-apps/tauri/pull/7160)) Changed `sep` and `delimiter` from `path` module into functions to fix import in frameworks like `next.js`
|
||||
- [`4652c446`](https://www.github.com/tauri-apps/tauri/commit/4652c446b361a801252bcf45e9da39813bf85482)([#7144](https://www.github.com/tauri-apps/tauri/pull/7144)) Add `tempDir` function to `path` module
|
||||
|
||||
## \[2.0.0-alpha.4]
|
||||
|
||||
- [`0ab5f40d`](https://www.github.com/tauri-apps/tauri/commit/0ab5f40d3a4207f20e4440587b41c4e78f91d233)([#6813](https://www.github.com/tauri-apps/tauri/pull/6813)) Add channel API for sending data across the IPC.
|
||||
- [`3245d14b`](https://www.github.com/tauri-apps/tauri/commit/3245d14b9eb256a5c5675c7030bac7082855df47)([#6895](https://www.github.com/tauri-apps/tauri/pull/6895)) Moved the `app` feature to its own plugin in the plugins-workspace repository.
|
||||
- [`09376af5`](https://www.github.com/tauri-apps/tauri/commit/09376af59424cc27803fa2820d2ac0d4cdc90a6d)([#6704](https://www.github.com/tauri-apps/tauri/pull/6704)) Moved the `cli` feature to its own plugin in the plugins-workspace repository.
|
||||
- [`2d5378bf`](https://www.github.com/tauri-apps/tauri/commit/2d5378bfc1ba817ee2f331b41738a90e5997e5e8)([#6717](https://www.github.com/tauri-apps/tauri/pull/6717)) Moved the dialog APIs to its own plugin in the plugins-workspace repository.
|
||||
- [`39f1b04f`](https://www.github.com/tauri-apps/tauri/commit/39f1b04f7be4966488484829cd54c8ce72a04200)([#6943](https://www.github.com/tauri-apps/tauri/pull/6943)) Moved the `event` JS APIs to a plugin.
|
||||
- [`fc4d687e`](https://www.github.com/tauri-apps/tauri/commit/fc4d687ef0ef2ea069ed73c40916da733b5dcb8f)([#6716](https://www.github.com/tauri-apps/tauri/pull/6716)) Moved the file system APIs to its own plugin in the plugins-workspace repository.
|
||||
- [`f78a3783`](https://www.github.com/tauri-apps/tauri/commit/f78a378344bbec48533641661d865920a8f46f8f)([#6742](https://www.github.com/tauri-apps/tauri/pull/6742)) Moved the `http` feature to its own plugin in the plugins-workspace repository.
|
||||
- [`29ce9ce2`](https://www.github.com/tauri-apps/tauri/commit/29ce9ce2ce7dfb260d556d5cffd075e8fe06660c)([#6902](https://www.github.com/tauri-apps/tauri/pull/6902)) Moved the `os` feature to its own plugin in the plugins-workspace repository.
|
||||
- [`60cf9ed2`](https://www.github.com/tauri-apps/tauri/commit/60cf9ed2fcd7be4df41e86cf18735efe9b6cb254)([#6905](https://www.github.com/tauri-apps/tauri/pull/6905)) Moved the `process` feature to its own plugin in the plugins-workspace repository.
|
||||
- [`96639ca2`](https://www.github.com/tauri-apps/tauri/commit/96639ca239c9e4f75142fc07868ac46822111cff)([#6749](https://www.github.com/tauri-apps/tauri/pull/6749)) Moved the `shell` functionality to its own plugin in the plugins-workspace repository.
|
||||
- [`b072daa3`](https://www.github.com/tauri-apps/tauri/commit/b072daa3bd3e38b808466666619ddb885052c5b2)([#6919](https://www.github.com/tauri-apps/tauri/pull/6919)) Moved the `updater` feature to its own plugin in the plugins-workspace repository.
|
||||
- [`cebd7526`](https://www.github.com/tauri-apps/tauri/commit/cebd75261ac71b98976314a450cb292eeeec1515)([#6728](https://www.github.com/tauri-apps/tauri/pull/6728)) Moved the `clipboard` feature to its own plugin in the plugins-workspace repository.
|
||||
- [`3f17ee82`](https://www.github.com/tauri-apps/tauri/commit/3f17ee82f6ff21108806edb7b00500b8512b8dc7)([#6737](https://www.github.com/tauri-apps/tauri/pull/6737)) Moved the `global-shortcut` feature to its own plugin in the plugins-workspace repository.
|
||||
- [`9a79dc08`](https://www.github.com/tauri-apps/tauri/commit/9a79dc085870e0c1a5df13481ff271b8c6cc3b78)([#6947](https://www.github.com/tauri-apps/tauri/pull/6947)) Moved the `window` JS APIs to its own plugin in the plugins-workspace repository.
|
||||
|
||||
## \[2.0.0-alpha.3]
|
||||
|
||||
- Overload the dialog `open` function to have better TS result types.
|
||||
- [1eacd51d](https://www.github.com/tauri-apps/tauri/commit/1eacd51d185ba69a3c3cb2cc93c792e2d5929843) overloaded the open function for convenient type inference ([#5619](https://www.github.com/tauri-apps/tauri/pull/5619)) on 2023-04-07
|
||||
|
||||
## \[2.0.0-alpha.2]
|
||||
|
||||
- Added `raw` encoding option to read stdout and stderr raw bytes.
|
||||
- [f992e7f5](https://www.github.com/tauri-apps/tauri/commit/f992e7f58bf975c654a3daf36780b31a32bac064) chore(changes): readd change file on 2023-04-03
|
||||
- Removed shell's `Command` constructor and added the `Command.create` static function instead.
|
||||
- [509d4678](https://www.github.com/tauri-apps/tauri/commit/509d4678b12816c1dd08a9a5efa71ba556d91c27) Support sending raw byte data to the "data" event for child command's stdout and stderr ([#5789](https://www.github.com/tauri-apps/tauri/pull/5789)) on 2023-03-31
|
||||
|
||||
## \[2.0.0-alpha.1]
|
||||
|
||||
- Added the `shadow` option when creating a window and `setShadow` function.
|
||||
- [a81750d7](https://www.github.com/tauri-apps/tauri/commit/a81750d779bc72f0fdb7de90b7fbddfd8049b328) feat(core): add shadow APIs ([#6206](https://www.github.com/tauri-apps/tauri/pull/6206)) on 2023-02-08
|
||||
|
||||
## \[2.0.0-alpha.0]
|
||||
|
||||
- First mobile alpha release!
|
||||
- [fa3a1098](https://www.github.com/tauri-apps/tauri/commit/fa3a10988a03aed1b66fb17d893b1a9adb90f7cd) feat(ci): prepare 2.0.0-alpha.0 ([#5786](https://www.github.com/tauri-apps/tauri/pull/5786)) on 2022-12-08
|
||||
|
||||
## \[1.5.3]
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- [`1c582a94`](https://www.github.com/tauri-apps/tauri/commit/1c582a942e345a066b65620e4db9f688ec142bb9)([#8392](https://www.github.com/tauri-apps/tauri/pull/8392)) Fix a regression where typescript could not find types when using `"moduleResolution": "node"`
|
||||
|
||||
## \[1.5.2]
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- [`50462702`](https://www.github.com/tauri-apps/tauri/commit/504627027303ef5a0e855aab2abea64c6964223b)([#8267](https://www.github.com/tauri-apps/tauri/pull/8267)) Add top-level `main`, `module` and `types` fields in `package.json` to be compliant with typescripts's `"moduleResolution": "node"`
|
||||
- [`14544e4b`](https://www.github.com/tauri-apps/tauri/commit/14544e4b87269c06c89fed3647d80f492e0a1d34)([#8219](https://www.github.com/tauri-apps/tauri/pull/8219)) Avoid crashing in `clearMocks`
|
||||
|
||||
## \[1.5.1]
|
||||
|
||||
### New Features
|
||||
|
||||
- [`2b0212af`](https://www.github.com/tauri-apps/tauri/commit/2b0212af49c386e52bb2357381813d6d435ec4af)([#7961](https://www.github.com/tauri-apps/tauri/pull/7961)) Add `mockConvertFileSrc` in `mocks` module, to mock `convertFileSrc` function.
|
||||
|
||||
## \[1.5.0]
|
||||
|
||||
### New Features
|
||||
|
||||
- [`6c408b73`](https://www.github.com/tauri-apps/tauri/commit/6c408b736c7aa2a0a91f0a40d45a2b7a7dedfe78)([#7269](https://www.github.com/tauri-apps/tauri/pull/7269)) Add option to specify notification sound.
|
||||
|
||||
### Enhancements
|
||||
|
||||
- [`58d6b899`](https://www.github.com/tauri-apps/tauri/commit/58d6b899e21d37bb42810890d289deb57f2273bd)([#7636](https://www.github.com/tauri-apps/tauri/pull/7636)) Add `append` option to `FsOptions` in the `fs` JS module, used in `writeTextFile` and `writeBinaryFile`, to be able to append to existing files instead of overwriting it.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- [`2eab1505`](https://www.github.com/tauri-apps/tauri/commit/2eab1505632ff71431d4c31c49b5afc78fa5b9dd)([#7394](https://www.github.com/tauri-apps/tauri/pull/7394)) Fix `Body.form` static not reading and sending entries of type `Blob` (including subclasses such as `File`)
|
||||
|
||||
## \[1.4.0]
|
||||
|
||||
### New Features
|
||||
|
||||
- [`359058ce`](https://www.github.com/tauri-apps/tauri/commit/359058cecca44a9c30b65140c44a8bb3a6dd3be8)([#5939](https://www.github.com/tauri-apps/tauri/pull/5939)) Add `locale` function in the `os` module to get the system locale.
|
||||
- [`c4d6fb4b`](https://www.github.com/tauri-apps/tauri/commit/c4d6fb4b1ea8acf02707a9fe5dcab47c1c5bae7b)([#2353](https://www.github.com/tauri-apps/tauri/pull/2353)) Added the `maximizable`, `minimizable` and `closable` fields on `WindowOptions`.
|
||||
- [`c4d6fb4b`](https://www.github.com/tauri-apps/tauri/commit/c4d6fb4b1ea8acf02707a9fe5dcab47c1c5bae7b)([#2353](https://www.github.com/tauri-apps/tauri/pull/2353)) Added the `setMaximizable`, `setMinimizable`, `setClosable`, `isMaximizable`, `isMinimizable` and `isClosable` methods.
|
||||
- [`000104bc`](https://www.github.com/tauri-apps/tauri/commit/000104bc3bc0c9ff3d20558ab9cf2080f126e9e0)([#6472](https://www.github.com/tauri-apps/tauri/pull/6472)) Add `WebviewWindow.is_focused` and `WebviewWindow.getFocusedWindow` getters.
|
||||
|
||||
## \[1.3.0]
|
||||
|
||||
- Return correct type for `event.payload` in `onResized` and `onMoved` window event handlers.
|
||||
- [0b46637e](https://www.github.com/tauri-apps/tauri/commit/0b46637ebaba54403afa32a1cb466f09df2db999) fix(api): construct correct object for onResized and onMoved, closes [#6507](https://www.github.com/tauri-apps/tauri/pull/6507) ([#6509](https://www.github.com/tauri-apps/tauri/pull/6509)) on 2023-04-03
|
||||
- Added the `WindowOptions::contentProtected` option and `WebviewWindow#setContentProtected` to change it at runtime.
|
||||
- [4ab5545b](https://www.github.com/tauri-apps/tauri/commit/4ab5545b7a831c549f3c65e74de487ede3ab7ce5) feat: add content protection api, closes [#5132](https://www.github.com/tauri-apps/tauri/pull/5132) ([#5513](https://www.github.com/tauri-apps/tauri/pull/5513)) on 2022-12-13
|
||||
- Allow setting the text of the dialog buttons.
|
||||
- [00e1efaa](https://www.github.com/tauri-apps/tauri/commit/00e1efaa9b33876d41dd360624b69971e70d3856) feat: customize button texts of message dialog ([#4383](https://www.github.com/tauri-apps/tauri/pull/4383)) on 2022-12-28
|
||||
- Add `is_minimized()` window method.
|
||||
- [62144ef3](https://www.github.com/tauri-apps/tauri/commit/62144ef3be63b237869e511826edfb938e2c7174) feat: add is_minimized (fix [#3878](https://www.github.com/tauri-apps/tauri/pull/3878)) ([#5618](https://www.github.com/tauri-apps/tauri/pull/5618)) on 2022-12-13
|
||||
- Add `title` getter on window.
|
||||
- [233e43b0](https://www.github.com/tauri-apps/tauri/commit/233e43b0c34fada1ca025378533a0b76931a6540) feat: add `title` getter on window, closes [#5023](https://www.github.com/tauri-apps/tauri/pull/5023) ([#5515](https://www.github.com/tauri-apps/tauri/pull/5515)) on 2022-12-13
|
||||
|
||||
## \[1.2.0]
|
||||
|
||||
- Added the `acceptFirstMouse` window option.
|
||||
- [95f467ad](https://www.github.com/tauri-apps/tauri/commit/95f467add51448319983c54e2f382c7c09fb72d6) feat(core): add window `accept_first_mouse` option, closes [#5347](https://www.github.com/tauri-apps/tauri/pull/5347) ([#5374](https://www.github.com/tauri-apps/tauri/pull/5374)) on 2022-10-17
|
||||
- Fix incorrect return type on `fs/exists`
|
||||
- [ca3cd8b3](https://www.github.com/tauri-apps/tauri/commit/ca3cd8b3d11beb9b6102da40b7d27f6dbe6cd2d0) fix(api): fs/exists return type previously set to void when it should be boolean ([#5252](https://www.github.com/tauri-apps/tauri/pull/5252)) on 2022-09-29
|
||||
- Initialize `Monitor` instances with the correct classes for `position` and `size` fields instead of plain object.
|
||||
- [6f41a271](https://www.github.com/tauri-apps/tauri/commit/6f41a2712445ac41a5ed84bbcd40af3b76c8b1d8) fix(api.js): fix `Monitor` initialization, closes [#4672](https://www.github.com/tauri-apps/tauri/pull/4672) ([#5314](https://www.github.com/tauri-apps/tauri/pull/5314)) on 2022-09-30
|
||||
- **Breaking change:** Node.js v12 is no longer supported.
|
||||
- [1129f4f5](https://www.github.com/tauri-apps/tauri/commit/1129f4f575dd02f746abe8e66472c88c8f9fe63d) refactor: simplify api.js bundling ([#4277](https://www.github.com/tauri-apps/tauri/pull/4277)) on 2022-10-04
|
||||
- Add new app-specific `BaseDirectory` enum variants `AppConfig`, `AppData`, `AppLocalData`, `AppCache` and `AppLog` along with equivalent functions in `path` module and deprecated ambiguous variants `Log` and `App` along with their equivalent functions in `path` module.
|
||||
- [5d89905e](https://www.github.com/tauri-apps/tauri/commit/5d89905e39ce0e6eaaec50a693679335449edb32) feat(api): add app-specific directory APIs, closes [#5263](https://www.github.com/tauri-apps/tauri/pull/5263) ([#5272](https://www.github.com/tauri-apps/tauri/pull/5272)) on 2022-09-28
|
||||
- Fix `dialog.save` return type
|
||||
- [8357ce5b](https://www.github.com/tauri-apps/tauri/commit/8357ce5b2efdd6f92c7944822542e48ba0e303ce) Fix dialog.save return type ([#5373](https://www.github.com/tauri-apps/tauri/pull/5373)) on 2022-10-08
|
||||
- Added support to `FormData` on the `Body.form` function.
|
||||
- [aa119f28](https://www.github.com/tauri-apps/tauri/commit/aa119f28364f8ffbc64c6bcdfc77483613076a20) feat(api): add FormData support on Body.form, closes [#5545](https://www.github.com/tauri-apps/tauri/pull/5545) ([#5546](https://www.github.com/tauri-apps/tauri/pull/5546)) on 2022-11-04
|
||||
- Added `show` and `hide` methods on the `app` module.
|
||||
- [39bf895b](https://www.github.com/tauri-apps/tauri/commit/39bf895b73ec6b53f5758815396ba85dda6b9c67) feat(macOS): Add application `show` and `hide` methods ([#3689](https://www.github.com/tauri-apps/tauri/pull/3689)) on 2022-10-03
|
||||
- Added `tabbingIdentifier` window option for macOS.
|
||||
- [4137ab44](https://www.github.com/tauri-apps/tauri/commit/4137ab44a81d739556cbc7583485887e78952bf1) feat(macos): add `tabbing_identifier` option, closes [#2804](https://www.github.com/tauri-apps/tauri/pull/2804), [#3912](https://www.github.com/tauri-apps/tauri/pull/3912) ([#5399](https://www.github.com/tauri-apps/tauri/pull/5399)) on 2022-10-19
|
||||
- Added `tabbing_identifier` to the window builder on macOS.
|
||||
- [4137ab44](https://www.github.com/tauri-apps/tauri/commit/4137ab44a81d739556cbc7583485887e78952bf1) feat(macos): add `tabbing_identifier` option, closes [#2804](https://www.github.com/tauri-apps/tauri/pull/2804), [#3912](https://www.github.com/tauri-apps/tauri/pull/3912) ([#5399](https://www.github.com/tauri-apps/tauri/pull/5399)) on 2022-10-19
|
||||
- Added the `user_agent` option when creating a window.
|
||||
- [a6c94119](https://www.github.com/tauri-apps/tauri/commit/a6c94119d8545d509723b147c273ca5edfe3729f) feat(core): expose user_agent to window config ([#5317](https://www.github.com/tauri-apps/tauri/pull/5317)) on 2022-10-02
|
||||
|
||||
## \[1.1.0]
|
||||
|
||||
- Update `mockIPC()` handler signature to allow async handler functions.
|
||||
- [4fa968dc](https://www.github.com/tauri-apps/tauri/commit/4fa968dc0e74b5206bfcd54e704d180c16b67b08) fix(api): add async `mockIPC()` handler signature ([#5056](https://www.github.com/tauri-apps/tauri/pull/5056)) on 2022-08-26
|
||||
- Improve shell's `Command`, `Command.stdout` and `Command.stderr` events with new `once`, `off`, `listenerCount`, `prependListener`, `prependOnceListener` and `removeAllListeners` functions.
|
||||
- [aa9f1243](https://www.github.com/tauri-apps/tauri/commit/aa9f1243e6c1629972a82e469f20c8399741740e) Improved EventEmitter for tauri api shell ([#4697](https://www.github.com/tauri-apps/tauri/pull/4697)) on 2022-07-26
|
||||
- Added the `encoding` option to the `Command` options.
|
||||
- [d8cf9f9f](https://www.github.com/tauri-apps/tauri/commit/d8cf9f9fcd617ac24fa418952fd4a32c08804f5c) Command support for specified character encoding, closes [#4644](https://www.github.com/tauri-apps/tauri/pull/4644) ([#4772](https://www.github.com/tauri-apps/tauri/pull/4772)) on 2022-07-28
|
||||
- Add `exists` function to the fs module.
|
||||
- [3c62dbc9](https://www.github.com/tauri-apps/tauri/commit/3c62dbc902c904d35a7472ce72a969084c95fbbe) feat(api): Add `exists` function to the fs module. ([#5060](https://www.github.com/tauri-apps/tauri/pull/5060)) on 2022-09-15
|
||||
|
||||
## \[1.0.2]
|
||||
|
||||
- Added helper functions to listen to updater and window events.
|
||||
- [b02fc90f](https://www.github.com/tauri-apps/tauri/commit/b02fc90f450ff9e9d8a35ee55dc1beced4957869) feat(api): add abstractions to updater and window event listeners ([#4569](https://www.github.com/tauri-apps/tauri/pull/4569)) on 2022-07-05
|
||||
- Add support to `ArrayBuffer` in `Body.bytes` and `writeBinaryFile`.
|
||||
- [92aca55a](https://www.github.com/tauri-apps/tauri/commit/92aca55a6f1f899d5c0c3a6aae9ac9cb0a7e9a86) feat(api): add support to ArrayBuffer ([#4579](https://www.github.com/tauri-apps/tauri/pull/4579)) on 2022-07-05
|
||||
- Use `toString()` on message/confirm/ask dialogs title and message values.
|
||||
- [b8cd2a79](https://www.github.com/tauri-apps/tauri/commit/b8cd2a7993cd2aa5b71b30c545b3307245d254bf) feat(api): call `toString()` on dialog title and message, closes [#4583](https://www.github.com/tauri-apps/tauri/pull/4583) ([#4588](https://www.github.com/tauri-apps/tauri/pull/4588)) on 2022-07-04
|
||||
- Remove the `type-fest` dependency, changing the OS types to the specific enum instead of allowing any string.
|
||||
- [d5e910eb](https://www.github.com/tauri-apps/tauri/commit/d5e910ebcc6c8d7f055ab0691286722b140ffcd4) chore(api): remove `type-fest` ([#4605](https://www.github.com/tauri-apps/tauri/pull/4605)) on 2022-07-06
|
||||
|
||||
## \[1.0.1]
|
||||
|
||||
- Fixes the `writeBinaryFile` sending an empty file contents when only the first argument is passed.
|
||||
- [ea43cf52](https://www.github.com/tauri-apps/tauri/commit/ea43cf52db8541d20a6397ef3ecd40f0f2bd6113) fix(api): `writeBinaryFile` sends an empty contents with only one arg ([#4368](https://www.github.com/tauri-apps/tauri/pull/4368)) on 2022-06-16
|
||||
|
||||
## \[1.0.0]
|
||||
|
||||
- Allow choosing multiple folders in `dialog.open`.
|
||||
- [4e51dce6](https://www.github.com/tauri-apps/tauri/commit/4e51dce6ca21c7664de779bc78a04be1051371f7) fix: dialog open supports multiple dirs, fixes [#4091](https://www.github.com/tauri-apps/tauri/pull/4091) ([#4354](https://www.github.com/tauri-apps/tauri/pull/4354)) on 2022-06-15
|
||||
- Upgrade to `stable`!
|
||||
- [f4bb30cc](https://www.github.com/tauri-apps/tauri/commit/f4bb30cc73d6ba9b9ef19ef004dc5e8e6bb901d3) feat(covector): prepare for v1 ([#4351](https://www.github.com/tauri-apps/tauri/pull/4351)) on 2022-06-15
|
||||
|
||||
## \[1.0.0-rc.7]
|
||||
|
||||
- Fix `FilePart` usage in `http.Body.form` by renaming the `value` property to `file`.
|
||||
- [55f89d5f](https://www.github.com/tauri-apps/tauri/commit/55f89d5f9d429252ad3fd557b1d6233b256495e0) fix(api): Rename FormPart `value` to `file` to match docs and endpoint ([#4307](https://www.github.com/tauri-apps/tauri/pull/4307)) on 2022-06-09
|
||||
- Fixes a memory leak in the command system.
|
||||
- [f72cace3](https://www.github.com/tauri-apps/tauri/commit/f72cace36821dc675a6d25268ae85a21bdbd6296) fix: never remove ipc callback & mem never be released ([#4274](https://www.github.com/tauri-apps/tauri/pull/4274)) on 2022-06-05
|
||||
- The notification's `isPermissionGranted` function now returns `boolean` instead of `boolean | null`. The response is never `null` because we won't check the permission for now, always returning `true` instead.
|
||||
- [f482b094](https://www.github.com/tauri-apps/tauri/commit/f482b0942276e9402ab3725957535039bacb4fef) fix: remove notification permission prompt ([#4302](https://www.github.com/tauri-apps/tauri/pull/4302)) on 2022-06-09
|
||||
- Added the `resolveResource` API to the path module.
|
||||
- [7bba8db8](https://www.github.com/tauri-apps/tauri/commit/7bba8db83ead92e9bd9c4be7863742e71ac47513) feat(api): add `resolveResource` API to the path module ([#4234](https://www.github.com/tauri-apps/tauri/pull/4234)) on 2022-05-29
|
||||
- Renamed `writeFile` to `writeTextFile` but kept the original function for backwards compatibility.
|
||||
- [3f998ca2](https://www.github.com/tauri-apps/tauri/commit/3f998ca29445a349489078a74dd068e157a4d68e) feat(api): add `writeTextFile` and `(path, contents, options)` overload ([#4228](https://www.github.com/tauri-apps/tauri/pull/4228)) on 2022-05-29
|
||||
- Added `(path, contents[, options])` overload to the `writeTextFile` and `writeBinaryFile` APIs.
|
||||
- [3f998ca2](https://www.github.com/tauri-apps/tauri/commit/3f998ca29445a349489078a74dd068e157a4d68e) feat(api): add `writeTextFile` and `(path, contents, options)` overload ([#4228](https://www.github.com/tauri-apps/tauri/pull/4228)) on 2022-05-29
|
||||
|
||||
## \[1.0.0-rc.6]
|
||||
|
||||
- Expose option to set the dialog type.
|
||||
- [f46175d5](https://www.github.com/tauri-apps/tauri/commit/f46175d5d46fa3eae66ad2415a0eb1efb7d31da2) feat(core): expose option to set dialog type, closes [#4183](https://www.github.com/tauri-apps/tauri/pull/4183) ([#4187](https://www.github.com/tauri-apps/tauri/pull/4187)) on 2022-05-21
|
||||
- Expose `title` option in the message dialog API.
|
||||
- [ae99f991](https://www.github.com/tauri-apps/tauri/commit/ae99f991674d77c322a2240d10ed4b78ed2f4d4b) feat(core): expose message dialog's title option, ref [#4183](https://www.github.com/tauri-apps/tauri/pull/4183) ([#4186](https://www.github.com/tauri-apps/tauri/pull/4186)) on 2022-05-21
|
||||
|
||||
## \[1.0.0-rc.5]
|
||||
|
||||
- Fixes the type of `http > connectTimeout`.
|
||||
- [f3c5ca89](https://www.github.com/tauri-apps/tauri/commit/f3c5ca89e79d429183c4e15a9e7cebada2b493a0) fix(core): http api `connect_timeout` deserialization, closes [#4004](https://www.github.com/tauri-apps/tauri/pull/4004) ([#4006](https://www.github.com/tauri-apps/tauri/pull/4006)) on 2022-04-29
|
||||
|
||||
## \[1.0.0-rc.4]
|
||||
|
||||
- Encode the file path in the `convertFileSrc` function.
|
||||
- [42e8d9cf](https://www.github.com/tauri-apps/tauri/commit/42e8d9cf925089e9ad591198ee04b0cc0a0eed48) fix(api): encode file path in `convertFileSrc` function, closes [#3841](https://www.github.com/tauri-apps/tauri/pull/3841) ([#3846](https://www.github.com/tauri-apps/tauri/pull/3846)) on 2022-04-02
|
||||
- Added `theme` getter to `WebviewWindow`.
|
||||
- [4cebcf6d](https://www.github.com/tauri-apps/tauri/commit/4cebcf6da7cad1953e0f01b426afac3b5ef1f81e) feat: expose theme APIs, closes [#3903](https://www.github.com/tauri-apps/tauri/pull/3903) ([#3937](https://www.github.com/tauri-apps/tauri/pull/3937)) on 2022-04-21
|
||||
- Added `theme` field to `WindowOptions`.
|
||||
- [4cebcf6d](https://www.github.com/tauri-apps/tauri/commit/4cebcf6da7cad1953e0f01b426afac3b5ef1f81e) feat: expose theme APIs, closes [#3903](https://www.github.com/tauri-apps/tauri/pull/3903) ([#3937](https://www.github.com/tauri-apps/tauri/pull/3937)) on 2022-04-21
|
||||
- Added the `setCursorGrab`, `setCursorVisible`, `setCursorIcon` and `setCursorPosition` methods to the `WebviewWindow` class.
|
||||
- [c54ddfe9](https://www.github.com/tauri-apps/tauri/commit/c54ddfe9338e7eb90b4d5b02dfde687d432d5bc1) feat: expose window cursor APIs, closes [#3888](https://www.github.com/tauri-apps/tauri/pull/3888) [#3890](https://www.github.com/tauri-apps/tauri/pull/3890) ([#3935](https://www.github.com/tauri-apps/tauri/pull/3935)) on 2022-04-21
|
||||
- **Breaking change:** The process Command API stdio lines now includes the trailing `\r`.
|
||||
- [b5622882](https://www.github.com/tauri-apps/tauri/commit/b5622882cf3748e1e5a90915f415c0cd922aaaf8) fix(cli): exit on non-compilation Cargo errors, closes [#3930](https://www.github.com/tauri-apps/tauri/pull/3930) ([#3942](https://www.github.com/tauri-apps/tauri/pull/3942)) on 2022-04-22
|
||||
- Added the `tauri://theme-changed` event.
|
||||
- [4cebcf6d](https://www.github.com/tauri-apps/tauri/commit/4cebcf6da7cad1953e0f01b426afac3b5ef1f81e) feat: expose theme APIs, closes [#3903](https://www.github.com/tauri-apps/tauri/pull/3903) ([#3937](https://www.github.com/tauri-apps/tauri/pull/3937)) on 2022-04-21
|
||||
|
||||
## \[1.0.0-rc.3]
|
||||
|
||||
- Properly define the `appWindow` type.
|
||||
- [1deeb03e](https://www.github.com/tauri-apps/tauri/commit/1deeb03ef6c7cbea8cf585864424a3d66f184a02) fix(api.js): appWindow shown as type `any`, fixes [#3747](https://www.github.com/tauri-apps/tauri/pull/3747) ([#3772](https://www.github.com/tauri-apps/tauri/pull/3772)) on 2022-03-24
|
||||
- Added `Temp` to the `BaseDirectory` enum.
|
||||
- [266156a0](https://www.github.com/tauri-apps/tauri/commit/266156a0b08150b21140dd552c8bc252fe413cdd) feat(core): add `BaseDirectory::Temp` and `$TEMP` variable ([#3763](https://www.github.com/tauri-apps/tauri/pull/3763)) on 2022-03-24
|
||||
|
||||
## \[1.0.0-rc.2]
|
||||
|
||||
- Do not crash if `__TAURI_METADATA__` is not set, log an error instead.
|
||||
- [9cb1059a](https://www.github.com/tauri-apps/tauri/commit/9cb1059aa3f81521ccc6da655243acfe0327cd98) fix(api): do not throw an exception if **TAURI_METADATA** is not set, fixes [#3554](https://www.github.com/tauri-apps/tauri/pull/3554) ([#3572](https://www.github.com/tauri-apps/tauri/pull/3572)) on 2022-03-03
|
||||
- Reimplement endpoint to read file as string for performance.
|
||||
- [834ccc51](https://www.github.com/tauri-apps/tauri/commit/834ccc51539401d36a7dfa1c0982623c9c446a4c) feat(core): reimplement `readTextFile` for performance ([#3631](https://www.github.com/tauri-apps/tauri/pull/3631)) on 2022-03-07
|
||||
- Fixes a regression on the `unlisten` command.
|
||||
- [76c791bd](https://www.github.com/tauri-apps/tauri/commit/76c791bd2b836d2055410e37e71716172a3f81ef) fix(core): regression on the unlisten function ([#3623](https://www.github.com/tauri-apps/tauri/pull/3623)) on 2022-03-06
|
||||
|
||||
## \[1.0.0-rc.1]
|
||||
|
||||
- Provide functions to mock IPC calls during testing and static site generation.
|
||||
- [7e04c072](https://www.github.com/tauri-apps/tauri/commit/7e04c072c4ee2278c648f44575c6c4710ac047f3) feat: add mock functions for testing and SSG ([#3437](https://www.github.com/tauri-apps/tauri/pull/3437)) on 2022-02-14
|
||||
- [6f5ed2e6](https://www.github.com/tauri-apps/tauri/commit/6f5ed2e69cb7ffa0d5c8eb5a744fbf94ed6010d4) fix: change file on 2022-02-14
|
||||
|
||||
## \[1.0.0-rc.0]
|
||||
|
||||
- Add `fileDropEnabled` property to `WindowOptions` so you can now disable it when creating windows from js.
|
||||
|
||||
- [1bfc32a3](https://www.github.com/tauri-apps/tauri/commit/1bfc32a3b2f31b962ce8a5c611b60cb008360923) fix(api.js): add `fileDropEnabled` to `WindowOptions`, closes [#2968](https://www.github.com/tauri-apps/tauri/pull/2968) ([#2989](https://www.github.com/tauri-apps/tauri/pull/2989)) on 2021-12-09
|
||||
|
||||
- Add `logDir` function to the `path` module to access the suggested log directory.
|
||||
Add `BaseDirectory.Log` to the `fs` module.
|
||||
|
||||
- [acbb3ae7](https://www.github.com/tauri-apps/tauri/commit/acbb3ae7bb0165846b9456aea103269f027fc548) feat: add Log directory ([#2736](https://www.github.com/tauri-apps/tauri/pull/2736)) on 2021-10-16
|
||||
- [62c7a8ad](https://www.github.com/tauri-apps/tauri/commit/62c7a8ad30fd3031b8679960590e5ef3eef8e4da) chore(covector): prepare for `rc` release ([#3376](https://www.github.com/tauri-apps/tauri/pull/3376)) on 2022-02-10
|
||||
|
||||
- Expose `ask`, `message` and `confirm` APIs on the dialog module.
|
||||
|
||||
- [e98c1af4](https://www.github.com/tauri-apps/tauri/commit/e98c1af44279a5ff6c8a6f0a506ecc219c9f77af) feat(core): expose message dialog APIs, fix window.confirm, implement HasRawWindowHandle for Window, closes [#2535](https://www.github.com/tauri-apps/tauri/pull/2535) ([#2700](https://www.github.com/tauri-apps/tauri/pull/2700)) on 2021-10-02
|
||||
|
||||
- Event `emit` now automatically serialize non-string types.
|
||||
|
||||
- [06000996](https://www.github.com/tauri-apps/tauri/commit/060009969627890fa9018e2f1105bad13299394c) feat(api): support unknown types for event emit payload, closes [#2929](https://www.github.com/tauri-apps/tauri/pull/2929) ([#2964](https://www.github.com/tauri-apps/tauri/pull/2964)) on 2022-01-07
|
||||
|
||||
- Fix `http.fetch` throwing error if the response is successful but the body is empty.
|
||||
|
||||
- [50c63900](https://www.github.com/tauri-apps/tauri/commit/50c63900c7313064037e2ceb798a6432fcd1bcda) fix(api.js): fix `http.fetch` throwing error if response body is empty, closes [#2831](https://www.github.com/tauri-apps/tauri/pull/2831) ([#3008](https://www.github.com/tauri-apps/tauri/pull/3008)) on 2021-12-09
|
||||
|
||||
- Add `title` option to file open/save dialogs.
|
||||
|
||||
- [e1d6a6e6](https://www.github.com/tauri-apps/tauri/commit/e1d6a6e6445637723e2331ca799a662e720e15a8) Create api-file-dialog-title.md ([#3235](https://www.github.com/tauri-apps/tauri/pull/3235)) on 2022-01-16
|
||||
- [62c7a8ad](https://www.github.com/tauri-apps/tauri/commit/62c7a8ad30fd3031b8679960590e5ef3eef8e4da) chore(covector): prepare for `rc` release ([#3376](https://www.github.com/tauri-apps/tauri/pull/3376)) on 2022-02-10
|
||||
|
||||
- Fix `os.platform` returning `macos` and `windows` instead of `darwin` and `win32`.
|
||||
|
||||
- [3924c3d8](https://www.github.com/tauri-apps/tauri/commit/3924c3d85365df30b376a1ec6c2d933460d66af0) fix(api.js): fix `os.platform` return on macos and windows, closes [#2698](https://www.github.com/tauri-apps/tauri/pull/2698) ([#2699](https://www.github.com/tauri-apps/tauri/pull/2699)) on 2021-10-02
|
||||
|
||||
- The `formatCallback` helper function now returns a number instead of a string.
|
||||
|
||||
- [a48b8b18](https://www.github.com/tauri-apps/tauri/commit/a48b8b18d428bcc404d489daa690bbefe1f57311) feat(core): validate callbacks and event names \[TRI-038] \[TRI-020] ([#21](https://www.github.com/tauri-apps/tauri/pull/21)) on 2022-01-09
|
||||
|
||||
- Added `rawHeaders` to `http > Response`.
|
||||
|
||||
- [b7a2345b](https://www.github.com/tauri-apps/tauri/commit/b7a2345b06ca0306988b4ba3d3deadd449e65af9) feat(core): add raw headers to HTTP API, closes [#2695](https://www.github.com/tauri-apps/tauri/pull/2695) ([#3053](https://www.github.com/tauri-apps/tauri/pull/3053)) on 2022-01-07
|
||||
|
||||
- Removed the `currentDir` API from the `path` module.
|
||||
|
||||
- [a08509c6](https://www.github.com/tauri-apps/tauri/commit/a08509c641f43695e25944a2dd47697b18cd83e2) fix(api): remove `currentDir` API from the `path` module on 2022-02-04
|
||||
|
||||
- Remove `.ts` files on the published package.
|
||||
|
||||
- [0f321ac0](https://www.github.com/tauri-apps/tauri/commit/0f321ac08d56412edd5bc9d166201fbc95d887d8) fix(api): do not ship TS files, closes [#2598](https://www.github.com/tauri-apps/tauri/pull/2598) ([#2645](https://www.github.com/tauri-apps/tauri/pull/2645)) on 2021-09-23
|
||||
|
||||
- **Breaking change:** Replaces all usages of `number[]` with `Uint8Array` to be closer aligned with the wider JS ecosystem.
|
||||
|
||||
- [9b19a805](https://www.github.com/tauri-apps/tauri/commit/9b19a805aa8efa64b22f2dfef193a144b8e0cee3) fix(api.js) Replace `number[]`with `Uint8Array`. fixes [#3306](https://www.github.com/tauri-apps/tauri/pull/3306) ([#3305](https://www.github.com/tauri-apps/tauri/pull/3305)) on 2022-02-05
|
||||
|
||||
- `WindowManager` methods `innerPosition` `outerPosition` now correctly return instance of `PhysicalPosition`.
|
||||
`WindowManager` methods `innerSize` `outerSize` now correctly return instance of `PhysicalSize`.
|
||||
|
||||
- [cc8b1468](https://www.github.com/tauri-apps/tauri/commit/cc8b1468c821df53ceb771061c919409a9c80978) Fix(api): Window size and position returning wrong class (fix: [#2599](https://www.github.com/tauri-apps/tauri/pull/2599)) ([#2621](https://www.github.com/tauri-apps/tauri/pull/2621)) on 2021-09-22
|
||||
|
||||
- Change the `event` field of the `Event` interface to type `EventName` instead of `string`.
|
||||
|
||||
- [b5d9bcb4](https://www.github.com/tauri-apps/tauri/commit/b5d9bcb402380abc86ae1fa1a77c629af2275f9d) Consistent event name usage ([#3228](https://www.github.com/tauri-apps/tauri/pull/3228)) on 2022-01-15
|
||||
- [62c7a8ad](https://www.github.com/tauri-apps/tauri/commit/62c7a8ad30fd3031b8679960590e5ef3eef8e4da) chore(covector): prepare for `rc` release ([#3376](https://www.github.com/tauri-apps/tauri/pull/3376)) on 2022-02-10
|
||||
|
||||
- Now `resolve()`, `join()` and `normalize()` from the `path` module, won't throw errors if the path doesn't exist, which matches NodeJS behavior.
|
||||
|
||||
- [fe381a0b](https://www.github.com/tauri-apps/tauri/commit/fe381a0bde86ebf4014007f6e21af4c1a9e58cef) fix: `join` no longer cares if path doesn't exist, closes [#2499](https://www.github.com/tauri-apps/tauri/pull/2499) ([#2548](https://www.github.com/tauri-apps/tauri/pull/2548)) on 2021-09-21
|
||||
|
||||
- Fixes the dialog `defaultPath` usage on Linux.
|
||||
|
||||
- [2212bd5d](https://www.github.com/tauri-apps/tauri/commit/2212bd5d75146f5a2df27cc2157a057642f626da) fix: dialog default path on Linux, closes [#3091](https://www.github.com/tauri-apps/tauri/pull/3091) ([#3123](https://www.github.com/tauri-apps/tauri/pull/3123)) on 2021-12-27
|
||||
|
||||
- Fixes `window.label` property returning null instead of the actual label.
|
||||
|
||||
- [f5109e0c](https://www.github.com/tauri-apps/tauri/commit/f5109e0c962e3d25404995194968bade1be33b16) fix(api): window label null instead of actual value, closes [#3295](https://www.github.com/tauri-apps/tauri/pull/3295) ([#3332](https://www.github.com/tauri-apps/tauri/pull/3332)) on 2022-02-04
|
||||
|
||||
- Remove the `BaseDirectory::Current` enum variant for security reasons.
|
||||
|
||||
- [696dca58](https://www.github.com/tauri-apps/tauri/commit/696dca58a9f8ee127a1cf857eb848e09f5845d18) refactor(core): remove `BaseDirectory::Current` variant on 2022-01-26
|
||||
|
||||
- Change `WindowLabel` type to `string`.
|
||||
|
||||
- [f68603ae](https://www.github.com/tauri-apps/tauri/commit/f68603aee4e16500dff9e385b217f5dd8b1b39e8) chore(docs): simplify event system documentation on 2021-09-27
|
||||
|
||||
- When building Universal macOS Binaries through the virtual target `universal-apple-darwin`:
|
||||
|
||||
- Expect a universal binary to be created by the user
|
||||
|
||||
- Ensure that binary is bundled and accessed correctly at runtime
|
||||
|
||||
- [3035e458](https://www.github.com/tauri-apps/tauri/commit/3035e4581c161ec7f0bd6d9b42e9015cf1dd1d77) Remove target triple from sidecar bin paths, closes [#3355](https://www.github.com/tauri-apps/tauri/pull/3355) ([#3356](https://www.github.com/tauri-apps/tauri/pull/3356)) on 2022-02-07
|
||||
|
||||
## \[1.0.0-beta.8]
|
||||
|
||||
- Revert target back to ES5.
|
||||
- [657c7dac](https://www.github.com/tauri-apps/tauri/commit/657c7dac734661956b87d021ff531ba530dd92a3) fix(api): revert ES2021 target on 2021-08-23
|
||||
|
||||
## \[1.0.0-beta.7]
|
||||
|
||||
- Fix missing asset protocol path.Now the protocol is `https://asset.localhost/path/to/file` on Windows. Linux and macOS
|
||||
is still `asset://path/to/file`.
|
||||
- [994b5325](https://www.github.com/tauri-apps/tauri/commit/994b5325dd385f564b37fe1530c5d798dc925fff) fix: missing asset protocol path ([#2484](https://www.github.com/tauri-apps/tauri/pull/2484)) on 2021-08-23
|
||||
|
||||
## \[1.0.0-beta.6]
|
||||
|
||||
- `bundle` now exports `clipboard` module so you can `import { clipboard } from "@tauri-apps/api"`.
|
||||
- [4f88c3fb](https://www.github.com/tauri-apps/tauri/commit/4f88c3fb94286f3daafb906e3513c9210ecfa76b) fix(api.js): `bundle` now exports `clipboard` mod, closes [#2243](https://www.github.com/tauri-apps/tauri/pull/2243) ([#2244](https://www.github.com/tauri-apps/tauri/pull/2244)) on 2021-07-19
|
||||
- Fix double window creation
|
||||
- [9fbcc024](https://www.github.com/tauri-apps/tauri/commit/9fbcc024542d87f71afd364acdcf2302cf82912c) fix(api.js): fix double window creation, closes [#2284](https://www.github.com/tauri-apps/tauri/pull/2284) ([#2285](https://www.github.com/tauri-apps/tauri/pull/2285)) on 2021-07-23
|
||||
- Add `os` module which exports `EOL`, `platform()`, `version()`, `type()`, `arch()`, `tempdir()`
|
||||
- [05e679a6](https://www.github.com/tauri-apps/tauri/commit/05e679a6d2aca5642c780052bcf1384c49a462de) feat(api.js): add `os` module ([#2299](https://www.github.com/tauri-apps/tauri/pull/2299)) on 2021-07-28
|
||||
- - Add new nodejs-inspired functions which are `join`, `resolve`, `normalize`, `dirname`, `basename` and `extname`.
|
||||
- Add `sep` and `delimiter` constants.
|
||||
- Removed `resolvePath` API, use `resolve` instead.
|
||||
- [05b9d81e](https://www.github.com/tauri-apps/tauri/commit/05b9d81ee6bcc920defca76cff00178b301fffe8) feat(api.js): add nodejs-inspired functions in `path` module ([#2310](https://www.github.com/tauri-apps/tauri/pull/2310)) on 2021-08-02
|
||||
- Change target to ES2021.
|
||||
- [97bc52ee](https://www.github.com/tauri-apps/tauri/commit/97bc52ee03dec0b67cc1cced23305a4c53e9eb62) Tooling: \[API] Changed target in tsconfig to es6 ([#2362](https://www.github.com/tauri-apps/tauri/pull/2362)) on 2021-08-09
|
||||
- Add `toggleMaximize()` function to the `WebviewWindow` class.
|
||||
- [1a510066](https://www.github.com/tauri-apps/tauri/commit/1a510066732d5f61c88c0ceed1c5f5cc559faf7d) fix(core): `data-tauri-drag-region` didn't respect resizable, closes [#2314](https://www.github.com/tauri-apps/tauri/pull/2314) ([#2316](https://www.github.com/tauri-apps/tauri/pull/2316)) on 2021-08-02
|
||||
- Fix `@ts-expect` error usage
|
||||
- [dd52e738](https://www.github.com/tauri-apps/tauri/commit/dd52e738f1fd323bd8d185d6e650f412eb031200) fix(api.js): fix `@ts-expect-error` usage, closes [#2249](https://www.github.com/tauri-apps/tauri/pull/2249) ([#2250](https://www.github.com/tauri-apps/tauri/pull/2250)) on 2021-07-20
|
||||
- Fixes file drop events being swapped (`file-drop-hover` on drop and `file-drop` on hover).
|
||||
- [c2b0fe1c](https://www.github.com/tauri-apps/tauri/commit/c2b0fe1ce58e54dbcfdb63162ad17d7e6d8774d9) fix(core): fix wrong file drop events ([#2300](https://www.github.com/tauri-apps/tauri/pull/2300)) on 2021-07-31
|
||||
- Fixes the global bundle UMD code.
|
||||
- [268450b1](https://www.github.com/tauri-apps/tauri/commit/268450b1329a4b55f2043890c565a8563f890c3a) fix(api): global bundle broken code, closes [#2289](https://www.github.com/tauri-apps/tauri/pull/2289) ([#2297](https://www.github.com/tauri-apps/tauri/pull/2297)) on 2021-07-26
|
||||
- - Fixes monitor api not working.
|
||||
- Fixes window.print() not working on macOS.
|
||||
- [0f63f5e7](https://www.github.com/tauri-apps/tauri/commit/0f63f5e757873f1787a1ae07ca531340d0d45ec3) fix(api): Fix monitor functions, closes [#2294](https://www.github.com/tauri-apps/tauri/pull/2294) ([#2301](https://www.github.com/tauri-apps/tauri/pull/2301)) on 2021-07-29
|
||||
- Improve `EventName` type using `type-fest`'s `LiteralUnion`.
|
||||
- [8e480297](https://www.github.com/tauri-apps/tauri/commit/8e48029790857b38988da4d291aa7458f51bb265) feat(api): improve `EventName` type definition ([#2379](https://www.github.com/tauri-apps/tauri/pull/2379)) on 2021-08-10
|
||||
- Update protocol url path with wry 0.12.1 on Windows.
|
||||
- [88382fe1](https://www.github.com/tauri-apps/tauri/commit/88382fe147ebcb3f59308cc529e5562a04970876) chore(api): update protocol url path with wry 0.12.1 on Windows ([#2409](https://www.github.com/tauri-apps/tauri/pull/2409)) on 2021-08-13
|
||||
|
||||
## \[1.0.0-beta.5]
|
||||
|
||||
- Adds `convertFileSrc` helper to the `tauri` module, simplifying the process of using file paths as webview source (`img`, `video`, etc).
|
||||
- [51a5cfe4](https://www.github.com/tauri-apps/tauri/commit/51a5cfe4b5e9890fb6f639c9c929657fd747a595) feat(api): add `convertFileSrc` helper ([#2138](https://www.github.com/tauri-apps/tauri/pull/2138)) on 2021-07-02
|
||||
- You can now use `emit`, `listen` and `once` using the `appWindow` exported by the window module.
|
||||
- [5d7626f8](https://www.github.com/tauri-apps/tauri/commit/5d7626f89781a6ebccceb9ab3b2e8335aa7a0392) feat(api): WindowManager extends WebviewWindowHandle, add events docs ([#2146](https://www.github.com/tauri-apps/tauri/pull/2146)) on 2021-07-03
|
||||
- Allow manipulating a spawned window directly using `WebviewWindow`, which now extends `WindowManager`.
|
||||
- [d69b1cf6](https://www.github.com/tauri-apps/tauri/commit/d69b1cf6d7c13297073073d753e30fe1a22a09cb) feat(api): allow managing windows created on JS ([#2154](https://www.github.com/tauri-apps/tauri/pull/2154)) on 2021-07-05
|
||||
|
||||
## \[1.0.0-beta.4]
|
||||
|
||||
- Add asset custom protocol to access local file system.
|
||||
- [ee60e424](https://www.github.com/tauri-apps/tauri/commit/ee60e424221559d3d725716b0003c5566ef2b5cd) feat: asset custom protocol to access local file system ([#2104](https://www.github.com/tauri-apps/tauri/pull/2104)) on 2021-06-28
|
||||
|
||||
## \[1.0.0-beta.3]
|
||||
|
||||
- Export `Response` and `ResponseType` as value instead of type.
|
||||
- [394b6e05](https://www.github.com/tauri-apps/tauri/commit/394b6e0572e7a0a92e103e462a7f603f7d569319) fix(api): http `ResponseType` export type error ([#2065](https://www.github.com/tauri-apps/tauri/pull/2065)) on 2021-06-24
|
||||
|
||||
## \[1.0.0-beta.2]
|
||||
|
||||
- Export `BaseDirectory` in `path` module
|
||||
- [277f5ca5](https://www.github.com/tauri-apps/tauri/commit/277f5ca5a8ae227bbdccee1ad52bdd88b4a5b11b) feat(api): export `BaseDirectory` in `path` module ([#1885](https://www.github.com/tauri-apps/tauri/pull/1885)) on 2021-05-30
|
||||
- Use `export type` to export TS types, enums and interfaces.
|
||||
- [9a662d26](https://www.github.com/tauri-apps/tauri/commit/9a662d2601b01d712c6bd205f8db1b674f56dfa7) fix: Monitor if --isolatedModules is enabled ([#1825](https://www.github.com/tauri-apps/tauri/pull/1825)) on 2021-05-13
|
||||
- [612cd8ec](https://www.github.com/tauri-apps/tauri/commit/612cd8ecb8e02954f3696b9e138cbc7d2c228fad) feat(api): finalize `export type` usage ([#1847](https://www.github.com/tauri-apps/tauri/pull/1847)) on 2021-05-17
|
||||
- Adds `focus?: boolean` to the WindowOptions interface.
|
||||
- [5f351622](https://www.github.com/tauri-apps/tauri/commit/5f351622c7812ad1bb56ddb37364ccaa4124c24b) feat(core): add focus API to the WindowBuilder and WindowOptions, [#1737](https://www.github.com/tauri-apps/tauri/pull/1737) on 2021-05-30
|
||||
- Adds `isDecorated` getter on the window API.
|
||||
- [f58a2114](https://www.github.com/tauri-apps/tauri/commit/f58a2114fbfd5307c349f05c88f2e08fd8baa8aa) feat(core): add `is_decorated` Window getter on 2021-05-30
|
||||
- Adds `isResizable` getter on the window API.
|
||||
- [1e8af280](https://www.github.com/tauri-apps/tauri/commit/1e8af280c27f381828d6209722b10e889082fa00) feat(core): add `is_resizable` Window getter on 2021-05-30
|
||||
- Adds `isVisible` getter on the window API.
|
||||
- [36506c96](https://www.github.com/tauri-apps/tauri/commit/36506c967de82bc7ff453d11e6104ecf66d7a588) feat(core): add `is_visible` API on 2021-05-30
|
||||
- Adds `requestUserAttention` API to the `window` module.
|
||||
- [7dcca6e9](https://www.github.com/tauri-apps/tauri/commit/7dcca6e9281182b11ad3d4a79871f09b30b9b419) feat(core): add `request_user_attention` API, closes [#2023](https://www.github.com/tauri-apps/tauri/pull/2023) ([#2026](https://www.github.com/tauri-apps/tauri/pull/2026)) on 2021-06-20
|
||||
- Adds `setFocus` to the window API.
|
||||
- [bb6992f8](https://www.github.com/tauri-apps/tauri/commit/bb6992f888196ca7c87bb2fe74ad2bd8bf393e05) feat(core): add `set_focus` window API, fixes [#1737](https://www.github.com/tauri-apps/tauri/pull/1737) on 2021-05-30
|
||||
- Adds `setSkipTaskbar` to the window API.
|
||||
- [e06aa277](https://www.github.com/tauri-apps/tauri/commit/e06aa277384450cfef617c0e57b0d5d403bb1e7f) feat(core): add `set_skip_taskbar` API on 2021-05-30
|
||||
- Adds `skipTaskbar?: boolean` to the WindowOptions interface.
|
||||
- [5525b03a](https://www.github.com/tauri-apps/tauri/commit/5525b03a78a2232c650043fbd9894ce1553cad41) feat(core): add `skip_taskbar` API to the WindowBuilder/WindowOptions on 2021-05-30
|
||||
- Adds `center?: boolean` to `WindowOptions` and `center()` API to the `appWindow`.
|
||||
- [5cba6eb4](https://www.github.com/tauri-apps/tauri/commit/5cba6eb4d28d53f06855d60d4d0eae6b95233ccf) feat(core): add window `center` API, closes [#1822](https://www.github.com/tauri-apps/tauri/pull/1822) ([#1954](https://www.github.com/tauri-apps/tauri/pull/1954)) on 2021-06-05
|
||||
- Adds `clipboard` APIs (write and read text).
|
||||
- [285bf64b](https://www.github.com/tauri-apps/tauri/commit/285bf64bf9569efb2df904c69c6df405ff0d62e2) feat(core): add clipboard writeText and readText APIs ([#2035](https://www.github.com/tauri-apps/tauri/pull/2035)) on 2021-06-21
|
||||
- [dee71ad5](https://www.github.com/tauri-apps/tauri/commit/dee71ad58349f699995cc9077b79032bacc6afcb) fix(workflows): update docs workflow syntax ([#2054](https://www.github.com/tauri-apps/tauri/pull/2054)) on 2021-06-23
|
||||
- The `http` APIs now resolve the returned promise when the API call finishes with an error status code.
|
||||
- [47f75584](https://www.github.com/tauri-apps/tauri/commit/47f7558417cc654bdb1d018127e8900bc4eac622) fix(core): resolve HTTP API on non-ok status code, fix binary response, closes [#2046](https://www.github.com/tauri-apps/tauri/pull/2046) ([#2053](https://www.github.com/tauri-apps/tauri/pull/2053)) on 2021-06-23
|
||||
- Improve RPC security by requiring a numeric code to invoke commands. The codes are generated by the Rust side and injected into the app's code using a closure, so external scripts can't access the backend. This change doesn't protect `withGlobalTauri` (`window.__TAURI__`) usage.
|
||||
- [160fb052](https://www.github.com/tauri-apps/tauri/commit/160fb0529fd31d755574ae30fbdf01fa221a2acb) feat(core): improve RPC security, closes [#814](https://www.github.com/tauri-apps/tauri/pull/814) ([#2047](https://www.github.com/tauri-apps/tauri/pull/2047)) on 2021-06-22
|
||||
- Mark the `WebviewWindow` constructor as public.
|
||||
- [4aeb936e](https://www.github.com/tauri-apps/tauri/commit/4aeb936e9b60b895d383597dc698ee5d638436f9) fix(api): `WebviewWindow` constructor is public ([#1888](https://www.github.com/tauri-apps/tauri/pull/1888)) on 2021-05-21
|
||||
- Validate arguments on the window `setLocation`, `setSize`, `setMinSize` and `setMaxSize` API.
|
||||
- [7616e6cc](https://www.github.com/tauri-apps/tauri/commit/7616e6cc7bcd49f688b0d00fdc33c94b7b93713d) feat(api): validate window API `size` and `location` arguments ([#1846](https://www.github.com/tauri-apps/tauri/pull/1846)) on 2021-05-17
|
||||
|
||||
## \[1.0.0-beta.1]
|
||||
|
||||
- Adds `package.json` to the `exports` object.
|
||||
- [ab1ea96](https://www.github.com/tauri-apps/tauri/commit/ab1ea964786e1781c922582b059c555b6072f1a0) chore(api): add `package.json` to the `exports` field ([#1807](https://www.github.com/tauri-apps/tauri/pull/1807)) on 2021-05-12
|
||||
|
||||
## \[1.0.0-beta.0]
|
||||
|
||||
- CommonJS chunks are now properly exported with `.cjs` extension
|
||||
- [ddcd923](https://www.github.com/tauri-apps/tauri/commit/ddcd9233bd6f499aa7f22484d6c151b01778bc1b) fix(api): export commonjs chunks with `.cjs` extension, fix [#1625](https://www.github.com/tauri-apps/tauri/pull/1625) ([#1627](https://www.github.com/tauri-apps/tauri/pull/1627)) on 2021-04-26
|
||||
- Adds `transparent?: boolean` to the `WindowOptions` interface.
|
||||
- [08c1c5c](https://www.github.com/tauri-apps/tauri/commit/08c1c5ca5c0ebe17ea98689a5fe3b7e47a98e955) fix(api): missing `transparent` flag on `WindowOptions` ([#1764](https://www.github.com/tauri-apps/tauri/pull/1764)) on 2021-05-10
|
||||
- Adds `options` argument to the shell command API (`env` and `cwd` configuration).
|
||||
- [721e98f](https://www.github.com/tauri-apps/tauri/commit/721e98f175567b360c86f30565ab1b9d08e7cf85) feat(core): add env, cwd to the command API, closes [#1634](https://www.github.com/tauri-apps/tauri/pull/1634) ([#1635](https://www.github.com/tauri-apps/tauri/pull/1635)) on 2021-04-28
|
||||
- Adds `startDragging` API on the window module.
|
||||
- [c31f097](https://www.github.com/tauri-apps/tauri/commit/c31f0978c535f794fffb75a121e69a323e70b06e) refactor: update to wry 0.9 ([#1630](https://www.github.com/tauri-apps/tauri/pull/1630)) on 2021-04-28
|
||||
- Move `exit` and `relaunch` APIs from `app` to `process` module.
|
||||
- [b0bb796](https://www.github.com/tauri-apps/tauri/commit/b0bb796a42e2560233aea47ce6ced54ac238eb53) refactor: rename `command` mod to `process`, move restart_application ([#1667](https://www.github.com/tauri-apps/tauri/pull/1667)) on 2021-04-30
|
||||
- The window management API was refactored: removed `setX`, `setY`, `setWidth`, `setHeight` APIs, renamed `resize` to `setSize` and the size and position APIs now allow defining both logical and physical values.
|
||||
- [6bfac86](https://www.github.com/tauri-apps/tauri/commit/6bfac866a703f1499a64237fb29b2625703f4e22) refactor(core): add window getters, physical & logical sizes/positions ([#1723](https://www.github.com/tauri-apps/tauri/pull/1723)) on 2021-05-05
|
||||
- Adds window getters.
|
||||
- [6bfac86](https://www.github.com/tauri-apps/tauri/commit/6bfac866a703f1499a64237fb29b2625703f4e22) refactor(core): add window getters, physical & logical sizes/positions ([#1723](https://www.github.com/tauri-apps/tauri/pull/1723)) on 2021-05-05
|
||||
|
||||
## \[1.0.0-beta-rc.3]
|
||||
|
||||
- Fixes distribution of the `@tauri-apps/api` package for older bundlers.
|
||||
- [7f998d0](https://www.github.com/tauri-apps/tauri/commit/7f998d08e3ab8823c99190fa283bdfa2c4f2749b) fix(api): distribution ([#1582](https://www.github.com/tauri-apps/tauri/pull/1582)) on 2021-04-22
|
||||
- Update minimum Node.js version to v12.13.0
|
||||
- [1f089fb](https://www.github.com/tauri-apps/tauri/commit/1f089fb4f964c673dcab5784bdf1da2833487a7c) chore: update minimum nodejs version to 12.13.0 ([#1562](https://www.github.com/tauri-apps/tauri/pull/1562)) on 2021-04-21
|
||||
|
||||
## \[1.0.0-beta-rc.2]
|
||||
|
||||
- TS was wrongly re-exporting the module.
|
||||
- [fcb3b48](https://www.github.com/tauri-apps/tauri/commit/fcb3b4857efa17d2a3717f32457e88b24520cc9b) fix: [#1512](https://www.github.com/tauri-apps/tauri/pull/1512) ([#1517](https://www.github.com/tauri-apps/tauri/pull/1517)) on 2021-04-19
|
||||
- [ae14a3f](https://www.github.com/tauri-apps/tauri/commit/ae14a3ff51a742b6ab6f76bbfc21f385310f1dc6) fix: [#1517](https://www.github.com/tauri-apps/tauri/pull/1517) had the wrong package reference in the changefile ([#1538](https://www.github.com/tauri-apps/tauri/pull/1538)) on 2021-04-19
|
||||
|
||||
## \[1.0.0-beta-rc.1]
|
||||
|
||||
- Missing the `files` property in the package.json which mean that the `dist` directory was not published and used.
|
||||
- [b2569a7](https://www.github.com/tauri-apps/tauri/commit/b2569a729a3caa88bdba62abc31f0665e1323aaa) fix(js-api): dist ([#1498](https://www.github.com/tauri-apps/tauri/pull/1498)) on 2021-04-15
|
||||
|
||||
## \[1.0.0-beta-rc.0]
|
||||
|
||||
- Add current working directory to the path api module.
|
||||
- [52c2baf](https://www.github.com/tauri-apps/tauri/commit/52c2baf940773cf7c51647fb6f20d0f7df126115) feat: add current working directory to path api module ([#1375](https://www.github.com/tauri-apps/tauri/pull/1375)) on 2021-03-23
|
||||
- [a6def70](https://www.github.com/tauri-apps/tauri/commit/a6def7066eec19c889b0f14cc1e475bf209a332e) Refactor(tauri): move tauri-api and tauri-updater to tauri ([#1455](https://www.github.com/tauri-apps/tauri/pull/1455)) on 2021-04-11
|
||||
- The shell process spawning API was rewritten and now includes stream access.
|
||||
- [3713066](https://www.github.com/tauri-apps/tauri/commit/3713066e451bd30d0cc6f57bb437f08276f4c4ad) refactor(core): rewrite shell execute API, closes [#1229](https://www.github.com/tauri-apps/tauri/pull/1229) ([#1408](https://www.github.com/tauri-apps/tauri/pull/1408)) on 2021-03-31
|
||||
- The file dialog API now uses [rfd](https://github.com/PolyMeilex/rfd). The filter option is now an array of `{ name: string, extensions: string[] }`.
|
||||
- [2326bcd](https://www.github.com/tauri-apps/tauri/commit/2326bcd399411f7f0eabdb7ade910be473adadae) refactor(core): use `nfd` for file dialogs, closes [#1251](https://www.github.com/tauri-apps/tauri/pull/1251) ([#1257](https://www.github.com/tauri-apps/tauri/pull/1257)) on 2021-02-18
|
||||
- [a6def70](https://www.github.com/tauri-apps/tauri/commit/a6def7066eec19c889b0f14cc1e475bf209a332e) Refactor(tauri): move tauri-api and tauri-updater to tauri ([#1455](https://www.github.com/tauri-apps/tauri/pull/1455)) on 2021-04-11
|
||||
- The HTTP API was improved with client caching and better payload and response types.
|
||||
- [a7bc472](https://www.github.com/tauri-apps/tauri/commit/a7bc472e994730071f960d09a12ac85296a080ae) refactor(core): improve HTTP API, closes [#1098](https://www.github.com/tauri-apps/tauri/pull/1098) ([#1237](https://www.github.com/tauri-apps/tauri/pull/1237)) on 2021-02-15
|
||||
- [a6def70](https://www.github.com/tauri-apps/tauri/commit/a6def7066eec19c889b0f14cc1e475bf209a332e) Refactor(tauri): move tauri-api and tauri-updater to tauri ([#1455](https://www.github.com/tauri-apps/tauri/pull/1455)) on 2021-04-11
|
||||
- Update all code files to have our license header.
|
||||
- [bf82136](https://www.github.com/tauri-apps/tauri/commit/bf8213646689175f8a158b956911f3a43e360690) feat(license): SPDX Headers ([#1449](https://www.github.com/tauri-apps/tauri/pull/1449)) on 2021-04-11
|
||||
- [a6def70](https://www.github.com/tauri-apps/tauri/commit/a6def7066eec19c889b0f14cc1e475bf209a332e) Refactor(tauri): move tauri-api and tauri-updater to tauri ([#1455](https://www.github.com/tauri-apps/tauri/pull/1455)) on 2021-04-11
|
||||
- [aea6145](https://www.github.com/tauri-apps/tauri/commit/aea614587bddab930d552512b54e18624fbf573e) refactor(repo): add /tooling folder ([#1457](https://www.github.com/tauri-apps/tauri/pull/1457)) on 2021-04-12
|
||||
- Use secure RNG on callback function names.
|
||||
- [c8992bb](https://www.github.com/tauri-apps/tauri/commit/c8992bb0bfb8eaeae8ebed444719f9c9372d39d4) refactor(api): use secure RNG, closes [#1356](https://www.github.com/tauri-apps/tauri/pull/1356) ([#1398](https://www.github.com/tauri-apps/tauri/pull/1398)) on 2021-03-30
|
||||
- The invoke function can now be called with the cmd as the first parameter and the args as the second.
|
||||
- [427d170](https://www.github.com/tauri-apps/tauri/commit/427d170930ab711fd0ca82f7a73b524d6fdc222f) feat(api/invoke): separate cmd arg ([#1321](https://www.github.com/tauri-apps/tauri/pull/1321)) on 2021-03-04
|
||||
- Adds a global shortcut API.
|
||||
- [855effa](https://www.github.com/tauri-apps/tauri/commit/855effadd9ebfb6bc1a3555ac7fc733f6f766b7a) feat(core): globalShortcut API ([#1232](https://www.github.com/tauri-apps/tauri/pull/1232)) on 2021-02-14
|
||||
- [a6def70](https://www.github.com/tauri-apps/tauri/commit/a6def7066eec19c889b0f14cc1e475bf209a332e) Refactor(tauri): move tauri-api and tauri-updater to tauri ([#1455](https://www.github.com/tauri-apps/tauri/pull/1455)) on 2021-04-11
|
||||
- Added window management and window creation APIs.
|
||||
- [a3d6dff](https://www.github.com/tauri-apps/tauri/commit/a3d6dff2163c7a45842253edd81dbc62248dc65d) feat(core): window API ([#1225](https://www.github.com/tauri-apps/tauri/pull/1225)) on 2021-02-13
|
||||
- [641374b](https://www.github.com/tauri-apps/tauri/commit/641374b15343518cd835bd5ada811941c65dcf2e) feat(core): window creation at runtime ([#1249](https://www.github.com/tauri-apps/tauri/pull/1249)) on 2021-02-17
|
177
node_modules/@tauri-apps/api/LICENSE_APACHE-2.0
generated
vendored
Normal file
177
node_modules/@tauri-apps/api/LICENSE_APACHE-2.0
generated
vendored
Normal file
@ -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
|
21
node_modules/@tauri-apps/api/LICENSE_MIT
generated
vendored
Normal file
21
node_modules/@tauri-apps/api/LICENSE_MIT
generated
vendored
Normal file
@ -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.
|
52
node_modules/@tauri-apps/api/README.md
generated
vendored
Normal file
52
node_modules/@tauri-apps/api/README.md
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
# @tauri-apps/api
|
||||
|
||||
<img align="right" src="https://github.com/tauri-apps/tauri/raw/dev/.github/icon.png" height="128" width="128">
|
||||
|
||||
[](https://github.com/tauri-apps/tauri/tree/dev)
|
||||
[](https://opencollective.com/tauri)
|
||||
[](https://github.com/tauri-apps/tauri/actions/workflows/lint-js.yml)
|
||||
[](https://app.fossa.com/projects/git%2Bgithub.com%2Ftauri-apps%2Ftauri?ref=badge_shield)
|
||||
[](https://discord.gg/SpmNs4S)
|
||||
[](https://tauri.app)
|
||||
[](https://good-labs.github.io/greater-good-affirmation)
|
||||
[](https://opencollective.com/tauri)
|
||||
|
||||
| Component | Version |
|
||||
| --------------- | ----------------------------------------------------- |
|
||||
| @tauri-apps/api |  |
|
||||
|
||||
## About Tauri
|
||||
|
||||
Tauri is a polyglot and generic system that is very composable and allows engineers to make a wide variety of applications. It is used for building applications for Desktop Computers using a combination of Rust tools and HTML rendered in a Webview. Apps built with Tauri can ship with any number of pieces of an optional JS API / Rust API so that webviews can control the system via message passing. In fact, developers can extend the default API with their own functionality and bridge the Webview and Rust-based backend easily.
|
||||
|
||||
Tauri apps can have custom menus and have tray-type interfaces. They can be updated, and are managed by the user's operating system as expected. They are very small, because they use the system's webview. They do not ship a runtime, since the final binary is compiled from rust. This makes the reversing of Tauri apps not a trivial task.
|
||||
|
||||
## This module
|
||||
|
||||
This is a typescript library that creates `cjs` and `esm` JavaScript endpoints for you to import into your Frontend framework so that the Webview can call and listen to backend activity. We also ship the pure typescript, because for some frameworks this is more optimal. It uses the message passing of webviews to their hosts.
|
||||
|
||||
To learn more about the details of how all of these pieces fit together, please consult this [ARCHITECTURE.md](https://github.com/tauri-apps/tauri/blob/dev/ARCHITECTURE.md) document.
|
||||
|
||||
## Installation
|
||||
|
||||
The preferred method is to install this module locally as a dependency:
|
||||
|
||||
```
|
||||
$ pnpm add @tauri-apps/api
|
||||
$ yarn add @tauri-apps/api
|
||||
$ npm add @tauri-apps/api
|
||||
```
|
||||
|
||||
## Semver
|
||||
|
||||
**tauri** is following [Semantic Versioning 2.0](https://semver.org/).
|
||||
|
||||
## Licenses
|
||||
|
||||
Code: (c) 2019 - 2021 - The Tauri Programme within The Commons Conservancy.
|
||||
|
||||
MIT or MIT/Apache 2.0 where applicable.
|
||||
|
||||
Logo: CC-BY-NC-ND
|
||||
|
||||
- Original Tauri Logo Designs by [Daniel Thompson-Yvetot](https://github.com/nothingismagick) and [Guillaume Chau](https://github.com/akryum)
|
185
node_modules/@tauri-apps/api/app.cjs
generated
vendored
Normal file
185
node_modules/@tauri-apps/api/app.cjs
generated
vendored
Normal file
@ -0,0 +1,185 @@
|
||||
'use strict';
|
||||
|
||||
var core = require('./core.cjs');
|
||||
var image = require('./image.cjs');
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/**
|
||||
* Application metadata and related APIs.
|
||||
*
|
||||
* @module
|
||||
*/
|
||||
/**
|
||||
* Gets the application version.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getVersion } from '@tauri-apps/api/app';
|
||||
* const appVersion = await getVersion();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function getVersion() {
|
||||
return core.invoke('plugin:app|version');
|
||||
}
|
||||
/**
|
||||
* Gets the application name.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getName } from '@tauri-apps/api/app';
|
||||
* const appName = await getName();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function getName() {
|
||||
return core.invoke('plugin:app|name');
|
||||
}
|
||||
/**
|
||||
* Gets the Tauri version.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getTauriVersion } from '@tauri-apps/api/app';
|
||||
* const tauriVersion = await getTauriVersion();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function getTauriVersion() {
|
||||
return core.invoke('plugin:app|tauri_version');
|
||||
}
|
||||
/**
|
||||
* Gets the application identifier.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getIdentifier } from '@tauri-apps/api/app';
|
||||
* const identifier = await getIdentifier();
|
||||
* ```
|
||||
*
|
||||
* @returns The application identifier as configured in `tauri.conf.json`.
|
||||
*
|
||||
* @since 2.4.0
|
||||
*/
|
||||
async function getIdentifier() {
|
||||
return core.invoke('plugin:app|identifier');
|
||||
}
|
||||
/**
|
||||
* Shows the application on macOS. This function does not automatically focus any specific app window.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { show } from '@tauri-apps/api/app';
|
||||
* await show();
|
||||
* ```
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
async function show() {
|
||||
return core.invoke('plugin:app|app_show');
|
||||
}
|
||||
/**
|
||||
* Hides the application on macOS.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { hide } from '@tauri-apps/api/app';
|
||||
* await hide();
|
||||
* ```
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
async function hide() {
|
||||
return core.invoke('plugin:app|app_hide');
|
||||
}
|
||||
/**
|
||||
* Fetches the data store identifiers on macOS and iOS.
|
||||
*
|
||||
* See https://developer.apple.com/documentation/webkit/wkwebsitedatastore for more information.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { fetchDataStoreIdentifiers } from '@tauri-apps/api/app';
|
||||
* const ids = await fetchDataStoreIdentifiers();
|
||||
* ```
|
||||
*
|
||||
* @since 2.4.0
|
||||
*/
|
||||
async function fetchDataStoreIdentifiers() {
|
||||
return core.invoke('plugin:app|fetch_data_store_identifiers');
|
||||
}
|
||||
/**
|
||||
* Removes the data store with the given identifier.
|
||||
*
|
||||
* Note that any webview using this data store should be closed before running this API.
|
||||
*
|
||||
* See https://developer.apple.com/documentation/webkit/wkwebsitedatastore for more information.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { fetchDataStoreIdentifiers, removeDataStore } from '@tauri-apps/api/app';
|
||||
* for (const id of (await fetchDataStoreIdentifiers())) {
|
||||
* await removeDataStore(id);
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @since 2.4.0
|
||||
*/
|
||||
async function removeDataStore(uuid) {
|
||||
return core.invoke('plugin:app|remove_data_store', { uuid });
|
||||
}
|
||||
/**
|
||||
* Get the default window icon.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { defaultWindowIcon } from '@tauri-apps/api/app';
|
||||
* await defaultWindowIcon();
|
||||
* ```
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function defaultWindowIcon() {
|
||||
return core.invoke('plugin:app|default_window_icon').then((rid) => rid ? new image.Image(rid) : null);
|
||||
}
|
||||
/**
|
||||
* Set app's theme, pass in `null` or `undefined` to follow system theme
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { setTheme } from '@tauri-apps/api/app';
|
||||
* await setTheme('dark');
|
||||
* ```
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **iOS / Android:** Unsupported.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function setTheme(theme) {
|
||||
return core.invoke('plugin:app|set_app_theme', { theme });
|
||||
}
|
||||
/**
|
||||
* Sets the dock visibility for the application on macOS.
|
||||
*
|
||||
* @param visible whether the dock should be visible or not
|
||||
* @since 2.5.0
|
||||
*/
|
||||
async function setDockVisibility(visible) {
|
||||
return core.invoke('plugin:app|set_dock_visibility', { visible });
|
||||
}
|
||||
|
||||
exports.defaultWindowIcon = defaultWindowIcon;
|
||||
exports.fetchDataStoreIdentifiers = fetchDataStoreIdentifiers;
|
||||
exports.getIdentifier = getIdentifier;
|
||||
exports.getName = getName;
|
||||
exports.getTauriVersion = getTauriVersion;
|
||||
exports.getVersion = getVersion;
|
||||
exports.hide = hide;
|
||||
exports.removeDataStore = removeDataStore;
|
||||
exports.setDockVisibility = setDockVisibility;
|
||||
exports.setTheme = setTheme;
|
||||
exports.show = show;
|
164
node_modules/@tauri-apps/api/app.d.ts
generated
vendored
Normal file
164
node_modules/@tauri-apps/api/app.d.ts
generated
vendored
Normal file
@ -0,0 +1,164 @@
|
||||
import { Image } from './image';
|
||||
import { Theme } from './window';
|
||||
export type DataStoreIdentifier = [
|
||||
number,
|
||||
number,
|
||||
number,
|
||||
number,
|
||||
number,
|
||||
number,
|
||||
number,
|
||||
number,
|
||||
number,
|
||||
number,
|
||||
number,
|
||||
number,
|
||||
number,
|
||||
number,
|
||||
number,
|
||||
number
|
||||
];
|
||||
/**
|
||||
* Application metadata and related APIs.
|
||||
*
|
||||
* @module
|
||||
*/
|
||||
/**
|
||||
* Gets the application version.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getVersion } from '@tauri-apps/api/app';
|
||||
* const appVersion = await getVersion();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
declare function getVersion(): Promise<string>;
|
||||
/**
|
||||
* Gets the application name.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getName } from '@tauri-apps/api/app';
|
||||
* const appName = await getName();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
declare function getName(): Promise<string>;
|
||||
/**
|
||||
* Gets the Tauri version.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getTauriVersion } from '@tauri-apps/api/app';
|
||||
* const tauriVersion = await getTauriVersion();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
declare function getTauriVersion(): Promise<string>;
|
||||
/**
|
||||
* Gets the application identifier.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getIdentifier } from '@tauri-apps/api/app';
|
||||
* const identifier = await getIdentifier();
|
||||
* ```
|
||||
*
|
||||
* @returns The application identifier as configured in `tauri.conf.json`.
|
||||
*
|
||||
* @since 2.4.0
|
||||
*/
|
||||
declare function getIdentifier(): Promise<string>;
|
||||
/**
|
||||
* Shows the application on macOS. This function does not automatically focus any specific app window.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { show } from '@tauri-apps/api/app';
|
||||
* await show();
|
||||
* ```
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
declare function show(): Promise<void>;
|
||||
/**
|
||||
* Hides the application on macOS.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { hide } from '@tauri-apps/api/app';
|
||||
* await hide();
|
||||
* ```
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
declare function hide(): Promise<void>;
|
||||
/**
|
||||
* Fetches the data store identifiers on macOS and iOS.
|
||||
*
|
||||
* See https://developer.apple.com/documentation/webkit/wkwebsitedatastore for more information.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { fetchDataStoreIdentifiers } from '@tauri-apps/api/app';
|
||||
* const ids = await fetchDataStoreIdentifiers();
|
||||
* ```
|
||||
*
|
||||
* @since 2.4.0
|
||||
*/
|
||||
declare function fetchDataStoreIdentifiers(): Promise<DataStoreIdentifier[]>;
|
||||
/**
|
||||
* Removes the data store with the given identifier.
|
||||
*
|
||||
* Note that any webview using this data store should be closed before running this API.
|
||||
*
|
||||
* See https://developer.apple.com/documentation/webkit/wkwebsitedatastore for more information.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { fetchDataStoreIdentifiers, removeDataStore } from '@tauri-apps/api/app';
|
||||
* for (const id of (await fetchDataStoreIdentifiers())) {
|
||||
* await removeDataStore(id);
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @since 2.4.0
|
||||
*/
|
||||
declare function removeDataStore(uuid: DataStoreIdentifier): Promise<DataStoreIdentifier[]>;
|
||||
/**
|
||||
* Get the default window icon.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { defaultWindowIcon } from '@tauri-apps/api/app';
|
||||
* await defaultWindowIcon();
|
||||
* ```
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
declare function defaultWindowIcon(): Promise<Image | null>;
|
||||
/**
|
||||
* Set app's theme, pass in `null` or `undefined` to follow system theme
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { setTheme } from '@tauri-apps/api/app';
|
||||
* await setTheme('dark');
|
||||
* ```
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **iOS / Android:** Unsupported.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
declare function setTheme(theme?: Theme | null): Promise<void>;
|
||||
/**
|
||||
* Sets the dock visibility for the application on macOS.
|
||||
*
|
||||
* @param visible whether the dock should be visible or not
|
||||
* @since 2.5.0
|
||||
*/
|
||||
declare function setDockVisibility(visible: boolean): Promise<void>;
|
||||
export { getName, getVersion, getTauriVersion, getIdentifier, show, hide, defaultWindowIcon, setTheme, fetchDataStoreIdentifiers, removeDataStore, setDockVisibility };
|
173
node_modules/@tauri-apps/api/app.js
generated
vendored
Normal file
173
node_modules/@tauri-apps/api/app.js
generated
vendored
Normal file
@ -0,0 +1,173 @@
|
||||
import { invoke } from './core.js';
|
||||
import { Image } from './image.js';
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/**
|
||||
* Application metadata and related APIs.
|
||||
*
|
||||
* @module
|
||||
*/
|
||||
/**
|
||||
* Gets the application version.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getVersion } from '@tauri-apps/api/app';
|
||||
* const appVersion = await getVersion();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function getVersion() {
|
||||
return invoke('plugin:app|version');
|
||||
}
|
||||
/**
|
||||
* Gets the application name.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getName } from '@tauri-apps/api/app';
|
||||
* const appName = await getName();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function getName() {
|
||||
return invoke('plugin:app|name');
|
||||
}
|
||||
/**
|
||||
* Gets the Tauri version.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getTauriVersion } from '@tauri-apps/api/app';
|
||||
* const tauriVersion = await getTauriVersion();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function getTauriVersion() {
|
||||
return invoke('plugin:app|tauri_version');
|
||||
}
|
||||
/**
|
||||
* Gets the application identifier.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getIdentifier } from '@tauri-apps/api/app';
|
||||
* const identifier = await getIdentifier();
|
||||
* ```
|
||||
*
|
||||
* @returns The application identifier as configured in `tauri.conf.json`.
|
||||
*
|
||||
* @since 2.4.0
|
||||
*/
|
||||
async function getIdentifier() {
|
||||
return invoke('plugin:app|identifier');
|
||||
}
|
||||
/**
|
||||
* Shows the application on macOS. This function does not automatically focus any specific app window.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { show } from '@tauri-apps/api/app';
|
||||
* await show();
|
||||
* ```
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
async function show() {
|
||||
return invoke('plugin:app|app_show');
|
||||
}
|
||||
/**
|
||||
* Hides the application on macOS.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { hide } from '@tauri-apps/api/app';
|
||||
* await hide();
|
||||
* ```
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
async function hide() {
|
||||
return invoke('plugin:app|app_hide');
|
||||
}
|
||||
/**
|
||||
* Fetches the data store identifiers on macOS and iOS.
|
||||
*
|
||||
* See https://developer.apple.com/documentation/webkit/wkwebsitedatastore for more information.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { fetchDataStoreIdentifiers } from '@tauri-apps/api/app';
|
||||
* const ids = await fetchDataStoreIdentifiers();
|
||||
* ```
|
||||
*
|
||||
* @since 2.4.0
|
||||
*/
|
||||
async function fetchDataStoreIdentifiers() {
|
||||
return invoke('plugin:app|fetch_data_store_identifiers');
|
||||
}
|
||||
/**
|
||||
* Removes the data store with the given identifier.
|
||||
*
|
||||
* Note that any webview using this data store should be closed before running this API.
|
||||
*
|
||||
* See https://developer.apple.com/documentation/webkit/wkwebsitedatastore for more information.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { fetchDataStoreIdentifiers, removeDataStore } from '@tauri-apps/api/app';
|
||||
* for (const id of (await fetchDataStoreIdentifiers())) {
|
||||
* await removeDataStore(id);
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @since 2.4.0
|
||||
*/
|
||||
async function removeDataStore(uuid) {
|
||||
return invoke('plugin:app|remove_data_store', { uuid });
|
||||
}
|
||||
/**
|
||||
* Get the default window icon.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { defaultWindowIcon } from '@tauri-apps/api/app';
|
||||
* await defaultWindowIcon();
|
||||
* ```
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function defaultWindowIcon() {
|
||||
return invoke('plugin:app|default_window_icon').then((rid) => rid ? new Image(rid) : null);
|
||||
}
|
||||
/**
|
||||
* Set app's theme, pass in `null` or `undefined` to follow system theme
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { setTheme } from '@tauri-apps/api/app';
|
||||
* await setTheme('dark');
|
||||
* ```
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **iOS / Android:** Unsupported.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function setTheme(theme) {
|
||||
return invoke('plugin:app|set_app_theme', { theme });
|
||||
}
|
||||
/**
|
||||
* Sets the dock visibility for the application on macOS.
|
||||
*
|
||||
* @param visible whether the dock should be visible or not
|
||||
* @since 2.5.0
|
||||
*/
|
||||
async function setDockVisibility(visible) {
|
||||
return invoke('plugin:app|set_dock_visibility', { visible });
|
||||
}
|
||||
|
||||
export { defaultWindowIcon, fetchDataStoreIdentifiers, getIdentifier, getName, getTauriVersion, getVersion, hide, removeDataStore, setDockVisibility, setTheme, show };
|
281
node_modules/@tauri-apps/api/core.cjs
generated
vendored
Normal file
281
node_modules/@tauri-apps/api/core.cjs
generated
vendored
Normal file
@ -0,0 +1,281 @@
|
||||
'use strict';
|
||||
|
||||
var tslib_es6 = require('./external/tslib/tslib.es6.cjs');
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
var _Channel_onmessage, _Channel_nextMessageIndex, _Channel_pendingMessages, _Channel_messageEndIndex, _Resource_rid;
|
||||
/**
|
||||
* Invoke your custom commands.
|
||||
*
|
||||
* This package is also accessible with `window.__TAURI__.core` when [`app.withGlobalTauri`](https://v2.tauri.app/reference/config/#withglobaltauri) in `tauri.conf.json` is set to `true`.
|
||||
* @module
|
||||
*/
|
||||
/**
|
||||
* A key to be used to implement a special function
|
||||
* on your types that define how your type should be serialized
|
||||
* when passing across the IPC.
|
||||
* @example
|
||||
* Given a type in Rust that looks like this
|
||||
* ```rs
|
||||
* #[derive(serde::Serialize, serde::Deserialize)
|
||||
* enum UserId {
|
||||
* String(String),
|
||||
* Number(u32),
|
||||
* }
|
||||
* ```
|
||||
* `UserId::String("id")` would be serialized into `{ String: "id" }`
|
||||
* and so we need to pass the same structure back to Rust
|
||||
* ```ts
|
||||
* import { SERIALIZE_TO_IPC_FN } from "@tauri-apps/api/core"
|
||||
*
|
||||
* class UserIdString {
|
||||
* id
|
||||
* constructor(id) {
|
||||
* this.id = id
|
||||
* }
|
||||
*
|
||||
* [SERIALIZE_TO_IPC_FN]() {
|
||||
* return { String: this.id }
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* class UserIdNumber {
|
||||
* id
|
||||
* constructor(id) {
|
||||
* this.id = id
|
||||
* }
|
||||
*
|
||||
* [SERIALIZE_TO_IPC_FN]() {
|
||||
* return { Number: this.id }
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* type UserId = UserIdString | UserIdNumber
|
||||
* ```
|
||||
*
|
||||
*/
|
||||
// if this value changes, make sure to update it in:
|
||||
// 1. ipc.js
|
||||
// 2. process-ipc-message-fn.js
|
||||
const SERIALIZE_TO_IPC_FN = '__TAURI_TO_IPC_KEY__';
|
||||
/**
|
||||
* Transforms a callback function to a string identifier that can be passed to the backend.
|
||||
* The backend uses the identifier to `eval()` the callback.
|
||||
*
|
||||
* @return A unique identifier associated with the callback function.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function transformCallback(callback, once = false) {
|
||||
return window.__TAURI_INTERNALS__.transformCallback(callback, once);
|
||||
}
|
||||
class Channel {
|
||||
constructor(onmessage) {
|
||||
_Channel_onmessage.set(this, void 0);
|
||||
// the index is used as a mechanism to preserve message order
|
||||
_Channel_nextMessageIndex.set(this, 0);
|
||||
_Channel_pendingMessages.set(this, []);
|
||||
_Channel_messageEndIndex.set(this, void 0);
|
||||
tslib_es6.__classPrivateFieldSet(this, _Channel_onmessage, onmessage || (() => { }), "f");
|
||||
this.id = transformCallback((rawMessage) => {
|
||||
const index = rawMessage.index;
|
||||
if ('end' in rawMessage) {
|
||||
if (index == tslib_es6.__classPrivateFieldGet(this, _Channel_nextMessageIndex, "f")) {
|
||||
this.cleanupCallback();
|
||||
}
|
||||
else {
|
||||
tslib_es6.__classPrivateFieldSet(this, _Channel_messageEndIndex, index, "f");
|
||||
}
|
||||
return;
|
||||
}
|
||||
const message = rawMessage.message;
|
||||
// Process the message if we're at the right order
|
||||
if (index == tslib_es6.__classPrivateFieldGet(this, _Channel_nextMessageIndex, "f")) {
|
||||
tslib_es6.__classPrivateFieldGet(this, _Channel_onmessage, "f").call(this, message);
|
||||
tslib_es6.__classPrivateFieldSet(this, _Channel_nextMessageIndex, tslib_es6.__classPrivateFieldGet(this, _Channel_nextMessageIndex, "f") + 1, "f");
|
||||
// process pending messages
|
||||
while (tslib_es6.__classPrivateFieldGet(this, _Channel_nextMessageIndex, "f") in tslib_es6.__classPrivateFieldGet(this, _Channel_pendingMessages, "f")) {
|
||||
const message = tslib_es6.__classPrivateFieldGet(this, _Channel_pendingMessages, "f")[tslib_es6.__classPrivateFieldGet(this, _Channel_nextMessageIndex, "f")];
|
||||
tslib_es6.__classPrivateFieldGet(this, _Channel_onmessage, "f").call(this, message);
|
||||
// eslint-disable-next-line @typescript-eslint/no-array-delete
|
||||
delete tslib_es6.__classPrivateFieldGet(this, _Channel_pendingMessages, "f")[tslib_es6.__classPrivateFieldGet(this, _Channel_nextMessageIndex, "f")];
|
||||
tslib_es6.__classPrivateFieldSet(this, _Channel_nextMessageIndex, tslib_es6.__classPrivateFieldGet(this, _Channel_nextMessageIndex, "f") + 1, "f");
|
||||
}
|
||||
if (tslib_es6.__classPrivateFieldGet(this, _Channel_nextMessageIndex, "f") === tslib_es6.__classPrivateFieldGet(this, _Channel_messageEndIndex, "f")) {
|
||||
this.cleanupCallback();
|
||||
}
|
||||
}
|
||||
// Queue the message if we're not
|
||||
else {
|
||||
// eslint-disable-next-line security/detect-object-injection
|
||||
tslib_es6.__classPrivateFieldGet(this, _Channel_pendingMessages, "f")[index] = message;
|
||||
}
|
||||
});
|
||||
}
|
||||
cleanupCallback() {
|
||||
Reflect.deleteProperty(window, `_${this.id}`);
|
||||
}
|
||||
set onmessage(handler) {
|
||||
tslib_es6.__classPrivateFieldSet(this, _Channel_onmessage, handler, "f");
|
||||
}
|
||||
get onmessage() {
|
||||
return tslib_es6.__classPrivateFieldGet(this, _Channel_onmessage, "f");
|
||||
}
|
||||
[(_Channel_onmessage = new WeakMap(), _Channel_nextMessageIndex = new WeakMap(), _Channel_pendingMessages = new WeakMap(), _Channel_messageEndIndex = new WeakMap(), SERIALIZE_TO_IPC_FN)]() {
|
||||
return `__CHANNEL__:${this.id}`;
|
||||
}
|
||||
toJSON() {
|
||||
// eslint-disable-next-line security/detect-object-injection
|
||||
return this[SERIALIZE_TO_IPC_FN]();
|
||||
}
|
||||
}
|
||||
class PluginListener {
|
||||
constructor(plugin, event, channelId) {
|
||||
this.plugin = plugin;
|
||||
this.event = event;
|
||||
this.channelId = channelId;
|
||||
}
|
||||
async unregister() {
|
||||
return invoke(`plugin:${this.plugin}|remove_listener`, {
|
||||
event: this.event,
|
||||
channelId: this.channelId
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Adds a listener to a plugin event.
|
||||
*
|
||||
* @returns The listener object to stop listening to the events.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function addPluginListener(plugin, event, cb) {
|
||||
const handler = new Channel(cb);
|
||||
return invoke(`plugin:${plugin}|registerListener`, { event, handler }).then(() => new PluginListener(plugin, event, handler.id));
|
||||
}
|
||||
/**
|
||||
* Get permission state for a plugin.
|
||||
*
|
||||
* This should be used by plugin authors to wrap their actual implementation.
|
||||
*/
|
||||
async function checkPermissions(plugin) {
|
||||
return invoke(`plugin:${plugin}|check_permissions`);
|
||||
}
|
||||
/**
|
||||
* Request permissions.
|
||||
*
|
||||
* This should be used by plugin authors to wrap their actual implementation.
|
||||
*/
|
||||
async function requestPermissions(plugin) {
|
||||
return invoke(`plugin:${plugin}|request_permissions`);
|
||||
}
|
||||
/**
|
||||
* Sends a message to the backend.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { invoke } from '@tauri-apps/api/core';
|
||||
* await invoke('login', { user: 'tauri', password: 'poiwe3h4r5ip3yrhtew9ty' });
|
||||
* ```
|
||||
*
|
||||
* @param cmd The command name.
|
||||
* @param args The optional arguments to pass to the command.
|
||||
* @param options The request options.
|
||||
* @return A promise resolving or rejecting to the backend response.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function invoke(cmd, args = {}, options) {
|
||||
return window.__TAURI_INTERNALS__.invoke(cmd, args, options);
|
||||
}
|
||||
/**
|
||||
* Convert a device file path to an URL that can be loaded by the webview.
|
||||
* Note that `asset:` and `http://asset.localhost` must be added to [`app.security.csp`](https://v2.tauri.app/reference/config/#csp-1) in `tauri.conf.json`.
|
||||
* Example CSP value: `"csp": "default-src 'self' ipc: http://ipc.localhost; img-src 'self' asset: http://asset.localhost"` to use the asset protocol on image sources.
|
||||
*
|
||||
* Additionally, `"enable" : "true"` must be added to [`app.security.assetProtocol`](https://v2.tauri.app/reference/config/#assetprotocolconfig)
|
||||
* in `tauri.conf.json` and its access scope must be defined on the `scope` array on the same `assetProtocol` object.
|
||||
*
|
||||
* @param filePath The file path.
|
||||
* @param protocol The protocol to use. Defaults to `asset`. You only need to set this when using a custom protocol.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { appDataDir, join } from '@tauri-apps/api/path';
|
||||
* import { convertFileSrc } from '@tauri-apps/api/core';
|
||||
* const appDataDirPath = await appDataDir();
|
||||
* const filePath = await join(appDataDirPath, 'assets/video.mp4');
|
||||
* const assetUrl = convertFileSrc(filePath);
|
||||
*
|
||||
* const video = document.getElementById('my-video');
|
||||
* const source = document.createElement('source');
|
||||
* source.type = 'video/mp4';
|
||||
* source.src = assetUrl;
|
||||
* video.appendChild(source);
|
||||
* video.load();
|
||||
* ```
|
||||
*
|
||||
* @return the URL that can be used as source on the webview.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function convertFileSrc(filePath, protocol = 'asset') {
|
||||
return window.__TAURI_INTERNALS__.convertFileSrc(filePath, protocol);
|
||||
}
|
||||
/**
|
||||
* A rust-backed resource stored through `tauri::Manager::resources_table` API.
|
||||
*
|
||||
* The resource lives in the main process and does not exist
|
||||
* in the Javascript world, and thus will not be cleaned up automatiacally
|
||||
* except on application exit. If you want to clean it up early, call {@linkcode Resource.close}
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { Resource, invoke } from '@tauri-apps/api/core';
|
||||
* export class DatabaseHandle extends Resource {
|
||||
* static async open(path: string): Promise<DatabaseHandle> {
|
||||
* const rid: number = await invoke('open_db', { path });
|
||||
* return new DatabaseHandle(rid);
|
||||
* }
|
||||
*
|
||||
* async execute(sql: string): Promise<void> {
|
||||
* await invoke('execute_sql', { rid: this.rid, sql });
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
class Resource {
|
||||
get rid() {
|
||||
return tslib_es6.__classPrivateFieldGet(this, _Resource_rid, "f");
|
||||
}
|
||||
constructor(rid) {
|
||||
_Resource_rid.set(this, void 0);
|
||||
tslib_es6.__classPrivateFieldSet(this, _Resource_rid, rid, "f");
|
||||
}
|
||||
/**
|
||||
* Destroys and cleans up this resource from memory.
|
||||
* **You should not call any method on this object anymore and should drop any reference to it.**
|
||||
*/
|
||||
async close() {
|
||||
return invoke('plugin:resources|close', {
|
||||
rid: this.rid
|
||||
});
|
||||
}
|
||||
}
|
||||
_Resource_rid = new WeakMap();
|
||||
function isTauri() {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-member-access
|
||||
return !!(globalThis || window).isTauri;
|
||||
}
|
||||
|
||||
exports.Channel = Channel;
|
||||
exports.PluginListener = PluginListener;
|
||||
exports.Resource = Resource;
|
||||
exports.SERIALIZE_TO_IPC_FN = SERIALIZE_TO_IPC_FN;
|
||||
exports.addPluginListener = addPluginListener;
|
||||
exports.checkPermissions = checkPermissions;
|
||||
exports.convertFileSrc = convertFileSrc;
|
||||
exports.invoke = invoke;
|
||||
exports.isTauri = isTauri;
|
||||
exports.requestPermissions = requestPermissions;
|
||||
exports.transformCallback = transformCallback;
|
193
node_modules/@tauri-apps/api/core.d.ts
generated
vendored
Normal file
193
node_modules/@tauri-apps/api/core.d.ts
generated
vendored
Normal file
@ -0,0 +1,193 @@
|
||||
/**
|
||||
* Invoke your custom commands.
|
||||
*
|
||||
* This package is also accessible with `window.__TAURI__.core` when [`app.withGlobalTauri`](https://v2.tauri.app/reference/config/#withglobaltauri) in `tauri.conf.json` is set to `true`.
|
||||
* @module
|
||||
*/
|
||||
/**
|
||||
* A key to be used to implement a special function
|
||||
* on your types that define how your type should be serialized
|
||||
* when passing across the IPC.
|
||||
* @example
|
||||
* Given a type in Rust that looks like this
|
||||
* ```rs
|
||||
* #[derive(serde::Serialize, serde::Deserialize)
|
||||
* enum UserId {
|
||||
* String(String),
|
||||
* Number(u32),
|
||||
* }
|
||||
* ```
|
||||
* `UserId::String("id")` would be serialized into `{ String: "id" }`
|
||||
* and so we need to pass the same structure back to Rust
|
||||
* ```ts
|
||||
* import { SERIALIZE_TO_IPC_FN } from "@tauri-apps/api/core"
|
||||
*
|
||||
* class UserIdString {
|
||||
* id
|
||||
* constructor(id) {
|
||||
* this.id = id
|
||||
* }
|
||||
*
|
||||
* [SERIALIZE_TO_IPC_FN]() {
|
||||
* return { String: this.id }
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* class UserIdNumber {
|
||||
* id
|
||||
* constructor(id) {
|
||||
* this.id = id
|
||||
* }
|
||||
*
|
||||
* [SERIALIZE_TO_IPC_FN]() {
|
||||
* return { Number: this.id }
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* type UserId = UserIdString | UserIdNumber
|
||||
* ```
|
||||
*
|
||||
*/
|
||||
export declare const SERIALIZE_TO_IPC_FN = "__TAURI_TO_IPC_KEY__";
|
||||
/**
|
||||
* Transforms a callback function to a string identifier that can be passed to the backend.
|
||||
* The backend uses the identifier to `eval()` the callback.
|
||||
*
|
||||
* @return A unique identifier associated with the callback function.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
declare function transformCallback<T = unknown>(callback?: (response: T) => void, once?: boolean): number;
|
||||
declare class Channel<T = unknown> {
|
||||
#private;
|
||||
/** The callback id returned from {@linkcode transformCallback} */
|
||||
id: number;
|
||||
constructor(onmessage?: (response: T) => void);
|
||||
private cleanupCallback;
|
||||
set onmessage(handler: (response: T) => void);
|
||||
get onmessage(): (response: T) => void;
|
||||
[SERIALIZE_TO_IPC_FN](): string;
|
||||
toJSON(): string;
|
||||
}
|
||||
declare class PluginListener {
|
||||
plugin: string;
|
||||
event: string;
|
||||
channelId: number;
|
||||
constructor(plugin: string, event: string, channelId: number);
|
||||
unregister(): Promise<void>;
|
||||
}
|
||||
/**
|
||||
* Adds a listener to a plugin event.
|
||||
*
|
||||
* @returns The listener object to stop listening to the events.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
declare function addPluginListener<T>(plugin: string, event: string, cb: (payload: T) => void): Promise<PluginListener>;
|
||||
type PermissionState = 'granted' | 'denied' | 'prompt' | 'prompt-with-rationale';
|
||||
/**
|
||||
* Get permission state for a plugin.
|
||||
*
|
||||
* This should be used by plugin authors to wrap their actual implementation.
|
||||
*/
|
||||
declare function checkPermissions<T>(plugin: string): Promise<T>;
|
||||
/**
|
||||
* Request permissions.
|
||||
*
|
||||
* This should be used by plugin authors to wrap their actual implementation.
|
||||
*/
|
||||
declare function requestPermissions<T>(plugin: string): Promise<T>;
|
||||
/**
|
||||
* Command arguments.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
type InvokeArgs = Record<string, unknown> | number[] | ArrayBuffer | Uint8Array;
|
||||
/**
|
||||
* @since 2.0.0
|
||||
*/
|
||||
interface InvokeOptions {
|
||||
headers: HeadersInit;
|
||||
}
|
||||
/**
|
||||
* Sends a message to the backend.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { invoke } from '@tauri-apps/api/core';
|
||||
* await invoke('login', { user: 'tauri', password: 'poiwe3h4r5ip3yrhtew9ty' });
|
||||
* ```
|
||||
*
|
||||
* @param cmd The command name.
|
||||
* @param args The optional arguments to pass to the command.
|
||||
* @param options The request options.
|
||||
* @return A promise resolving or rejecting to the backend response.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
declare function invoke<T>(cmd: string, args?: InvokeArgs, options?: InvokeOptions): Promise<T>;
|
||||
/**
|
||||
* Convert a device file path to an URL that can be loaded by the webview.
|
||||
* Note that `asset:` and `http://asset.localhost` must be added to [`app.security.csp`](https://v2.tauri.app/reference/config/#csp-1) in `tauri.conf.json`.
|
||||
* Example CSP value: `"csp": "default-src 'self' ipc: http://ipc.localhost; img-src 'self' asset: http://asset.localhost"` to use the asset protocol on image sources.
|
||||
*
|
||||
* Additionally, `"enable" : "true"` must be added to [`app.security.assetProtocol`](https://v2.tauri.app/reference/config/#assetprotocolconfig)
|
||||
* in `tauri.conf.json` and its access scope must be defined on the `scope` array on the same `assetProtocol` object.
|
||||
*
|
||||
* @param filePath The file path.
|
||||
* @param protocol The protocol to use. Defaults to `asset`. You only need to set this when using a custom protocol.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { appDataDir, join } from '@tauri-apps/api/path';
|
||||
* import { convertFileSrc } from '@tauri-apps/api/core';
|
||||
* const appDataDirPath = await appDataDir();
|
||||
* const filePath = await join(appDataDirPath, 'assets/video.mp4');
|
||||
* const assetUrl = convertFileSrc(filePath);
|
||||
*
|
||||
* const video = document.getElementById('my-video');
|
||||
* const source = document.createElement('source');
|
||||
* source.type = 'video/mp4';
|
||||
* source.src = assetUrl;
|
||||
* video.appendChild(source);
|
||||
* video.load();
|
||||
* ```
|
||||
*
|
||||
* @return the URL that can be used as source on the webview.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
declare function convertFileSrc(filePath: string, protocol?: string): string;
|
||||
/**
|
||||
* A rust-backed resource stored through `tauri::Manager::resources_table` API.
|
||||
*
|
||||
* The resource lives in the main process and does not exist
|
||||
* in the Javascript world, and thus will not be cleaned up automatiacally
|
||||
* except on application exit. If you want to clean it up early, call {@linkcode Resource.close}
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { Resource, invoke } from '@tauri-apps/api/core';
|
||||
* export class DatabaseHandle extends Resource {
|
||||
* static async open(path: string): Promise<DatabaseHandle> {
|
||||
* const rid: number = await invoke('open_db', { path });
|
||||
* return new DatabaseHandle(rid);
|
||||
* }
|
||||
*
|
||||
* async execute(sql: string): Promise<void> {
|
||||
* await invoke('execute_sql', { rid: this.rid, sql });
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export declare class Resource {
|
||||
#private;
|
||||
get rid(): number;
|
||||
constructor(rid: number);
|
||||
/**
|
||||
* Destroys 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<void>;
|
||||
}
|
||||
declare function isTauri(): boolean;
|
||||
export type { InvokeArgs, InvokeOptions };
|
||||
export { transformCallback, Channel, PluginListener, addPluginListener, PermissionState, checkPermissions, requestPermissions, invoke, convertFileSrc, isTauri };
|
269
node_modules/@tauri-apps/api/core.js
generated
vendored
Normal file
269
node_modules/@tauri-apps/api/core.js
generated
vendored
Normal file
@ -0,0 +1,269 @@
|
||||
import { __classPrivateFieldGet, __classPrivateFieldSet } from './external/tslib/tslib.es6.js';
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
var _Channel_onmessage, _Channel_nextMessageIndex, _Channel_pendingMessages, _Channel_messageEndIndex, _Resource_rid;
|
||||
/**
|
||||
* Invoke your custom commands.
|
||||
*
|
||||
* This package is also accessible with `window.__TAURI__.core` when [`app.withGlobalTauri`](https://v2.tauri.app/reference/config/#withglobaltauri) in `tauri.conf.json` is set to `true`.
|
||||
* @module
|
||||
*/
|
||||
/**
|
||||
* A key to be used to implement a special function
|
||||
* on your types that define how your type should be serialized
|
||||
* when passing across the IPC.
|
||||
* @example
|
||||
* Given a type in Rust that looks like this
|
||||
* ```rs
|
||||
* #[derive(serde::Serialize, serde::Deserialize)
|
||||
* enum UserId {
|
||||
* String(String),
|
||||
* Number(u32),
|
||||
* }
|
||||
* ```
|
||||
* `UserId::String("id")` would be serialized into `{ String: "id" }`
|
||||
* and so we need to pass the same structure back to Rust
|
||||
* ```ts
|
||||
* import { SERIALIZE_TO_IPC_FN } from "@tauri-apps/api/core"
|
||||
*
|
||||
* class UserIdString {
|
||||
* id
|
||||
* constructor(id) {
|
||||
* this.id = id
|
||||
* }
|
||||
*
|
||||
* [SERIALIZE_TO_IPC_FN]() {
|
||||
* return { String: this.id }
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* class UserIdNumber {
|
||||
* id
|
||||
* constructor(id) {
|
||||
* this.id = id
|
||||
* }
|
||||
*
|
||||
* [SERIALIZE_TO_IPC_FN]() {
|
||||
* return { Number: this.id }
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* type UserId = UserIdString | UserIdNumber
|
||||
* ```
|
||||
*
|
||||
*/
|
||||
// if this value changes, make sure to update it in:
|
||||
// 1. ipc.js
|
||||
// 2. process-ipc-message-fn.js
|
||||
const SERIALIZE_TO_IPC_FN = '__TAURI_TO_IPC_KEY__';
|
||||
/**
|
||||
* Transforms a callback function to a string identifier that can be passed to the backend.
|
||||
* The backend uses the identifier to `eval()` the callback.
|
||||
*
|
||||
* @return A unique identifier associated with the callback function.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function transformCallback(callback, once = false) {
|
||||
return window.__TAURI_INTERNALS__.transformCallback(callback, once);
|
||||
}
|
||||
class Channel {
|
||||
constructor(onmessage) {
|
||||
_Channel_onmessage.set(this, void 0);
|
||||
// the index is used as a mechanism to preserve message order
|
||||
_Channel_nextMessageIndex.set(this, 0);
|
||||
_Channel_pendingMessages.set(this, []);
|
||||
_Channel_messageEndIndex.set(this, void 0);
|
||||
__classPrivateFieldSet(this, _Channel_onmessage, onmessage || (() => { }), "f");
|
||||
this.id = transformCallback((rawMessage) => {
|
||||
const index = rawMessage.index;
|
||||
if ('end' in rawMessage) {
|
||||
if (index == __classPrivateFieldGet(this, _Channel_nextMessageIndex, "f")) {
|
||||
this.cleanupCallback();
|
||||
}
|
||||
else {
|
||||
__classPrivateFieldSet(this, _Channel_messageEndIndex, index, "f");
|
||||
}
|
||||
return;
|
||||
}
|
||||
const message = rawMessage.message;
|
||||
// Process the message if we're at the right order
|
||||
if (index == __classPrivateFieldGet(this, _Channel_nextMessageIndex, "f")) {
|
||||
__classPrivateFieldGet(this, _Channel_onmessage, "f").call(this, message);
|
||||
__classPrivateFieldSet(this, _Channel_nextMessageIndex, __classPrivateFieldGet(this, _Channel_nextMessageIndex, "f") + 1, "f");
|
||||
// process pending messages
|
||||
while (__classPrivateFieldGet(this, _Channel_nextMessageIndex, "f") in __classPrivateFieldGet(this, _Channel_pendingMessages, "f")) {
|
||||
const message = __classPrivateFieldGet(this, _Channel_pendingMessages, "f")[__classPrivateFieldGet(this, _Channel_nextMessageIndex, "f")];
|
||||
__classPrivateFieldGet(this, _Channel_onmessage, "f").call(this, message);
|
||||
// eslint-disable-next-line @typescript-eslint/no-array-delete
|
||||
delete __classPrivateFieldGet(this, _Channel_pendingMessages, "f")[__classPrivateFieldGet(this, _Channel_nextMessageIndex, "f")];
|
||||
__classPrivateFieldSet(this, _Channel_nextMessageIndex, __classPrivateFieldGet(this, _Channel_nextMessageIndex, "f") + 1, "f");
|
||||
}
|
||||
if (__classPrivateFieldGet(this, _Channel_nextMessageIndex, "f") === __classPrivateFieldGet(this, _Channel_messageEndIndex, "f")) {
|
||||
this.cleanupCallback();
|
||||
}
|
||||
}
|
||||
// Queue the message if we're not
|
||||
else {
|
||||
// eslint-disable-next-line security/detect-object-injection
|
||||
__classPrivateFieldGet(this, _Channel_pendingMessages, "f")[index] = message;
|
||||
}
|
||||
});
|
||||
}
|
||||
cleanupCallback() {
|
||||
Reflect.deleteProperty(window, `_${this.id}`);
|
||||
}
|
||||
set onmessage(handler) {
|
||||
__classPrivateFieldSet(this, _Channel_onmessage, handler, "f");
|
||||
}
|
||||
get onmessage() {
|
||||
return __classPrivateFieldGet(this, _Channel_onmessage, "f");
|
||||
}
|
||||
[(_Channel_onmessage = new WeakMap(), _Channel_nextMessageIndex = new WeakMap(), _Channel_pendingMessages = new WeakMap(), _Channel_messageEndIndex = new WeakMap(), SERIALIZE_TO_IPC_FN)]() {
|
||||
return `__CHANNEL__:${this.id}`;
|
||||
}
|
||||
toJSON() {
|
||||
// eslint-disable-next-line security/detect-object-injection
|
||||
return this[SERIALIZE_TO_IPC_FN]();
|
||||
}
|
||||
}
|
||||
class PluginListener {
|
||||
constructor(plugin, event, channelId) {
|
||||
this.plugin = plugin;
|
||||
this.event = event;
|
||||
this.channelId = channelId;
|
||||
}
|
||||
async unregister() {
|
||||
return invoke(`plugin:${this.plugin}|remove_listener`, {
|
||||
event: this.event,
|
||||
channelId: this.channelId
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Adds a listener to a plugin event.
|
||||
*
|
||||
* @returns The listener object to stop listening to the events.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function addPluginListener(plugin, event, cb) {
|
||||
const handler = new Channel(cb);
|
||||
return invoke(`plugin:${plugin}|registerListener`, { event, handler }).then(() => new PluginListener(plugin, event, handler.id));
|
||||
}
|
||||
/**
|
||||
* Get permission state for a plugin.
|
||||
*
|
||||
* This should be used by plugin authors to wrap their actual implementation.
|
||||
*/
|
||||
async function checkPermissions(plugin) {
|
||||
return invoke(`plugin:${plugin}|check_permissions`);
|
||||
}
|
||||
/**
|
||||
* Request permissions.
|
||||
*
|
||||
* This should be used by plugin authors to wrap their actual implementation.
|
||||
*/
|
||||
async function requestPermissions(plugin) {
|
||||
return invoke(`plugin:${plugin}|request_permissions`);
|
||||
}
|
||||
/**
|
||||
* Sends a message to the backend.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { invoke } from '@tauri-apps/api/core';
|
||||
* await invoke('login', { user: 'tauri', password: 'poiwe3h4r5ip3yrhtew9ty' });
|
||||
* ```
|
||||
*
|
||||
* @param cmd The command name.
|
||||
* @param args The optional arguments to pass to the command.
|
||||
* @param options The request options.
|
||||
* @return A promise resolving or rejecting to the backend response.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function invoke(cmd, args = {}, options) {
|
||||
return window.__TAURI_INTERNALS__.invoke(cmd, args, options);
|
||||
}
|
||||
/**
|
||||
* Convert a device file path to an URL that can be loaded by the webview.
|
||||
* Note that `asset:` and `http://asset.localhost` must be added to [`app.security.csp`](https://v2.tauri.app/reference/config/#csp-1) in `tauri.conf.json`.
|
||||
* Example CSP value: `"csp": "default-src 'self' ipc: http://ipc.localhost; img-src 'self' asset: http://asset.localhost"` to use the asset protocol on image sources.
|
||||
*
|
||||
* Additionally, `"enable" : "true"` must be added to [`app.security.assetProtocol`](https://v2.tauri.app/reference/config/#assetprotocolconfig)
|
||||
* in `tauri.conf.json` and its access scope must be defined on the `scope` array on the same `assetProtocol` object.
|
||||
*
|
||||
* @param filePath The file path.
|
||||
* @param protocol The protocol to use. Defaults to `asset`. You only need to set this when using a custom protocol.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { appDataDir, join } from '@tauri-apps/api/path';
|
||||
* import { convertFileSrc } from '@tauri-apps/api/core';
|
||||
* const appDataDirPath = await appDataDir();
|
||||
* const filePath = await join(appDataDirPath, 'assets/video.mp4');
|
||||
* const assetUrl = convertFileSrc(filePath);
|
||||
*
|
||||
* const video = document.getElementById('my-video');
|
||||
* const source = document.createElement('source');
|
||||
* source.type = 'video/mp4';
|
||||
* source.src = assetUrl;
|
||||
* video.appendChild(source);
|
||||
* video.load();
|
||||
* ```
|
||||
*
|
||||
* @return the URL that can be used as source on the webview.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function convertFileSrc(filePath, protocol = 'asset') {
|
||||
return window.__TAURI_INTERNALS__.convertFileSrc(filePath, protocol);
|
||||
}
|
||||
/**
|
||||
* A rust-backed resource stored through `tauri::Manager::resources_table` API.
|
||||
*
|
||||
* The resource lives in the main process and does not exist
|
||||
* in the Javascript world, and thus will not be cleaned up automatiacally
|
||||
* except on application exit. If you want to clean it up early, call {@linkcode Resource.close}
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { Resource, invoke } from '@tauri-apps/api/core';
|
||||
* export class DatabaseHandle extends Resource {
|
||||
* static async open(path: string): Promise<DatabaseHandle> {
|
||||
* const rid: number = await invoke('open_db', { path });
|
||||
* return new DatabaseHandle(rid);
|
||||
* }
|
||||
*
|
||||
* async execute(sql: string): Promise<void> {
|
||||
* await invoke('execute_sql', { rid: this.rid, sql });
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
class Resource {
|
||||
get rid() {
|
||||
return __classPrivateFieldGet(this, _Resource_rid, "f");
|
||||
}
|
||||
constructor(rid) {
|
||||
_Resource_rid.set(this, void 0);
|
||||
__classPrivateFieldSet(this, _Resource_rid, rid, "f");
|
||||
}
|
||||
/**
|
||||
* Destroys and cleans up this resource from memory.
|
||||
* **You should not call any method on this object anymore and should drop any reference to it.**
|
||||
*/
|
||||
async close() {
|
||||
return invoke('plugin:resources|close', {
|
||||
rid: this.rid
|
||||
});
|
||||
}
|
||||
}
|
||||
_Resource_rid = new WeakMap();
|
||||
function isTauri() {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-member-access
|
||||
return !!(globalThis || window).isTauri;
|
||||
}
|
||||
|
||||
export { Channel, PluginListener, Resource, SERIALIZE_TO_IPC_FN, addPluginListener, checkPermissions, convertFileSrc, invoke, isTauri, requestPermissions, transformCallback };
|
334
node_modules/@tauri-apps/api/dpi.cjs
generated
vendored
Normal file
334
node_modules/@tauri-apps/api/dpi.cjs
generated
vendored
Normal file
@ -0,0 +1,334 @@
|
||||
'use strict';
|
||||
|
||||
var core = require('./core.cjs');
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/**
|
||||
* A size represented in logical pixels.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
class LogicalSize {
|
||||
constructor(...args) {
|
||||
this.type = 'Logical';
|
||||
if (args.length === 1) {
|
||||
if ('Logical' in args[0]) {
|
||||
this.width = args[0].Logical.width;
|
||||
this.height = args[0].Logical.height;
|
||||
}
|
||||
else {
|
||||
this.width = args[0].width;
|
||||
this.height = args[0].height;
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.width = args[0];
|
||||
this.height = args[1];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Converts the logical size to a physical one.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { LogicalSize } from '@tauri-apps/api/dpi';
|
||||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||||
*
|
||||
* const appWindow = getCurrentWindow();
|
||||
* const factor = await appWindow.scaleFactor();
|
||||
* const size = new LogicalSize(400, 500);
|
||||
* const physical = size.toPhysical(factor);
|
||||
* ```
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
toPhysical(scaleFactor) {
|
||||
return new PhysicalSize(this.width * scaleFactor, this.height * scaleFactor);
|
||||
}
|
||||
[core.SERIALIZE_TO_IPC_FN]() {
|
||||
return {
|
||||
width: this.width,
|
||||
height: this.height
|
||||
};
|
||||
}
|
||||
toJSON() {
|
||||
// eslint-disable-next-line security/detect-object-injection
|
||||
return this[core.SERIALIZE_TO_IPC_FN]();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A size represented in physical pixels.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
class PhysicalSize {
|
||||
constructor(...args) {
|
||||
this.type = 'Physical';
|
||||
if (args.length === 1) {
|
||||
if ('Physical' in args[0]) {
|
||||
this.width = args[0].Physical.width;
|
||||
this.height = args[0].Physical.height;
|
||||
}
|
||||
else {
|
||||
this.width = args[0].width;
|
||||
this.height = args[0].height;
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.width = args[0];
|
||||
this.height = args[1];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Converts the physical size to a logical one.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||||
* const appWindow = getCurrentWindow();
|
||||
* const factor = await appWindow.scaleFactor();
|
||||
* const size = await appWindow.innerSize(); // PhysicalSize
|
||||
* const logical = size.toLogical(factor);
|
||||
* ```
|
||||
*/
|
||||
toLogical(scaleFactor) {
|
||||
return new LogicalSize(this.width / scaleFactor, this.height / scaleFactor);
|
||||
}
|
||||
[core.SERIALIZE_TO_IPC_FN]() {
|
||||
return {
|
||||
width: this.width,
|
||||
height: this.height
|
||||
};
|
||||
}
|
||||
toJSON() {
|
||||
// eslint-disable-next-line security/detect-object-injection
|
||||
return this[core.SERIALIZE_TO_IPC_FN]();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A size represented either in physical or in logical pixels.
|
||||
*
|
||||
* This type is basically a union type of {@linkcode LogicalSize} and {@linkcode PhysicalSize}
|
||||
* but comes in handy when using `tauri::Size` in Rust as an argument to a command, as this class
|
||||
* automatically serializes into a valid format so it can be deserialized correctly into `tauri::Size`
|
||||
*
|
||||
* So instead of
|
||||
* ```typescript
|
||||
* import { invoke } from '@tauri-apps/api/core';
|
||||
* import { LogicalSize, PhysicalSize } from '@tauri-apps/api/dpi';
|
||||
*
|
||||
* const size: LogicalSize | PhysicalSize = someFunction(); // where someFunction returns either LogicalSize or PhysicalSize
|
||||
* const validSize = size instanceof LogicalSize
|
||||
* ? { Logical: { width: size.width, height: size.height } }
|
||||
* : { Physical: { width: size.width, height: size.height } }
|
||||
* await invoke("do_something_with_size", { size: validSize });
|
||||
* ```
|
||||
*
|
||||
* You can just use {@linkcode Size}
|
||||
* ```typescript
|
||||
* import { invoke } from '@tauri-apps/api/core';
|
||||
* import { LogicalSize, PhysicalSize, Size } from '@tauri-apps/api/dpi';
|
||||
*
|
||||
* const size: LogicalSize | PhysicalSize = someFunction(); // where someFunction returns either LogicalSize or PhysicalSize
|
||||
* const validSize = new Size(size);
|
||||
* await invoke("do_something_with_size", { size: validSize });
|
||||
* ```
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
class Size {
|
||||
constructor(size) {
|
||||
this.size = size;
|
||||
}
|
||||
toLogical(scaleFactor) {
|
||||
return this.size instanceof LogicalSize
|
||||
? this.size
|
||||
: this.size.toLogical(scaleFactor);
|
||||
}
|
||||
toPhysical(scaleFactor) {
|
||||
return this.size instanceof PhysicalSize
|
||||
? this.size
|
||||
: this.size.toPhysical(scaleFactor);
|
||||
}
|
||||
[core.SERIALIZE_TO_IPC_FN]() {
|
||||
return {
|
||||
[`${this.size.type}`]: {
|
||||
width: this.size.width,
|
||||
height: this.size.height
|
||||
}
|
||||
};
|
||||
}
|
||||
toJSON() {
|
||||
// eslint-disable-next-line security/detect-object-injection
|
||||
return this[core.SERIALIZE_TO_IPC_FN]();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A position represented in logical pixels.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
class LogicalPosition {
|
||||
constructor(...args) {
|
||||
this.type = 'Logical';
|
||||
if (args.length === 1) {
|
||||
if ('Logical' in args[0]) {
|
||||
this.x = args[0].Logical.x;
|
||||
this.y = args[0].Logical.y;
|
||||
}
|
||||
else {
|
||||
this.x = args[0].x;
|
||||
this.y = args[0].y;
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.x = args[0];
|
||||
this.y = args[1];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Converts the logical position to a physical one.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { LogicalPosition } from '@tauri-apps/api/dpi';
|
||||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||||
*
|
||||
* const appWindow = getCurrentWindow();
|
||||
* const factor = await appWindow.scaleFactor();
|
||||
* const position = new LogicalPosition(400, 500);
|
||||
* const physical = position.toPhysical(factor);
|
||||
* ```
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
toPhysical(scaleFactor) {
|
||||
return new PhysicalPosition(this.x * scaleFactor, this.y * scaleFactor);
|
||||
}
|
||||
[core.SERIALIZE_TO_IPC_FN]() {
|
||||
return {
|
||||
x: this.x,
|
||||
y: this.y
|
||||
};
|
||||
}
|
||||
toJSON() {
|
||||
// eslint-disable-next-line security/detect-object-injection
|
||||
return this[core.SERIALIZE_TO_IPC_FN]();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A position represented in physical pixels.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
class PhysicalPosition {
|
||||
constructor(...args) {
|
||||
this.type = 'Physical';
|
||||
if (args.length === 1) {
|
||||
if ('Physical' in args[0]) {
|
||||
this.x = args[0].Physical.x;
|
||||
this.y = args[0].Physical.y;
|
||||
}
|
||||
else {
|
||||
this.x = args[0].x;
|
||||
this.y = args[0].y;
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.x = args[0];
|
||||
this.y = args[1];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Converts the physical position to a logical one.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { PhysicalPosition } from '@tauri-apps/api/dpi';
|
||||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||||
*
|
||||
* const appWindow = getCurrentWindow();
|
||||
* const factor = await appWindow.scaleFactor();
|
||||
* const position = new PhysicalPosition(400, 500);
|
||||
* const physical = position.toLogical(factor);
|
||||
* ```
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
toLogical(scaleFactor) {
|
||||
return new LogicalPosition(this.x / scaleFactor, this.y / scaleFactor);
|
||||
}
|
||||
[core.SERIALIZE_TO_IPC_FN]() {
|
||||
return {
|
||||
x: this.x,
|
||||
y: this.y
|
||||
};
|
||||
}
|
||||
toJSON() {
|
||||
// eslint-disable-next-line security/detect-object-injection
|
||||
return this[core.SERIALIZE_TO_IPC_FN]();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A position represented either in physical or in logical pixels.
|
||||
*
|
||||
* This type is basically a union type of {@linkcode LogicalSize} and {@linkcode PhysicalSize}
|
||||
* but comes in handy when using `tauri::Position` in Rust as an argument to a command, as this class
|
||||
* automatically serializes into a valid format so it can be deserialized correctly into `tauri::Position`
|
||||
*
|
||||
* So instead of
|
||||
* ```typescript
|
||||
* import { invoke } from '@tauri-apps/api/core';
|
||||
* import { LogicalPosition, PhysicalPosition } from '@tauri-apps/api/dpi';
|
||||
*
|
||||
* const position: LogicalPosition | PhysicalPosition = someFunction(); // where someFunction returns either LogicalPosition or PhysicalPosition
|
||||
* const validPosition = position instanceof LogicalPosition
|
||||
* ? { Logical: { x: position.x, y: position.y } }
|
||||
* : { Physical: { x: position.x, y: position.y } }
|
||||
* await invoke("do_something_with_position", { position: validPosition });
|
||||
* ```
|
||||
*
|
||||
* You can just use {@linkcode Position}
|
||||
* ```typescript
|
||||
* import { invoke } from '@tauri-apps/api/core';
|
||||
* import { LogicalPosition, PhysicalPosition, Position } from '@tauri-apps/api/dpi';
|
||||
*
|
||||
* const position: LogicalPosition | PhysicalPosition = someFunction(); // where someFunction returns either LogicalPosition or PhysicalPosition
|
||||
* const validPosition = new Position(position);
|
||||
* await invoke("do_something_with_position", { position: validPosition });
|
||||
* ```
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
class Position {
|
||||
constructor(position) {
|
||||
this.position = position;
|
||||
}
|
||||
toLogical(scaleFactor) {
|
||||
return this.position instanceof LogicalPosition
|
||||
? this.position
|
||||
: this.position.toLogical(scaleFactor);
|
||||
}
|
||||
toPhysical(scaleFactor) {
|
||||
return this.position instanceof PhysicalPosition
|
||||
? this.position
|
||||
: this.position.toPhysical(scaleFactor);
|
||||
}
|
||||
[core.SERIALIZE_TO_IPC_FN]() {
|
||||
return {
|
||||
[`${this.position.type}`]: {
|
||||
x: this.position.x,
|
||||
y: this.position.y
|
||||
}
|
||||
};
|
||||
}
|
||||
toJSON() {
|
||||
// eslint-disable-next-line security/detect-object-injection
|
||||
return this[core.SERIALIZE_TO_IPC_FN]();
|
||||
}
|
||||
}
|
||||
|
||||
exports.LogicalPosition = LogicalPosition;
|
||||
exports.LogicalSize = LogicalSize;
|
||||
exports.PhysicalPosition = PhysicalPosition;
|
||||
exports.PhysicalSize = PhysicalSize;
|
||||
exports.Position = Position;
|
||||
exports.Size = Size;
|
276
node_modules/@tauri-apps/api/dpi.d.ts
generated
vendored
Normal file
276
node_modules/@tauri-apps/api/dpi.d.ts
generated
vendored
Normal file
@ -0,0 +1,276 @@
|
||||
import { SERIALIZE_TO_IPC_FN } from './core';
|
||||
/**
|
||||
* A size represented in logical pixels.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
declare class LogicalSize {
|
||||
readonly type = "Logical";
|
||||
width: number;
|
||||
height: number;
|
||||
constructor(width: number, height: number);
|
||||
constructor(object: {
|
||||
Logical: {
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
});
|
||||
constructor(object: {
|
||||
width: number;
|
||||
height: number;
|
||||
});
|
||||
/**
|
||||
* Converts the logical size to a physical one.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { LogicalSize } from '@tauri-apps/api/dpi';
|
||||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||||
*
|
||||
* const appWindow = getCurrentWindow();
|
||||
* const factor = await appWindow.scaleFactor();
|
||||
* const size = new LogicalSize(400, 500);
|
||||
* const physical = size.toPhysical(factor);
|
||||
* ```
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
toPhysical(scaleFactor: number): PhysicalSize;
|
||||
[SERIALIZE_TO_IPC_FN](): {
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
toJSON(): {
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* A size represented in physical pixels.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
declare class PhysicalSize {
|
||||
readonly type = "Physical";
|
||||
width: number;
|
||||
height: number;
|
||||
constructor(width: number, height: number);
|
||||
constructor(object: {
|
||||
Physical: {
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
});
|
||||
constructor(object: {
|
||||
width: number;
|
||||
height: number;
|
||||
});
|
||||
/**
|
||||
* Converts the physical size to a logical one.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||||
* const appWindow = getCurrentWindow();
|
||||
* const factor = await appWindow.scaleFactor();
|
||||
* const size = await appWindow.innerSize(); // PhysicalSize
|
||||
* const logical = size.toLogical(factor);
|
||||
* ```
|
||||
*/
|
||||
toLogical(scaleFactor: number): LogicalSize;
|
||||
[SERIALIZE_TO_IPC_FN](): {
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
toJSON(): {
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* A size represented either in physical or in logical pixels.
|
||||
*
|
||||
* This type is basically a union type of {@linkcode LogicalSize} and {@linkcode PhysicalSize}
|
||||
* but comes in handy when using `tauri::Size` in Rust as an argument to a command, as this class
|
||||
* automatically serializes into a valid format so it can be deserialized correctly into `tauri::Size`
|
||||
*
|
||||
* So instead of
|
||||
* ```typescript
|
||||
* import { invoke } from '@tauri-apps/api/core';
|
||||
* import { LogicalSize, PhysicalSize } from '@tauri-apps/api/dpi';
|
||||
*
|
||||
* const size: LogicalSize | PhysicalSize = someFunction(); // where someFunction returns either LogicalSize or PhysicalSize
|
||||
* const validSize = size instanceof LogicalSize
|
||||
* ? { Logical: { width: size.width, height: size.height } }
|
||||
* : { Physical: { width: size.width, height: size.height } }
|
||||
* await invoke("do_something_with_size", { size: validSize });
|
||||
* ```
|
||||
*
|
||||
* You can just use {@linkcode Size}
|
||||
* ```typescript
|
||||
* import { invoke } from '@tauri-apps/api/core';
|
||||
* import { LogicalSize, PhysicalSize, Size } from '@tauri-apps/api/dpi';
|
||||
*
|
||||
* const size: LogicalSize | PhysicalSize = someFunction(); // where someFunction returns either LogicalSize or PhysicalSize
|
||||
* const validSize = new Size(size);
|
||||
* await invoke("do_something_with_size", { size: validSize });
|
||||
* ```
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
declare class Size {
|
||||
size: LogicalSize | PhysicalSize;
|
||||
constructor(size: LogicalSize | PhysicalSize);
|
||||
toLogical(scaleFactor: number): LogicalSize;
|
||||
toPhysical(scaleFactor: number): PhysicalSize;
|
||||
[SERIALIZE_TO_IPC_FN](): {
|
||||
[x: string]: {
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
};
|
||||
toJSON(): {
|
||||
[x: string]: {
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
};
|
||||
}
|
||||
/**
|
||||
* A position represented in logical pixels.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
declare class LogicalPosition {
|
||||
readonly type = "Logical";
|
||||
x: number;
|
||||
y: number;
|
||||
constructor(x: number, y: number);
|
||||
constructor(object: {
|
||||
Logical: {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
});
|
||||
constructor(object: {
|
||||
x: number;
|
||||
y: number;
|
||||
});
|
||||
/**
|
||||
* Converts the logical position to a physical one.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { LogicalPosition } from '@tauri-apps/api/dpi';
|
||||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||||
*
|
||||
* const appWindow = getCurrentWindow();
|
||||
* const factor = await appWindow.scaleFactor();
|
||||
* const position = new LogicalPosition(400, 500);
|
||||
* const physical = position.toPhysical(factor);
|
||||
* ```
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
toPhysical(scaleFactor: number): PhysicalPosition;
|
||||
[SERIALIZE_TO_IPC_FN](): {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
toJSON(): {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* A position represented in physical pixels.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
declare class PhysicalPosition {
|
||||
readonly type = "Physical";
|
||||
x: number;
|
||||
y: number;
|
||||
constructor(x: number, y: number);
|
||||
constructor(object: {
|
||||
Physical: {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
});
|
||||
constructor(object: {
|
||||
x: number;
|
||||
y: number;
|
||||
});
|
||||
/**
|
||||
* Converts the physical position to a logical one.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { PhysicalPosition } from '@tauri-apps/api/dpi';
|
||||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||||
*
|
||||
* const appWindow = getCurrentWindow();
|
||||
* const factor = await appWindow.scaleFactor();
|
||||
* const position = new PhysicalPosition(400, 500);
|
||||
* const physical = position.toLogical(factor);
|
||||
* ```
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
toLogical(scaleFactor: number): LogicalPosition;
|
||||
[SERIALIZE_TO_IPC_FN](): {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
toJSON(): {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* A position represented either in physical or in logical pixels.
|
||||
*
|
||||
* This type is basically a union type of {@linkcode LogicalSize} and {@linkcode PhysicalSize}
|
||||
* but comes in handy when using `tauri::Position` in Rust as an argument to a command, as this class
|
||||
* automatically serializes into a valid format so it can be deserialized correctly into `tauri::Position`
|
||||
*
|
||||
* So instead of
|
||||
* ```typescript
|
||||
* import { invoke } from '@tauri-apps/api/core';
|
||||
* import { LogicalPosition, PhysicalPosition } from '@tauri-apps/api/dpi';
|
||||
*
|
||||
* const position: LogicalPosition | PhysicalPosition = someFunction(); // where someFunction returns either LogicalPosition or PhysicalPosition
|
||||
* const validPosition = position instanceof LogicalPosition
|
||||
* ? { Logical: { x: position.x, y: position.y } }
|
||||
* : { Physical: { x: position.x, y: position.y } }
|
||||
* await invoke("do_something_with_position", { position: validPosition });
|
||||
* ```
|
||||
*
|
||||
* You can just use {@linkcode Position}
|
||||
* ```typescript
|
||||
* import { invoke } from '@tauri-apps/api/core';
|
||||
* import { LogicalPosition, PhysicalPosition, Position } from '@tauri-apps/api/dpi';
|
||||
*
|
||||
* const position: LogicalPosition | PhysicalPosition = someFunction(); // where someFunction returns either LogicalPosition or PhysicalPosition
|
||||
* const validPosition = new Position(position);
|
||||
* await invoke("do_something_with_position", { position: validPosition });
|
||||
* ```
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
declare class Position {
|
||||
position: LogicalPosition | PhysicalPosition;
|
||||
constructor(position: LogicalPosition | PhysicalPosition);
|
||||
toLogical(scaleFactor: number): LogicalPosition;
|
||||
toPhysical(scaleFactor: number): PhysicalPosition;
|
||||
[SERIALIZE_TO_IPC_FN](): {
|
||||
[x: string]: {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
};
|
||||
toJSON(): {
|
||||
[x: string]: {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
};
|
||||
}
|
||||
export { LogicalPosition, LogicalSize, Size, PhysicalPosition, PhysicalSize, Position };
|
327
node_modules/@tauri-apps/api/dpi.js
generated
vendored
Normal file
327
node_modules/@tauri-apps/api/dpi.js
generated
vendored
Normal file
@ -0,0 +1,327 @@
|
||||
import { SERIALIZE_TO_IPC_FN } from './core.js';
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/**
|
||||
* A size represented in logical pixels.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
class LogicalSize {
|
||||
constructor(...args) {
|
||||
this.type = 'Logical';
|
||||
if (args.length === 1) {
|
||||
if ('Logical' in args[0]) {
|
||||
this.width = args[0].Logical.width;
|
||||
this.height = args[0].Logical.height;
|
||||
}
|
||||
else {
|
||||
this.width = args[0].width;
|
||||
this.height = args[0].height;
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.width = args[0];
|
||||
this.height = args[1];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Converts the logical size to a physical one.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { LogicalSize } from '@tauri-apps/api/dpi';
|
||||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||||
*
|
||||
* const appWindow = getCurrentWindow();
|
||||
* const factor = await appWindow.scaleFactor();
|
||||
* const size = new LogicalSize(400, 500);
|
||||
* const physical = size.toPhysical(factor);
|
||||
* ```
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
toPhysical(scaleFactor) {
|
||||
return new PhysicalSize(this.width * scaleFactor, this.height * scaleFactor);
|
||||
}
|
||||
[SERIALIZE_TO_IPC_FN]() {
|
||||
return {
|
||||
width: this.width,
|
||||
height: this.height
|
||||
};
|
||||
}
|
||||
toJSON() {
|
||||
// eslint-disable-next-line security/detect-object-injection
|
||||
return this[SERIALIZE_TO_IPC_FN]();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A size represented in physical pixels.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
class PhysicalSize {
|
||||
constructor(...args) {
|
||||
this.type = 'Physical';
|
||||
if (args.length === 1) {
|
||||
if ('Physical' in args[0]) {
|
||||
this.width = args[0].Physical.width;
|
||||
this.height = args[0].Physical.height;
|
||||
}
|
||||
else {
|
||||
this.width = args[0].width;
|
||||
this.height = args[0].height;
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.width = args[0];
|
||||
this.height = args[1];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Converts the physical size to a logical one.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||||
* const appWindow = getCurrentWindow();
|
||||
* const factor = await appWindow.scaleFactor();
|
||||
* const size = await appWindow.innerSize(); // PhysicalSize
|
||||
* const logical = size.toLogical(factor);
|
||||
* ```
|
||||
*/
|
||||
toLogical(scaleFactor) {
|
||||
return new LogicalSize(this.width / scaleFactor, this.height / scaleFactor);
|
||||
}
|
||||
[SERIALIZE_TO_IPC_FN]() {
|
||||
return {
|
||||
width: this.width,
|
||||
height: this.height
|
||||
};
|
||||
}
|
||||
toJSON() {
|
||||
// eslint-disable-next-line security/detect-object-injection
|
||||
return this[SERIALIZE_TO_IPC_FN]();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A size represented either in physical or in logical pixels.
|
||||
*
|
||||
* This type is basically a union type of {@linkcode LogicalSize} and {@linkcode PhysicalSize}
|
||||
* but comes in handy when using `tauri::Size` in Rust as an argument to a command, as this class
|
||||
* automatically serializes into a valid format so it can be deserialized correctly into `tauri::Size`
|
||||
*
|
||||
* So instead of
|
||||
* ```typescript
|
||||
* import { invoke } from '@tauri-apps/api/core';
|
||||
* import { LogicalSize, PhysicalSize } from '@tauri-apps/api/dpi';
|
||||
*
|
||||
* const size: LogicalSize | PhysicalSize = someFunction(); // where someFunction returns either LogicalSize or PhysicalSize
|
||||
* const validSize = size instanceof LogicalSize
|
||||
* ? { Logical: { width: size.width, height: size.height } }
|
||||
* : { Physical: { width: size.width, height: size.height } }
|
||||
* await invoke("do_something_with_size", { size: validSize });
|
||||
* ```
|
||||
*
|
||||
* You can just use {@linkcode Size}
|
||||
* ```typescript
|
||||
* import { invoke } from '@tauri-apps/api/core';
|
||||
* import { LogicalSize, PhysicalSize, Size } from '@tauri-apps/api/dpi';
|
||||
*
|
||||
* const size: LogicalSize | PhysicalSize = someFunction(); // where someFunction returns either LogicalSize or PhysicalSize
|
||||
* const validSize = new Size(size);
|
||||
* await invoke("do_something_with_size", { size: validSize });
|
||||
* ```
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
class Size {
|
||||
constructor(size) {
|
||||
this.size = size;
|
||||
}
|
||||
toLogical(scaleFactor) {
|
||||
return this.size instanceof LogicalSize
|
||||
? this.size
|
||||
: this.size.toLogical(scaleFactor);
|
||||
}
|
||||
toPhysical(scaleFactor) {
|
||||
return this.size instanceof PhysicalSize
|
||||
? this.size
|
||||
: this.size.toPhysical(scaleFactor);
|
||||
}
|
||||
[SERIALIZE_TO_IPC_FN]() {
|
||||
return {
|
||||
[`${this.size.type}`]: {
|
||||
width: this.size.width,
|
||||
height: this.size.height
|
||||
}
|
||||
};
|
||||
}
|
||||
toJSON() {
|
||||
// eslint-disable-next-line security/detect-object-injection
|
||||
return this[SERIALIZE_TO_IPC_FN]();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A position represented in logical pixels.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
class LogicalPosition {
|
||||
constructor(...args) {
|
||||
this.type = 'Logical';
|
||||
if (args.length === 1) {
|
||||
if ('Logical' in args[0]) {
|
||||
this.x = args[0].Logical.x;
|
||||
this.y = args[0].Logical.y;
|
||||
}
|
||||
else {
|
||||
this.x = args[0].x;
|
||||
this.y = args[0].y;
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.x = args[0];
|
||||
this.y = args[1];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Converts the logical position to a physical one.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { LogicalPosition } from '@tauri-apps/api/dpi';
|
||||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||||
*
|
||||
* const appWindow = getCurrentWindow();
|
||||
* const factor = await appWindow.scaleFactor();
|
||||
* const position = new LogicalPosition(400, 500);
|
||||
* const physical = position.toPhysical(factor);
|
||||
* ```
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
toPhysical(scaleFactor) {
|
||||
return new PhysicalPosition(this.x * scaleFactor, this.y * scaleFactor);
|
||||
}
|
||||
[SERIALIZE_TO_IPC_FN]() {
|
||||
return {
|
||||
x: this.x,
|
||||
y: this.y
|
||||
};
|
||||
}
|
||||
toJSON() {
|
||||
// eslint-disable-next-line security/detect-object-injection
|
||||
return this[SERIALIZE_TO_IPC_FN]();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A position represented in physical pixels.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
class PhysicalPosition {
|
||||
constructor(...args) {
|
||||
this.type = 'Physical';
|
||||
if (args.length === 1) {
|
||||
if ('Physical' in args[0]) {
|
||||
this.x = args[0].Physical.x;
|
||||
this.y = args[0].Physical.y;
|
||||
}
|
||||
else {
|
||||
this.x = args[0].x;
|
||||
this.y = args[0].y;
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.x = args[0];
|
||||
this.y = args[1];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Converts the physical position to a logical one.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { PhysicalPosition } from '@tauri-apps/api/dpi';
|
||||
* import { getCurrentWindow } from '@tauri-apps/api/window';
|
||||
*
|
||||
* const appWindow = getCurrentWindow();
|
||||
* const factor = await appWindow.scaleFactor();
|
||||
* const position = new PhysicalPosition(400, 500);
|
||||
* const physical = position.toLogical(factor);
|
||||
* ```
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
toLogical(scaleFactor) {
|
||||
return new LogicalPosition(this.x / scaleFactor, this.y / scaleFactor);
|
||||
}
|
||||
[SERIALIZE_TO_IPC_FN]() {
|
||||
return {
|
||||
x: this.x,
|
||||
y: this.y
|
||||
};
|
||||
}
|
||||
toJSON() {
|
||||
// eslint-disable-next-line security/detect-object-injection
|
||||
return this[SERIALIZE_TO_IPC_FN]();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A position represented either in physical or in logical pixels.
|
||||
*
|
||||
* This type is basically a union type of {@linkcode LogicalSize} and {@linkcode PhysicalSize}
|
||||
* but comes in handy when using `tauri::Position` in Rust as an argument to a command, as this class
|
||||
* automatically serializes into a valid format so it can be deserialized correctly into `tauri::Position`
|
||||
*
|
||||
* So instead of
|
||||
* ```typescript
|
||||
* import { invoke } from '@tauri-apps/api/core';
|
||||
* import { LogicalPosition, PhysicalPosition } from '@tauri-apps/api/dpi';
|
||||
*
|
||||
* const position: LogicalPosition | PhysicalPosition = someFunction(); // where someFunction returns either LogicalPosition or PhysicalPosition
|
||||
* const validPosition = position instanceof LogicalPosition
|
||||
* ? { Logical: { x: position.x, y: position.y } }
|
||||
* : { Physical: { x: position.x, y: position.y } }
|
||||
* await invoke("do_something_with_position", { position: validPosition });
|
||||
* ```
|
||||
*
|
||||
* You can just use {@linkcode Position}
|
||||
* ```typescript
|
||||
* import { invoke } from '@tauri-apps/api/core';
|
||||
* import { LogicalPosition, PhysicalPosition, Position } from '@tauri-apps/api/dpi';
|
||||
*
|
||||
* const position: LogicalPosition | PhysicalPosition = someFunction(); // where someFunction returns either LogicalPosition or PhysicalPosition
|
||||
* const validPosition = new Position(position);
|
||||
* await invoke("do_something_with_position", { position: validPosition });
|
||||
* ```
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
class Position {
|
||||
constructor(position) {
|
||||
this.position = position;
|
||||
}
|
||||
toLogical(scaleFactor) {
|
||||
return this.position instanceof LogicalPosition
|
||||
? this.position
|
||||
: this.position.toLogical(scaleFactor);
|
||||
}
|
||||
toPhysical(scaleFactor) {
|
||||
return this.position instanceof PhysicalPosition
|
||||
? this.position
|
||||
: this.position.toPhysical(scaleFactor);
|
||||
}
|
||||
[SERIALIZE_TO_IPC_FN]() {
|
||||
return {
|
||||
[`${this.position.type}`]: {
|
||||
x: this.position.x,
|
||||
y: this.position.y
|
||||
}
|
||||
};
|
||||
}
|
||||
toJSON() {
|
||||
// eslint-disable-next-line security/detect-object-injection
|
||||
return this[SERIALIZE_TO_IPC_FN]();
|
||||
}
|
||||
}
|
||||
|
||||
export { LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize, Position, Size };
|
163
node_modules/@tauri-apps/api/event.cjs
generated
vendored
Normal file
163
node_modules/@tauri-apps/api/event.cjs
generated
vendored
Normal file
@ -0,0 +1,163 @@
|
||||
'use strict';
|
||||
|
||||
var core = require('./core.cjs');
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/**
|
||||
* The event system allows you to emit events to the backend and listen to events from it.
|
||||
*
|
||||
* This package is also accessible with `window.__TAURI__.event` when [`app.withGlobalTauri`](https://v2.tauri.app/reference/config/#withglobaltauri) in `tauri.conf.json` is set to `true`.
|
||||
* @module
|
||||
*/
|
||||
/**
|
||||
* @since 1.1.0
|
||||
*/
|
||||
exports.TauriEvent = void 0;
|
||||
(function (TauriEvent) {
|
||||
TauriEvent["WINDOW_RESIZED"] = "tauri://resize";
|
||||
TauriEvent["WINDOW_MOVED"] = "tauri://move";
|
||||
TauriEvent["WINDOW_CLOSE_REQUESTED"] = "tauri://close-requested";
|
||||
TauriEvent["WINDOW_DESTROYED"] = "tauri://destroyed";
|
||||
TauriEvent["WINDOW_FOCUS"] = "tauri://focus";
|
||||
TauriEvent["WINDOW_BLUR"] = "tauri://blur";
|
||||
TauriEvent["WINDOW_SCALE_FACTOR_CHANGED"] = "tauri://scale-change";
|
||||
TauriEvent["WINDOW_THEME_CHANGED"] = "tauri://theme-changed";
|
||||
TauriEvent["WINDOW_CREATED"] = "tauri://window-created";
|
||||
TauriEvent["WEBVIEW_CREATED"] = "tauri://webview-created";
|
||||
TauriEvent["DRAG_ENTER"] = "tauri://drag-enter";
|
||||
TauriEvent["DRAG_OVER"] = "tauri://drag-over";
|
||||
TauriEvent["DRAG_DROP"] = "tauri://drag-drop";
|
||||
TauriEvent["DRAG_LEAVE"] = "tauri://drag-leave";
|
||||
})(exports.TauriEvent || (exports.TauriEvent = {}));
|
||||
/**
|
||||
* Unregister the event listener associated with the given name and id.
|
||||
*
|
||||
* @ignore
|
||||
* @param event The event name
|
||||
* @param eventId Event identifier
|
||||
* @returns
|
||||
*/
|
||||
async function _unlisten(event, eventId) {
|
||||
await core.invoke('plugin:event|unlisten', {
|
||||
event,
|
||||
eventId
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Listen to an emitted event to any {@link EventTarget|target}.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { listen } from '@tauri-apps/api/event';
|
||||
* const unlisten = await listen<string>('error', (event) => {
|
||||
* console.log(`Got error, payload: ${event.payload}`);
|
||||
* });
|
||||
*
|
||||
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
||||
* unlisten();
|
||||
* ```
|
||||
*
|
||||
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
||||
* @param handler Event handler callback.
|
||||
* @param options Event listening options.
|
||||
* @returns A promise resolving to a function to unlisten to the event.
|
||||
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function listen(event, handler, options) {
|
||||
var _a;
|
||||
const target = typeof (options === null || options === void 0 ? void 0 : options.target) === 'string'
|
||||
? { kind: 'AnyLabel', label: options.target }
|
||||
: ((_a = options === null || options === void 0 ? void 0 : options.target) !== null && _a !== void 0 ? _a : { kind: 'Any' });
|
||||
return core.invoke('plugin:event|listen', {
|
||||
event,
|
||||
target,
|
||||
handler: core.transformCallback(handler)
|
||||
}).then((eventId) => {
|
||||
return async () => _unlisten(event, eventId);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Listens once to an emitted event to any {@link EventTarget|target}.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { once } from '@tauri-apps/api/event';
|
||||
* interface LoadedPayload {
|
||||
* loggedIn: boolean,
|
||||
* token: string
|
||||
* }
|
||||
* const unlisten = await once<LoadedPayload>('loaded', (event) => {
|
||||
* console.log(`App is loaded, loggedIn: ${event.payload.loggedIn}, token: ${event.payload.token}`);
|
||||
* });
|
||||
*
|
||||
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
||||
* unlisten();
|
||||
* ```
|
||||
*
|
||||
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
||||
* @param handler Event handler callback.
|
||||
* @param options Event listening options.
|
||||
* @returns A promise resolving to a function to unlisten to the event.
|
||||
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function once(event, handler, options) {
|
||||
return listen(event, (eventData) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
_unlisten(event, eventData.id);
|
||||
handler(eventData);
|
||||
}, options);
|
||||
}
|
||||
/**
|
||||
* Emits an event to all {@link EventTarget|targets}.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { emit } from '@tauri-apps/api/event';
|
||||
* await emit('frontend-loaded', { loggedIn: true, token: 'authToken' });
|
||||
* ```
|
||||
*
|
||||
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
||||
* @param payload Event payload.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function emit(event, payload) {
|
||||
await core.invoke('plugin:event|emit', {
|
||||
event,
|
||||
payload
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Emits an event to all {@link EventTarget|targets} matching the given target.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { emitTo } from '@tauri-apps/api/event';
|
||||
* await emitTo('main', 'frontend-loaded', { loggedIn: true, token: 'authToken' });
|
||||
* ```
|
||||
*
|
||||
* @param target Label of the target Window/Webview/WebviewWindow or raw {@link EventTarget} object.
|
||||
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
||||
* @param payload Event payload.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function emitTo(target, event, payload) {
|
||||
const eventTarget = typeof target === 'string' ? { kind: 'AnyLabel', label: target } : target;
|
||||
await core.invoke('plugin:event|emit_to', {
|
||||
target: eventTarget,
|
||||
event,
|
||||
payload
|
||||
});
|
||||
}
|
||||
|
||||
exports.emit = emit;
|
||||
exports.emitTo = emitTo;
|
||||
exports.listen = listen;
|
||||
exports.once = once;
|
138
node_modules/@tauri-apps/api/event.d.ts
generated
vendored
Normal file
138
node_modules/@tauri-apps/api/event.d.ts
generated
vendored
Normal file
@ -0,0 +1,138 @@
|
||||
type EventTarget = {
|
||||
kind: 'Any';
|
||||
} | {
|
||||
kind: 'AnyLabel';
|
||||
label: string;
|
||||
} | {
|
||||
kind: 'App';
|
||||
} | {
|
||||
kind: 'Window';
|
||||
label: string;
|
||||
} | {
|
||||
kind: 'Webview';
|
||||
label: string;
|
||||
} | {
|
||||
kind: 'WebviewWindow';
|
||||
label: string;
|
||||
};
|
||||
interface Event<T> {
|
||||
/** Event name */
|
||||
event: EventName;
|
||||
/** Event identifier used to unlisten */
|
||||
id: number;
|
||||
/** Event payload */
|
||||
payload: T;
|
||||
}
|
||||
type EventCallback<T> = (event: Event<T>) => void;
|
||||
type UnlistenFn = () => void;
|
||||
type EventName = `${TauriEvent}` | (string & Record<never, never>);
|
||||
interface Options {
|
||||
/**
|
||||
* The event target to listen to, defaults to `{ kind: 'Any' }`, see {@link EventTarget}.
|
||||
*
|
||||
* If a string is provided, {@link EventTarget.AnyLabel} is used.
|
||||
*/
|
||||
target?: string | EventTarget;
|
||||
}
|
||||
/**
|
||||
* @since 1.1.0
|
||||
*/
|
||||
declare enum TauriEvent {
|
||||
WINDOW_RESIZED = "tauri://resize",
|
||||
WINDOW_MOVED = "tauri://move",
|
||||
WINDOW_CLOSE_REQUESTED = "tauri://close-requested",
|
||||
WINDOW_DESTROYED = "tauri://destroyed",
|
||||
WINDOW_FOCUS = "tauri://focus",
|
||||
WINDOW_BLUR = "tauri://blur",
|
||||
WINDOW_SCALE_FACTOR_CHANGED = "tauri://scale-change",
|
||||
WINDOW_THEME_CHANGED = "tauri://theme-changed",
|
||||
WINDOW_CREATED = "tauri://window-created",
|
||||
WEBVIEW_CREATED = "tauri://webview-created",
|
||||
DRAG_ENTER = "tauri://drag-enter",
|
||||
DRAG_OVER = "tauri://drag-over",
|
||||
DRAG_DROP = "tauri://drag-drop",
|
||||
DRAG_LEAVE = "tauri://drag-leave"
|
||||
}
|
||||
/**
|
||||
* Listen to an emitted event to any {@link EventTarget|target}.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { listen } from '@tauri-apps/api/event';
|
||||
* const unlisten = await listen<string>('error', (event) => {
|
||||
* console.log(`Got error, payload: ${event.payload}`);
|
||||
* });
|
||||
*
|
||||
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
||||
* unlisten();
|
||||
* ```
|
||||
*
|
||||
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
||||
* @param handler Event handler callback.
|
||||
* @param options Event listening options.
|
||||
* @returns A promise resolving to a function to unlisten to the event.
|
||||
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
declare function listen<T>(event: EventName, handler: EventCallback<T>, options?: Options): Promise<UnlistenFn>;
|
||||
/**
|
||||
* Listens once to an emitted event to any {@link EventTarget|target}.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { once } from '@tauri-apps/api/event';
|
||||
* interface LoadedPayload {
|
||||
* loggedIn: boolean,
|
||||
* token: string
|
||||
* }
|
||||
* const unlisten = await once<LoadedPayload>('loaded', (event) => {
|
||||
* console.log(`App is loaded, loggedIn: ${event.payload.loggedIn}, token: ${event.payload.token}`);
|
||||
* });
|
||||
*
|
||||
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
||||
* unlisten();
|
||||
* ```
|
||||
*
|
||||
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
||||
* @param handler Event handler callback.
|
||||
* @param options Event listening options.
|
||||
* @returns A promise resolving to a function to unlisten to the event.
|
||||
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
declare function once<T>(event: EventName, handler: EventCallback<T>, options?: Options): Promise<UnlistenFn>;
|
||||
/**
|
||||
* Emits an event to all {@link EventTarget|targets}.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { emit } from '@tauri-apps/api/event';
|
||||
* await emit('frontend-loaded', { loggedIn: true, token: 'authToken' });
|
||||
* ```
|
||||
*
|
||||
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
||||
* @param payload Event payload.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
declare function emit<T>(event: string, payload?: T): Promise<void>;
|
||||
/**
|
||||
* Emits an event to all {@link EventTarget|targets} matching the given target.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { emitTo } from '@tauri-apps/api/event';
|
||||
* await emitTo('main', 'frontend-loaded', { loggedIn: true, token: 'authToken' });
|
||||
* ```
|
||||
*
|
||||
* @param target Label of the target Window/Webview/WebviewWindow or raw {@link EventTarget} object.
|
||||
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
||||
* @param payload Event payload.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
declare function emitTo<T>(target: EventTarget | string, event: string, payload?: T): Promise<void>;
|
||||
export type { Event, EventTarget, EventCallback, UnlistenFn, EventName, Options };
|
||||
export { listen, once, emit, emitTo, TauriEvent };
|
158
node_modules/@tauri-apps/api/event.js
generated
vendored
Normal file
158
node_modules/@tauri-apps/api/event.js
generated
vendored
Normal file
@ -0,0 +1,158 @@
|
||||
import { invoke, transformCallback } from './core.js';
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/**
|
||||
* The event system allows you to emit events to the backend and listen to events from it.
|
||||
*
|
||||
* This package is also accessible with `window.__TAURI__.event` when [`app.withGlobalTauri`](https://v2.tauri.app/reference/config/#withglobaltauri) in `tauri.conf.json` is set to `true`.
|
||||
* @module
|
||||
*/
|
||||
/**
|
||||
* @since 1.1.0
|
||||
*/
|
||||
var TauriEvent;
|
||||
(function (TauriEvent) {
|
||||
TauriEvent["WINDOW_RESIZED"] = "tauri://resize";
|
||||
TauriEvent["WINDOW_MOVED"] = "tauri://move";
|
||||
TauriEvent["WINDOW_CLOSE_REQUESTED"] = "tauri://close-requested";
|
||||
TauriEvent["WINDOW_DESTROYED"] = "tauri://destroyed";
|
||||
TauriEvent["WINDOW_FOCUS"] = "tauri://focus";
|
||||
TauriEvent["WINDOW_BLUR"] = "tauri://blur";
|
||||
TauriEvent["WINDOW_SCALE_FACTOR_CHANGED"] = "tauri://scale-change";
|
||||
TauriEvent["WINDOW_THEME_CHANGED"] = "tauri://theme-changed";
|
||||
TauriEvent["WINDOW_CREATED"] = "tauri://window-created";
|
||||
TauriEvent["WEBVIEW_CREATED"] = "tauri://webview-created";
|
||||
TauriEvent["DRAG_ENTER"] = "tauri://drag-enter";
|
||||
TauriEvent["DRAG_OVER"] = "tauri://drag-over";
|
||||
TauriEvent["DRAG_DROP"] = "tauri://drag-drop";
|
||||
TauriEvent["DRAG_LEAVE"] = "tauri://drag-leave";
|
||||
})(TauriEvent || (TauriEvent = {}));
|
||||
/**
|
||||
* Unregister the event listener associated with the given name and id.
|
||||
*
|
||||
* @ignore
|
||||
* @param event The event name
|
||||
* @param eventId Event identifier
|
||||
* @returns
|
||||
*/
|
||||
async function _unlisten(event, eventId) {
|
||||
await invoke('plugin:event|unlisten', {
|
||||
event,
|
||||
eventId
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Listen to an emitted event to any {@link EventTarget|target}.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { listen } from '@tauri-apps/api/event';
|
||||
* const unlisten = await listen<string>('error', (event) => {
|
||||
* console.log(`Got error, payload: ${event.payload}`);
|
||||
* });
|
||||
*
|
||||
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
||||
* unlisten();
|
||||
* ```
|
||||
*
|
||||
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
||||
* @param handler Event handler callback.
|
||||
* @param options Event listening options.
|
||||
* @returns A promise resolving to a function to unlisten to the event.
|
||||
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function listen(event, handler, options) {
|
||||
var _a;
|
||||
const target = typeof (options === null || options === void 0 ? void 0 : options.target) === 'string'
|
||||
? { kind: 'AnyLabel', label: options.target }
|
||||
: ((_a = options === null || options === void 0 ? void 0 : options.target) !== null && _a !== void 0 ? _a : { kind: 'Any' });
|
||||
return invoke('plugin:event|listen', {
|
||||
event,
|
||||
target,
|
||||
handler: transformCallback(handler)
|
||||
}).then((eventId) => {
|
||||
return async () => _unlisten(event, eventId);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Listens once to an emitted event to any {@link EventTarget|target}.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { once } from '@tauri-apps/api/event';
|
||||
* interface LoadedPayload {
|
||||
* loggedIn: boolean,
|
||||
* token: string
|
||||
* }
|
||||
* const unlisten = await once<LoadedPayload>('loaded', (event) => {
|
||||
* console.log(`App is loaded, loggedIn: ${event.payload.loggedIn}, token: ${event.payload.token}`);
|
||||
* });
|
||||
*
|
||||
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
||||
* unlisten();
|
||||
* ```
|
||||
*
|
||||
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
||||
* @param handler Event handler callback.
|
||||
* @param options Event listening options.
|
||||
* @returns A promise resolving to a function to unlisten to the event.
|
||||
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function once(event, handler, options) {
|
||||
return listen(event, (eventData) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
_unlisten(event, eventData.id);
|
||||
handler(eventData);
|
||||
}, options);
|
||||
}
|
||||
/**
|
||||
* Emits an event to all {@link EventTarget|targets}.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { emit } from '@tauri-apps/api/event';
|
||||
* await emit('frontend-loaded', { loggedIn: true, token: 'authToken' });
|
||||
* ```
|
||||
*
|
||||
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
||||
* @param payload Event payload.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function emit(event, payload) {
|
||||
await invoke('plugin:event|emit', {
|
||||
event,
|
||||
payload
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Emits an event to all {@link EventTarget|targets} matching the given target.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { emitTo } from '@tauri-apps/api/event';
|
||||
* await emitTo('main', 'frontend-loaded', { loggedIn: true, token: 'authToken' });
|
||||
* ```
|
||||
*
|
||||
* @param target Label of the target Window/Webview/WebviewWindow or raw {@link EventTarget} object.
|
||||
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
||||
* @param payload Event payload.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function emitTo(target, event, payload) {
|
||||
const eventTarget = typeof target === 'string' ? { kind: 'AnyLabel', label: target } : target;
|
||||
await invoke('plugin:event|emit_to', {
|
||||
target: eventTarget,
|
||||
event,
|
||||
payload
|
||||
});
|
||||
}
|
||||
|
||||
export { TauriEvent, emit, emitTo, listen, once };
|
39
node_modules/@tauri-apps/api/external/tslib/tslib.es6.cjs
generated
vendored
Normal file
39
node_modules/@tauri-apps/api/external/tslib/tslib.es6.cjs
generated
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
***************************************************************************** */
|
||||
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
||||
|
||||
|
||||
function __classPrivateFieldGet(receiver, state, kind, f) {
|
||||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
||||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
||||
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
||||
}
|
||||
|
||||
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
||||
if (kind === "m") throw new TypeError("Private method is not writable");
|
||||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
||||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
||||
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
||||
}
|
||||
|
||||
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
||||
var e = new Error(message);
|
||||
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
||||
};
|
||||
|
||||
exports.__classPrivateFieldGet = __classPrivateFieldGet;
|
||||
exports.__classPrivateFieldSet = __classPrivateFieldSet;
|
36
node_modules/@tauri-apps/api/external/tslib/tslib.es6.js
generated
vendored
Normal file
36
node_modules/@tauri-apps/api/external/tslib/tslib.es6.js
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
/******************************************************************************
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
***************************************************************************** */
|
||||
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
||||
|
||||
|
||||
function __classPrivateFieldGet(receiver, state, kind, f) {
|
||||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
||||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
||||
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
||||
}
|
||||
|
||||
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
||||
if (kind === "m") throw new TypeError("Private method is not writable");
|
||||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
||||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
||||
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
||||
}
|
||||
|
||||
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
||||
var e = new Error(message);
|
||||
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
||||
};
|
||||
|
||||
export { __classPrivateFieldGet, __classPrivateFieldSet };
|
88
node_modules/@tauri-apps/api/image.cjs
generated
vendored
Normal file
88
node_modules/@tauri-apps/api/image.cjs
generated
vendored
Normal file
@ -0,0 +1,88 @@
|
||||
'use strict';
|
||||
|
||||
var core = require('./core.cjs');
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/** An RGBA Image in row-major order from top to bottom. */
|
||||
class Image extends core.Resource {
|
||||
/**
|
||||
* Creates an Image from a resource ID. For internal use only.
|
||||
*
|
||||
* @ignore
|
||||
*/
|
||||
constructor(rid) {
|
||||
super(rid);
|
||||
}
|
||||
/** Creates a new Image using RGBA data, in row-major order from top to bottom, and with specified width and height. */
|
||||
static async new(rgba, width, height) {
|
||||
return core.invoke('plugin:image|new', {
|
||||
rgba: transformImage(rgba),
|
||||
width,
|
||||
height
|
||||
}).then((rid) => new Image(rid));
|
||||
}
|
||||
/**
|
||||
* Creates a new image using the provided bytes by inferring the file format.
|
||||
* If the format is known, prefer [@link Image.fromPngBytes] or [@link Image.fromIcoBytes].
|
||||
*
|
||||
* Only `ico` and `png` are supported (based on activated feature flag).
|
||||
*
|
||||
* Note that you need the `image-ico` or `image-png` Cargo features to use this API.
|
||||
* To enable it, change your Cargo.toml file:
|
||||
* ```toml
|
||||
* [dependencies]
|
||||
* tauri = { version = "...", features = ["...", "image-png"] }
|
||||
* ```
|
||||
*/
|
||||
static async fromBytes(bytes) {
|
||||
return core.invoke('plugin:image|from_bytes', {
|
||||
bytes: transformImage(bytes)
|
||||
}).then((rid) => new Image(rid));
|
||||
}
|
||||
/**
|
||||
* Creates a new image using the provided path.
|
||||
*
|
||||
* Only `ico` and `png` are supported (based on activated feature flag).
|
||||
*
|
||||
* Note that you need the `image-ico` or `image-png` Cargo features to use this API.
|
||||
* To enable it, change your Cargo.toml file:
|
||||
* ```toml
|
||||
* [dependencies]
|
||||
* tauri = { version = "...", features = ["...", "image-png"] }
|
||||
* ```
|
||||
*/
|
||||
static async fromPath(path) {
|
||||
return core.invoke('plugin:image|from_path', { path }).then((rid) => new Image(rid));
|
||||
}
|
||||
/** Returns the RGBA data for this image, in row-major order from top to bottom. */
|
||||
async rgba() {
|
||||
return core.invoke('plugin:image|rgba', {
|
||||
rid: this.rid
|
||||
}).then((buffer) => new Uint8Array(buffer));
|
||||
}
|
||||
/** Returns the size of this image. */
|
||||
async size() {
|
||||
return core.invoke('plugin:image|size', { rid: this.rid });
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Transforms image from various types into a type acceptable by Rust.
|
||||
*
|
||||
* See [tauri::image::JsImage](https://docs.rs/tauri/2/tauri/image/enum.JsImage.html) for more information.
|
||||
* Note the API signature is not stable and might change.
|
||||
*/
|
||||
function transformImage(image) {
|
||||
const ret = image == null
|
||||
? null
|
||||
: typeof image === 'string'
|
||||
? image
|
||||
: image instanceof Image
|
||||
? image.rid
|
||||
: image;
|
||||
return ret;
|
||||
}
|
||||
|
||||
exports.Image = Image;
|
||||
exports.transformImage = transformImage;
|
54
node_modules/@tauri-apps/api/image.d.ts
generated
vendored
Normal file
54
node_modules/@tauri-apps/api/image.d.ts
generated
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
import { Resource } from './core';
|
||||
export interface ImageSize {
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
||||
/** An RGBA Image in row-major order from top to bottom. */
|
||||
export declare class Image extends Resource {
|
||||
/**
|
||||
* Creates an Image from a resource ID. For internal use only.
|
||||
*
|
||||
* @ignore
|
||||
*/
|
||||
constructor(rid: number);
|
||||
/** Creates a new Image using RGBA data, in row-major order from top to bottom, and with specified width and height. */
|
||||
static new(rgba: number[] | Uint8Array | ArrayBuffer, width: number, height: number): Promise<Image>;
|
||||
/**
|
||||
* Creates a new image using the provided bytes by inferring the file format.
|
||||
* If the format is known, prefer [@link Image.fromPngBytes] or [@link Image.fromIcoBytes].
|
||||
*
|
||||
* Only `ico` and `png` are supported (based on activated feature flag).
|
||||
*
|
||||
* Note that you need the `image-ico` or `image-png` Cargo features to use this API.
|
||||
* To enable it, change your Cargo.toml file:
|
||||
* ```toml
|
||||
* [dependencies]
|
||||
* tauri = { version = "...", features = ["...", "image-png"] }
|
||||
* ```
|
||||
*/
|
||||
static fromBytes(bytes: number[] | Uint8Array | ArrayBuffer): Promise<Image>;
|
||||
/**
|
||||
* Creates a new image using the provided path.
|
||||
*
|
||||
* Only `ico` and `png` are supported (based on activated feature flag).
|
||||
*
|
||||
* Note that you need the `image-ico` or `image-png` Cargo features to use this API.
|
||||
* To enable it, change your Cargo.toml file:
|
||||
* ```toml
|
||||
* [dependencies]
|
||||
* tauri = { version = "...", features = ["...", "image-png"] }
|
||||
* ```
|
||||
*/
|
||||
static fromPath(path: string): Promise<Image>;
|
||||
/** Returns the RGBA data for this image, in row-major order from top to bottom. */
|
||||
rgba(): Promise<Uint8Array>;
|
||||
/** Returns the size of this image. */
|
||||
size(): Promise<ImageSize>;
|
||||
}
|
||||
/**
|
||||
* Transforms image from various types into a type acceptable by Rust.
|
||||
*
|
||||
* See [tauri::image::JsImage](https://docs.rs/tauri/2/tauri/image/enum.JsImage.html) for more information.
|
||||
* Note the API signature is not stable and might change.
|
||||
*/
|
||||
export declare function transformImage<T>(image: string | Image | Uint8Array | ArrayBuffer | number[] | null): T;
|
85
node_modules/@tauri-apps/api/image.js
generated
vendored
Normal file
85
node_modules/@tauri-apps/api/image.js
generated
vendored
Normal file
@ -0,0 +1,85 @@
|
||||
import { Resource, invoke } from './core.js';
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/** An RGBA Image in row-major order from top to bottom. */
|
||||
class Image extends Resource {
|
||||
/**
|
||||
* Creates an Image from a resource ID. For internal use only.
|
||||
*
|
||||
* @ignore
|
||||
*/
|
||||
constructor(rid) {
|
||||
super(rid);
|
||||
}
|
||||
/** Creates a new Image using RGBA data, in row-major order from top to bottom, and with specified width and height. */
|
||||
static async new(rgba, width, height) {
|
||||
return invoke('plugin:image|new', {
|
||||
rgba: transformImage(rgba),
|
||||
width,
|
||||
height
|
||||
}).then((rid) => new Image(rid));
|
||||
}
|
||||
/**
|
||||
* Creates a new image using the provided bytes by inferring the file format.
|
||||
* If the format is known, prefer [@link Image.fromPngBytes] or [@link Image.fromIcoBytes].
|
||||
*
|
||||
* Only `ico` and `png` are supported (based on activated feature flag).
|
||||
*
|
||||
* Note that you need the `image-ico` or `image-png` Cargo features to use this API.
|
||||
* To enable it, change your Cargo.toml file:
|
||||
* ```toml
|
||||
* [dependencies]
|
||||
* tauri = { version = "...", features = ["...", "image-png"] }
|
||||
* ```
|
||||
*/
|
||||
static async fromBytes(bytes) {
|
||||
return invoke('plugin:image|from_bytes', {
|
||||
bytes: transformImage(bytes)
|
||||
}).then((rid) => new Image(rid));
|
||||
}
|
||||
/**
|
||||
* Creates a new image using the provided path.
|
||||
*
|
||||
* Only `ico` and `png` are supported (based on activated feature flag).
|
||||
*
|
||||
* Note that you need the `image-ico` or `image-png` Cargo features to use this API.
|
||||
* To enable it, change your Cargo.toml file:
|
||||
* ```toml
|
||||
* [dependencies]
|
||||
* tauri = { version = "...", features = ["...", "image-png"] }
|
||||
* ```
|
||||
*/
|
||||
static async fromPath(path) {
|
||||
return invoke('plugin:image|from_path', { path }).then((rid) => new Image(rid));
|
||||
}
|
||||
/** Returns the RGBA data for this image, in row-major order from top to bottom. */
|
||||
async rgba() {
|
||||
return invoke('plugin:image|rgba', {
|
||||
rid: this.rid
|
||||
}).then((buffer) => new Uint8Array(buffer));
|
||||
}
|
||||
/** Returns the size of this image. */
|
||||
async size() {
|
||||
return invoke('plugin:image|size', { rid: this.rid });
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Transforms image from various types into a type acceptable by Rust.
|
||||
*
|
||||
* See [tauri::image::JsImage](https://docs.rs/tauri/2/tauri/image/enum.JsImage.html) for more information.
|
||||
* Note the API signature is not stable and might change.
|
||||
*/
|
||||
function transformImage(image) {
|
||||
const ret = image == null
|
||||
? null
|
||||
: typeof image === 'string'
|
||||
? image
|
||||
: image instanceof Image
|
||||
? image.rid
|
||||
: image;
|
||||
return ret;
|
||||
}
|
||||
|
||||
export { Image, transformImage };
|
29
node_modules/@tauri-apps/api/index.cjs
generated
vendored
Normal file
29
node_modules/@tauri-apps/api/index.cjs
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
|
||||
var app = require('./app.cjs');
|
||||
var core = require('./core.cjs');
|
||||
var dpi = require('./dpi.cjs');
|
||||
var event = require('./event.cjs');
|
||||
var image = require('./image.cjs');
|
||||
var menu = require('./menu.cjs');
|
||||
var mocks = require('./mocks.cjs');
|
||||
var path = require('./path.cjs');
|
||||
var tray = require('./tray.cjs');
|
||||
var webview = require('./webview.cjs');
|
||||
var webviewWindow = require('./webviewWindow.cjs');
|
||||
var window = require('./window.cjs');
|
||||
|
||||
|
||||
|
||||
exports.app = app;
|
||||
exports.core = core;
|
||||
exports.dpi = dpi;
|
||||
exports.event = event;
|
||||
exports.image = image;
|
||||
exports.menu = menu;
|
||||
exports.mocks = mocks;
|
||||
exports.path = path;
|
||||
exports.tray = tray;
|
||||
exports.webview = webview;
|
||||
exports.webviewWindow = webviewWindow;
|
||||
exports.window = window;
|
33
node_modules/@tauri-apps/api/index.d.ts
generated
vendored
Normal file
33
node_modules/@tauri-apps/api/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* The Tauri API allows you to interface with the backend layer.
|
||||
*
|
||||
* This module exposes all other modules as an object where the key is the module name, and the value is the module exports.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { event, window, path } from '@tauri-apps/api'
|
||||
* ```
|
||||
*
|
||||
* ### Vanilla JS API
|
||||
*
|
||||
* The above import syntax is for JavaScript/TypeScript with a bundler. If you're using vanilla JavaScript, you can use the global `window.__TAURI__` object instead. It requires `app.withGlobalTauri` configuration option enabled.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* const { event, window: tauriWindow, path } = window.__TAURI__;
|
||||
* ```
|
||||
*
|
||||
* @module
|
||||
*/
|
||||
import * as app from './app';
|
||||
import * as core from './core';
|
||||
import * as dpi from './dpi';
|
||||
import * as event from './event';
|
||||
import * as image from './image';
|
||||
import * as menu from './menu';
|
||||
import * as mocks from './mocks';
|
||||
import * as path from './path';
|
||||
import * as tray from './tray';
|
||||
import * as webview from './webview';
|
||||
import * as webviewWindow from './webviewWindow';
|
||||
import * as window from './window';
|
||||
export { app, core, dpi, event, image, menu, mocks, path, tray, webview, webviewWindow, window };
|
24
node_modules/@tauri-apps/api/index.js
generated
vendored
Normal file
24
node_modules/@tauri-apps/api/index.js
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
import * as app from './app.js';
|
||||
export { app };
|
||||
import * as core from './core.js';
|
||||
export { core };
|
||||
import * as dpi from './dpi.js';
|
||||
export { dpi };
|
||||
import * as event from './event.js';
|
||||
export { event };
|
||||
import * as image from './image.js';
|
||||
export { image };
|
||||
import * as menu from './menu.js';
|
||||
export { menu };
|
||||
import * as mocks from './mocks.js';
|
||||
export { mocks };
|
||||
import * as path from './path.js';
|
||||
export { path };
|
||||
import * as tray from './tray.js';
|
||||
export { tray };
|
||||
import * as webview from './webview.js';
|
||||
export { webview };
|
||||
import * as webviewWindow from './webviewWindow.js';
|
||||
export { webviewWindow };
|
||||
import * as window from './window.js';
|
||||
export { window };
|
30
node_modules/@tauri-apps/api/menu.cjs
generated
vendored
Normal file
30
node_modules/@tauri-apps/api/menu.cjs
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
'use strict';
|
||||
|
||||
var submenu = require('./menu/submenu.cjs');
|
||||
var menuItem = require('./menu/menuItem.cjs');
|
||||
var menu = require('./menu/menu.cjs');
|
||||
var checkMenuItem = require('./menu/checkMenuItem.cjs');
|
||||
var iconMenuItem = require('./menu/iconMenuItem.cjs');
|
||||
var predefinedMenuItem = require('./menu/predefinedMenuItem.cjs');
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/**
|
||||
* Menu types and utilities.
|
||||
*
|
||||
* This package is also accessible with `window.__TAURI__.menu` when [`app.withGlobalTauri`](https://v2.tauri.app/reference/config/#withglobaltauri) in `tauri.conf.json` is set to `true`.
|
||||
* @module
|
||||
*/
|
||||
|
||||
exports.Submenu = submenu.Submenu;
|
||||
exports.itemFromKind = submenu.itemFromKind;
|
||||
exports.MenuItem = menuItem.MenuItem;
|
||||
exports.Menu = menu.Menu;
|
||||
exports.CheckMenuItem = checkMenuItem.CheckMenuItem;
|
||||
exports.IconMenuItem = iconMenuItem.IconMenuItem;
|
||||
Object.defineProperty(exports, "NativeIcon", {
|
||||
enumerable: true,
|
||||
get: function () { return iconMenuItem.NativeIcon; }
|
||||
});
|
||||
exports.PredefinedMenuItem = predefinedMenuItem.PredefinedMenuItem;
|
12
node_modules/@tauri-apps/api/menu.d.ts
generated
vendored
Normal file
12
node_modules/@tauri-apps/api/menu.d.ts
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
export * from './menu/submenu';
|
||||
export * from './menu/menuItem';
|
||||
export * from './menu/menu';
|
||||
export * from './menu/checkMenuItem';
|
||||
export * from './menu/iconMenuItem';
|
||||
export * from './menu/predefinedMenuItem';
|
||||
/**
|
||||
* Menu types and utilities.
|
||||
*
|
||||
* This package is also accessible with `window.__TAURI__.menu` when [`app.withGlobalTauri`](https://v2.tauri.app/reference/config/#withglobaltauri) in `tauri.conf.json` is set to `true`.
|
||||
* @module
|
||||
*/
|
16
node_modules/@tauri-apps/api/menu.js
generated
vendored
Normal file
16
node_modules/@tauri-apps/api/menu.js
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
export { Submenu, itemFromKind } from './menu/submenu.js';
|
||||
export { MenuItem } from './menu/menuItem.js';
|
||||
export { Menu } from './menu/menu.js';
|
||||
export { CheckMenuItem } from './menu/checkMenuItem.js';
|
||||
export { IconMenuItem, NativeIcon } from './menu/iconMenuItem.js';
|
||||
export { PredefinedMenuItem } from './menu/predefinedMenuItem.js';
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/**
|
||||
* Menu types and utilities.
|
||||
*
|
||||
* This package is also accessible with `window.__TAURI__.menu` when [`app.withGlobalTauri`](https://v2.tauri.app/reference/config/#withglobaltauri) in `tauri.conf.json` is set to `true`.
|
||||
* @module
|
||||
*/
|
100
node_modules/@tauri-apps/api/menu/base.cjs
generated
vendored
Normal file
100
node_modules/@tauri-apps/api/menu/base.cjs
generated
vendored
Normal file
@ -0,0 +1,100 @@
|
||||
'use strict';
|
||||
|
||||
var tslib_es6 = require('../external/tslib/tslib.es6.cjs');
|
||||
var core = require('../core.cjs');
|
||||
var image = require('../image.cjs');
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
var _MenuItemBase_id, _MenuItemBase_kind;
|
||||
function injectChannel(i) {
|
||||
var _a;
|
||||
if ('items' in i) {
|
||||
i.items = (_a = i.items) === null || _a === void 0 ? void 0 : _a.map((item) => 'rid' in item ? item : injectChannel(item));
|
||||
}
|
||||
else if ('action' in i && i.action) {
|
||||
const handler = new core.Channel();
|
||||
handler.onmessage = i.action;
|
||||
delete i.action;
|
||||
return { ...i, handler };
|
||||
}
|
||||
return i;
|
||||
}
|
||||
async function newMenu(kind, opts) {
|
||||
const handler = new core.Channel();
|
||||
if (opts && typeof opts === 'object') {
|
||||
if ('action' in opts && opts.action) {
|
||||
handler.onmessage = opts.action;
|
||||
delete opts.action;
|
||||
}
|
||||
// about predefined menu item icon
|
||||
if ('item' in opts
|
||||
&& opts.item
|
||||
&& typeof opts.item === 'object'
|
||||
&& 'About' in opts.item
|
||||
&& opts.item.About
|
||||
&& typeof opts.item.About === 'object'
|
||||
&& 'icon' in opts.item.About
|
||||
&& opts.item.About.icon) {
|
||||
opts.item.About.icon = image.transformImage(opts.item.About.icon);
|
||||
}
|
||||
// icon menu item icon
|
||||
if ('icon' in opts && opts.icon) {
|
||||
opts.icon = image.transformImage(opts.icon);
|
||||
}
|
||||
// submenu items
|
||||
if ('items' in opts && opts.items) {
|
||||
function prepareItem(i) {
|
||||
var _a;
|
||||
if ('rid' in i) {
|
||||
return [i.rid, i.kind];
|
||||
}
|
||||
if ('item' in i && typeof i.item === 'object' && ((_a = i.item.About) === null || _a === void 0 ? void 0 : _a.icon)) {
|
||||
i.item.About.icon = image.transformImage(i.item.About.icon);
|
||||
}
|
||||
if ('icon' in i && i.icon) {
|
||||
i.icon = image.transformImage(i.icon);
|
||||
}
|
||||
if ('items' in i && i.items) {
|
||||
// @ts-expect-error the `prepareItem` return doesn't exactly match
|
||||
// this is fine, because the difference is in `[number, string]` variant
|
||||
i.items = i.items.map(prepareItem);
|
||||
}
|
||||
return injectChannel(i);
|
||||
}
|
||||
// @ts-expect-error the `prepareItem` return doesn't exactly match
|
||||
// this is fine, because the difference is in `[number, string]` variant
|
||||
opts.items = opts.items.map(prepareItem);
|
||||
}
|
||||
}
|
||||
return core.invoke('plugin:menu|new', {
|
||||
kind,
|
||||
options: opts,
|
||||
handler
|
||||
});
|
||||
}
|
||||
class MenuItemBase extends core.Resource {
|
||||
/** The id of this item. */
|
||||
get id() {
|
||||
return tslib_es6.__classPrivateFieldGet(this, _MenuItemBase_id, "f");
|
||||
}
|
||||
/** @ignore */
|
||||
get kind() {
|
||||
return tslib_es6.__classPrivateFieldGet(this, _MenuItemBase_kind, "f");
|
||||
}
|
||||
/** @ignore */
|
||||
constructor(rid, id, kind) {
|
||||
super(rid);
|
||||
/** @ignore */
|
||||
_MenuItemBase_id.set(this, void 0);
|
||||
/** @ignore */
|
||||
_MenuItemBase_kind.set(this, void 0);
|
||||
tslib_es6.__classPrivateFieldSet(this, _MenuItemBase_id, id, "f");
|
||||
tslib_es6.__classPrivateFieldSet(this, _MenuItemBase_kind, kind, "f");
|
||||
}
|
||||
}
|
||||
_MenuItemBase_id = new WeakMap(), _MenuItemBase_kind = new WeakMap();
|
||||
|
||||
exports.MenuItemBase = MenuItemBase;
|
||||
exports.newMenu = newMenu;
|
18
node_modules/@tauri-apps/api/menu/base.d.ts
generated
vendored
Normal file
18
node_modules/@tauri-apps/api/menu/base.d.ts
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
import { Resource } from '../core';
|
||||
import { CheckMenuItemOptions } from './checkMenuItem';
|
||||
import { IconMenuItemOptions } from './iconMenuItem';
|
||||
import { MenuOptions } from './menu';
|
||||
import { MenuItemOptions } from './menuItem';
|
||||
import { PredefinedMenuItemOptions } from './predefinedMenuItem';
|
||||
import { SubmenuOptions } from './submenu';
|
||||
export type ItemKind = 'MenuItem' | 'Predefined' | 'Check' | 'Icon' | 'Submenu' | 'Menu';
|
||||
export declare function newMenu(kind: ItemKind, opts?: MenuOptions | MenuItemOptions | SubmenuOptions | PredefinedMenuItemOptions | CheckMenuItemOptions | IconMenuItemOptions): Promise<[number, string]>;
|
||||
export declare class MenuItemBase extends Resource {
|
||||
#private;
|
||||
/** The id of this item. */
|
||||
get id(): string;
|
||||
/** @ignore */
|
||||
get kind(): string;
|
||||
/** @ignore */
|
||||
protected constructor(rid: number, id: string, kind: ItemKind);
|
||||
}
|
97
node_modules/@tauri-apps/api/menu/base.js
generated
vendored
Normal file
97
node_modules/@tauri-apps/api/menu/base.js
generated
vendored
Normal file
@ -0,0 +1,97 @@
|
||||
import { __classPrivateFieldGet, __classPrivateFieldSet } from '../external/tslib/tslib.es6.js';
|
||||
import { Resource, Channel, invoke } from '../core.js';
|
||||
import { transformImage } from '../image.js';
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
var _MenuItemBase_id, _MenuItemBase_kind;
|
||||
function injectChannel(i) {
|
||||
var _a;
|
||||
if ('items' in i) {
|
||||
i.items = (_a = i.items) === null || _a === void 0 ? void 0 : _a.map((item) => 'rid' in item ? item : injectChannel(item));
|
||||
}
|
||||
else if ('action' in i && i.action) {
|
||||
const handler = new Channel();
|
||||
handler.onmessage = i.action;
|
||||
delete i.action;
|
||||
return { ...i, handler };
|
||||
}
|
||||
return i;
|
||||
}
|
||||
async function newMenu(kind, opts) {
|
||||
const handler = new Channel();
|
||||
if (opts && typeof opts === 'object') {
|
||||
if ('action' in opts && opts.action) {
|
||||
handler.onmessage = opts.action;
|
||||
delete opts.action;
|
||||
}
|
||||
// about predefined menu item icon
|
||||
if ('item' in opts
|
||||
&& opts.item
|
||||
&& typeof opts.item === 'object'
|
||||
&& 'About' in opts.item
|
||||
&& opts.item.About
|
||||
&& typeof opts.item.About === 'object'
|
||||
&& 'icon' in opts.item.About
|
||||
&& opts.item.About.icon) {
|
||||
opts.item.About.icon = transformImage(opts.item.About.icon);
|
||||
}
|
||||
// icon menu item icon
|
||||
if ('icon' in opts && opts.icon) {
|
||||
opts.icon = transformImage(opts.icon);
|
||||
}
|
||||
// submenu items
|
||||
if ('items' in opts && opts.items) {
|
||||
function prepareItem(i) {
|
||||
var _a;
|
||||
if ('rid' in i) {
|
||||
return [i.rid, i.kind];
|
||||
}
|
||||
if ('item' in i && typeof i.item === 'object' && ((_a = i.item.About) === null || _a === void 0 ? void 0 : _a.icon)) {
|
||||
i.item.About.icon = transformImage(i.item.About.icon);
|
||||
}
|
||||
if ('icon' in i && i.icon) {
|
||||
i.icon = transformImage(i.icon);
|
||||
}
|
||||
if ('items' in i && i.items) {
|
||||
// @ts-expect-error the `prepareItem` return doesn't exactly match
|
||||
// this is fine, because the difference is in `[number, string]` variant
|
||||
i.items = i.items.map(prepareItem);
|
||||
}
|
||||
return injectChannel(i);
|
||||
}
|
||||
// @ts-expect-error the `prepareItem` return doesn't exactly match
|
||||
// this is fine, because the difference is in `[number, string]` variant
|
||||
opts.items = opts.items.map(prepareItem);
|
||||
}
|
||||
}
|
||||
return invoke('plugin:menu|new', {
|
||||
kind,
|
||||
options: opts,
|
||||
handler
|
||||
});
|
||||
}
|
||||
class MenuItemBase extends Resource {
|
||||
/** The id of this item. */
|
||||
get id() {
|
||||
return __classPrivateFieldGet(this, _MenuItemBase_id, "f");
|
||||
}
|
||||
/** @ignore */
|
||||
get kind() {
|
||||
return __classPrivateFieldGet(this, _MenuItemBase_kind, "f");
|
||||
}
|
||||
/** @ignore */
|
||||
constructor(rid, id, kind) {
|
||||
super(rid);
|
||||
/** @ignore */
|
||||
_MenuItemBase_id.set(this, void 0);
|
||||
/** @ignore */
|
||||
_MenuItemBase_kind.set(this, void 0);
|
||||
__classPrivateFieldSet(this, _MenuItemBase_id, id, "f");
|
||||
__classPrivateFieldSet(this, _MenuItemBase_kind, kind, "f");
|
||||
}
|
||||
}
|
||||
_MenuItemBase_id = new WeakMap(), _MenuItemBase_kind = new WeakMap();
|
||||
|
||||
export { MenuItemBase, newMenu };
|
68
node_modules/@tauri-apps/api/menu/checkMenuItem.cjs
generated
vendored
Normal file
68
node_modules/@tauri-apps/api/menu/checkMenuItem.cjs
generated
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
'use strict';
|
||||
|
||||
var base = require('./base.cjs');
|
||||
var core = require('../core.cjs');
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/**
|
||||
* A check menu item inside a {@linkcode Menu} or {@linkcode Submenu}
|
||||
* and usually contains a text and a check mark or a similar toggle
|
||||
* that corresponds to a checked and unchecked states.
|
||||
*/
|
||||
class CheckMenuItem extends base.MenuItemBase {
|
||||
/** @ignore */
|
||||
constructor(rid, id) {
|
||||
super(rid, id, 'Check');
|
||||
}
|
||||
/** Create a new check menu item. */
|
||||
static async new(opts) {
|
||||
return base.newMenu('Check', opts).then(([rid, id]) => new CheckMenuItem(rid, id));
|
||||
}
|
||||
/** Returns the text of this check menu item. */
|
||||
async text() {
|
||||
return core.invoke('plugin:menu|text', { rid: this.rid, kind: this.kind });
|
||||
}
|
||||
/** Sets the text for this check menu item. */
|
||||
async setText(text) {
|
||||
return core.invoke('plugin:menu|set_text', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
text
|
||||
});
|
||||
}
|
||||
/** Returns whether this check menu item is enabled or not. */
|
||||
async isEnabled() {
|
||||
return core.invoke('plugin:menu|is_enabled', { rid: this.rid, kind: this.kind });
|
||||
}
|
||||
/** Sets whether this check menu item is enabled or not. */
|
||||
async setEnabled(enabled) {
|
||||
return core.invoke('plugin:menu|set_enabled', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
enabled
|
||||
});
|
||||
}
|
||||
/** Sets the accelerator for this check menu item. */
|
||||
async setAccelerator(accelerator) {
|
||||
return core.invoke('plugin:menu|set_accelerator', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
accelerator
|
||||
});
|
||||
}
|
||||
/** Returns whether this check menu item is checked or not. */
|
||||
async isChecked() {
|
||||
return core.invoke('plugin:menu|is_checked', { rid: this.rid });
|
||||
}
|
||||
/** Sets whether this check menu item is checked or not. */
|
||||
async setChecked(checked) {
|
||||
return core.invoke('plugin:menu|set_checked', {
|
||||
rid: this.rid,
|
||||
checked
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
exports.CheckMenuItem = CheckMenuItem;
|
32
node_modules/@tauri-apps/api/menu/checkMenuItem.d.ts
generated
vendored
Normal file
32
node_modules/@tauri-apps/api/menu/checkMenuItem.d.ts
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
import { MenuItemBase } from './base';
|
||||
import { type MenuItemOptions } from '../menu';
|
||||
/** Options for creating a new check menu item. */
|
||||
export interface CheckMenuItemOptions extends MenuItemOptions {
|
||||
/** Whether the new check menu item is enabled or not. */
|
||||
checked?: boolean;
|
||||
}
|
||||
/**
|
||||
* A check menu item inside a {@linkcode Menu} or {@linkcode Submenu}
|
||||
* and usually contains a text and a check mark or a similar toggle
|
||||
* that corresponds to a checked and unchecked states.
|
||||
*/
|
||||
export declare class CheckMenuItem extends MenuItemBase {
|
||||
/** @ignore */
|
||||
protected constructor(rid: number, id: string);
|
||||
/** Create a new check menu item. */
|
||||
static new(opts: CheckMenuItemOptions): Promise<CheckMenuItem>;
|
||||
/** Returns the text of this check menu item. */
|
||||
text(): Promise<string>;
|
||||
/** Sets the text for this check menu item. */
|
||||
setText(text: string): Promise<void>;
|
||||
/** Returns whether this check menu item is enabled or not. */
|
||||
isEnabled(): Promise<boolean>;
|
||||
/** Sets whether this check menu item is enabled or not. */
|
||||
setEnabled(enabled: boolean): Promise<void>;
|
||||
/** Sets the accelerator for this check menu item. */
|
||||
setAccelerator(accelerator: string | null): Promise<void>;
|
||||
/** Returns whether this check menu item is checked or not. */
|
||||
isChecked(): Promise<boolean>;
|
||||
/** Sets whether this check menu item is checked or not. */
|
||||
setChecked(checked: boolean): Promise<void>;
|
||||
}
|
66
node_modules/@tauri-apps/api/menu/checkMenuItem.js
generated
vendored
Normal file
66
node_modules/@tauri-apps/api/menu/checkMenuItem.js
generated
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
import { MenuItemBase, newMenu } from './base.js';
|
||||
import { invoke } from '../core.js';
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/**
|
||||
* A check menu item inside a {@linkcode Menu} or {@linkcode Submenu}
|
||||
* and usually contains a text and a check mark or a similar toggle
|
||||
* that corresponds to a checked and unchecked states.
|
||||
*/
|
||||
class CheckMenuItem extends MenuItemBase {
|
||||
/** @ignore */
|
||||
constructor(rid, id) {
|
||||
super(rid, id, 'Check');
|
||||
}
|
||||
/** Create a new check menu item. */
|
||||
static async new(opts) {
|
||||
return newMenu('Check', opts).then(([rid, id]) => new CheckMenuItem(rid, id));
|
||||
}
|
||||
/** Returns the text of this check menu item. */
|
||||
async text() {
|
||||
return invoke('plugin:menu|text', { rid: this.rid, kind: this.kind });
|
||||
}
|
||||
/** Sets the text for this check menu item. */
|
||||
async setText(text) {
|
||||
return invoke('plugin:menu|set_text', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
text
|
||||
});
|
||||
}
|
||||
/** Returns whether this check menu item is enabled or not. */
|
||||
async isEnabled() {
|
||||
return invoke('plugin:menu|is_enabled', { rid: this.rid, kind: this.kind });
|
||||
}
|
||||
/** Sets whether this check menu item is enabled or not. */
|
||||
async setEnabled(enabled) {
|
||||
return invoke('plugin:menu|set_enabled', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
enabled
|
||||
});
|
||||
}
|
||||
/** Sets the accelerator for this check menu item. */
|
||||
async setAccelerator(accelerator) {
|
||||
return invoke('plugin:menu|set_accelerator', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
accelerator
|
||||
});
|
||||
}
|
||||
/** Returns whether this check menu item is checked or not. */
|
||||
async isChecked() {
|
||||
return invoke('plugin:menu|is_checked', { rid: this.rid });
|
||||
}
|
||||
/** Sets whether this check menu item is checked or not. */
|
||||
async setChecked(checked) {
|
||||
return invoke('plugin:menu|set_checked', {
|
||||
rid: this.rid,
|
||||
checked
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export { CheckMenuItem };
|
186
node_modules/@tauri-apps/api/menu/iconMenuItem.cjs
generated
vendored
Normal file
186
node_modules/@tauri-apps/api/menu/iconMenuItem.cjs
generated
vendored
Normal file
@ -0,0 +1,186 @@
|
||||
'use strict';
|
||||
|
||||
var base = require('./base.cjs');
|
||||
var core = require('../core.cjs');
|
||||
var image = require('../image.cjs');
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/**
|
||||
* A native Icon to be used for the menu item
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Windows / Linux**: Unsupported.
|
||||
*/
|
||||
exports.NativeIcon = void 0;
|
||||
(function (NativeIcon) {
|
||||
/** An add item template image. */
|
||||
NativeIcon["Add"] = "Add";
|
||||
/** Advanced preferences toolbar icon for the preferences window. */
|
||||
NativeIcon["Advanced"] = "Advanced";
|
||||
/** A Bluetooth template image. */
|
||||
NativeIcon["Bluetooth"] = "Bluetooth";
|
||||
/** Bookmarks image suitable for a template. */
|
||||
NativeIcon["Bookmarks"] = "Bookmarks";
|
||||
/** A caution image. */
|
||||
NativeIcon["Caution"] = "Caution";
|
||||
/** A color panel toolbar icon. */
|
||||
NativeIcon["ColorPanel"] = "ColorPanel";
|
||||
/** A column view mode template image. */
|
||||
NativeIcon["ColumnView"] = "ColumnView";
|
||||
/** A computer icon. */
|
||||
NativeIcon["Computer"] = "Computer";
|
||||
/** An enter full-screen mode template image. */
|
||||
NativeIcon["EnterFullScreen"] = "EnterFullScreen";
|
||||
/** Permissions for all users. */
|
||||
NativeIcon["Everyone"] = "Everyone";
|
||||
/** An exit full-screen mode template image. */
|
||||
NativeIcon["ExitFullScreen"] = "ExitFullScreen";
|
||||
/** A cover flow view mode template image. */
|
||||
NativeIcon["FlowView"] = "FlowView";
|
||||
/** A folder image. */
|
||||
NativeIcon["Folder"] = "Folder";
|
||||
/** A burnable folder icon. */
|
||||
NativeIcon["FolderBurnable"] = "FolderBurnable";
|
||||
/** A smart folder icon. */
|
||||
NativeIcon["FolderSmart"] = "FolderSmart";
|
||||
/** A link template image. */
|
||||
NativeIcon["FollowLinkFreestanding"] = "FollowLinkFreestanding";
|
||||
/** A font panel toolbar icon. */
|
||||
NativeIcon["FontPanel"] = "FontPanel";
|
||||
/** A `go back` template image. */
|
||||
NativeIcon["GoLeft"] = "GoLeft";
|
||||
/** A `go forward` template image. */
|
||||
NativeIcon["GoRight"] = "GoRight";
|
||||
/** Home image suitable for a template. */
|
||||
NativeIcon["Home"] = "Home";
|
||||
/** An iChat Theater template image. */
|
||||
NativeIcon["IChatTheater"] = "IChatTheater";
|
||||
/** An icon view mode template image. */
|
||||
NativeIcon["IconView"] = "IconView";
|
||||
/** An information toolbar icon. */
|
||||
NativeIcon["Info"] = "Info";
|
||||
/** A template image used to denote invalid data. */
|
||||
NativeIcon["InvalidDataFreestanding"] = "InvalidDataFreestanding";
|
||||
/** A generic left-facing triangle template image. */
|
||||
NativeIcon["LeftFacingTriangle"] = "LeftFacingTriangle";
|
||||
/** A list view mode template image. */
|
||||
NativeIcon["ListView"] = "ListView";
|
||||
/** A locked padlock template image. */
|
||||
NativeIcon["LockLocked"] = "LockLocked";
|
||||
/** An unlocked padlock template image. */
|
||||
NativeIcon["LockUnlocked"] = "LockUnlocked";
|
||||
/** A horizontal dash, for use in menus. */
|
||||
NativeIcon["MenuMixedState"] = "MenuMixedState";
|
||||
/** A check mark template image, for use in menus. */
|
||||
NativeIcon["MenuOnState"] = "MenuOnState";
|
||||
/** A MobileMe icon. */
|
||||
NativeIcon["MobileMe"] = "MobileMe";
|
||||
/** A drag image for multiple items. */
|
||||
NativeIcon["MultipleDocuments"] = "MultipleDocuments";
|
||||
/** A network icon. */
|
||||
NativeIcon["Network"] = "Network";
|
||||
/** A path button template image. */
|
||||
NativeIcon["Path"] = "Path";
|
||||
/** General preferences toolbar icon for the preferences window. */
|
||||
NativeIcon["PreferencesGeneral"] = "PreferencesGeneral";
|
||||
/** A Quick Look template image. */
|
||||
NativeIcon["QuickLook"] = "QuickLook";
|
||||
/** A refresh template image. */
|
||||
NativeIcon["RefreshFreestanding"] = "RefreshFreestanding";
|
||||
/** A refresh template image. */
|
||||
NativeIcon["Refresh"] = "Refresh";
|
||||
/** A remove item template image. */
|
||||
NativeIcon["Remove"] = "Remove";
|
||||
/** A reveal contents template image. */
|
||||
NativeIcon["RevealFreestanding"] = "RevealFreestanding";
|
||||
/** A generic right-facing triangle template image. */
|
||||
NativeIcon["RightFacingTriangle"] = "RightFacingTriangle";
|
||||
/** A share view template image. */
|
||||
NativeIcon["Share"] = "Share";
|
||||
/** A slideshow template image. */
|
||||
NativeIcon["Slideshow"] = "Slideshow";
|
||||
/** A badge for a `smart` item. */
|
||||
NativeIcon["SmartBadge"] = "SmartBadge";
|
||||
/** Small green indicator, similar to iChat's available image. */
|
||||
NativeIcon["StatusAvailable"] = "StatusAvailable";
|
||||
/** Small clear indicator. */
|
||||
NativeIcon["StatusNone"] = "StatusNone";
|
||||
/** Small yellow indicator, similar to iChat's idle image. */
|
||||
NativeIcon["StatusPartiallyAvailable"] = "StatusPartiallyAvailable";
|
||||
/** Small red indicator, similar to iChat's unavailable image. */
|
||||
NativeIcon["StatusUnavailable"] = "StatusUnavailable";
|
||||
/** A stop progress template image. */
|
||||
NativeIcon["StopProgressFreestanding"] = "StopProgressFreestanding";
|
||||
/** A stop progress button template image. */
|
||||
NativeIcon["StopProgress"] = "StopProgress";
|
||||
/** An image of the empty trash can. */
|
||||
NativeIcon["TrashEmpty"] = "TrashEmpty";
|
||||
/** An image of the full trash can. */
|
||||
NativeIcon["TrashFull"] = "TrashFull";
|
||||
/** Permissions for a single user. */
|
||||
NativeIcon["User"] = "User";
|
||||
/** User account toolbar icon for the preferences window. */
|
||||
NativeIcon["UserAccounts"] = "UserAccounts";
|
||||
/** Permissions for a group of users. */
|
||||
NativeIcon["UserGroup"] = "UserGroup";
|
||||
/** Permissions for guests. */
|
||||
NativeIcon["UserGuest"] = "UserGuest";
|
||||
})(exports.NativeIcon || (exports.NativeIcon = {}));
|
||||
/**
|
||||
* An icon menu item inside a {@linkcode Menu} or {@linkcode Submenu}
|
||||
* and usually contains an icon and a text.
|
||||
*/
|
||||
class IconMenuItem extends base.MenuItemBase {
|
||||
/** @ignore */
|
||||
constructor(rid, id) {
|
||||
super(rid, id, 'Icon');
|
||||
}
|
||||
/** Create a new icon menu item. */
|
||||
static async new(opts) {
|
||||
return base.newMenu('Icon', opts).then(([rid, id]) => new IconMenuItem(rid, id));
|
||||
}
|
||||
/** Returns the text of this icon menu item. */
|
||||
async text() {
|
||||
return core.invoke('plugin:menu|text', { rid: this.rid, kind: this.kind });
|
||||
}
|
||||
/** Sets the text for this icon menu item. */
|
||||
async setText(text) {
|
||||
return core.invoke('plugin:menu|set_text', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
text
|
||||
});
|
||||
}
|
||||
/** Returns whether this icon menu item is enabled or not. */
|
||||
async isEnabled() {
|
||||
return core.invoke('plugin:menu|is_enabled', { rid: this.rid, kind: this.kind });
|
||||
}
|
||||
/** Sets whether this icon menu item is enabled or not. */
|
||||
async setEnabled(enabled) {
|
||||
return core.invoke('plugin:menu|set_enabled', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
enabled
|
||||
});
|
||||
}
|
||||
/** Sets the accelerator for this icon menu item. */
|
||||
async setAccelerator(accelerator) {
|
||||
return core.invoke('plugin:menu|set_accelerator', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
accelerator
|
||||
});
|
||||
}
|
||||
/** Sets an icon for this icon menu item */
|
||||
async setIcon(icon) {
|
||||
return core.invoke('plugin:menu|set_icon', {
|
||||
rid: this.rid,
|
||||
icon: image.transformImage(icon)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
exports.IconMenuItem = IconMenuItem;
|
160
node_modules/@tauri-apps/api/menu/iconMenuItem.d.ts
generated
vendored
Normal file
160
node_modules/@tauri-apps/api/menu/iconMenuItem.d.ts
generated
vendored
Normal file
@ -0,0 +1,160 @@
|
||||
import { MenuItemBase } from './base';
|
||||
import { type MenuItemOptions } from '../menu';
|
||||
import { Image } from '../image';
|
||||
/**
|
||||
* A native Icon to be used for the menu item
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Windows / Linux**: Unsupported.
|
||||
*/
|
||||
export declare enum NativeIcon {
|
||||
/** An add item template image. */
|
||||
Add = "Add",
|
||||
/** Advanced preferences toolbar icon for the preferences window. */
|
||||
Advanced = "Advanced",
|
||||
/** A Bluetooth template image. */
|
||||
Bluetooth = "Bluetooth",
|
||||
/** Bookmarks image suitable for a template. */
|
||||
Bookmarks = "Bookmarks",
|
||||
/** A caution image. */
|
||||
Caution = "Caution",
|
||||
/** A color panel toolbar icon. */
|
||||
ColorPanel = "ColorPanel",
|
||||
/** A column view mode template image. */
|
||||
ColumnView = "ColumnView",
|
||||
/** A computer icon. */
|
||||
Computer = "Computer",
|
||||
/** An enter full-screen mode template image. */
|
||||
EnterFullScreen = "EnterFullScreen",
|
||||
/** Permissions for all users. */
|
||||
Everyone = "Everyone",
|
||||
/** An exit full-screen mode template image. */
|
||||
ExitFullScreen = "ExitFullScreen",
|
||||
/** A cover flow view mode template image. */
|
||||
FlowView = "FlowView",
|
||||
/** A folder image. */
|
||||
Folder = "Folder",
|
||||
/** A burnable folder icon. */
|
||||
FolderBurnable = "FolderBurnable",
|
||||
/** A smart folder icon. */
|
||||
FolderSmart = "FolderSmart",
|
||||
/** A link template image. */
|
||||
FollowLinkFreestanding = "FollowLinkFreestanding",
|
||||
/** A font panel toolbar icon. */
|
||||
FontPanel = "FontPanel",
|
||||
/** A `go back` template image. */
|
||||
GoLeft = "GoLeft",
|
||||
/** A `go forward` template image. */
|
||||
GoRight = "GoRight",
|
||||
/** Home image suitable for a template. */
|
||||
Home = "Home",
|
||||
/** An iChat Theater template image. */
|
||||
IChatTheater = "IChatTheater",
|
||||
/** An icon view mode template image. */
|
||||
IconView = "IconView",
|
||||
/** An information toolbar icon. */
|
||||
Info = "Info",
|
||||
/** A template image used to denote invalid data. */
|
||||
InvalidDataFreestanding = "InvalidDataFreestanding",
|
||||
/** A generic left-facing triangle template image. */
|
||||
LeftFacingTriangle = "LeftFacingTriangle",
|
||||
/** A list view mode template image. */
|
||||
ListView = "ListView",
|
||||
/** A locked padlock template image. */
|
||||
LockLocked = "LockLocked",
|
||||
/** An unlocked padlock template image. */
|
||||
LockUnlocked = "LockUnlocked",
|
||||
/** A horizontal dash, for use in menus. */
|
||||
MenuMixedState = "MenuMixedState",
|
||||
/** A check mark template image, for use in menus. */
|
||||
MenuOnState = "MenuOnState",
|
||||
/** A MobileMe icon. */
|
||||
MobileMe = "MobileMe",
|
||||
/** A drag image for multiple items. */
|
||||
MultipleDocuments = "MultipleDocuments",
|
||||
/** A network icon. */
|
||||
Network = "Network",
|
||||
/** A path button template image. */
|
||||
Path = "Path",
|
||||
/** General preferences toolbar icon for the preferences window. */
|
||||
PreferencesGeneral = "PreferencesGeneral",
|
||||
/** A Quick Look template image. */
|
||||
QuickLook = "QuickLook",
|
||||
/** A refresh template image. */
|
||||
RefreshFreestanding = "RefreshFreestanding",
|
||||
/** A refresh template image. */
|
||||
Refresh = "Refresh",
|
||||
/** A remove item template image. */
|
||||
Remove = "Remove",
|
||||
/** A reveal contents template image. */
|
||||
RevealFreestanding = "RevealFreestanding",
|
||||
/** A generic right-facing triangle template image. */
|
||||
RightFacingTriangle = "RightFacingTriangle",
|
||||
/** A share view template image. */
|
||||
Share = "Share",
|
||||
/** A slideshow template image. */
|
||||
Slideshow = "Slideshow",
|
||||
/** A badge for a `smart` item. */
|
||||
SmartBadge = "SmartBadge",
|
||||
/** Small green indicator, similar to iChat's available image. */
|
||||
StatusAvailable = "StatusAvailable",
|
||||
/** Small clear indicator. */
|
||||
StatusNone = "StatusNone",
|
||||
/** Small yellow indicator, similar to iChat's idle image. */
|
||||
StatusPartiallyAvailable = "StatusPartiallyAvailable",
|
||||
/** Small red indicator, similar to iChat's unavailable image. */
|
||||
StatusUnavailable = "StatusUnavailable",
|
||||
/** A stop progress template image. */
|
||||
StopProgressFreestanding = "StopProgressFreestanding",
|
||||
/** A stop progress button template image. */
|
||||
StopProgress = "StopProgress",
|
||||
/** An image of the empty trash can. */
|
||||
TrashEmpty = "TrashEmpty",
|
||||
/** An image of the full trash can. */
|
||||
TrashFull = "TrashFull",
|
||||
/** Permissions for a single user. */
|
||||
User = "User",
|
||||
/** User account toolbar icon for the preferences window. */
|
||||
UserAccounts = "UserAccounts",
|
||||
/** Permissions for a group of users. */
|
||||
UserGroup = "UserGroup",
|
||||
/** Permissions for guests. */
|
||||
UserGuest = "UserGuest"
|
||||
}
|
||||
/** Options for creating a new icon menu item. */
|
||||
export interface IconMenuItemOptions extends MenuItemOptions {
|
||||
/**
|
||||
* Icon to be used for the new icon menu item.
|
||||
*
|
||||
* Note that you may need the `image-ico` or `image-png` Cargo features to use this API.
|
||||
* To enable it, change your Cargo.toml file:
|
||||
* ```toml
|
||||
* [dependencies]
|
||||
* tauri = { version = "...", features = ["...", "image-png"] }
|
||||
* ```
|
||||
*/
|
||||
icon?: NativeIcon | string | Image | Uint8Array | ArrayBuffer | number[];
|
||||
}
|
||||
/**
|
||||
* An icon menu item inside a {@linkcode Menu} or {@linkcode Submenu}
|
||||
* and usually contains an icon and a text.
|
||||
*/
|
||||
export declare class IconMenuItem extends MenuItemBase {
|
||||
/** @ignore */
|
||||
protected constructor(rid: number, id: string);
|
||||
/** Create a new icon menu item. */
|
||||
static new(opts: IconMenuItemOptions): Promise<IconMenuItem>;
|
||||
/** Returns the text of this icon menu item. */
|
||||
text(): Promise<string>;
|
||||
/** Sets the text for this icon menu item. */
|
||||
setText(text: string): Promise<void>;
|
||||
/** Returns whether this icon menu item is enabled or not. */
|
||||
isEnabled(): Promise<boolean>;
|
||||
/** Sets whether this icon menu item is enabled or not. */
|
||||
setEnabled(enabled: boolean): Promise<void>;
|
||||
/** Sets the accelerator for this icon menu item. */
|
||||
setAccelerator(accelerator: string | null): Promise<void>;
|
||||
/** Sets an icon for this icon menu item */
|
||||
setIcon(icon: NativeIcon | string | Image | Uint8Array | ArrayBuffer | number[] | null): Promise<void>;
|
||||
}
|
184
node_modules/@tauri-apps/api/menu/iconMenuItem.js
generated
vendored
Normal file
184
node_modules/@tauri-apps/api/menu/iconMenuItem.js
generated
vendored
Normal file
@ -0,0 +1,184 @@
|
||||
import { MenuItemBase, newMenu } from './base.js';
|
||||
import { invoke } from '../core.js';
|
||||
import { transformImage } from '../image.js';
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/**
|
||||
* A native Icon to be used for the menu item
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Windows / Linux**: Unsupported.
|
||||
*/
|
||||
var NativeIcon;
|
||||
(function (NativeIcon) {
|
||||
/** An add item template image. */
|
||||
NativeIcon["Add"] = "Add";
|
||||
/** Advanced preferences toolbar icon for the preferences window. */
|
||||
NativeIcon["Advanced"] = "Advanced";
|
||||
/** A Bluetooth template image. */
|
||||
NativeIcon["Bluetooth"] = "Bluetooth";
|
||||
/** Bookmarks image suitable for a template. */
|
||||
NativeIcon["Bookmarks"] = "Bookmarks";
|
||||
/** A caution image. */
|
||||
NativeIcon["Caution"] = "Caution";
|
||||
/** A color panel toolbar icon. */
|
||||
NativeIcon["ColorPanel"] = "ColorPanel";
|
||||
/** A column view mode template image. */
|
||||
NativeIcon["ColumnView"] = "ColumnView";
|
||||
/** A computer icon. */
|
||||
NativeIcon["Computer"] = "Computer";
|
||||
/** An enter full-screen mode template image. */
|
||||
NativeIcon["EnterFullScreen"] = "EnterFullScreen";
|
||||
/** Permissions for all users. */
|
||||
NativeIcon["Everyone"] = "Everyone";
|
||||
/** An exit full-screen mode template image. */
|
||||
NativeIcon["ExitFullScreen"] = "ExitFullScreen";
|
||||
/** A cover flow view mode template image. */
|
||||
NativeIcon["FlowView"] = "FlowView";
|
||||
/** A folder image. */
|
||||
NativeIcon["Folder"] = "Folder";
|
||||
/** A burnable folder icon. */
|
||||
NativeIcon["FolderBurnable"] = "FolderBurnable";
|
||||
/** A smart folder icon. */
|
||||
NativeIcon["FolderSmart"] = "FolderSmart";
|
||||
/** A link template image. */
|
||||
NativeIcon["FollowLinkFreestanding"] = "FollowLinkFreestanding";
|
||||
/** A font panel toolbar icon. */
|
||||
NativeIcon["FontPanel"] = "FontPanel";
|
||||
/** A `go back` template image. */
|
||||
NativeIcon["GoLeft"] = "GoLeft";
|
||||
/** A `go forward` template image. */
|
||||
NativeIcon["GoRight"] = "GoRight";
|
||||
/** Home image suitable for a template. */
|
||||
NativeIcon["Home"] = "Home";
|
||||
/** An iChat Theater template image. */
|
||||
NativeIcon["IChatTheater"] = "IChatTheater";
|
||||
/** An icon view mode template image. */
|
||||
NativeIcon["IconView"] = "IconView";
|
||||
/** An information toolbar icon. */
|
||||
NativeIcon["Info"] = "Info";
|
||||
/** A template image used to denote invalid data. */
|
||||
NativeIcon["InvalidDataFreestanding"] = "InvalidDataFreestanding";
|
||||
/** A generic left-facing triangle template image. */
|
||||
NativeIcon["LeftFacingTriangle"] = "LeftFacingTriangle";
|
||||
/** A list view mode template image. */
|
||||
NativeIcon["ListView"] = "ListView";
|
||||
/** A locked padlock template image. */
|
||||
NativeIcon["LockLocked"] = "LockLocked";
|
||||
/** An unlocked padlock template image. */
|
||||
NativeIcon["LockUnlocked"] = "LockUnlocked";
|
||||
/** A horizontal dash, for use in menus. */
|
||||
NativeIcon["MenuMixedState"] = "MenuMixedState";
|
||||
/** A check mark template image, for use in menus. */
|
||||
NativeIcon["MenuOnState"] = "MenuOnState";
|
||||
/** A MobileMe icon. */
|
||||
NativeIcon["MobileMe"] = "MobileMe";
|
||||
/** A drag image for multiple items. */
|
||||
NativeIcon["MultipleDocuments"] = "MultipleDocuments";
|
||||
/** A network icon. */
|
||||
NativeIcon["Network"] = "Network";
|
||||
/** A path button template image. */
|
||||
NativeIcon["Path"] = "Path";
|
||||
/** General preferences toolbar icon for the preferences window. */
|
||||
NativeIcon["PreferencesGeneral"] = "PreferencesGeneral";
|
||||
/** A Quick Look template image. */
|
||||
NativeIcon["QuickLook"] = "QuickLook";
|
||||
/** A refresh template image. */
|
||||
NativeIcon["RefreshFreestanding"] = "RefreshFreestanding";
|
||||
/** A refresh template image. */
|
||||
NativeIcon["Refresh"] = "Refresh";
|
||||
/** A remove item template image. */
|
||||
NativeIcon["Remove"] = "Remove";
|
||||
/** A reveal contents template image. */
|
||||
NativeIcon["RevealFreestanding"] = "RevealFreestanding";
|
||||
/** A generic right-facing triangle template image. */
|
||||
NativeIcon["RightFacingTriangle"] = "RightFacingTriangle";
|
||||
/** A share view template image. */
|
||||
NativeIcon["Share"] = "Share";
|
||||
/** A slideshow template image. */
|
||||
NativeIcon["Slideshow"] = "Slideshow";
|
||||
/** A badge for a `smart` item. */
|
||||
NativeIcon["SmartBadge"] = "SmartBadge";
|
||||
/** Small green indicator, similar to iChat's available image. */
|
||||
NativeIcon["StatusAvailable"] = "StatusAvailable";
|
||||
/** Small clear indicator. */
|
||||
NativeIcon["StatusNone"] = "StatusNone";
|
||||
/** Small yellow indicator, similar to iChat's idle image. */
|
||||
NativeIcon["StatusPartiallyAvailable"] = "StatusPartiallyAvailable";
|
||||
/** Small red indicator, similar to iChat's unavailable image. */
|
||||
NativeIcon["StatusUnavailable"] = "StatusUnavailable";
|
||||
/** A stop progress template image. */
|
||||
NativeIcon["StopProgressFreestanding"] = "StopProgressFreestanding";
|
||||
/** A stop progress button template image. */
|
||||
NativeIcon["StopProgress"] = "StopProgress";
|
||||
/** An image of the empty trash can. */
|
||||
NativeIcon["TrashEmpty"] = "TrashEmpty";
|
||||
/** An image of the full trash can. */
|
||||
NativeIcon["TrashFull"] = "TrashFull";
|
||||
/** Permissions for a single user. */
|
||||
NativeIcon["User"] = "User";
|
||||
/** User account toolbar icon for the preferences window. */
|
||||
NativeIcon["UserAccounts"] = "UserAccounts";
|
||||
/** Permissions for a group of users. */
|
||||
NativeIcon["UserGroup"] = "UserGroup";
|
||||
/** Permissions for guests. */
|
||||
NativeIcon["UserGuest"] = "UserGuest";
|
||||
})(NativeIcon || (NativeIcon = {}));
|
||||
/**
|
||||
* An icon menu item inside a {@linkcode Menu} or {@linkcode Submenu}
|
||||
* and usually contains an icon and a text.
|
||||
*/
|
||||
class IconMenuItem extends MenuItemBase {
|
||||
/** @ignore */
|
||||
constructor(rid, id) {
|
||||
super(rid, id, 'Icon');
|
||||
}
|
||||
/** Create a new icon menu item. */
|
||||
static async new(opts) {
|
||||
return newMenu('Icon', opts).then(([rid, id]) => new IconMenuItem(rid, id));
|
||||
}
|
||||
/** Returns the text of this icon menu item. */
|
||||
async text() {
|
||||
return invoke('plugin:menu|text', { rid: this.rid, kind: this.kind });
|
||||
}
|
||||
/** Sets the text for this icon menu item. */
|
||||
async setText(text) {
|
||||
return invoke('plugin:menu|set_text', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
text
|
||||
});
|
||||
}
|
||||
/** Returns whether this icon menu item is enabled or not. */
|
||||
async isEnabled() {
|
||||
return invoke('plugin:menu|is_enabled', { rid: this.rid, kind: this.kind });
|
||||
}
|
||||
/** Sets whether this icon menu item is enabled or not. */
|
||||
async setEnabled(enabled) {
|
||||
return invoke('plugin:menu|set_enabled', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
enabled
|
||||
});
|
||||
}
|
||||
/** Sets the accelerator for this icon menu item. */
|
||||
async setAccelerator(accelerator) {
|
||||
return invoke('plugin:menu|set_accelerator', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
accelerator
|
||||
});
|
||||
}
|
||||
/** Sets an icon for this icon menu item */
|
||||
async setIcon(icon) {
|
||||
return invoke('plugin:menu|set_icon', {
|
||||
rid: this.rid,
|
||||
icon: transformImage(icon)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export { IconMenuItem, NativeIcon };
|
147
node_modules/@tauri-apps/api/menu/menu.cjs
generated
vendored
Normal file
147
node_modules/@tauri-apps/api/menu/menu.cjs
generated
vendored
Normal file
@ -0,0 +1,147 @@
|
||||
'use strict';
|
||||
|
||||
var submenu = require('./submenu.cjs');
|
||||
var dpi = require('../dpi.cjs');
|
||||
var core = require('../core.cjs');
|
||||
var base = require('./base.cjs');
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/** A type that is either a menu bar on the window
|
||||
* on Windows and Linux or as a global menu in the menubar on macOS.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS**: if using {@linkcode Menu} for the global menubar, it can only contain {@linkcode Submenu}s.
|
||||
*/
|
||||
class Menu extends base.MenuItemBase {
|
||||
/** @ignore */
|
||||
constructor(rid, id) {
|
||||
super(rid, id, 'Menu');
|
||||
}
|
||||
/** Create a new menu. */
|
||||
static async new(opts) {
|
||||
return base.newMenu('Menu', opts).then(([rid, id]) => new Menu(rid, id));
|
||||
}
|
||||
/** Create a default menu. */
|
||||
static async default() {
|
||||
return core.invoke('plugin:menu|create_default').then(([rid, id]) => new Menu(rid, id));
|
||||
}
|
||||
/**
|
||||
* Add a menu item to the end of this menu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Only {@linkcode Submenu}s can be added to a {@linkcode Menu}.
|
||||
*/
|
||||
async append(items) {
|
||||
return core.invoke('plugin:menu|append', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
items: (Array.isArray(items) ? items : [items]).map((i) => 'rid' in i ? [i.rid, i.kind] : i)
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Add a menu item to the beginning of this menu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Only {@linkcode Submenu}s can be added to a {@linkcode Menu}.
|
||||
*/
|
||||
async prepend(items) {
|
||||
return core.invoke('plugin:menu|prepend', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
items: (Array.isArray(items) ? items : [items]).map((i) => 'rid' in i ? [i.rid, i.kind] : i)
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Add a menu item to the specified position in this menu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Only {@linkcode Submenu}s can be added to a {@linkcode Menu}.
|
||||
*/
|
||||
async insert(items, position) {
|
||||
return core.invoke('plugin:menu|insert', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
items: (Array.isArray(items) ? items : [items]).map((i) => 'rid' in i ? [i.rid, i.kind] : i),
|
||||
position
|
||||
});
|
||||
}
|
||||
/** Remove a menu item from this menu. */
|
||||
async remove(item) {
|
||||
return core.invoke('plugin:menu|remove', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
item: [item.rid, item.kind]
|
||||
});
|
||||
}
|
||||
/** Remove a menu item from this menu at the specified position. */
|
||||
async removeAt(position) {
|
||||
return core.invoke('plugin:menu|remove_at', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
position
|
||||
}).then(submenu.itemFromKind);
|
||||
}
|
||||
/** Returns a list of menu items that has been added to this menu. */
|
||||
async items() {
|
||||
return core.invoke('plugin:menu|items', {
|
||||
rid: this.rid,
|
||||
kind: this.kind
|
||||
}).then((i) => i.map(submenu.itemFromKind));
|
||||
}
|
||||
/** Retrieves the menu item matching the given identifier. */
|
||||
async get(id) {
|
||||
return core.invoke('plugin:menu|get', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
id
|
||||
}).then((r) => (r ? submenu.itemFromKind(r) : null));
|
||||
}
|
||||
/**
|
||||
* Popup this menu as a context menu on the specified window.
|
||||
*
|
||||
* If the position, is provided, it is relative to the window's top-left corner.
|
||||
*/
|
||||
async popup(at, window) {
|
||||
var _a;
|
||||
return core.invoke('plugin:menu|popup', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
window: (_a = window === null || window === void 0 ? void 0 : window.label) !== null && _a !== void 0 ? _a : null,
|
||||
at: at instanceof dpi.Position ? at : at ? new dpi.Position(at) : null
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Sets the app-wide menu and returns the previous one.
|
||||
*
|
||||
* If a window was not created with an explicit menu or had one set explicitly,
|
||||
* this menu will be assigned to it.
|
||||
*/
|
||||
async setAsAppMenu() {
|
||||
return core.invoke('plugin:menu|set_as_app_menu', {
|
||||
rid: this.rid
|
||||
}).then((r) => (r ? new Menu(r[0], r[1]) : null));
|
||||
}
|
||||
/**
|
||||
* Sets the window menu and returns the previous one.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Unsupported. The menu on macOS is app-wide and not specific to one
|
||||
* window, if you need to set it, use {@linkcode Menu.setAsAppMenu} instead.
|
||||
*/
|
||||
async setAsWindowMenu(window) {
|
||||
var _a;
|
||||
return core.invoke('plugin:menu|set_as_window_menu', {
|
||||
rid: this.rid,
|
||||
window: (_a = window === null || window === void 0 ? void 0 : window.label) !== null && _a !== void 0 ? _a : null
|
||||
}).then((r) => (r ? new Menu(r[0], r[1]) : null));
|
||||
}
|
||||
}
|
||||
|
||||
exports.Menu = Menu;
|
85
node_modules/@tauri-apps/api/menu/menu.d.ts
generated
vendored
Normal file
85
node_modules/@tauri-apps/api/menu/menu.d.ts
generated
vendored
Normal file
@ -0,0 +1,85 @@
|
||||
import { MenuItemOptions, SubmenuOptions, IconMenuItemOptions, PredefinedMenuItemOptions, CheckMenuItemOptions } from '../menu';
|
||||
import { MenuItem } from './menuItem';
|
||||
import { CheckMenuItem } from './checkMenuItem';
|
||||
import { IconMenuItem } from './iconMenuItem';
|
||||
import { PredefinedMenuItem } from './predefinedMenuItem';
|
||||
import { Submenu } from './submenu';
|
||||
import { type LogicalPosition, PhysicalPosition, Position } from '../dpi';
|
||||
import { type Window } from '../window';
|
||||
import { MenuItemBase } from './base';
|
||||
/** Options for creating a new menu. */
|
||||
export interface MenuOptions {
|
||||
/** Specify an id to use for the new menu. */
|
||||
id?: string;
|
||||
/** List of items to add to the new menu. */
|
||||
items?: Array<Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | MenuItemOptions | SubmenuOptions | IconMenuItemOptions | PredefinedMenuItemOptions | CheckMenuItemOptions>;
|
||||
}
|
||||
/** A type that is either a menu bar on the window
|
||||
* on Windows and Linux or as a global menu in the menubar on macOS.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS**: if using {@linkcode Menu} for the global menubar, it can only contain {@linkcode Submenu}s.
|
||||
*/
|
||||
export declare class Menu extends MenuItemBase {
|
||||
/** @ignore */
|
||||
protected constructor(rid: number, id: string);
|
||||
/** Create a new menu. */
|
||||
static new(opts?: MenuOptions): Promise<Menu>;
|
||||
/** Create a default menu. */
|
||||
static default(): Promise<Menu>;
|
||||
/**
|
||||
* Add a menu item to the end of this menu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Only {@linkcode Submenu}s can be added to a {@linkcode Menu}.
|
||||
*/
|
||||
append<T extends Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | MenuItemOptions | SubmenuOptions | IconMenuItemOptions | PredefinedMenuItemOptions | CheckMenuItemOptions>(items: T | T[]): Promise<void>;
|
||||
/**
|
||||
* Add a menu item to the beginning of this menu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Only {@linkcode Submenu}s can be added to a {@linkcode Menu}.
|
||||
*/
|
||||
prepend<T extends Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | MenuItemOptions | SubmenuOptions | IconMenuItemOptions | PredefinedMenuItemOptions | CheckMenuItemOptions>(items: T | T[]): Promise<void>;
|
||||
/**
|
||||
* Add a menu item to the specified position in this menu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Only {@linkcode Submenu}s can be added to a {@linkcode Menu}.
|
||||
*/
|
||||
insert<T extends Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | MenuItemOptions | SubmenuOptions | IconMenuItemOptions | PredefinedMenuItemOptions | CheckMenuItemOptions>(items: T | T[], position: number): Promise<void>;
|
||||
/** Remove a menu item from this menu. */
|
||||
remove(item: Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem): Promise<void>;
|
||||
/** Remove a menu item from this menu at the specified position. */
|
||||
removeAt(position: number): Promise<Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | null>;
|
||||
/** Returns a list of menu items that has been added to this menu. */
|
||||
items(): Promise<Array<Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem>>;
|
||||
/** Retrieves the menu item matching the given identifier. */
|
||||
get(id: string): Promise<Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | null>;
|
||||
/**
|
||||
* Popup this menu as a context menu on the specified window.
|
||||
*
|
||||
* If the position, is provided, it is relative to the window's top-left corner.
|
||||
*/
|
||||
popup(at?: PhysicalPosition | LogicalPosition | Position, window?: Window): Promise<void>;
|
||||
/**
|
||||
* Sets the app-wide menu and returns the previous one.
|
||||
*
|
||||
* If a window was not created with an explicit menu or had one set explicitly,
|
||||
* this menu will be assigned to it.
|
||||
*/
|
||||
setAsAppMenu(): Promise<Menu | null>;
|
||||
/**
|
||||
* Sets the window menu and returns the previous one.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Unsupported. The menu on macOS is app-wide and not specific to one
|
||||
* window, if you need to set it, use {@linkcode Menu.setAsAppMenu} instead.
|
||||
*/
|
||||
setAsWindowMenu(window?: Window): Promise<Menu | null>;
|
||||
}
|
145
node_modules/@tauri-apps/api/menu/menu.js
generated
vendored
Normal file
145
node_modules/@tauri-apps/api/menu/menu.js
generated
vendored
Normal file
@ -0,0 +1,145 @@
|
||||
import { itemFromKind } from './submenu.js';
|
||||
import { Position } from '../dpi.js';
|
||||
import { invoke } from '../core.js';
|
||||
import { MenuItemBase, newMenu } from './base.js';
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/** A type that is either a menu bar on the window
|
||||
* on Windows and Linux or as a global menu in the menubar on macOS.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS**: if using {@linkcode Menu} for the global menubar, it can only contain {@linkcode Submenu}s.
|
||||
*/
|
||||
class Menu extends MenuItemBase {
|
||||
/** @ignore */
|
||||
constructor(rid, id) {
|
||||
super(rid, id, 'Menu');
|
||||
}
|
||||
/** Create a new menu. */
|
||||
static async new(opts) {
|
||||
return newMenu('Menu', opts).then(([rid, id]) => new Menu(rid, id));
|
||||
}
|
||||
/** Create a default menu. */
|
||||
static async default() {
|
||||
return invoke('plugin:menu|create_default').then(([rid, id]) => new Menu(rid, id));
|
||||
}
|
||||
/**
|
||||
* Add a menu item to the end of this menu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Only {@linkcode Submenu}s can be added to a {@linkcode Menu}.
|
||||
*/
|
||||
async append(items) {
|
||||
return invoke('plugin:menu|append', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
items: (Array.isArray(items) ? items : [items]).map((i) => 'rid' in i ? [i.rid, i.kind] : i)
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Add a menu item to the beginning of this menu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Only {@linkcode Submenu}s can be added to a {@linkcode Menu}.
|
||||
*/
|
||||
async prepend(items) {
|
||||
return invoke('plugin:menu|prepend', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
items: (Array.isArray(items) ? items : [items]).map((i) => 'rid' in i ? [i.rid, i.kind] : i)
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Add a menu item to the specified position in this menu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Only {@linkcode Submenu}s can be added to a {@linkcode Menu}.
|
||||
*/
|
||||
async insert(items, position) {
|
||||
return invoke('plugin:menu|insert', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
items: (Array.isArray(items) ? items : [items]).map((i) => 'rid' in i ? [i.rid, i.kind] : i),
|
||||
position
|
||||
});
|
||||
}
|
||||
/** Remove a menu item from this menu. */
|
||||
async remove(item) {
|
||||
return invoke('plugin:menu|remove', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
item: [item.rid, item.kind]
|
||||
});
|
||||
}
|
||||
/** Remove a menu item from this menu at the specified position. */
|
||||
async removeAt(position) {
|
||||
return invoke('plugin:menu|remove_at', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
position
|
||||
}).then(itemFromKind);
|
||||
}
|
||||
/** Returns a list of menu items that has been added to this menu. */
|
||||
async items() {
|
||||
return invoke('plugin:menu|items', {
|
||||
rid: this.rid,
|
||||
kind: this.kind
|
||||
}).then((i) => i.map(itemFromKind));
|
||||
}
|
||||
/** Retrieves the menu item matching the given identifier. */
|
||||
async get(id) {
|
||||
return invoke('plugin:menu|get', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
id
|
||||
}).then((r) => (r ? itemFromKind(r) : null));
|
||||
}
|
||||
/**
|
||||
* Popup this menu as a context menu on the specified window.
|
||||
*
|
||||
* If the position, is provided, it is relative to the window's top-left corner.
|
||||
*/
|
||||
async popup(at, window) {
|
||||
var _a;
|
||||
return invoke('plugin:menu|popup', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
window: (_a = window === null || window === void 0 ? void 0 : window.label) !== null && _a !== void 0 ? _a : null,
|
||||
at: at instanceof Position ? at : at ? new Position(at) : null
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Sets the app-wide menu and returns the previous one.
|
||||
*
|
||||
* If a window was not created with an explicit menu or had one set explicitly,
|
||||
* this menu will be assigned to it.
|
||||
*/
|
||||
async setAsAppMenu() {
|
||||
return invoke('plugin:menu|set_as_app_menu', {
|
||||
rid: this.rid
|
||||
}).then((r) => (r ? new Menu(r[0], r[1]) : null));
|
||||
}
|
||||
/**
|
||||
* Sets the window menu and returns the previous one.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Unsupported. The menu on macOS is app-wide and not specific to one
|
||||
* window, if you need to set it, use {@linkcode Menu.setAsAppMenu} instead.
|
||||
*/
|
||||
async setAsWindowMenu(window) {
|
||||
var _a;
|
||||
return invoke('plugin:menu|set_as_window_menu', {
|
||||
rid: this.rid,
|
||||
window: (_a = window === null || window === void 0 ? void 0 : window.label) !== null && _a !== void 0 ? _a : null
|
||||
}).then((r) => (r ? new Menu(r[0], r[1]) : null));
|
||||
}
|
||||
}
|
||||
|
||||
export { Menu };
|
53
node_modules/@tauri-apps/api/menu/menuItem.cjs
generated
vendored
Normal file
53
node_modules/@tauri-apps/api/menu/menuItem.cjs
generated
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
'use strict';
|
||||
|
||||
var base = require('./base.cjs');
|
||||
var core = require('../core.cjs');
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/** A menu item inside a {@linkcode Menu} or {@linkcode Submenu} and contains only text. */
|
||||
class MenuItem extends base.MenuItemBase {
|
||||
/** @ignore */
|
||||
constructor(rid, id) {
|
||||
super(rid, id, 'MenuItem');
|
||||
}
|
||||
/** Create a new menu item. */
|
||||
static async new(opts) {
|
||||
return base.newMenu('MenuItem', opts).then(([rid, id]) => new MenuItem(rid, id));
|
||||
}
|
||||
/** Returns the text of this menu item. */
|
||||
async text() {
|
||||
return core.invoke('plugin:menu|text', { rid: this.rid, kind: this.kind });
|
||||
}
|
||||
/** Sets the text for this menu item. */
|
||||
async setText(text) {
|
||||
return core.invoke('plugin:menu|set_text', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
text
|
||||
});
|
||||
}
|
||||
/** Returns whether this menu item is enabled or not. */
|
||||
async isEnabled() {
|
||||
return core.invoke('plugin:menu|is_enabled', { rid: this.rid, kind: this.kind });
|
||||
}
|
||||
/** Sets whether this menu item is enabled or not. */
|
||||
async setEnabled(enabled) {
|
||||
return core.invoke('plugin:menu|set_enabled', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
enabled
|
||||
});
|
||||
}
|
||||
/** Sets the accelerator for this menu item. */
|
||||
async setAccelerator(accelerator) {
|
||||
return core.invoke('plugin:menu|set_accelerator', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
accelerator
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
exports.MenuItem = MenuItem;
|
31
node_modules/@tauri-apps/api/menu/menuItem.d.ts
generated
vendored
Normal file
31
node_modules/@tauri-apps/api/menu/menuItem.d.ts
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
import { MenuItemBase } from './base';
|
||||
/** Options for creating a new menu item. */
|
||||
export interface MenuItemOptions {
|
||||
/** Specify an id to use for the new menu item. */
|
||||
id?: string;
|
||||
/** The text of the new menu item. */
|
||||
text: string;
|
||||
/** Whether the new menu item is enabled or not. */
|
||||
enabled?: boolean;
|
||||
/** Specify an accelerator for the new menu item. */
|
||||
accelerator?: string;
|
||||
/** Specify a handler to be called when this menu item is activated. */
|
||||
action?: (id: string) => void;
|
||||
}
|
||||
/** A menu item inside a {@linkcode Menu} or {@linkcode Submenu} and contains only text. */
|
||||
export declare class MenuItem extends MenuItemBase {
|
||||
/** @ignore */
|
||||
protected constructor(rid: number, id: string);
|
||||
/** Create a new menu item. */
|
||||
static new(opts: MenuItemOptions): Promise<MenuItem>;
|
||||
/** Returns the text of this menu item. */
|
||||
text(): Promise<string>;
|
||||
/** Sets the text for this menu item. */
|
||||
setText(text: string): Promise<void>;
|
||||
/** Returns whether this menu item is enabled or not. */
|
||||
isEnabled(): Promise<boolean>;
|
||||
/** Sets whether this menu item is enabled or not. */
|
||||
setEnabled(enabled: boolean): Promise<void>;
|
||||
/** Sets the accelerator for this menu item. */
|
||||
setAccelerator(accelerator: string | null): Promise<void>;
|
||||
}
|
51
node_modules/@tauri-apps/api/menu/menuItem.js
generated
vendored
Normal file
51
node_modules/@tauri-apps/api/menu/menuItem.js
generated
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
import { MenuItemBase, newMenu } from './base.js';
|
||||
import { invoke } from '../core.js';
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/** A menu item inside a {@linkcode Menu} or {@linkcode Submenu} and contains only text. */
|
||||
class MenuItem extends MenuItemBase {
|
||||
/** @ignore */
|
||||
constructor(rid, id) {
|
||||
super(rid, id, 'MenuItem');
|
||||
}
|
||||
/** Create a new menu item. */
|
||||
static async new(opts) {
|
||||
return newMenu('MenuItem', opts).then(([rid, id]) => new MenuItem(rid, id));
|
||||
}
|
||||
/** Returns the text of this menu item. */
|
||||
async text() {
|
||||
return invoke('plugin:menu|text', { rid: this.rid, kind: this.kind });
|
||||
}
|
||||
/** Sets the text for this menu item. */
|
||||
async setText(text) {
|
||||
return invoke('plugin:menu|set_text', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
text
|
||||
});
|
||||
}
|
||||
/** Returns whether this menu item is enabled or not. */
|
||||
async isEnabled() {
|
||||
return invoke('plugin:menu|is_enabled', { rid: this.rid, kind: this.kind });
|
||||
}
|
||||
/** Sets whether this menu item is enabled or not. */
|
||||
async setEnabled(enabled) {
|
||||
return invoke('plugin:menu|set_enabled', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
enabled
|
||||
});
|
||||
}
|
||||
/** Sets the accelerator for this menu item. */
|
||||
async setAccelerator(accelerator) {
|
||||
return invoke('plugin:menu|set_accelerator', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
accelerator
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export { MenuItem };
|
33
node_modules/@tauri-apps/api/menu/predefinedMenuItem.cjs
generated
vendored
Normal file
33
node_modules/@tauri-apps/api/menu/predefinedMenuItem.cjs
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
'use strict';
|
||||
|
||||
var base = require('./base.cjs');
|
||||
var core = require('../core.cjs');
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/** A predefined (native) menu item which has a predefined behavior by the OS or by tauri. */
|
||||
class PredefinedMenuItem extends base.MenuItemBase {
|
||||
/** @ignore */
|
||||
constructor(rid, id) {
|
||||
super(rid, id, 'Predefined');
|
||||
}
|
||||
/** Create a new predefined menu item. */
|
||||
static async new(opts) {
|
||||
return base.newMenu('Predefined', opts).then(([rid, id]) => new PredefinedMenuItem(rid, id));
|
||||
}
|
||||
/** Returns the text of this predefined menu item. */
|
||||
async text() {
|
||||
return core.invoke('plugin:menu|text', { rid: this.rid, kind: this.kind });
|
||||
}
|
||||
/** Sets the text for this predefined menu item. */
|
||||
async setText(text) {
|
||||
return core.invoke('plugin:menu|set_text', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
text
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
exports.PredefinedMenuItem = PredefinedMenuItem;
|
95
node_modules/@tauri-apps/api/menu/predefinedMenuItem.d.ts
generated
vendored
Normal file
95
node_modules/@tauri-apps/api/menu/predefinedMenuItem.d.ts
generated
vendored
Normal file
@ -0,0 +1,95 @@
|
||||
import { MenuItemBase } from './base';
|
||||
import { Image } from '../image';
|
||||
/** A metadata for the about predefined menu item. */
|
||||
export interface AboutMetadata {
|
||||
/** Sets the application name. */
|
||||
name?: string;
|
||||
/** The application version. */
|
||||
version?: string;
|
||||
/**
|
||||
* The short version, e.g. "1.0".
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Windows / Linux:** Appended to the end of `version` in parentheses.
|
||||
*/
|
||||
shortVersion?: string;
|
||||
/**
|
||||
* The authors of the application.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **macOS:** Unsupported.
|
||||
*/
|
||||
authors?: string[];
|
||||
/**
|
||||
* Application comments.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **macOS:** Unsupported.
|
||||
*/
|
||||
comments?: string;
|
||||
/** The copyright of the application. */
|
||||
copyright?: string;
|
||||
/**
|
||||
* The license of the application.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **macOS:** Unsupported.
|
||||
*/
|
||||
license?: string;
|
||||
/**
|
||||
* The application website.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **macOS:** Unsupported.
|
||||
*/
|
||||
website?: string;
|
||||
/**
|
||||
* The website label.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **macOS:** Unsupported.
|
||||
*/
|
||||
websiteLabel?: string;
|
||||
/**
|
||||
* The credits.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Windows / Linux:** Unsupported.
|
||||
*/
|
||||
credits?: string;
|
||||
/**
|
||||
* The application icon.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Windows:** Unsupported.
|
||||
*/
|
||||
icon?: string | Uint8Array | ArrayBuffer | number[] | Image;
|
||||
}
|
||||
/** Options for creating a new predefined menu item. */
|
||||
export interface PredefinedMenuItemOptions {
|
||||
/** The text of the new predefined menu item. */
|
||||
text?: string;
|
||||
/** The predefined item type */
|
||||
item: 'Separator' | 'Copy' | 'Cut' | 'Paste' | 'SelectAll' | 'Undo' | 'Redo' | 'Minimize' | 'Maximize' | 'Fullscreen' | 'Hide' | 'HideOthers' | 'ShowAll' | 'CloseWindow' | 'Quit' | 'Services' | {
|
||||
About: AboutMetadata | null;
|
||||
};
|
||||
}
|
||||
/** A predefined (native) menu item which has a predefined behavior by the OS or by tauri. */
|
||||
export declare class PredefinedMenuItem extends MenuItemBase {
|
||||
/** @ignore */
|
||||
protected constructor(rid: number, id: string);
|
||||
/** Create a new predefined menu item. */
|
||||
static new(opts?: PredefinedMenuItemOptions): Promise<PredefinedMenuItem>;
|
||||
/** Returns the text of this predefined menu item. */
|
||||
text(): Promise<string>;
|
||||
/** Sets the text for this predefined menu item. */
|
||||
setText(text: string): Promise<void>;
|
||||
}
|
31
node_modules/@tauri-apps/api/menu/predefinedMenuItem.js
generated
vendored
Normal file
31
node_modules/@tauri-apps/api/menu/predefinedMenuItem.js
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
import { MenuItemBase, newMenu } from './base.js';
|
||||
import { invoke } from '../core.js';
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/** A predefined (native) menu item which has a predefined behavior by the OS or by tauri. */
|
||||
class PredefinedMenuItem extends MenuItemBase {
|
||||
/** @ignore */
|
||||
constructor(rid, id) {
|
||||
super(rid, id, 'Predefined');
|
||||
}
|
||||
/** Create a new predefined menu item. */
|
||||
static async new(opts) {
|
||||
return newMenu('Predefined', opts).then(([rid, id]) => new PredefinedMenuItem(rid, id));
|
||||
}
|
||||
/** Returns the text of this predefined menu item. */
|
||||
async text() {
|
||||
return invoke('plugin:menu|text', { rid: this.rid, kind: this.kind });
|
||||
}
|
||||
/** Sets the text for this predefined menu item. */
|
||||
async setText(text) {
|
||||
return invoke('plugin:menu|set_text', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
text
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export { PredefinedMenuItem };
|
194
node_modules/@tauri-apps/api/menu/submenu.cjs
generated
vendored
Normal file
194
node_modules/@tauri-apps/api/menu/submenu.cjs
generated
vendored
Normal file
@ -0,0 +1,194 @@
|
||||
'use strict';
|
||||
|
||||
var menuItem = require('./menuItem.cjs');
|
||||
var checkMenuItem = require('./checkMenuItem.cjs');
|
||||
var iconMenuItem = require('./iconMenuItem.cjs');
|
||||
var predefinedMenuItem = require('./predefinedMenuItem.cjs');
|
||||
var core = require('../core.cjs');
|
||||
var base = require('./base.cjs');
|
||||
var dpi = require('../dpi.cjs');
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/** @ignore */
|
||||
function itemFromKind([rid, id, kind]) {
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
||||
switch (kind) {
|
||||
case 'Submenu':
|
||||
// @ts-expect-error constructor is protected for external usage only, safe for us to use
|
||||
return new Submenu(rid, id);
|
||||
case 'Predefined':
|
||||
// @ts-expect-error constructor is protected for external usage only, safe for us to use
|
||||
return new predefinedMenuItem.PredefinedMenuItem(rid, id);
|
||||
case 'Check':
|
||||
// @ts-expect-error constructor is protected for external usage only, safe for us to use
|
||||
return new checkMenuItem.CheckMenuItem(rid, id);
|
||||
case 'Icon':
|
||||
// @ts-expect-error constructor is protected for external usage only, safe for us to use
|
||||
return new iconMenuItem.IconMenuItem(rid, id);
|
||||
case 'MenuItem':
|
||||
default:
|
||||
// @ts-expect-error constructor is protected for external usage only, safe for us to use
|
||||
return new menuItem.MenuItem(rid, id);
|
||||
}
|
||||
/* eslint-enable @typescript-eslint/no-unsafe-return */
|
||||
}
|
||||
/** A type that is a submenu inside a {@linkcode Menu} or {@linkcode Submenu}. */
|
||||
class Submenu extends base.MenuItemBase {
|
||||
/** @ignore */
|
||||
constructor(rid, id) {
|
||||
super(rid, id, 'Submenu');
|
||||
}
|
||||
/** Create a new submenu. */
|
||||
static async new(opts) {
|
||||
return base.newMenu('Submenu', opts).then(([rid, id]) => new Submenu(rid, id));
|
||||
}
|
||||
/** Returns the text of this submenu. */
|
||||
async text() {
|
||||
return core.invoke('plugin:menu|text', { rid: this.rid, kind: this.kind });
|
||||
}
|
||||
/** Sets the text for this submenu. */
|
||||
async setText(text) {
|
||||
return core.invoke('plugin:menu|set_text', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
text
|
||||
});
|
||||
}
|
||||
/** Returns whether this submenu is enabled or not. */
|
||||
async isEnabled() {
|
||||
return core.invoke('plugin:menu|is_enabled', { rid: this.rid, kind: this.kind });
|
||||
}
|
||||
/** Sets whether this submenu is enabled or not. */
|
||||
async setEnabled(enabled) {
|
||||
return core.invoke('plugin:menu|set_enabled', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
enabled
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Add a menu item to the end of this submenu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Only {@linkcode Submenu}s can be added to a {@linkcode Menu}.
|
||||
*/
|
||||
async append(items) {
|
||||
return core.invoke('plugin:menu|append', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
items: (Array.isArray(items) ? items : [items]).map((i) => 'rid' in i ? [i.rid, i.kind] : i)
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Add a menu item to the beginning of this submenu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Only {@linkcode Submenu}s can be added to a {@linkcode Menu}.
|
||||
*/
|
||||
async prepend(items) {
|
||||
return core.invoke('plugin:menu|prepend', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
items: (Array.isArray(items) ? items : [items]).map((i) => 'rid' in i ? [i.rid, i.kind] : i)
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Add a menu item to the specified position in this submenu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Only {@linkcode Submenu}s can be added to a {@linkcode Menu}.
|
||||
*/
|
||||
async insert(items, position) {
|
||||
return core.invoke('plugin:menu|insert', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
items: (Array.isArray(items) ? items : [items]).map((i) => 'rid' in i ? [i.rid, i.kind] : i),
|
||||
position
|
||||
});
|
||||
}
|
||||
/** Remove a menu item from this submenu. */
|
||||
async remove(item) {
|
||||
return core.invoke('plugin:menu|remove', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
item: [item.rid, item.kind]
|
||||
});
|
||||
}
|
||||
/** Remove a menu item from this submenu at the specified position. */
|
||||
async removeAt(position) {
|
||||
return core.invoke('plugin:menu|remove_at', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
position
|
||||
}).then(itemFromKind);
|
||||
}
|
||||
/** Returns a list of menu items that has been added to this submenu. */
|
||||
async items() {
|
||||
return core.invoke('plugin:menu|items', {
|
||||
rid: this.rid,
|
||||
kind: this.kind
|
||||
}).then((i) => i.map(itemFromKind));
|
||||
}
|
||||
/** Retrieves the menu item matching the given identifier. */
|
||||
async get(id) {
|
||||
return core.invoke('plugin:menu|get', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
id
|
||||
}).then((r) => (r ? itemFromKind(r) : null));
|
||||
}
|
||||
/**
|
||||
* Popup this submenu as a context menu on the specified window.
|
||||
*
|
||||
* If the position, is provided, it is relative to the window's top-left corner.
|
||||
*/
|
||||
async popup(at, window) {
|
||||
var _a;
|
||||
return core.invoke('plugin:menu|popup', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
window: (_a = window === null || window === void 0 ? void 0 : window.label) !== null && _a !== void 0 ? _a : null,
|
||||
at: at instanceof dpi.Position ? at : at ? new dpi.Position(at) : null
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Set this submenu as the Window menu for the application on macOS.
|
||||
*
|
||||
* This will cause macOS to automatically add window-switching items and
|
||||
* certain other items to the menu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Windows / Linux**: Unsupported.
|
||||
*/
|
||||
async setAsWindowsMenuForNSApp() {
|
||||
return core.invoke('plugin:menu|set_as_windows_menu_for_nsapp', {
|
||||
rid: this.rid
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Set this submenu as the Help menu for the application on macOS.
|
||||
*
|
||||
* This will cause macOS to automatically add a search box to the menu.
|
||||
*
|
||||
* If no menu is set as the Help menu, macOS will automatically use any menu
|
||||
* which has a title matching the localized word "Help".
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Windows / Linux**: Unsupported.
|
||||
*/
|
||||
async setAsHelpMenuForNSApp() {
|
||||
return core.invoke('plugin:menu|set_as_help_menu_for_nsapp', {
|
||||
rid: this.rid
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
exports.Submenu = Submenu;
|
||||
exports.itemFromKind = itemFromKind;
|
88
node_modules/@tauri-apps/api/menu/submenu.d.ts
generated
vendored
Normal file
88
node_modules/@tauri-apps/api/menu/submenu.d.ts
generated
vendored
Normal file
@ -0,0 +1,88 @@
|
||||
import { IconMenuItemOptions, PredefinedMenuItemOptions, CheckMenuItemOptions } from '../menu';
|
||||
import { MenuItem, type MenuItemOptions } from './menuItem';
|
||||
import { CheckMenuItem } from './checkMenuItem';
|
||||
import { IconMenuItem } from './iconMenuItem';
|
||||
import { PredefinedMenuItem } from './predefinedMenuItem';
|
||||
import { type LogicalPosition, PhysicalPosition, type Window } from '../window';
|
||||
import { type ItemKind, MenuItemBase } from './base';
|
||||
import { type MenuOptions } from './menu';
|
||||
/** @ignore */
|
||||
export declare function itemFromKind([rid, id, kind]: [number, string, ItemKind]): Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem;
|
||||
export type SubmenuOptions = Omit<MenuItemOptions, 'accelerator' | 'action'> & MenuOptions;
|
||||
/** A type that is a submenu inside a {@linkcode Menu} or {@linkcode Submenu}. */
|
||||
export declare class Submenu extends MenuItemBase {
|
||||
/** @ignore */
|
||||
protected constructor(rid: number, id: string);
|
||||
/** Create a new submenu. */
|
||||
static new(opts: SubmenuOptions): Promise<Submenu>;
|
||||
/** Returns the text of this submenu. */
|
||||
text(): Promise<string>;
|
||||
/** Sets the text for this submenu. */
|
||||
setText(text: string): Promise<void>;
|
||||
/** Returns whether this submenu is enabled or not. */
|
||||
isEnabled(): Promise<boolean>;
|
||||
/** Sets whether this submenu is enabled or not. */
|
||||
setEnabled(enabled: boolean): Promise<void>;
|
||||
/**
|
||||
* Add a menu item to the end of this submenu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Only {@linkcode Submenu}s can be added to a {@linkcode Menu}.
|
||||
*/
|
||||
append<T extends Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | MenuItemOptions | SubmenuOptions | IconMenuItemOptions | PredefinedMenuItemOptions | CheckMenuItemOptions>(items: T | T[]): Promise<void>;
|
||||
/**
|
||||
* Add a menu item to the beginning of this submenu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Only {@linkcode Submenu}s can be added to a {@linkcode Menu}.
|
||||
*/
|
||||
prepend<T extends Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | MenuItemOptions | SubmenuOptions | IconMenuItemOptions | PredefinedMenuItemOptions | CheckMenuItemOptions>(items: T | T[]): Promise<void>;
|
||||
/**
|
||||
* Add a menu item to the specified position in this submenu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Only {@linkcode Submenu}s can be added to a {@linkcode Menu}.
|
||||
*/
|
||||
insert<T extends Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | MenuItemOptions | SubmenuOptions | IconMenuItemOptions | PredefinedMenuItemOptions | CheckMenuItemOptions>(items: T | T[], position: number): Promise<void>;
|
||||
/** Remove a menu item from this submenu. */
|
||||
remove(item: Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem): Promise<void>;
|
||||
/** Remove a menu item from this submenu at the specified position. */
|
||||
removeAt(position: number): Promise<Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | null>;
|
||||
/** Returns a list of menu items that has been added to this submenu. */
|
||||
items(): Promise<Array<Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem>>;
|
||||
/** Retrieves the menu item matching the given identifier. */
|
||||
get(id: string): Promise<Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | null>;
|
||||
/**
|
||||
* Popup this submenu as a context menu on the specified window.
|
||||
*
|
||||
* If the position, is provided, it is relative to the window's top-left corner.
|
||||
*/
|
||||
popup(at?: PhysicalPosition | LogicalPosition, window?: Window): Promise<void>;
|
||||
/**
|
||||
* Set this submenu as the Window menu for the application on macOS.
|
||||
*
|
||||
* This will cause macOS to automatically add window-switching items and
|
||||
* certain other items to the menu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Windows / Linux**: Unsupported.
|
||||
*/
|
||||
setAsWindowsMenuForNSApp(): Promise<void>;
|
||||
/**
|
||||
* Set this submenu as the Help menu for the application on macOS.
|
||||
*
|
||||
* This will cause macOS to automatically add a search box to the menu.
|
||||
*
|
||||
* If no menu is set as the Help menu, macOS will automatically use any menu
|
||||
* which has a title matching the localized word "Help".
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Windows / Linux**: Unsupported.
|
||||
*/
|
||||
setAsHelpMenuForNSApp(): Promise<void>;
|
||||
}
|
191
node_modules/@tauri-apps/api/menu/submenu.js
generated
vendored
Normal file
191
node_modules/@tauri-apps/api/menu/submenu.js
generated
vendored
Normal file
@ -0,0 +1,191 @@
|
||||
import { MenuItem } from './menuItem.js';
|
||||
import { CheckMenuItem } from './checkMenuItem.js';
|
||||
import { IconMenuItem } from './iconMenuItem.js';
|
||||
import { PredefinedMenuItem } from './predefinedMenuItem.js';
|
||||
import { invoke } from '../core.js';
|
||||
import { MenuItemBase, newMenu } from './base.js';
|
||||
import { Position } from '../dpi.js';
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/** @ignore */
|
||||
function itemFromKind([rid, id, kind]) {
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
||||
switch (kind) {
|
||||
case 'Submenu':
|
||||
// @ts-expect-error constructor is protected for external usage only, safe for us to use
|
||||
return new Submenu(rid, id);
|
||||
case 'Predefined':
|
||||
// @ts-expect-error constructor is protected for external usage only, safe for us to use
|
||||
return new PredefinedMenuItem(rid, id);
|
||||
case 'Check':
|
||||
// @ts-expect-error constructor is protected for external usage only, safe for us to use
|
||||
return new CheckMenuItem(rid, id);
|
||||
case 'Icon':
|
||||
// @ts-expect-error constructor is protected for external usage only, safe for us to use
|
||||
return new IconMenuItem(rid, id);
|
||||
case 'MenuItem':
|
||||
default:
|
||||
// @ts-expect-error constructor is protected for external usage only, safe for us to use
|
||||
return new MenuItem(rid, id);
|
||||
}
|
||||
/* eslint-enable @typescript-eslint/no-unsafe-return */
|
||||
}
|
||||
/** A type that is a submenu inside a {@linkcode Menu} or {@linkcode Submenu}. */
|
||||
class Submenu extends MenuItemBase {
|
||||
/** @ignore */
|
||||
constructor(rid, id) {
|
||||
super(rid, id, 'Submenu');
|
||||
}
|
||||
/** Create a new submenu. */
|
||||
static async new(opts) {
|
||||
return newMenu('Submenu', opts).then(([rid, id]) => new Submenu(rid, id));
|
||||
}
|
||||
/** Returns the text of this submenu. */
|
||||
async text() {
|
||||
return invoke('plugin:menu|text', { rid: this.rid, kind: this.kind });
|
||||
}
|
||||
/** Sets the text for this submenu. */
|
||||
async setText(text) {
|
||||
return invoke('plugin:menu|set_text', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
text
|
||||
});
|
||||
}
|
||||
/** Returns whether this submenu is enabled or not. */
|
||||
async isEnabled() {
|
||||
return invoke('plugin:menu|is_enabled', { rid: this.rid, kind: this.kind });
|
||||
}
|
||||
/** Sets whether this submenu is enabled or not. */
|
||||
async setEnabled(enabled) {
|
||||
return invoke('plugin:menu|set_enabled', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
enabled
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Add a menu item to the end of this submenu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Only {@linkcode Submenu}s can be added to a {@linkcode Menu}.
|
||||
*/
|
||||
async append(items) {
|
||||
return invoke('plugin:menu|append', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
items: (Array.isArray(items) ? items : [items]).map((i) => 'rid' in i ? [i.rid, i.kind] : i)
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Add a menu item to the beginning of this submenu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Only {@linkcode Submenu}s can be added to a {@linkcode Menu}.
|
||||
*/
|
||||
async prepend(items) {
|
||||
return invoke('plugin:menu|prepend', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
items: (Array.isArray(items) ? items : [items]).map((i) => 'rid' in i ? [i.rid, i.kind] : i)
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Add a menu item to the specified position in this submenu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Only {@linkcode Submenu}s can be added to a {@linkcode Menu}.
|
||||
*/
|
||||
async insert(items, position) {
|
||||
return invoke('plugin:menu|insert', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
items: (Array.isArray(items) ? items : [items]).map((i) => 'rid' in i ? [i.rid, i.kind] : i),
|
||||
position
|
||||
});
|
||||
}
|
||||
/** Remove a menu item from this submenu. */
|
||||
async remove(item) {
|
||||
return invoke('plugin:menu|remove', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
item: [item.rid, item.kind]
|
||||
});
|
||||
}
|
||||
/** Remove a menu item from this submenu at the specified position. */
|
||||
async removeAt(position) {
|
||||
return invoke('plugin:menu|remove_at', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
position
|
||||
}).then(itemFromKind);
|
||||
}
|
||||
/** Returns a list of menu items that has been added to this submenu. */
|
||||
async items() {
|
||||
return invoke('plugin:menu|items', {
|
||||
rid: this.rid,
|
||||
kind: this.kind
|
||||
}).then((i) => i.map(itemFromKind));
|
||||
}
|
||||
/** Retrieves the menu item matching the given identifier. */
|
||||
async get(id) {
|
||||
return invoke('plugin:menu|get', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
id
|
||||
}).then((r) => (r ? itemFromKind(r) : null));
|
||||
}
|
||||
/**
|
||||
* Popup this submenu as a context menu on the specified window.
|
||||
*
|
||||
* If the position, is provided, it is relative to the window's top-left corner.
|
||||
*/
|
||||
async popup(at, window) {
|
||||
var _a;
|
||||
return invoke('plugin:menu|popup', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
window: (_a = window === null || window === void 0 ? void 0 : window.label) !== null && _a !== void 0 ? _a : null,
|
||||
at: at instanceof Position ? at : at ? new Position(at) : null
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Set this submenu as the Window menu for the application on macOS.
|
||||
*
|
||||
* This will cause macOS to automatically add window-switching items and
|
||||
* certain other items to the menu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Windows / Linux**: Unsupported.
|
||||
*/
|
||||
async setAsWindowsMenuForNSApp() {
|
||||
return invoke('plugin:menu|set_as_windows_menu_for_nsapp', {
|
||||
rid: this.rid
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Set this submenu as the Help menu for the application on macOS.
|
||||
*
|
||||
* This will cause macOS to automatically add a search box to the menu.
|
||||
*
|
||||
* If no menu is set as the Help menu, macOS will automatically use any menu
|
||||
* which has a title matching the localized word "Help".
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Windows / Linux**: Unsupported.
|
||||
*/
|
||||
async setAsHelpMenuForNSApp() {
|
||||
return invoke('plugin:menu|set_as_help_menu_for_nsapp', {
|
||||
rid: this.rid
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export { Submenu, itemFromKind };
|
208
node_modules/@tauri-apps/api/mocks.cjs
generated
vendored
Normal file
208
node_modules/@tauri-apps/api/mocks.cjs
generated
vendored
Normal file
@ -0,0 +1,208 @@
|
||||
'use strict';
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
function mockInternals() {
|
||||
var _a;
|
||||
window.__TAURI_INTERNALS__ = (_a = window.__TAURI_INTERNALS__) !== null && _a !== void 0 ? _a : {};
|
||||
}
|
||||
/**
|
||||
* Intercepts all IPC requests with the given mock handler.
|
||||
*
|
||||
* This function can be used when testing tauri frontend applications or when running the frontend in a Node.js context during static site generation.
|
||||
*
|
||||
* # Examples
|
||||
*
|
||||
* Testing setup using Vitest:
|
||||
* ```js
|
||||
* import { mockIPC, clearMocks } from "@tauri-apps/api/mocks"
|
||||
* import { invoke } from "@tauri-apps/api/core"
|
||||
*
|
||||
* afterEach(() => {
|
||||
* clearMocks()
|
||||
* })
|
||||
*
|
||||
* test("mocked command", () => {
|
||||
* mockIPC((cmd, payload) => {
|
||||
* switch (cmd) {
|
||||
* case "add":
|
||||
* return (payload.a as number) + (payload.b as number);
|
||||
* default:
|
||||
* break;
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* expect(invoke('add', { a: 12, b: 15 })).resolves.toBe(27);
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* The callback function can also return a Promise:
|
||||
* ```js
|
||||
* import { mockIPC, clearMocks } from "@tauri-apps/api/mocks"
|
||||
* import { invoke } from "@tauri-apps/api/core"
|
||||
*
|
||||
* afterEach(() => {
|
||||
* clearMocks()
|
||||
* })
|
||||
*
|
||||
* test("mocked command", () => {
|
||||
* mockIPC((cmd, payload) => {
|
||||
* if(cmd === "get_data") {
|
||||
* return fetch("https://example.com/data.json")
|
||||
* .then((response) => response.json())
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* expect(invoke('get_data')).resolves.toBe({ foo: 'bar' });
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function mockIPC(cb) {
|
||||
mockInternals();
|
||||
window.__TAURI_INTERNALS__.transformCallback = function transformCallback(
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
callback, once = false) {
|
||||
const identifier = window.crypto.getRandomValues(new Uint32Array(1))[0];
|
||||
const prop = `_${identifier}`;
|
||||
Object.defineProperty(window, prop, {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
value: (result) => {
|
||||
if (once) {
|
||||
Reflect.deleteProperty(window, prop);
|
||||
}
|
||||
return callback && callback(result);
|
||||
},
|
||||
writable: false,
|
||||
configurable: true
|
||||
});
|
||||
return identifier;
|
||||
};
|
||||
// eslint-disable-next-line @typescript-eslint/require-await
|
||||
window.__TAURI_INTERNALS__.invoke = async function (cmd, args,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
options) {
|
||||
return cb(cmd, args);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Mocks one or many window labels.
|
||||
* In non-tauri context it is required to call this function *before* using the `@tauri-apps/api/window` module.
|
||||
*
|
||||
* This function only mocks the *presence* of windows,
|
||||
* window properties (e.g. width and height) can be mocked like regular IPC calls using the `mockIPC` function.
|
||||
*
|
||||
* # Examples
|
||||
*
|
||||
* ```js
|
||||
* import { mockWindows } from "@tauri-apps/api/mocks";
|
||||
* import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||
*
|
||||
* mockWindows("main", "second", "third");
|
||||
*
|
||||
* const win = getCurrentWindow();
|
||||
*
|
||||
* win.label // "main"
|
||||
* ```
|
||||
*
|
||||
* ```js
|
||||
* import { mockWindows } from "@tauri-apps/api/mocks";
|
||||
*
|
||||
* mockWindows("main", "second", "third");
|
||||
*
|
||||
* mockIPC((cmd, args) => {
|
||||
* if (cmd === "plugin:event|emit") {
|
||||
* console.log('emit event', args?.event, args?.payload);
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* const { emit } = await import("@tauri-apps/api/event");
|
||||
* await emit('loaded'); // this will cause the mocked IPC handler to log to the console.
|
||||
* ```
|
||||
*
|
||||
* @param current Label of window this JavaScript context is running in.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function mockWindows(current, ..._additionalWindows) {
|
||||
mockInternals();
|
||||
window.__TAURI_INTERNALS__.metadata = {
|
||||
currentWindow: { label: current },
|
||||
currentWebview: { windowLabel: current, label: current }
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Mock `convertFileSrc` function
|
||||
*
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* import { mockConvertFileSrc } from "@tauri-apps/api/mocks";
|
||||
* import { convertFileSrc } from "@tauri-apps/api/core";
|
||||
*
|
||||
* mockConvertFileSrc("windows")
|
||||
*
|
||||
* const url = convertFileSrc("C:\\Users\\user\\file.txt")
|
||||
* ```
|
||||
*
|
||||
* @param osName The operating system to mock, can be one of linux, macos, or windows
|
||||
*
|
||||
* @since 1.6.0
|
||||
*/
|
||||
function mockConvertFileSrc(osName) {
|
||||
mockInternals();
|
||||
window.__TAURI_INTERNALS__.convertFileSrc = function (filePath, protocol = 'asset') {
|
||||
const path = encodeURIComponent(filePath);
|
||||
return osName === 'windows'
|
||||
? `http://${protocol}.localhost/${path}`
|
||||
: `${protocol}://localhost/${path}`;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Clears mocked functions/data injected by the other functions in this module.
|
||||
* When using a test runner that doesn't provide a fresh window object for each test, calling this function will reset tauri specific properties.
|
||||
*
|
||||
* # Example
|
||||
*
|
||||
* ```js
|
||||
* import { mockWindows, clearMocks } from "@tauri-apps/api/mocks"
|
||||
*
|
||||
* afterEach(() => {
|
||||
* clearMocks()
|
||||
* })
|
||||
*
|
||||
* test("mocked windows", () => {
|
||||
* mockWindows("main", "second", "third");
|
||||
*
|
||||
* expect(window.__TAURI_INTERNALS__).toHaveProperty("metadata")
|
||||
* })
|
||||
*
|
||||
* test("no mocked windows", () => {
|
||||
* expect(window.__TAURI_INTERNALS__).not.toHaveProperty("metadata")
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function clearMocks() {
|
||||
var _a, _b, _c;
|
||||
if (typeof window.__TAURI_INTERNALS__ !== 'object') {
|
||||
return;
|
||||
}
|
||||
if ((_a = window.__TAURI_INTERNALS__) === null || _a === void 0 ? void 0 : _a.convertFileSrc)
|
||||
// @ts-expect-error "The operand of a 'delete' operator must be optional' does not matter in this case
|
||||
delete window.__TAURI_INTERNALS__.convertFileSrc;
|
||||
if ((_b = window.__TAURI_INTERNALS__) === null || _b === void 0 ? void 0 : _b.invoke)
|
||||
// @ts-expect-error "The operand of a 'delete' operator must be optional' does not matter in this case
|
||||
delete window.__TAURI_INTERNALS__.invoke;
|
||||
if ((_c = window.__TAURI_INTERNALS__) === null || _c === void 0 ? void 0 : _c.metadata)
|
||||
// @ts-expect-error "The operand of a 'delete' operator must be optional' does not matter in this case
|
||||
delete window.__TAURI_INTERNALS__.metadata;
|
||||
}
|
||||
|
||||
exports.clearMocks = clearMocks;
|
||||
exports.mockConvertFileSrc = mockConvertFileSrc;
|
||||
exports.mockIPC = mockIPC;
|
||||
exports.mockWindows = mockWindows;
|
141
node_modules/@tauri-apps/api/mocks.d.ts
generated
vendored
Normal file
141
node_modules/@tauri-apps/api/mocks.d.ts
generated
vendored
Normal file
@ -0,0 +1,141 @@
|
||||
import type { InvokeArgs } from './core';
|
||||
/**
|
||||
* Intercepts all IPC requests with the given mock handler.
|
||||
*
|
||||
* This function can be used when testing tauri frontend applications or when running the frontend in a Node.js context during static site generation.
|
||||
*
|
||||
* # Examples
|
||||
*
|
||||
* Testing setup using Vitest:
|
||||
* ```js
|
||||
* import { mockIPC, clearMocks } from "@tauri-apps/api/mocks"
|
||||
* import { invoke } from "@tauri-apps/api/core"
|
||||
*
|
||||
* afterEach(() => {
|
||||
* clearMocks()
|
||||
* })
|
||||
*
|
||||
* test("mocked command", () => {
|
||||
* mockIPC((cmd, payload) => {
|
||||
* switch (cmd) {
|
||||
* case "add":
|
||||
* return (payload.a as number) + (payload.b as number);
|
||||
* default:
|
||||
* break;
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* expect(invoke('add', { a: 12, b: 15 })).resolves.toBe(27);
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* The callback function can also return a Promise:
|
||||
* ```js
|
||||
* import { mockIPC, clearMocks } from "@tauri-apps/api/mocks"
|
||||
* import { invoke } from "@tauri-apps/api/core"
|
||||
*
|
||||
* afterEach(() => {
|
||||
* clearMocks()
|
||||
* })
|
||||
*
|
||||
* test("mocked command", () => {
|
||||
* mockIPC((cmd, payload) => {
|
||||
* if(cmd === "get_data") {
|
||||
* return fetch("https://example.com/data.json")
|
||||
* .then((response) => response.json())
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* expect(invoke('get_data')).resolves.toBe({ foo: 'bar' });
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
export declare function mockIPC(cb: (cmd: string, payload?: InvokeArgs) => unknown): void;
|
||||
/**
|
||||
* Mocks one or many window labels.
|
||||
* In non-tauri context it is required to call this function *before* using the `@tauri-apps/api/window` module.
|
||||
*
|
||||
* This function only mocks the *presence* of windows,
|
||||
* window properties (e.g. width and height) can be mocked like regular IPC calls using the `mockIPC` function.
|
||||
*
|
||||
* # Examples
|
||||
*
|
||||
* ```js
|
||||
* import { mockWindows } from "@tauri-apps/api/mocks";
|
||||
* import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||
*
|
||||
* mockWindows("main", "second", "third");
|
||||
*
|
||||
* const win = getCurrentWindow();
|
||||
*
|
||||
* win.label // "main"
|
||||
* ```
|
||||
*
|
||||
* ```js
|
||||
* import { mockWindows } from "@tauri-apps/api/mocks";
|
||||
*
|
||||
* mockWindows("main", "second", "third");
|
||||
*
|
||||
* mockIPC((cmd, args) => {
|
||||
* if (cmd === "plugin:event|emit") {
|
||||
* console.log('emit event', args?.event, args?.payload);
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* const { emit } = await import("@tauri-apps/api/event");
|
||||
* await emit('loaded'); // this will cause the mocked IPC handler to log to the console.
|
||||
* ```
|
||||
*
|
||||
* @param current Label of window this JavaScript context is running in.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
export declare function mockWindows(current: string, ..._additionalWindows: string[]): void;
|
||||
/**
|
||||
* Mock `convertFileSrc` function
|
||||
*
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* import { mockConvertFileSrc } from "@tauri-apps/api/mocks";
|
||||
* import { convertFileSrc } from "@tauri-apps/api/core";
|
||||
*
|
||||
* mockConvertFileSrc("windows")
|
||||
*
|
||||
* const url = convertFileSrc("C:\\Users\\user\\file.txt")
|
||||
* ```
|
||||
*
|
||||
* @param osName The operating system to mock, can be one of linux, macos, or windows
|
||||
*
|
||||
* @since 1.6.0
|
||||
*/
|
||||
export declare function mockConvertFileSrc(osName: string): void;
|
||||
/**
|
||||
* Clears mocked functions/data injected by the other functions in this module.
|
||||
* When using a test runner that doesn't provide a fresh window object for each test, calling this function will reset tauri specific properties.
|
||||
*
|
||||
* # Example
|
||||
*
|
||||
* ```js
|
||||
* import { mockWindows, clearMocks } from "@tauri-apps/api/mocks"
|
||||
*
|
||||
* afterEach(() => {
|
||||
* clearMocks()
|
||||
* })
|
||||
*
|
||||
* test("mocked windows", () => {
|
||||
* mockWindows("main", "second", "third");
|
||||
*
|
||||
* expect(window.__TAURI_INTERNALS__).toHaveProperty("metadata")
|
||||
* })
|
||||
*
|
||||
* test("no mocked windows", () => {
|
||||
* expect(window.__TAURI_INTERNALS__).not.toHaveProperty("metadata")
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
export declare function clearMocks(): void;
|
203
node_modules/@tauri-apps/api/mocks.js
generated
vendored
Normal file
203
node_modules/@tauri-apps/api/mocks.js
generated
vendored
Normal file
@ -0,0 +1,203 @@
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
function mockInternals() {
|
||||
var _a;
|
||||
window.__TAURI_INTERNALS__ = (_a = window.__TAURI_INTERNALS__) !== null && _a !== void 0 ? _a : {};
|
||||
}
|
||||
/**
|
||||
* Intercepts all IPC requests with the given mock handler.
|
||||
*
|
||||
* This function can be used when testing tauri frontend applications or when running the frontend in a Node.js context during static site generation.
|
||||
*
|
||||
* # Examples
|
||||
*
|
||||
* Testing setup using Vitest:
|
||||
* ```js
|
||||
* import { mockIPC, clearMocks } from "@tauri-apps/api/mocks"
|
||||
* import { invoke } from "@tauri-apps/api/core"
|
||||
*
|
||||
* afterEach(() => {
|
||||
* clearMocks()
|
||||
* })
|
||||
*
|
||||
* test("mocked command", () => {
|
||||
* mockIPC((cmd, payload) => {
|
||||
* switch (cmd) {
|
||||
* case "add":
|
||||
* return (payload.a as number) + (payload.b as number);
|
||||
* default:
|
||||
* break;
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* expect(invoke('add', { a: 12, b: 15 })).resolves.toBe(27);
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* The callback function can also return a Promise:
|
||||
* ```js
|
||||
* import { mockIPC, clearMocks } from "@tauri-apps/api/mocks"
|
||||
* import { invoke } from "@tauri-apps/api/core"
|
||||
*
|
||||
* afterEach(() => {
|
||||
* clearMocks()
|
||||
* })
|
||||
*
|
||||
* test("mocked command", () => {
|
||||
* mockIPC((cmd, payload) => {
|
||||
* if(cmd === "get_data") {
|
||||
* return fetch("https://example.com/data.json")
|
||||
* .then((response) => response.json())
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* expect(invoke('get_data')).resolves.toBe({ foo: 'bar' });
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function mockIPC(cb) {
|
||||
mockInternals();
|
||||
window.__TAURI_INTERNALS__.transformCallback = function transformCallback(
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
callback, once = false) {
|
||||
const identifier = window.crypto.getRandomValues(new Uint32Array(1))[0];
|
||||
const prop = `_${identifier}`;
|
||||
Object.defineProperty(window, prop, {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
value: (result) => {
|
||||
if (once) {
|
||||
Reflect.deleteProperty(window, prop);
|
||||
}
|
||||
return callback && callback(result);
|
||||
},
|
||||
writable: false,
|
||||
configurable: true
|
||||
});
|
||||
return identifier;
|
||||
};
|
||||
// eslint-disable-next-line @typescript-eslint/require-await
|
||||
window.__TAURI_INTERNALS__.invoke = async function (cmd, args,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
options) {
|
||||
return cb(cmd, args);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Mocks one or many window labels.
|
||||
* In non-tauri context it is required to call this function *before* using the `@tauri-apps/api/window` module.
|
||||
*
|
||||
* This function only mocks the *presence* of windows,
|
||||
* window properties (e.g. width and height) can be mocked like regular IPC calls using the `mockIPC` function.
|
||||
*
|
||||
* # Examples
|
||||
*
|
||||
* ```js
|
||||
* import { mockWindows } from "@tauri-apps/api/mocks";
|
||||
* import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||
*
|
||||
* mockWindows("main", "second", "third");
|
||||
*
|
||||
* const win = getCurrentWindow();
|
||||
*
|
||||
* win.label // "main"
|
||||
* ```
|
||||
*
|
||||
* ```js
|
||||
* import { mockWindows } from "@tauri-apps/api/mocks";
|
||||
*
|
||||
* mockWindows("main", "second", "third");
|
||||
*
|
||||
* mockIPC((cmd, args) => {
|
||||
* if (cmd === "plugin:event|emit") {
|
||||
* console.log('emit event', args?.event, args?.payload);
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* const { emit } = await import("@tauri-apps/api/event");
|
||||
* await emit('loaded'); // this will cause the mocked IPC handler to log to the console.
|
||||
* ```
|
||||
*
|
||||
* @param current Label of window this JavaScript context is running in.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function mockWindows(current, ..._additionalWindows) {
|
||||
mockInternals();
|
||||
window.__TAURI_INTERNALS__.metadata = {
|
||||
currentWindow: { label: current },
|
||||
currentWebview: { windowLabel: current, label: current }
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Mock `convertFileSrc` function
|
||||
*
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* import { mockConvertFileSrc } from "@tauri-apps/api/mocks";
|
||||
* import { convertFileSrc } from "@tauri-apps/api/core";
|
||||
*
|
||||
* mockConvertFileSrc("windows")
|
||||
*
|
||||
* const url = convertFileSrc("C:\\Users\\user\\file.txt")
|
||||
* ```
|
||||
*
|
||||
* @param osName The operating system to mock, can be one of linux, macos, or windows
|
||||
*
|
||||
* @since 1.6.0
|
||||
*/
|
||||
function mockConvertFileSrc(osName) {
|
||||
mockInternals();
|
||||
window.__TAURI_INTERNALS__.convertFileSrc = function (filePath, protocol = 'asset') {
|
||||
const path = encodeURIComponent(filePath);
|
||||
return osName === 'windows'
|
||||
? `http://${protocol}.localhost/${path}`
|
||||
: `${protocol}://localhost/${path}`;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Clears mocked functions/data injected by the other functions in this module.
|
||||
* When using a test runner that doesn't provide a fresh window object for each test, calling this function will reset tauri specific properties.
|
||||
*
|
||||
* # Example
|
||||
*
|
||||
* ```js
|
||||
* import { mockWindows, clearMocks } from "@tauri-apps/api/mocks"
|
||||
*
|
||||
* afterEach(() => {
|
||||
* clearMocks()
|
||||
* })
|
||||
*
|
||||
* test("mocked windows", () => {
|
||||
* mockWindows("main", "second", "third");
|
||||
*
|
||||
* expect(window.__TAURI_INTERNALS__).toHaveProperty("metadata")
|
||||
* })
|
||||
*
|
||||
* test("no mocked windows", () => {
|
||||
* expect(window.__TAURI_INTERNALS__).not.toHaveProperty("metadata")
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function clearMocks() {
|
||||
var _a, _b, _c;
|
||||
if (typeof window.__TAURI_INTERNALS__ !== 'object') {
|
||||
return;
|
||||
}
|
||||
if ((_a = window.__TAURI_INTERNALS__) === null || _a === void 0 ? void 0 : _a.convertFileSrc)
|
||||
// @ts-expect-error "The operand of a 'delete' operator must be optional' does not matter in this case
|
||||
delete window.__TAURI_INTERNALS__.convertFileSrc;
|
||||
if ((_b = window.__TAURI_INTERNALS__) === null || _b === void 0 ? void 0 : _b.invoke)
|
||||
// @ts-expect-error "The operand of a 'delete' operator must be optional' does not matter in this case
|
||||
delete window.__TAURI_INTERNALS__.invoke;
|
||||
if ((_c = window.__TAURI_INTERNALS__) === null || _c === void 0 ? void 0 : _c.metadata)
|
||||
// @ts-expect-error "The operand of a 'delete' operator must be optional' does not matter in this case
|
||||
delete window.__TAURI_INTERNALS__.metadata;
|
||||
}
|
||||
|
||||
export { clearMocks, mockConvertFileSrc, mockIPC, mockWindows };
|
63
node_modules/@tauri-apps/api/package.json
generated
vendored
Normal file
63
node_modules/@tauri-apps/api/package.json
generated
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
{
|
||||
"name": "@tauri-apps/api",
|
||||
"version": "2.5.0",
|
||||
"description": "Tauri API definitions",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/tauri"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/tauri-apps/tauri.git"
|
||||
},
|
||||
"contributors": [
|
||||
"Tauri Programme within The Commons Conservancy"
|
||||
],
|
||||
"license": "Apache-2.0 OR MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/tauri-apps/tauri/issues"
|
||||
},
|
||||
"homepage": "https://github.com/tauri-apps/tauri#readme",
|
||||
"type": "module",
|
||||
"main": "./index.cjs",
|
||||
"module": "./index.js",
|
||||
"types": "./index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./index.js",
|
||||
"require": "./index.cjs",
|
||||
"types": "./index.d.ts"
|
||||
},
|
||||
"./*": {
|
||||
"import": "./*.js",
|
||||
"require": "./*.cjs",
|
||||
"types": "./*.d.ts"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.21.0",
|
||||
"@rollup/plugin-terser": "0.4.4",
|
||||
"@rollup/plugin-typescript": "12.1.2",
|
||||
"@types/eslint": "^9.6.1",
|
||||
"@types/node": "^22.13.5",
|
||||
"eslint": "^9.21.0",
|
||||
"eslint-config-prettier": "10.1.2",
|
||||
"eslint-plugin-security": "3.0.1",
|
||||
"fast-glob": "3.3.3",
|
||||
"globals": "^16.0.0",
|
||||
"rollup": "4.40.0",
|
||||
"tslib": "^2.8.1",
|
||||
"typescript": "^5.8.3",
|
||||
"typescript-eslint": "^8.25.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rollup -c --configPlugin typescript",
|
||||
"build:debug": "rollup -c --configPlugin typescript",
|
||||
"npm-pack": "pnpm build && cd ./dist && npm pack",
|
||||
"npm-publish": "pnpm build && cd ./dist && pnpm publish --access public --loglevel silly --no-git-checks",
|
||||
"ts:check": "tsc --noEmit",
|
||||
"eslint:check": "eslint src/**/*.ts",
|
||||
"eslint:fix": "eslint src/**/*.ts --fix"
|
||||
}
|
||||
}
|
737
node_modules/@tauri-apps/api/path.cjs
generated
vendored
Normal file
737
node_modules/@tauri-apps/api/path.cjs
generated
vendored
Normal file
@ -0,0 +1,737 @@
|
||||
'use strict';
|
||||
|
||||
var core = require('./core.cjs');
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/**
|
||||
* The path module provides utilities for working with file and directory paths.
|
||||
*
|
||||
* This package is also accessible with `window.__TAURI__.path` when [`app.withGlobalTauri`](https://v2.tauri.app/reference/config/#withglobaltauri) in `tauri.conf.json` is set to `true`.
|
||||
*
|
||||
* It is recommended to allowlist only the APIs you use for optimal bundle size and security.
|
||||
* @module
|
||||
*/
|
||||
/**
|
||||
* @since 2.0.0
|
||||
*/
|
||||
exports.BaseDirectory = void 0;
|
||||
(function (BaseDirectory) {
|
||||
/**
|
||||
* @see {@link audioDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["Audio"] = 1] = "Audio";
|
||||
/**
|
||||
* @see {@link cacheDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["Cache"] = 2] = "Cache";
|
||||
/**
|
||||
* @see {@link configDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["Config"] = 3] = "Config";
|
||||
/**
|
||||
* @see {@link dataDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["Data"] = 4] = "Data";
|
||||
/**
|
||||
* @see {@link localDataDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["LocalData"] = 5] = "LocalData";
|
||||
/**
|
||||
* @see {@link documentDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["Document"] = 6] = "Document";
|
||||
/**
|
||||
* @see {@link downloadDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["Download"] = 7] = "Download";
|
||||
/**
|
||||
* @see {@link pictureDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["Picture"] = 8] = "Picture";
|
||||
/**
|
||||
* @see {@link publicDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["Public"] = 9] = "Public";
|
||||
/**
|
||||
* @see {@link videoDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["Video"] = 10] = "Video";
|
||||
/**
|
||||
* @see {@link resourceDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["Resource"] = 11] = "Resource";
|
||||
/**
|
||||
* @see {@link tempDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["Temp"] = 12] = "Temp";
|
||||
/**
|
||||
* @see {@link appConfigDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["AppConfig"] = 13] = "AppConfig";
|
||||
/**
|
||||
* @see {@link appDataDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["AppData"] = 14] = "AppData";
|
||||
/**
|
||||
* @see {@link appLocalDataDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["AppLocalData"] = 15] = "AppLocalData";
|
||||
/**
|
||||
* @see {@link appCacheDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["AppCache"] = 16] = "AppCache";
|
||||
/**
|
||||
* @see {@link appLogDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["AppLog"] = 17] = "AppLog";
|
||||
/**
|
||||
* @see {@link desktopDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["Desktop"] = 18] = "Desktop";
|
||||
/**
|
||||
* @see {@link executableDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["Executable"] = 19] = "Executable";
|
||||
/**
|
||||
* @see {@link fontDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["Font"] = 20] = "Font";
|
||||
/**
|
||||
* @see {@link homeDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["Home"] = 21] = "Home";
|
||||
/**
|
||||
* @see {@link runtimeDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["Runtime"] = 22] = "Runtime";
|
||||
/**
|
||||
* @see {@link templateDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["Template"] = 23] = "Template";
|
||||
})(exports.BaseDirectory || (exports.BaseDirectory = {}));
|
||||
/**
|
||||
* Returns the path to the suggested directory for your app's config files.
|
||||
* Resolves to `${configDir}/${bundleIdentifier}`, where `bundleIdentifier` is the [`identifier`](https://v2.tauri.app/reference/config/#identifier) value configured in `tauri.conf.json`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { appConfigDir } from '@tauri-apps/api/path';
|
||||
* const appConfigDirPath = await appConfigDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
async function appConfigDir() {
|
||||
return core.invoke('plugin:path|resolve_directory', {
|
||||
directory: exports.BaseDirectory.AppConfig
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the suggested directory for your app's data files.
|
||||
* Resolves to `${dataDir}/${bundleIdentifier}`, where `bundleIdentifier` is the [`identifier`](https://v2.tauri.app/reference/config/#identifier) value configured in `tauri.conf.json`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { appDataDir } from '@tauri-apps/api/path';
|
||||
* const appDataDirPath = await appDataDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
async function appDataDir() {
|
||||
return core.invoke('plugin:path|resolve_directory', {
|
||||
directory: exports.BaseDirectory.AppData
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the suggested directory for your app's local data files.
|
||||
* Resolves to `${localDataDir}/${bundleIdentifier}`, where `bundleIdentifier` is the [`identifier`](https://v2.tauri.app/reference/config/#identifier) value configured in `tauri.conf.json`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { appLocalDataDir } from '@tauri-apps/api/path';
|
||||
* const appLocalDataDirPath = await appLocalDataDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
async function appLocalDataDir() {
|
||||
return core.invoke('plugin:path|resolve_directory', {
|
||||
directory: exports.BaseDirectory.AppLocalData
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the suggested directory for your app's cache files.
|
||||
* Resolves to `${cacheDir}/${bundleIdentifier}`, where `bundleIdentifier` is the [`identifier`](https://v2.tauri.app/reference/config/#identifier) value configured in `tauri.conf.json`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { appCacheDir } from '@tauri-apps/api/path';
|
||||
* const appCacheDirPath = await appCacheDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
async function appCacheDir() {
|
||||
return core.invoke('plugin:path|resolve_directory', {
|
||||
directory: exports.BaseDirectory.AppCache
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the user's audio directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)' `XDG_MUSIC_DIR`.
|
||||
* - **macOS:** Resolves to `$HOME/Music`.
|
||||
* - **Windows:** Resolves to `{FOLDERID_Music}`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { audioDir } from '@tauri-apps/api/path';
|
||||
* const audioDirPath = await audioDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function audioDir() {
|
||||
return core.invoke('plugin:path|resolve_directory', {
|
||||
directory: exports.BaseDirectory.Audio
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the user's cache directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to `$XDG_CACHE_HOME` or `$HOME/.cache`.
|
||||
* - **macOS:** Resolves to `$HOME/Library/Caches`.
|
||||
* - **Windows:** Resolves to `{FOLDERID_LocalAppData}`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { cacheDir } from '@tauri-apps/api/path';
|
||||
* const cacheDirPath = await cacheDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function cacheDir() {
|
||||
return core.invoke('plugin:path|resolve_directory', {
|
||||
directory: exports.BaseDirectory.Cache
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the user's config directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to `$XDG_CONFIG_HOME` or `$HOME/.config`.
|
||||
* - **macOS:** Resolves to `$HOME/Library/Application Support`.
|
||||
* - **Windows:** Resolves to `{FOLDERID_RoamingAppData}`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { configDir } from '@tauri-apps/api/path';
|
||||
* const configDirPath = await configDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function configDir() {
|
||||
return core.invoke('plugin:path|resolve_directory', {
|
||||
directory: exports.BaseDirectory.Config
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the user's data directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to `$XDG_DATA_HOME` or `$HOME/.local/share`.
|
||||
* - **macOS:** Resolves to `$HOME/Library/Application Support`.
|
||||
* - **Windows:** Resolves to `{FOLDERID_RoamingAppData}`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { dataDir } from '@tauri-apps/api/path';
|
||||
* const dataDirPath = await dataDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function dataDir() {
|
||||
return core.invoke('plugin:path|resolve_directory', {
|
||||
directory: exports.BaseDirectory.Data
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the user's desktop directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)' `XDG_DESKTOP_DIR`.
|
||||
* - **macOS:** Resolves to `$HOME/Desktop`.
|
||||
* - **Windows:** Resolves to `{FOLDERID_Desktop}`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { desktopDir } from '@tauri-apps/api/path';
|
||||
* const desktopPath = await desktopDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function desktopDir() {
|
||||
return core.invoke('plugin:path|resolve_directory', {
|
||||
directory: exports.BaseDirectory.Desktop
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the user's document directory.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { documentDir } from '@tauri-apps/api/path';
|
||||
* const documentDirPath = await documentDir();
|
||||
* ```
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)' `XDG_DOCUMENTS_DIR`.
|
||||
* - **macOS:** Resolves to `$HOME/Documents`.
|
||||
* - **Windows:** Resolves to `{FOLDERID_Documents}`.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function documentDir() {
|
||||
return core.invoke('plugin:path|resolve_directory', {
|
||||
directory: exports.BaseDirectory.Document
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the user's download directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux**: Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)' `XDG_DOWNLOAD_DIR`.
|
||||
* - **macOS**: Resolves to `$HOME/Downloads`.
|
||||
* - **Windows**: Resolves to `{FOLDERID_Downloads}`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { downloadDir } from '@tauri-apps/api/path';
|
||||
* const downloadDirPath = await downloadDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function downloadDir() {
|
||||
return core.invoke('plugin:path|resolve_directory', {
|
||||
directory: exports.BaseDirectory.Download
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the user's executable directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to `$XDG_BIN_HOME/../bin` or `$XDG_DATA_HOME/../bin` or `$HOME/.local/bin`.
|
||||
* - **macOS:** Not supported.
|
||||
* - **Windows:** Not supported.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { executableDir } from '@tauri-apps/api/path';
|
||||
* const executableDirPath = await executableDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function executableDir() {
|
||||
return core.invoke('plugin:path|resolve_directory', {
|
||||
directory: exports.BaseDirectory.Executable
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the user's font directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to `$XDG_DATA_HOME/fonts` or `$HOME/.local/share/fonts`.
|
||||
* - **macOS:** Resolves to `$HOME/Library/Fonts`.
|
||||
* - **Windows:** Not supported.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { fontDir } from '@tauri-apps/api/path';
|
||||
* const fontDirPath = await fontDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function fontDir() {
|
||||
return core.invoke('plugin:path|resolve_directory', {
|
||||
directory: exports.BaseDirectory.Font
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the user's home directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to `$HOME`.
|
||||
* - **macOS:** Resolves to `$HOME`.
|
||||
* - **Windows:** Resolves to `{FOLDERID_Profile}`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { homeDir } from '@tauri-apps/api/path';
|
||||
* const homeDirPath = await homeDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function homeDir() {
|
||||
return core.invoke('plugin:path|resolve_directory', {
|
||||
directory: exports.BaseDirectory.Home
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the user's local data directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to `$XDG_DATA_HOME` or `$HOME/.local/share`.
|
||||
* - **macOS:** Resolves to `$HOME/Library/Application Support`.
|
||||
* - **Windows:** Resolves to `{FOLDERID_LocalAppData}`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { localDataDir } from '@tauri-apps/api/path';
|
||||
* const localDataDirPath = await localDataDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function localDataDir() {
|
||||
return core.invoke('plugin:path|resolve_directory', {
|
||||
directory: exports.BaseDirectory.LocalData
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the user's picture directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)' `XDG_PICTURES_DIR`.
|
||||
* - **macOS:** Resolves to `$HOME/Pictures`.
|
||||
* - **Windows:** Resolves to `{FOLDERID_Pictures}`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { pictureDir } from '@tauri-apps/api/path';
|
||||
* const pictureDirPath = await pictureDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function pictureDir() {
|
||||
return core.invoke('plugin:path|resolve_directory', {
|
||||
directory: exports.BaseDirectory.Picture
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the user's public directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)' `XDG_PUBLICSHARE_DIR`.
|
||||
* - **macOS:** Resolves to `$HOME/Public`.
|
||||
* - **Windows:** Resolves to `{FOLDERID_Public}`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { publicDir } from '@tauri-apps/api/path';
|
||||
* const publicDirPath = await publicDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function publicDir() {
|
||||
return core.invoke('plugin:path|resolve_directory', {
|
||||
directory: exports.BaseDirectory.Public
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the application's resource directory.
|
||||
* To resolve a resource path, see the [[resolveResource | `resolveResource API`]].
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { resourceDir } from '@tauri-apps/api/path';
|
||||
* const resourceDirPath = await resourceDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function resourceDir() {
|
||||
return core.invoke('plugin:path|resolve_directory', {
|
||||
directory: exports.BaseDirectory.Resource
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Resolve the path to a resource file.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { resolveResource } from '@tauri-apps/api/path';
|
||||
* const resourcePath = await resolveResource('script.sh');
|
||||
* ```
|
||||
*
|
||||
* @param resourcePath The path to the resource.
|
||||
* Must follow the same syntax as defined in `tauri.conf.json > bundle > resources`, i.e. keeping subfolders and parent dir components (`../`).
|
||||
* @returns The full path to the resource.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function resolveResource(resourcePath) {
|
||||
return core.invoke('plugin:path|resolve_directory', {
|
||||
directory: exports.BaseDirectory.Resource,
|
||||
path: resourcePath
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the user's runtime directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to `$XDG_RUNTIME_DIR`.
|
||||
* - **macOS:** Not supported.
|
||||
* - **Windows:** Not supported.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { runtimeDir } from '@tauri-apps/api/path';
|
||||
* const runtimeDirPath = await runtimeDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function runtimeDir() {
|
||||
return core.invoke('plugin:path|resolve_directory', {
|
||||
directory: exports.BaseDirectory.Runtime
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the user's template directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)' `XDG_TEMPLATES_DIR`.
|
||||
* - **macOS:** Not supported.
|
||||
* - **Windows:** Resolves to `{FOLDERID_Templates}`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { templateDir } from '@tauri-apps/api/path';
|
||||
* const templateDirPath = await templateDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function templateDir() {
|
||||
return core.invoke('plugin:path|resolve_directory', {
|
||||
directory: exports.BaseDirectory.Template
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the user's video directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)' `XDG_VIDEOS_DIR`.
|
||||
* - **macOS:** Resolves to `$HOME/Movies`.
|
||||
* - **Windows:** Resolves to `{FOLDERID_Videos}`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { videoDir } from '@tauri-apps/api/path';
|
||||
* const videoDirPath = await videoDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function videoDir() {
|
||||
return core.invoke('plugin:path|resolve_directory', {
|
||||
directory: exports.BaseDirectory.Video
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the suggested directory for your app's log files.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to `${configDir}/${bundleIdentifier}/logs`.
|
||||
* - **macOS:** Resolves to `${homeDir}/Library/Logs/{bundleIdentifier}`
|
||||
* - **Windows:** Resolves to `${configDir}/${bundleIdentifier}/logs`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { appLogDir } from '@tauri-apps/api/path';
|
||||
* const appLogDirPath = await appLogDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
async function appLogDir() {
|
||||
return core.invoke('plugin:path|resolve_directory', {
|
||||
directory: exports.BaseDirectory.AppLog
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns a temporary directory.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { tempDir } from '@tauri-apps/api/path';
|
||||
* const temp = await tempDir();
|
||||
* ```
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function tempDir() {
|
||||
return core.invoke('plugin:path|resolve_directory', {
|
||||
directory: exports.BaseDirectory.Temp
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the platform-specific path segment separator:
|
||||
* - `\` on Windows
|
||||
* - `/` on POSIX
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
function sep() {
|
||||
return window.__TAURI_INTERNALS__.plugins.path.sep;
|
||||
}
|
||||
/**
|
||||
* Returns the platform-specific path segment delimiter:
|
||||
* - `;` on Windows
|
||||
* - `:` on POSIX
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
function delimiter() {
|
||||
return window.__TAURI_INTERNALS__.plugins.path.delimiter;
|
||||
}
|
||||
/**
|
||||
* Resolves a sequence of `paths` or `path` segments into an absolute path.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { resolve, appDataDir } from '@tauri-apps/api/path';
|
||||
* const appDataDirPath = await appDataDir();
|
||||
* const path = await resolve(appDataDirPath, '..', 'users', 'tauri', 'avatar.png');
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function resolve(...paths) {
|
||||
return core.invoke('plugin:path|resolve', { paths });
|
||||
}
|
||||
/**
|
||||
* Normalizes the given `path`, resolving `'..'` and `'.'` segments and resolve symbolic links.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { normalize, appDataDir } from '@tauri-apps/api/path';
|
||||
* const appDataDirPath = await appDataDir();
|
||||
* const path = await normalize(`${appDataDirPath}/../users/tauri/avatar.png`);
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function normalize(path) {
|
||||
return core.invoke('plugin:path|normalize', { path });
|
||||
}
|
||||
/**
|
||||
* Joins all given `path` segments together using the platform-specific separator as a delimiter, then normalizes the resulting path.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { join, appDataDir } from '@tauri-apps/api/path';
|
||||
* const appDataDirPath = await appDataDir();
|
||||
* const path = await join(appDataDirPath, 'users', 'tauri', 'avatar.png');
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function join(...paths) {
|
||||
return core.invoke('plugin:path|join', { paths });
|
||||
}
|
||||
/**
|
||||
* Returns the directory name of a `path`. Trailing directory separators are ignored.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { dirname } from '@tauri-apps/api/path';
|
||||
* const dir = await dirname('/path/to/somedir/');
|
||||
* assert(dir === 'somedir');
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function dirname(path) {
|
||||
return core.invoke('plugin:path|dirname', { path });
|
||||
}
|
||||
/**
|
||||
* Returns the extension of the `path`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { extname } from '@tauri-apps/api/path';
|
||||
* const ext = await extname('/path/to/file.html');
|
||||
* assert(ext === 'html');
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function extname(path) {
|
||||
return core.invoke('plugin:path|extname', { path });
|
||||
}
|
||||
/**
|
||||
* Returns the last portion of a `path`. Trailing directory separators are ignored.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { basename } from '@tauri-apps/api/path';
|
||||
* const base = await basename('path/to/app.conf');
|
||||
* assert(base === 'app.conf');
|
||||
* ```
|
||||
* @param ext An optional file extension to be removed from the returned path.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function basename(path, ext) {
|
||||
return core.invoke('plugin:path|basename', { path, ext });
|
||||
}
|
||||
/**
|
||||
* Returns whether the path is absolute or not.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { isAbsolute } from '@tauri-apps/api/path';
|
||||
* assert(await isAbsolute('/home/tauri'));
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function isAbsolute(path) {
|
||||
return core.invoke('plugin:path|is_absolute', { path });
|
||||
}
|
||||
|
||||
exports.appCacheDir = appCacheDir;
|
||||
exports.appConfigDir = appConfigDir;
|
||||
exports.appDataDir = appDataDir;
|
||||
exports.appLocalDataDir = appLocalDataDir;
|
||||
exports.appLogDir = appLogDir;
|
||||
exports.audioDir = audioDir;
|
||||
exports.basename = basename;
|
||||
exports.cacheDir = cacheDir;
|
||||
exports.configDir = configDir;
|
||||
exports.dataDir = dataDir;
|
||||
exports.delimiter = delimiter;
|
||||
exports.desktopDir = desktopDir;
|
||||
exports.dirname = dirname;
|
||||
exports.documentDir = documentDir;
|
||||
exports.downloadDir = downloadDir;
|
||||
exports.executableDir = executableDir;
|
||||
exports.extname = extname;
|
||||
exports.fontDir = fontDir;
|
||||
exports.homeDir = homeDir;
|
||||
exports.isAbsolute = isAbsolute;
|
||||
exports.join = join;
|
||||
exports.localDataDir = localDataDir;
|
||||
exports.normalize = normalize;
|
||||
exports.pictureDir = pictureDir;
|
||||
exports.publicDir = publicDir;
|
||||
exports.resolve = resolve;
|
||||
exports.resolveResource = resolveResource;
|
||||
exports.resourceDir = resourceDir;
|
||||
exports.runtimeDir = runtimeDir;
|
||||
exports.sep = sep;
|
||||
exports.tempDir = tempDir;
|
||||
exports.templateDir = templateDir;
|
||||
exports.videoDir = videoDir;
|
573
node_modules/@tauri-apps/api/path.d.ts
generated
vendored
Normal file
573
node_modules/@tauri-apps/api/path.d.ts
generated
vendored
Normal file
@ -0,0 +1,573 @@
|
||||
/**
|
||||
* @since 2.0.0
|
||||
*/
|
||||
declare enum BaseDirectory {
|
||||
/**
|
||||
* @see {@link audioDir} for more information.
|
||||
*/
|
||||
Audio = 1,
|
||||
/**
|
||||
* @see {@link cacheDir} for more information.
|
||||
*/
|
||||
Cache = 2,
|
||||
/**
|
||||
* @see {@link configDir} for more information.
|
||||
*/
|
||||
Config = 3,
|
||||
/**
|
||||
* @see {@link dataDir} for more information.
|
||||
*/
|
||||
Data = 4,
|
||||
/**
|
||||
* @see {@link localDataDir} for more information.
|
||||
*/
|
||||
LocalData = 5,
|
||||
/**
|
||||
* @see {@link documentDir} for more information.
|
||||
*/
|
||||
Document = 6,
|
||||
/**
|
||||
* @see {@link downloadDir} for more information.
|
||||
*/
|
||||
Download = 7,
|
||||
/**
|
||||
* @see {@link pictureDir} for more information.
|
||||
*/
|
||||
Picture = 8,
|
||||
/**
|
||||
* @see {@link publicDir} for more information.
|
||||
*/
|
||||
Public = 9,
|
||||
/**
|
||||
* @see {@link videoDir} for more information.
|
||||
*/
|
||||
Video = 10,
|
||||
/**
|
||||
* @see {@link resourceDir} for more information.
|
||||
*/
|
||||
Resource = 11,
|
||||
/**
|
||||
* @see {@link tempDir} for more information.
|
||||
*/
|
||||
Temp = 12,
|
||||
/**
|
||||
* @see {@link appConfigDir} for more information.
|
||||
*/
|
||||
AppConfig = 13,
|
||||
/**
|
||||
* @see {@link appDataDir} for more information.
|
||||
*/
|
||||
AppData = 14,
|
||||
/**
|
||||
* @see {@link appLocalDataDir} for more information.
|
||||
*/
|
||||
AppLocalData = 15,
|
||||
/**
|
||||
* @see {@link appCacheDir} for more information.
|
||||
*/
|
||||
AppCache = 16,
|
||||
/**
|
||||
* @see {@link appLogDir} for more information.
|
||||
*/
|
||||
AppLog = 17,
|
||||
/**
|
||||
* @see {@link desktopDir} for more information.
|
||||
*/
|
||||
Desktop = 18,
|
||||
/**
|
||||
* @see {@link executableDir} for more information.
|
||||
*/
|
||||
Executable = 19,
|
||||
/**
|
||||
* @see {@link fontDir} for more information.
|
||||
*/
|
||||
Font = 20,
|
||||
/**
|
||||
* @see {@link homeDir} for more information.
|
||||
*/
|
||||
Home = 21,
|
||||
/**
|
||||
* @see {@link runtimeDir} for more information.
|
||||
*/
|
||||
Runtime = 22,
|
||||
/**
|
||||
* @see {@link templateDir} for more information.
|
||||
*/
|
||||
Template = 23
|
||||
}
|
||||
/**
|
||||
* Returns the path to the suggested directory for your app's config files.
|
||||
* Resolves to `${configDir}/${bundleIdentifier}`, where `bundleIdentifier` is the [`identifier`](https://v2.tauri.app/reference/config/#identifier) value configured in `tauri.conf.json`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { appConfigDir } from '@tauri-apps/api/path';
|
||||
* const appConfigDirPath = await appConfigDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
declare function appConfigDir(): Promise<string>;
|
||||
/**
|
||||
* Returns the path to the suggested directory for your app's data files.
|
||||
* Resolves to `${dataDir}/${bundleIdentifier}`, where `bundleIdentifier` is the [`identifier`](https://v2.tauri.app/reference/config/#identifier) value configured in `tauri.conf.json`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { appDataDir } from '@tauri-apps/api/path';
|
||||
* const appDataDirPath = await appDataDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
declare function appDataDir(): Promise<string>;
|
||||
/**
|
||||
* Returns the path to the suggested directory for your app's local data files.
|
||||
* Resolves to `${localDataDir}/${bundleIdentifier}`, where `bundleIdentifier` is the [`identifier`](https://v2.tauri.app/reference/config/#identifier) value configured in `tauri.conf.json`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { appLocalDataDir } from '@tauri-apps/api/path';
|
||||
* const appLocalDataDirPath = await appLocalDataDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
declare function appLocalDataDir(): Promise<string>;
|
||||
/**
|
||||
* Returns the path to the suggested directory for your app's cache files.
|
||||
* Resolves to `${cacheDir}/${bundleIdentifier}`, where `bundleIdentifier` is the [`identifier`](https://v2.tauri.app/reference/config/#identifier) value configured in `tauri.conf.json`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { appCacheDir } from '@tauri-apps/api/path';
|
||||
* const appCacheDirPath = await appCacheDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
declare function appCacheDir(): Promise<string>;
|
||||
/**
|
||||
* Returns the path to the user's audio directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)' `XDG_MUSIC_DIR`.
|
||||
* - **macOS:** Resolves to `$HOME/Music`.
|
||||
* - **Windows:** Resolves to `{FOLDERID_Music}`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { audioDir } from '@tauri-apps/api/path';
|
||||
* const audioDirPath = await audioDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
declare function audioDir(): Promise<string>;
|
||||
/**
|
||||
* Returns the path to the user's cache directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to `$XDG_CACHE_HOME` or `$HOME/.cache`.
|
||||
* - **macOS:** Resolves to `$HOME/Library/Caches`.
|
||||
* - **Windows:** Resolves to `{FOLDERID_LocalAppData}`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { cacheDir } from '@tauri-apps/api/path';
|
||||
* const cacheDirPath = await cacheDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
declare function cacheDir(): Promise<string>;
|
||||
/**
|
||||
* Returns the path to the user's config directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to `$XDG_CONFIG_HOME` or `$HOME/.config`.
|
||||
* - **macOS:** Resolves to `$HOME/Library/Application Support`.
|
||||
* - **Windows:** Resolves to `{FOLDERID_RoamingAppData}`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { configDir } from '@tauri-apps/api/path';
|
||||
* const configDirPath = await configDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
declare function configDir(): Promise<string>;
|
||||
/**
|
||||
* Returns the path to the user's data directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to `$XDG_DATA_HOME` or `$HOME/.local/share`.
|
||||
* - **macOS:** Resolves to `$HOME/Library/Application Support`.
|
||||
* - **Windows:** Resolves to `{FOLDERID_RoamingAppData}`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { dataDir } from '@tauri-apps/api/path';
|
||||
* const dataDirPath = await dataDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
declare function dataDir(): Promise<string>;
|
||||
/**
|
||||
* Returns the path to the user's desktop directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)' `XDG_DESKTOP_DIR`.
|
||||
* - **macOS:** Resolves to `$HOME/Desktop`.
|
||||
* - **Windows:** Resolves to `{FOLDERID_Desktop}`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { desktopDir } from '@tauri-apps/api/path';
|
||||
* const desktopPath = await desktopDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
declare function desktopDir(): Promise<string>;
|
||||
/**
|
||||
* Returns the path to the user's document directory.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { documentDir } from '@tauri-apps/api/path';
|
||||
* const documentDirPath = await documentDir();
|
||||
* ```
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)' `XDG_DOCUMENTS_DIR`.
|
||||
* - **macOS:** Resolves to `$HOME/Documents`.
|
||||
* - **Windows:** Resolves to `{FOLDERID_Documents}`.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
declare function documentDir(): Promise<string>;
|
||||
/**
|
||||
* Returns the path to the user's download directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux**: Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)' `XDG_DOWNLOAD_DIR`.
|
||||
* - **macOS**: Resolves to `$HOME/Downloads`.
|
||||
* - **Windows**: Resolves to `{FOLDERID_Downloads}`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { downloadDir } from '@tauri-apps/api/path';
|
||||
* const downloadDirPath = await downloadDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
declare function downloadDir(): Promise<string>;
|
||||
/**
|
||||
* Returns the path to the user's executable directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to `$XDG_BIN_HOME/../bin` or `$XDG_DATA_HOME/../bin` or `$HOME/.local/bin`.
|
||||
* - **macOS:** Not supported.
|
||||
* - **Windows:** Not supported.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { executableDir } from '@tauri-apps/api/path';
|
||||
* const executableDirPath = await executableDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
declare function executableDir(): Promise<string>;
|
||||
/**
|
||||
* Returns the path to the user's font directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to `$XDG_DATA_HOME/fonts` or `$HOME/.local/share/fonts`.
|
||||
* - **macOS:** Resolves to `$HOME/Library/Fonts`.
|
||||
* - **Windows:** Not supported.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { fontDir } from '@tauri-apps/api/path';
|
||||
* const fontDirPath = await fontDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
declare function fontDir(): Promise<string>;
|
||||
/**
|
||||
* Returns the path to the user's home directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to `$HOME`.
|
||||
* - **macOS:** Resolves to `$HOME`.
|
||||
* - **Windows:** Resolves to `{FOLDERID_Profile}`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { homeDir } from '@tauri-apps/api/path';
|
||||
* const homeDirPath = await homeDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
declare function homeDir(): Promise<string>;
|
||||
/**
|
||||
* Returns the path to the user's local data directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to `$XDG_DATA_HOME` or `$HOME/.local/share`.
|
||||
* - **macOS:** Resolves to `$HOME/Library/Application Support`.
|
||||
* - **Windows:** Resolves to `{FOLDERID_LocalAppData}`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { localDataDir } from '@tauri-apps/api/path';
|
||||
* const localDataDirPath = await localDataDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
declare function localDataDir(): Promise<string>;
|
||||
/**
|
||||
* Returns the path to the user's picture directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)' `XDG_PICTURES_DIR`.
|
||||
* - **macOS:** Resolves to `$HOME/Pictures`.
|
||||
* - **Windows:** Resolves to `{FOLDERID_Pictures}`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { pictureDir } from '@tauri-apps/api/path';
|
||||
* const pictureDirPath = await pictureDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
declare function pictureDir(): Promise<string>;
|
||||
/**
|
||||
* Returns the path to the user's public directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)' `XDG_PUBLICSHARE_DIR`.
|
||||
* - **macOS:** Resolves to `$HOME/Public`.
|
||||
* - **Windows:** Resolves to `{FOLDERID_Public}`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { publicDir } from '@tauri-apps/api/path';
|
||||
* const publicDirPath = await publicDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
declare function publicDir(): Promise<string>;
|
||||
/**
|
||||
* Returns the path to the application's resource directory.
|
||||
* To resolve a resource path, see the [[resolveResource | `resolveResource API`]].
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { resourceDir } from '@tauri-apps/api/path';
|
||||
* const resourceDirPath = await resourceDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
declare function resourceDir(): Promise<string>;
|
||||
/**
|
||||
* Resolve the path to a resource file.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { resolveResource } from '@tauri-apps/api/path';
|
||||
* const resourcePath = await resolveResource('script.sh');
|
||||
* ```
|
||||
*
|
||||
* @param resourcePath The path to the resource.
|
||||
* Must follow the same syntax as defined in `tauri.conf.json > bundle > resources`, i.e. keeping subfolders and parent dir components (`../`).
|
||||
* @returns The full path to the resource.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
declare function resolveResource(resourcePath: string): Promise<string>;
|
||||
/**
|
||||
* Returns the path to the user's runtime directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to `$XDG_RUNTIME_DIR`.
|
||||
* - **macOS:** Not supported.
|
||||
* - **Windows:** Not supported.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { runtimeDir } from '@tauri-apps/api/path';
|
||||
* const runtimeDirPath = await runtimeDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
declare function runtimeDir(): Promise<string>;
|
||||
/**
|
||||
* Returns the path to the user's template directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)' `XDG_TEMPLATES_DIR`.
|
||||
* - **macOS:** Not supported.
|
||||
* - **Windows:** Resolves to `{FOLDERID_Templates}`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { templateDir } from '@tauri-apps/api/path';
|
||||
* const templateDirPath = await templateDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
declare function templateDir(): Promise<string>;
|
||||
/**
|
||||
* Returns the path to the user's video directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)' `XDG_VIDEOS_DIR`.
|
||||
* - **macOS:** Resolves to `$HOME/Movies`.
|
||||
* - **Windows:** Resolves to `{FOLDERID_Videos}`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { videoDir } from '@tauri-apps/api/path';
|
||||
* const videoDirPath = await videoDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
declare function videoDir(): Promise<string>;
|
||||
/**
|
||||
* Returns the path to the suggested directory for your app's log files.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to `${configDir}/${bundleIdentifier}/logs`.
|
||||
* - **macOS:** Resolves to `${homeDir}/Library/Logs/{bundleIdentifier}`
|
||||
* - **Windows:** Resolves to `${configDir}/${bundleIdentifier}/logs`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { appLogDir } from '@tauri-apps/api/path';
|
||||
* const appLogDirPath = await appLogDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
declare function appLogDir(): Promise<string>;
|
||||
/**
|
||||
* Returns a temporary directory.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { tempDir } from '@tauri-apps/api/path';
|
||||
* const temp = await tempDir();
|
||||
* ```
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
declare function tempDir(): Promise<string>;
|
||||
/**
|
||||
* Returns the platform-specific path segment separator:
|
||||
* - `\` on Windows
|
||||
* - `/` on POSIX
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
declare function sep(): string;
|
||||
/**
|
||||
* Returns the platform-specific path segment delimiter:
|
||||
* - `;` on Windows
|
||||
* - `:` on POSIX
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
declare function delimiter(): string;
|
||||
/**
|
||||
* Resolves a sequence of `paths` or `path` segments into an absolute path.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { resolve, appDataDir } from '@tauri-apps/api/path';
|
||||
* const appDataDirPath = await appDataDir();
|
||||
* const path = await resolve(appDataDirPath, '..', 'users', 'tauri', 'avatar.png');
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
declare function resolve(...paths: string[]): Promise<string>;
|
||||
/**
|
||||
* Normalizes the given `path`, resolving `'..'` and `'.'` segments and resolve symbolic links.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { normalize, appDataDir } from '@tauri-apps/api/path';
|
||||
* const appDataDirPath = await appDataDir();
|
||||
* const path = await normalize(`${appDataDirPath}/../users/tauri/avatar.png`);
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
declare function normalize(path: string): Promise<string>;
|
||||
/**
|
||||
* Joins all given `path` segments together using the platform-specific separator as a delimiter, then normalizes the resulting path.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { join, appDataDir } from '@tauri-apps/api/path';
|
||||
* const appDataDirPath = await appDataDir();
|
||||
* const path = await join(appDataDirPath, 'users', 'tauri', 'avatar.png');
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
declare function join(...paths: string[]): Promise<string>;
|
||||
/**
|
||||
* Returns the directory name of a `path`. Trailing directory separators are ignored.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { dirname } from '@tauri-apps/api/path';
|
||||
* const dir = await dirname('/path/to/somedir/');
|
||||
* assert(dir === 'somedir');
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
declare function dirname(path: string): Promise<string>;
|
||||
/**
|
||||
* Returns the extension of the `path`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { extname } from '@tauri-apps/api/path';
|
||||
* const ext = await extname('/path/to/file.html');
|
||||
* assert(ext === 'html');
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
declare function extname(path: string): Promise<string>;
|
||||
/**
|
||||
* Returns the last portion of a `path`. Trailing directory separators are ignored.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { basename } from '@tauri-apps/api/path';
|
||||
* const base = await basename('path/to/app.conf');
|
||||
* assert(base === 'app.conf');
|
||||
* ```
|
||||
* @param ext An optional file extension to be removed from the returned path.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
declare function basename(path: string, ext?: string): Promise<string>;
|
||||
/**
|
||||
* Returns whether the path is absolute or not.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { isAbsolute } from '@tauri-apps/api/path';
|
||||
* assert(await isAbsolute('/home/tauri'));
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
declare function isAbsolute(path: string): Promise<boolean>;
|
||||
export { BaseDirectory, appConfigDir, appDataDir, appLocalDataDir, appCacheDir, appLogDir, audioDir, cacheDir, configDir, dataDir, desktopDir, documentDir, downloadDir, executableDir, fontDir, homeDir, localDataDir, pictureDir, publicDir, resourceDir, resolveResource, runtimeDir, templateDir, videoDir, sep, delimiter, resolve, normalize, join, dirname, extname, basename, isAbsolute, tempDir };
|
703
node_modules/@tauri-apps/api/path.js
generated
vendored
Normal file
703
node_modules/@tauri-apps/api/path.js
generated
vendored
Normal file
@ -0,0 +1,703 @@
|
||||
import { invoke } from './core.js';
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/**
|
||||
* The path module provides utilities for working with file and directory paths.
|
||||
*
|
||||
* This package is also accessible with `window.__TAURI__.path` when [`app.withGlobalTauri`](https://v2.tauri.app/reference/config/#withglobaltauri) in `tauri.conf.json` is set to `true`.
|
||||
*
|
||||
* It is recommended to allowlist only the APIs you use for optimal bundle size and security.
|
||||
* @module
|
||||
*/
|
||||
/**
|
||||
* @since 2.0.0
|
||||
*/
|
||||
var BaseDirectory;
|
||||
(function (BaseDirectory) {
|
||||
/**
|
||||
* @see {@link audioDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["Audio"] = 1] = "Audio";
|
||||
/**
|
||||
* @see {@link cacheDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["Cache"] = 2] = "Cache";
|
||||
/**
|
||||
* @see {@link configDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["Config"] = 3] = "Config";
|
||||
/**
|
||||
* @see {@link dataDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["Data"] = 4] = "Data";
|
||||
/**
|
||||
* @see {@link localDataDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["LocalData"] = 5] = "LocalData";
|
||||
/**
|
||||
* @see {@link documentDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["Document"] = 6] = "Document";
|
||||
/**
|
||||
* @see {@link downloadDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["Download"] = 7] = "Download";
|
||||
/**
|
||||
* @see {@link pictureDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["Picture"] = 8] = "Picture";
|
||||
/**
|
||||
* @see {@link publicDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["Public"] = 9] = "Public";
|
||||
/**
|
||||
* @see {@link videoDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["Video"] = 10] = "Video";
|
||||
/**
|
||||
* @see {@link resourceDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["Resource"] = 11] = "Resource";
|
||||
/**
|
||||
* @see {@link tempDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["Temp"] = 12] = "Temp";
|
||||
/**
|
||||
* @see {@link appConfigDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["AppConfig"] = 13] = "AppConfig";
|
||||
/**
|
||||
* @see {@link appDataDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["AppData"] = 14] = "AppData";
|
||||
/**
|
||||
* @see {@link appLocalDataDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["AppLocalData"] = 15] = "AppLocalData";
|
||||
/**
|
||||
* @see {@link appCacheDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["AppCache"] = 16] = "AppCache";
|
||||
/**
|
||||
* @see {@link appLogDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["AppLog"] = 17] = "AppLog";
|
||||
/**
|
||||
* @see {@link desktopDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["Desktop"] = 18] = "Desktop";
|
||||
/**
|
||||
* @see {@link executableDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["Executable"] = 19] = "Executable";
|
||||
/**
|
||||
* @see {@link fontDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["Font"] = 20] = "Font";
|
||||
/**
|
||||
* @see {@link homeDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["Home"] = 21] = "Home";
|
||||
/**
|
||||
* @see {@link runtimeDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["Runtime"] = 22] = "Runtime";
|
||||
/**
|
||||
* @see {@link templateDir} for more information.
|
||||
*/
|
||||
BaseDirectory[BaseDirectory["Template"] = 23] = "Template";
|
||||
})(BaseDirectory || (BaseDirectory = {}));
|
||||
/**
|
||||
* Returns the path to the suggested directory for your app's config files.
|
||||
* Resolves to `${configDir}/${bundleIdentifier}`, where `bundleIdentifier` is the [`identifier`](https://v2.tauri.app/reference/config/#identifier) value configured in `tauri.conf.json`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { appConfigDir } from '@tauri-apps/api/path';
|
||||
* const appConfigDirPath = await appConfigDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
async function appConfigDir() {
|
||||
return invoke('plugin:path|resolve_directory', {
|
||||
directory: BaseDirectory.AppConfig
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the suggested directory for your app's data files.
|
||||
* Resolves to `${dataDir}/${bundleIdentifier}`, where `bundleIdentifier` is the [`identifier`](https://v2.tauri.app/reference/config/#identifier) value configured in `tauri.conf.json`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { appDataDir } from '@tauri-apps/api/path';
|
||||
* const appDataDirPath = await appDataDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
async function appDataDir() {
|
||||
return invoke('plugin:path|resolve_directory', {
|
||||
directory: BaseDirectory.AppData
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the suggested directory for your app's local data files.
|
||||
* Resolves to `${localDataDir}/${bundleIdentifier}`, where `bundleIdentifier` is the [`identifier`](https://v2.tauri.app/reference/config/#identifier) value configured in `tauri.conf.json`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { appLocalDataDir } from '@tauri-apps/api/path';
|
||||
* const appLocalDataDirPath = await appLocalDataDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
async function appLocalDataDir() {
|
||||
return invoke('plugin:path|resolve_directory', {
|
||||
directory: BaseDirectory.AppLocalData
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the suggested directory for your app's cache files.
|
||||
* Resolves to `${cacheDir}/${bundleIdentifier}`, where `bundleIdentifier` is the [`identifier`](https://v2.tauri.app/reference/config/#identifier) value configured in `tauri.conf.json`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { appCacheDir } from '@tauri-apps/api/path';
|
||||
* const appCacheDirPath = await appCacheDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
async function appCacheDir() {
|
||||
return invoke('plugin:path|resolve_directory', {
|
||||
directory: BaseDirectory.AppCache
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the user's audio directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)' `XDG_MUSIC_DIR`.
|
||||
* - **macOS:** Resolves to `$HOME/Music`.
|
||||
* - **Windows:** Resolves to `{FOLDERID_Music}`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { audioDir } from '@tauri-apps/api/path';
|
||||
* const audioDirPath = await audioDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function audioDir() {
|
||||
return invoke('plugin:path|resolve_directory', {
|
||||
directory: BaseDirectory.Audio
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the user's cache directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to `$XDG_CACHE_HOME` or `$HOME/.cache`.
|
||||
* - **macOS:** Resolves to `$HOME/Library/Caches`.
|
||||
* - **Windows:** Resolves to `{FOLDERID_LocalAppData}`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { cacheDir } from '@tauri-apps/api/path';
|
||||
* const cacheDirPath = await cacheDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function cacheDir() {
|
||||
return invoke('plugin:path|resolve_directory', {
|
||||
directory: BaseDirectory.Cache
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the user's config directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to `$XDG_CONFIG_HOME` or `$HOME/.config`.
|
||||
* - **macOS:** Resolves to `$HOME/Library/Application Support`.
|
||||
* - **Windows:** Resolves to `{FOLDERID_RoamingAppData}`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { configDir } from '@tauri-apps/api/path';
|
||||
* const configDirPath = await configDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function configDir() {
|
||||
return invoke('plugin:path|resolve_directory', {
|
||||
directory: BaseDirectory.Config
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the user's data directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to `$XDG_DATA_HOME` or `$HOME/.local/share`.
|
||||
* - **macOS:** Resolves to `$HOME/Library/Application Support`.
|
||||
* - **Windows:** Resolves to `{FOLDERID_RoamingAppData}`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { dataDir } from '@tauri-apps/api/path';
|
||||
* const dataDirPath = await dataDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function dataDir() {
|
||||
return invoke('plugin:path|resolve_directory', {
|
||||
directory: BaseDirectory.Data
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the user's desktop directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)' `XDG_DESKTOP_DIR`.
|
||||
* - **macOS:** Resolves to `$HOME/Desktop`.
|
||||
* - **Windows:** Resolves to `{FOLDERID_Desktop}`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { desktopDir } from '@tauri-apps/api/path';
|
||||
* const desktopPath = await desktopDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function desktopDir() {
|
||||
return invoke('plugin:path|resolve_directory', {
|
||||
directory: BaseDirectory.Desktop
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the user's document directory.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { documentDir } from '@tauri-apps/api/path';
|
||||
* const documentDirPath = await documentDir();
|
||||
* ```
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)' `XDG_DOCUMENTS_DIR`.
|
||||
* - **macOS:** Resolves to `$HOME/Documents`.
|
||||
* - **Windows:** Resolves to `{FOLDERID_Documents}`.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function documentDir() {
|
||||
return invoke('plugin:path|resolve_directory', {
|
||||
directory: BaseDirectory.Document
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the user's download directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux**: Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)' `XDG_DOWNLOAD_DIR`.
|
||||
* - **macOS**: Resolves to `$HOME/Downloads`.
|
||||
* - **Windows**: Resolves to `{FOLDERID_Downloads}`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { downloadDir } from '@tauri-apps/api/path';
|
||||
* const downloadDirPath = await downloadDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function downloadDir() {
|
||||
return invoke('plugin:path|resolve_directory', {
|
||||
directory: BaseDirectory.Download
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the user's executable directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to `$XDG_BIN_HOME/../bin` or `$XDG_DATA_HOME/../bin` or `$HOME/.local/bin`.
|
||||
* - **macOS:** Not supported.
|
||||
* - **Windows:** Not supported.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { executableDir } from '@tauri-apps/api/path';
|
||||
* const executableDirPath = await executableDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function executableDir() {
|
||||
return invoke('plugin:path|resolve_directory', {
|
||||
directory: BaseDirectory.Executable
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the user's font directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to `$XDG_DATA_HOME/fonts` or `$HOME/.local/share/fonts`.
|
||||
* - **macOS:** Resolves to `$HOME/Library/Fonts`.
|
||||
* - **Windows:** Not supported.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { fontDir } from '@tauri-apps/api/path';
|
||||
* const fontDirPath = await fontDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function fontDir() {
|
||||
return invoke('plugin:path|resolve_directory', {
|
||||
directory: BaseDirectory.Font
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the user's home directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to `$HOME`.
|
||||
* - **macOS:** Resolves to `$HOME`.
|
||||
* - **Windows:** Resolves to `{FOLDERID_Profile}`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { homeDir } from '@tauri-apps/api/path';
|
||||
* const homeDirPath = await homeDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function homeDir() {
|
||||
return invoke('plugin:path|resolve_directory', {
|
||||
directory: BaseDirectory.Home
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the user's local data directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to `$XDG_DATA_HOME` or `$HOME/.local/share`.
|
||||
* - **macOS:** Resolves to `$HOME/Library/Application Support`.
|
||||
* - **Windows:** Resolves to `{FOLDERID_LocalAppData}`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { localDataDir } from '@tauri-apps/api/path';
|
||||
* const localDataDirPath = await localDataDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function localDataDir() {
|
||||
return invoke('plugin:path|resolve_directory', {
|
||||
directory: BaseDirectory.LocalData
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the user's picture directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)' `XDG_PICTURES_DIR`.
|
||||
* - **macOS:** Resolves to `$HOME/Pictures`.
|
||||
* - **Windows:** Resolves to `{FOLDERID_Pictures}`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { pictureDir } from '@tauri-apps/api/path';
|
||||
* const pictureDirPath = await pictureDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function pictureDir() {
|
||||
return invoke('plugin:path|resolve_directory', {
|
||||
directory: BaseDirectory.Picture
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the user's public directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)' `XDG_PUBLICSHARE_DIR`.
|
||||
* - **macOS:** Resolves to `$HOME/Public`.
|
||||
* - **Windows:** Resolves to `{FOLDERID_Public}`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { publicDir } from '@tauri-apps/api/path';
|
||||
* const publicDirPath = await publicDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function publicDir() {
|
||||
return invoke('plugin:path|resolve_directory', {
|
||||
directory: BaseDirectory.Public
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the application's resource directory.
|
||||
* To resolve a resource path, see the [[resolveResource | `resolveResource API`]].
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { resourceDir } from '@tauri-apps/api/path';
|
||||
* const resourceDirPath = await resourceDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function resourceDir() {
|
||||
return invoke('plugin:path|resolve_directory', {
|
||||
directory: BaseDirectory.Resource
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Resolve the path to a resource file.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { resolveResource } from '@tauri-apps/api/path';
|
||||
* const resourcePath = await resolveResource('script.sh');
|
||||
* ```
|
||||
*
|
||||
* @param resourcePath The path to the resource.
|
||||
* Must follow the same syntax as defined in `tauri.conf.json > bundle > resources`, i.e. keeping subfolders and parent dir components (`../`).
|
||||
* @returns The full path to the resource.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function resolveResource(resourcePath) {
|
||||
return invoke('plugin:path|resolve_directory', {
|
||||
directory: BaseDirectory.Resource,
|
||||
path: resourcePath
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the user's runtime directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to `$XDG_RUNTIME_DIR`.
|
||||
* - **macOS:** Not supported.
|
||||
* - **Windows:** Not supported.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { runtimeDir } from '@tauri-apps/api/path';
|
||||
* const runtimeDirPath = await runtimeDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function runtimeDir() {
|
||||
return invoke('plugin:path|resolve_directory', {
|
||||
directory: BaseDirectory.Runtime
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the user's template directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)' `XDG_TEMPLATES_DIR`.
|
||||
* - **macOS:** Not supported.
|
||||
* - **Windows:** Resolves to `{FOLDERID_Templates}`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { templateDir } from '@tauri-apps/api/path';
|
||||
* const templateDirPath = await templateDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function templateDir() {
|
||||
return invoke('plugin:path|resolve_directory', {
|
||||
directory: BaseDirectory.Template
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the user's video directory.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to [`xdg-user-dirs`](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/)' `XDG_VIDEOS_DIR`.
|
||||
* - **macOS:** Resolves to `$HOME/Movies`.
|
||||
* - **Windows:** Resolves to `{FOLDERID_Videos}`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { videoDir } from '@tauri-apps/api/path';
|
||||
* const videoDirPath = await videoDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function videoDir() {
|
||||
return invoke('plugin:path|resolve_directory', {
|
||||
directory: BaseDirectory.Video
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the path to the suggested directory for your app's log files.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** Resolves to `${configDir}/${bundleIdentifier}/logs`.
|
||||
* - **macOS:** Resolves to `${homeDir}/Library/Logs/{bundleIdentifier}`
|
||||
* - **Windows:** Resolves to `${configDir}/${bundleIdentifier}/logs`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { appLogDir } from '@tauri-apps/api/path';
|
||||
* const appLogDirPath = await appLogDir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
async function appLogDir() {
|
||||
return invoke('plugin:path|resolve_directory', {
|
||||
directory: BaseDirectory.AppLog
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns a temporary directory.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { tempDir } from '@tauri-apps/api/path';
|
||||
* const temp = await tempDir();
|
||||
* ```
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function tempDir() {
|
||||
return invoke('plugin:path|resolve_directory', {
|
||||
directory: BaseDirectory.Temp
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns the platform-specific path segment separator:
|
||||
* - `\` on Windows
|
||||
* - `/` on POSIX
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
function sep() {
|
||||
return window.__TAURI_INTERNALS__.plugins.path.sep;
|
||||
}
|
||||
/**
|
||||
* Returns the platform-specific path segment delimiter:
|
||||
* - `;` on Windows
|
||||
* - `:` on POSIX
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
function delimiter() {
|
||||
return window.__TAURI_INTERNALS__.plugins.path.delimiter;
|
||||
}
|
||||
/**
|
||||
* Resolves a sequence of `paths` or `path` segments into an absolute path.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { resolve, appDataDir } from '@tauri-apps/api/path';
|
||||
* const appDataDirPath = await appDataDir();
|
||||
* const path = await resolve(appDataDirPath, '..', 'users', 'tauri', 'avatar.png');
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function resolve(...paths) {
|
||||
return invoke('plugin:path|resolve', { paths });
|
||||
}
|
||||
/**
|
||||
* Normalizes the given `path`, resolving `'..'` and `'.'` segments and resolve symbolic links.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { normalize, appDataDir } from '@tauri-apps/api/path';
|
||||
* const appDataDirPath = await appDataDir();
|
||||
* const path = await normalize(`${appDataDirPath}/../users/tauri/avatar.png`);
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function normalize(path) {
|
||||
return invoke('plugin:path|normalize', { path });
|
||||
}
|
||||
/**
|
||||
* Joins all given `path` segments together using the platform-specific separator as a delimiter, then normalizes the resulting path.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { join, appDataDir } from '@tauri-apps/api/path';
|
||||
* const appDataDirPath = await appDataDir();
|
||||
* const path = await join(appDataDirPath, 'users', 'tauri', 'avatar.png');
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function join(...paths) {
|
||||
return invoke('plugin:path|join', { paths });
|
||||
}
|
||||
/**
|
||||
* Returns the directory name of a `path`. Trailing directory separators are ignored.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { dirname } from '@tauri-apps/api/path';
|
||||
* const dir = await dirname('/path/to/somedir/');
|
||||
* assert(dir === 'somedir');
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function dirname(path) {
|
||||
return invoke('plugin:path|dirname', { path });
|
||||
}
|
||||
/**
|
||||
* Returns the extension of the `path`.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { extname } from '@tauri-apps/api/path';
|
||||
* const ext = await extname('/path/to/file.html');
|
||||
* assert(ext === 'html');
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function extname(path) {
|
||||
return invoke('plugin:path|extname', { path });
|
||||
}
|
||||
/**
|
||||
* Returns the last portion of a `path`. Trailing directory separators are ignored.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { basename } from '@tauri-apps/api/path';
|
||||
* const base = await basename('path/to/app.conf');
|
||||
* assert(base === 'app.conf');
|
||||
* ```
|
||||
* @param ext An optional file extension to be removed from the returned path.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function basename(path, ext) {
|
||||
return invoke('plugin:path|basename', { path, ext });
|
||||
}
|
||||
/**
|
||||
* Returns whether the path is absolute or not.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { isAbsolute } from '@tauri-apps/api/path';
|
||||
* assert(await isAbsolute('/home/tauri'));
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function isAbsolute(path) {
|
||||
return invoke('plugin:path|is_absolute', { path });
|
||||
}
|
||||
|
||||
export { BaseDirectory, appCacheDir, appConfigDir, appDataDir, appLocalDataDir, appLogDir, audioDir, basename, cacheDir, configDir, dataDir, delimiter, desktopDir, dirname, documentDir, downloadDir, executableDir, extname, fontDir, homeDir, isAbsolute, join, localDataDir, normalize, pictureDir, publicDir, resolve, resolveResource, resourceDir, runtimeDir, sep, tempDir, templateDir, videoDir };
|
188
node_modules/@tauri-apps/api/tray.cjs
generated
vendored
Normal file
188
node_modules/@tauri-apps/api/tray.cjs
generated
vendored
Normal file
@ -0,0 +1,188 @@
|
||||
'use strict';
|
||||
|
||||
var core = require('./core.cjs');
|
||||
var image = require('./image.cjs');
|
||||
var dpi = require('./dpi.cjs');
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/**
|
||||
* Tray icon class and associated methods. This type constructor is private,
|
||||
* instead, you should use the static method {@linkcode TrayIcon.new}.
|
||||
*
|
||||
* #### Warning
|
||||
*
|
||||
* Unlike Rust, javascript does not have any way to run cleanup code
|
||||
* when an object is being removed by garbage collection, but this tray icon
|
||||
* will be cleaned up when the tauri app exists, however if you want to cleanup
|
||||
* this object early, you need to call {@linkcode TrayIcon.close}.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* import { TrayIcon } from '@tauri-apps/api/tray';
|
||||
* const tray = await TrayIcon.new({ tooltip: 'awesome tray tooltip' });
|
||||
* tray.set_tooltip('new tooltip');
|
||||
* ```
|
||||
*/
|
||||
class TrayIcon extends core.Resource {
|
||||
constructor(rid, id) {
|
||||
super(rid);
|
||||
this.id = id;
|
||||
}
|
||||
/** Gets a tray icon using the provided id. */
|
||||
static async getById(id) {
|
||||
return core.invoke('plugin:tray|get_by_id', { id }).then((rid) => rid ? new TrayIcon(rid, id) : null);
|
||||
}
|
||||
/**
|
||||
* Removes a tray icon using the provided id from tauri's internal state.
|
||||
*
|
||||
* Note that this may cause the tray icon to disappear
|
||||
* if it wasn't cloned somewhere else or referenced by JS.
|
||||
*/
|
||||
static async removeById(id) {
|
||||
return core.invoke('plugin:tray|remove_by_id', { id });
|
||||
}
|
||||
/**
|
||||
* Creates a new {@linkcode TrayIcon}
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Linux:** Sometimes the icon won't be visible unless a menu is set.
|
||||
* Setting an empty {@linkcode Menu} is enough.
|
||||
*/
|
||||
static async new(options) {
|
||||
if (options === null || options === void 0 ? void 0 : options.menu) {
|
||||
// @ts-expect-error we only need the rid and kind
|
||||
options.menu = [options.menu.rid, options.menu.kind];
|
||||
}
|
||||
if (options === null || options === void 0 ? void 0 : options.icon) {
|
||||
options.icon = image.transformImage(options.icon);
|
||||
}
|
||||
const handler = new core.Channel();
|
||||
if (options === null || options === void 0 ? void 0 : options.action) {
|
||||
const action = options.action;
|
||||
handler.onmessage = (e) => action(mapEvent(e));
|
||||
delete options.action;
|
||||
}
|
||||
return core.invoke('plugin:tray|new', {
|
||||
options: options !== null && options !== void 0 ? options : {},
|
||||
handler
|
||||
}).then(([rid, id]) => new TrayIcon(rid, id));
|
||||
}
|
||||
/**
|
||||
* Sets a new tray icon. If `null` is provided, it will remove the icon.
|
||||
*
|
||||
* Note that you may need the `image-ico` or `image-png` Cargo features to use this API.
|
||||
* To enable it, change your Cargo.toml file:
|
||||
* ```toml
|
||||
* [dependencies]
|
||||
* tauri = { version = "...", features = ["...", "image-png"] }
|
||||
* ```
|
||||
*/
|
||||
async setIcon(icon) {
|
||||
let trayIcon = null;
|
||||
if (icon) {
|
||||
trayIcon = image.transformImage(icon);
|
||||
}
|
||||
return core.invoke('plugin:tray|set_icon', { rid: this.rid, icon: trayIcon });
|
||||
}
|
||||
/**
|
||||
* Sets a new tray menu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Linux**: once a menu is set it cannot be removed so `null` has no effect
|
||||
*/
|
||||
async setMenu(menu) {
|
||||
if (menu) {
|
||||
// @ts-expect-error we only need the rid and kind
|
||||
menu = [menu.rid, menu.kind];
|
||||
}
|
||||
return core.invoke('plugin:tray|set_menu', { rid: this.rid, menu });
|
||||
}
|
||||
/**
|
||||
* Sets the tooltip for this tray icon.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Linux:** Unsupported
|
||||
*/
|
||||
async setTooltip(tooltip) {
|
||||
return core.invoke('plugin:tray|set_tooltip', { rid: this.rid, tooltip });
|
||||
}
|
||||
/**
|
||||
* Sets the tooltip for this tray icon.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Linux:** The title will not be shown unless there is an icon
|
||||
* as well. The title is useful for numerical and other frequently
|
||||
* updated information. In general, it shouldn't be shown unless a
|
||||
* user requests it as it can take up a significant amount of space
|
||||
* on the user's panel. This may not be shown in all visualizations.
|
||||
* - **Windows:** Unsupported
|
||||
*/
|
||||
async setTitle(title) {
|
||||
return core.invoke('plugin:tray|set_title', { rid: this.rid, title });
|
||||
}
|
||||
/** Show or hide this tray icon. */
|
||||
async setVisible(visible) {
|
||||
return core.invoke('plugin:tray|set_visible', { rid: this.rid, visible });
|
||||
}
|
||||
/**
|
||||
* Sets the tray icon temp dir path. **Linux only**.
|
||||
*
|
||||
* On Linux, we need to write the icon to the disk and usually it will
|
||||
* be `$XDG_RUNTIME_DIR/tray-icon` or `$TEMP/tray-icon`.
|
||||
*/
|
||||
async setTempDirPath(path) {
|
||||
return core.invoke('plugin:tray|set_temp_dir_path', { rid: this.rid, path });
|
||||
}
|
||||
/** Sets the current icon as a [template](https://developer.apple.com/documentation/appkit/nsimage/1520017-template?language=objc). **macOS only** */
|
||||
async setIconAsTemplate(asTemplate) {
|
||||
return core.invoke('plugin:tray|set_icon_as_template', {
|
||||
rid: this.rid,
|
||||
asTemplate
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Disable or enable showing the tray menu on left click.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Linux**: Unsupported.
|
||||
*
|
||||
* @deprecated use {@linkcode TrayIcon.setShowMenuOnLeftClick} instead.
|
||||
*/
|
||||
async setMenuOnLeftClick(onLeft) {
|
||||
return core.invoke('plugin:tray|set_show_menu_on_left_click', {
|
||||
rid: this.rid,
|
||||
onLeft
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Disable or enable showing the tray menu on left click.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Linux**: Unsupported.
|
||||
*
|
||||
* @since 2.2.0
|
||||
*/
|
||||
async setShowMenuOnLeftClick(onLeft) {
|
||||
return core.invoke('plugin:tray|set_show_menu_on_left_click', {
|
||||
rid: this.rid,
|
||||
onLeft
|
||||
});
|
||||
}
|
||||
}
|
||||
function mapEvent(e) {
|
||||
const out = e;
|
||||
out.position = new dpi.PhysicalPosition(e.position);
|
||||
out.rect.position = new dpi.PhysicalPosition(e.rect.position);
|
||||
out.rect.size = new dpi.PhysicalSize(e.rect.size);
|
||||
return out;
|
||||
}
|
||||
|
||||
exports.TrayIcon = TrayIcon;
|
219
node_modules/@tauri-apps/api/tray.d.ts
generated
vendored
Normal file
219
node_modules/@tauri-apps/api/tray.d.ts
generated
vendored
Normal file
@ -0,0 +1,219 @@
|
||||
import type { Menu, Submenu } from './menu';
|
||||
import { Resource } from './core';
|
||||
import { Image } from './image';
|
||||
import { PhysicalPosition, PhysicalSize } from './dpi';
|
||||
export type MouseButtonState = 'Up' | 'Down';
|
||||
export type MouseButton = 'Left' | 'Right' | 'Middle';
|
||||
export type TrayIconEventType = 'Click' | 'DoubleClick' | 'Enter' | 'Move' | 'Leave';
|
||||
export type TrayIconEventBase<T extends TrayIconEventType> = {
|
||||
/** The tray icon event type */
|
||||
type: T;
|
||||
/** Id of the tray icon which triggered this event. */
|
||||
id: string;
|
||||
/** Physical position of the click the triggered this event. */
|
||||
position: PhysicalPosition;
|
||||
/** Position and size of the tray icon. */
|
||||
rect: {
|
||||
position: PhysicalPosition;
|
||||
size: PhysicalSize;
|
||||
};
|
||||
};
|
||||
export type TrayIconClickEvent = {
|
||||
/** Mouse button that triggered this event. */
|
||||
button: MouseButton;
|
||||
/** Mouse button state when this event was triggered. */
|
||||
buttonState: MouseButtonState;
|
||||
};
|
||||
/**
|
||||
* Describes a tray icon event.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Linux**: Unsupported. The event is not emitted even though the icon is shown,
|
||||
* the icon will still show a context menu on right click.
|
||||
*/
|
||||
export type TrayIconEvent = (TrayIconEventBase<'Click'> & TrayIconClickEvent) | (TrayIconEventBase<'DoubleClick'> & Omit<TrayIconClickEvent, 'buttonState'>) | TrayIconEventBase<'Enter'> | TrayIconEventBase<'Move'> | TrayIconEventBase<'Leave'>;
|
||||
/**
|
||||
* Tray icon types and utilities.
|
||||
*
|
||||
* This package is also accessible with `window.__TAURI__.tray` when [`app.withGlobalTauri`](https://v2.tauri.app/reference/config/#withglobaltauri) in `tauri.conf.json` is set to `true`.
|
||||
* @module
|
||||
*/
|
||||
/** {@link TrayIcon.new|`TrayIcon`} creation options */
|
||||
export interface TrayIconOptions {
|
||||
/** The tray icon id. If undefined, a random one will be assigned */
|
||||
id?: string;
|
||||
/** The tray icon menu */
|
||||
menu?: Menu | Submenu;
|
||||
/**
|
||||
* The tray icon which could be icon bytes or path to the icon file.
|
||||
*
|
||||
* Note that you may need the `image-ico` or `image-png` Cargo features to use this API.
|
||||
* To enable it, change your Cargo.toml file:
|
||||
* ```toml
|
||||
* [dependencies]
|
||||
* tauri = { version = "...", features = ["...", "image-png"] }
|
||||
* ```
|
||||
*/
|
||||
icon?: string | Uint8Array | ArrayBuffer | number[] | Image;
|
||||
/** The tray icon tooltip */
|
||||
tooltip?: string;
|
||||
/**
|
||||
* The tray title
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Linux:** The title will not be shown unless there is an icon
|
||||
* as well. The title is useful for numerical and other frequently
|
||||
* updated information. In general, it shouldn't be shown unless a
|
||||
* user requests it as it can take up a significant amount of space
|
||||
* on the user's panel. This may not be shown in all visualizations.
|
||||
* - **Windows:** Unsupported.
|
||||
*/
|
||||
title?: string;
|
||||
/**
|
||||
* The tray icon temp dir path. **Linux only**.
|
||||
*
|
||||
* On Linux, we need to write the icon to the disk and usually it will
|
||||
* be `$XDG_RUNTIME_DIR/tray-icon` or `$TEMP/tray-icon`.
|
||||
*/
|
||||
tempDirPath?: string;
|
||||
/**
|
||||
* Use the icon as a [template](https://developer.apple.com/documentation/appkit/nsimage/1520017-template?language=objc). **macOS only**.
|
||||
*/
|
||||
iconAsTemplate?: boolean;
|
||||
/**
|
||||
* Whether to show the tray menu on left click or not, default is `true`.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Linux**: Unsupported.
|
||||
*
|
||||
* @deprecated use {@linkcode TrayIconOptions.showMenuOnLeftClick} instead.
|
||||
*/
|
||||
menuOnLeftClick?: boolean;
|
||||
/**
|
||||
* Whether to show the tray menu on left click or not, default is `true`.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Linux**: Unsupported.
|
||||
*
|
||||
* @since 2.2.0
|
||||
*/
|
||||
showMenuOnLeftClick?: boolean;
|
||||
/** A handler for an event on the tray icon. */
|
||||
action?: (event: TrayIconEvent) => void;
|
||||
}
|
||||
/**
|
||||
* Tray icon class and associated methods. This type constructor is private,
|
||||
* instead, you should use the static method {@linkcode TrayIcon.new}.
|
||||
*
|
||||
* #### Warning
|
||||
*
|
||||
* Unlike Rust, javascript does not have any way to run cleanup code
|
||||
* when an object is being removed by garbage collection, but this tray icon
|
||||
* will be cleaned up when the tauri app exists, however if you want to cleanup
|
||||
* this object early, you need to call {@linkcode TrayIcon.close}.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* import { TrayIcon } from '@tauri-apps/api/tray';
|
||||
* const tray = await TrayIcon.new({ tooltip: 'awesome tray tooltip' });
|
||||
* tray.set_tooltip('new tooltip');
|
||||
* ```
|
||||
*/
|
||||
export declare class TrayIcon extends Resource {
|
||||
/** The id associated with this tray icon. */
|
||||
id: string;
|
||||
private constructor();
|
||||
/** Gets a tray icon using the provided id. */
|
||||
static getById(id: string): Promise<TrayIcon | null>;
|
||||
/**
|
||||
* Removes a tray icon using the provided id from tauri's internal state.
|
||||
*
|
||||
* Note that this may cause the tray icon to disappear
|
||||
* if it wasn't cloned somewhere else or referenced by JS.
|
||||
*/
|
||||
static removeById(id: string): Promise<void>;
|
||||
/**
|
||||
* Creates a new {@linkcode TrayIcon}
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Linux:** Sometimes the icon won't be visible unless a menu is set.
|
||||
* Setting an empty {@linkcode Menu} is enough.
|
||||
*/
|
||||
static new(options?: TrayIconOptions): Promise<TrayIcon>;
|
||||
/**
|
||||
* Sets a new tray icon. If `null` is provided, it will remove the icon.
|
||||
*
|
||||
* Note that you may need the `image-ico` or `image-png` Cargo features to use this API.
|
||||
* To enable it, change your Cargo.toml file:
|
||||
* ```toml
|
||||
* [dependencies]
|
||||
* tauri = { version = "...", features = ["...", "image-png"] }
|
||||
* ```
|
||||
*/
|
||||
setIcon(icon: string | Image | Uint8Array | ArrayBuffer | number[] | null): Promise<void>;
|
||||
/**
|
||||
* Sets a new tray menu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Linux**: once a menu is set it cannot be removed so `null` has no effect
|
||||
*/
|
||||
setMenu(menu: Menu | Submenu | null): Promise<void>;
|
||||
/**
|
||||
* Sets the tooltip for this tray icon.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Linux:** Unsupported
|
||||
*/
|
||||
setTooltip(tooltip: string | null): Promise<void>;
|
||||
/**
|
||||
* Sets the tooltip for this tray icon.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Linux:** The title will not be shown unless there is an icon
|
||||
* as well. The title is useful for numerical and other frequently
|
||||
* updated information. In general, it shouldn't be shown unless a
|
||||
* user requests it as it can take up a significant amount of space
|
||||
* on the user's panel. This may not be shown in all visualizations.
|
||||
* - **Windows:** Unsupported
|
||||
*/
|
||||
setTitle(title: string | null): Promise<void>;
|
||||
/** Show or hide this tray icon. */
|
||||
setVisible(visible: boolean): Promise<void>;
|
||||
/**
|
||||
* Sets the tray icon temp dir path. **Linux only**.
|
||||
*
|
||||
* On Linux, we need to write the icon to the disk and usually it will
|
||||
* be `$XDG_RUNTIME_DIR/tray-icon` or `$TEMP/tray-icon`.
|
||||
*/
|
||||
setTempDirPath(path: string | null): Promise<void>;
|
||||
/** Sets the current icon as a [template](https://developer.apple.com/documentation/appkit/nsimage/1520017-template?language=objc). **macOS only** */
|
||||
setIconAsTemplate(asTemplate: boolean): Promise<void>;
|
||||
/**
|
||||
* Disable or enable showing the tray menu on left click.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Linux**: Unsupported.
|
||||
*
|
||||
* @deprecated use {@linkcode TrayIcon.setShowMenuOnLeftClick} instead.
|
||||
*/
|
||||
setMenuOnLeftClick(onLeft: boolean): Promise<void>;
|
||||
/**
|
||||
* Disable or enable showing the tray menu on left click.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Linux**: Unsupported.
|
||||
*
|
||||
* @since 2.2.0
|
||||
*/
|
||||
setShowMenuOnLeftClick(onLeft: boolean): Promise<void>;
|
||||
}
|
186
node_modules/@tauri-apps/api/tray.js
generated
vendored
Normal file
186
node_modules/@tauri-apps/api/tray.js
generated
vendored
Normal file
@ -0,0 +1,186 @@
|
||||
import { Resource, invoke, Channel } from './core.js';
|
||||
import { transformImage } from './image.js';
|
||||
import { PhysicalPosition, PhysicalSize } from './dpi.js';
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/**
|
||||
* Tray icon class and associated methods. This type constructor is private,
|
||||
* instead, you should use the static method {@linkcode TrayIcon.new}.
|
||||
*
|
||||
* #### Warning
|
||||
*
|
||||
* Unlike Rust, javascript does not have any way to run cleanup code
|
||||
* when an object is being removed by garbage collection, but this tray icon
|
||||
* will be cleaned up when the tauri app exists, however if you want to cleanup
|
||||
* this object early, you need to call {@linkcode TrayIcon.close}.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* import { TrayIcon } from '@tauri-apps/api/tray';
|
||||
* const tray = await TrayIcon.new({ tooltip: 'awesome tray tooltip' });
|
||||
* tray.set_tooltip('new tooltip');
|
||||
* ```
|
||||
*/
|
||||
class TrayIcon extends Resource {
|
||||
constructor(rid, id) {
|
||||
super(rid);
|
||||
this.id = id;
|
||||
}
|
||||
/** Gets a tray icon using the provided id. */
|
||||
static async getById(id) {
|
||||
return invoke('plugin:tray|get_by_id', { id }).then((rid) => rid ? new TrayIcon(rid, id) : null);
|
||||
}
|
||||
/**
|
||||
* Removes a tray icon using the provided id from tauri's internal state.
|
||||
*
|
||||
* Note that this may cause the tray icon to disappear
|
||||
* if it wasn't cloned somewhere else or referenced by JS.
|
||||
*/
|
||||
static async removeById(id) {
|
||||
return invoke('plugin:tray|remove_by_id', { id });
|
||||
}
|
||||
/**
|
||||
* Creates a new {@linkcode TrayIcon}
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Linux:** Sometimes the icon won't be visible unless a menu is set.
|
||||
* Setting an empty {@linkcode Menu} is enough.
|
||||
*/
|
||||
static async new(options) {
|
||||
if (options === null || options === void 0 ? void 0 : options.menu) {
|
||||
// @ts-expect-error we only need the rid and kind
|
||||
options.menu = [options.menu.rid, options.menu.kind];
|
||||
}
|
||||
if (options === null || options === void 0 ? void 0 : options.icon) {
|
||||
options.icon = transformImage(options.icon);
|
||||
}
|
||||
const handler = new Channel();
|
||||
if (options === null || options === void 0 ? void 0 : options.action) {
|
||||
const action = options.action;
|
||||
handler.onmessage = (e) => action(mapEvent(e));
|
||||
delete options.action;
|
||||
}
|
||||
return invoke('plugin:tray|new', {
|
||||
options: options !== null && options !== void 0 ? options : {},
|
||||
handler
|
||||
}).then(([rid, id]) => new TrayIcon(rid, id));
|
||||
}
|
||||
/**
|
||||
* Sets a new tray icon. If `null` is provided, it will remove the icon.
|
||||
*
|
||||
* Note that you may need the `image-ico` or `image-png` Cargo features to use this API.
|
||||
* To enable it, change your Cargo.toml file:
|
||||
* ```toml
|
||||
* [dependencies]
|
||||
* tauri = { version = "...", features = ["...", "image-png"] }
|
||||
* ```
|
||||
*/
|
||||
async setIcon(icon) {
|
||||
let trayIcon = null;
|
||||
if (icon) {
|
||||
trayIcon = transformImage(icon);
|
||||
}
|
||||
return invoke('plugin:tray|set_icon', { rid: this.rid, icon: trayIcon });
|
||||
}
|
||||
/**
|
||||
* Sets a new tray menu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Linux**: once a menu is set it cannot be removed so `null` has no effect
|
||||
*/
|
||||
async setMenu(menu) {
|
||||
if (menu) {
|
||||
// @ts-expect-error we only need the rid and kind
|
||||
menu = [menu.rid, menu.kind];
|
||||
}
|
||||
return invoke('plugin:tray|set_menu', { rid: this.rid, menu });
|
||||
}
|
||||
/**
|
||||
* Sets the tooltip for this tray icon.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Linux:** Unsupported
|
||||
*/
|
||||
async setTooltip(tooltip) {
|
||||
return invoke('plugin:tray|set_tooltip', { rid: this.rid, tooltip });
|
||||
}
|
||||
/**
|
||||
* Sets the tooltip for this tray icon.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Linux:** The title will not be shown unless there is an icon
|
||||
* as well. The title is useful for numerical and other frequently
|
||||
* updated information. In general, it shouldn't be shown unless a
|
||||
* user requests it as it can take up a significant amount of space
|
||||
* on the user's panel. This may not be shown in all visualizations.
|
||||
* - **Windows:** Unsupported
|
||||
*/
|
||||
async setTitle(title) {
|
||||
return invoke('plugin:tray|set_title', { rid: this.rid, title });
|
||||
}
|
||||
/** Show or hide this tray icon. */
|
||||
async setVisible(visible) {
|
||||
return invoke('plugin:tray|set_visible', { rid: this.rid, visible });
|
||||
}
|
||||
/**
|
||||
* Sets the tray icon temp dir path. **Linux only**.
|
||||
*
|
||||
* On Linux, we need to write the icon to the disk and usually it will
|
||||
* be `$XDG_RUNTIME_DIR/tray-icon` or `$TEMP/tray-icon`.
|
||||
*/
|
||||
async setTempDirPath(path) {
|
||||
return invoke('plugin:tray|set_temp_dir_path', { rid: this.rid, path });
|
||||
}
|
||||
/** Sets the current icon as a [template](https://developer.apple.com/documentation/appkit/nsimage/1520017-template?language=objc). **macOS only** */
|
||||
async setIconAsTemplate(asTemplate) {
|
||||
return invoke('plugin:tray|set_icon_as_template', {
|
||||
rid: this.rid,
|
||||
asTemplate
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Disable or enable showing the tray menu on left click.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Linux**: Unsupported.
|
||||
*
|
||||
* @deprecated use {@linkcode TrayIcon.setShowMenuOnLeftClick} instead.
|
||||
*/
|
||||
async setMenuOnLeftClick(onLeft) {
|
||||
return invoke('plugin:tray|set_show_menu_on_left_click', {
|
||||
rid: this.rid,
|
||||
onLeft
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Disable or enable showing the tray menu on left click.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Linux**: Unsupported.
|
||||
*
|
||||
* @since 2.2.0
|
||||
*/
|
||||
async setShowMenuOnLeftClick(onLeft) {
|
||||
return invoke('plugin:tray|set_show_menu_on_left_click', {
|
||||
rid: this.rid,
|
||||
onLeft
|
||||
});
|
||||
}
|
||||
}
|
||||
function mapEvent(e) {
|
||||
const out = e;
|
||||
out.position = new PhysicalPosition(e.position);
|
||||
out.rect.position = new PhysicalPosition(e.rect.position);
|
||||
out.rect.size = new PhysicalSize(e.rect.size);
|
||||
return out;
|
||||
}
|
||||
|
||||
export { TrayIcon };
|
548
node_modules/@tauri-apps/api/webview.cjs
generated
vendored
Normal file
548
node_modules/@tauri-apps/api/webview.cjs
generated
vendored
Normal file
@ -0,0 +1,548 @@
|
||||
'use strict';
|
||||
|
||||
var dpi = require('./dpi.cjs');
|
||||
var event = require('./event.cjs');
|
||||
var core = require('./core.cjs');
|
||||
var window$1 = require('./window.cjs');
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/**
|
||||
* Provides APIs to create webviews, communicate with other webviews and manipulate the current webview.
|
||||
*
|
||||
* #### Webview events
|
||||
*
|
||||
* Events can be listened to using {@link Webview.listen}:
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from "@tauri-apps/api/webview";
|
||||
* getCurrentWebview().listen("my-webview-event", ({ event, payload }) => { });
|
||||
* ```
|
||||
*
|
||||
* @module
|
||||
*/
|
||||
/**
|
||||
* Get an instance of `Webview` for the current webview.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
function getCurrentWebview() {
|
||||
return new Webview(window$1.getCurrentWindow(), window.__TAURI_INTERNALS__.metadata.currentWebview.label, {
|
||||
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
|
||||
skip: true
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Gets a list of instances of `Webview` for all available webviews.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function getAllWebviews() {
|
||||
return core.invoke('plugin:webview|get_all_webviews').then((webviews) => webviews.map((w) => new Webview(new window$1.Window(w.windowLabel, {
|
||||
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
|
||||
skip: true
|
||||
}), w.label, {
|
||||
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
|
||||
skip: true
|
||||
})));
|
||||
}
|
||||
/** @ignore */
|
||||
// events that are emitted right here instead of by the created webview
|
||||
const localTauriEvents = ['tauri://created', 'tauri://error'];
|
||||
/**
|
||||
* Create new webview or get a handle to an existing one.
|
||||
*
|
||||
* Webviews are identified by a *label* a unique identifier that can be used to reference it later.
|
||||
* It may only contain alphanumeric characters `a-zA-Z` plus the following special characters `-`, `/`, `:` and `_`.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { Window } from "@tauri-apps/api/window"
|
||||
* import { Webview } from "@tauri-apps/api/webview"
|
||||
*
|
||||
* const appWindow = new Window('uniqueLabel');
|
||||
*
|
||||
* // loading embedded asset:
|
||||
* const webview = new Webview(appWindow, 'theUniqueLabel', {
|
||||
* url: 'path/to/page.html'
|
||||
* });
|
||||
* // alternatively, load a remote URL:
|
||||
* const webview = new Webview(appWindow, 'theUniqueLabel', {
|
||||
* url: 'https://github.com/tauri-apps/tauri'
|
||||
* });
|
||||
*
|
||||
* webview.once('tauri://created', function () {
|
||||
* // webview successfully created
|
||||
* });
|
||||
* webview.once('tauri://error', function (e) {
|
||||
* // an error happened creating the webview
|
||||
* });
|
||||
*
|
||||
* // emit an event to the backend
|
||||
* await webview.emit("some-event", "data");
|
||||
* // listen to an event from the backend
|
||||
* const unlisten = await webview.listen("event-name", e => {});
|
||||
* unlisten();
|
||||
* ```
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
class Webview {
|
||||
/**
|
||||
* Creates a new Webview.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { Window } from '@tauri-apps/api/window'
|
||||
* import { Webview } from '@tauri-apps/api/webview'
|
||||
* const appWindow = new Window('my-label')
|
||||
* const webview = new Webview(appWindow, 'my-label', {
|
||||
* url: 'https://github.com/tauri-apps/tauri'
|
||||
* });
|
||||
* webview.once('tauri://created', function () {
|
||||
* // webview successfully created
|
||||
* });
|
||||
* webview.once('tauri://error', function (e) {
|
||||
* // an error happened creating the webview
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @param window the window to add this webview to.
|
||||
* @param label The unique webview label. Must be alphanumeric: `a-zA-Z-/:_`.
|
||||
* @returns The {@link Webview} instance to communicate with the webview.
|
||||
*/
|
||||
constructor(window, label, options) {
|
||||
this.window = window;
|
||||
this.label = label;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
this.listeners = Object.create(null);
|
||||
// @ts-expect-error `skip` is not a public API so it is not defined in WebviewOptions
|
||||
if (!(options === null || options === void 0 ? void 0 : options.skip)) {
|
||||
core.invoke('plugin:webview|create_webview', {
|
||||
windowLabel: window.label,
|
||||
label,
|
||||
options
|
||||
})
|
||||
.then(async () => this.emit('tauri://created'))
|
||||
.catch(async (e) => this.emit('tauri://error', e));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Gets the Webview for the webview associated with the given label.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { Webview } from '@tauri-apps/api/webview';
|
||||
* const mainWebview = Webview.getByLabel('main');
|
||||
* ```
|
||||
*
|
||||
* @param label The webview label.
|
||||
* @returns The Webview instance to communicate with the webview or null if the webview doesn't exist.
|
||||
*/
|
||||
static async getByLabel(label) {
|
||||
var _a;
|
||||
return (_a = (await getAllWebviews()).find((w) => w.label === label)) !== null && _a !== void 0 ? _a : null;
|
||||
}
|
||||
/**
|
||||
* Get an instance of `Webview` for the current webview.
|
||||
*/
|
||||
static getCurrent() {
|
||||
return getCurrentWebview();
|
||||
}
|
||||
/**
|
||||
* Gets a list of instances of `Webview` for all available webviews.
|
||||
*/
|
||||
static async getAll() {
|
||||
return getAllWebviews();
|
||||
}
|
||||
/**
|
||||
* Listen to an emitted event on this webview.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* const unlisten = await getCurrentWebview().listen<string>('state-changed', (event) => {
|
||||
* console.log(`Got error: ${payload}`);
|
||||
* });
|
||||
*
|
||||
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
||||
* unlisten();
|
||||
* ```
|
||||
*
|
||||
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
||||
* @param handler Event handler.
|
||||
* @returns A promise resolving to a function to unlisten to the event.
|
||||
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
||||
*/
|
||||
async listen(event$1, handler) {
|
||||
if (this._handleTauriEvent(event$1, handler)) {
|
||||
return () => {
|
||||
// eslint-disable-next-line security/detect-object-injection
|
||||
const listeners = this.listeners[event$1];
|
||||
listeners.splice(listeners.indexOf(handler), 1);
|
||||
};
|
||||
}
|
||||
return event.listen(event$1, handler, {
|
||||
target: { kind: 'Webview', label: this.label }
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Listen to an emitted event on this webview only once.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* const unlisten = await getCurrent().once<null>('initialized', (event) => {
|
||||
* console.log(`Webview initialized!`);
|
||||
* });
|
||||
*
|
||||
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
||||
* unlisten();
|
||||
* ```
|
||||
*
|
||||
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
||||
* @param handler Event handler.
|
||||
* @returns A promise resolving to a function to unlisten to the event.
|
||||
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
||||
*/
|
||||
async once(event$1, handler) {
|
||||
if (this._handleTauriEvent(event$1, handler)) {
|
||||
return () => {
|
||||
// eslint-disable-next-line security/detect-object-injection
|
||||
const listeners = this.listeners[event$1];
|
||||
listeners.splice(listeners.indexOf(handler), 1);
|
||||
};
|
||||
}
|
||||
return event.once(event$1, handler, {
|
||||
target: { kind: 'Webview', label: this.label }
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Emits an event to all {@link EventTarget|targets}.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* await getCurrentWebview().emit('webview-loaded', { loggedIn: true, token: 'authToken' });
|
||||
* ```
|
||||
*
|
||||
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
||||
* @param payload Event payload.
|
||||
*/
|
||||
async emit(event$1, payload) {
|
||||
if (localTauriEvents.includes(event$1)) {
|
||||
// eslint-disable-next-line
|
||||
for (const handler of this.listeners[event$1] || []) {
|
||||
handler({
|
||||
event: event$1,
|
||||
id: -1,
|
||||
payload
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
return event.emit(event$1, payload);
|
||||
}
|
||||
/**
|
||||
* Emits an event to all {@link EventTarget|targets} matching the given target.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* await getCurrentWebview().emitTo('main', 'webview-loaded', { loggedIn: true, token: 'authToken' });
|
||||
* ```
|
||||
*
|
||||
* @param target Label of the target Window/Webview/WebviewWindow or raw {@link EventTarget} object.
|
||||
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
||||
* @param payload Event payload.
|
||||
*/
|
||||
async emitTo(target, event$1, payload) {
|
||||
if (localTauriEvents.includes(event$1)) {
|
||||
// eslint-disable-next-line
|
||||
for (const handler of this.listeners[event$1] || []) {
|
||||
handler({
|
||||
event: event$1,
|
||||
id: -1,
|
||||
payload
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
return event.emitTo(target, event$1, payload);
|
||||
}
|
||||
/** @ignore */
|
||||
_handleTauriEvent(event, handler) {
|
||||
if (localTauriEvents.includes(event)) {
|
||||
if (!(event in this.listeners)) {
|
||||
// eslint-disable-next-line security/detect-object-injection
|
||||
this.listeners[event] = [handler];
|
||||
}
|
||||
else {
|
||||
// eslint-disable-next-line security/detect-object-injection
|
||||
this.listeners[event].push(handler);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// Getters
|
||||
/**
|
||||
* The position of the top-left hand corner of the webview's client area relative to the top-left hand corner of the desktop.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* const position = await getCurrentWebview().position();
|
||||
* ```
|
||||
*
|
||||
* @returns The webview's position.
|
||||
*/
|
||||
async position() {
|
||||
return core.invoke('plugin:webview|webview_position', {
|
||||
label: this.label
|
||||
}).then((p) => new dpi.PhysicalPosition(p));
|
||||
}
|
||||
/**
|
||||
* The physical size of the webview's client area.
|
||||
* The client area is the content of the webview, excluding the title bar and borders.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* const size = await getCurrentWebview().size();
|
||||
* ```
|
||||
*
|
||||
* @returns The webview's size.
|
||||
*/
|
||||
async size() {
|
||||
return core.invoke('plugin:webview|webview_size', {
|
||||
label: this.label
|
||||
}).then((s) => new dpi.PhysicalSize(s));
|
||||
}
|
||||
// Setters
|
||||
/**
|
||||
* Closes the webview.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* await getCurrentWebview().close();
|
||||
* ```
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*/
|
||||
async close() {
|
||||
return core.invoke('plugin:webview|webview_close', {
|
||||
label: this.label
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Resizes the webview.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrent, LogicalSize } from '@tauri-apps/api/webview';
|
||||
* await getCurrentWebview().setSize(new LogicalSize(600, 500));
|
||||
* ```
|
||||
*
|
||||
* @param size The logical or physical size.
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*/
|
||||
async setSize(size) {
|
||||
return core.invoke('plugin:webview|set_webview_size', {
|
||||
label: this.label,
|
||||
value: size instanceof dpi.Size ? size : new dpi.Size(size)
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Sets the webview position.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrent, LogicalPosition } from '@tauri-apps/api/webview';
|
||||
* await getCurrentWebview().setPosition(new LogicalPosition(600, 500));
|
||||
* ```
|
||||
*
|
||||
* @param position The new position, in logical or physical pixels.
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*/
|
||||
async setPosition(position) {
|
||||
return core.invoke('plugin:webview|set_webview_position', {
|
||||
label: this.label,
|
||||
value: position instanceof dpi.Position ? position : new dpi.Position(position)
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Bring the webview to front and focus.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* await getCurrentWebview().setFocus();
|
||||
* ```
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*/
|
||||
async setFocus() {
|
||||
return core.invoke('plugin:webview|set_webview_focus', {
|
||||
label: this.label
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Hide the webview.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* await getCurrentWebview().hide();
|
||||
* ```
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*/
|
||||
async hide() {
|
||||
return core.invoke('plugin:webview|webview_hide', {
|
||||
label: this.label
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Show the webview.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* await getCurrentWebview().show();
|
||||
* ```
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*/
|
||||
async show() {
|
||||
return core.invoke('plugin:webview|webview_show', {
|
||||
label: this.label
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Set webview zoom level.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* await getCurrentWebview().setZoom(1.5);
|
||||
* ```
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*/
|
||||
async setZoom(scaleFactor) {
|
||||
return core.invoke('plugin:webview|set_webview_zoom', {
|
||||
label: this.label,
|
||||
value: scaleFactor
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Moves this webview to the given label.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* await getCurrentWebview().reparent('other-window');
|
||||
* ```
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*/
|
||||
async reparent(window) {
|
||||
return core.invoke('plugin:webview|reparent', {
|
||||
label: this.label,
|
||||
window: typeof window === 'string' ? window : window.label
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Clears all browsing data for this webview.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* await getCurrentWebview().clearAllBrowsingData();
|
||||
* ```
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*/
|
||||
async clearAllBrowsingData() {
|
||||
return core.invoke('plugin:webview|clear_all_browsing_data');
|
||||
}
|
||||
/**
|
||||
* Specify the webview background color.
|
||||
*
|
||||
* #### Platfrom-specific:
|
||||
*
|
||||
* - **macOS / iOS**: Not implemented.
|
||||
* - **Windows**:
|
||||
* - On Windows 7, transparency is not supported and the alpha value will be ignored.
|
||||
* - On Windows higher than 7: translucent colors are not supported so any alpha value other than `0` will be replaced by `255`
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
async setBackgroundColor(color) {
|
||||
return core.invoke('plugin:webview|set_webview_background_color', { color });
|
||||
}
|
||||
// Listeners
|
||||
/**
|
||||
* Listen to a file drop event.
|
||||
* The listener is triggered when the user hovers the selected files on the webview,
|
||||
* drops the files or cancels the operation.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from "@tauri-apps/api/webview";
|
||||
* const unlisten = await getCurrentWebview().onDragDropEvent((event) => {
|
||||
* if (event.payload.type === 'over') {
|
||||
* console.log('User hovering', event.payload.position);
|
||||
* } else if (event.payload.type === 'drop') {
|
||||
* console.log('User dropped', event.payload.paths);
|
||||
* } else {
|
||||
* console.log('File drop cancelled');
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
||||
* unlisten();
|
||||
* ```
|
||||
*
|
||||
* When the debugger panel is open, the drop position of this event may be inaccurate due to a known limitation.
|
||||
* To retrieve the correct drop position, please detach the debugger.
|
||||
*
|
||||
* @returns A promise resolving to a function to unlisten to the event.
|
||||
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
||||
*/
|
||||
async onDragDropEvent(handler) {
|
||||
const unlistenDragEnter = await this.listen(event.TauriEvent.DRAG_ENTER, (event) => {
|
||||
handler({
|
||||
...event,
|
||||
payload: {
|
||||
type: 'enter',
|
||||
paths: event.payload.paths,
|
||||
position: new dpi.PhysicalPosition(event.payload.position)
|
||||
}
|
||||
});
|
||||
});
|
||||
const unlistenDragOver = await this.listen(event.TauriEvent.DRAG_OVER, (event) => {
|
||||
handler({
|
||||
...event,
|
||||
payload: {
|
||||
type: 'over',
|
||||
position: new dpi.PhysicalPosition(event.payload.position)
|
||||
}
|
||||
});
|
||||
});
|
||||
const unlistenDragDrop = await this.listen(event.TauriEvent.DRAG_DROP, (event) => {
|
||||
handler({
|
||||
...event,
|
||||
payload: {
|
||||
type: 'drop',
|
||||
paths: event.payload.paths,
|
||||
position: new dpi.PhysicalPosition(event.payload.position)
|
||||
}
|
||||
});
|
||||
});
|
||||
const unlistenDragLeave = await this.listen(event.TauriEvent.DRAG_LEAVE, (event) => {
|
||||
handler({ ...event, payload: { type: 'leave' } });
|
||||
});
|
||||
return () => {
|
||||
unlistenDragEnter();
|
||||
unlistenDragDrop();
|
||||
unlistenDragOver();
|
||||
unlistenDragLeave();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
exports.Webview = Webview;
|
||||
exports.getAllWebviews = getAllWebviews;
|
||||
exports.getCurrentWebview = getCurrentWebview;
|
531
node_modules/@tauri-apps/api/webview.d.ts
generated
vendored
Normal file
531
node_modules/@tauri-apps/api/webview.d.ts
generated
vendored
Normal file
@ -0,0 +1,531 @@
|
||||
/**
|
||||
* Provides APIs to create webviews, communicate with other webviews and manipulate the current webview.
|
||||
*
|
||||
* #### Webview events
|
||||
*
|
||||
* Events can be listened to using {@link Webview.listen}:
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from "@tauri-apps/api/webview";
|
||||
* getCurrentWebview().listen("my-webview-event", ({ event, payload }) => { });
|
||||
* ```
|
||||
*
|
||||
* @module
|
||||
*/
|
||||
import { PhysicalPosition, PhysicalSize } from './dpi';
|
||||
import type { LogicalPosition, LogicalSize } from './dpi';
|
||||
import { Position, Size } from './dpi';
|
||||
import type { EventName, EventCallback, UnlistenFn } from './event';
|
||||
import { type EventTarget } from './event';
|
||||
import { BackgroundThrottlingPolicy, Color, Window } from './window';
|
||||
import { WebviewWindow } from './webviewWindow';
|
||||
/** The drag and drop event types. */
|
||||
type DragDropEvent = {
|
||||
type: 'enter';
|
||||
paths: string[];
|
||||
position: PhysicalPosition;
|
||||
} | {
|
||||
type: 'over';
|
||||
position: PhysicalPosition;
|
||||
} | {
|
||||
type: 'drop';
|
||||
paths: string[];
|
||||
position: PhysicalPosition;
|
||||
} | {
|
||||
type: 'leave';
|
||||
};
|
||||
/**
|
||||
* Get an instance of `Webview` for the current webview.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
declare function getCurrentWebview(): Webview;
|
||||
/**
|
||||
* Gets a list of instances of `Webview` for all available webviews.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
declare function getAllWebviews(): Promise<Webview[]>;
|
||||
/** @ignore */
|
||||
export type WebviewLabel = string;
|
||||
/**
|
||||
* Create new webview or get a handle to an existing one.
|
||||
*
|
||||
* Webviews are identified by a *label* a unique identifier that can be used to reference it later.
|
||||
* It may only contain alphanumeric characters `a-zA-Z` plus the following special characters `-`, `/`, `:` and `_`.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { Window } from "@tauri-apps/api/window"
|
||||
* import { Webview } from "@tauri-apps/api/webview"
|
||||
*
|
||||
* const appWindow = new Window('uniqueLabel');
|
||||
*
|
||||
* // loading embedded asset:
|
||||
* const webview = new Webview(appWindow, 'theUniqueLabel', {
|
||||
* url: 'path/to/page.html'
|
||||
* });
|
||||
* // alternatively, load a remote URL:
|
||||
* const webview = new Webview(appWindow, 'theUniqueLabel', {
|
||||
* url: 'https://github.com/tauri-apps/tauri'
|
||||
* });
|
||||
*
|
||||
* webview.once('tauri://created', function () {
|
||||
* // webview successfully created
|
||||
* });
|
||||
* webview.once('tauri://error', function (e) {
|
||||
* // an error happened creating the webview
|
||||
* });
|
||||
*
|
||||
* // emit an event to the backend
|
||||
* await webview.emit("some-event", "data");
|
||||
* // listen to an event from the backend
|
||||
* const unlisten = await webview.listen("event-name", e => {});
|
||||
* unlisten();
|
||||
* ```
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
declare class Webview {
|
||||
/** The webview label. It is a unique identifier for the webview, can be used to reference it later. */
|
||||
label: WebviewLabel;
|
||||
/** The window hosting this webview. */
|
||||
window: Window;
|
||||
/** Local event listeners. */
|
||||
listeners: Record<string, Array<EventCallback<any>>>;
|
||||
/**
|
||||
* Creates a new Webview.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { Window } from '@tauri-apps/api/window'
|
||||
* import { Webview } from '@tauri-apps/api/webview'
|
||||
* const appWindow = new Window('my-label')
|
||||
* const webview = new Webview(appWindow, 'my-label', {
|
||||
* url: 'https://github.com/tauri-apps/tauri'
|
||||
* });
|
||||
* webview.once('tauri://created', function () {
|
||||
* // webview successfully created
|
||||
* });
|
||||
* webview.once('tauri://error', function (e) {
|
||||
* // an error happened creating the webview
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @param window the window to add this webview to.
|
||||
* @param label The unique webview label. Must be alphanumeric: `a-zA-Z-/:_`.
|
||||
* @returns The {@link Webview} instance to communicate with the webview.
|
||||
*/
|
||||
constructor(window: Window, label: WebviewLabel, options: WebviewOptions);
|
||||
/**
|
||||
* Gets the Webview for the webview associated with the given label.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { Webview } from '@tauri-apps/api/webview';
|
||||
* const mainWebview = Webview.getByLabel('main');
|
||||
* ```
|
||||
*
|
||||
* @param label The webview label.
|
||||
* @returns The Webview instance to communicate with the webview or null if the webview doesn't exist.
|
||||
*/
|
||||
static getByLabel(label: string): Promise<Webview | null>;
|
||||
/**
|
||||
* Get an instance of `Webview` for the current webview.
|
||||
*/
|
||||
static getCurrent(): Webview;
|
||||
/**
|
||||
* Gets a list of instances of `Webview` for all available webviews.
|
||||
*/
|
||||
static getAll(): Promise<Webview[]>;
|
||||
/**
|
||||
* Listen to an emitted event on this webview.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* const unlisten = await getCurrentWebview().listen<string>('state-changed', (event) => {
|
||||
* console.log(`Got error: ${payload}`);
|
||||
* });
|
||||
*
|
||||
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
||||
* unlisten();
|
||||
* ```
|
||||
*
|
||||
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
||||
* @param handler Event handler.
|
||||
* @returns A promise resolving to a function to unlisten to the event.
|
||||
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
||||
*/
|
||||
listen<T>(event: EventName, handler: EventCallback<T>): Promise<UnlistenFn>;
|
||||
/**
|
||||
* Listen to an emitted event on this webview only once.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* const unlisten = await getCurrent().once<null>('initialized', (event) => {
|
||||
* console.log(`Webview initialized!`);
|
||||
* });
|
||||
*
|
||||
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
||||
* unlisten();
|
||||
* ```
|
||||
*
|
||||
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
||||
* @param handler Event handler.
|
||||
* @returns A promise resolving to a function to unlisten to the event.
|
||||
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
||||
*/
|
||||
once<T>(event: EventName, handler: EventCallback<T>): Promise<UnlistenFn>;
|
||||
/**
|
||||
* Emits an event to all {@link EventTarget|targets}.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* await getCurrentWebview().emit('webview-loaded', { loggedIn: true, token: 'authToken' });
|
||||
* ```
|
||||
*
|
||||
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
||||
* @param payload Event payload.
|
||||
*/
|
||||
emit<T>(event: string, payload?: T): Promise<void>;
|
||||
/**
|
||||
* Emits an event to all {@link EventTarget|targets} matching the given target.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* await getCurrentWebview().emitTo('main', 'webview-loaded', { loggedIn: true, token: 'authToken' });
|
||||
* ```
|
||||
*
|
||||
* @param target Label of the target Window/Webview/WebviewWindow or raw {@link EventTarget} object.
|
||||
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
||||
* @param payload Event payload.
|
||||
*/
|
||||
emitTo<T>(target: string | EventTarget, event: string, payload?: T): Promise<void>;
|
||||
/** @ignore */
|
||||
_handleTauriEvent<T>(event: string, handler: EventCallback<T>): boolean;
|
||||
/**
|
||||
* The position of the top-left hand corner of the webview's client area relative to the top-left hand corner of the desktop.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* const position = await getCurrentWebview().position();
|
||||
* ```
|
||||
*
|
||||
* @returns The webview's position.
|
||||
*/
|
||||
position(): Promise<PhysicalPosition>;
|
||||
/**
|
||||
* The physical size of the webview's client area.
|
||||
* The client area is the content of the webview, excluding the title bar and borders.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* const size = await getCurrentWebview().size();
|
||||
* ```
|
||||
*
|
||||
* @returns The webview's size.
|
||||
*/
|
||||
size(): Promise<PhysicalSize>;
|
||||
/**
|
||||
* Closes the webview.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* await getCurrentWebview().close();
|
||||
* ```
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*/
|
||||
close(): Promise<void>;
|
||||
/**
|
||||
* Resizes the webview.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrent, LogicalSize } from '@tauri-apps/api/webview';
|
||||
* await getCurrentWebview().setSize(new LogicalSize(600, 500));
|
||||
* ```
|
||||
*
|
||||
* @param size The logical or physical size.
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*/
|
||||
setSize(size: LogicalSize | PhysicalSize | Size): Promise<void>;
|
||||
/**
|
||||
* Sets the webview position.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrent, LogicalPosition } from '@tauri-apps/api/webview';
|
||||
* await getCurrentWebview().setPosition(new LogicalPosition(600, 500));
|
||||
* ```
|
||||
*
|
||||
* @param position The new position, in logical or physical pixels.
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*/
|
||||
setPosition(position: LogicalPosition | PhysicalPosition | Position): Promise<void>;
|
||||
/**
|
||||
* Bring the webview to front and focus.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* await getCurrentWebview().setFocus();
|
||||
* ```
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*/
|
||||
setFocus(): Promise<void>;
|
||||
/**
|
||||
* Hide the webview.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* await getCurrentWebview().hide();
|
||||
* ```
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*/
|
||||
hide(): Promise<void>;
|
||||
/**
|
||||
* Show the webview.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* await getCurrentWebview().show();
|
||||
* ```
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*/
|
||||
show(): Promise<void>;
|
||||
/**
|
||||
* Set webview zoom level.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* await getCurrentWebview().setZoom(1.5);
|
||||
* ```
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*/
|
||||
setZoom(scaleFactor: number): Promise<void>;
|
||||
/**
|
||||
* Moves this webview to the given label.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* await getCurrentWebview().reparent('other-window');
|
||||
* ```
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*/
|
||||
reparent(window: Window | WebviewWindow | string): Promise<void>;
|
||||
/**
|
||||
* Clears all browsing data for this webview.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* await getCurrentWebview().clearAllBrowsingData();
|
||||
* ```
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*/
|
||||
clearAllBrowsingData(): Promise<void>;
|
||||
/**
|
||||
* Specify the webview background color.
|
||||
*
|
||||
* #### Platfrom-specific:
|
||||
*
|
||||
* - **macOS / iOS**: Not implemented.
|
||||
* - **Windows**:
|
||||
* - On Windows 7, transparency is not supported and the alpha value will be ignored.
|
||||
* - On Windows higher than 7: translucent colors are not supported so any alpha value other than `0` will be replaced by `255`
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
setBackgroundColor(color: Color | null): Promise<void>;
|
||||
/**
|
||||
* Listen to a file drop event.
|
||||
* The listener is triggered when the user hovers the selected files on the webview,
|
||||
* drops the files or cancels the operation.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from "@tauri-apps/api/webview";
|
||||
* const unlisten = await getCurrentWebview().onDragDropEvent((event) => {
|
||||
* if (event.payload.type === 'over') {
|
||||
* console.log('User hovering', event.payload.position);
|
||||
* } else if (event.payload.type === 'drop') {
|
||||
* console.log('User dropped', event.payload.paths);
|
||||
* } else {
|
||||
* console.log('File drop cancelled');
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
||||
* unlisten();
|
||||
* ```
|
||||
*
|
||||
* When the debugger panel is open, the drop position of this event may be inaccurate due to a known limitation.
|
||||
* To retrieve the correct drop position, please detach the debugger.
|
||||
*
|
||||
* @returns A promise resolving to a function to unlisten to the event.
|
||||
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
||||
*/
|
||||
onDragDropEvent(handler: EventCallback<DragDropEvent>): Promise<UnlistenFn>;
|
||||
}
|
||||
/**
|
||||
* Configuration for the webview to create.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
interface WebviewOptions {
|
||||
/**
|
||||
* Remote URL or local file path to open.
|
||||
*
|
||||
* - URL such as `https://github.com/tauri-apps` is opened directly on a Tauri webview.
|
||||
* - data: URL such as `data:text/html,<html>...` is only supported with the `webview-data-url` Cargo feature for the `tauri` dependency.
|
||||
* - local file path or route such as `/path/to/page.html` or `/users` is appended to the application URL (the devServer URL on development, or `tauri://localhost/` and `https://tauri.localhost/` on production).
|
||||
*/
|
||||
url?: string;
|
||||
/** The initial vertical position. */
|
||||
x: number;
|
||||
/** The initial horizontal position. */
|
||||
y: number;
|
||||
/** The initial width. */
|
||||
width: number;
|
||||
/** The initial height. */
|
||||
height: number;
|
||||
/**
|
||||
* Whether the webview is transparent or not.
|
||||
* Note that on `macOS` this requires the `macos-private-api` feature flag, enabled under `tauri.conf.json > app > macOSPrivateApi`.
|
||||
* WARNING: Using private APIs on `macOS` prevents your application from being accepted to the `App Store`.
|
||||
*/
|
||||
transparent?: boolean;
|
||||
/**
|
||||
* Whether the webview should have focus or not
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
focus?: boolean;
|
||||
/**
|
||||
* Whether the drag and drop is enabled or not on the webview. By default it is enabled.
|
||||
*
|
||||
* Disabling it is required to use HTML5 drag and drop on the frontend on Windows.
|
||||
*/
|
||||
dragDropEnabled?: boolean;
|
||||
/**
|
||||
* Whether clicking an inactive webview also clicks through to the webview on macOS.
|
||||
*/
|
||||
acceptFirstMouse?: boolean;
|
||||
/**
|
||||
* The user agent for the webview.
|
||||
*/
|
||||
userAgent?: string;
|
||||
/**
|
||||
* Whether or not the webview should be launched in incognito mode.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Android:** Unsupported.
|
||||
*/
|
||||
incognito?: boolean;
|
||||
/**
|
||||
* The proxy URL for the WebView for all network requests.
|
||||
*
|
||||
* Must be either a `http://` or a `socks5://` URL.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **macOS**: Requires the `macos-proxy` feature flag and only compiles for macOS 14+.
|
||||
* */
|
||||
proxyUrl?: string;
|
||||
/**
|
||||
* Whether page zooming by hotkeys is enabled
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Windows**: Controls WebView2's [`IsZoomControlEnabled`](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2settings?view=webview2-winrt-1.0.2420.47#iszoomcontrolenabled) setting.
|
||||
* - **MacOS / Linux**: Injects a polyfill that zooms in and out with `ctrl/command` + `-/=`,
|
||||
* 20% in each step, ranging from 20% to 1000%. Requires `webview:allow-set-webview-zoom` permission
|
||||
*
|
||||
* - **Android / iOS**: Unsupported.
|
||||
*/
|
||||
zoomHotkeysEnabled?: boolean;
|
||||
/**
|
||||
* Sets whether the custom protocols should use `https://<scheme>.localhost` instead of the default `http://<scheme>.localhost` on Windows and Android. Defaults to `false`.
|
||||
*
|
||||
* #### Note
|
||||
*
|
||||
* Using a `https` scheme will NOT allow mixed content when trying to fetch `http` endpoints and therefore will not match the behavior of the `<scheme>://localhost` protocols used on macOS and Linux.
|
||||
*
|
||||
* #### Warning
|
||||
*
|
||||
* Changing this value between releases will change the IndexedDB, cookies and localstorage location and your app will not be able to access them.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
useHttpsScheme?: boolean;
|
||||
/**
|
||||
* Whether web inspector, which is usually called browser devtools, is enabled or not. Enabled by default.
|
||||
*
|
||||
* This API works in **debug** builds, but requires `devtools` feature flag to enable it in **release** builds.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - macOS: This will call private functions on **macOS**.
|
||||
* - Android: Open `chrome://inspect/#devices` in Chrome to get the devtools window. Wry's `WebView` devtools API isn't supported on Android.
|
||||
* - iOS: Open Safari > Develop > [Your Device Name] > [Your WebView] to get the devtools window.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
devtools?: boolean;
|
||||
/**
|
||||
* Set the window and webview background color.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS / iOS**: Not implemented.
|
||||
* - **Windows**:
|
||||
* - On Windows 7, alpha channel is ignored.
|
||||
* - On Windows 8 and newer, if alpha channel is not `0`, it will be ignored.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
backgroundColor?: Color;
|
||||
/** Change the default background throttling behaviour.
|
||||
*
|
||||
* By default, browsers use a suspend policy that will throttle timers and even unload
|
||||
* the whole tab (view) to free resources after roughly 5 minutes when a view became
|
||||
* minimized or hidden. This will pause all tasks until the documents visibility state
|
||||
* changes back from hidden to visible by bringing the view back to the foreground.
|
||||
*
|
||||
* ## Platform-specific
|
||||
*
|
||||
* - **Linux / Windows / Android**: Unsupported. Workarounds like a pending WebLock transaction might suffice.
|
||||
* - **iOS**: Supported since version 17.0+.
|
||||
* - **macOS**: Supported since version 14.0+.
|
||||
*
|
||||
* see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
backgroundThrottling?: BackgroundThrottlingPolicy;
|
||||
/**
|
||||
* Whether we should disable JavaScript code execution on the webview or not.
|
||||
*/
|
||||
javascriptDisabled?: boolean;
|
||||
/**
|
||||
* on macOS and iOS there is a link preview on long pressing links, this is enabled by default.
|
||||
* see https://docs.rs/objc2-web-kit/latest/objc2_web_kit/struct.WKWebView.html#method.allowsLinkPreview
|
||||
*/
|
||||
allowLinkPreview?: boolean;
|
||||
/**
|
||||
* Allows disabling the input accessory view on iOS.
|
||||
*
|
||||
* The accessory view is the view that appears above the keyboard when a text input element is focused.
|
||||
* It usually displays a view with "Done", "Next" buttons.
|
||||
*/
|
||||
disableInputAccessoryView?: boolean;
|
||||
}
|
||||
export { Webview, getCurrentWebview, getAllWebviews };
|
||||
export type { DragDropEvent, WebviewOptions, Color };
|
544
node_modules/@tauri-apps/api/webview.js
generated
vendored
Normal file
544
node_modules/@tauri-apps/api/webview.js
generated
vendored
Normal file
@ -0,0 +1,544 @@
|
||||
import { PhysicalPosition, PhysicalSize, Size, Position } from './dpi.js';
|
||||
import { listen, once, emit, emitTo, TauriEvent } from './event.js';
|
||||
import { invoke } from './core.js';
|
||||
import { getCurrentWindow, Window } from './window.js';
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/**
|
||||
* Provides APIs to create webviews, communicate with other webviews and manipulate the current webview.
|
||||
*
|
||||
* #### Webview events
|
||||
*
|
||||
* Events can be listened to using {@link Webview.listen}:
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from "@tauri-apps/api/webview";
|
||||
* getCurrentWebview().listen("my-webview-event", ({ event, payload }) => { });
|
||||
* ```
|
||||
*
|
||||
* @module
|
||||
*/
|
||||
/**
|
||||
* Get an instance of `Webview` for the current webview.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
function getCurrentWebview() {
|
||||
return new Webview(getCurrentWindow(), window.__TAURI_INTERNALS__.metadata.currentWebview.label, {
|
||||
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
|
||||
skip: true
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Gets a list of instances of `Webview` for all available webviews.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function getAllWebviews() {
|
||||
return invoke('plugin:webview|get_all_webviews').then((webviews) => webviews.map((w) => new Webview(new Window(w.windowLabel, {
|
||||
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
|
||||
skip: true
|
||||
}), w.label, {
|
||||
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
|
||||
skip: true
|
||||
})));
|
||||
}
|
||||
/** @ignore */
|
||||
// events that are emitted right here instead of by the created webview
|
||||
const localTauriEvents = ['tauri://created', 'tauri://error'];
|
||||
/**
|
||||
* Create new webview or get a handle to an existing one.
|
||||
*
|
||||
* Webviews are identified by a *label* a unique identifier that can be used to reference it later.
|
||||
* It may only contain alphanumeric characters `a-zA-Z` plus the following special characters `-`, `/`, `:` and `_`.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { Window } from "@tauri-apps/api/window"
|
||||
* import { Webview } from "@tauri-apps/api/webview"
|
||||
*
|
||||
* const appWindow = new Window('uniqueLabel');
|
||||
*
|
||||
* // loading embedded asset:
|
||||
* const webview = new Webview(appWindow, 'theUniqueLabel', {
|
||||
* url: 'path/to/page.html'
|
||||
* });
|
||||
* // alternatively, load a remote URL:
|
||||
* const webview = new Webview(appWindow, 'theUniqueLabel', {
|
||||
* url: 'https://github.com/tauri-apps/tauri'
|
||||
* });
|
||||
*
|
||||
* webview.once('tauri://created', function () {
|
||||
* // webview successfully created
|
||||
* });
|
||||
* webview.once('tauri://error', function (e) {
|
||||
* // an error happened creating the webview
|
||||
* });
|
||||
*
|
||||
* // emit an event to the backend
|
||||
* await webview.emit("some-event", "data");
|
||||
* // listen to an event from the backend
|
||||
* const unlisten = await webview.listen("event-name", e => {});
|
||||
* unlisten();
|
||||
* ```
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
class Webview {
|
||||
/**
|
||||
* Creates a new Webview.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { Window } from '@tauri-apps/api/window'
|
||||
* import { Webview } from '@tauri-apps/api/webview'
|
||||
* const appWindow = new Window('my-label')
|
||||
* const webview = new Webview(appWindow, 'my-label', {
|
||||
* url: 'https://github.com/tauri-apps/tauri'
|
||||
* });
|
||||
* webview.once('tauri://created', function () {
|
||||
* // webview successfully created
|
||||
* });
|
||||
* webview.once('tauri://error', function (e) {
|
||||
* // an error happened creating the webview
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @param window the window to add this webview to.
|
||||
* @param label The unique webview label. Must be alphanumeric: `a-zA-Z-/:_`.
|
||||
* @returns The {@link Webview} instance to communicate with the webview.
|
||||
*/
|
||||
constructor(window, label, options) {
|
||||
this.window = window;
|
||||
this.label = label;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
this.listeners = Object.create(null);
|
||||
// @ts-expect-error `skip` is not a public API so it is not defined in WebviewOptions
|
||||
if (!(options === null || options === void 0 ? void 0 : options.skip)) {
|
||||
invoke('plugin:webview|create_webview', {
|
||||
windowLabel: window.label,
|
||||
label,
|
||||
options
|
||||
})
|
||||
.then(async () => this.emit('tauri://created'))
|
||||
.catch(async (e) => this.emit('tauri://error', e));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Gets the Webview for the webview associated with the given label.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { Webview } from '@tauri-apps/api/webview';
|
||||
* const mainWebview = Webview.getByLabel('main');
|
||||
* ```
|
||||
*
|
||||
* @param label The webview label.
|
||||
* @returns The Webview instance to communicate with the webview or null if the webview doesn't exist.
|
||||
*/
|
||||
static async getByLabel(label) {
|
||||
var _a;
|
||||
return (_a = (await getAllWebviews()).find((w) => w.label === label)) !== null && _a !== void 0 ? _a : null;
|
||||
}
|
||||
/**
|
||||
* Get an instance of `Webview` for the current webview.
|
||||
*/
|
||||
static getCurrent() {
|
||||
return getCurrentWebview();
|
||||
}
|
||||
/**
|
||||
* Gets a list of instances of `Webview` for all available webviews.
|
||||
*/
|
||||
static async getAll() {
|
||||
return getAllWebviews();
|
||||
}
|
||||
/**
|
||||
* Listen to an emitted event on this webview.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* const unlisten = await getCurrentWebview().listen<string>('state-changed', (event) => {
|
||||
* console.log(`Got error: ${payload}`);
|
||||
* });
|
||||
*
|
||||
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
||||
* unlisten();
|
||||
* ```
|
||||
*
|
||||
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
||||
* @param handler Event handler.
|
||||
* @returns A promise resolving to a function to unlisten to the event.
|
||||
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
||||
*/
|
||||
async listen(event, handler) {
|
||||
if (this._handleTauriEvent(event, handler)) {
|
||||
return () => {
|
||||
// eslint-disable-next-line security/detect-object-injection
|
||||
const listeners = this.listeners[event];
|
||||
listeners.splice(listeners.indexOf(handler), 1);
|
||||
};
|
||||
}
|
||||
return listen(event, handler, {
|
||||
target: { kind: 'Webview', label: this.label }
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Listen to an emitted event on this webview only once.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* const unlisten = await getCurrent().once<null>('initialized', (event) => {
|
||||
* console.log(`Webview initialized!`);
|
||||
* });
|
||||
*
|
||||
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
||||
* unlisten();
|
||||
* ```
|
||||
*
|
||||
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
||||
* @param handler Event handler.
|
||||
* @returns A promise resolving to a function to unlisten to the event.
|
||||
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
||||
*/
|
||||
async once(event, handler) {
|
||||
if (this._handleTauriEvent(event, handler)) {
|
||||
return () => {
|
||||
// eslint-disable-next-line security/detect-object-injection
|
||||
const listeners = this.listeners[event];
|
||||
listeners.splice(listeners.indexOf(handler), 1);
|
||||
};
|
||||
}
|
||||
return once(event, handler, {
|
||||
target: { kind: 'Webview', label: this.label }
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Emits an event to all {@link EventTarget|targets}.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* await getCurrentWebview().emit('webview-loaded', { loggedIn: true, token: 'authToken' });
|
||||
* ```
|
||||
*
|
||||
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
||||
* @param payload Event payload.
|
||||
*/
|
||||
async emit(event, payload) {
|
||||
if (localTauriEvents.includes(event)) {
|
||||
// eslint-disable-next-line
|
||||
for (const handler of this.listeners[event] || []) {
|
||||
handler({
|
||||
event,
|
||||
id: -1,
|
||||
payload
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
return emit(event, payload);
|
||||
}
|
||||
/**
|
||||
* Emits an event to all {@link EventTarget|targets} matching the given target.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* await getCurrentWebview().emitTo('main', 'webview-loaded', { loggedIn: true, token: 'authToken' });
|
||||
* ```
|
||||
*
|
||||
* @param target Label of the target Window/Webview/WebviewWindow or raw {@link EventTarget} object.
|
||||
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
||||
* @param payload Event payload.
|
||||
*/
|
||||
async emitTo(target, event, payload) {
|
||||
if (localTauriEvents.includes(event)) {
|
||||
// eslint-disable-next-line
|
||||
for (const handler of this.listeners[event] || []) {
|
||||
handler({
|
||||
event,
|
||||
id: -1,
|
||||
payload
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
return emitTo(target, event, payload);
|
||||
}
|
||||
/** @ignore */
|
||||
_handleTauriEvent(event, handler) {
|
||||
if (localTauriEvents.includes(event)) {
|
||||
if (!(event in this.listeners)) {
|
||||
// eslint-disable-next-line security/detect-object-injection
|
||||
this.listeners[event] = [handler];
|
||||
}
|
||||
else {
|
||||
// eslint-disable-next-line security/detect-object-injection
|
||||
this.listeners[event].push(handler);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// Getters
|
||||
/**
|
||||
* The position of the top-left hand corner of the webview's client area relative to the top-left hand corner of the desktop.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* const position = await getCurrentWebview().position();
|
||||
* ```
|
||||
*
|
||||
* @returns The webview's position.
|
||||
*/
|
||||
async position() {
|
||||
return invoke('plugin:webview|webview_position', {
|
||||
label: this.label
|
||||
}).then((p) => new PhysicalPosition(p));
|
||||
}
|
||||
/**
|
||||
* The physical size of the webview's client area.
|
||||
* The client area is the content of the webview, excluding the title bar and borders.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* const size = await getCurrentWebview().size();
|
||||
* ```
|
||||
*
|
||||
* @returns The webview's size.
|
||||
*/
|
||||
async size() {
|
||||
return invoke('plugin:webview|webview_size', {
|
||||
label: this.label
|
||||
}).then((s) => new PhysicalSize(s));
|
||||
}
|
||||
// Setters
|
||||
/**
|
||||
* Closes the webview.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* await getCurrentWebview().close();
|
||||
* ```
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*/
|
||||
async close() {
|
||||
return invoke('plugin:webview|webview_close', {
|
||||
label: this.label
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Resizes the webview.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrent, LogicalSize } from '@tauri-apps/api/webview';
|
||||
* await getCurrentWebview().setSize(new LogicalSize(600, 500));
|
||||
* ```
|
||||
*
|
||||
* @param size The logical or physical size.
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*/
|
||||
async setSize(size) {
|
||||
return invoke('plugin:webview|set_webview_size', {
|
||||
label: this.label,
|
||||
value: size instanceof Size ? size : new Size(size)
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Sets the webview position.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrent, LogicalPosition } from '@tauri-apps/api/webview';
|
||||
* await getCurrentWebview().setPosition(new LogicalPosition(600, 500));
|
||||
* ```
|
||||
*
|
||||
* @param position The new position, in logical or physical pixels.
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*/
|
||||
async setPosition(position) {
|
||||
return invoke('plugin:webview|set_webview_position', {
|
||||
label: this.label,
|
||||
value: position instanceof Position ? position : new Position(position)
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Bring the webview to front and focus.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* await getCurrentWebview().setFocus();
|
||||
* ```
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*/
|
||||
async setFocus() {
|
||||
return invoke('plugin:webview|set_webview_focus', {
|
||||
label: this.label
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Hide the webview.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* await getCurrentWebview().hide();
|
||||
* ```
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*/
|
||||
async hide() {
|
||||
return invoke('plugin:webview|webview_hide', {
|
||||
label: this.label
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Show the webview.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* await getCurrentWebview().show();
|
||||
* ```
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*/
|
||||
async show() {
|
||||
return invoke('plugin:webview|webview_show', {
|
||||
label: this.label
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Set webview zoom level.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* await getCurrentWebview().setZoom(1.5);
|
||||
* ```
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*/
|
||||
async setZoom(scaleFactor) {
|
||||
return invoke('plugin:webview|set_webview_zoom', {
|
||||
label: this.label,
|
||||
value: scaleFactor
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Moves this webview to the given label.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* await getCurrentWebview().reparent('other-window');
|
||||
* ```
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*/
|
||||
async reparent(window) {
|
||||
return invoke('plugin:webview|reparent', {
|
||||
label: this.label,
|
||||
window: typeof window === 'string' ? window : window.label
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Clears all browsing data for this webview.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from '@tauri-apps/api/webview';
|
||||
* await getCurrentWebview().clearAllBrowsingData();
|
||||
* ```
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*/
|
||||
async clearAllBrowsingData() {
|
||||
return invoke('plugin:webview|clear_all_browsing_data');
|
||||
}
|
||||
/**
|
||||
* Specify the webview background color.
|
||||
*
|
||||
* #### Platfrom-specific:
|
||||
*
|
||||
* - **macOS / iOS**: Not implemented.
|
||||
* - **Windows**:
|
||||
* - On Windows 7, transparency is not supported and the alpha value will be ignored.
|
||||
* - On Windows higher than 7: translucent colors are not supported so any alpha value other than `0` will be replaced by `255`
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
async setBackgroundColor(color) {
|
||||
return invoke('plugin:webview|set_webview_background_color', { color });
|
||||
}
|
||||
// Listeners
|
||||
/**
|
||||
* Listen to a file drop event.
|
||||
* The listener is triggered when the user hovers the selected files on the webview,
|
||||
* drops the files or cancels the operation.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getCurrentWebview } from "@tauri-apps/api/webview";
|
||||
* const unlisten = await getCurrentWebview().onDragDropEvent((event) => {
|
||||
* if (event.payload.type === 'over') {
|
||||
* console.log('User hovering', event.payload.position);
|
||||
* } else if (event.payload.type === 'drop') {
|
||||
* console.log('User dropped', event.payload.paths);
|
||||
* } else {
|
||||
* console.log('File drop cancelled');
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
||||
* unlisten();
|
||||
* ```
|
||||
*
|
||||
* When the debugger panel is open, the drop position of this event may be inaccurate due to a known limitation.
|
||||
* To retrieve the correct drop position, please detach the debugger.
|
||||
*
|
||||
* @returns A promise resolving to a function to unlisten to the event.
|
||||
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
||||
*/
|
||||
async onDragDropEvent(handler) {
|
||||
const unlistenDragEnter = await this.listen(TauriEvent.DRAG_ENTER, (event) => {
|
||||
handler({
|
||||
...event,
|
||||
payload: {
|
||||
type: 'enter',
|
||||
paths: event.payload.paths,
|
||||
position: new PhysicalPosition(event.payload.position)
|
||||
}
|
||||
});
|
||||
});
|
||||
const unlistenDragOver = await this.listen(TauriEvent.DRAG_OVER, (event) => {
|
||||
handler({
|
||||
...event,
|
||||
payload: {
|
||||
type: 'over',
|
||||
position: new PhysicalPosition(event.payload.position)
|
||||
}
|
||||
});
|
||||
});
|
||||
const unlistenDragDrop = await this.listen(TauriEvent.DRAG_DROP, (event) => {
|
||||
handler({
|
||||
...event,
|
||||
payload: {
|
||||
type: 'drop',
|
||||
paths: event.payload.paths,
|
||||
position: new PhysicalPosition(event.payload.position)
|
||||
}
|
||||
});
|
||||
});
|
||||
const unlistenDragLeave = await this.listen(TauriEvent.DRAG_LEAVE, (event) => {
|
||||
handler({ ...event, payload: { type: 'leave' } });
|
||||
});
|
||||
return () => {
|
||||
unlistenDragEnter();
|
||||
unlistenDragDrop();
|
||||
unlistenDragOver();
|
||||
unlistenDragLeave();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export { Webview, getAllWebviews, getCurrentWebview };
|
211
node_modules/@tauri-apps/api/webviewWindow.cjs
generated
vendored
Normal file
211
node_modules/@tauri-apps/api/webviewWindow.cjs
generated
vendored
Normal file
@ -0,0 +1,211 @@
|
||||
'use strict';
|
||||
|
||||
var webview = require('./webview.cjs');
|
||||
var window = require('./window.cjs');
|
||||
var event = require('./event.cjs');
|
||||
var core = require('./core.cjs');
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/**
|
||||
* Get an instance of `Webview` for the current webview window.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
function getCurrentWebviewWindow() {
|
||||
const webview$1 = webview.getCurrentWebview();
|
||||
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
|
||||
return new WebviewWindow(webview$1.label, { skip: true });
|
||||
}
|
||||
/**
|
||||
* Gets a list of instances of `Webview` for all available webview windows.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function getAllWebviewWindows() {
|
||||
return core.invoke('plugin:window|get_all_windows').then((windows) => windows.map((w) => new WebviewWindow(w, {
|
||||
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
|
||||
skip: true
|
||||
})));
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
||||
class WebviewWindow {
|
||||
/**
|
||||
* Creates a new {@link Window} hosting a {@link Webview}.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { WebviewWindow } from '@tauri-apps/api/webviewWindow'
|
||||
* const webview = new WebviewWindow('my-label', {
|
||||
* url: 'https://github.com/tauri-apps/tauri'
|
||||
* });
|
||||
* webview.once('tauri://created', function () {
|
||||
* // webview successfully created
|
||||
* });
|
||||
* webview.once('tauri://error', function (e) {
|
||||
* // an error happened creating the webview
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @param label The unique webview label. Must be alphanumeric: `a-zA-Z-/:_`.
|
||||
* @returns The {@link WebviewWindow} instance to communicate with the window and webview.
|
||||
*/
|
||||
constructor(label, options = {}) {
|
||||
var _a;
|
||||
this.label = label;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
this.listeners = Object.create(null);
|
||||
// @ts-expect-error `skip` is not a public API so it is not defined in WebviewOptions
|
||||
if (!(options === null || options === void 0 ? void 0 : options.skip)) {
|
||||
core.invoke('plugin:webview|create_webview_window', {
|
||||
options: {
|
||||
...options,
|
||||
parent: typeof options.parent === 'string'
|
||||
? options.parent
|
||||
: (_a = options.parent) === null || _a === void 0 ? void 0 : _a.label,
|
||||
label
|
||||
}
|
||||
})
|
||||
.then(async () => this.emit('tauri://created'))
|
||||
.catch(async (e) => this.emit('tauri://error', e));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Gets the Webview for the webview associated with the given label.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { Webview } from '@tauri-apps/api/webviewWindow';
|
||||
* const mainWebview = Webview.getByLabel('main');
|
||||
* ```
|
||||
*
|
||||
* @param label The webview label.
|
||||
* @returns The Webview instance to communicate with the webview or null if the webview doesn't exist.
|
||||
*/
|
||||
static async getByLabel(label) {
|
||||
var _a;
|
||||
const webview = (_a = (await getAllWebviewWindows()).find((w) => w.label === label)) !== null && _a !== void 0 ? _a : null;
|
||||
if (webview) {
|
||||
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
|
||||
return new WebviewWindow(webview.label, { skip: true });
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Get an instance of `Webview` for the current webview.
|
||||
*/
|
||||
static getCurrent() {
|
||||
return getCurrentWebviewWindow();
|
||||
}
|
||||
/**
|
||||
* Gets a list of instances of `Webview` for all available webviews.
|
||||
*/
|
||||
static async getAll() {
|
||||
return getAllWebviewWindows();
|
||||
}
|
||||
/**
|
||||
* Listen to an emitted event on this webivew window.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { WebviewWindow } from '@tauri-apps/api/webviewWindow';
|
||||
* const unlisten = await WebviewWindow.getCurrent().listen<string>('state-changed', (event) => {
|
||||
* console.log(`Got error: ${payload}`);
|
||||
* });
|
||||
*
|
||||
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
||||
* unlisten();
|
||||
* ```
|
||||
*
|
||||
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
||||
* @param handler Event handler.
|
||||
* @returns A promise resolving to a function to unlisten to the event.
|
||||
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
||||
*/
|
||||
async listen(event$1, handler) {
|
||||
if (this._handleTauriEvent(event$1, handler)) {
|
||||
return () => {
|
||||
// eslint-disable-next-line security/detect-object-injection
|
||||
const listeners = this.listeners[event$1];
|
||||
listeners.splice(listeners.indexOf(handler), 1);
|
||||
};
|
||||
}
|
||||
return event.listen(event$1, handler, {
|
||||
target: { kind: 'WebviewWindow', label: this.label }
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Listen to an emitted event on this webview window only once.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { WebviewWindow } from '@tauri-apps/api/webviewWindow';
|
||||
* const unlisten = await WebviewWindow.getCurrent().once<null>('initialized', (event) => {
|
||||
* console.log(`Webview initialized!`);
|
||||
* });
|
||||
*
|
||||
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
||||
* unlisten();
|
||||
* ```
|
||||
*
|
||||
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
||||
* @param handler Event handler.
|
||||
* @returns A promise resolving to a function to unlisten to the event.
|
||||
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
||||
*/
|
||||
async once(event$1, handler) {
|
||||
if (this._handleTauriEvent(event$1, handler)) {
|
||||
return () => {
|
||||
// eslint-disable-next-line security/detect-object-injection
|
||||
const listeners = this.listeners[event$1];
|
||||
listeners.splice(listeners.indexOf(handler), 1);
|
||||
};
|
||||
}
|
||||
return event.once(event$1, handler, {
|
||||
target: { kind: 'WebviewWindow', label: this.label }
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Set the window and webview background color.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Android / iOS:** Unsupported for the window layer.
|
||||
* - **macOS / iOS**: Not implemented for the webview layer.
|
||||
* - **Windows**:
|
||||
* - alpha channel is ignored for the window layer.
|
||||
* - On Windows 7, alpha channel is ignored for the webview layer.
|
||||
* - On Windows 8 and newer, if alpha channel is not `0`, it will be ignored.
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
async setBackgroundColor(color) {
|
||||
return core.invoke('plugin:window|set_background_color', { color }).then(() => {
|
||||
return core.invoke('plugin:webview|set_webview_background_color', { color });
|
||||
});
|
||||
}
|
||||
}
|
||||
// Order matters, we use window APIs by default
|
||||
applyMixins(WebviewWindow, [window.Window, webview.Webview]);
|
||||
/** Extends a base class by other specified classes, without overriding existing properties */
|
||||
function applyMixins(baseClass, extendedClasses) {
|
||||
(Array.isArray(extendedClasses)
|
||||
? extendedClasses
|
||||
: [extendedClasses]).forEach((extendedClass) => {
|
||||
Object.getOwnPropertyNames(extendedClass.prototype).forEach((name) => {
|
||||
var _a;
|
||||
if (typeof baseClass.prototype === 'object'
|
||||
&& baseClass.prototype
|
||||
&& name in baseClass.prototype)
|
||||
return;
|
||||
Object.defineProperty(baseClass.prototype, name,
|
||||
// eslint-disable-next-line
|
||||
(_a = Object.getOwnPropertyDescriptor(extendedClass.prototype, name)) !== null && _a !== void 0 ? _a : Object.create(null));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
exports.WebviewWindow = WebviewWindow;
|
||||
exports.getAllWebviewWindows = getAllWebviewWindows;
|
||||
exports.getCurrentWebviewWindow = getCurrentWebviewWindow;
|
123
node_modules/@tauri-apps/api/webviewWindow.d.ts
generated
vendored
Normal file
123
node_modules/@tauri-apps/api/webviewWindow.d.ts
generated
vendored
Normal file
@ -0,0 +1,123 @@
|
||||
import { Webview, WebviewLabel, WebviewOptions } from './webview';
|
||||
import type { WindowOptions } from './window';
|
||||
import { Window } from './window';
|
||||
import type { EventName, EventCallback, UnlistenFn } from './event';
|
||||
import type { Color, DragDropEvent } from './webview';
|
||||
/**
|
||||
* Get an instance of `Webview` for the current webview window.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
declare function getCurrentWebviewWindow(): WebviewWindow;
|
||||
/**
|
||||
* Gets a list of instances of `Webview` for all available webview windows.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
declare function getAllWebviewWindows(): Promise<WebviewWindow[]>;
|
||||
interface WebviewWindow extends Webview, Window {
|
||||
}
|
||||
declare class WebviewWindow {
|
||||
label: string;
|
||||
/** Local event listeners. */
|
||||
listeners: Record<string, Array<EventCallback<any>>>;
|
||||
/**
|
||||
* Creates a new {@link Window} hosting a {@link Webview}.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { WebviewWindow } from '@tauri-apps/api/webviewWindow'
|
||||
* const webview = new WebviewWindow('my-label', {
|
||||
* url: 'https://github.com/tauri-apps/tauri'
|
||||
* });
|
||||
* webview.once('tauri://created', function () {
|
||||
* // webview successfully created
|
||||
* });
|
||||
* webview.once('tauri://error', function (e) {
|
||||
* // an error happened creating the webview
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @param label The unique webview label. Must be alphanumeric: `a-zA-Z-/:_`.
|
||||
* @returns The {@link WebviewWindow} instance to communicate with the window and webview.
|
||||
*/
|
||||
constructor(label: WebviewLabel, options?: Omit<WebviewOptions, 'x' | 'y' | 'width' | 'height'> & WindowOptions);
|
||||
/**
|
||||
* Gets the Webview for the webview associated with the given label.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { Webview } from '@tauri-apps/api/webviewWindow';
|
||||
* const mainWebview = Webview.getByLabel('main');
|
||||
* ```
|
||||
*
|
||||
* @param label The webview label.
|
||||
* @returns The Webview instance to communicate with the webview or null if the webview doesn't exist.
|
||||
*/
|
||||
static getByLabel(label: string): Promise<WebviewWindow | null>;
|
||||
/**
|
||||
* Get an instance of `Webview` for the current webview.
|
||||
*/
|
||||
static getCurrent(): WebviewWindow;
|
||||
/**
|
||||
* Gets a list of instances of `Webview` for all available webviews.
|
||||
*/
|
||||
static getAll(): Promise<WebviewWindow[]>;
|
||||
/**
|
||||
* Listen to an emitted event on this webivew window.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { WebviewWindow } from '@tauri-apps/api/webviewWindow';
|
||||
* const unlisten = await WebviewWindow.getCurrent().listen<string>('state-changed', (event) => {
|
||||
* console.log(`Got error: ${payload}`);
|
||||
* });
|
||||
*
|
||||
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
||||
* unlisten();
|
||||
* ```
|
||||
*
|
||||
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
||||
* @param handler Event handler.
|
||||
* @returns A promise resolving to a function to unlisten to the event.
|
||||
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
||||
*/
|
||||
listen<T>(event: EventName, handler: EventCallback<T>): Promise<UnlistenFn>;
|
||||
/**
|
||||
* Listen to an emitted event on this webview window only once.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { WebviewWindow } from '@tauri-apps/api/webviewWindow';
|
||||
* const unlisten = await WebviewWindow.getCurrent().once<null>('initialized', (event) => {
|
||||
* console.log(`Webview initialized!`);
|
||||
* });
|
||||
*
|
||||
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
||||
* unlisten();
|
||||
* ```
|
||||
*
|
||||
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
||||
* @param handler Event handler.
|
||||
* @returns A promise resolving to a function to unlisten to the event.
|
||||
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
||||
*/
|
||||
once<T>(event: EventName, handler: EventCallback<T>): Promise<UnlistenFn>;
|
||||
/**
|
||||
* Set the window and webview background color.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Android / iOS:** Unsupported for the window layer.
|
||||
* - **macOS / iOS**: Not implemented for the webview layer.
|
||||
* - **Windows**:
|
||||
* - alpha channel is ignored for the window layer.
|
||||
* - On Windows 7, alpha channel is ignored for the webview layer.
|
||||
* - On Windows 8 and newer, if alpha channel is not `0`, it will be ignored.
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
setBackgroundColor(color: Color): Promise<void>;
|
||||
}
|
||||
export { WebviewWindow, getCurrentWebviewWindow, getAllWebviewWindows };
|
||||
export type { DragDropEvent, Color };
|
207
node_modules/@tauri-apps/api/webviewWindow.js
generated
vendored
Normal file
207
node_modules/@tauri-apps/api/webviewWindow.js
generated
vendored
Normal file
@ -0,0 +1,207 @@
|
||||
import { getCurrentWebview, Webview } from './webview.js';
|
||||
import { Window } from './window.js';
|
||||
import { listen, once } from './event.js';
|
||||
import { invoke } from './core.js';
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/**
|
||||
* Get an instance of `Webview` for the current webview window.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
function getCurrentWebviewWindow() {
|
||||
const webview = getCurrentWebview();
|
||||
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
|
||||
return new WebviewWindow(webview.label, { skip: true });
|
||||
}
|
||||
/**
|
||||
* Gets a list of instances of `Webview` for all available webview windows.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function getAllWebviewWindows() {
|
||||
return invoke('plugin:window|get_all_windows').then((windows) => windows.map((w) => new WebviewWindow(w, {
|
||||
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
|
||||
skip: true
|
||||
})));
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
||||
class WebviewWindow {
|
||||
/**
|
||||
* Creates a new {@link Window} hosting a {@link Webview}.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { WebviewWindow } from '@tauri-apps/api/webviewWindow'
|
||||
* const webview = new WebviewWindow('my-label', {
|
||||
* url: 'https://github.com/tauri-apps/tauri'
|
||||
* });
|
||||
* webview.once('tauri://created', function () {
|
||||
* // webview successfully created
|
||||
* });
|
||||
* webview.once('tauri://error', function (e) {
|
||||
* // an error happened creating the webview
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @param label The unique webview label. Must be alphanumeric: `a-zA-Z-/:_`.
|
||||
* @returns The {@link WebviewWindow} instance to communicate with the window and webview.
|
||||
*/
|
||||
constructor(label, options = {}) {
|
||||
var _a;
|
||||
this.label = label;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
this.listeners = Object.create(null);
|
||||
// @ts-expect-error `skip` is not a public API so it is not defined in WebviewOptions
|
||||
if (!(options === null || options === void 0 ? void 0 : options.skip)) {
|
||||
invoke('plugin:webview|create_webview_window', {
|
||||
options: {
|
||||
...options,
|
||||
parent: typeof options.parent === 'string'
|
||||
? options.parent
|
||||
: (_a = options.parent) === null || _a === void 0 ? void 0 : _a.label,
|
||||
label
|
||||
}
|
||||
})
|
||||
.then(async () => this.emit('tauri://created'))
|
||||
.catch(async (e) => this.emit('tauri://error', e));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Gets the Webview for the webview associated with the given label.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { Webview } from '@tauri-apps/api/webviewWindow';
|
||||
* const mainWebview = Webview.getByLabel('main');
|
||||
* ```
|
||||
*
|
||||
* @param label The webview label.
|
||||
* @returns The Webview instance to communicate with the webview or null if the webview doesn't exist.
|
||||
*/
|
||||
static async getByLabel(label) {
|
||||
var _a;
|
||||
const webview = (_a = (await getAllWebviewWindows()).find((w) => w.label === label)) !== null && _a !== void 0 ? _a : null;
|
||||
if (webview) {
|
||||
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
|
||||
return new WebviewWindow(webview.label, { skip: true });
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Get an instance of `Webview` for the current webview.
|
||||
*/
|
||||
static getCurrent() {
|
||||
return getCurrentWebviewWindow();
|
||||
}
|
||||
/**
|
||||
* Gets a list of instances of `Webview` for all available webviews.
|
||||
*/
|
||||
static async getAll() {
|
||||
return getAllWebviewWindows();
|
||||
}
|
||||
/**
|
||||
* Listen to an emitted event on this webivew window.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { WebviewWindow } from '@tauri-apps/api/webviewWindow';
|
||||
* const unlisten = await WebviewWindow.getCurrent().listen<string>('state-changed', (event) => {
|
||||
* console.log(`Got error: ${payload}`);
|
||||
* });
|
||||
*
|
||||
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
||||
* unlisten();
|
||||
* ```
|
||||
*
|
||||
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
||||
* @param handler Event handler.
|
||||
* @returns A promise resolving to a function to unlisten to the event.
|
||||
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
||||
*/
|
||||
async listen(event, handler) {
|
||||
if (this._handleTauriEvent(event, handler)) {
|
||||
return () => {
|
||||
// eslint-disable-next-line security/detect-object-injection
|
||||
const listeners = this.listeners[event];
|
||||
listeners.splice(listeners.indexOf(handler), 1);
|
||||
};
|
||||
}
|
||||
return listen(event, handler, {
|
||||
target: { kind: 'WebviewWindow', label: this.label }
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Listen to an emitted event on this webview window only once.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { WebviewWindow } from '@tauri-apps/api/webviewWindow';
|
||||
* const unlisten = await WebviewWindow.getCurrent().once<null>('initialized', (event) => {
|
||||
* console.log(`Webview initialized!`);
|
||||
* });
|
||||
*
|
||||
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
||||
* unlisten();
|
||||
* ```
|
||||
*
|
||||
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
||||
* @param handler Event handler.
|
||||
* @returns A promise resolving to a function to unlisten to the event.
|
||||
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
||||
*/
|
||||
async once(event, handler) {
|
||||
if (this._handleTauriEvent(event, handler)) {
|
||||
return () => {
|
||||
// eslint-disable-next-line security/detect-object-injection
|
||||
const listeners = this.listeners[event];
|
||||
listeners.splice(listeners.indexOf(handler), 1);
|
||||
};
|
||||
}
|
||||
return once(event, handler, {
|
||||
target: { kind: 'WebviewWindow', label: this.label }
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Set the window and webview background color.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Android / iOS:** Unsupported for the window layer.
|
||||
* - **macOS / iOS**: Not implemented for the webview layer.
|
||||
* - **Windows**:
|
||||
* - alpha channel is ignored for the window layer.
|
||||
* - On Windows 7, alpha channel is ignored for the webview layer.
|
||||
* - On Windows 8 and newer, if alpha channel is not `0`, it will be ignored.
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
async setBackgroundColor(color) {
|
||||
return invoke('plugin:window|set_background_color', { color }).then(() => {
|
||||
return invoke('plugin:webview|set_webview_background_color', { color });
|
||||
});
|
||||
}
|
||||
}
|
||||
// Order matters, we use window APIs by default
|
||||
applyMixins(WebviewWindow, [Window, Webview]);
|
||||
/** Extends a base class by other specified classes, without overriding existing properties */
|
||||
function applyMixins(baseClass, extendedClasses) {
|
||||
(Array.isArray(extendedClasses)
|
||||
? extendedClasses
|
||||
: [extendedClasses]).forEach((extendedClass) => {
|
||||
Object.getOwnPropertyNames(extendedClass.prototype).forEach((name) => {
|
||||
var _a;
|
||||
if (typeof baseClass.prototype === 'object'
|
||||
&& baseClass.prototype
|
||||
&& name in baseClass.prototype)
|
||||
return;
|
||||
Object.defineProperty(baseClass.prototype, name,
|
||||
// eslint-disable-next-line
|
||||
(_a = Object.getOwnPropertyDescriptor(extendedClass.prototype, name)) !== null && _a !== void 0 ? _a : Object.create(null));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export { WebviewWindow, getAllWebviewWindows, getCurrentWebviewWindow };
|
1986
node_modules/@tauri-apps/api/window.cjs
generated
vendored
Normal file
1986
node_modules/@tauri-apps/api/window.cjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1723
node_modules/@tauri-apps/api/window.d.ts
generated
vendored
Normal file
1723
node_modules/@tauri-apps/api/window.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1973
node_modules/@tauri-apps/api/window.js
generated
vendored
Normal file
1973
node_modules/@tauri-apps/api/window.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
20
node_modules/@tauri-apps/plugin-opener/LICENSE.spdx
generated
vendored
Normal file
20
node_modules/@tauri-apps/plugin-opener/LICENSE.spdx
generated
vendored
Normal file
@ -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: <text>Tauri is a rust project that enables developers to make secure
|
||||
and small desktop applications using a web frontend.
|
||||
</text>
|
||||
PackageComment: <text>The package includes the following libraries; see
|
||||
Relationship information.
|
||||
</text>
|
||||
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
|
145
node_modules/@tauri-apps/plugin-opener/README.md
generated
vendored
Normal file
145
node_modules/@tauri-apps/plugin-opener/README.md
generated
vendored
Normal file
@ -0,0 +1,145 @@
|
||||

|
||||
|
||||
<!-- description -->
|
||||
|
||||
| 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.
|
||||
|
||||
<!-- Add the branch for installations using git! -->
|
||||
|
||||
```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
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td align="center" valign="middle">
|
||||
<a href="https://crabnebula.dev" target="_blank">
|
||||
<img src="https://github.com/tauri-apps/plugins-workspace/raw/v2/.github/sponsors/crabnebula.svg" alt="CrabNebula" width="283">
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
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.
|
94
node_modules/@tauri-apps/plugin-opener/dist-js/index.cjs
generated
vendored
Normal file
94
node_modules/@tauri-apps/plugin-opener/dist-js/index.cjs
generated
vendored
Normal file
@ -0,0 +1,94 @@
|
||||
'use strict';
|
||||
|
||||
var core = require('@tauri-apps/api/core');
|
||||
|
||||
// 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
|
||||
*/
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
async function openUrl(url, openWith) {
|
||||
await core.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
|
||||
*/
|
||||
async function openPath(path, openWith) {
|
||||
await core.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
|
||||
*/
|
||||
async function revealItemInDir(path) {
|
||||
return core.invoke('plugin:opener|reveal_item_in_dir', { path });
|
||||
}
|
||||
|
||||
exports.openPath = openPath;
|
||||
exports.openUrl = openUrl;
|
||||
exports.revealItemInDir = revealItemInDir;
|
56
node_modules/@tauri-apps/plugin-opener/dist-js/index.d.ts
generated
vendored
Normal file
56
node_modules/@tauri-apps/plugin-opener/dist-js/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
/**
|
||||
* 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 declare function openUrl(url: string | URL, openWith?: string): Promise<void>;
|
||||
/**
|
||||
* 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 declare function openPath(path: string, openWith?: string): Promise<void>;
|
||||
/**
|
||||
* 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 declare function revealItemInDir(path: string): Promise<unknown>;
|
90
node_modules/@tauri-apps/plugin-opener/dist-js/index.js
generated
vendored
Normal file
90
node_modules/@tauri-apps/plugin-opener/dist-js/index.js
generated
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
|
||||
// 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
|
||||
*/
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
async function openUrl(url, openWith) {
|
||||
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
|
||||
*/
|
||||
async function openPath(path, openWith) {
|
||||
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
|
||||
*/
|
||||
async function revealItemInDir(path) {
|
||||
return invoke('plugin:opener|reveal_item_in_dir', { path });
|
||||
}
|
||||
|
||||
export { openPath, openUrl, revealItemInDir };
|
1
node_modules/@tauri-apps/plugin-opener/dist-js/init.d.ts
generated
vendored
Normal file
1
node_modules/@tauri-apps/plugin-opener/dist-js/init.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export {};
|
30
node_modules/@tauri-apps/plugin-opener/package.json
generated
vendored
Normal file
30
node_modules/@tauri-apps/plugin-opener/package.json
generated
vendored
Normal file
@ -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"
|
||||
}
|
||||
}
|
2
LICENSE → node_modules/tailwindcss/LICENSE
generated
vendored
2
LICENSE → node_modules/tailwindcss/LICENSE
generated
vendored
@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2025 mii443
|
||||
Copyright (c) Tailwind Labs, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
40
node_modules/tailwindcss/README.md
generated
vendored
Normal file
40
node_modules/tailwindcss/README.md
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
<p align="center">
|
||||
<a href="https://tailwindcss.com" target="_blank">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/tailwindlabs/tailwindcss/HEAD/.github/logo-dark.svg">
|
||||
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/tailwindlabs/tailwindcss/HEAD/.github/logo-light.svg">
|
||||
<img alt="Tailwind CSS" src="https://raw.githubusercontent.com/tailwindlabs/tailwindcss/HEAD/.github/logo-light.svg" width="350" height="70" style="max-width: 100%;">
|
||||
</picture>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
A utility-first CSS framework for rapidly building custom user interfaces.
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/tailwindlabs/tailwindcss/actions"><img src="https://img.shields.io/github/actions/workflow/status/tailwindlabs/tailwindcss/ci.yml?branch=next" alt="Build Status"></a>
|
||||
<a href="https://www.npmjs.com/package/tailwindcss"><img src="https://img.shields.io/npm/dt/tailwindcss.svg" alt="Total Downloads"></a>
|
||||
<a href="https://github.com/tailwindcss/tailwindcss/releases"><img src="https://img.shields.io/npm/v/tailwindcss.svg" alt="Latest Release"></a>
|
||||
<a href="https://github.com/tailwindcss/tailwindcss/blob/master/LICENSE"><img src="https://img.shields.io/npm/l/tailwindcss.svg" alt="License"></a>
|
||||
</p>
|
||||
|
||||
---
|
||||
|
||||
## Documentation
|
||||
|
||||
For full documentation, visit [tailwindcss.com](https://tailwindcss.com).
|
||||
|
||||
## Community
|
||||
|
||||
For help, discussion about best practices, or any other conversation that would benefit from being searchable:
|
||||
|
||||
[Discuss Tailwind CSS on GitHub](https://github.com/tailwindcss/tailwindcss/discussions)
|
||||
|
||||
For chatting with others using the framework:
|
||||
|
||||
[Join the Tailwind CSS Discord Server](https://discord.gg/7NF8GNe)
|
||||
|
||||
## Contributing
|
||||
|
||||
If you're interested in contributing to Tailwind CSS, please read our [contributing docs](https://github.com/tailwindcss/tailwindcss/blob/next/.github/CONTRIBUTING.md) **before submitting a pull request**.
|
35
node_modules/tailwindcss/dist/chunk-FEUCFEMW.mjs
generated
vendored
Normal file
35
node_modules/tailwindcss/dist/chunk-FEUCFEMW.mjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/tailwindcss/dist/chunk-HTB5LLOP.mjs
generated
vendored
Normal file
1
node_modules/tailwindcss/dist/chunk-HTB5LLOP.mjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/tailwindcss/dist/chunk-P5FH2LZE.mjs
generated
vendored
Normal file
1
node_modules/tailwindcss/dist/chunk-P5FH2LZE.mjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
295
node_modules/tailwindcss/dist/colors-b_6i0Oi7.d.ts
generated
vendored
Normal file
295
node_modules/tailwindcss/dist/colors-b_6i0Oi7.d.ts
generated
vendored
Normal file
@ -0,0 +1,295 @@
|
||||
declare const _default: {
|
||||
inherit: string;
|
||||
current: string;
|
||||
transparent: string;
|
||||
black: string;
|
||||
white: string;
|
||||
slate: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
gray: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
zinc: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
neutral: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
stone: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
red: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
orange: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
amber: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
yellow: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
lime: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
green: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
emerald: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
teal: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
cyan: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
sky: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
blue: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
indigo: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
violet: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
purple: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
fuchsia: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
pink: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
rose: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
};
|
||||
|
||||
export { _default as _ };
|
295
node_modules/tailwindcss/dist/colors.d.mts
generated
vendored
Normal file
295
node_modules/tailwindcss/dist/colors.d.mts
generated
vendored
Normal file
@ -0,0 +1,295 @@
|
||||
declare const _default: {
|
||||
inherit: string;
|
||||
current: string;
|
||||
transparent: string;
|
||||
black: string;
|
||||
white: string;
|
||||
slate: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
gray: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
zinc: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
neutral: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
stone: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
red: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
orange: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
amber: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
yellow: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
lime: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
green: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
emerald: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
teal: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
cyan: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
sky: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
blue: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
indigo: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
violet: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
purple: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
fuchsia: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
pink: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
rose: {
|
||||
'50': string;
|
||||
'100': string;
|
||||
'200': string;
|
||||
'300': string;
|
||||
'400': string;
|
||||
'500': string;
|
||||
'600': string;
|
||||
'700': string;
|
||||
'800': string;
|
||||
'900': string;
|
||||
'950': string;
|
||||
};
|
||||
};
|
||||
|
||||
export { _default as default };
|
5
node_modules/tailwindcss/dist/colors.d.ts
generated
vendored
Normal file
5
node_modules/tailwindcss/dist/colors.d.ts
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
import { _ as _default } from './colors-b_6i0Oi7.js';
|
||||
|
||||
|
||||
|
||||
export { _default as default };
|
1
node_modules/tailwindcss/dist/colors.js
generated
vendored
Normal file
1
node_modules/tailwindcss/dist/colors.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/tailwindcss/dist/colors.mjs
generated
vendored
Normal file
1
node_modules/tailwindcss/dist/colors.mjs
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
import{a}from"./chunk-HTB5LLOP.mjs";export{a as default};
|
1147
node_modules/tailwindcss/dist/default-theme.d.mts
generated
vendored
Normal file
1147
node_modules/tailwindcss/dist/default-theme.d.mts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1147
node_modules/tailwindcss/dist/default-theme.d.ts
generated
vendored
Normal file
1147
node_modules/tailwindcss/dist/default-theme.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/tailwindcss/dist/default-theme.js
generated
vendored
Normal file
1
node_modules/tailwindcss/dist/default-theme.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/tailwindcss/dist/default-theme.mjs
generated
vendored
Normal file
1
node_modules/tailwindcss/dist/default-theme.mjs
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
import{h as a}from"./chunk-P5FH2LZE.mjs";import"./chunk-HTB5LLOP.mjs";export{a as default};
|
6
node_modules/tailwindcss/dist/flatten-color-palette.d.mts
generated
vendored
Normal file
6
node_modules/tailwindcss/dist/flatten-color-palette.d.mts
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
type Colors = {
|
||||
[key: string | number]: string | Colors;
|
||||
};
|
||||
declare function flattenColorPalette(colors: Colors): Record<string, string>;
|
||||
|
||||
export { flattenColorPalette as default };
|
6
node_modules/tailwindcss/dist/flatten-color-palette.d.ts
generated
vendored
Normal file
6
node_modules/tailwindcss/dist/flatten-color-palette.d.ts
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
type Colors = {
|
||||
[key: string | number]: string | Colors;
|
||||
};
|
||||
declare function flattenColorPalette(colors: Colors): Record<string, string>;
|
||||
|
||||
export { flattenColorPalette as default };
|
3
node_modules/tailwindcss/dist/flatten-color-palette.js
generated
vendored
Normal file
3
node_modules/tailwindcss/dist/flatten-color-palette.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/tailwindcss/dist/flatten-color-palette.mjs
generated
vendored
Normal file
1
node_modules/tailwindcss/dist/flatten-color-palette.mjs
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
import"./chunk-FEUCFEMW.mjs";import"./chunk-P5FH2LZE.mjs";import"./chunk-HTB5LLOP.mjs";function i(r){let n={};for(let[e,t]of Object.entries(r??{}))if(e!=="__CSS_VALUES__")if(typeof t=="object"&&t!==null)for(let[o,f]of Object.entries(i(t)))n[`${e}${o==="DEFAULT"?"":`-${o}`}`]=f;else n[e]=t;if("__CSS_VALUES__"in r)for(let[e,t]of Object.entries(r.__CSS_VALUES__))(Number(t)&4)===0&&(n[e]=r[e]);return n}export{i as default};
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user