feat: update to tauri beta.24 (#1537)

* feat: update to tauri beta.24

* remove .tauri

* pnpm build
This commit is contained in:
Lucas Fernandes Nogueira
2024-07-12 17:59:17 -03:00
committed by GitHub
parent 9973f8ee83
commit 22a17980ff
70 changed files with 1363 additions and 533 deletions
+1 -1
View File
@@ -24,6 +24,6 @@
"LICENSE"
],
"dependencies": {
"@tauri-apps/api": "2.0.0-beta.14"
"@tauri-apps/api": "2.0.0-beta.15"
}
}
+1 -1
View File
@@ -23,6 +23,6 @@
"LICENSE"
],
"dependencies": {
"@tauri-apps/api": "2.0.0-beta.14"
"@tauri-apps/api": "2.0.0-beta.15"
}
}
+1 -1
View File
@@ -24,6 +24,6 @@
"LICENSE"
],
"dependencies": {
"@tauri-apps/api": "2.0.0-beta.14"
"@tauri-apps/api": "2.0.0-beta.15"
}
}
+1 -1
View File
@@ -24,6 +24,6 @@
"LICENSE"
],
"dependencies": {
"@tauri-apps/api": "2.0.0-beta.14"
"@tauri-apps/api": "2.0.0-beta.15"
}
}
+1 -1
View File
@@ -23,6 +23,6 @@
"LICENSE"
],
"dependencies": {
"@tauri-apps/api": "2.0.0-beta.14"
"@tauri-apps/api": "2.0.0-beta.15"
}
}
+1 -1
View File
@@ -23,6 +23,6 @@
"LICENSE"
],
"dependencies": {
"@tauri-apps/api": "2.0.0-beta.14"
"@tauri-apps/api": "2.0.0-beta.15"
}
}
+1 -1
View File
@@ -1 +1 @@
if("__TAURI__"in window){var __TAURI_PLUGIN_DEEPLINK__=function(e){"use strict";function n(e,n=!1){return window.__TAURI_INTERNALS__.transformCallback(e,n)}async function r(e,n={},r){return window.__TAURI_INTERNALS__.invoke(e,n,r)}var t;async function i(e,t,i){const a={kind:"Any"};return r("plugin:event|listen",{event:e,target:a,handler:n(t)}).then((n=>async()=>async function(e,n){await r("plugin:event|unlisten",{event:e,eventId:n})}(e,n)))}async function a(){return await r("plugin:deep-link|get_current")}return"function"==typeof SuppressedError&&SuppressedError,function(e){e.WINDOW_RESIZED="tauri://resize",e.WINDOW_MOVED="tauri://move",e.WINDOW_CLOSE_REQUESTED="tauri://close-requested",e.WINDOW_DESTROYED="tauri://destroyed",e.WINDOW_FOCUS="tauri://focus",e.WINDOW_BLUR="tauri://blur",e.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",e.WINDOW_THEME_CHANGED="tauri://theme-changed",e.WINDOW_CREATED="tauri://window-created",e.WEBVIEW_CREATED="tauri://webview-created",e.DRAG="tauri://drag",e.DROP="tauri://drop",e.DROP_OVER="tauri://drop-over",e.DROP_CANCELLED="tauri://drag-cancelled"}(t||(t={})),e.getCurrent=a,e.isRegistered=async function(e){return await r("plugin:deep-link|is_registered",{protocol:e})},e.onOpenUrl=async function(e){const n=await a();return n&&e(n),await i("deep-link://new-url",(n=>{e(n.payload)}))},e.register=async function(e){return await r("plugin:deep-link|register",{protocol:e})},e.unregister=async function(e){return await r("plugin:deep-link|unregister",{protocol:e})},e}({});Object.defineProperty(window.__TAURI__,"deepLink",{value:__TAURI_PLUGIN_DEEPLINK__})}
if("__TAURI__"in window){var __TAURI_PLUGIN_DEEPLINK__=function(e){"use strict";function n(e,n=!1){return window.__TAURI_INTERNALS__.transformCallback(e,n)}async function r(e,n={},r){return window.__TAURI_INTERNALS__.invoke(e,n,r)}var t;async function i(e,t,i){const a={kind:"Any"};return r("plugin:event|listen",{event:e,target:a,handler:n(t)}).then((n=>async()=>async function(e,n){await r("plugin:event|unlisten",{event:e,eventId:n})}(e,n)))}async function a(){return await r("plugin:deep-link|get_current")}return"function"==typeof SuppressedError&&SuppressedError,function(e){e.WINDOW_RESIZED="tauri://resize",e.WINDOW_MOVED="tauri://move",e.WINDOW_CLOSE_REQUESTED="tauri://close-requested",e.WINDOW_DESTROYED="tauri://destroyed",e.WINDOW_FOCUS="tauri://focus",e.WINDOW_BLUR="tauri://blur",e.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",e.WINDOW_THEME_CHANGED="tauri://theme-changed",e.WINDOW_CREATED="tauri://window-created",e.WEBVIEW_CREATED="tauri://webview-created",e.DRAG_ENTER="tauri://drag-enter",e.DRAG_OVER="tauri://drag-over",e.DRAG_DROP="tauri://drag-drop",e.DRAG_LEAVE="tauri://drag-leave"}(t||(t={})),e.getCurrent=a,e.isRegistered=async function(e){return await r("plugin:deep-link|is_registered",{protocol:e})},e.onOpenUrl=async function(e){const n=await a();return n&&e(n),await i("deep-link://new-url",(n=>{e(n.payload)}))},e.register=async function(e){return await r("plugin:deep-link|register",{protocol:e})},e.unregister=async function(e){return await r("plugin:deep-link|unregister",{protocol:e})},e}({});Object.defineProperty(window.__TAURI__,"deepLink",{value:__TAURI_PLUGIN_DEEPLINK__})}
+2 -2
View File
@@ -10,11 +10,11 @@
"tauri": "tauri"
},
"dependencies": {
"@tauri-apps/api": "2.0.0-beta.14",
"@tauri-apps/api": "2.0.0-beta.15",
"@tauri-apps/plugin-deep-link": "2.0.0-beta.8"
},
"devDependencies": {
"@tauri-apps/cli": "2.0.0-beta.21",
"@tauri-apps/cli": "2.0.0-beta.22",
"internal-ip": "7.0.0",
"typescript": "^5.2.2",
"vite": "^5.0.13"
@@ -2,6 +2,8 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
use tauri::Listener;
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
#[tauri::command]
fn greet(name: &str) -> String {
+1 -1
View File
@@ -24,6 +24,6 @@
"LICENSE"
],
"dependencies": {
"@tauri-apps/api": "2.0.0-beta.14"
"@tauri-apps/api": "2.0.0-beta.15"
}
}
+1 -1
View File
@@ -5,7 +5,7 @@
use serde::de::DeserializeOwned;
use tauri::{
plugin::{Builder, PluginApi, TauriPlugin},
AppHandle, Manager, Runtime,
AppHandle, Emitter, Manager, Runtime,
};
mod commands;
+1 -1
View File
@@ -23,6 +23,6 @@
"LICENSE"
],
"dependencies": {
"@tauri-apps/api": "2.0.0-beta.14"
"@tauri-apps/api": "2.0.0-beta.15"
}
}
+1 -1
View File
@@ -24,6 +24,6 @@
"LICENSE"
],
"dependencies": {
"@tauri-apps/api": "2.0.0-beta.14"
"@tauri-apps/api": "2.0.0-beta.15"
}
}
+1 -1
View File
@@ -110,7 +110,7 @@ pub fn init<R: Runtime>() -> TauriPlugin<R, Option<config::Config>> {
.on_event(|app, event| {
if let RunEvent::WindowEvent {
label: _,
event: WindowEvent::DragDrop(DragDropEvent::Dropped { paths, position: _ }),
event: WindowEvent::DragDrop(DragDropEvent::Drop { paths, position: _ }),
..
} = event
{
+6 -6
View File
@@ -50,29 +50,29 @@ enum WatcherKind {
Watcher(RecommendedWatcher),
}
fn watch_raw(on_event: Channel, rx: Receiver<notify::Result<Event>>) {
fn watch_raw(on_event: Channel<Event>, rx: Receiver<notify::Result<Event>>) {
spawn(move || {
while let Ok(event) = rx.recv() {
if let Ok(event) = event {
// TODO: Should errors be emitted too?
let _ = on_event.send(&event);
let _ = on_event.send(event);
}
}
});
}
fn watch_debounced(on_event: Channel, rx: Receiver<DebounceEventResult>) {
fn watch_debounced(on_event: Channel<Event>, rx: Receiver<DebounceEventResult>) {
spawn(move || {
while let Ok(Ok(events)) = rx.recv() {
for event in events {
// TODO: Should errors be emitted too?
let _ = on_event.send(&event.event);
let _ = on_event.send(event.event);
}
}
});
}
#[derive(Deserialize)]
#[derive(Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct WatchOptions {
base_dir: Option<BaseDirectory>,
@@ -85,7 +85,7 @@ pub async fn watch<R: Runtime>(
webview: Webview<R>,
paths: Vec<SafePathBuf>,
options: WatchOptions,
on_event: Channel,
on_event: Channel<Event>,
global_scope: GlobalScope<Entry>,
command_scope: CommandScope<Entry>,
) -> CommandResult<ResourceId> {
+1 -1
View File
@@ -23,6 +23,6 @@
"LICENSE"
],
"dependencies": {
"@tauri-apps/api": "2.0.0-beta.14"
"@tauri-apps/api": "2.0.0-beta.15"
}
}
@@ -1,7 +1,7 @@
## Default Permission
No features are enabled by default, as we believe
the shortcuts can be inherently dangerous and it is
the shortcuts can be inherently dangerous and it is
application specific if specific shortcuts should be
registered or unregistered.
@@ -365,7 +365,7 @@
]
},
{
"description": "default -> No features are enabled by default, as we believe\nthe shortcuts can be inherently dangerous and it is \napplication specific if specific shortcuts should be\nregistered or unregistered.\n",
"description": "default -> No features are enabled by default, as we believe\nthe shortcuts can be inherently dangerous and it is\napplication specific if specific shortcuts should be\nregistered or unregistered.\n",
"type": "string",
"enum": [
"default"
+2 -2
View File
@@ -244,7 +244,7 @@ where
.map_err(|e| Error::GlobalHotkey(e.to_string()))
}
#[derive(Serialize)]
#[derive(Clone, Serialize)]
struct ShortcutJsEvent {
shortcut: String,
id: u32,
@@ -256,7 +256,7 @@ fn register<R: Runtime>(
_app: AppHandle<R>,
global_shortcut: State<'_, GlobalShortcut<R>>,
shortcuts: Vec<String>,
handler: Channel,
handler: Channel<ShortcutJsEvent>,
) -> Result<()> {
let mut hotkeys = Vec::new();
+1 -1
View File
@@ -23,6 +23,6 @@
"LICENSE"
],
"dependencies": {
"@tauri-apps/api": "2.0.0-beta.14"
"@tauri-apps/api": "2.0.0-beta.15"
}
}
+1 -1
View File
@@ -1 +1 @@
if("__TAURI__"in window){var __TAURI_PLUGIN_LOG__=function(e){"use strict";function n(e,n=!1){return window.__TAURI_INTERNALS__.transformCallback(e,n)}async function r(e,n={},r){return window.__TAURI_INTERNALS__.invoke(e,n,r)}var a,t;async function o(e,a,t){const o={kind:"Any"};return r("plugin:event|listen",{event:e,target:o,handler:n(a)}).then((n=>async()=>async function(e,n){await r("plugin:event|unlisten",{event:e,eventId:n})}(e,n)))}async function i(e,n,a){const t=(new Error).stack?.split("\n").map((e=>e.split("@"))),o=t?.filter((([e,n])=>e.length>0&&"[native code]"!==n)),{file:i,line:c,keyValues:u}=a??{};let l=o?.[0]?.filter((e=>e.length>0)).join("@");"Error"===l&&(l="webview::unknown"),await r("plugin:log|log",{level:e,message:n,location:l,file:i,line:c,keyValues:u})}async function c(e){return await o("log://log",(n=>{const{level:r}=n.payload;let{message:a}=n.payload;a=a.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,""),e({message:a,level:r})}))}return"function"==typeof SuppressedError&&SuppressedError,function(e){e.WINDOW_RESIZED="tauri://resize",e.WINDOW_MOVED="tauri://move",e.WINDOW_CLOSE_REQUESTED="tauri://close-requested",e.WINDOW_DESTROYED="tauri://destroyed",e.WINDOW_FOCUS="tauri://focus",e.WINDOW_BLUR="tauri://blur",e.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",e.WINDOW_THEME_CHANGED="tauri://theme-changed",e.WINDOW_CREATED="tauri://window-created",e.WEBVIEW_CREATED="tauri://webview-created",e.DRAG="tauri://drag",e.DROP="tauri://drop",e.DROP_OVER="tauri://drop-over",e.DROP_CANCELLED="tauri://drag-cancelled"}(a||(a={})),function(e){e[e.Trace=1]="Trace",e[e.Debug=2]="Debug",e[e.Info=3]="Info",e[e.Warn=4]="Warn",e[e.Error=5]="Error"}(t||(t={})),e.attachConsole=async function(){return await c((({level:e,message:n})=>{switch(e){case t.Trace:console.log(n);break;case t.Debug:console.debug(n);break;case t.Info:console.info(n);break;case t.Warn:console.warn(n);break;case t.Error:console.error(n);break;default:throw new Error(`unknown log level ${e}`)}}))},e.attachLogger=c,e.debug=async function(e,n){await i(t.Debug,e,n)},e.error=async function(e,n){await i(t.Error,e,n)},e.info=async function(e,n){await i(t.Info,e,n)},e.trace=async function(e,n){await i(t.Trace,e,n)},e.warn=async function(e,n){await i(t.Warn,e,n)},e}({});Object.defineProperty(window.__TAURI__,"log",{value:__TAURI_PLUGIN_LOG__})}
if("__TAURI__"in window){var __TAURI_PLUGIN_LOG__=function(e){"use strict";function n(e,n=!1){return window.__TAURI_INTERNALS__.transformCallback(e,n)}async function r(e,n={},r){return window.__TAURI_INTERNALS__.invoke(e,n,r)}var a,t;async function o(e,a,t){const o={kind:"Any"};return r("plugin:event|listen",{event:e,target:o,handler:n(a)}).then((n=>async()=>async function(e,n){await r("plugin:event|unlisten",{event:e,eventId:n})}(e,n)))}async function i(e,n,a){const t=(new Error).stack?.split("\n").map((e=>e.split("@"))),o=t?.filter((([e,n])=>e.length>0&&"[native code]"!==n)),{file:i,line:c,keyValues:u}=a??{};let l=o?.[0]?.filter((e=>e.length>0)).join("@");"Error"===l&&(l="webview::unknown"),await r("plugin:log|log",{level:e,message:n,location:l,file:i,line:c,keyValues:u})}async function c(e){return await o("log://log",(n=>{const{level:r}=n.payload;let{message:a}=n.payload;a=a.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,""),e({message:a,level:r})}))}return"function"==typeof SuppressedError&&SuppressedError,function(e){e.WINDOW_RESIZED="tauri://resize",e.WINDOW_MOVED="tauri://move",e.WINDOW_CLOSE_REQUESTED="tauri://close-requested",e.WINDOW_DESTROYED="tauri://destroyed",e.WINDOW_FOCUS="tauri://focus",e.WINDOW_BLUR="tauri://blur",e.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",e.WINDOW_THEME_CHANGED="tauri://theme-changed",e.WINDOW_CREATED="tauri://window-created",e.WEBVIEW_CREATED="tauri://webview-created",e.DRAG_ENTER="tauri://drag-enter",e.DRAG_OVER="tauri://drag-over",e.DRAG_DROP="tauri://drag-drop",e.DRAG_LEAVE="tauri://drag-leave"}(a||(a={})),function(e){e[e.Trace=1]="Trace",e[e.Debug=2]="Debug",e[e.Info=3]="Info",e[e.Warn=4]="Warn",e[e.Error=5]="Error"}(t||(t={})),e.attachConsole=async function(){return await c((({level:e,message:n})=>{switch(e){case t.Trace:console.log(n);break;case t.Debug:console.debug(n);break;case t.Info:console.info(n);break;case t.Warn:console.warn(n);break;case t.Error:console.error(n);break;default:throw new Error(`unknown log level ${e}`)}}))},e.attachLogger=c,e.debug=async function(e,n){await i(t.Debug,e,n)},e.error=async function(e,n){await i(t.Error,e,n)},e.info=async function(e,n){await i(t.Info,e,n)},e.trace=async function(e,n){await i(t.Trace,e,n)},e.warn=async function(e,n){await i(t.Warn,e,n)},e}({});Object.defineProperty(window.__TAURI__,"log",{value:__TAURI_PLUGIN_LOG__})}
+1 -1
View File
@@ -24,6 +24,6 @@
"LICENSE"
],
"dependencies": {
"@tauri-apps/api": "2.0.0-beta.14"
"@tauri-apps/api": "2.0.0-beta.15"
}
}
+1
View File
@@ -24,6 +24,7 @@ use std::{
iter::FromIterator,
path::{Path, PathBuf},
};
use tauri::Emitter;
use tauri::{
plugin::{self, TauriPlugin},
Manager, Runtime,
+1 -1
View File
@@ -24,6 +24,6 @@
"LICENSE"
],
"dependencies": {
"@tauri-apps/api": "2.0.0-beta.14"
"@tauri-apps/api": "2.0.0-beta.15"
}
}
+1 -1
View File
@@ -23,6 +23,6 @@
"LICENSE"
],
"dependencies": {
"@tauri-apps/api": "2.0.0-beta.14"
"@tauri-apps/api": "2.0.0-beta.15"
}
}
+1 -1
View File
@@ -23,6 +23,6 @@
"LICENSE"
],
"dependencies": {
"@tauri-apps/api": "2.0.0-beta.14"
"@tauri-apps/api": "2.0.0-beta.15"
}
}
+1 -1
View File
@@ -24,6 +24,6 @@
"LICENSE"
],
"dependencies": {
"@tauri-apps/api": "2.0.0-beta.14"
"@tauri-apps/api": "2.0.0-beta.15"
}
}
+1 -1
View File
@@ -23,6 +23,6 @@
"LICENSE"
],
"dependencies": {
"@tauri-apps/api": "2.0.0-beta.14"
"@tauri-apps/api": "2.0.0-beta.15"
}
}
+1
View File
@@ -0,0 +1 @@
/.tauri
+1 -1
View File
@@ -23,6 +23,6 @@
"LICENSE"
],
"dependencies": {
"@tauri-apps/api": "2.0.0-beta.14"
"@tauri-apps/api": "2.0.0-beta.15"
}
}
+5 -5
View File
@@ -23,7 +23,7 @@ type ChildId = u32;
#[derive(Debug, Clone, Serialize)]
#[serde(tag = "event", content = "payload")]
#[non_exhaustive]
enum JSCommandEvent {
pub enum JSCommandEvent {
/// Stderr bytes until a newline (\n) or carriage return (\r) is found.
Stderr(Buffer),
/// Stdout bytes until a newline (\n) or carriage return (\r) is found.
@@ -233,7 +233,7 @@ pub fn spawn<R: Runtime>(
shell: State<'_, Shell<R>>,
program: String,
args: ExecuteArgs,
on_event: Channel,
on_event: Channel<JSCommandEvent>,
options: CommandOptions,
command_scope: CommandScope<crate::scope::ScopeAllowedCommand>,
global_scope: GlobalScope<crate::scope::ScopeAllowedCommand>,
@@ -254,14 +254,14 @@ pub fn spawn<R: Runtime>(
};
let js_event = JSCommandEvent::new(event, encoding);
if on_event.send(&js_event).is_err() {
if on_event.send(js_event.clone()).is_err() {
fn send<'a>(
on_event: &'a Channel,
on_event: &'a Channel<JSCommandEvent>,
js_event: &'a JSCommandEvent,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>> {
Box::pin(async move {
tokio::time::sleep(std::time::Duration::from_millis(15)).await;
if on_event.send(js_event).is_err() {
if on_event.send(js_event.clone()).is_err() {
send(on_event, js_event).await;
}
})
-215
View File
@@ -1,215 +0,0 @@
{
"name": "app",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "app",
"version": "1.0.0",
"license": "MIT",
"devDependencies": {
"@tauri-apps/cli": "2.0.0-beta.21"
}
},
"node_modules/@tauri-apps/cli": {
"version": "2.0.0-beta.21",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli/-/cli-2.0.0-beta.21.tgz",
"integrity": "sha512-lqV4pD0iTs8ASd19slH0eRoVAjbxtD0cCsZFVD7kG4sYkeZ0IkvtxbvnHAOUbALfvnHZr1dVXFDVxQUqJK2OXw==",
"dev": true,
"license": "Apache-2.0 OR MIT",
"bin": {
"tauri": "tauri.js"
},
"engines": {
"node": ">= 10"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/tauri"
},
"optionalDependencies": {
"@tauri-apps/cli-darwin-arm64": "2.0.0-beta.21",
"@tauri-apps/cli-darwin-x64": "2.0.0-beta.21",
"@tauri-apps/cli-linux-arm-gnueabihf": "2.0.0-beta.21",
"@tauri-apps/cli-linux-arm64-gnu": "2.0.0-beta.21",
"@tauri-apps/cli-linux-arm64-musl": "2.0.0-beta.21",
"@tauri-apps/cli-linux-x64-gnu": "2.0.0-beta.21",
"@tauri-apps/cli-linux-x64-musl": "2.0.0-beta.21",
"@tauri-apps/cli-win32-arm64-msvc": "2.0.0-beta.21",
"@tauri-apps/cli-win32-ia32-msvc": "2.0.0-beta.21",
"@tauri-apps/cli-win32-x64-msvc": "2.0.0-beta.21"
}
},
"node_modules/@tauri-apps/cli-darwin-arm64": {
"version": "2.0.0-beta.21",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-darwin-arm64/-/cli-darwin-arm64-2.0.0-beta.21.tgz",
"integrity": "sha512-okI7PRSC6RO4JfrOTqu4oWf0IfBPbkGHisyDOTay6K5uhz4zzry5fFJVa8S/DTrKtdjau4vcik/EDCxiGRun9Q==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-darwin-x64": {
"version": "2.0.0-beta.21",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-darwin-x64/-/cli-darwin-x64-2.0.0-beta.21.tgz",
"integrity": "sha512-mXoJDXB6CBoqUnFb4TCsSVC6FJRZsN1DHRZAyn6iNLIhOrObcM4L2xz8rzt3WirANwJ/ayrNv95fEt8Fq1jmgA==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-linux-arm-gnueabihf": {
"version": "2.0.0-beta.21",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm-gnueabihf/-/cli-linux-arm-gnueabihf-2.0.0-beta.21.tgz",
"integrity": "sha512-LYPOx3LE2eZ0g8Zh/HYaNg6B1pZzH4BPMcma7wGZ0XPu+4fKLLGgav13xP2lknLnxiRP9jJCaTIBKXgcQEtLyg==",
"cpu": [
"arm"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-linux-arm64-gnu": {
"version": "2.0.0-beta.21",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm64-gnu/-/cli-linux-arm64-gnu-2.0.0-beta.21.tgz",
"integrity": "sha512-VP2L729tgY889OZj5U436EntjwkI8MyVB+GrvBv8k2mj1nWB651KiVIpcUmsUgjXZ2r01bifN9J0l+3EFEXUAQ==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-linux-arm64-musl": {
"version": "2.0.0-beta.21",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm64-musl/-/cli-linux-arm64-musl-2.0.0-beta.21.tgz",
"integrity": "sha512-s1rV01RIdowlPHfw7hTBnCEm2C3mZbynF+xpyRSv9vSczu4dpfwILMRwxB4nzMzdJ7RPHsf/R+5Ww86e8QM4Gw==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-linux-x64-gnu": {
"version": "2.0.0-beta.21",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-x64-gnu/-/cli-linux-x64-gnu-2.0.0-beta.21.tgz",
"integrity": "sha512-yGh7ktUycHT3mAnKxC7cx/vjcbjJzoxQCxnjWpmIayVwq+iXLD1mK7nRXRdJpL/rnBFTqqD29CKuypCEFiq3/A==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-linux-x64-musl": {
"version": "2.0.0-beta.21",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-x64-musl/-/cli-linux-x64-musl-2.0.0-beta.21.tgz",
"integrity": "sha512-+79b8O3tsjbGR47pJtcSKGmtqj4rsSxB5AfMb4UCkmoNkbaOzB0YS/ZieUGAb+SHXZ/MMs7mcl96N9SqYOL7hw==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-win32-arm64-msvc": {
"version": "2.0.0-beta.21",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-arm64-msvc/-/cli-win32-arm64-msvc-2.0.0-beta.21.tgz",
"integrity": "sha512-rKlpcjx6t1ECZciMmHT5xkXKjC+O+TVxRKmA21tEq/Ezt7XdnufGko1hduwQmVJWkHxKg6ab7uf98ImMpDC5UA==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-win32-ia32-msvc": {
"version": "2.0.0-beta.21",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-ia32-msvc/-/cli-win32-ia32-msvc-2.0.0-beta.21.tgz",
"integrity": "sha512-ExdhvRfgAoZi4/7re6OkmfqsHvTJQgWouTNphHWRilUEqBM7TEQV1UxYtwWfgyOKelyx4cxUYDFAJxootTb2Nw==",
"cpu": [
"ia32"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-win32-x64-msvc": {
"version": "2.0.0-beta.21",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-x64-msvc/-/cli-win32-x64-msvc-2.0.0-beta.21.tgz",
"integrity": "sha512-JtNTwNXIOfE04Cs3ieTvkdcMyJM9Sujw5MM9zNmusJKE03s/OLqbNK/2ISlcb/puwYGGPhhyYtL5hCmYXIrHHQ==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
}
}
}
@@ -9,6 +9,6 @@
"author": "",
"license": "MIT",
"devDependencies": {
"@tauri-apps/cli": "2.0.0-beta.21"
"@tauri-apps/cli": "2.0.0-beta.22"
}
}
+1 -1
View File
@@ -24,6 +24,6 @@
"LICENSE"
],
"dependencies": {
"@tauri-apps/api": "2.0.0-beta.14"
"@tauri-apps/api": "2.0.0-beta.15"
}
}
+10
View File
@@ -0,0 +1,10 @@
.DS_Store
/.build
/Packages
/*.xcodeproj
xcuserdata/
DerivedData/
.swiftpm/config/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
Package.resolved
@@ -0,0 +1,40 @@
// swift-tools-version:5.3
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
import PackageDescription
let package = Package(
name: "Tauri",
platforms: [
.macOS(.v10_13),
.iOS(.v11),
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "Tauri",
type: .static,
targets: ["Tauri"])
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(name: "SwiftRs", url: "https://github.com/Brendonovich/swift-rs", from: "1.0.0")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "Tauri",
dependencies: [
.byName(name: "SwiftRs")
],
path: "Sources"
),
.testTarget(
name: "TauriTests",
dependencies: ["Tauri"]
),
]
)
+3
View File
@@ -0,0 +1,3 @@
# Tauri
Tauri iOS API.
@@ -0,0 +1,65 @@
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
import Foundation
let CHANNEL_PREFIX = "__CHANNEL__:"
let channelDataKey = CodingUserInfoKey(rawValue: "sendChannelData")!
public class Channel: Decodable {
public let id: UInt64
let handler: (UInt64, String) -> Void
public required init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
let channelDef = try container.decode(String.self)
let components = channelDef.components(separatedBy: CHANNEL_PREFIX)
if components.count < 2 {
throw DecodingError.dataCorruptedError(
in: container,
debugDescription: "Invalid channel definition from \(channelDef)"
)
}
guard let channelId = UInt64(components[1]) else {
throw DecodingError.dataCorruptedError(
in: container,
debugDescription: "Invalid channel ID from \(channelDef)"
)
}
guard let handler = decoder.userInfo[channelDataKey] as? (UInt64, String) -> Void else {
throw DecodingError.dataCorruptedError(
in: container,
debugDescription: "missing userInfo for Channel handler. This is a Tauri issue"
)
}
self.id = channelId
self.handler = handler
}
func serialize(_ data: JsonValue) -> String {
do {
return try data.jsonRepresentation() ?? "\"Failed to serialize payload\""
} catch {
return "\"\(error)\""
}
}
public func send(_ data: JsonObject) {
send(.dictionary(data))
}
public func send(_ data: JsonValue) {
handler(id, serialize(data))
}
public func send<T: Encodable>(_ data: T) throws {
let json = try JSONEncoder().encode(data)
handler(id, String(decoding: json, as: UTF8.self))
}
}
@@ -0,0 +1,107 @@
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
import Foundation
import UIKit
@objc public class Invoke: NSObject {
public let command: String
let callback: UInt64
let error: UInt64
let data: String
let sendResponse: (UInt64, String?) -> Void
let sendChannelData: (UInt64, String) -> Void
public init(
command: String, callback: UInt64, error: UInt64,
sendResponse: @escaping (UInt64, String?) -> Void,
sendChannelData: @escaping (UInt64, String) -> Void, data: String
) {
self.command = command
self.callback = callback
self.error = error
self.data = data
self.sendResponse = sendResponse
self.sendChannelData = sendChannelData
}
public func parseArgs<T: Decodable>(_ type: T.Type) throws -> T {
let jsonData = self.data.data(using: .utf8)!
let decoder = JSONDecoder()
decoder.userInfo[channelDataKey] = sendChannelData
return try decoder.decode(type, from: jsonData)
}
func serialize(_ data: JsonValue) -> String {
do {
return try data.jsonRepresentation() ?? "\"Failed to serialize payload\""
} catch {
return "\"\(error)\""
}
}
public func resolve() {
sendResponse(callback, nil)
}
public func resolve(_ data: JsonObject) {
resolve(.dictionary(data))
}
public func resolve(_ data: JsonValue) {
sendResponse(callback, serialize(data))
}
public func resolve<T: Encodable>(_ data: T) {
do {
let json = try JSONEncoder().encode(data)
sendResponse(callback, String(decoding: json, as: UTF8.self))
} catch {
sendResponse(self.error, "\"\(error)\"")
}
}
public func reject(
_ message: String, code: String? = nil, error: Error? = nil, data: JsonValue? = nil
) {
let payload: NSMutableDictionary = [
"message": message
]
if let code = code {
payload["code"] = code
}
if let error = error {
payload["error"] = error
}
if let data = data {
switch data {
case .dictionary(let dict):
for entry in dict {
payload[entry.key] = entry.value
}
}
}
sendResponse(self.error, serialize(.dictionary(payload as! JsonObject)))
}
public func unimplemented() {
unimplemented("not implemented")
}
public func unimplemented(_ message: String) {
reject(message)
}
public func unavailable() {
unavailable("not available")
}
public func unavailable(_ message: String) {
reject(message)
}
}
@@ -0,0 +1,22 @@
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
import Foundation
// declare our empty protocol, and conformance, for typing
public protocol JSValue {}
extension String: JSValue {}
extension Bool: JSValue {}
extension Int: JSValue {}
extension Float: JSValue {}
extension Double: JSValue {}
extension NSNumber: JSValue {}
extension NSNull: JSValue {}
extension Array: JSValue {}
extension Date: JSValue {}
extension Dictionary: JSValue where Key == String, Value == JSValue {}
// convenience aliases
public typealias JSObject = [String: JSValue]
public typealias JSArray = [JSValue]
@@ -0,0 +1,58 @@
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
import Foundation
public typealias JsonObject = [String: Any]
public enum JsonValue {
case dictionary(JsonObject)
enum SerializationError: Error {
case invalidObject
}
public func jsonRepresentation(includingFields: JsonObject? = nil) throws -> String? {
switch self {
case .dictionary(var dictionary):
if let fields = includingFields {
dictionary.merge(fields) { (current, _) in current }
}
dictionary = prepare(dictionary: dictionary)
guard JSONSerialization.isValidJSONObject(dictionary) else {
throw SerializationError.invalidObject
}
let data = try JSONSerialization.data(withJSONObject: dictionary, options: [])
return String(data: data, encoding: .utf8)
}
}
private static let formatter = ISO8601DateFormatter()
private func prepare(dictionary: JsonObject) -> JsonObject {
return dictionary.mapValues { (value) -> Any in
if let date = value as? Date {
return JsonValue.formatter.string(from: date)
} else if let aDictionary = value as? JsonObject {
return prepare(dictionary: aDictionary)
} else if let anArray = value as? [Any] {
return prepare(array: anArray)
}
return value
}
}
private func prepare(array: [Any]) -> [Any] {
return array.map { (value) -> Any in
if let date = value as? Date {
return JsonValue.formatter.string(from: date)
} else if let aDictionary = value as? JsonObject {
return prepare(dictionary: aDictionary)
} else if let anArray = value as? [Any] {
return prepare(array: anArray)
}
return value
}
}
}
@@ -0,0 +1,58 @@
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
import os.log
import UIKit
/// Wrapper class for os_log function
public class Logger {
private static var _enabled = false
public static var enabled: Bool {
get {
#if DEBUG
return true
#else
return _enabled
#endif
}
set {
Logger._enabled = newValue
}
}
static func log(_ items: Any..., category: String, type: OSLogType) {
if Logger.enabled {
var message = ""
let last = items.count - 1
for (index, item) in items.enumerated() {
message += "\(item)"
if index != last {
message += " "
}
}
let log = OSLog(subsystem: Bundle.main.bundleIdentifier ?? "-", category: category)
os_log("%{public}@", log: log, type: type, String(message.prefix(4068)))
}
}
public static func debug(_ items: Any..., category: String = "app") {
#if DEBUG
Logger.log(items, category: category, type: OSLogType.default)
#else
Logger.log(items, category: category, type: OSLogType.debug)
#endif
}
public static func info(_ items: Any..., category: String = "app") {
#if DEBUG
Logger.log(items, category: category, type: OSLogType.default)
#else
Logger.log(items, category: category, type: OSLogType.info)
#endif
}
public static func error(_ items: Any..., category: String = "app") {
Logger.log(items, category: category, type: OSLogType.error)
}
}
@@ -0,0 +1,81 @@
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
import WebKit
import os.log
struct RegisterListenerArgs: Decodable {
let event: String
let handler: Channel
}
struct RemoveListenerArgs: Decodable {
let event: String
let channelId: UInt64
}
open class Plugin: NSObject {
public let manager: PluginManager = PluginManager.shared
var config: String = "{}"
private var listeners = [String: [Channel]]()
internal func setConfig(_ config: String) {
self.config = config
}
public func parseConfig<T: Decodable>(_ type: T.Type) throws -> T {
let jsonData = self.config.data(using: .utf8)!
let decoder = JSONDecoder()
return try decoder.decode(type, from: jsonData)
}
@objc open func load(webview: WKWebView) {}
@objc open func checkPermissions(_ invoke: Invoke) {
invoke.resolve()
}
@objc open func requestPermissions(_ invoke: Invoke) {
invoke.resolve()
}
public func trigger(_ event: String, data: JSObject) {
if let eventListeners = listeners[event] {
for channel in eventListeners {
channel.send(data)
}
}
}
public func trigger<T: Encodable>(_ event: String, data: T) throws {
if let eventListeners = listeners[event] {
for channel in eventListeners {
try channel.send(data)
}
}
}
@objc func registerListener(_ invoke: Invoke) throws {
let args = try invoke.parseArgs(RegisterListenerArgs.self)
if var eventListeners = listeners[args.event] {
eventListeners.append(args.handler)
} else {
listeners[args.event] = [args.handler]
}
invoke.resolve()
}
@objc func removeListener(_ invoke: Invoke) throws {
let args = try invoke.parseArgs(RemoveListenerArgs.self)
if let eventListeners = listeners[args.event] {
listeners[args.event] = eventListeners.filter { $0.id != args.channelId }
}
invoke.resolve()
}
}
@@ -0,0 +1,134 @@
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
import Foundation
import SwiftRs
import UIKit
import WebKit
import os.log
class PluginHandle {
var instance: Plugin
var loaded = false
init(plugin: Plugin) {
instance = plugin
}
}
public class PluginManager {
static let shared: PluginManager = PluginManager()
public var viewController: UIViewController?
var plugins: [String: PluginHandle] = [:]
var ipcDispatchQueue = DispatchQueue(label: "ipc")
public var isSimEnvironment: Bool {
#if targetEnvironment(simulator)
return true
#else
return false
#endif
}
public func assetUrl(fromLocalURL url: URL?) -> URL? {
guard let inputURL = url else {
return nil
}
return URL(string: "asset://localhost")!.appendingPathComponent(inputURL.path)
}
func onWebviewCreated(_ webview: WKWebView) {
for (_, handle) in plugins {
if !handle.loaded {
handle.instance.load(webview: webview)
}
}
}
func load<P: Plugin>(name: String, plugin: P, config: String, webview: WKWebView?) {
plugin.setConfig(config)
let handle = PluginHandle(plugin: plugin)
if let webview = webview {
handle.instance.load(webview: webview)
handle.loaded = true
}
plugins[name] = handle
}
func invoke(name: String, invoke: Invoke) {
if let plugin = plugins[name] {
ipcDispatchQueue.async {
let selectorWithThrows = Selector(("\(invoke.command):error:"))
if plugin.instance.responds(to: selectorWithThrows) {
var error: NSError? = nil
withUnsafeMutablePointer(to: &error) {
let methodIMP: IMP! = plugin.instance.method(for: selectorWithThrows)
unsafeBitCast(
methodIMP, to: (@convention(c) (Any?, Selector, Invoke, OpaquePointer) -> Void).self)(
plugin.instance, selectorWithThrows, invoke, OpaquePointer($0))
}
if let error = error {
invoke.reject("\(error)")
// TODO: app crashes without this leak
let _ = Unmanaged.passRetained(error)
}
} else {
let selector = Selector(("\(invoke.command):"))
if plugin.instance.responds(to: selector) {
plugin.instance.perform(selector, with: invoke)
} else {
invoke.reject("No command \(invoke.command) found for plugin \(name)")
}
}
}
} else {
invoke.reject("Plugin \(name) not initialized")
}
}
}
extension PluginManager: NSCopying {
public func copy(with zone: NSZone? = nil) -> Any {
return self
}
}
@_cdecl("register_plugin")
func registerPlugin(name: SRString, plugin: NSObject, config: SRString, webview: WKWebView?) {
PluginManager.shared.load(
name: name.toString(),
plugin: plugin as! Plugin,
config: config.toString(),
webview: webview
)
}
@_cdecl("on_webview_created")
func onWebviewCreated(webview: WKWebView, viewController: UIViewController) {
PluginManager.shared.viewController = viewController
PluginManager.shared.onWebviewCreated(webview)
}
@_cdecl("run_plugin_command")
func runCommand(
id: Int,
name: SRString,
command: SRString,
data: SRString,
callback: @escaping @convention(c) (Int, Bool, UnsafePointer<CChar>) -> Void,
sendChannelData: @escaping @convention(c) (UInt64, UnsafePointer<CChar>) -> Void
) {
let callbackId: UInt64 = 0
let errorId: UInt64 = 1
let invoke = Invoke(
command: command.toString(), callback: callbackId, error: errorId,
sendResponse: { (fn: UInt64, payload: String?) -> Void in
let success = fn == callbackId
callback(id, success, payload ?? "null")
},
sendChannelData: { (id: UInt64, payload: String) -> Void in
sendChannelData(id, payload)
}, data: data.toString())
PluginManager.shared.invoke(name: name.toString(), invoke: invoke)
}
@@ -0,0 +1,15 @@
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
import UIKit
public class UIUtils {
public static func centerPopover(rootViewController: UIViewController?, popoverController: UIViewController) {
if let viewController = rootViewController {
popoverController.popoverPresentationController?.sourceRect = CGRect(x: viewController.view.center.x, y: viewController.view.center.y, width: 0, height: 0)
popoverController.popoverPresentationController?.sourceView = viewController.view
popoverController.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection.up
}
}
}
+1 -1
View File
@@ -1 +1 @@
if("__TAURI__"in window){var __TAURI_PLUGIN_STORE__=function(t){"use strict";function a(t,a=!1){return window.__TAURI_INTERNALS__.transformCallback(t,a)}async function e(t,a={},e){return window.__TAURI_INTERNALS__.invoke(t,a,e)}var n;async function r(t,n,r){const i={kind:"Any"};return e("plugin:event|listen",{event:t,target:i,handler:a(n)}).then((a=>async()=>async function(t,a){await e("plugin:event|unlisten",{event:t,eventId:a})}(t,a)))}"function"==typeof SuppressedError&&SuppressedError,function(t){t.WINDOW_RESIZED="tauri://resize",t.WINDOW_MOVED="tauri://move",t.WINDOW_CLOSE_REQUESTED="tauri://close-requested",t.WINDOW_DESTROYED="tauri://destroyed",t.WINDOW_FOCUS="tauri://focus",t.WINDOW_BLUR="tauri://blur",t.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",t.WINDOW_THEME_CHANGED="tauri://theme-changed",t.WINDOW_CREATED="tauri://window-created",t.WEBVIEW_CREATED="tauri://webview-created",t.DRAG="tauri://drag",t.DROP="tauri://drop",t.DROP_OVER="tauri://drop-over",t.DROP_CANCELLED="tauri://drag-cancelled"}(n||(n={}));return t.Store=class{constructor(t){this.path=t}async set(t,a){await e("plugin:store|set",{path:this.path,key:t,value:a})}async get(t){return await e("plugin:store|get",{path:this.path,key:t})}async has(t){return await e("plugin:store|has",{path:this.path,key:t})}async delete(t){return await e("plugin:store|delete",{path:this.path,key:t})}async clear(){await e("plugin:store|clear",{path:this.path})}async reset(){await e("plugin:store|reset",{path:this.path})}async keys(){return await e("plugin:store|keys",{path:this.path})}async values(){return await e("plugin:store|values",{path:this.path})}async entries(){return await e("plugin:store|entries",{path:this.path})}async length(){return await e("plugin:store|length",{path:this.path})}async load(){await e("plugin:store|load",{path:this.path})}async save(){await e("plugin:store|save",{path:this.path})}async onKeyChange(t,a){return await r("store://change",(e=>{e.payload.path===this.path&&e.payload.key===t&&a(e.payload.value)}))}async onChange(t){return await r("store://change",(a=>{a.payload.path===this.path&&t(a.payload.key,a.payload.value)}))}},t}({});Object.defineProperty(window.__TAURI__,"store",{value:__TAURI_PLUGIN_STORE__})}
if("__TAURI__"in window){var __TAURI_PLUGIN_STORE__=function(t){"use strict";function a(t,a=!1){return window.__TAURI_INTERNALS__.transformCallback(t,a)}async function e(t,a={},e){return window.__TAURI_INTERNALS__.invoke(t,a,e)}var n;async function r(t,n,r){const i={kind:"Any"};return e("plugin:event|listen",{event:t,target:i,handler:a(n)}).then((a=>async()=>async function(t,a){await e("plugin:event|unlisten",{event:t,eventId:a})}(t,a)))}"function"==typeof SuppressedError&&SuppressedError,function(t){t.WINDOW_RESIZED="tauri://resize",t.WINDOW_MOVED="tauri://move",t.WINDOW_CLOSE_REQUESTED="tauri://close-requested",t.WINDOW_DESTROYED="tauri://destroyed",t.WINDOW_FOCUS="tauri://focus",t.WINDOW_BLUR="tauri://blur",t.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",t.WINDOW_THEME_CHANGED="tauri://theme-changed",t.WINDOW_CREATED="tauri://window-created",t.WEBVIEW_CREATED="tauri://webview-created",t.DRAG_ENTER="tauri://drag-enter",t.DRAG_OVER="tauri://drag-over",t.DRAG_DROP="tauri://drag-drop",t.DRAG_LEAVE="tauri://drag-leave"}(n||(n={}));return t.Store=class{constructor(t){this.path=t}async set(t,a){await e("plugin:store|set",{path:this.path,key:t,value:a})}async get(t){return await e("plugin:store|get",{path:this.path,key:t})}async has(t){return await e("plugin:store|has",{path:this.path,key:t})}async delete(t){return await e("plugin:store|delete",{path:this.path,key:t})}async clear(){await e("plugin:store|clear",{path:this.path})}async reset(){await e("plugin:store|reset",{path:this.path})}async keys(){return await e("plugin:store|keys",{path:this.path})}async values(){return await e("plugin:store|values",{path:this.path})}async entries(){return await e("plugin:store|entries",{path:this.path})}async length(){return await e("plugin:store|length",{path:this.path})}async load(){await e("plugin:store|load",{path:this.path})}async save(){await e("plugin:store|save",{path:this.path})}async onKeyChange(t,a){return await r("store://change",(e=>{e.payload.path===this.path&&e.payload.key===t&&a(e.payload.value)}))}async onChange(t){return await r("store://change",(a=>{a.payload.path===this.path&&t(a.payload.key,a.payload.value)}))}},t}({});Object.defineProperty(window.__TAURI__,"store",{value:__TAURI_PLUGIN_STORE__})}
+1 -1
View File
@@ -24,6 +24,6 @@
"LICENSE"
],
"dependencies": {
"@tauri-apps/api": "2.0.0-beta.14"
"@tauri-apps/api": "2.0.0-beta.15"
}
}
+6 -6
View File
@@ -10,7 +10,7 @@ use std::{
collections::HashMap,
path::{Path, PathBuf},
};
use tauri::{AppHandle, Manager, Runtime};
use tauri::{AppHandle, Emitter, Runtime};
type SerializeFn =
fn(&HashMap<String, JsonValue>) -> Result<Vec<u8>, Box<dyn std::error::Error + Send + Sync>>;
@@ -51,7 +51,7 @@ impl<R: Runtime> StoreBuilder<R> {
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
/// use tauri_plugin_store::StoreBuilder;
///
/// let builder = StoreBuilder::new("store.bin");
/// let builder = StoreBuilder::<tauri::Wry>::new("store.bin");
///
/// # Ok(())
/// # }
@@ -89,7 +89,7 @@ impl<R: Runtime> StoreBuilder<R> {
///
/// defaults.insert("foo".to_string(), "bar".into());
///
/// let builder = StoreBuilder::new("store.bin")
/// let builder = StoreBuilder::<tauri::Wry>::new("store.bin")
/// .defaults(defaults);
///
/// # Ok(())
@@ -107,7 +107,7 @@ impl<R: Runtime> StoreBuilder<R> {
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
/// use tauri_plugin_store::StoreBuilder;
///
/// let builder = StoreBuilder::new("store.bin")
/// let builder = StoreBuilder::<tauri::Wry>::new("store.bin")
/// .default("foo".to_string(), "bar".into());
///
/// # Ok(())
@@ -127,7 +127,7 @@ impl<R: Runtime> StoreBuilder<R> {
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
/// use tauri_plugin_store::StoreBuilder;
///
/// let builder = StoreBuilder::new("store.json")
/// let builder = StoreBuilder::<tauri::Wry>::new("store.json")
/// .serialize(|cache| serde_json::to_vec(&cache).map_err(Into::into));
///
/// # Ok(())
@@ -144,7 +144,7 @@ impl<R: Runtime> StoreBuilder<R> {
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
/// use tauri_plugin_store::StoreBuilder;
///
/// let builder = StoreBuilder::new("store.json")
/// let builder = StoreBuilder::<tauri::Wry>::new("store.json")
/// .deserialize(|bytes| serde_json::from_slice(&bytes).map_err(Into::into));
///
/// # Ok(())
+1 -1
View File
@@ -24,6 +24,6 @@
"LICENSE"
],
"dependencies": {
"@tauri-apps/api": "2.0.0-beta.14"
"@tauri-apps/api": "2.0.0-beta.15"
}
}
+1 -1
View File
@@ -23,6 +23,6 @@
"LICENSE"
],
"dependencies": {
"@tauri-apps/api": "2.0.0-beta.14"
"@tauri-apps/api": "2.0.0-beta.15"
}
}
+5 -5
View File
@@ -10,7 +10,7 @@ use tauri::{ipc::Channel, Manager, Resource, ResourceId, Runtime, Webview};
use std::time::Duration;
use url::Url;
#[derive(Debug, Serialize)]
#[derive(Debug, Clone, Serialize)]
#[serde(tag = "event", content = "data")]
pub enum DownloadEvent {
#[serde(rename_all = "camelCase")]
@@ -82,7 +82,7 @@ pub(crate) async fn check<R: Runtime>(
pub(crate) async fn download<R: Runtime>(
webview: Webview<R>,
rid: ResourceId,
on_event: Channel,
on_event: Channel<DownloadEvent>,
) -> Result<ResourceId> {
let update = webview.resources_table().get::<Update>(rid)?;
let mut first_chunk = true;
@@ -96,7 +96,7 @@ pub(crate) async fn download<R: Runtime>(
let _ = on_event.send(DownloadEvent::Progress { chunk_length });
},
|| {
let _ = on_event.send(&DownloadEvent::Finished);
let _ = on_event.send(DownloadEvent::Finished);
},
)
.await?;
@@ -122,7 +122,7 @@ pub(crate) async fn install<R: Runtime>(
pub(crate) async fn download_and_install<R: Runtime>(
webview: Webview<R>,
rid: ResourceId,
on_event: Channel,
on_event: Channel<DownloadEvent>,
) -> Result<()> {
let update = webview.resources_table().get::<Update>(rid)?;
@@ -138,7 +138,7 @@ pub(crate) async fn download_and_install<R: Runtime>(
let _ = on_event.send(DownloadEvent::Progress { chunk_length });
},
|| {
let _ = on_event.send(&DownloadEvent::Finished);
let _ = on_event.send(DownloadEvent::Finished);
},
)
.await?;
+1 -1
View File
@@ -24,6 +24,6 @@
"LICENSE"
],
"dependencies": {
"@tauri-apps/api": "2.0.0-beta.14"
"@tauri-apps/api": "2.0.0-beta.15"
}
}
+4 -4
View File
@@ -65,7 +65,7 @@ async fn download(
url: &str,
file_path: &str,
headers: HashMap<String, String>,
on_progress: Channel,
on_progress: Channel<ProgressPayload>,
) -> Result<()> {
let client = reqwest::Client::new();
@@ -84,7 +84,7 @@ async fn download(
while let Some(chunk) = stream.try_next().await? {
file.write_all(&chunk).await?;
let _ = on_progress.send(&ProgressPayload {
let _ = on_progress.send(ProgressPayload {
progress: chunk.len() as u64,
total,
});
@@ -99,7 +99,7 @@ async fn upload(
url: &str,
file_path: &str,
headers: HashMap<String, String>,
on_progress: Channel,
on_progress: Channel<ProgressPayload>,
) -> Result<String> {
// Read the file
let file = File::open(file_path).await?;
@@ -129,7 +129,7 @@ async fn upload(
}
}
fn file_to_body(channel: Channel, file: File) -> reqwest::Body {
fn file_to_body(channel: Channel<ProgressPayload>, file: File) -> reqwest::Body {
let stream = FramedRead::new(file, BytesCodec::new()).map_ok(|r| r.freeze());
reqwest::Body::wrap_stream(ReadProgressStream::new(
@@ -9,7 +9,7 @@
"preview": "vite preview"
},
"devDependencies": {
"@tauri-apps/cli": "2.0.0-beta.21",
"@tauri-apps/cli": "2.0.0-beta.22",
"typescript": "^5.3.3",
"vite": "^5.0.13"
},
+1 -1
View File
@@ -23,6 +23,6 @@
"LICENSE"
],
"dependencies": {
"@tauri-apps/api": "2.0.0-beta.14"
"@tauri-apps/api": "2.0.0-beta.15"
}
}
+1 -1
View File
@@ -117,7 +117,7 @@ enum WebSocketMessage {
async fn connect<R: Runtime>(
window: Window<R>,
url: String,
on_message: Channel,
on_message: Channel<serde_json::Value>,
config: Option<ConnectionConfig>,
) -> Result<Id> {
let id = rand::random();
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -3,7 +3,7 @@
// SPDX-License-Identifier: MIT
import { invoke } from "@tauri-apps/api/core";
import { type WindowLabel, getCurrent } from "@tauri-apps/api/window";
import { type WindowLabel, getCurrentWindow } from "@tauri-apps/api/window";
export enum StateFlags {
SIZE = 1 << 0,
@@ -36,7 +36,7 @@ async function restoreState(
* Restore the state for the current window from disk.
*/
async function restoreStateCurrent(flags: StateFlags): Promise<void> {
await restoreState(getCurrent().label, flags);
await restoreState(getCurrentWindow().label, flags);
}
/**
* Get the name of the file used to store window state.
+1 -1
View File
@@ -24,6 +24,6 @@
"LICENSE"
],
"dependencies": {
"@tauri-apps/api": "2.0.0-beta.14"
"@tauri-apps/api": "2.0.0-beta.15"
}
}