chore(deps): replace dependency eslint-config-standard-with-typescript with eslint-config-love 43.1.0 (#1228)

* chore(deps): replace dependency eslint-config-standard-with-typescript with eslint-config-love 43.1.0

* actually apply the rules lol

* rebuild

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: FabianLars <fabianlars@fabianlars.de>
pull/1234/head
renovate[bot] 1 year ago committed by GitHub
parent 8aacc312cf
commit faa89850d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -5,4 +5,6 @@ build/
dist-js
api-iife.js
init-iife.js
init.js
init.js
rollup.config.js
examples/

@ -4,6 +4,7 @@
"es2021": true
},
"extends": [
"love",
"prettier",
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
@ -13,7 +14,8 @@
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
"sourceType": "module",
"project": ["**/tsconfig.json"]
},
"plugins": ["@typescript-eslint"],
"rules": {}

@ -18,7 +18,7 @@
"covector": "^0.10.2",
"eslint": "8.57.0",
"eslint-config-prettier": "9.1.0",
"eslint-config-standard-with-typescript": "43.0.1",
"eslint-config-love": "43.1.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-n": "17.2.1",
"eslint-plugin-promise": "6.1.1",

@ -1 +1 @@
if("__TAURI__"in window){var __TAURI_PLUGIN_AUTHENTICATOR__=function(t){"use strict";async function i(t,i={},a){return window.__TAURI_INTERNALS__.invoke(t,i,a)}"function"==typeof SuppressedError&&SuppressedError;return t.Authenticator=class{async init(){return await i("plugin:authenticator|init_auth")}async register(t,a){return await i("plugin:authenticator|register",{timeout:1e4,challenge:t,application:a})}async verifyRegistration(t,a,e,n){return await i("plugin:authenticator|verify_registration",{challenge:t,application:a,registerData:e,clientData:n})}async sign(t,a,e){return await i("plugin:authenticator|sign",{timeout:1e4,challenge:t,application:a,keyHandle:e})}async verifySignature(t,a,e,n,r,u){return await i("plugin:authenticator|verify_signature",{challenge:t,application:a,signData:e,clientData:n,keyHandle:r,pubkey:u})}},t}({});Object.defineProperty(window.__TAURI__,"authenticator",{value:__TAURI_PLUGIN_AUTHENTICATOR__})}
if("__TAURI__"in window){var __TAURI_PLUGIN_AUTHENTICATOR__=function(t){"use strict";async function i(t,i={},a){return window.__TAURI_INTERNALS__.invoke(t,i,a)}"function"==typeof SuppressedError&&SuppressedError;return t.Authenticator=class{async init(){await i("plugin:authenticator|init_auth")}async register(t,a){return await i("plugin:authenticator|register",{timeout:1e4,challenge:t,application:a})}async verifyRegistration(t,a,e,n){return await i("plugin:authenticator|verify_registration",{challenge:t,application:a,registerData:e,clientData:n})}async sign(t,a,e){return await i("plugin:authenticator|sign",{timeout:1e4,challenge:t,application:a,keyHandle:e})}async verifySignature(t,a,e,n,r,u){return await i("plugin:authenticator|verify_signature",{challenge:t,application:a,signData:e,clientData:n,keyHandle:r,pubkey:u})}},t}({});Object.defineProperty(window.__TAURI__,"authenticator",{value:__TAURI_PLUGIN_AUTHENTICATOR__})}

