remove build script

This commit is contained in:
Jonas Kruckenberg 2022-11-13 21:05:51 +01:00
parent 20442c1f43
commit c9fa93de72
21 changed files with 4368 additions and 33 deletions

View file

@ -1,33 +0,0 @@
use std::process::Command;
fn main() {
/* Shared arguments */
let sargs: &[&str] = &[
"--outdir=dist",
"--format=esm",
"--bundle",
"tauri/tooling/api/src/app.ts",
"tauri/tooling/api/src/clipboard.ts",
"tauri/tooling/api/src/tauri.ts",
"tauri/tooling/api/src/event.ts",
"tauri/tooling/api/src/mocks.ts",
"tauri/tooling/api/src/window.ts",
"tauri/tooling/api/src/process.ts"
];
if cfg!(windows) {
/* Use cmd if the target is windows */
Command::new("cmd")
.args(&["/C", "esbuild"])
.args(sargs)
.output()
.unwrap();
} else if cfg!(unix) {
Command::new("esbuild")
.args(sargs)
.output()
.unwrap();
} else {
panic!("Unsupported build target");
}
}

15
package.json Normal file
View file

@ -0,0 +1,15 @@
{
"name": "tauri-sys",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "esbuild --outdir=src --format=esm --bundle tauri/tooling/api/src/*.ts"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"esbuild": "^0.15.13"
}
}

237
pnpm-lock.yaml generated Normal file
View file

