feat: update to tauri 2.0.0-alpha.9 (#372)

This commit is contained in:
Lucas Fernandes Nogueira
2023-05-18 11:39:46 -03:00
committed by GitHub
parent 717ae67097
commit 3c9771e287
36 changed files with 163 additions and 288 deletions
+1 -1
View File
@@ -27,6 +27,6 @@
"tslib": "^2.5.0"
},
"dependencies": {
"@tauri-apps/api": "^1.2.0"
"@tauri-apps/api": "2.0.0-alpha.4"
}
}
+1 -1
View File
@@ -28,6 +28,6 @@
"tslib": "^2.5.0"
},
"dependencies": {
"@tauri-apps/api": "^1.2.0"
"@tauri-apps/api": "2.0.0-alpha.4"
}
}
+1 -1
View File
@@ -27,6 +27,6 @@
"tslib": "^2.5.0"
},
"dependencies": {
"@tauri-apps/api": "^1.2.0"
"@tauri-apps/api": "2.0.0-alpha.4"
}
}
+1 -1
View File
@@ -27,6 +27,6 @@
"tslib": "^2.4.1"
},
"dependencies": {
"@tauri-apps/api": "^1.2.0"
"@tauri-apps/api": "2.0.0-alpha.4"
}
}
+1 -1
View File
@@ -27,6 +27,6 @@
"tslib": "^2.4.1"
},
"dependencies": {
"@tauri-apps/api": "^1.2.0"
"@tauri-apps/api": "2.0.0-alpha.4"
}
}
+1 -1
View File
@@ -27,6 +27,6 @@
"tslib": "^2.4.1"
},
"dependencies": {
"@tauri-apps/api": "^1.2.0"
"@tauri-apps/api": "2.0.0-alpha.4"
}
}
+1 -31
View File
@@ -74,6 +74,7 @@
*/
import { invoke } from "@tauri-apps/api/tauri";
import { BaseDirectory } from "@tauri-apps/api/path";
interface Permissions {
/**
@@ -182,37 +183,6 @@ interface BackendMetadata {
blocks: number | undefined;
}
// TODO: pull BaseDirectory from @tauri-apps/api/path
/**
* @since 1.0.0
*/
enum BaseDirectory {
Audio = 1,
Cache,
Config,
Data,
LocalData,
Document,
Download,
Picture,
Public,
Video,
Resource,
Temp,
AppConfig,
AppData,
AppLocalData,
AppCache,
AppLog,
Desktop,
Executable,
Font,
Home,
Runtime,
Template,
}
/**
* @since 1.0.0
*/
+1 -1
View File
@@ -28,6 +28,6 @@
"tslib": "^2.4.1"
},
"dependencies": {
"@tauri-apps/api": "^1.2.0"
"@tauri-apps/api": "2.0.0-alpha.4"
}
}
+1 -1
View File
@@ -27,6 +27,6 @@
"tslib": "^2.4.1"
},
"dependencies": {
"@tauri-apps/api": "^1.2.0"
"@tauri-apps/api": "2.0.0-alpha.4"
}
}
+1 -1
View File
@@ -27,6 +27,6 @@
"tslib": "^2.5.0"
},
"dependencies": {
"@tauri-apps/api": "^1.2.0"
"@tauri-apps/api": "2.0.0-alpha.4"
}
}
+1 -1
View File
@@ -28,6 +28,6 @@
"tslib": "^2.5.0"
},
"dependencies": {
"@tauri-apps/api": "^1.2.0"
"@tauri-apps/api": "2.0.0-alpha.4"
}
}
+9 -48
View File
@@ -24,7 +24,11 @@
* @module
*/
import { invoke, transformCallback } from "@tauri-apps/api/tauri";
import {
invoke,
PluginListener,
addPluginListener,
} from "@tauri-apps/api/tauri";
/**
* Options to send a notification.
@@ -551,59 +555,16 @@ async function channels(): Promise<Channel[]> {
return invoke("plugin:notification|getActive");
}
class EventChannel {
id: number;
unregisterFn: (channel: EventChannel) => Promise<void>;
constructor(
id: number,
unregisterFn: (channel: EventChannel) => Promise<void>
) {
this.id = id;
this.unregisterFn = unregisterFn;
}
toJSON(): string {
return `__CHANNEL__:${this.id}`;
}
async unregister(): Promise<void> {
return this.unregisterFn(this);
}
}
// TODO: use addPluginListener API on @tauri-apps/api/tauri 2.0.0-alpha.4
async function onNotificationReceived(
cb: (notification: Options) => void
): Promise<EventChannel> {
const channelId = transformCallback(cb);
const handler = new EventChannel(channelId, (channel) =>
invoke("plugin:notification|remove_listener", {
event: "notification",
channelId: channel.id,
})
);
return invoke("plugin:notification|register_listener", {
event: "notification",
handler,
}).then(() => handler);
): Promise<PluginListener> {
return addPluginListener("notification", "notification", cb);
}
// TODO: use addPluginListener API on @tauri-apps/api/tauri 2.0.0-alpha.4
async function onAction(
cb: (notification: Options) => void
): Promise<EventChannel> {
const channelId = transformCallback(cb);
const handler = new EventChannel(channelId, (channel) =>
invoke("plugin:notification|remove_listener", {
event: "actionPerformed",
channelId: channel.id,
})
);
return invoke("plugin:notification|register_listener", {
event: "actionPerformed",
handler,
}).then(() => handler);
): Promise<PluginListener> {
return addPluginListener("notification", "actionPerformed", cb);
}
export type {
+1 -1
View File
@@ -27,6 +27,6 @@
"tslib": "^2.4.1"
},
"dependencies": {
"@tauri-apps/api": "^1.2.0"
"@tauri-apps/api": "2.0.0-alpha.4"
}
}
+1 -1
View File
@@ -27,6 +27,6 @@
"tslib": "^2.5.0"
},
"dependencies": {
"@tauri-apps/api": "^1.2.0"
"@tauri-apps/api": "2.0.0-alpha.4"
}
}
+1 -1
View File
@@ -28,6 +28,6 @@
"tslib": "^2.5.0"
},
"dependencies": {
"@tauri-apps/api": "^1.2.0"
"@tauri-apps/api": "2.0.0-alpha.4"
}
}
+1 -1
View File
@@ -27,6 +27,6 @@
"tslib": "^2.5.0"
},
"dependencies": {
"@tauri-apps/api": "^1.2.0"
"@tauri-apps/api": "2.0.0-alpha.4"
}
}
+1 -1
View File
@@ -27,6 +27,6 @@
"tslib": "^2.4.1"
},
"dependencies": {
"@tauri-apps/api": "^1.2.0"
"@tauri-apps/api": "2.0.0-alpha.4"
}
}
@@ -8,7 +8,7 @@
},
"author": "",
"license": "MIT",
"dependencies": {
"@tauri-apps/cli": "^2.0.0-alpha.8"
"devDependencies": {
"@tauri-apps/cli": "^2.0.0-alpha.9"
}
}
+1 -1
View File
@@ -28,6 +28,6 @@
"tslib": "^2.5.0"
},
"dependencies": {
"@tauri-apps/api": "^1.2.0"
"@tauri-apps/api": "2.0.0-alpha.4"
}
}
+1 -1
View File
@@ -28,6 +28,6 @@
"tslib": "^2.5.0"
},
"dependencies": {
"@tauri-apps/api": "^1.2.0"
"@tauri-apps/api": "2.0.0-alpha.4"
}
}
+1 -1
View File
@@ -28,6 +28,6 @@
"tslib": "^2.5.0"
},
"dependencies": {
"@tauri-apps/api": "^1.2.0"
"@tauri-apps/api": "2.0.0-alpha.4"
}
}
+1 -29
View File
@@ -1,4 +1,4 @@
import { invoke, transformCallback } from "@tauri-apps/api/tauri";
import { invoke, Channel } from "@tauri-apps/api/tauri";
interface CheckOptions {
/**
@@ -23,34 +23,6 @@ interface UpdateResponse {
body?: string;
}
// TODO: use channel from @tauri-apps/api on v2
class Channel<T = unknown> {
id: number;
// @ts-expect-error field used by the IPC serializer
private readonly __TAURI_CHANNEL_MARKER__ = true;
#onmessage: (response: T) => void = () => {
// no-op
};
constructor() {
this.id = transformCallback((response: T) => {
this.#onmessage(response);
});
}
set onmessage(handler: (response: T) => void) {
this.#onmessage = handler;
}
get onmessage(): (response: T) => void {
return this.#onmessage;
}
toJSON(): string {
return `__CHANNEL__:${this.id}`;
}
}
type DownloadEvent =
| { event: "Started"; data: { contentLength?: number } }
| { event: "Progress"; data: { chunkLength: number } }
+1 -1
View File
@@ -27,6 +27,6 @@
"tslib": "^2.5.0"
},
"dependencies": {
"@tauri-apps/api": "^1.2.0"
"@tauri-apps/api": "2.0.0-alpha.4"
}
}
@@ -17,7 +17,6 @@ fn main() {
// It must be the last parameter used in the command line and must not contain any quotes, even if the path contains spaces.
// Only absolute paths are supported.
// NOTE: we only need this because this is an integration test and we don't want to install the app in the programs folder
// TODO mutate plugin config
updater = updater.installer_args(vec![format!(
"/D={}",
tauri::utils::platform::current_exe()
+1 -29
View File
@@ -1,4 +1,4 @@
import { invoke, transformCallback } from "@tauri-apps/api/tauri";
import { invoke, Channel } from "@tauri-apps/api/tauri";
interface ProgressPayload {
progress: number;
@@ -7,34 +7,6 @@ interface ProgressPayload {
type ProgressHandler = (progress: ProgressPayload) => void;
// TODO: use channel from @tauri-apps/api on v2
class Channel<T = unknown> {
id: number;
// @ts-expect-error field used by the IPC serializer
private readonly __TAURI_CHANNEL_MARKER__ = true;
#onmessage: (response: T) => void = () => {
// no-op
};
constructor() {
this.id = transformCallback((response: T) => {
this.#onmessage(response);
});
}
set onmessage(handler: (response: T) => void) {
this.#onmessage = handler;
}
get onmessage(): (response: T) => void {
return this.#onmessage;
}
toJSON(): string {
return `__CHANNEL__:${this.id}`;
}
}
async function upload(
url: string,
filePath: string,
+1 -1
View File
@@ -28,6 +28,6 @@
"tslib": "^2.5.0"
},
"dependencies": {
"@tauri-apps/api": "^1.2.0"
"@tauri-apps/api": "2.0.0-alpha.4"
}
}
@@ -13,7 +13,7 @@
"devDependencies": {
"@sveltejs/adapter-auto": "^2.0.0",
"@sveltejs/kit": "^1.15.5",
"@tauri-apps/cli": "^1.2.3",
"@tauri-apps/cli": "2.0.0-alpha.9",
"svelte": "^3.58.0",
"svelte-check": "^3.2.0",
"tslib": "^2.5.0",
@@ -21,7 +21,6 @@
"vite": "^4.2.1"
},
"dependencies": {
"@tauri-apps/cli": "^2.0.0-alpha.8",
"@tauri-apps/plugin-websocket": "link:../../"
},
"type": "module"
+1 -1
View File
@@ -27,6 +27,6 @@
"tslib": "^2.5.0"
},
"dependencies": {
"@tauri-apps/api": "^1.2.0"
"@tauri-apps/api": "2.0.0-alpha.4"
}
}
+1 -1
View File
@@ -28,6 +28,6 @@
"tslib": "^2.5.0"
},
"dependencies": {
"@tauri-apps/api": "^1.2.0"
"@tauri-apps/api": "2.0.0-alpha.4"
}
}
+1 -1
View File
@@ -27,6 +27,6 @@
"tslib": "^2.5.0"
},
"dependencies": {
"@tauri-apps/api": "^1.2.0"
"@tauri-apps/api": "2.0.0-alpha.4"
}
}