@ -6,7 +6,7 @@ import { invoke } from "@tauri-apps/api/core";
export class Authenticator {
async init(): Promise<void> {
return await invoke("plugin:authenticator|init_auth");
await invoke("plugin:authenticator|init_auth");
}
async register(challenge: string, application: string): Promise<string> {

@ -1 +1 @@
if("__TAURI__"in window){var __TAURI_PLUGIN_BARCODESCANNER__=function(n){"use strict";async function e(n,e={},r){return window.__TAURI_INTERNALS__.invoke(n,e,r)}var r;return"function"==typeof SuppressedError&&SuppressedError,n.Format=void 0,(r=n.Format||(n.Format={})).QRCode="QR_CODE",r.UPC_A="UPC_A",r.UPC_E="UPC_E",r.EAN8="EAN_8",r.EAN13="EAN_13",r.Code39="CODE_39",r.Code93="CODE_93",r.Code128="CODE_128",r.Codabar="CODABAR",r.ITF="ITF",r.Aztec="AZTEC",r.DataMatrix="DATA_MATRIX",r.PDF417="PDF_417",n.cancel=async function(){return await e("plugin:barcode-scanner|cancel")},n.checkPermissions=async function(){return await e("plugin:barcode-scanner|check_permissions").then((n=>n.camera))},n.openAppSettings=async function(){return await e("plugin:barcode-scanner|open_app_settings")},n.requestPermissions=async function(){return await e("plugin:barcode-scanner|request_permissions").then((n=>n.camera))},n.scan=async function(n){return await e("plugin:barcode-scanner|scan",{...n})},n}({});Object.defineProperty(window.__TAURI__,"barcodeScanner",{value:__TAURI_PLUGIN_BARCODESCANNER__})}
if("__TAURI__"in window){var __TAURI_PLUGIN_BARCODESCANNER__=function(n){"use strict";async function e(n,e={},a){return window.__TAURI_INTERNALS__.invoke(n,e,a)}var a;return"function"==typeof SuppressedError&&SuppressedError,n.Format=void 0,(a=n.Format||(n.Format={})).QRCode="QR_CODE",a.UPC_A="UPC_A",a.UPC_E="UPC_E",a.EAN8="EAN_8",a.EAN13="EAN_13",a.Code39="CODE_39",a.Code93="CODE_93",a.Code128="CODE_128",a.Codabar="CODABAR",a.ITF="ITF",a.Aztec="AZTEC",a.DataMatrix="DATA_MATRIX",a.PDF417="PDF_417",n.cancel=async function(){await e("plugin:barcode-scanner|cancel")},n.checkPermissions=async function(){return await e("plugin:barcode-scanner|check_permissions").then((n=>n.camera))},n.openAppSettings=async function(){await e("plugin:barcode-scanner|open_app_settings")},n.requestPermissions=async function(){return await e("plugin:barcode-scanner|request_permissions").then((n=>n.camera))},n.scan=async function(n){return await e("plugin:barcode-scanner|scan",{...n})},n}({});Object.defineProperty(window.__TAURI__,"barcodeScanner",{value:__TAURI_PLUGIN_BARCODESCANNER__})}

@ -46,7 +46,7 @@ export async function scan(options?: ScanOptions): Promise<Scanned> {
* Cancel the current scan process.
*/
export async function cancel(): Promise<void> {
return await invoke("plugin:barcode-scanner|cancel");
await invoke("plugin:barcode-scanner|cancel");
}
/**
@ -71,5 +71,5 @@ export async function requestPermissions(): Promise<PermissionState> {
* Open application settings. Useful if permission was denied and the user must manually enable it.
*/
export async function openAppSettings(): Promise<void> {
return await invoke("plugin:barcode-scanner|open_app_settings");
await invoke("plugin:barcode-scanner|open_app_settings");
}

@ -1 +1 @@
if("__TAURI__"in window){var __TAURI_PLUGIN_BIOMETRIC__=function(e){"use strict";async function n(e,n={},r){return window.__TAURI_INTERNALS__.invoke(e,n,r)}var r;return"function"==typeof SuppressedError&&SuppressedError,e.BiometryType=void 0,(r=e.BiometryType||(e.BiometryType={}))[r.None=0]="None",r[r.TouchID=1]="TouchID",r[r.FaceID=2]="FaceID",r[r.Iris=3]="Iris",e.authenticate=async function(e,r){return n("plugin:biometric|authenticate",{reason:e,...r})},e.checkStatus=async function(){return n("plugin:biometric|status")},e}({});Object.defineProperty(window.__TAURI__,"biometric",{value:__TAURI_PLUGIN_BIOMETRIC__})}
if("__TAURI__"in window){var __TAURI_PLUGIN_BIOMETRIC__=function(e){"use strict";async function i(e,i={},t){return window.__TAURI_INTERNALS__.invoke(e,i,t)}var t;return"function"==typeof SuppressedError&&SuppressedError,e.BiometryType=void 0,(t=e.BiometryType||(e.BiometryType={}))[t.None=0]="None",t[t.TouchID=1]="TouchID",t[t.FaceID=2]="FaceID",t[t.Iris=3]="Iris",e.authenticate=async function(e,t){await i("plugin:biometric|authenticate",{reason:e,...t})},e.checkStatus=async function(){return await i("plugin:biometric|status")},e}({});Object.defineProperty(window.__TAURI__,"biometric",{value:__TAURI_PLUGIN_BIOMETRIC__})}

@ -51,7 +51,7 @@ export interface AuthOptions {
* @returns a promise resolving to an object containing all the information about the status of the biometry.
*/
export async function checkStatus(): Promise<Status> {
return invoke("plugin:biometric|status");
return await invoke("plugin:biometric|status");
}
/**
@ -70,7 +70,7 @@ export async function authenticate(
reason: string,
options?: AuthOptions,
): Promise<void> {
return invoke("plugin:biometric|authenticate", {
await invoke("plugin:biometric|authenticate", {
reason,
...options,
});

@ -1 +1 @@
if("__TAURI__"in window){var __TAURI_PLUGIN_CLIPBOARDMANAGER__=function(e){"use strict";var r;async function t(e,r={},t){return window.__TAURI_INTERNALS__.invoke(e,r,t)}"function"==typeof SuppressedError&&SuppressedError;class n{get rid(){return function(e,r,t,n){if("a"===t&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof r?e!==r||!n:!r.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===t?n:"a"===t?n.call(e):n?n.value:r.get(e)}(this,r,"f")}constructor(e){r.set(this,void 0),function(e,r,t,n,a){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!a)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof r?e!==r||!a:!r.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===n?a.call(e,t):a?a.value=t:r.set(e,t)}(this,r,e,"f")}async close(){return t("plugin:resources|close",{rid:this.rid})}}r=new WeakMap;class a extends n{constructor(e){super(e)}static async new(e,r,n){return t("plugin:image|new",{rgba:i(e),width:r,height:n}).then((e=>new a(e)))}static async fromBytes(e){return t("plugin:image|from_bytes",{bytes:i(e)}).then((e=>new a(e)))}static async fromPath(e){return t("plugin:image|from_path",{path:e}).then((e=>new a(e)))}async rgba(){return t("plugin:image|rgba",{rid:this.rid}).then((e=>new Uint8Array(e)))}async size(){return t("plugin:image|size",{rid:this.rid})}}function i(e){return null==e?null:"string"==typeof e?e:e instanceof Uint8Array?Array.from(e):e instanceof ArrayBuffer?Array.from(new Uint8Array(e)):e instanceof a?e.rid:e}return e.clear=async function(){await t("plugin:clipboard-manager|clear")},e.readImage=async function(){return await t("plugin:clipboard-manager|read_image").then((e=>new a(e)))},e.readText=async function(){return(await t("plugin:clipboard-manager|read_text")).plainText.text},e.writeHtml=async function(e,r){return t("plugin:clipboard-manager|write_html",{data:{html:{html:e,altHtml:r}}})},e.writeImage=async function(e){return t("plugin:clipboard-manager|write_image",{data:{image:{image:i(e)}}})},e.writeText=async function(e,r){return t("plugin:clipboard-manager|write_text",{data:{plainText:{label:r?.label,text:e}}})},e}({});Object.defineProperty(window.__TAURI__,"clipboardManager",{value:__TAURI_PLUGIN_CLIPBOARDMANAGER__})}
if("__TAURI__"in window){var __TAURI_PLUGIN_CLIPBOARDMANAGER__=function(e){"use strict";var t;async function n(e,t={},n){return window.__TAURI_INTERNALS__.invoke(e,t,n)}"function"==typeof SuppressedError&&SuppressedError;class r{get rid(){return function(e,t,n,r){if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t.get(e)}(this,t)}constructor(e){t.set(this,void 0),function(e,t,n,r,a){if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");t.set(e,n)}(this,t,e)}async close(){return n("plugin:resources|close",{rid:this.rid})}}t=new WeakMap;class a extends r{constructor(e){super(e)}static async new(e,t,r){return n("plugin:image|new",{rgba:i(e),width:t,height:r}).then((e=>new a(e)))}static async fromBytes(e){return n("plugin:image|from_bytes",{bytes:i(e)}).then((e=>new a(e)))}static async fromPath(e){return n("plugin:image|from_path",{path:e}).then((e=>new a(e)))}async rgba(){return n("plugin:image|rgba",{rid:this.rid}).then((e=>new Uint8Array(e)))}async size(){return n("plugin:image|size",{rid:this.rid})}}function i(e){return null==e?null:"string"==typeof e?e:e instanceof Uint8Array?Array.from(e):e instanceof ArrayBuffer?Array.from(new Uint8Array(e)):e instanceof a?e.rid:e}return e.clear=async function(){await n("plugin:clipboard-manager|clear")},e.readImage=async function(){return await n("plugin:clipboard-manager|read_image").then((e=>new a(e)))},e.readText=async function(){return(await n("plugin:clipboard-manager|read_text")).plainText.text},e.writeHtml=async function(e,t){await n("plugin:clipboard-manager|write_html",{data:{html:{html:e,altHtml:t}}})},e.writeImage=async function(e){await n("plugin:clipboard-manager|write_image",{data:{image:{image:i(e)}}})},e.writeText=async function(e,t){await n("plugin:clipboard-manager|write_text",{data:{plainText:{label:t?.label,text:e}}})},e}({});Object.defineProperty(window.__TAURI__,"clipboardManager",{value:__TAURI_PLUGIN_CLIPBOARDMANAGER__})}

@ -30,7 +30,7 @@ async function writeText(
text: string,
opts?: { label?: string },
): Promise<void> {
return invoke("plugin:clipboard-manager|write_text", {
await invoke("plugin:clipboard-manager|write_text", {
data: {
plainText: {
label: opts?.label,
@ -93,7 +93,7 @@ async function readImage(): Promise<Image> {
async function writeImage(
image: string | Image | Uint8Array | ArrayBuffer | number[],
): Promise<void> {
return invoke("plugin:clipboard-manager|write_image", {
await invoke("plugin:clipboard-manager|write_image", {
data: {
image: {
image: transformImage(image),
@ -117,7 +117,7 @@ async function writeImage(
* @since 2.0.0
*/
async function writeHtml(html: string, altHtml?: string): Promise<void> {
return invoke("plugin:clipboard-manager|write_html", {
await invoke("plugin:clipboard-manager|write_html", {
data: {
html: {
html,
@ -138,7 +138,6 @@ async function writeHtml(html: string, altHtml?: string): Promise<void> {
*/
async function clear(): Promise<void> {
await invoke("plugin:clipboard-manager|clear");
return;
}
export { writeText, readText, writeHtml, clear, readImage, writeImage };

@ -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 t(e,n={},t){return window.__TAURI_INTERNALS__.invoke(e,n,t)}var r;async function i(e,r,i){const _="string"==typeof i?.target?{kind:"AnyLabel",label:i.target}:i?.target??{kind:"Any"};return t("plugin:event|listen",{event:e,target:_,handler:n(r)}).then((n=>async()=>async function(e,n){await t("plugin:event|unlisten",{event:e,eventId:n})}(e,n)))}async function _(){return await t("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.WEBVIEW_CREATED="tauri://webview-created",e.FILE_DROP="tauri://file-drop",e.FILE_DROP_HOVER="tauri://file-drop-hover",e.FILE_DROP_CANCELLED="tauri://file-drop-cancelled"}(r||(r={})),e.getCurrent=_,e.onOpenUrl=async function(e){const n=await _();return null!=n&&e(n),await i("deep-link://new-url",(n=>e(n.payload)))},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){return r("plugin:event|listen",{event:e,target:{kind:"Any"},handler:n(t)}).then((n=>async()=>async function(e,n){await r("plugin:event|unlisten",{event:e,eventId:n})}(e,n)))}async function _(){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=_,e.onOpenUrl=async function(e){const n=await _();return null!=n&&e(n),await i("deep-link://new-url",(n=>{e(n.payload)}))},e}({});Object.defineProperty(window.__TAURI__,"deepLink",{value:__TAURI_PLUGIN_DEEPLINK__})}

@ -3,7 +3,7 @@
// SPDX-License-Identifier: MIT
import { invoke } from "@tauri-apps/api/core";
import { UnlistenFn, listen } from "@tauri-apps/api/event";
import { type UnlistenFn, listen } from "@tauri-apps/api/event";
export async function getCurrent(): Promise<string[] | null> {
return await invoke<string[] | null>("plugin:deep-link|get_current");
@ -19,7 +19,7 @@ export async function onOpenUrl(
handler(current);
}
return await listen<string[]>("deep-link://new-url", (event) =>
handler(event.payload),
);
return await listen<string[]>("deep-link://new-url", (event) => {
handler(event.payload);
});
}

@ -1 +1 @@
if("__TAURI__"in window){var __TAURI_PLUGIN_DIALOG__=function(t){"use strict";async function n(t,n={},e){return window.__TAURI_INTERNALS__.invoke(t,n,e)}return"function"==typeof SuppressedError&&SuppressedError,t.ask=async function(t,e){const o="string"==typeof e?{title:e}:e;return n("plugin:dialog|ask",{message:t.toString(),title:o?.title?.toString(),kind:o?.kind,okButtonLabel:o?.okLabel?.toString()??"Yes",cancelButtonLabel:o?.cancelLabel?.toString()??"No"})},t.confirm=async function(t,e){const o="string"==typeof e?{title:e}:e;return n("plugin:dialog|confirm",{message:t.toString(),title:o?.title?.toString(),kind:o?.kind,okButtonLabel:o?.okLabel?.toString()??"Ok",cancelButtonLabel:o?.cancelLabel?.toString()??"Cancel"})},t.message=async function(t,e){const o="string"==typeof e?{title:e}:e;return n("plugin:dialog|message",{message:t.toString(),title:o?.title?.toString(),kind:o?.kind,okButtonLabel:o?.okLabel?.toString()})},t.open=async function(t={}){return"object"==typeof t&&Object.freeze(t),n("plugin:dialog|open",{options:t})},t.save=async function(t={}){return"object"==typeof t&&Object.freeze(t),n("plugin:dialog|save",{options:t})},t}({});Object.defineProperty(window.__TAURI__,"dialog",{value:__TAURI_PLUGIN_DIALOG__})}
if("__TAURI__"in window){var __TAURI_PLUGIN_DIALOG__=function(t){"use strict";async function n(t,n={},e){return window.__TAURI_INTERNALS__.invoke(t,n,e)}return"function"==typeof SuppressedError&&SuppressedError,t.ask=async function(t,e){const i="string"==typeof e?{title:e}:e;return await n("plugin:dialog|ask",{message:t.toString(),title:i?.title?.toString(),kind:i?.kind,okButtonLabel:i?.okLabel?.toString()??"Yes",cancelButtonLabel:i?.cancelLabel?.toString()??"No"})},t.confirm=async function(t,e){const i="string"==typeof e?{title:e}:e;return await n("plugin:dialog|confirm",{message:t.toString(),title:i?.title?.toString(),kind:i?.kind,okButtonLabel:i?.okLabel?.toString()??"Ok",cancelButtonLabel:i?.cancelLabel?.toString()??"Cancel"})},t.message=async function(t,e){const i="string"==typeof e?{title:e}:e;await n("plugin:dialog|message",{message:t.toString(),title:i?.title?.toString(),kind:i?.kind,okButtonLabel:i?.okLabel?.toString()})},t.open=async function(t={}){return"object"==typeof t&&Object.freeze(t),await n("plugin:dialog|open",{options:t})},t.save=async function(t={}){return"object"==typeof t&&Object.freeze(t),await n("plugin:dialog|save",{options:t})},t}({});Object.defineProperty(window.__TAURI__,"dialog",{value:__TAURI_PLUGIN_DIALOG__})}

@ -163,13 +163,14 @@ type OpenDialogReturn<T extends OpenDialogOptions> = T["directory"] extends true
* @since 2.0.0
*/
async function open<T extends OpenDialogOptions>(
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
options: T = {} as T,
): Promise<OpenDialogReturn<T>> {
if (typeof options === "object") {
Object.freeze(options);
}
return invoke("plugin:dialog|open", { options });
return await invoke("plugin:dialog|open", { options });
}
/**
@ -201,7 +202,7 @@ async function save(options: SaveDialogOptions = {}): Promise<string | null> {
Object.freeze(options);
}
return invoke("plugin:dialog|save", { options });
return await invoke("plugin:dialog|save", { options });
}
/**
@ -226,7 +227,7 @@ async function message(
options?: string | MessageDialogOptions,
): Promise<void> {
const opts = typeof options === "string" ? { title: options } : options;
return invoke("plugin:dialog|message", {
await invoke("plugin:dialog|message", {
message: message.toString(),
title: opts?.title?.toString(),
kind: opts?.kind,
@ -255,7 +256,7 @@ async function ask(
options?: string | ConfirmDialogOptions,
): Promise<boolean> {
const opts = typeof options === "string" ? { title: options } : options;
return invoke("plugin:dialog|ask", {
return await invoke("plugin:dialog|ask", {
message: message.toString(),
title: opts?.title?.toString(),
kind: opts?.kind,
@ -285,7 +286,7 @@ async function confirm(
options?: string | ConfirmDialogOptions,
): Promise<boolean> {
const opts = typeof options === "string" ? { title: options } : options;
return invoke("plugin:dialog|confirm", {
return await invoke("plugin:dialog|confirm", {
message: message.toString(),
title: opts?.title?.toString(),
kind: opts?.kind,

@ -5,14 +5,14 @@
import { invoke } from "@tauri-apps/api/core";
window.alert = function (message: string) {
invoke("plugin:dialog|message", {
void invoke("plugin:dialog|message", {
message: message.toString(),
});
};
// @ts-expect-error tauri does not have sync IPC :(
window.confirm = function (message: string) {
return invoke("plugin:dialog|confirm", {
window.confirm = async function (message: string) {
return await invoke("plugin:dialog|confirm", {
message: message.toString(),
});
};

@ -1 +1 @@
!function(){"use strict";async function n(n,i={},o){return window.__TAURI_INTERNALS__.invoke(n,i,o)}"function"==typeof SuppressedError&&SuppressedError,window.alert=function(i){n("plugin:dialog|message",{message:i.toString()})},window.confirm=function(i){return n("plugin:dialog|confirm",{message:i.toString()})}}();
!function(){"use strict";async function n(n,i={},o){return window.__TAURI_INTERNALS__.invoke(n,i,o)}"function"==typeof SuppressedError&&SuppressedError,window.alert=function(i){n("plugin:dialog|message",{message:i.toString()})},window.confirm=async function(i){return await n("plugin:dialog|confirm",{message:i.toString()})}}();

File diff suppressed because one or more lines are too long

@ -249,10 +249,6 @@ function parseFileInfo(r: UnparsedFileInfo): FileInfo {
* @since 2.0.0
*/
class FileHandle extends Resource {
constructor(rid: number) {
super(rid);
}
/**
* Reads up to `p.byteLength` bytes into `p`. It resolves to the number of
* bytes read (`0` < `n` <= `p.byteLength`) and rejects if any error
@ -330,7 +326,7 @@ class FileHandle extends Resource {
* @since 2.0.0
*/
async seek(offset: number, whence: SeekMode): Promise<number> {
return invoke("plugin:fs|seek", {
return await invoke("plugin:fs|seek", {
rid: this.rid,
offset,
whence,
@ -382,7 +378,7 @@ class FileHandle extends Resource {
* @since 2.0.0
*/
async truncate(len?: number): Promise<void> {
return invoke("plugin:fs|ftruncate", {
await invoke("plugin:fs|ftruncate", {
rid: this.rid,
len,
});
@ -409,7 +405,7 @@ class FileHandle extends Resource {
* @since 2.0.0
*/
async write(data: Uint8Array): Promise<number> {
return invoke("plugin:fs|write", {
return await invoke("plugin:fs|write", {
rid: this.rid,
data: Array.from(data),
});
@ -569,7 +565,7 @@ async function copyFile(
throw new TypeError("Must be a file URL.");
}
return invoke("plugin:fs|copy_file", {
await invoke("plugin:fs|copy_file", {
fromPath: fromPath instanceof URL ? fromPath.toString() : fromPath,
toPath: toPath instanceof URL ? toPath.toString() : toPath,
options,
@ -608,7 +604,7 @@ async function mkdir(
throw new TypeError("Must be a file URL.");
}
return invoke("plugin:fs|mkdir", {
await invoke("plugin:fs|mkdir", {
path: path instanceof URL ? path.toString() : path,
options,
});
@ -669,7 +665,7 @@ async function readDir(
throw new TypeError("Must be a file URL.");
}
return invoke("plugin:fs|read_dir", {
return await invoke("plugin:fs|read_dir", {
path: path instanceof URL ? path.toString() : path,
options,
});
@ -728,7 +724,7 @@ async function readTextFile(
throw new TypeError("Must be a file URL.");
}
return invoke<string>("plugin:fs|read_text_file", {
return await invoke<string>("plugin:fs|read_text_file", {
path: path instanceof URL ? path.toString() : path,
options,
});
@ -759,11 +755,11 @@ async function readTextFileLines(
const pathStr = path instanceof URL ? path.toString() : path;
return Promise.resolve({
return await Promise.resolve({
path: pathStr,
rid: null as number | null,
async next(): Promise<IteratorResult<string>> {
if (!this.rid) {
if (this.rid == null) {
this.rid = await invoke<number>("plugin:fs|read_text_file_lines", {
path: pathStr,
options,
@ -779,7 +775,8 @@ async function readTextFileLines(
if (done) this.rid = null;
return {
value: done ? "" : (line as string),
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
value: done ? "" : line!,
done,
};
},
@ -819,7 +816,7 @@ async function remove(
throw new TypeError("Must be a file URL.");
}
return invoke("plugin:fs|remove", {
await invoke("plugin:fs|remove", {
path: path instanceof URL ? path.toString() : path,
options,
});
@ -862,7 +859,7 @@ async function rename(
throw new TypeError("Must be a file URL.");
}
return invoke("plugin:fs|rename", {
await invoke("plugin:fs|rename", {
oldPath: oldPath instanceof URL ? oldPath.toString() : oldPath,
newPath: newPath instanceof URL ? newPath.toString() : newPath,
options,
@ -965,7 +962,7 @@ async function truncate(
throw new TypeError("Must be a file URL.");
}
return invoke("plugin:fs|truncate", {
await invoke("plugin:fs|truncate", {
path: path instanceof URL ? path.toString() : path,
len,
options,
@ -1010,7 +1007,7 @@ async function writeFile(
throw new TypeError("Must be a file URL.");
}
return invoke("plugin:fs|write_file", {
await invoke("plugin:fs|write_file", {
path: path instanceof URL ? path.toString() : path,
data: Array.from(data),
options,
@ -1037,7 +1034,7 @@ async function writeTextFile(
throw new TypeError("Must be a file URL.");
}
return invoke("plugin:fs|write_text_file", {
await invoke("plugin:fs|write_text_file", {
path: path instanceof URL ? path.toString() : path,
data,
options,
@ -1071,7 +1068,7 @@ async function exists(
throw new TypeError("Must be a file URL.");
}
return invoke("plugin:fs|exists", {
return await invoke("plugin:fs|exists", {
path: path instanceof URL ? path.toString() : path,
options,
});
@ -1098,11 +1095,11 @@ interface DebouncedWatchOptions extends WatchOptions {
/**
* @since 2.0.0
*/
type WatchEvent = {
interface WatchEvent {
type: WatchEventKind;
paths: string[];
attrs: unknown;
};
}
/**
* @since 2.0.0

@ -1 +1 @@
if("__TAURI__"in window){var __TAURI_PLUGIN_GLOBALSHORTCUT__=function(t){"use strict";function e(t,e,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(t):n?n.value:e.get(t)}function r(t,e,r,n,s){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?s.call(t,r):s?s.value=r:e.set(t,r),r}var n,s,i;"function"==typeof SuppressedError&&SuppressedError;class o{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,n.set(this,(()=>{})),s.set(this,0),i.set(this,{}),this.id=function(t,e=!1){return window.__TAURI_INTERNALS__.transformCallback(t,e)}((({message:t,id:o})=>{if(o===e(this,s,"f")){r(this,s,o+1,"f"),e(this,n,"f").call(this,t);const a=Object.keys(e(this,i,"f"));if(a.length>0){let t=o+1;for(const r of a.sort()){if(parseInt(r)!==t)break;{const s=e(this,i,"f")[r];delete e(this,i,"f")[r],e(this,n,"f").call(this,s),t+=1}}}}else e(this,i,"f")[o.toString()]=t}))}set onmessage(t){r(this,n,t,"f")}get onmessage(){return e(this,n,"f")}toJSON(){return`__CHANNEL__:${this.id}`}}async function a(t,e={},r){return window.__TAURI_INTERNALS__.invoke(t,e,r)}return n=new WeakMap,s=new WeakMap,i=new WeakMap,t.isRegistered=async function(t){return await a("plugin:global-shortcut|is_registered",{shortcut:t})},t.register=async function(t,e){const r=new o;return r.onmessage=e,await a("plugin:global-shortcut|register",{shortcut:t,handler:r})},t.registerAll=async function(t,e){const r=new o;return r.onmessage=e,await a("plugin:global-shortcut|register_all",{shortcuts:t,handler:r})},t.unregister=async function(t){return await a("plugin:global-shortcut|unregister",{shortcut:t})},t.unregisterAll=async function(){return await a("plugin:global-shortcut|unregister_all")},t}({});Object.defineProperty(window.__TAURI__,"globalShortcut",{value:__TAURI_PLUGIN_GLOBALSHORTCUT__})}
if("__TAURI__"in window){var __TAURI_PLUGIN_GLOBALSHORTCUT__=function(t){"use strict";function e(t,e,s,n){if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(t)}function s(t,e,s,n,r){if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,s),s}var n,r,i;"function"==typeof SuppressedError&&SuppressedError;class o{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,n.set(this,(()=>{})),r.set(this,0),i.set(this,{}),this.id=function(t,e=!1){return window.__TAURI_INTERNALS__.transformCallback(t,e)}((({message:t,id:o})=>{if(o===e(this,r)){s(this,r,o+1),e(this,n).call(this,t);const a=Object.keys(e(this,i));if(a.length>0){let t=o+1;for(const s of a.sort()){if(parseInt(s)!==t)break;{const r=e(this,i)[s];delete e(this,i)[s],e(this,n).call(this,r),t+=1}}}}else e(this,i)[o.toString()]=t}))}set onmessage(t){s(this,n,t)}get onmessage(){return e(this,n)}toJSON(){return`__CHANNEL__:${this.id}`}}async function a(t,e={},s){return window.__TAURI_INTERNALS__.invoke(t,e,s)}return n=new WeakMap,r=new WeakMap,i=new WeakMap,t.isRegistered=async function(t){return await a("plugin:global-shortcut|is_registered",{shortcut:t})},t.register=async function(t,e){const s=new o;s.onmessage=e,await a("plugin:global-shortcut|register",{shortcut:t,handler:s})},t.registerAll=async function(t,e){const s=new o;s.onmessage=e,await a("plugin:global-shortcut|register_all",{shortcuts:t,handler:s})},t.unregister=async function(t){await a("plugin:global-shortcut|unregister",{shortcut:t})},t.unregisterAll=async function(){await a("plugin:global-shortcut|unregister_all")},t}({});Object.defineProperty(window.__TAURI__,"globalShortcut",{value:__TAURI_PLUGIN_GLOBALSHORTCUT__})}

@ -34,7 +34,7 @@ async function register(
const h = new Channel<string>();
h.onmessage = handler;
return await invoke("plugin:global-shortcut|register", {
await invoke("plugin:global-shortcut|register", {
shortcut,
handler: h,
});
@ -62,7 +62,7 @@ async function registerAll(
const h = new Channel<string>();
h.onmessage = handler;
return await invoke("plugin:global-shortcut|register_all", {
await invoke("plugin:global-shortcut|register_all", {
shortcuts,
handler: h,
});
@ -102,7 +102,7 @@ async function isRegistered(shortcut: string): Promise<boolean> {
* @since 2.0.0
*/
async function unregister(shortcut: string): Promise<void> {
return await invoke("plugin:global-shortcut|unregister", {
await invoke("plugin:global-shortcut|unregister", {
shortcut,
});
}
@ -118,7 +118,7 @@ async function unregister(shortcut: string): Promise<void> {
* @since 2.0.0
*/
async function unregisterAll(): Promise<void> {
return await invoke("plugin:global-shortcut|unregister_all");
await invoke("plugin:global-shortcut|unregister_all");
}
export { register, registerAll, isRegistered, unregister, unregisterAll };

@ -1 +1 @@
if("__TAURI__"in window){var __TAURI_PLUGIN_HTTP__=function(e){"use strict";async function t(e,t={},r){return window.__TAURI_INTERNALS__.invoke(e,t,r)}return"function"==typeof SuppressedError&&SuppressedError,e.fetch=async function(e,r){const n=r?.maxRedirections,a=r?.connectTimeout,i=r?.proxy;r&&(delete r.maxRedirections,delete r.connectTimeout,delete r.proxy);const s=r?.signal,o=(r?.headers?r.headers instanceof Headers?Array.from(r.headers.entries()):Array.isArray(r.headers)?r.headers:Object.entries(r.headers):[]).map((([e,t])=>[e,"string"==typeof t?t:t.toString()])),d=new Request(e,r),c=await d.arrayBuffer(),u=c.byteLength?Array.from(new Uint8Array(c)):null,_=await t("plugin:http|fetch",{clientConfig:{method:d.method,url:d.url,headers:o,data:u,maxRedirections:n,connectTimeout:a,proxy:i}});s?.addEventListener("abort",(()=>{t("plugin:http|fetch_cancel",{rid:_})}));const{status:f,statusText:h,url:p,headers:l,rid:y}=await t("plugin:http|fetch_send",{rid:_}),T=await t("plugin:http|fetch_read_body",{rid:y}),w=new Response(T instanceof ArrayBuffer&&T.byteLength?T:T instanceof Array&&T.length?new Uint8Array(T):null,{headers:l,status:f,statusText:h});return Object.defineProperty(w,"url",{value:p}),w},e}({});Object.defineProperty(window.__TAURI__,"http",{value:__TAURI_PLUGIN_HTTP__})}
if("__TAURI__"in window){var __TAURI_PLUGIN_HTTP__=function(e){"use strict";async function t(e,t={},r){return window.__TAURI_INTERNALS__.invoke(e,t,r)}return"function"==typeof SuppressedError&&SuppressedError,e.fetch=async function(e,r){const n=r?.maxRedirections,a=r?.connectTimeout,i=r?.proxy;null!=r&&(delete r.maxRedirections,delete r.connectTimeout,delete r.proxy);const s=r?.signal,o=(null==r?.headers?[]:r.headers instanceof Headers?Array.from(r.headers.entries()):Array.isArray(r.headers)?r.headers:Object.entries(r.headers)).map((([e,t])=>[e,"string"==typeof t?t:t.toString()])),d=new Request(e,r),u=await d.arrayBuffer(),c=0!==u.byteLength?Array.from(new Uint8Array(u)):null,_=await t("plugin:http|fetch",{clientConfig:{method:d.method,url:d.url,headers:o,data:c,maxRedirections:n,connectTimeout:a,proxy:i}});s?.addEventListener("abort",(()=>{t("plugin:http|fetch_cancel",{rid:_})}));const{status:l,statusText:f,url:h,headers:p,rid:y}=await t("plugin:http|fetch_send",{rid:_}),T=await t("plugin:http|fetch_read_body",{rid:y}),w=new Response(T instanceof ArrayBuffer&&0!==T.byteLength?T:T instanceof Array&&T.length>0?new Uint8Array(T):null,{headers:p,status:l,statusText:f});return Object.defineProperty(w,"url",{value:h}),w},e}({});Object.defineProperty(window.__TAURI__,"http",{value:__TAURI_PLUGIN_HTTP__})}

@ -31,7 +31,7 @@ import { invoke } from "@tauri-apps/api/core";
*
* @since 2.0.0
*/
export type Proxy = {
export interface Proxy {
/**
* Proxy all traffic to the passed URL.
*/
@ -44,7 +44,7 @@ export type Proxy = {
* Proxy all HTTPS traffic to the passed URL.
*/
https?: string | ProxyConfig;
};
}
export interface ProxyConfig {
/**
@ -59,7 +59,7 @@ export interface ProxyConfig {
password: string;
};
/**
* A configuration for filtering out requests that shouldnt be proxied.
* A configuration for filtering out requests that shouldn't be proxied.
* Entries are expected to be comma-separated (whitespace between entries is ignored)
*/
noProxy?: string;
@ -107,7 +107,7 @@ export async function fetch(
const proxy = init?.proxy;
// Remove these fields before creating the request
if (init) {
if (init != null) {
delete init.maxRedirections;
delete init.connectTimeout;
delete init.proxy;
@ -115,15 +115,16 @@ export async function fetch(
const signal = init?.signal;
const headers = !init?.headers
? []
: init.headers instanceof Headers
? Array.from(init.headers.entries())
: Array.isArray(init.headers)
? init.headers
: Object.entries(init.headers);
const headers =
init?.headers == null
? []
: init.headers instanceof Headers
? Array.from(init.headers.entries())
: Array.isArray(init.headers)
? init.headers
: Object.entries(init.headers);
const mappedHeaders: [string, string][] = headers.map(([name, val]) => [
const mappedHeaders: Array<[string, string]> = headers.map(([name, val]) => [
name,
// we need to ensure we have all values as strings
// eslint-disable-next-line
@ -132,7 +133,8 @@ export async function fetch(
const req = new Request(input, init);
const buffer = await req.arrayBuffer();
const reqData = buffer.byteLength ? Array.from(new Uint8Array(buffer)) : null;
const reqData =
buffer.byteLength !== 0 ? Array.from(new Uint8Array(buffer)) : null;
const rid = await invoke<number>("plugin:http|fetch", {
clientConfig: {
@ -147,7 +149,7 @@ export async function fetch(
});
signal?.addEventListener("abort", () => {
invoke("plugin:http|fetch_cancel", {
void invoke("plugin:http|fetch_cancel", {
rid,
});
});
@ -178,9 +180,9 @@ export async function fetch(
);
const res = new Response(
body instanceof ArrayBuffer && body.byteLength
body instanceof ArrayBuffer && body.byteLength !== 0
? body
: body instanceof Array && body.length
: body instanceof Array && body.length > 0
? new Uint8Array(body)
: null,
{

@ -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="string"==typeof t?.target?{kind:"AnyLabel",label:t.target}:t?.target??{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:l}=a??{};let u=o?.[0]?.filter((e=>e.length>0)).join("@");"Error"===u&&(u="webview::unknown"),await r("plugin:log|log",{level:e,message:n,location:u,file:i,line:c,keyValues:l})}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.WEBVIEW_CREATED="tauri://webview-created",e.FILE_DROP="tauri://file-drop",e.FILE_DROP_HOVER="tauri://file-drop-hover",e.FILE_DROP_CANCELLED="tauri://file-drop-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 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){return r("plugin:event|listen",{event:e,target:{kind:"Any"},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__})}

@ -5,11 +5,11 @@
import { invoke } from "@tauri-apps/api/core";
import { listen, type UnlistenFn, type Event } from "@tauri-apps/api/event";
export type LogOptions = {
export interface LogOptions {
file?: string;
line?: number;
keyValues?: Record<string, string | undefined>;
};
}
enum LogLevel {
/**
@ -218,7 +218,7 @@ export async function attachLogger(fn: LoggerFn): Promise<UnlistenFn> {
* @returns a function to cancel the listener.
*/
export async function attachConsole(): Promise<UnlistenFn> {
return attachLogger(({ level, message }: RecordPayload) => {
return await attachLogger(({ level, message }: RecordPayload) => {
switch (level) {
case LogLevel.Trace:
console.log(message);

@ -1 +1 @@
if("__TAURI__"in window){var __TAURI_PLUGIN_NFC__=function(n){"use strict";async function e(n,e={},t){return window.__TAURI_INTERNALS__.invoke(n,e,t)}"function"==typeof SuppressedError&&SuppressedError;const t=[84],r=[85];var o,c;function a(n,e,t,r){return{format:n,kind:"string"==typeof e?Array.from((new TextEncoder).encode(e)):e,id:"string"==typeof t?Array.from((new TextEncoder).encode(t)):t,payload:"string"==typeof r?Array.from((new TextEncoder).encode(r)):r}}n.TechKind=void 0,(o=n.TechKind||(n.TechKind={}))[o.IsoDep=0]="IsoDep",o[o.MifareClassic=1]="MifareClassic",o[o.MifareUltralight=2]="MifareUltralight",o[o.Ndef=3]="Ndef",o[o.NdefFormatable=4]="NdefFormatable",o[o.NfcA=5]="NfcA",o[o.NfcB=6]="NfcB",o[o.NfcBarcode=7]="NfcBarcode",o[o.NfcF=8]="NfcF",o[o.NfcV=9]="NfcV",n.NFCTypeNameFormat=void 0,(c=n.NFCTypeNameFormat||(n.NFCTypeNameFormat={}))[c.Empty=0]="Empty",c[c.NfcWellKnown=1]="NfcWellKnown",c[c.Media=2]="Media",c[c.AbsoluteURI=3]="AbsoluteURI",c[c.NfcExternal=4]="NfcExternal",c[c.Unknown=5]="Unknown",c[c.Unchanged=6]="Unchanged";const i=["","http://www.","https://www.","http://","https://","tel:","mailto:","ftp://anonymous:anonymous@","ftp://ftp.","ftps://","sftp://","smb://","nfs://","ftp://","dav://","news:","telnet://","imap:","rtsp://","urn:","pop:","sip:","sips:","tftp:","btspp://","btl2cap://","btgoep://","tcpobex://","irdaobex://","file://","urn:epc:id:","urn:epc:tag:","urn:epc:pat:","urn:epc:raw:","urn:epc:","urn:nfc:"];function f(n){const{type:e,...t}=n;return{[e]:t}}return n.RTD_TEXT=t,n.RTD_URI=r,n.isAvailable=async function(){return await e("plugin:nfc|is_available")},n.record=a,n.scan=async function(n,t){return await e("plugin:nfc|scan",{kind:f(n),...t})},n.textRecord=function(e,r,o="en"){const c=Array.from((new TextEncoder).encode(o+e));return c.unshift(o.length),a(n.NFCTypeNameFormat.NfcWellKnown,t,r||[],c)},n.uriRecord=function(e,t){return a(n.NFCTypeNameFormat.NfcWellKnown,r,t||[],function(n){let e="";i.slice(1).forEach((function(t){e&&"urn:"!==e||0!==n.indexOf(t)||(e=t)})),e||(e="");const t=Array.from((new TextEncoder).encode(n.slice(e.length))),r=i.indexOf(e);return t.unshift(r),t}(e))},n.write=async function(n,t){const{kind:r,...o}=t||{};return r&&(o.kind=f(r)),await e("plugin:nfc|write",{records:n,...o})},n}({});Object.defineProperty(window.__TAURI__,"nfc",{value:__TAURI_PLUGIN_NFC__})}
if("__TAURI__"in window){var __TAURI_PLUGIN_NFC__=function(n){"use strict";async function e(n,e={},t){return window.__TAURI_INTERNALS__.invoke(n,e,t)}"function"==typeof SuppressedError&&SuppressedError;const t=[84],r=[85];var o,c;function a(n,e,t,r){return{format:n,kind:"string"==typeof e?Array.from((new TextEncoder).encode(e)):e,id:"string"==typeof t?Array.from((new TextEncoder).encode(t)):t,payload:"string"==typeof r?Array.from((new TextEncoder).encode(r)):r}}n.TechKind=void 0,(o=n.TechKind||(n.TechKind={}))[o.IsoDep=0]="IsoDep",o[o.MifareClassic=1]="MifareClassic",o[o.MifareUltralight=2]="MifareUltralight",o[o.Ndef=3]="Ndef",o[o.NdefFormatable=4]="NdefFormatable",o[o.NfcA=5]="NfcA",o[o.NfcB=6]="NfcB",o[o.NfcBarcode=7]="NfcBarcode",o[o.NfcF=8]="NfcF",o[o.NfcV=9]="NfcV",n.NFCTypeNameFormat=void 0,(c=n.NFCTypeNameFormat||(n.NFCTypeNameFormat={}))[c.Empty=0]="Empty",c[c.NfcWellKnown=1]="NfcWellKnown",c[c.Media=2]="Media",c[c.AbsoluteURI=3]="AbsoluteURI",c[c.NfcExternal=4]="NfcExternal",c[c.Unknown=5]="Unknown",c[c.Unchanged=6]="Unchanged";const i=["","http://www.","https://www.","http://","https://","tel:","mailto:","ftp://anonymous:anonymous@","ftp://ftp.","ftps://","sftp://","smb://","nfs://","ftp://","dav://","news:","telnet://","imap:","rtsp://","urn:","pop:","sip:","sips:","tftp:","btspp://","btl2cap://","btgoep://","tcpobex://","irdaobex://","file://","urn:epc:id:","urn:epc:tag:","urn:epc:pat:","urn:epc:raw:","urn:epc:","urn:nfc:"];function f(n){const{type:e,...t}=n;return{[e]:t}}return n.RTD_TEXT=t,n.RTD_URI=r,n.isAvailable=async function(){return await e("plugin:nfc|is_available")},n.record=a,n.scan=async function(n,t){return await e("plugin:nfc|scan",{kind:f(n),...t})},n.textRecord=function(e,r,o="en"){const c=Array.from((new TextEncoder).encode(o+e));return c.unshift(o.length),a(n.NFCTypeNameFormat.NfcWellKnown,t,r??[],c)},n.uriRecord=function(e,t){return a(n.NFCTypeNameFormat.NfcWellKnown,r,t??[],function(n){let e="";i.slice(1).forEach((function(t){0!==e.length&&"urn:"!==e||0!==n.indexOf(t)||(e=t)})),0===e.length&&(e="");const t=Array.from((new TextEncoder).encode(n.slice(e.length))),r=i.indexOf(e);return t.unshift(r),t}(e))},n.write=async function(n,t){const{kind:r,...o}=t??{};null!=r&&(o.kind=f(r)),await e("plugin:nfc|write",{records:n,...o})},n}({});Object.defineProperty(window.__TAURI__,"nfc",{value:__TAURI_PLUGIN_NFC__})}

@ -134,7 +134,7 @@ export function textRecord(
): NFCRecord {
const payload = Array.from(new TextEncoder().encode(language + text));
payload.unshift(language.length);
return record(NFCTypeNameFormat.NfcWellKnown, RTD_TEXT, id || [], payload);
return record(NFCTypeNameFormat.NfcWellKnown, RTD_TEXT, id ?? [], payload);
}
const protocols = [
@ -180,12 +180,15 @@ function encodeURI(uri: string): number[] {
let prefix = "";
protocols.slice(1).forEach(function (protocol) {
if ((!prefix || prefix === "urn:") && uri.indexOf(protocol) === 0) {
if (
(prefix.length === 0 || prefix === "urn:") &&
uri.indexOf(protocol) === 0
) {
prefix = protocol;
}
});
if (!prefix) {
if (prefix.length === 0) {
prefix = "";
}
@ -203,7 +206,7 @@ export function uriRecord(uri: string, id?: string | number[]): NFCRecord {
return record(
NFCTypeNameFormat.NfcWellKnown,
RTD_URI,
id || [],
id ?? [],
encodeURI(uri),
);
}
@ -256,12 +259,12 @@ export async function write(
records: NFCRecord[],
options?: WriteOptions,
): Promise<void> {
const { kind, ...opts } = options || {};
if (kind) {
const { kind, ...opts } = options ?? {};
if (kind != null) {
// @ts-expect-error map the property
opts.kind = mapScanKind(kind);
}
return await invoke("plugin:nfc|write", {
await invoke("plugin:nfc|write", {
records,
...opts,
});

@ -1 +1 @@
if("__TAURI__"in window){var __TAURI_PLUGIN_NOTIFICATION__=function(e){"use strict";function n(e,n,i,t){if("a"===i&&!t)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof n?e!==n||!t:!n.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?t:"a"===i?t.call(e):t?t.value:n.get(e)}function i(e,n,i,t,o){if("m"===t)throw new TypeError("Private method is not writable");if("a"===t&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof n?e!==n||!o:!n.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===t?o.call(e,i):o?o.value=i:n.set(e,i),i}var t,o,r,a,c,s;"function"==typeof SuppressedError&&SuppressedError;class l{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,t.set(this,(()=>{})),o.set(this,0),r.set(this,{}),this.id=function(e,n=!1){return window.__TAURI_INTERNALS__.transformCallback(e,n)}((({message:e,id:a})=>{if(a===n(this,o,"f")){i(this,o,a+1,"f"),n(this,t,"f").call(this,e);const c=Object.keys(n(this,r,"f"));if(c.length>0){let e=a+1;for(const i of c.sort()){if(parseInt(i)!==e)break;{const o=n(this,r,"f")[i];delete n(this,r,"f")[i],n(this,t,"f").call(this,o),e+=1}}}}else n(this,r,"f")[a.toString()]=e}))}set onmessage(e){i(this,t,e,"f")}get onmessage(){return n(this,t,"f")}toJSON(){return`__CHANNEL__:${this.id}`}}t=new WeakMap,o=new WeakMap,r=new WeakMap;class u{constructor(e,n,i){this.plugin=e,this.event=n,this.channelId=i}async unregister(){return d(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}}async function f(e,n,i){const t=new l;return t.onmessage=i,d(`plugin:${e}|register_listener`,{event:n,handler:t}).then((()=>new u(e,n,t.id)))}async function d(e,n={},i){return window.__TAURI_INTERNALS__.invoke(e,n,i)}e.ScheduleEvery=void 0,(a=e.ScheduleEvery||(e.ScheduleEvery={})).Year="year",a.Month="month",a.TwoWeeks="twoWeeks",a.Week="week",a.Day="day",a.Hour="hour",a.Minute="minute",a.Second="second";return e.Importance=void 0,(c=e.Importance||(e.Importance={}))[c.None=0]="None",c[c.Min=1]="Min",c[c.Low=2]="Low",c[c.Default=3]="Default",c[c.High=4]="High",e.Visibility=void 0,(s=e.Visibility||(e.Visibility={}))[s.Secret=-1]="Secret",s[s.Private=0]="Private",s[s.Public=1]="Public",e.Schedule=class{static at(e,n=!1,i=!1){return{at:{date:e,repeating:n,allowWhileIdle:i},interval:void 0,every:void 0}}static interval(e,n=!1){return{at:void 0,interval:{interval:e,allowWhileIdle:n},every:void 0}}static every(e,n,i=!1){return{at:void 0,interval:void 0,every:{interval:e,count:n,allowWhileIdle:i}}}},e.active=async function(){return d("plugin:notification|get_active")},e.cancel=async function(e){return d("plugin:notification|cancel",{notifications:e})},e.cancelAll=async function(){return d("plugin:notification|cancel")},e.channels=async function(){return d("plugin:notification|listChannels")},e.createChannel=async function(e){return d("plugin:notification|create_channel",{...e})},e.isPermissionGranted=async function(){return"default"!==window.Notification.permission?Promise.resolve("granted"===window.Notification.permission):d("plugin:notification|is_permission_granted")},e.onAction=async function(e){return f("notification","actionPerformed",e)},e.onNotificationReceived=async function(e){return f("notification","notification",e)},e.pending=async function(){return d("plugin:notification|get_pending")},e.registerActionTypes=async function(e){return d("plugin:notification|register_action_types",{types:e})},e.removeActive=async function(e){return d("plugin:notification|remove_active",{notifications:e})},e.removeAllActive=async function(){return d("plugin:notification|remove_active")},e.removeChannel=async function(e){return d("plugin:notification|delete_channel",{id:e})},e.requestPermission=async function(){return window.Notification.requestPermission()},e.sendNotification=function(e){"string"==typeof e?new window.Notification(e):new window.Notification(e.title,e)},e}({});Object.defineProperty(window.__TAURI__,"notification",{value:__TAURI_PLUGIN_NOTIFICATION__})}
if("__TAURI__"in window){var __TAURI_PLUGIN_NOTIFICATION__=function(i){"use strict";function n(i,n,t,e){if("function"==typeof n?i!==n||!e:!n.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n.get(i)}function t(i,n,t,e,o){if("function"==typeof n?i!==n||!o:!n.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n.set(i,t),t}var e,o,a,r,c,s;"function"==typeof SuppressedError&&SuppressedError;class l{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,e.set(this,(()=>{})),o.set(this,0),a.set(this,{}),this.id=function(i,n=!1){return window.__TAURI_INTERNALS__.transformCallback(i,n)}((({message:i,id:r})=>{if(r===n(this,o)){t(this,o,r+1),n(this,e).call(this,i);const c=Object.keys(n(this,a));if(c.length>0){let i=r+1;for(const t of c.sort()){if(parseInt(t)!==i)break;{const o=n(this,a)[t];delete n(this,a)[t],n(this,e).call(this,o),i+=1}}}}else n(this,a)[r.toString()]=i}))}set onmessage(i){t(this,e,i)}get onmessage(){return n(this,e)}toJSON(){return`__CHANNEL__:${this.id}`}}e=new WeakMap,o=new WeakMap,a=new WeakMap;class u{constructor(i,n,t){this.plugin=i,this.event=n,this.channelId=t}async unregister(){return d(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}}async function f(i,n,t){const e=new l;return e.onmessage=t,d(`plugin:${i}|register_listener`,{event:n,handler:e}).then((()=>new u(i,n,e.id)))}async function d(i,n={},t){return window.__TAURI_INTERNALS__.invoke(i,n,t)}i.ScheduleEvery=void 0,(r=i.ScheduleEvery||(i.ScheduleEvery={})).Year="year",r.Month="month",r.TwoWeeks="twoWeeks",r.Week="week",r.Day="day",r.Hour="hour",r.Minute="minute",r.Second="second";return i.Importance=void 0,(c=i.Importance||(i.Importance={}))[c.None=0]="None",c[c.Min=1]="Min",c[c.Low=2]="Low",c[c.Default=3]="Default",c[c.High=4]="High",i.Visibility=void 0,(s=i.Visibility||(i.Visibility={}))[s.Secret=-1]="Secret",s[s.Private=0]="Private",s[s.Public=1]="Public",i.Schedule=class{static at(i,n=!1,t=!1){return{at:{date:i,repeating:n,allowWhileIdle:t},interval:void 0,every:void 0}}static interval(i,n=!1){return{at:void 0,interval:{interval:i,allowWhileIdle:n},every:void 0}}static every(i,n,t=!1){return{at:void 0,interval:void 0,every:{interval:i,count:n,allowWhileIdle:t}}}},i.active=async function(){return await d("plugin:notification|get_active")},i.cancel=async function(i){await d("plugin:notification|cancel",{notifications:i})},i.cancelAll=async function(){await d("plugin:notification|cancel")},i.channels=async function(){return await d("plugin:notification|listChannels")},i.createChannel=async function(i){await d("plugin:notification|create_channel",{...i})},i.isPermissionGranted=async function(){return"default"!==window.Notification.permission?await Promise.resolve("granted"===window.Notification.permission):await d("plugin:notification|is_permission_granted")},i.onAction=async function(i){return await f("notification","actionPerformed",i)},i.onNotificationReceived=async function(i){return await f("notification","notification",i)},i.pending=async function(){return await d("plugin:notification|get_pending")},i.registerActionTypes=async function(i){await d("plugin:notification|register_action_types",{types:i})},i.removeActive=async function(i){await d("plugin:notification|remove_active",{notifications:i})},i.removeAllActive=async function(){await d("plugin:notification|remove_active")},i.removeChannel=async function(i){await d("plugin:notification|delete_channel",{id:i})},i.requestPermission=async function(){return await window.Notification.requestPermission()},i.sendNotification=function(i){"string"==typeof i?new window.Notification(i):new window.Notification(i.title,i)},i}({});Object.defineProperty(window.__TAURI__,"notification",{value:__TAURI_PLUGIN_NOTIFICATION__})}

@ -11,7 +11,7 @@
import {
invoke,
PluginListener,
type PluginListener,
addPluginListener,
} from "@tauri-apps/api/core";
@ -103,7 +103,7 @@ interface Options {
/**
* Extra payload to store in the notification.
*/
extra?: { [key: string]: unknown };
extra?: Record<string, unknown>;
/**
* If true, the notification cannot be dismissed by the user on Android.
*
@ -130,7 +130,7 @@ interface Options {
number?: number;
}
type ScheduleInterval = {
interface ScheduleInterval {
year?: number;
month?: number;
day?: number;
@ -147,7 +147,7 @@ type ScheduleInterval = {
hour?: number;
minute?: number;
second?: number;
};
}
enum ScheduleEvery {
Year = "year",
@ -171,12 +171,14 @@ class Schedule {
allowWhileIdle: boolean;
}
| undefined;
interval:
| {
interval: ScheduleInterval;
allowWhileIdle: boolean;
}
| undefined;
every:
| {
interval: ScheduleEvery;
@ -317,9 +319,9 @@ type Permission = "granted" | "denied" | "default";
*/
async function isPermissionGranted(): Promise<boolean> {
if (window.Notification.permission !== "default") {
return Promise.resolve(window.Notification.permission === "granted");
return await Promise.resolve(window.Notification.permission === "granted");
}
return invoke("plugin:notification|is_permission_granted");
return await invoke("plugin:notification|is_permission_granted");
}
/**
@ -339,7 +341,7 @@ async function isPermissionGranted(): Promise<boolean> {
* @since 2.0.0
*/
async function requestPermission(): Promise<Permission> {
return window.Notification.requestPermission();
return await window.Notification.requestPermission();
}
/**
@ -390,7 +392,7 @@ function sendNotification(options: Options | string): void {
* @since 2.0.0
*/
async function registerActionTypes(types: ActionType[]): Promise<void> {
return invoke("plugin:notification|register_action_types", { types });
await invoke("plugin:notification|register_action_types", { types });
}
/**
@ -407,7 +409,7 @@ async function registerActionTypes(types: ActionType[]): Promise<void> {
* @since 2.0.0
*/
async function pending(): Promise<PendingNotification[]> {
return invoke("plugin:notification|get_pending");
return await invoke("plugin:notification|get_pending");
}
/**
@ -424,7 +426,7 @@ async function pending(): Promise<PendingNotification[]> {
* @since 2.0.0
*/
async function cancel(notifications: number[]): Promise<void> {
return invoke("plugin:notification|cancel", { notifications });
await invoke("plugin:notification|cancel", { notifications });
}
/**
@ -441,7 +443,7 @@ async function cancel(notifications: number[]): Promise<void> {
* @since 2.0.0
*/
async function cancelAll(): Promise<void> {
return invoke("plugin:notification|cancel");
await invoke("plugin:notification|cancel");
}
/**
@ -458,7 +460,7 @@ async function cancelAll(): Promise<void> {
* @since 2.0.0
*/
async function active(): Promise<ActiveNotification[]> {
return invoke("plugin:notification|get_active");
return await invoke("plugin:notification|get_active");
}
/**
@ -475,9 +477,9 @@ async function active(): Promise<ActiveNotification[]> {
* @since 2.0.0
*/
async function removeActive(
notifications: { id: number; tag?: string }[],
notifications: Array<{ id: number; tag?: string }>,
): Promise<void> {
return invoke("plugin:notification|remove_active", { notifications });
await invoke("plugin:notification|remove_active", { notifications });
}
/**
@ -494,7 +496,7 @@ async function removeActive(
* @since 2.0.0
*/
async function removeAllActive(): Promise<void> {
return invoke("plugin:notification|remove_active");
await invoke("plugin:notification|remove_active");
}
/**
@ -518,7 +520,7 @@ async function removeAllActive(): Promise<void> {
* @since 2.0.0
*/
async function createChannel(channel: Channel): Promise<void> {
return invoke("plugin:notification|create_channel", { ...channel });
await invoke("plugin:notification|create_channel", { ...channel });
}
/**
@ -535,7 +537,7 @@ async function createChannel(channel: Channel): Promise<void> {
* @since 2.0.0
*/
async function removeChannel(id: string): Promise<void> {
return invoke("plugin:notification|delete_channel", { id });
await invoke("plugin:notification|delete_channel", { id });
}
/**
@ -552,19 +554,19 @@ async function removeChannel(id: string): Promise<void> {
* @since 2.0.0
*/
async function channels(): Promise<Channel[]> {
return invoke("plugin:notification|listChannels");
return await invoke("plugin:notification|listChannels");
}
async function onNotificationReceived(
cb: (notification: Options) => void,
): Promise<PluginListener> {
return addPluginListener("notification", "notification", cb);
return await addPluginListener("notification", "notification", cb);
}
async function onAction(
cb: (notification: Options) => void,
): Promise<PluginListener> {
return addPluginListener("notification", "actionPerformed", cb);
return await addPluginListener("notification", "actionPerformed", cb);
}
export type {

@ -9,22 +9,28 @@ import type { Options } from "./index";
let permissionSettable = false;
let permissionValue = "default";
function isPermissionGranted() {
async function isPermissionGranted(): Promise<boolean> {
if (window.Notification.permission !== "default") {
return Promise.resolve(window.Notification.permission === "granted");
return await Promise.resolve(
window.Notification.permission === "granted",
);
}
return invoke("plugin:notification|is_permission_granted");
return await invoke("plugin:notification|is_permission_granted");
}
function setNotificationPermission(value: "granted" | "denied" | "default") {
function setNotificationPermission(
value: "granted" | "denied" | "default",
): void {
permissionSettable = true;
// @ts-expect-error we can actually set this value on the webview
window.Notification.permission = value;
permissionSettable = false;
}
function requestPermission() {
return invoke<"prompt" | "default" | "granted" | "denied">(
async function requestPermission(): Promise<
"default" | "denied" | "granted" | "prompt"
> {
return await invoke<"prompt" | "default" | "granted" | "denied">(
"plugin:notification|request_permission",
).then((permission) => {
setNotificationPermission(
@ -34,12 +40,12 @@ import type { Options } from "./index";
});
}
function sendNotification(options: string | Options) {
async function sendNotification(options: string | Options): Promise<void> {
if (typeof options === "object") {
Object.freeze(options);
}
return invoke("plugin:notification|notify", {
await invoke("plugin:notification|notify", {
options:
typeof options === "string"
? {
@ -51,8 +57,10 @@ import type { Options } from "./index";
// @ts-expect-error unfortunately we can't implement the whole type, so we overwrite it with our own version
window.Notification = function (title, options) {
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
const opts = options || {};
sendNotification(
void sendNotification(
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
Object.assign(opts, {
title,
}),
@ -73,7 +81,7 @@ import type { Options } from "./index";
},
});
isPermissionGranted().then(function (response) {
void isPermissionGranted().then(function (response) {
if (response === null) {
setNotificationPermission("default");
} else {

@ -1 +1 @@
!function(){"use strict";async function i(i,n={},t){return window.__TAURI_INTERNALS__.invoke(i,n,t)}"function"==typeof SuppressedError&&SuppressedError,function(){let n=!1,t="default";function o(i){n=!0,window.Notification.permission=i,n=!1}window.Notification=function(n,t){const o=t||{};!function(n){"object"==typeof n&&Object.freeze(n),i("plugin:notification|notify",{options:"string"==typeof n?{title:n}:n})}(Object.assign(o,{title:n}))},window.Notification.requestPermission=function(){return i("plugin:notification|request_permission").then((i=>(o("prompt"===i?"default":i),i)))},Object.defineProperty(window.Notification,"permission",{enumerable:!0,get:()=>t,set:i=>{if(!n)throw new Error("Readonly property");t=i}}),("default"!==window.Notification.permission?Promise.resolve("granted"===window.Notification.permission):i("plugin:notification|is_permission_granted")).then((function(i){o(null===i?"default":i?"granted":"denied")}))}()}();
!function(){"use strict";async function i(i,n={},t){return window.__TAURI_INTERNALS__.invoke(i,n,t)}"function"==typeof SuppressedError&&SuppressedError,function(){let n=!1,t="default";function o(i){n=!0,window.Notification.permission=i,n=!1}window.Notification=function(n,t){const o=t||{};!async function(n){"object"==typeof n&&Object.freeze(n),await i("plugin:notification|notify",{options:"string"==typeof n?{title:n}:n})}(Object.assign(o,{title:n}))},window.Notification.requestPermission=async function(){return await i("plugin:notification|request_permission").then((i=>(o("prompt"===i?"default":i),i)))},Object.defineProperty(window.Notification,"permission",{enumerable:!0,get:()=>t,set:i=>{if(!n)throw new Error("Readonly property");t=i}}),async function(){return"default"!==window.Notification.permission?await Promise.resolve("granted"===window.Notification.permission):await i("plugin:notification|is_permission_granted")}().then((function(i){o(null===i?"default":i?"granted":"denied")}))}()}();

@ -1 +1 @@
if("__TAURI__"in window){var __TAURI_PLUGIN_OS__=function(n){"use strict";async function o(n,o={},e){return window.__TAURI_INTERNALS__.invoke(n,o,e)}return"function"==typeof SuppressedError&&SuppressedError,n.arch=async function(){return o("plugin:os|arch")},n.eol=function(){return window.__TAURI_OS_PLUGIN_INTERNALS__.eol},n.exeExtension=async function(){return o("plugin:os|exe_extension")},n.family=async function(){return o("plugin:os|family")},n.hostname=async function(){return o("plugin:os|hostname")},n.locale=async function(){return o("plugin:os|locale")},n.platform=async function(){return o("plugin:os|platform")},n.type=async function(){return o("plugin:os|os_type")},n.version=async function(){return o("plugin:os|version")},n}({});Object.defineProperty(window.__TAURI__,"os",{value:__TAURI_PLUGIN_OS__})}
if("__TAURI__"in window){var __TAURI_PLUGIN_OS__=function(n){"use strict";async function t(n,t={},i){return window.__TAURI_INTERNALS__.invoke(n,t,i)}return"function"==typeof SuppressedError&&SuppressedError,n.arch=async function(){return await t("plugin:os|arch")},n.eol=function(){return window.__TAURI_OS_PLUGIN_INTERNALS__.eol},n.exeExtension=async function(){return await t("plugin:os|exe_extension")},n.family=async function(){return await t("plugin:os|family")},n.hostname=async function(){return await t("plugin:os|hostname")},n.locale=async function(){return await t("plugin:os|locale")},n.platform=async function(){return await t("plugin:os|platform")},n.type=async function(){return await t("plugin:os|os_type")},n.version=async function(){return await t("plugin:os|version")},n}({});Object.defineProperty(window.__TAURI__,"os",{value:__TAURI_PLUGIN_OS__})}

@ -53,7 +53,7 @@ type Arch =
*
* @since 2.0.0
* */
function eol() {
function eol(): string {
return window.__TAURI_OS_PLUGIN_INTERNALS__.eol;
}
@ -71,7 +71,7 @@ function eol() {
*
*/
async function platform(): Promise<Platform> {
return invoke("plugin:os|platform");
return await invoke("plugin:os|platform");
}
/**
@ -85,7 +85,7 @@ async function platform(): Promise<Platform> {
* @since 2.0.0
*/
async function version(): Promise<string> {
return invoke("plugin:os|version");
return await invoke("plugin:os|version");
}
type Family = "unix" | "windows";
@ -101,7 +101,7 @@ type Family = "unix" | "windows";
* @since 2.0.0
*/
async function family(): Promise<Family> {
return invoke("plugin:os|family");
return await invoke("plugin:os|family");
}
/**
@ -115,7 +115,7 @@ async function family(): Promise<Family> {
* @since 2.0.0
*/
async function type(): Promise<OsType> {
return invoke("plugin:os|os_type");
return await invoke("plugin:os|os_type");
}
/**
@ -130,7 +130,7 @@ async function type(): Promise<OsType> {
* @since 2.0.0
*/
async function arch(): Promise<Arch> {
return invoke("plugin:os|arch");
return await invoke("plugin:os|arch");
}
/**
@ -147,7 +147,7 @@ async function arch(): Promise<Arch> {
* @since 2.0.0
*/
async function locale(): Promise<string | null> {
return invoke("plugin:os|locale");
return await invoke("plugin:os|locale");
}
/**
@ -161,7 +161,7 @@ async function locale(): Promise<string | null> {
* @since 2.0.0
*/
async function exeExtension(): Promise<string | null> {
return invoke("plugin:os|exe_extension");
return await invoke("plugin:os|exe_extension");
}
/**
@ -173,7 +173,7 @@ async function exeExtension(): Promise<string | null> {
* ```
*/
async function hostname(): Promise<string | null> {
return invoke("plugin:os|hostname");
return await invoke("plugin:os|hostname");
}
export {

@ -1 +1 @@
if("__TAURI__"in window){var __TAURI_PLUGIN_PROCESS__=function(n){"use strict";async function r(n,r={},_){return window.__TAURI_INTERNALS__.invoke(n,r,_)}return"function"==typeof SuppressedError&&SuppressedError,n.exit=async function(n=0){return r("plugin:process|exit",{code:n})},n.relaunch=async function(){return r("plugin:process|restart")},n}({});Object.defineProperty(window.__TAURI__,"process",{value:__TAURI_PLUGIN_PROCESS__})}
if("__TAURI__"in window){var __TAURI_PLUGIN_PROCESS__=function(_){"use strict";async function n(_,n={},e){return window.__TAURI_INTERNALS__.invoke(_,n,e)}return"function"==typeof SuppressedError&&SuppressedError,_.exit=async function(_=0){await n("plugin:process|exit",{code:_})},_.relaunch=async function(){await n("plugin:process|restart")},_}({});Object.defineProperty(window.__TAURI__,"process",{value:__TAURI_PLUGIN_PROCESS__})}

@ -23,7 +23,7 @@ import { invoke } from "@tauri-apps/api/core";
* @since 2.0.0
*/
async function exit(code = 0): Promise<void> {
return invoke("plugin:process|exit", { code });
await invoke("plugin:process|exit", { code });
}
/**
@ -39,7 +39,7 @@ async function exit(code = 0): Promise<void> {
* @since 2.0.0
*/
async function relaunch(): Promise<void> {
return invoke("plugin:process|restart");
await invoke("plugin:process|restart");
}
export { exit, relaunch };

@ -1 +1 @@
if("__TAURI__"in window){var __TAURI_PLUGIN_SHELL__=function(e){"use strict";function t(e,t,s,r){if("a"===s&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?r:"a"===s?r.call(e):r?r.value:t.get(e)}function s(e,t,s,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,s):n?n.value=s:t.set(e,s),s}var r,n,i;"function"==typeof SuppressedError&&SuppressedError;class o{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,r.set(this,(()=>{})),n.set(this,0),i.set(this,{}),this.id=function(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}((({message:e,id:o})=>{if(o===t(this,n,"f")){s(this,n,o+1,"f"),t(this,r,"f").call(this,e);const a=Object.keys(t(this,i,"f"));if(a.length>0){let e=o+1;for(const s of a.sort()){if(parseInt(s)!==e)break;{const n=t(this,i,"f")[s];delete t(this,i,"f")[s],t(this,r,"f").call(this,n),e+=1}}}}else t(this,i,"f")[o.toString()]=e}))}set onmessage(e){s(this,r,e,"f")}get onmessage(){return t(this,r,"f")}toJSON(){return`__CHANNEL__:${this.id}`}}async function a(e,t={},s){return window.__TAURI_INTERNALS__.invoke(e,t,s)}r=new WeakMap,n=new WeakMap,i=new WeakMap;class h{constructor(){this.eventListeners=Object.create(null)}addListener(e,t){return this.on(e,t)}removeListener(e,t){return this.off(e,t)}on(e,t){return e in this.eventListeners?this.eventListeners[e].push(t):this.eventListeners[e]=[t],this}once(e,t){const s=r=>{this.removeListener(e,s),t(r)};return this.addListener(e,s)}off(e,t){return e in this.eventListeners&&(this.eventListeners[e]=this.eventListeners[e].filter((e=>e!==t))),this}removeAllListeners(e){return e?delete this.eventListeners[e]:this.eventListeners=Object.create(null),this}emit(e,t){if(e in this.eventListeners){const s=this.eventListeners[e];for(const e of s)e(t);return!0}return!1}listenerCount(e){return e in this.eventListeners?this.eventListeners[e].length:0}prependListener(e,t){return e in this.eventListeners?this.eventListeners[e].unshift(t):this.eventListeners[e]=[t],this}prependOnceListener(e,t){const s=r=>{this.removeListener(e,s),t(r)};return this.prependListener(e,s)}}class c{constructor(e){this.pid=e}async write(e){return a("plugin:shell|stdin_write",{pid:this.pid,buffer:"string"==typeof e?e:Array.from(e)})}async kill(){return a("plugin:shell|kill",{cmd:"killChild",pid:this.pid})}}class u extends h{constructor(e,t=[],s){super(),this.stdout=new h,this.stderr=new h,this.program=e,this.args="string"==typeof t?[t]:t,this.options=s??{}}static create(e,t=[],s){return new u(e,t,s)}static sidecar(e,t=[],s){const r=new u(e,t,s);return r.options.sidecar=!0,r}async spawn(){return async function(e,t,s=[],r){"object"==typeof s&&Object.freeze(s);const n=new o;return n.onmessage=e,a("plugin:shell|execute",{program:t,args:s,options:r,onEvent:n})}((e=>{switch(e.event){case"Error":this.emit("error",e.payload);break;case"Terminated":this.emit("close",e.payload);break;case"Stdout":this.stdout.emit("data",e.payload);break;case"Stderr":this.stderr.emit("data",e.payload)}}),this.program,this.args,this.options).then((e=>new c(e)))}async execute(){return new Promise(((e,t)=>{this.on("error",t);const s=[],r=[];this.stdout.on("data",(e=>{s.push(e)})),this.stderr.on("data",(e=>{r.push(e)})),this.on("close",(t=>{e({code:t.code,signal:t.signal,stdout:this.collectOutput(s),stderr:this.collectOutput(r)})})),this.spawn().catch(t)}))}collectOutput(e){return"raw"===this.options.encoding?e.reduce(((e,t)=>new Uint8Array([...e,...t,10])),new Uint8Array):e.join("\n")}}return e.Child=c,e.Command=u,e.EventEmitter=h,e.open=async function(e,t){return a("plugin:shell|open",{path:e,with:t})},e}({});Object.defineProperty(window.__TAURI__,"shell",{value:__TAURI_PLUGIN_SHELL__})}
if("__TAURI__"in window){var __TAURI_PLUGIN_SHELL__=function(t){"use strict";function e(t,e,s,n){if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(t)}function s(t,e,s,n,i){if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,s),s}var n,i,r;"function"==typeof SuppressedError&&SuppressedError;class o{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,n.set(this,(()=>{})),i.set(this,0),r.set(this,{}),this.id=function(t,e=!1){return window.__TAURI_INTERNALS__.transformCallback(t,e)}((({message:t,id:o})=>{if(o===e(this,i)){s(this,i,o+1),e(this,n).call(this,t);const a=Object.keys(e(this,r));if(a.length>0){let t=o+1;for(const s of a.sort()){if(parseInt(s)!==t)break;{const i=e(this,r)[s];delete e(this,r)[s],e(this,n).call(this,i),t+=1}}}}else e(this,r)[o.toString()]=t}))}set onmessage(t){s(this,n,t)}get onmessage(){return e(this,n)}toJSON(){return`__CHANNEL__:${this.id}`}}async function a(t,e={},s){return window.__TAURI_INTERNALS__.invoke(t,e,s)}n=new WeakMap,i=new WeakMap,r=new WeakMap;class h{constructor(){this.eventListeners=Object.create(null)}addListener(t,e){return this.on(t,e)}removeListener(t,e){return this.off(t,e)}on(t,e){return t in this.eventListeners?this.eventListeners[t].push(e):this.eventListeners[t]=[e],this}once(t,e){const s=n=>{this.removeListener(t,s),e(n)};return this.addListener(t,s)}off(t,e){return t in this.eventListeners&&(this.eventListeners[t]=this.eventListeners[t].filter((t=>t!==e))),this}removeAllListeners(t){return t?delete this.eventListeners[t]:this.eventListeners=Object.create(null),this}emit(t,e){if(t in this.eventListeners){const s=this.eventListeners[t];for(const t of s)t(e);return!0}return!1}listenerCount(t){return t in this.eventListeners?this.eventListeners[t].length:0}prependListener(t,e){return t in this.eventListeners?this.eventListeners[t].unshift(e):this.eventListeners[t]=[e],this}prependOnceListener(t,e){const s=n=>{this.removeListener(t,s),e(n)};return this.prependListener(t,s)}}class c{constructor(t){this.pid=t}async write(t){await a("plugin:shell|stdin_write",{pid:this.pid,buffer:"string"==typeof t?t:Array.from(t)})}async kill(){await a("plugin:shell|kill",{cmd:"killChild",pid:this.pid})}}class u extends h{constructor(t,e=[],s){super(),this.stdout=new h,this.stderr=new h,this.program=t,this.args="string"==typeof e?[e]:e,this.options=s??{}}static create(t,e=[],s){return new u(t,e,s)}static sidecar(t,e=[],s){const n=new u(t,e,s);return n.options.sidecar=!0,n}async spawn(){return await async function(t,e,s=[],n){"object"==typeof s&&Object.freeze(s);const i=new o;return i.onmessage=t,await a("plugin:shell|execute",{program:e,args:s,options:n,onEvent:i})}((t=>{switch(t.event){case"Error":this.emit("error",t.payload);break;case"Terminated":this.emit("close",t.payload);break;case"Stdout":this.stdout.emit("data",t.payload);break;case"Stderr":this.stderr.emit("data",t.payload)}}),this.program,this.args,this.options).then((t=>new c(t)))}async execute(){return await new Promise(((t,e)=>{this.on("error",e);const s=[],n=[];this.stdout.on("data",(t=>{s.push(t)})),this.stderr.on("data",(t=>{n.push(t)})),this.on("close",(e=>{t({code:e.code,signal:e.signal,stdout:this.collectOutput(s),stderr:this.collectOutput(n)})})),this.spawn().catch(e)}))}collectOutput(t){return"raw"===this.options.encoding?t.reduce(((t,e)=>new Uint8Array([...t,...e,10])),new Uint8Array):t.join("\n")}}return t.Child=c,t.Command=u,t.EventEmitter=h,t.open=async function(t,e){await a("plugin:shell|open",{path:t,with:e})},t}({});Object.defineProperty(window.__TAURI__,"shell",{value:__TAURI_PLUGIN_SHELL__})}

@ -124,7 +124,7 @@ async function execute<O extends IOPayload>(
const onEvent = new Channel<CommandEvent<O>>();
onEvent.onmessage = onEventHandler;
return invoke<number>("plugin:shell|execute", {
return await invoke<number>("plugin:shell|execute", {
program,
args,
options,
@ -237,6 +237,7 @@ class EventEmitter<E extends Record<string, any>> {
* @since 2.0.0
*/
removeAllListeners<N extends keyof E>(event?: N): this {
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
if (event) {
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete,security/detect-object-injection
delete this.eventListeners[event];
@ -354,7 +355,7 @@ class Child {
* @since 2.0.0
*/
async write(data: IOPayload): Promise<void> {
return invoke("plugin:shell|stdin_write", {
await invoke("plugin:shell|stdin_write", {
pid: this.pid,
// correctly serialize Uint8Arrays
buffer: typeof data === "string" ? data : Array.from(data),
@ -369,7 +370,7 @@ class Child {
* @since 2.0.0
*/
async kill(): Promise<void> {
return invoke("plugin:shell|kill", {
await invoke("plugin:shell|kill", {
cmd: "killChild",
pid: this.pid,
});
@ -512,7 +513,7 @@ class Command<O extends IOPayload> extends EventEmitter<CommandEvents> {
* @since 2.0.0
*/
async spawn(): Promise<Child> {
return execute<O>(
return await execute<O>(
(event) => {
switch (event.event) {
case "Error":
@ -552,7 +553,7 @@ class Command<O extends IOPayload> extends EventEmitter<CommandEvents> {
* @since 2.0.0
*/
async execute(): Promise<ChildProcess<O>> {
return new Promise((resolve, reject) => {
return await new Promise((resolve, reject) => {
this.on("error", reject);
const stdout: O[] = [];
@ -644,7 +645,7 @@ type CommandEvent<O extends IOPayload> =
* @since 2.0.0
*/
async function open(path: string, openWith?: string): Promise<void> {
return invoke("plugin:shell|open", {
await invoke("plugin:shell|open", {
path,
with: openWith,
});

@ -5,27 +5,27 @@
import { invoke } from "@tauri-apps/api/core";
// open <a href="..."> links with the API
function openLinks() {
function openLinks(): void {
document.querySelector("body")?.addEventListener("click", function (e) {
let target = e.target as HTMLElement;
let target: HTMLElement | null = e.target as HTMLElement;
while (target != null) {
if (target.matches("a")) {
const t = target as HTMLAnchorElement;
if (
t.href &&
t.href !== "" &&
["http://", "https://", "mailto:", "tel:"].some((v) =>
t.href.startsWith(v),
) &&
t.target === "_blank"
) {
invoke("plugin:shell|open", {
void invoke("plugin:shell|open", {
path: t.href,
});
e.preventDefault();
}
break;
}
target = target.parentElement as HTMLElement;
target = target.parentElement;
}
});
}

@ -1 +1 @@
!function(){"use strict";async function e(e,t={},n){return window.__TAURI_INTERNALS__.invoke(e,t,n)}function t(){document.querySelector("body")?.addEventListener("click",(function(t){let n=t.target;for(;null!=n;){if(n.matches("a")){const r=n;r.href&&["http://","https://","mailto:","tel:"].some((e=>r.href.startsWith(e)))&&"_blank"===r.target&&(e("plugin:shell|open",{path:r.href}),t.preventDefault());break}n=n.parentElement}}))}"function"==typeof SuppressedError&&SuppressedError,"complete"===document.readyState||"interactive"===document.readyState?t():window.addEventListener("DOMContentLoaded",t,!0)}();
!function(){"use strict";async function e(e,t={},n){return window.__TAURI_INTERNALS__.invoke(e,t,n)}function t(){document.querySelector("body")?.addEventListener("click",(function(t){let n=t.target;for(;null!=n;){if(n.matches("a")){const r=n;""!==r.href&&["http://","https://","mailto:","tel:"].some((e=>r.href.startsWith(e)))&&"_blank"===r.target&&(e("plugin:shell|open",{path:r.href}),t.preventDefault());break}n=n.parentElement}}))}"function"==typeof SuppressedError&&SuppressedError,"complete"===document.readyState||"interactive"===document.readyState?t():window.addEventListener("DOMContentLoaded",t,!0)}();

@ -119,6 +119,7 @@ export default class Database {
rowsAffected,
};
}
/**
* **select**
*

@ -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="string"==typeof r?.target?{kind:"AnyLabel",label:r.target}:r?.target??{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.WEBVIEW_CREATED="tauri://webview-created",t.FILE_DROP="tauri://file-drop",t.FILE_DROP_HOVER="tauri://file-drop-hover",t.FILE_DROP_CANCELLED="tauri://file-drop-cancelled"}(n||(n={}));return t.Store=class{constructor(t){this.path=t}async set(t,a){return 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(){return await e("plugin:store|clear",{path:this.path})}async reset(){return 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(){return await e("plugin:store|load",{path:this.path})}async save(){return 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){return e("plugin:event|listen",{event:t,target:{kind:"Any"},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__})}

@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
import { listen, UnlistenFn } from "@tauri-apps/api/event";
import { listen, type UnlistenFn } from "@tauri-apps/api/event";
import { invoke } from "@tauri-apps/api/core";
@ -29,7 +29,7 @@ export class Store {
* @returns
*/
async set(key: string, value: unknown): Promise<void> {
return await invoke("plugin:store|set", {
await invoke("plugin:store|set", {
path: this.path,
key,
value,
@ -82,7 +82,7 @@ export class Store {
* @returns
*/
async clear(): Promise<void> {
return await invoke("plugin:store|clear", {
await invoke("plugin:store|clear", {
path: this.path,
});
}
@ -94,7 +94,7 @@ export class Store {
* @returns
*/
async reset(): Promise<void> {
return await invoke("plugin:store|reset", {
await invoke("plugin:store|reset", {
path: this.path,
});
}
@ -152,7 +152,7 @@ export class Store {
* @returns
*/
async load(): Promise<void> {
return await invoke("plugin:store|load", {
await invoke("plugin:store|load", {
path: this.path,
});
}
@ -165,7 +165,7 @@ export class Store {
* @returns
*/
async save(): Promise<void> {
return await invoke("plugin:store|save", {
await invoke("plugin:store|save", {
path: this.path,
});
}

@ -1 +1 @@
if("__TAURI__"in window){var __TAURI_PLUGIN_STRONGHOLD__=function(t){"use strict";async function e(t,e={},r){return window.__TAURI_INTERNALS__.invoke(t,e,r)}function r(t){return"string"==typeof t?t:Array.from(t instanceof ArrayBuffer?new Uint8Array(t):t)}"function"==typeof SuppressedError&&SuppressedError;class n{constructor(t,e){this.type=t,this.payload=e}static generic(t,e){return new n("Generic",{vault:r(t),record:r(e)})}static counter(t,e){return new n("Counter",{vault:r(t),counter:e})}}class a{constructor(t){this.procedureArgs=t}async generateSLIP10Seed(t,r){return await e("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"SLIP10Generate",payload:{output:t,sizeBytes:r}}}).then((t=>Uint8Array.from(t)))}async deriveSLIP10(t,r,n,a){return await e("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"SLIP10Derive",payload:{chain:t,input:{type:r,payload:n},output:a}}}).then((t=>Uint8Array.from(t)))}async recoverBIP39(t,r,n){return await e("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"BIP39Recover",payload:{mnemonic:t,passphrase:n,output:r}}}).then((t=>Uint8Array.from(t)))}async generateBIP39(t,r){return await e("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"BIP39Generate",payload:{output:t,passphrase:r}}}).then((t=>Uint8Array.from(t)))}async getEd25519PublicKey(t){return await e("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"PublicKey",payload:{type:"Ed25519",privateKey:t}}}).then((t=>Uint8Array.from(t)))}async signEd25519(t,r){return await e("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"Ed25519Sign",payload:{privateKey:t,msg:r}}}).then((t=>Uint8Array.from(t)))}}class s{constructor(t,e){this.path=t,this.name=r(e)}getVault(t){return new i(this.path,this.name,r(t))}getStore(){return new o(this.path,this.name)}}class o{constructor(t,e){this.path=t,this.client=e}async get(t){return await e("plugin:stronghold|get_store_record",{snapshotPath:this.path,client:this.client,key:r(t)}).then((t=>null!=t?Uint8Array.from(t):null))}async insert(t,n,a){return await e("plugin:stronghold|save_store_record",{snapshotPath:this.path,client:this.client,key:r(t),value:n,lifetime:a})}async remove(t){return await e("plugin:stronghold|remove_store_record",{snapshotPath:this.path,client:this.client,key:r(t)}).then((t=>null!=t?Uint8Array.from(t):null))}}class i extends a{constructor(t,e,n){super({snapshotPath:t,client:e,vault:n}),this.path=t,this.client=r(e),this.name=r(n)}async insert(t,n){return await e("plugin:stronghold|save_secret",{snapshotPath:this.path,client:this.client,vault:this.name,recordPath:r(t),secret:n})}async remove(t){return await e("plugin:stronghold|remove_secret",{snapshotPath:this.path,client:this.client,vault:this.name,recordPath:t.payload.record})}}class h{constructor(t){this.path=t}static async load(t,r){return await e("plugin:stronghold|initialize",{snapshotPath:t,password:r}).then((()=>new h(t)))}async unload(){return await e("plugin:stronghold|destroy",{snapshotPath:this.path})}async loadClient(t){return await e("plugin:stronghold|load_client",{snapshotPath:this.path,client:r(t)}).then((()=>new s(this.path,t)))}async createClient(t){return await e("plugin:stronghold|create_client",{snapshotPath:this.path,client:r(t)}).then((()=>new s(this.path,t)))}async save(){return await e("plugin:stronghold|save",{snapshotPath:this.path})}}return t.Client=s,t.Location=n,t.Store=o,t.Stronghold=h,t.Vault=i,t}({});Object.defineProperty(window.__TAURI__,"stronghold",{value:__TAURI_PLUGIN_STRONGHOLD__})}
if("__TAURI__"in window){var __TAURI_PLUGIN_STRONGHOLD__=function(t){"use strict";async function e(t,e={},r){return window.__TAURI_INTERNALS__.invoke(t,e,r)}function r(t){return"string"==typeof t?t:Array.from(t instanceof ArrayBuffer?new Uint8Array(t):t)}"function"==typeof SuppressedError&&SuppressedError;class n{constructor(t,e){this.type=t,this.payload=e}static generic(t,e){return new n("Generic",{vault:r(t),record:r(e)})}static counter(t,e){return new n("Counter",{vault:r(t),counter:e})}}class a{constructor(t){this.procedureArgs=t}async generateSLIP10Seed(t,r){return await e("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"SLIP10Generate",payload:{output:t,sizeBytes:r}}}).then((t=>Uint8Array.from(t)))}async deriveSLIP10(t,r,n,a){return await e("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"SLIP10Derive",payload:{chain:t,input:{type:r,payload:n},output:a}}}).then((t=>Uint8Array.from(t)))}async recoverBIP39(t,r,n){return await e("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"BIP39Recover",payload:{mnemonic:t,passphrase:n,output:r}}}).then((t=>Uint8Array.from(t)))}async generateBIP39(t,r){return await e("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"BIP39Generate",payload:{output:t,passphrase:r}}}).then((t=>Uint8Array.from(t)))}async getEd25519PublicKey(t){return await e("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"PublicKey",payload:{type:"Ed25519",privateKey:t}}}).then((t=>Uint8Array.from(t)))}async signEd25519(t,r){return await e("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"Ed25519Sign",payload:{privateKey:t,msg:r}}}).then((t=>Uint8Array.from(t)))}}class s{constructor(t,e){this.path=t,this.name=r(e)}getVault(t){return new i(this.path,this.name,r(t))}getStore(){return new o(this.path,this.name)}}class o{constructor(t,e){this.path=t,this.client=e}async get(t){return await e("plugin:stronghold|get_store_record",{snapshotPath:this.path,client:this.client,key:r(t)}).then((t=>null!=t?Uint8Array.from(t):null))}async insert(t,n,a){await e("plugin:stronghold|save_store_record",{snapshotPath:this.path,client:this.client,key:r(t),value:n,lifetime:a})}async remove(t){return await e("plugin:stronghold|remove_store_record",{snapshotPath:this.path,client:this.client,key:r(t)}).then((t=>null!=t?Uint8Array.from(t):null))}}class i extends a{constructor(t,e,n){super({snapshotPath:t,client:e,vault:n}),this.path=t,this.client=r(e),this.name=r(n)}async insert(t,n){await e("plugin:stronghold|save_secret",{snapshotPath:this.path,client:this.client,vault:this.name,recordPath:r(t),secret:n})}async remove(t){await e("plugin:stronghold|remove_secret",{snapshotPath:this.path,client:this.client,vault:this.name,recordPath:t.payload.record})}}class h{constructor(t){this.path=t}static async load(t,r){return await e("plugin:stronghold|initialize",{snapshotPath:t,password:r}).then((()=>new h(t)))}async unload(){await e("plugin:stronghold|destroy",{snapshotPath:this.path})}async loadClient(t){return await e("plugin:stronghold|load_client",{snapshotPath:this.path,client:r(t)}).then((()=>new s(this.path,t)))}async createClient(t){return await e("plugin:stronghold|create_client",{snapshotPath:this.path,client:r(t)}).then((()=>new s(this.path,t)))}async save(){await e("plugin:stronghold|save",{snapshotPath:this.path})}}return t.Client=s,t.Location=n,t.Store=o,t.Stronghold=h,t.Vault=i,t}({});Object.defineProperty(window.__TAURI__,"stronghold",{value:__TAURI_PLUGIN_STRONGHOLD__})}

@ -85,7 +85,7 @@ export interface NetworkConfig {
export interface Duration {
/** The number of whole seconds contained by this Duration. */
secs: number;
/** The fractional part of this Duration, in nanoseconds. Must be greater or equal to 0 and smaller than 1e+9 (the max number of nanoseoncds in a second)*/
/** The fractional part of this Duration, in nanoseconds. Must be greater or equal to 0 and smaller than 1e+9 (the max number of nanoseoncds in a second) */
nanos: number;
}
@ -314,7 +314,7 @@ export class Store {
value: number[],
lifetime?: Duration,
): Promise<void> {
return await invoke("plugin:stronghold|save_store_record", {
await invoke("plugin:stronghold|save_store_record", {
snapshotPath: this.path,
client: this.client,
key: toBytesDto(key),
@ -366,7 +366,7 @@ export class Vault extends ProcedureExecutor {
* @returns
*/
async insert(recordPath: RecordPath, secret: number[]): Promise<void> {
return await invoke("plugin:stronghold|save_secret", {
await invoke("plugin:stronghold|save_secret", {
snapshotPath: this.path,
client: this.client,
vault: this.name,
@ -382,7 +382,7 @@ export class Vault extends ProcedureExecutor {
* @returns
*/
async remove(location: Location): Promise<void> {
return await invoke("plugin:stronghold|remove_secret", {
await invoke("plugin:stronghold|remove_secret", {
snapshotPath: this.path,
client: this.client,
vault: this.name,
@ -423,7 +423,7 @@ export class Stronghold {
* Remove this instance from the cache.
*/
async unload(): Promise<void> {
return await invoke("plugin:stronghold|destroy", {
await invoke("plugin:stronghold|destroy", {
snapshotPath: this.path,
});
}
@ -447,7 +447,7 @@ export class Stronghold {
* @returns
*/
async save(): Promise<void> {
return await invoke("plugin:stronghold|save", {
await invoke("plugin:stronghold|save", {
snapshotPath: this.path,
});
}

@ -1 +1 @@
if("__TAURI__"in window){var __TAURI_PLUGIN_UPDATER__=function(e){"use strict";function t(e,t,r,s){if("a"===r&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?s:"a"===r?s.call(e):s?s.value:t.get(e)}function r(e,t,r,s,n){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?n.call(e,r):n?n.value=r:t.set(e,r),r}var s,n,i,a;"function"==typeof SuppressedError&&SuppressedError;class o{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,s.set(this,(()=>{})),n.set(this,0),i.set(this,{}),this.id=function(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}((({message:e,id:a})=>{if(a===t(this,n,"f")){r(this,n,a+1,"f"),t(this,s,"f").call(this,e);const o=Object.keys(t(this,i,"f"));if(o.length>0){let e=a+1;for(const r of o.sort()){if(parseInt(r)!==e)break;{const n=t(this,i,"f")[r];delete t(this,i,"f")[r],t(this,s,"f").call(this,n),e+=1}}}}else t(this,i,"f")[a.toString()]=e}))}set onmessage(e){r(this,s,e,"f")}get onmessage(){return t(this,s,"f")}toJSON(){return`__CHANNEL__:${this.id}`}}async function c(e,t={},r){return window.__TAURI_INTERNALS__.invoke(e,t,r)}s=new WeakMap,n=new WeakMap,i=new WeakMap;class d{get rid(){return t(this,a,"f")}constructor(e){a.set(this,void 0),r(this,a,e,"f")}async close(){return c("plugin:resources|close",{rid:this.rid})}}a=new WeakMap;class h extends d{constructor(e){super(e.rid),this.available=e.available,this.currentVersion=e.currentVersion,this.version=e.version,this.date=e.date,this.body=e.body}async downloadAndInstall(e){const t=new o;return e&&(t.onmessage=e),c("plugin:updater|download_and_install",{onEvent:t,rid:this.rid})}}return e.Update=h,e.check=async function(e){return e?.headers&&(e.headers=Array.from(new Headers(e.headers).entries())),c("plugin:updater|check",{...e}).then((e=>e.available?new h(e):null))},e}({});Object.defineProperty(window.__TAURI__,"updater",{value:__TAURI_PLUGIN_UPDATER__})}
if("__TAURI__"in window){var __TAURI_PLUGIN_UPDATER__=function(e){"use strict";function t(e,t,s,n){if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t.get(e)}function s(e,t,s,n,r){if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,s),s}var n,r,i,a;"function"==typeof SuppressedError&&SuppressedError;class o{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,n.set(this,(()=>{})),r.set(this,0),i.set(this,{}),this.id=function(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}((({message:e,id:a})=>{if(a===t(this,r)){s(this,r,a+1),t(this,n).call(this,e);const o=Object.keys(t(this,i));if(o.length>0){let e=a+1;for(const s of o.sort()){if(parseInt(s)!==e)break;{const r=t(this,i)[s];delete t(this,i)[s],t(this,n).call(this,r),e+=1}}}}else t(this,i)[a.toString()]=e}))}set onmessage(e){s(this,n,e)}get onmessage(){return t(this,n)}toJSON(){return`__CHANNEL__:${this.id}`}}async function c(e,t={},s){return window.__TAURI_INTERNALS__.invoke(e,t,s)}n=new WeakMap,r=new WeakMap,i=new WeakMap;class d{get rid(){return t(this,a)}constructor(e){a.set(this,void 0),s(this,a,e)}async close(){return c("plugin:resources|close",{rid:this.rid})}}a=new WeakMap;class _ extends d{constructor(e){super(e.rid),this.available=e.available,this.currentVersion=e.currentVersion,this.version=e.version,this.date=e.date,this.body=e.body}async downloadAndInstall(e){const t=new o;null!=e&&(t.onmessage=e),await c("plugin:updater|download_and_install",{onEvent:t,rid:this.rid})}}return e.Update=_,e.check=async function(e){return null!=e?.headers&&(e.headers=Array.from(new Headers(e.headers).entries())),await c("plugin:updater|check",{...e}).then((e=>e.available?new _(e):null))},e}({});Object.defineProperty(window.__TAURI__,"updater",{value:__TAURI_PLUGIN_UPDATER__})}

@ -60,10 +60,10 @@ class Update extends Resource {
onEvent?: (progress: DownloadEvent) => void,
): Promise<void> {
const channel = new Channel<DownloadEvent>();
if (onEvent) {
if (onEvent != null) {
channel.onmessage = onEvent;
}
return invoke("plugin:updater|download_and_install", {
await invoke("plugin:updater|download_and_install", {
onEvent: channel,
rid: this.rid,
});
@ -72,11 +72,11 @@ class Update extends Resource {
/** Check for updates, resolves to `null` if no updates are available */
async function check(options?: CheckOptions): Promise<Update | null> {
if (options?.headers) {
if (options?.headers != null) {
options.headers = Array.from(new Headers(options.headers).entries());
}
return invoke<UpdateMetadata>("plugin:updater|check", {
return await invoke<UpdateMetadata>("plugin:updater|check", {
...options,
}).then((meta) => (meta.available ? new Update(meta) : null));
}

@ -1 +1 @@
if("__TAURI__"in window){var __TAURI_PLUGIN_UPLOAD__=function(e){"use strict";function t(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)}function n(e,t,n,r,o){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?o.call(e,n):o?o.value=n:t.set(e,n),n}var r,o,s;"function"==typeof SuppressedError&&SuppressedError;class a{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,r.set(this,(()=>{})),o.set(this,0),s.set(this,{}),this.id=function(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}((({message:e,id:a})=>{if(a===t(this,o,"f")){n(this,o,a+1,"f"),t(this,r,"f").call(this,e);const i=Object.keys(t(this,s,"f"));if(i.length>0){let e=a+1;for(const n of i.sort()){if(parseInt(n)!==e)break;{const o=t(this,s,"f")[n];delete t(this,s,"f")[n],t(this,r,"f").call(this,o),e+=1}}}}else t(this,s,"f")[a.toString()]=e}))}set onmessage(e){n(this,r,e,"f")}get onmessage(){return t(this,r,"f")}toJSON(){return`__CHANNEL__:${this.id}`}}async function i(e,t={},n){return window.__TAURI_INTERNALS__.invoke(e,t,n)}return r=new WeakMap,o=new WeakMap,s=new WeakMap,e.download=async function(e,t,n,r){const o=new Uint32Array(1);window.crypto.getRandomValues(o);const s=o[0],c=new a;null!=n&&(c.onmessage=n),await i("plugin:upload|download",{id:s,url:e,filePath:t,headers:r??{},onProgress:c})},e.upload=async function(e,t,n,r){const o=new Uint32Array(1);window.crypto.getRandomValues(o);const s=o[0],c=new a;return null!=n&&(c.onmessage=n),await i("plugin:upload|upload",{id:s,url:e,filePath:t,headers:r??{},onProgress:c})},e}({});Object.defineProperty(window.__TAURI__,"upload",{value:__TAURI_PLUGIN_UPLOAD__})}
if("__TAURI__"in window){var __TAURI_PLUGIN_UPLOAD__=function(t){"use strict";function e(t,e,n,o){if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(t)}function n(t,e,n,o,s){if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,n),n}var o,s,r;"function"==typeof SuppressedError&&SuppressedError;class i{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,o.set(this,(()=>{})),s.set(this,0),r.set(this,{}),this.id=function(t,e=!1){return window.__TAURI_INTERNALS__.transformCallback(t,e)}((({message:t,id:i})=>{if(i===e(this,s)){n(this,s,i+1),e(this,o).call(this,t);const a=Object.keys(e(this,r));if(a.length>0){let t=i+1;for(const n of a.sort()){if(parseInt(n)!==t)break;{const s=e(this,r)[n];delete e(this,r)[n],e(this,o).call(this,s),t+=1}}}}else e(this,r)[i.toString()]=t}))}set onmessage(t){n(this,o,t)}get onmessage(){return e(this,o)}toJSON(){return`__CHANNEL__:${this.id}`}}async function a(t,e={},n){return window.__TAURI_INTERNALS__.invoke(t,e,n)}return o=new WeakMap,s=new WeakMap,r=new WeakMap,t.download=async function(t,e,n,o){const s=new Uint32Array(1);window.crypto.getRandomValues(s);const r=s[0],_=new i;null!=n&&(_.onmessage=n),await a("plugin:upload|download",{id:r,url:t,filePath:e,headers:o??{},onProgress:_})},t.upload=async function(t,e,n,o){const s=new Uint32Array(1);window.crypto.getRandomValues(s);const r=s[0],_=new i;return null!=n&&(_.onmessage=n),await a("plugin:upload|upload",{id:r,url:t,filePath:e,headers:o??{},onProgress:_})},t}({});Object.defineProperty(window.__TAURI__,"upload",{value:__TAURI_PLUGIN_UPLOAD__})}

@ -1 +1 @@
if("__TAURI__"in window){var __TAURI_PLUGIN_WEBSOCKET__=function(){"use strict";function e(e,t,r,s){if("a"===r&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?s:"a"===r?s.call(e):s?s.value:t.get(e)}function t(e,t,r,s,n){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?n.call(e,r):n?n.value=r:t.set(e,r),r}var r,s,n;"function"==typeof SuppressedError&&SuppressedError;class i{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,r.set(this,(()=>{})),s.set(this,0),n.set(this,{}),this.id=function(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}((({message:i,id:a})=>{if(a===e(this,s,"f")){t(this,s,a+1,"f"),e(this,r,"f").call(this,i);const o=Object.keys(e(this,n,"f"));if(o.length>0){let t=a+1;for(const s of o.sort()){if(parseInt(s)!==t)break;{const i=e(this,n,"f")[s];delete e(this,n,"f")[s],e(this,r,"f").call(this,i),t+=1}}}}else e(this,n,"f")[a.toString()]=i}))}set onmessage(e){t(this,r,e,"f")}get onmessage(){return e(this,r,"f")}toJSON(){return`__CHANNEL__:${this.id}`}}async function a(e,t={},r){return window.__TAURI_INTERNALS__.invoke(e,t,r)}r=new WeakMap,s=new WeakMap,n=new WeakMap;class o{constructor(e,t){this.id=e,this.listeners=t}static async connect(e,t){const r=[],s=new i;return s.onmessage=e=>{r.forEach((t=>t(e)))},t?.headers&&(t.headers=Array.from(new Headers(t.headers).entries())),await a("plugin:websocket|connect",{url:e,onMessage:s,config:t}).then((e=>new o(e,r)))}addListener(e){this.listeners.push(e)}async send(e){let t;if("string"==typeof e)t={type:"Text",data:e};else if("object"==typeof e&&"type"in e)t=e;else{if(!Array.isArray(e))throw new Error("invalid `message` type, expected a `{ type: string, data: any }` object, a string or a numeric array");t={type:"Binary",data:e}}return await a("plugin:websocket|send",{id:this.id,message:t})}async disconnect(){return await this.send({type:"Close",data:{code:1e3,reason:"Disconnected by client"}})}}return o}();Object.defineProperty(window.__TAURI__,"websocket",{value:__TAURI_PLUGIN_WEBSOCKET__})}
if("__TAURI__"in window){var __TAURI_PLUGIN_WEBSOCKET__=function(){"use strict";function e(e,t,s,n){if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t.get(e)}function t(e,t,s,n,r){if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,s),s}var s,n,r;"function"==typeof SuppressedError&&SuppressedError;class i{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,s.set(this,(()=>{})),n.set(this,0),r.set(this,{}),this.id=function(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}((({message:i,id:a})=>{if(a===e(this,n)){t(this,n,a+1),e(this,s).call(this,i);const o=Object.keys(e(this,r));if(o.length>0){let t=a+1;for(const n of o.sort()){if(parseInt(n)!==t)break;{const i=e(this,r)[n];delete e(this,r)[n],e(this,s).call(this,i),t+=1}}}}else e(this,r)[a.toString()]=i}))}set onmessage(e){t(this,s,e)}get onmessage(){return e(this,s)}toJSON(){return`__CHANNEL__:${this.id}`}}async function a(e,t={},s){return window.__TAURI_INTERNALS__.invoke(e,t,s)}s=new WeakMap,n=new WeakMap,r=new WeakMap;class o{constructor(e,t){this.id=e,this.listeners=t}static async connect(e,t){const s=[],n=new i;return n.onmessage=e=>{s.forEach((t=>{t(e)}))},null!=t?.headers&&(t.headers=Array.from(new Headers(t.headers).entries())),await a("plugin:websocket|connect",{url:e,onMessage:n,config:t}).then((e=>new o(e,s)))}addListener(e){this.listeners.push(e)}async send(e){let t;if("string"==typeof e)t={type:"Text",data:e};else if("object"==typeof e&&"type"in e)t=e;else{if(!Array.isArray(e))throw new Error("invalid `message` type, expected a `{ type: string, data: any }` object, a string or a numeric array");t={type:"Binary",data:e}}await a("plugin:websocket|send",{id:this.id,message:t})}async disconnect(){await this.send({type:"Close",data:{code:1e3,reason:"Disconnected by client"}})}}return o}();Object.defineProperty(window.__TAURI__,"websocket",{value:__TAURI_PLUGIN_WEBSOCKET__})}

@ -34,13 +34,17 @@ async function connect() {
function send() {
ws.send(document.querySelector("#msg-input")?.textContent || "")
.then(() => _updateResponse("Message sent"))
.then(() => {
_updateResponse("Message sent");
})
.catch(_updateResponse);
}
function disconnect() {
ws.disconnect()
.then(() => _updateResponse("Disconnected"))
.then(() => {
_updateResponse("Disconnected");
})
.catch(_updateResponse);
}

@ -47,10 +47,12 @@ export default class WebSocket {
const onMessage = new Channel<Message>();
onMessage.onmessage = (message: Message): void => {
listeners.forEach((l) => l(message));
listeners.forEach((l) => {
l(message);
});
};
if (config?.headers) {
if (config?.headers != null) {
config.headers = Array.from(new Headers(config.headers).entries());
}
@ -78,14 +80,14 @@ export default class WebSocket {
"invalid `message` type, expected a `{ type: string, data: any }` object, a string or a numeric array",
);
}
return await invoke("plugin:websocket|send", {
await invoke("plugin:websocket|send", {
id: this.id,
message: m,
});
}
async disconnect(): Promise<void> {
return await this.send({
await this.send({
type: "Close",
data: {
code: 1000,

File diff suppressed because one or more lines are too long

@ -3,7 +3,7 @@
// SPDX-License-Identifier: MIT
import { invoke } from "@tauri-apps/api/core";
import { WindowLabel, getCurrent } from "@tauri-apps/api/window";
import { type WindowLabel, getCurrent } from "@tauri-apps/api/window";
export enum StateFlags {
SIZE = 1 << 0,
@ -19,7 +19,7 @@ export enum StateFlags {
* Save the state of all open windows to disk.
*/
async function saveWindowState(flags: StateFlags): Promise<void> {
return invoke("plugin:window-state|save_window_state", { flags });
await invoke("plugin:window-state|save_window_state", { flags });
}
/**
@ -29,20 +29,20 @@ async function restoreState(
label: WindowLabel,
flags: StateFlags,
): Promise<void> {
return invoke("plugin:window-state|restore_state", { label, flags });
await invoke("plugin:window-state|restore_state", { label, flags });
}
/**
* Restore the state for the current window from disk.
*/
async function restoreStateCurrent(flags: StateFlags): Promise<void> {
return restoreState(getCurrent().label, flags);
await restoreState(getCurrent().label, flags);
}
/**
* Get the name of the file used to store window state.
*/
async function filename(): Promise<string> {
return invoke("plugin:window-state|filename");
return await invoke("plugin:window-state|filename");
}
export { restoreState, restoreStateCurrent, saveWindowState, filename };

@ -33,12 +33,12 @@ importers:
eslint:
specifier: 8.57.0
version: 8.57.0
eslint-config-love:
specifier: 43.1.0
version: 43.1.0(@typescript-eslint/eslint-plugin@7.7.1)(eslint-plugin-import@2.29.1)(eslint-plugin-n@17.2.1)(eslint-plugin-promise@6.1.1)(eslint@8.57.0)(typescript@5.4.5)
eslint-config-prettier:
specifier: 9.1.0
version: 9.1.0(eslint@8.57.0)
eslint-config-standard-with-typescript:
specifier: 43.0.1
version: 43.0.1(@typescript-eslint/eslint-plugin@7.7.1)(eslint-plugin-import@2.29.1)(eslint-plugin-n@17.2.1)(eslint-plugin-promise@6.1.1)(eslint@8.57.0)(typescript@5.4.5)
eslint-plugin-import:
specifier: 2.29.1
version: 2.29.1(@typescript-eslint/parser@7.7.1)(eslint@8.57.0)
@ -2850,18 +2850,8 @@ packages:
eslint: 8.57.0
dev: true
/eslint-config-prettier@9.1.0(eslint@8.57.0):
resolution: {integrity: sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==}
hasBin: true
peerDependencies:
eslint: '>=7.0.0'
dependencies:
eslint: 8.57.0
dev: true
/eslint-config-standard-with-typescript@43.0.1(@typescript-eslint/eslint-plugin@7.7.1)(eslint-plugin-import@2.29.1)(eslint-plugin-n@17.2.1)(eslint-plugin-promise@6.1.1)(eslint@8.57.0)(typescript@5.4.5):
resolution: {integrity: sha512-WfZ986+qzIzX6dcr4yGUyVb/l9N3Z8wPXCc5z/70fljs3UbWhhV+WxrfgsqMToRzuuyX9MqZ974pq2UPhDTOcA==}
deprecated: Please use eslint-config-love, instead.
/eslint-config-love@43.1.0(@typescript-eslint/eslint-plugin@7.7.1)(eslint-plugin-import@2.29.1)(eslint-plugin-n@17.2.1)(eslint-plugin-promise@6.1.1)(eslint@8.57.0)(typescript@5.4.5):
resolution: {integrity: sha512-r3+7mSaOl0BEGf8LEntPPDbWTDw8o0Dpy9vdts7m+NAuSpmz9C/gL+64lC0Z8nKNE4uwdymPGll4czGQiR+XmQ==}
peerDependencies:
'@typescript-eslint/eslint-plugin': ^6.4.0
eslint: ^8.0.1
@ -2882,6 +2872,15 @@ packages:
- supports-color
dev: true
/eslint-config-prettier@9.1.0(eslint@8.57.0):
resolution: {integrity: sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==}
hasBin: true
peerDependencies:
eslint: '>=7.0.0'
dependencies:
eslint: 8.57.0
dev: true
/eslint-config-standard@17.1.0(eslint-plugin-import@2.29.1)(eslint-plugin-n@17.2.1)(eslint-plugin-promise@6.1.1)(eslint@8.57.0):
resolution: {integrity: sha512-IwHwmaBNtDK4zDHQukFDW5u/aTb8+meQWZvNFWkiGmbWjD6bqyuSSBxxXKkCftCUzc1zwCH2m/baCNDLGmuO5Q==}
engines: {node: '>=12.0.0'}

Loading…
Cancel
Save