@ -0,0 +1,237 @@
lockfileVersion: 5.4
specifiers:
esbuild: ^0.15.13
devDependencies:
esbuild: 0.15.13
packages:
/@esbuild/android-arm/0.15.13:
resolution: {integrity: sha512-RY2fVI8O0iFUNvZirXaQ1vMvK0xhCcl0gqRj74Z6yEiO1zAUa7hbsdwZM1kzqbxHK7LFyMizipfXT3JME+12Hw==}
engines: {node: '>=12'}
cpu: [arm]
os: [android]
requiresBuild: true
dev: true
optional: true
/@esbuild/linux-loong64/0.15.13:
resolution: {integrity: sha512-+BoyIm4I8uJmH/QDIH0fu7MG0AEx9OXEDXnqptXCwKOlOqZiS4iraH1Nr7/ObLMokW3sOCeBNyD68ATcV9b9Ag==}
engines: {node: '>=12'}
cpu: [loong64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/esbuild-android-64/0.15.13:
resolution: {integrity: sha512-yRorukXBlokwTip+Sy4MYskLhJsO0Kn0/Fj43s1krVblfwP+hMD37a4Wmg139GEsMLl+vh8WXp2mq/cTA9J97g==}
engines: {node: '>=12'}
cpu: [x64]
os: [android]
requiresBuild: true
dev: true
optional: true
/esbuild-android-arm64/0.15.13:
resolution: {integrity: sha512-TKzyymLD6PiVeyYa4c5wdPw87BeAiTXNtK6amWUcXZxkV51gOk5u5qzmDaYSwiWeecSNHamFsaFjLoi32QR5/w==}
engines: {node: '>=12'}
cpu: [arm64]
os: [android]
requiresBuild: true
dev: true
optional: true
/esbuild-darwin-64/0.15.13:
resolution: {integrity: sha512-WAx7c2DaOS6CrRcoYCgXgkXDliLnFv3pQLV6GeW1YcGEZq2Gnl8s9Pg7ahValZkpOa0iE/ojRVQ87sbUhF1Cbg==}
engines: {node: '>=12'}
cpu: [x64]
os: [darwin]
requiresBuild: true
dev: true
optional: true
/esbuild-darwin-arm64/0.15.13:
resolution: {integrity: sha512-U6jFsPfSSxC3V1CLiQqwvDuj3GGrtQNB3P3nNC3+q99EKf94UGpsG9l4CQ83zBs1NHrk1rtCSYT0+KfK5LsD8A==}
engines: {node: '>=12'}
cpu: [arm64]
os: [darwin]
requiresBuild: true
dev: true
optional: true
/esbuild-freebsd-64/0.15.13:
resolution: {integrity: sha512-whItJgDiOXaDG/idy75qqevIpZjnReZkMGCgQaBWZuKHoElDJC1rh7MpoUgupMcdfOd+PgdEwNQW9DAE6i8wyA==}
engines: {node: '>=12'}
cpu: [x64]
os: [freebsd]
requiresBuild: true
dev: true
optional: true
/esbuild-freebsd-arm64/0.15.13:
resolution: {integrity: sha512-6pCSWt8mLUbPtygv7cufV0sZLeylaMwS5Fznj6Rsx9G2AJJsAjQ9ifA+0rQEIg7DwJmi9it+WjzNTEAzzdoM3Q==}
engines: {node: '>=12'}
cpu: [arm64]
os: [freebsd]
requiresBuild: true
dev: true
optional: true
/esbuild-linux-32/0.15.13:
resolution: {integrity: sha512-VbZdWOEdrJiYApm2kkxoTOgsoCO1krBZ3quHdYk3g3ivWaMwNIVPIfEE0f0XQQ0u5pJtBsnk2/7OPiCFIPOe/w==}
engines: {node: '>=12'}
cpu: [ia32]
os: [linux]
requiresBuild: true
dev: true
optional: true
/esbuild-linux-64/0.15.13:
resolution: {integrity: sha512-rXmnArVNio6yANSqDQlIO4WiP+Cv7+9EuAHNnag7rByAqFVuRusLbGi2697A5dFPNXoO//IiogVwi3AdcfPC6A==}
engines: {node: '>=12'}
cpu: [x64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/esbuild-linux-arm/0.15.13:
resolution: {integrity: sha512-Ac6LpfmJO8WhCMQmO253xX2IU2B3wPDbl4IvR0hnqcPrdfCaUa2j/lLMGTjmQ4W5JsJIdHEdW12dG8lFS0MbxQ==}
engines: {node: '>=12'}
cpu: [arm]
os: [linux]
requiresBuild: true
dev: true
optional: true
/esbuild-linux-arm64/0.15.13:
resolution: {integrity: sha512-alEMGU4Z+d17U7KQQw2IV8tQycO6T+rOrgW8OS22Ua25x6kHxoG6Ngry6Aq6uranC+pNWNMB6aHFPh7aTQdORQ==}
engines: {node: '>=12'}
cpu: [arm64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/esbuild-linux-mips64le/0.15.13:
resolution: {integrity: sha512-47PgmyYEu+yN5rD/MbwS6DxP2FSGPo4Uxg5LwIdxTiyGC2XKwHhHyW7YYEDlSuXLQXEdTO7mYe8zQ74czP7W8A==}
engines: {node: '>=12'}
cpu: [mips64el]
os: [linux]
requiresBuild: true
dev: true
optional: true
/esbuild-linux-ppc64le/0.15.13:
resolution: {integrity: sha512-z6n28h2+PC1Ayle9DjKoBRcx/4cxHoOa2e689e2aDJSaKug3jXcQw7mM+GLg+9ydYoNzj8QxNL8ihOv/OnezhA==}
engines: {node: '>=12'}
cpu: [ppc64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/esbuild-linux-riscv64/0.15.13:
resolution: {integrity: sha512-+Lu4zuuXuQhgLUGyZloWCqTslcCAjMZH1k3Xc9MSEJEpEFdpsSU0sRDXAnk18FKOfEjhu4YMGaykx9xjtpA6ow==}
engines: {node: '>=12'}
cpu: [riscv64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/esbuild-linux-s390x/0.15.13:
resolution: {integrity: sha512-BMeXRljruf7J0TMxD5CIXS65y7puiZkAh+s4XFV9qy16SxOuMhxhVIXYLnbdfLrsYGFzx7U9mcdpFWkkvy/Uag==}
engines: {node: '>=12'}
cpu: [s390x]
os: [linux]
requiresBuild: true
dev: true
optional: true
/esbuild-netbsd-64/0.15.13:
resolution: {integrity: sha512-EHj9QZOTel581JPj7UO3xYbltFTYnHy+SIqJVq6yd3KkCrsHRbapiPb0Lx3EOOtybBEE9EyqbmfW1NlSDsSzvQ==}
engines: {node: '>=12'}
cpu: [x64]
os: [netbsd]
requiresBuild: true
dev: true
optional: true
/esbuild-openbsd-64/0.15.13:
resolution: {integrity: sha512-nkuDlIjF/sfUhfx8SKq0+U+Fgx5K9JcPq1mUodnxI0x4kBdCv46rOGWbuJ6eof2n3wdoCLccOoJAbg9ba/bT2w==}
engines: {node: '>=12'}
cpu: [x64]
os: [openbsd]
requiresBuild: true
dev: true
optional: true
/esbuild-sunos-64/0.15.13:
resolution: {integrity: sha512-jVeu2GfxZQ++6lRdY43CS0Tm/r4WuQQ0Pdsrxbw+aOrHQPHV0+LNOLnvbN28M7BSUGnJnHkHm2HozGgNGyeIRw==}
engines: {node: '>=12'}
cpu: [x64]
os: [sunos]
requiresBuild: true
dev: true
optional: true
/esbuild-windows-32/0.15.13:
resolution: {integrity: sha512-XoF2iBf0wnqo16SDq+aDGi/+QbaLFpkiRarPVssMh9KYbFNCqPLlGAWwDvxEVz+ywX6Si37J2AKm+AXq1kC0JA==}
engines: {node: '>=12'}
cpu: [ia32]
os: [win32]
requiresBuild: true
dev: true
optional: true
/esbuild-windows-64/0.15.13:
resolution: {integrity: sha512-Et6htEfGycjDrtqb2ng6nT+baesZPYQIW+HUEHK4D1ncggNrDNk3yoboYQ5KtiVrw/JaDMNttz8rrPubV/fvPQ==}
engines: {node: '>=12'}
cpu: [x64]
os: [win32]
requiresBuild: true
dev: true
optional: true
/esbuild-windows-arm64/0.15.13:
resolution: {integrity: sha512-3bv7tqntThQC9SWLRouMDmZnlOukBhOCTlkzNqzGCmrkCJI7io5LLjwJBOVY6kOUlIvdxbooNZwjtBvj+7uuVg==}
engines: {node: '>=12'}
cpu: [arm64]
os: [win32]
requiresBuild: true
dev: true
optional: true
/esbuild/0.15.13:
resolution: {integrity: sha512-Cu3SC84oyzzhrK/YyN4iEVy2jZu5t2fz66HEOShHURcjSkOSAVL8C/gfUT+lDJxkVHpg8GZ10DD0rMHRPqMFaQ==}
engines: {node: '>=12'}
hasBin: true
requiresBuild: true
optionalDependencies:
'@esbuild/android-arm': 0.15.13
'@esbuild/linux-loong64': 0.15.13
esbuild-android-64: 0.15.13
esbuild-android-arm64: 0.15.13
esbuild-darwin-64: 0.15.13
esbuild-darwin-arm64: 0.15.13
esbuild-freebsd-64: 0.15.13
esbuild-freebsd-arm64: 0.15.13
esbuild-linux-32: 0.15.13
esbuild-linux-64: 0.15.13
esbuild-linux-arm: 0.15.13
esbuild-linux-arm64: 0.15.13
esbuild-linux-mips64le: 0.15.13
esbuild-linux-ppc64le: 0.15.13
esbuild-linux-riscv64: 0.15.13
esbuild-linux-s390x: 0.15.13
esbuild-netbsd-64: 0.15.13
esbuild-openbsd-64: 0.15.13
esbuild-sunos-64: 0.15.13
esbuild-windows-32: 0.15.13
esbuild-windows-64: 0.15.13
esbuild-windows-arm64: 0.15.13
dev: true

55
src/cli.js Normal file
View file

@ -0,0 +1,55 @@
// tauri/tooling/api/src/tauri.ts
function uid() {
return window.crypto.getRandomValues(new Uint32Array(1))[0];
}
function transformCallback(callback, once = false) {
const identifier = uid();
const prop = `_${identifier}`;
Object.defineProperty(window, prop, {
value: (result) => {
if (once) {
Reflect.deleteProperty(window, prop);
}
return callback?.(result);
},
writable: false,
configurable: true
});
return identifier;
}
async function invoke(cmd, args = {}) {
return new Promise((resolve, reject) => {
const callback = transformCallback((e) => {
resolve(e);
Reflect.deleteProperty(window, `_${error}`);
}, true);
const error = transformCallback((e) => {
reject(e);
Reflect.deleteProperty(window, `_${callback}`);
}, true);
window.__TAURI_IPC__({
cmd,
callback,
error,
...args
});
});
}
// tauri/tooling/api/src/helpers/tauri.ts
async function invokeTauriCommand(command) {
return invoke("tauri", command);
}
// tauri/tooling/api/src/cli.ts
async function getMatches() {
return invokeTauriCommand({
__tauriModule: "Cli",
message: {
cmd: "cliMatches"
}
});
}
export {
getMatches
};

111
src/dialog.js Normal file
View file

@ -0,0 +1,111 @@
// tauri/tooling/api/src/tauri.ts
function uid() {
return window.crypto.getRandomValues(new Uint32Array(1))[0];
}
function transformCallback(callback, once = false) {
const identifier = uid();
const prop = `_${identifier}`;
Object.defineProperty(window, prop, {
value: (result) => {
if (once) {
Reflect.deleteProperty(window, prop);
}
return callback?.(result);
},
writable: false,
configurable: true
});
return identifier;
}
async function invoke(cmd, args = {}) {
return new Promise((resolve, reject) => {
const callback = transformCallback((e) => {
resolve(e);
Reflect.deleteProperty(window, `_${error}`);
}, true);
const error = transformCallback((e) => {
reject(e);
Reflect.deleteProperty(window, `_${callback}`);
}, true);
window.__TAURI_IPC__({
cmd,
callback,
error,
...args
});
});
}
// tauri/tooling/api/src/helpers/tauri.ts
async function invokeTauriCommand(command) {
return invoke("tauri", command);
}
// tauri/tooling/api/src/dialog.ts
async function open(options = {}) {
if (typeof options === "object") {
Object.freeze(options);
}
return invokeTauriCommand({
__tauriModule: "Dialog",
message: {
cmd: "openDialog",
options
}
});
}
async function save(options = {}) {
if (typeof options === "object") {
Object.freeze(options);
}
return invokeTauriCommand({
__tauriModule: "Dialog",
message: {
cmd: "saveDialog",
options
}
});
}
async function message(message2, options) {
const opts = typeof options === "string" ? { title: options } : options;
return invokeTauriCommand({
__tauriModule: "Dialog",
message: {
cmd: "messageDialog",
message: message2.toString(),
title: opts?.title?.toString(),
type: opts?.type
}
});
}
async function ask(message2, options) {
const opts = typeof options === "string" ? { title: options } : options;
return invokeTauriCommand({
__tauriModule: "Dialog",
message: {
cmd: "askDialog",
message: message2.toString(),
title: opts?.title?.toString(),
type: opts?.type
}
});
}
async function confirm(message2, options) {
const opts = typeof options === "string" ? { title: options } : options;
return invokeTauriCommand({
__tauriModule: "Dialog",
message: {
cmd: "confirmDialog",
message: message2.toString(),
title: opts?.title?.toString(),
type: opts?.type
}
});
}
export {
ask,
confirm,
message,
open,
save
};

243
src/fs.js Normal file
View file

@ -0,0 +1,243 @@
// tauri/tooling/api/src/tauri.ts
function uid() {
return window.crypto.getRandomValues(new Uint32Array(1))[0];
}
function transformCallback(callback, once = false) {
const identifier = uid();
const prop = `_${identifier}`;
Object.defineProperty(window, prop, {
value: (result) => {
if (once) {
Reflect.deleteProperty(window, prop);
}
return callback?.(result);
},
writable: false,
configurable: true
});
return identifier;
}
async function invoke(cmd, args = {}) {
return new Promise((resolve, reject) => {
const callback = transformCallback((e) => {
resolve(e);
Reflect.deleteProperty(window, `_${error}`);
}, true);
const error = transformCallback((e) => {
reject(e);
Reflect.deleteProperty(window, `_${callback}`);
}, true);
window.__TAURI_IPC__({
cmd,
callback,
error,
...args
});
});
}
// tauri/tooling/api/src/helpers/tauri.ts
async function invokeTauriCommand(command) {
return invoke("tauri", command);
}
// tauri/tooling/api/src/fs.ts
var BaseDirectory = /* @__PURE__ */ ((BaseDirectory2) => {
BaseDirectory2[BaseDirectory2["Audio"] = 1] = "Audio";
BaseDirectory2[BaseDirectory2["Cache"] = 2] = "Cache";
BaseDirectory2[BaseDirectory2["Config"] = 3] = "Config";
BaseDirectory2[BaseDirectory2["Data"] = 4] = "Data";
BaseDirectory2[BaseDirectory2["LocalData"] = 5] = "LocalData";
BaseDirectory2[BaseDirectory2["Desktop"] = 6] = "Desktop";
BaseDirectory2[BaseDirectory2["Document"] = 7] = "Document";
BaseDirectory2[BaseDirectory2["Download"] = 8] = "Download";
BaseDirectory2[BaseDirectory2["Executable"] = 9] = "Executable";
BaseDirectory2[BaseDirectory2["Font"] = 10] = "Font";
BaseDirectory2[BaseDirectory2["Home"] = 11] = "Home";
BaseDirectory2[BaseDirectory2["Picture"] = 12] = "Picture";
BaseDirectory2[BaseDirectory2["Public"] = 13] = "Public";
BaseDirectory2[BaseDirectory2["Runtime"] = 14] = "Runtime";
BaseDirectory2[BaseDirectory2["Template"] = 15] = "Template";
BaseDirectory2[BaseDirectory2["Video"] = 16] = "Video";
BaseDirectory2[BaseDirectory2["Resource"] = 17] = "Resource";
BaseDirectory2[BaseDirectory2["App"] = 18] = "App";
BaseDirectory2[BaseDirectory2["Log"] = 19] = "Log";
BaseDirectory2[BaseDirectory2["Temp"] = 20] = "Temp";
BaseDirectory2[BaseDirectory2["AppConfig"] = 21] = "AppConfig";
BaseDirectory2[BaseDirectory2["AppData"] = 22] = "AppData";
BaseDirectory2[BaseDirectory2["AppLocalData"] = 23] = "AppLocalData";
BaseDirectory2[BaseDirectory2["AppCache"] = 24] = "AppCache";
BaseDirectory2[BaseDirectory2["AppLog"] = 25] = "AppLog";
return BaseDirectory2;
})(BaseDirectory || {});
async function readTextFile(filePath, options = {}) {
return invokeTauriCommand({
__tauriModule: "Fs",
message: {
cmd: "readTextFile",
path: filePath,
options
}
});
}
async function readBinaryFile(filePath, options = {}) {
const arr = await invokeTauriCommand({
__tauriModule: "Fs",
message: {
cmd: "readFile",
path: filePath,
options
}
});
return Uint8Array.from(arr);
}
async function writeTextFile(path, contents, options) {
if (typeof options === "object") {
Object.freeze(options);
}
if (typeof path === "object") {
Object.freeze(path);
}
const file = { path: "", contents: "" };
let fileOptions = options;
if (typeof path === "string") {
file.path = path;
} else {
file.path = path.path;
file.contents = path.contents;
}
if (typeof contents === "string") {
file.contents = contents ?? "";
} else {
fileOptions = contents;
}
return invokeTauriCommand({
__tauriModule: "Fs",
message: {
cmd: "writeFile",
path: file.path,
contents: Array.from(new TextEncoder().encode(file.contents)),
options: fileOptions
}
});
}
async function writeBinaryFile(path, contents, options) {
if (typeof options === "object") {
Object.freeze(options);
}
if (typeof path === "object") {
Object.freeze(path);
}
const file = { path: "", contents: [] };
let fileOptions = options;
if (typeof path === "string") {
file.path = path;
} else {
file.path = path.path;
file.contents = path.contents;
}
if (contents && "dir" in contents) {
fileOptions = contents;
} else if (typeof path === "string") {
file.contents = contents ?? [];
}
return invokeTauriCommand({
__tauriModule: "Fs",
message: {
cmd: "writeFile",
path: file.path,
contents: Array.from(
file.contents instanceof ArrayBuffer ? new Uint8Array(file.contents) : file.contents
),
options: fileOptions
}
});
}
async function readDir(dir, options = {}) {
return invokeTauriCommand({
__tauriModule: "Fs",
message: {
cmd: "readDir",
path: dir,
options
}
});
}
async function createDir(dir, options = {}) {
return invokeTauriCommand({
__tauriModule: "Fs",
message: {
cmd: "createDir",
path: dir,
options
}
});
}
async function removeDir(dir, options = {}) {
return invokeTauriCommand({
__tauriModule: "Fs",
message: {
cmd: "removeDir",
path: dir,
options
}
});
}
async function copyFile(source, destination, options = {}) {
return invokeTauriCommand({
__tauriModule: "Fs",
message: {
cmd: "copyFile",
source,
destination,
options
}
});
}
async function removeFile(file, options = {}) {
return invokeTauriCommand({
__tauriModule: "Fs",
message: {
cmd: "removeFile",
path: file,
options
}
});
}
async function renameFile(oldPath, newPath, options = {}) {
return invokeTauriCommand({
__tauriModule: "Fs",
message: {
cmd: "renameFile",
oldPath,
newPath,
options
}
});
}
async function exists(path, options = {}) {
return invokeTauriCommand({
__tauriModule: "Fs",
message: {
cmd: "exists",
path,
options
}
});
}
export {
BaseDirectory,
BaseDirectory as Dir,
copyFile,
createDir,
exists,
readBinaryFile,
readDir,
readTextFile,
removeDir,
removeFile,
renameFile,
writeBinaryFile,
writeTextFile as writeFile,
writeTextFile
};

97
src/globalShortcut.js Normal file
View file

@ -0,0 +1,97 @@
// tauri/tooling/api/src/tauri.ts
function uid() {
return window.crypto.getRandomValues(new Uint32Array(1))[0];
}
function transformCallback(callback, once = false) {
const identifier = uid();
const prop = `_${identifier}`;
Object.defineProperty(window, prop, {
value: (result) => {
if (once) {
Reflect.deleteProperty(window, prop);
}
return callback?.(result);
},
writable: false,
configurable: true
});
return identifier;
}
async function invoke(cmd, args = {}) {
return new Promise((resolve, reject) => {
const callback = transformCallback((e) => {
resolve(e);
Reflect.deleteProperty(window, `_${error}`);
}, true);
const error = transformCallback((e) => {
reject(e);
Reflect.deleteProperty(window, `_${callback}`);
}, true);
window.__TAURI_IPC__({
cmd,
callback,
error,
...args
});
});
}
// tauri/tooling/api/src/helpers/tauri.ts
async function invokeTauriCommand(command) {
return invoke("tauri", command);
}
// tauri/tooling/api/src/globalShortcut.ts
async function register(shortcut, handler) {
return invokeTauriCommand({
__tauriModule: "GlobalShortcut",
message: {
cmd: "register",
shortcut,
handler: transformCallback(handler)
}
});
}
async function registerAll(shortcuts, handler) {
return invokeTauriCommand({
__tauriModule: "GlobalShortcut",
message: {
cmd: "registerAll",
shortcuts,
handler: transformCallback(handler)
}
});
}
async function isRegistered(shortcut) {
return invokeTauriCommand({
__tauriModule: "GlobalShortcut",
message: {
cmd: "isRegistered",
shortcut
}
});
}
async function unregister(shortcut) {
return invokeTauriCommand({
__tauriModule: "GlobalShortcut",
message: {
cmd: "unregister",
shortcut
}
});
}
async function unregisterAll() {
return invokeTauriCommand({
__tauriModule: "GlobalShortcut",
message: {
cmd: "unregisterAll"
}
});
}
export {
isRegistered,
register,
registerAll,
unregister,
unregisterAll
};

207
src/http.js Normal file
View file

@ -0,0 +1,207 @@
// tauri/tooling/api/src/tauri.ts
function uid() {
return window.crypto.getRandomValues(new Uint32Array(1))[0];
}
function transformCallback(callback, once = false) {
const identifier = uid();
const prop = `_${identifier}`;
Object.defineProperty(window, prop, {
value: (result) => {
if (once) {
Reflect.deleteProperty(window, prop);
}
return callback?.(result);
},
writable: false,
configurable: true
});
return identifier;
}
async function invoke(cmd, args = {}) {
return new Promise((resolve, reject) => {
const callback = transformCallback((e) => {
resolve(e);
Reflect.deleteProperty(window, `_${error}`);
}, true);
const error = transformCallback((e) => {
reject(e);
Reflect.deleteProperty(window, `_${callback}`);
}, true);
window.__TAURI_IPC__({
cmd,
callback,
error,
...args
});
});
}
// tauri/tooling/api/src/helpers/tauri.ts
async function invokeTauriCommand(command) {
return invoke("tauri", command);
}
// tauri/tooling/api/src/http.ts
var ResponseType = /* @__PURE__ */ ((ResponseType2) => {
ResponseType2[ResponseType2["JSON"] = 1] = "JSON";
ResponseType2[ResponseType2["Text"] = 2] = "Text";
ResponseType2[ResponseType2["Binary"] = 3] = "Binary";
return ResponseType2;
})(ResponseType || {});
var Body = class {
constructor(type, payload) {
this.type = type;
this.payload = payload;
}
static form(data) {
const form = {};
for (const key in data) {
const v = data[key];
let r;
if (typeof v === "string") {
r = v;
} else if (v instanceof Uint8Array || Array.isArray(v)) {
r = Array.from(v);
} else if (typeof v.file === "string") {
r = { file: v.file, mime: v.mime, fileName: v.fileName };
} else {
r = { file: Array.from(v.file), mime: v.mime, fileName: v.fileName };
}
form[key] = r;
}
return new Body("Form", form);
}
static json(data) {
return new Body("Json", data);
}
static text(value) {
return new Body("Text", value);
}
static bytes(bytes) {
return new Body(
"Bytes",
Array.from(bytes instanceof ArrayBuffer ? new Uint8Array(bytes) : bytes)
);
}
};
var Response = class {
constructor(response) {
this.url = response.url;
this.status = response.status;
this.ok = this.status >= 200 && this.status < 300;
this.headers = response.headers;
this.rawHeaders = response.rawHeaders;
this.data = response.data;
}
};
var Client = class {
constructor(id) {
this.id = id;
}
async drop() {
return invokeTauriCommand({
__tauriModule: "Http",
message: {
cmd: "dropClient",
client: this.id
}
});
}
async request(options) {
const jsonResponse = !options.responseType || options.responseType === 1 /* JSON */;
if (jsonResponse) {
options.responseType = 2 /* Text */;
}
return invokeTauriCommand({
__tauriModule: "Http",
message: {
cmd: "httpRequest",
client: this.id,
options
}
}).then((res) => {
const response = new Response(res);
if (jsonResponse) {
try {
response.data = JSON.parse(response.data);
} catch (e) {
if (response.ok && response.data === "") {
response.data = {};
} else if (response.ok) {
throw Error(
`Failed to parse response \`${response.data}\` as JSON: ${e};
try setting the \`responseType\` option to \`ResponseType.Text\` or \`ResponseType.Binary\` if the API does not return a JSON response.`
);
}
}
return response;
}
return response;
});
}
async get(url, options) {
return this.request({
method: "GET",
url,
...options
});
}
async post(url, body, options) {
return this.request({
method: "POST",
url,
body,
...options
});
}
async put(url, body, options) {
return this.request({
method: "PUT",
url,
body,
...options
});
}
async patch(url, options) {
return this.request({
method: "PATCH",
url,
...options
});
}
async delete(url, options) {
return this.request({
method: "DELETE",
url,
...options
});
}
};
async function getClient(options) {
return invokeTauriCommand({
__tauriModule: "Http",
message: {
cmd: "createClient",
options
}
}).then((id) => new Client(id));
}
var defaultClient = null;
async function fetch(url, options) {
if (defaultClient === null) {
defaultClient = await getClient();
}
return defaultClient.request({
url,
method: options?.method ?? "GET",
...options
});
}
export {
Body,
Client,
Response,
ResponseType,
fetch,
getClient
};

2402
src/index.js Normal file

File diff suppressed because it is too large Load diff

70
src/notification.js Normal file
View file

@ -0,0 +1,70 @@
// tauri/tooling/api/src/tauri.ts
function uid() {
return window.crypto.getRandomValues(new Uint32Array(1))[0];
}
function transformCallback(callback, once = false) {
const identifier = uid();
const prop = `_${identifier}`;
Object.defineProperty(window, prop, {
value: (result) => {
if (once) {
Reflect.deleteProperty(window, prop);
}
return callback?.(result);
},
writable: false,
configurable: true
});
return identifier;
}
async function invoke(cmd, args = {}) {
return new Promise((resolve, reject) => {
const callback = transformCallback((e) => {
resolve(e);
Reflect.deleteProperty(window, `_${error}`);
}, true);
const error = transformCallback((e) => {
reject(e);
Reflect.deleteProperty(window, `_${callback}`);
}, true);
window.__TAURI_IPC__({
cmd,
callback,
error,
...args
});
});
}
// tauri/tooling/api/src/helpers/tauri.ts
async function invokeTauriCommand(command) {
return invoke("tauri", command);
}
// tauri/tooling/api/src/notification.ts
async function isPermissionGranted() {
if (window.Notification.permission !== "default") {
return Promise.resolve(window.Notification.permission === "granted");
}
return invokeTauriCommand({
__tauriModule: "Notification",
message: {
cmd: "isNotificationPermissionGranted"
}
});
}
async function requestPermission() {
return window.Notification.requestPermission();
}
function sendNotification(options) {
if (typeof options === "string") {
new window.Notification(options);
} else {
new window.Notification(options.title, options);
}
}
export {
isPermissionGranted,
requestPermission,
sendNotification
};

98
src/os.js Normal file
View file

@ -0,0 +1,98 @@
// tauri/tooling/api/src/helpers/os-check.ts
function isWindows() {
return navigator.appVersion.includes("Win");
}
// tauri/tooling/api/src/tauri.ts
function uid() {
return window.crypto.getRandomValues(new Uint32Array(1))[0];
}
function transformCallback(callback, once = false) {
const identifier = uid();
const prop = `_${identifier}`;
Object.defineProperty(window, prop, {
value: (result) => {
if (once) {
Reflect.deleteProperty(window, prop);
}
return callback?.(result);
},
writable: false,
configurable: true
});
return identifier;
}
async function invoke(cmd, args = {}) {
return new Promise((resolve, reject) => {
const callback = transformCallback((e) => {
resolve(e);
Reflect.deleteProperty(window, `_${error}`);
}, true);
const error = transformCallback((e) => {
reject(e);
Reflect.deleteProperty(window, `_${callback}`);
}, true);
window.__TAURI_IPC__({
cmd,
callback,
error,
...args
});
});
}
// tauri/tooling/api/src/helpers/tauri.ts
async function invokeTauriCommand(command) {
return invoke("tauri", command);
}
// tauri/tooling/api/src/os.ts
var EOL = isWindows() ? "\r\n" : "\n";
async function platform() {
return invokeTauriCommand({
__tauriModule: "Os",
message: {
cmd: "platform"
}
});
}
async function version() {
return invokeTauriCommand({
__tauriModule: "Os",
message: {
cmd: "version"
}
});
}
async function type() {
return invokeTauriCommand({
__tauriModule: "Os",
message: {
cmd: "osType"
}
});
}
async function arch() {
return invokeTauriCommand({
__tauriModule: "Os",
message: {
cmd: "arch"
}
});
}
async function tempdir() {
return invokeTauriCommand({
__tauriModule: "Os",
message: {
cmd: "tempdir"
}
});
}
export {
EOL,
arch,
platform,
tempdir,
type,
version
};

418
src/path.js Normal file
View file

@ -0,0 +1,418 @@
// tauri/tooling/api/src/tauri.ts
function uid() {
return window.crypto.getRandomValues(new Uint32Array(1))[0];
}
function transformCallback(callback, once = false) {
const identifier = uid();
const prop = `_${identifier}`;
Object.defineProperty(window, prop, {
value: (result) => {
if (once) {
Reflect.deleteProperty(window, prop);
}
return callback?.(result);
},
writable: false,
configurable: true
});
return identifier;
}
async function invoke(cmd, args = {}) {
return new Promise((resolve2, reject) => {
const callback = transformCallback((e) => {
resolve2(e);
Reflect.deleteProperty(window, `_${error}`);
}, true);
const error = transformCallback((e) => {
reject(e);
Reflect.deleteProperty(window, `_${callback}`);
}, true);
window.__TAURI_IPC__({
cmd,
callback,
error,
...args
});
});
}
// tauri/tooling/api/src/helpers/tauri.ts
async function invokeTauriCommand(command) {
return invoke("tauri", command);
}
// tauri/tooling/api/src/fs.ts
var BaseDirectory = /* @__PURE__ */ ((BaseDirectory2) => {
BaseDirectory2[BaseDirectory2["Audio"] = 1] = "Audio";
BaseDirectory2[BaseDirectory2["Cache"] = 2] = "Cache";
BaseDirectory2[BaseDirectory2["Config"] = 3] = "Config";
BaseDirectory2[BaseDirectory2["Data"] = 4] = "Data";
BaseDirectory2[BaseDirectory2["LocalData"] = 5] = "LocalData";
BaseDirectory2[BaseDirectory2["Desktop"] = 6] = "Desktop";
BaseDirectory2[BaseDirectory2["Document"] = 7] = "Document";
BaseDirectory2[BaseDirectory2["Download"] = 8] = "Download";
BaseDirectory2[BaseDirectory2["Executable"] = 9] = "Executable";
BaseDirectory2[BaseDirectory2["Font"] = 10] = "Font";
BaseDirectory2[BaseDirectory2["Home"] = 11] = "Home";
BaseDirectory2[BaseDirectory2["Picture"] = 12] = "Picture";
BaseDirectory2[BaseDirectory2["Public"] = 13] = "Public";
BaseDirectory2[BaseDirectory2["Runtime"] = 14] = "Runtime";
BaseDirectory2[BaseDirectory2["Template"] = 15] = "Template";
BaseDirectory2[BaseDirectory2["Video"] = 16] = "Video";
BaseDirectory2[BaseDirectory2["Resource"] = 17] = "Resource";
BaseDirectory2[BaseDirectory2["App"] = 18] = "App";
BaseDirectory2[BaseDirectory2["Log"] = 19] = "Log";
BaseDirectory2[BaseDirectory2["Temp"] = 20] = "Temp";
BaseDirectory2[BaseDirectory2["AppConfig"] = 21] = "AppConfig";
BaseDirectory2[BaseDirectory2["AppData"] = 22] = "AppData";
BaseDirectory2[BaseDirectory2["AppLocalData"] = 23] = "AppLocalData";
BaseDirectory2[BaseDirectory2["AppCache"] = 24] = "AppCache";
BaseDirectory2[BaseDirectory2["AppLog"] = 25] = "AppLog";
return BaseDirectory2;
})(BaseDirectory || {});
// tauri/tooling/api/src/helpers/os-check.ts
function isWindows() {
return navigator.appVersion.includes("Win");
}
// tauri/tooling/api/src/path.ts
async function appDir() {
return appConfigDir();
}
async function appConfigDir() {
return invokeTauriCommand({
__tauriModule: "Path",
message: {
cmd: "resolvePath",
path: "",
directory: 21 /* AppConfig */
}
});
}
async function appDataDir() {
return invokeTauriCommand({
__tauriModule: "Path",
message: {
cmd: "resolvePath",
path: "",
directory: 22 /* AppData */
}
});
}
async function appLocalDataDir() {
return invokeTauriCommand({
__tauriModule: "Path",
message: {
cmd: "resolvePath",
path: "",
directory: 23 /* AppLocalData */
}
});
}
async function appCacheDir() {
return invokeTauriCommand({
__tauriModule: "Path",
message: {
cmd: "resolvePath",
path: "",
directory: 24 /* AppCache */
}
});
}
async function audioDir() {
return invokeTauriCommand({
__tauriModule: "Path",
message: {
cmd: "resolvePath",
path: "",
directory: 1 /* Audio */
}
});
}
async function cacheDir() {
return invokeTauriCommand({
__tauriModule: "Path",
message: {
cmd: "resolvePath",
path: "",
directory: 2 /* Cache */
}
});
}
async function configDir() {
return invokeTauriCommand({
__tauriModule: "Path",
message: {
cmd: "resolvePath",
path: "",
directory: 3 /* Config */
}
});
}
async function dataDir() {
return invokeTauriCommand({
__tauriModule: "Path",
message: {
cmd: "resolvePath",
path: "",
directory: 4 /* Data */
}
});
}
async function desktopDir() {
return invokeTauriCommand({
__tauriModule: "Path",
message: {
cmd: "resolvePath",
path: "",
directory: 6 /* Desktop */
}
});
}
async function documentDir() {
return invokeTauriCommand({
__tauriModule: "Path",
message: {
cmd: "resolvePath",
path: "",
directory: 7 /* Document */
}
});
}
async function downloadDir() {
return invokeTauriCommand({
__tauriModule: "Path",
message: {
cmd: "resolvePath",
path: "",
directory: 8 /* Download */
}
});
}
async function executableDir() {
return invokeTauriCommand({
__tauriModule: "Path",
message: {
cmd: "resolvePath",
path: "",
directory: 9 /* Executable */
}
});
}
async function fontDir() {
return invokeTauriCommand({
__tauriModule: "Path",
message: {
cmd: "resolvePath",
path: "",
directory: 10 /* Font */
}
});
}
async function homeDir() {
return invokeTauriCommand({
__tauriModule: "Path",
message: {
cmd: "resolvePath",
path: "",
directory: 11 /* Home */
}
});
}
async function localDataDir() {
return invokeTauriCommand({
__tauriModule: "Path",
message: {
cmd: "resolvePath",
path: "",
directory: 5 /* LocalData */
}
});
}
async function pictureDir() {
return invokeTauriCommand({
__tauriModule: "Path",
message: {
cmd: "resolvePath",
path: "",
directory: 12 /* Picture */
}
});
}
async function publicDir() {
return invokeTauriCommand({
__tauriModule: "Path",
message: {
cmd: "resolvePath",
path: "",
directory: 13 /* Public */
}
});
}
async function resourceDir() {
return invokeTauriCommand({
__tauriModule: "Path",
message: {
cmd: "resolvePath",
path: "",
directory: 17 /* Resource */
}
});
}
async function resolveResource(resourcePath) {
return invokeTauriCommand({
__tauriModule: "Path",
message: {
cmd: "resolvePath",
path: resourcePath,
directory: 17 /* Resource */
}
});
}
async function runtimeDir() {
return invokeTauriCommand({
__tauriModule: "Path",
message: {
cmd: "resolvePath",
path: "",
directory: 14 /* Runtime */
}
});
}
async function templateDir() {
return invokeTauriCommand({
__tauriModule: "Path",
message: {
cmd: "resolvePath",
path: "",
directory: 15 /* Template */
}
});
}
async function videoDir() {
return invokeTauriCommand({
__tauriModule: "Path",
message: {
cmd: "resolvePath",
path: "",
directory: 16 /* Video */
}
});
}
async function logDir() {
return appLogDir();
}
async function appLogDir() {
return invokeTauriCommand({
__tauriModule: "Path",
message: {
cmd: "resolvePath",
path: "",
directory: 25 /* AppLog */
}
});
}
var sep = isWindows() ? "\\" : "/";
var delimiter = isWindows() ? ";" : ":";
async function resolve(...paths) {
return invokeTauriCommand({
__tauriModule: "Path",
message: {
cmd: "resolve",
paths
}
});
}
async function normalize(path) {
return invokeTauriCommand({
__tauriModule: "Path",
message: {
cmd: "normalize",
path
}
});
}
async function join(...paths) {
return invokeTauriCommand({
__tauriModule: "Path",
message: {
cmd: "join",
paths
}
});
}
async function dirname(path) {
return invokeTauriCommand({
__tauriModule: "Path",
message: {
cmd: "dirname",
path
}
});
}
async function extname(path) {
return invokeTauriCommand({
__tauriModule: "Path",
message: {
cmd: "extname",
path
}
});
}
async function basename(path, ext) {
return invokeTauriCommand({
__tauriModule: "Path",
message: {
cmd: "basename",
path,
ext
}
});
}
async function isAbsolute(path) {
return invokeTauriCommand({
__tauriModule: "Path",
message: {
cmd: "isAbsolute",
path
}
});
}
export {
BaseDirectory,
appCacheDir,
appConfigDir,
appDataDir,
appDir,
appLocalDataDir,
appLogDir,
audioDir,
basename,
cacheDir,
configDir,
dataDir,
delimiter,
desktopDir,
dirname,
documentDir,
downloadDir,
executableDir,
extname,
fontDir,
homeDir,
isAbsolute,
join,
localDataDir,
logDir,
normalize,
pictureDir,
publicDir,
resolve,
resolveResource,
resourceDir,
runtimeDir,
sep,
templateDir,
videoDir
};

230
src/shell.js Normal file
View file

@ -0,0 +1,230 @@
// tauri/tooling/api/src/tauri.ts
function uid() {
return window.crypto.getRandomValues(new Uint32Array(1))[0];
}
function transformCallback(callback, once = false) {
const identifier = uid();
const prop = `_${identifier}`;
Object.defineProperty(window, prop, {
value: (result) => {
if (once) {
Reflect.deleteProperty(window, prop);
}
return callback?.(result);
},
writable: false,
configurable: true
});
return identifier;
}
async function invoke(cmd, args = {}) {
return new Promise((resolve, reject) => {
const callback = transformCallback((e) => {
resolve(e);
Reflect.deleteProperty(window, `_${error}`);
}, true);
const error = transformCallback((e) => {
reject(e);
Reflect.deleteProperty(window, `_${callback}`);
}, true);
window.__TAURI_IPC__({
cmd,
callback,
error,
...args
});
});
}
// tauri/tooling/api/src/helpers/tauri.ts
async function invokeTauriCommand(command) {
return invoke("tauri", command);
}
// tauri/tooling/api/src/shell.ts
async function execute(onEvent, program, args = [], options) {
if (typeof args === "object") {
Object.freeze(args);
}
return invokeTauriCommand({
__tauriModule: "Shell",
message: {
cmd: "execute",
program,
args,
options,
onEventFn: transformCallback(onEvent)
}
});
}
var EventEmitter = class {
constructor() {
this.eventListeners = /* @__PURE__ */ Object.create(null);
}
addListener(eventName, listener) {
return this.on(eventName, listener);
}
removeListener(eventName, listener) {
return this.off(eventName, listener);
}
on(eventName, listener) {
if (eventName in this.eventListeners) {
this.eventListeners[eventName].push(listener);
} else {
this.eventListeners[eventName] = [listener];
}
return this;
}
once(eventName, listener) {
const wrapper = (...args) => {
this.removeListener(eventName, wrapper);
listener(...args);
};
return this.addListener(eventName, wrapper);
}
off(eventName, listener) {
if (eventName in this.eventListeners) {
this.eventListeners[eventName] = this.eventListeners[eventName].filter(
(l) => l !== listener
);
}
return this;
}
removeAllListeners(event) {
if (event) {
delete this.eventListeners[event];
} else {
this.eventListeners = /* @__PURE__ */ Object.create(null);
}
return this;
}
emit(eventName, ...args) {
if (eventName in this.eventListeners) {
const listeners = this.eventListeners[eventName];
for (const listener of listeners)
listener(...args);
return true;
}
return false;
}
listenerCount(eventName) {
if (eventName in this.eventListeners)
return this.eventListeners[eventName].length;
return 0;
}
prependListener(eventName, listener) {
if (eventName in this.eventListeners) {
this.eventListeners[eventName].unshift(listener);
} else {
this.eventListeners[eventName] = [listener];
}
return this;
}
prependOnceListener(eventName, listener) {
const wrapper = (...args) => {
this.removeListener(eventName, wrapper);
listener(...args);
};
return this.prependListener(eventName, wrapper);
}
};
var Child = class {
constructor(pid) {
this.pid = pid;
}
async write(data) {
return invokeTauriCommand({
__tauriModule: "Shell",
message: {
cmd: "stdinWrite",
pid: this.pid,
buffer: typeof data === "string" ? data : Array.from(data)
}
});
}
async kill() {
return invokeTauriCommand({
__tauriModule: "Shell",
message: {
cmd: "killChild",
pid: this.pid
}
});
}
};
var Command = class extends EventEmitter {
constructor(program, args = [], options) {
super();
this.stdout = new EventEmitter();
this.stderr = new EventEmitter();
this.program = program;
this.args = typeof args === "string" ? [args] : args;
this.options = options ?? {};
}
static sidecar(program, args = [], options) {
const instance = new Command(program, args, options);
instance.options.sidecar = true;
return instance;
}
async spawn() {
return execute(
(event) => {
switch (event.event) {
case "Error":
this.emit("error", event.payload);
break;
case "Terminated":
this.emit("close", event.payload);
break;
case "Stdout":
this.stdout.emit("data", event.payload);
break;
case "Stderr":
this.stderr.emit("data", event.payload);
break;
}
},
this.program,
this.args,
this.options
).then((pid) => new Child(pid));
}
async execute() {
return new Promise((resolve, reject) => {
this.on("error", reject);
const stdout = [];
const stderr = [];
this.stdout.on("data", (line) => {
stdout.push(line);
});
this.stderr.on("data", (line) => {
stderr.push(line);
});
this.on("close", (payload) => {
resolve({
code: payload.code,
signal: payload.signal,
stdout: stdout.join("\n"),
stderr: stderr.join("\n")
});
});
this.spawn().catch(reject);
});
}
};
async function open(path, openWith) {
return invokeTauriCommand({
__tauriModule: "Shell",
message: {
cmd: "open",
path,
with: openWith
}
});
}
export {
Child,
Command,
EventEmitter,
open
};

185
src/updater.js Normal file
View file

@ -0,0 +1,185 @@
// tauri/tooling/api/src/tauri.ts
function uid() {
return window.crypto.getRandomValues(new Uint32Array(1))[0];
}
function transformCallback(callback, once3 = false) {
const identifier = uid();
const prop = `_${identifier}`;
Object.defineProperty(window, prop, {
value: (result) => {
if (once3) {
Reflect.deleteProperty(window, prop);
}
return callback?.(result);
},
writable: false,
configurable: true
});
return identifier;
}
async function invoke(cmd, args = {}) {
return new Promise((resolve, reject) => {
const callback = transformCallback((e) => {
resolve(e);
Reflect.deleteProperty(window, `_${error}`);
}, true);
const error = transformCallback((e) => {
reject(e);
Reflect.deleteProperty(window, `_${callback}`);
}, true);
window.__TAURI_IPC__({
cmd,
callback,
error,
...args
});
});
}
// tauri/tooling/api/src/helpers/tauri.ts
async function invokeTauriCommand(command) {
return invoke("tauri", command);
}
// tauri/tooling/api/src/helpers/event.ts
async function _unlisten(event, eventId) {
return invokeTauriCommand({
__tauriModule: "Event",
message: {
cmd: "unlisten",
event,
eventId
}
});
}
async function emit(event, windowLabel, payload) {
await invokeTauriCommand({
__tauriModule: "Event",
message: {
cmd: "emit",
event,
windowLabel,
payload
}
});
}
async function listen(event, windowLabel, handler) {
return invokeTauriCommand({
__tauriModule: "Event",
message: {
cmd: "listen",
event,
windowLabel,
handler: transformCallback(handler)
}
}).then((eventId) => {
return async () => _unlisten(event, eventId);
});
}
async function once(event, windowLabel, handler) {
return listen(event, windowLabel, (eventData) => {
handler(eventData);
_unlisten(event, eventData.id).catch(() => {
});
});
}
// tauri/tooling/api/src/event.ts
async function listen2(event, handler) {
return listen(event, null, handler);
}
async function once2(event, handler) {
return once(event, null, handler);
}
async function emit2(event, payload) {
return emit(event, void 0, payload);
}
// tauri/tooling/api/src/updater.ts
async function onUpdaterEvent(handler) {
return listen2("tauri://update-status" /* STATUS_UPDATE */, (data) => {
handler(data?.payload);
});
}
async function installUpdate() {
let unlistenerFn;
function cleanListener() {
if (unlistenerFn) {
unlistenerFn();
}
unlistenerFn = void 0;
}
return new Promise((resolve, reject) => {
function onStatusChange(statusResult) {
if (statusResult.error) {
cleanListener();
return reject(statusResult.error);
}
if (statusResult.status === "DONE") {
cleanListener();
return resolve();
}
}
onUpdaterEvent(onStatusChange).then((fn) => {
unlistenerFn = fn;
}).catch((e) => {
cleanListener();
throw e;
});
emit2("tauri://update-install" /* INSTALL_UPDATE */).catch((e) => {
cleanListener();
throw e;
});
});
}
async function checkUpdate() {
let unlistenerFn;
function cleanListener() {
if (unlistenerFn) {
unlistenerFn();
}
unlistenerFn = void 0;
}
return new Promise((resolve, reject) => {
function onUpdateAvailable(manifest) {
cleanListener();
return resolve({
manifest,
shouldUpdate: true
});
}
function onStatusChange(statusResult) {
if (statusResult.error) {
cleanListener();
return reject(statusResult.error);
}
if (statusResult.status === "UPTODATE") {
cleanListener();
return resolve({
shouldUpdate: false
});
}
}
once2("tauri://update-available" /* UPDATE_AVAILABLE */, (data) => {
onUpdateAvailable(data?.payload);
}).catch((e) => {
cleanListener();
throw e;
});
onUpdaterEvent(onStatusChange).then((fn) => {
unlistenerFn = fn;
}).catch((e) => {
cleanListener();
throw e;
});
emit2("tauri://update" /* CHECK_UPDATE */).catch((e) => {
cleanListener();
throw e;
});
});
}
export {
checkUpdate,
installUpdate,
onUpdaterEvent
};