parent
cd9daf6b20
commit
2ed0742b86
@ -1,2 +1,3 @@
|
|||||||
target
|
target
|
||||||
node_modules
|
node_modules
|
||||||
|
dist
|
@ -1,7 +0,0 @@
|
|||||||
export declare class Authenticator {
|
|
||||||
init(): Promise<void>;
|
|
||||||
register(challenge: string, application: string): Promise<string>;
|
|
||||||
verifyRegistration(challenge: string, application: string, registerData: string, clientData: string): Promise<string>;
|
|
||||||
sign(challenge: string, application: string, keyHandle: string): Promise<string>;
|
|
||||||
verifySignature(challenge: string, application: string, signData: string, clientData: string, keyHandle: string, pubkey: string): Promise<number>;
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
var d=Object.defineProperty;var e=(c,a)=>{for(var b in a)d(c,b,{get:a[b],enumerable:!0});};
|
|
||||||
|
|
||||||
var f={};e(f,{convertFileSrc:()=>w,invoke:()=>c,transformCallback:()=>s});function u(){return window.crypto.getRandomValues(new Uint32Array(1))[0]}function s(e,r=!1){let n=u(),t=`_${n}`;return Object.defineProperty(window,t,{value:o=>(r&&Reflect.deleteProperty(window,t),e==null?void 0:e(o)),writable:!1,configurable:!0}),n}async function c(e,r={}){return new Promise((n,t)=>{let o=s(i=>{n(i),Reflect.deleteProperty(window,`_${a}`);},!0),a=s(i=>{t(i),Reflect.deleteProperty(window,`_${o}`);},!0);window.__TAURI_IPC__({cmd:e,callback:o,error:a,...r});})}function w(e,r="asset"){let n=encodeURIComponent(e);return navigator.userAgent.includes("Windows")?`https://${r}.localhost/${n}`:`${r}://localhost/${n}`}
|
|
||||||
|
|
||||||
class Authenticator {
|
|
||||||
async init() {
|
|
||||||
return await c("plugin:authenticator|init");
|
|
||||||
}
|
|
||||||
async register(challenge, application) {
|
|
||||||
return await c("plugin:authenticator|register", {
|
|
||||||
timeout: 10000,
|
|
||||||
challenge,
|
|
||||||
application,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
async verifyRegistration(challenge, application, registerData, clientData) {
|
|
||||||
return await c("plugin:authenticator|verify_registration", {
|
|
||||||
challenge,
|
|
||||||
application,
|
|
||||||
registerData,
|
|
||||||
clientData,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
async sign(challenge, application, keyHandle) {
|
|
||||||
return await c("plugin:authenticator|sign", {
|
|
||||||
timeout: 10000,
|
|
||||||
challenge,
|
|
||||||
application,
|
|
||||||
keyHandle,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
async verifySignature(challenge, application, signData, clientData, keyHandle, pubkey) {
|
|
||||||
return await c("plugin:authenticator|verify_signature", {
|
|
||||||
challenge,
|
|
||||||
application,
|
|
||||||
signData,
|
|
||||||
clientData,
|
|
||||||
keyHandle,
|
|
||||||
pubkey,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export { Authenticator };
|
|
||||||
//# sourceMappingURL=index.min.js.map
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"index.min.js","sources":["../../../../node_modules/.pnpm/@tauri-apps+api@1.2.0/node_modules/@tauri-apps/api/chunk-FEIY7W7S.js","../../../../node_modules/.pnpm/@tauri-apps+api@1.2.0/node_modules/@tauri-apps/api/chunk-RCPA6UVN.js","../index.ts"],"sourcesContent":["var d=Object.defineProperty;var e=(c,a)=>{for(var b in a)d(c,b,{get:a[b],enumerable:!0})};export{e as a};\n","import{a as d}from\"./chunk-FEIY7W7S.js\";var f={};d(f,{convertFileSrc:()=>w,invoke:()=>c,transformCallback:()=>s});function u(){return window.crypto.getRandomValues(new Uint32Array(1))[0]}function s(e,r=!1){let n=u(),t=`_${n}`;return Object.defineProperty(window,t,{value:o=>(r&&Reflect.deleteProperty(window,t),e==null?void 0:e(o)),writable:!1,configurable:!0}),n}async function c(e,r={}){return new Promise((n,t)=>{let o=s(i=>{n(i),Reflect.deleteProperty(window,`_${a}`)},!0),a=s(i=>{t(i),Reflect.deleteProperty(window,`_${o}`)},!0);window.__TAURI_IPC__({cmd:e,callback:o,error:a,...r})})}function w(e,r=\"asset\"){let n=encodeURIComponent(e);return navigator.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QAAA,OAAO,MAAMA,CAAM,CAAC,0CAA0C,EAAE;YAC9D,SAAS;YACT,WAAW;YACX,YAAY;YACZ,UAAU;AACX,SAAA,CAAC,CAAC;KACJ;AAED,IAAA,MAAM,IAAI,CACR,SAAiB,EACjB,WAAmB,EACnB,SAAiB,EAAA;AAEjB,QAAA,OAAO,MAAMA,CAAM,CAAC,2BAA2B,EAAE;AAC/C,YAAA,OAAO,EAAE,KAAK;YACd,SAAS;YACT,WAAW;YACX,SAAS;AACV,SAAA,CAAC,CAAC;KACJ;AAED,IAAA,MAAM,eAAe,CACnB,SAAiB,EACjB,WAAmB,EACnB,QAAgB,EAChB,UAAkB,EAClB,SAAiB,EACjB,MAAc,EAAA;AAEd,QAAA,OAAO,MAAMA,CAAM,CAAC,uCAAuC,EAAE;YAC3D,SAAS;YACT,WAAW;YACX,QAAQ;YACR,UAAU;YACV,SAAS;YACT,MAAM;AACP,SAAA,CAAC,CAAC;KACJ;AACF;;;;"}
|
|
@ -1,43 +0,0 @@
|
|||||||
import { invoke } from '@tauri-apps/api/tauri';
|
|
||||||
|
|
||||||
class Authenticator {
|
|
||||||
async init() {
|
|
||||||
return await invoke("plugin:authenticator|init");
|
|
||||||
}
|
|
||||||
async register(challenge, application) {
|
|
||||||
return await invoke("plugin:authenticator|register", {
|
|
||||||
timeout: 10000,
|
|
||||||
challenge,
|
|
||||||
application,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
async verifyRegistration(challenge, application, registerData, clientData) {
|
|
||||||
return await invoke("plugin:authenticator|verify_registration", {
|
|
||||||
challenge,
|
|
||||||
application,
|
|
||||||
registerData,
|
|
||||||
clientData,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
async sign(challenge, application, keyHandle) {
|
|
||||||
return await invoke("plugin:authenticator|sign", {
|
|
||||||
timeout: 10000,
|
|
||||||
challenge,
|
|
||||||
application,
|
|
||||||
keyHandle,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
async verifySignature(challenge, application, signData, clientData, keyHandle, pubkey) {
|
|
||||||
return await invoke("plugin:authenticator|verify_signature", {
|
|
||||||
challenge,
|
|
||||||
application,
|
|
||||||
signData,
|
|
||||||
clientData,
|
|
||||||
keyHandle,
|
|
||||||
pubkey,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export { Authenticator };
|
|
||||||
//# sourceMappingURL=index.mjs.map
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"index.mjs","sources":["../index.ts"],"sourcesContent":[null],"names":[],"mappings":";;MAEa,aAAa,CAAA;AACxB,IAAA,MAAM,IAAI,GAAA;AACR,QAAA,OAAO,MAAM,MAAM,CAAC,2BAA2B,CAAC,CAAC;KAClD;AAED,IAAA,MAAM,QAAQ,CAAC,SAAiB,EAAE,WAAmB,EAAA;AACnD,QAAA,OAAO,MAAM,MAAM,CAAC,+BAA+B,EAAE;AACnD,YAAA,OAAO,EAAE,KAAK;YACd,SAAS;YACT,WAAW;AACZ,SAAA,CAAC,CAAC;KACJ;IAED,MAAM,kBAAkB,CACtB,SAAiB,EACjB,WAAmB,EACnB,YAAoB,EACpB,UAAkB,EAAA;AAElB,QAAA,OAAO,MAAM,MAAM,CAAC,0CAA0C,EAAE;YAC9D,SAAS;YACT,WAAW;YACX,YAAY;YACZ,UAAU;AACX,SAAA,CAAC,CAAC;KACJ;AAED,IAAA,MAAM,IAAI,CACR,SAAiB,EACjB,WAAmB,EACnB,SAAiB,EAAA;AAEjB,QAAA,OAAO,MAAM,MAAM,CAAC,2BAA2B,EAAE;AAC/C,YAAA,OAAO,EAAE,KAAK;YACd,SAAS;YACT,WAAW;YACX,SAAS;AACV,SAAA,CAAC,CAAC;KACJ;AAED,IAAA,MAAM,eAAe,CACnB,SAAiB,EACjB,WAAmB,EACnB,QAAgB,EAChB,UAAkB,EAClB,SAAiB,EACjB,MAAc,EAAA;AAEd,QAAA,OAAO,MAAM,MAAM,CAAC,uCAAuC,EAAE;YAC3D,SAAS;YACT,WAAW;YACX,QAAQ;YACR,UAAU;YACV,SAAS;YACT,MAAM;AACP,SAAA,CAAC,CAAC;KACJ;AACF;;;;"}
|
|
@ -1,3 +0,0 @@
|
|||||||
export declare function isEnabled(): Promise<boolean>;
|
|
||||||
export declare function enable(): Promise<void>;
|
|
||||||
export declare function disable(): Promise<void>;
|
|
@ -1,17 +0,0 @@
|
|||||||
var d=Object.defineProperty;var e=(c,a)=>{for(var b in a)d(c,b,{get:a[b],enumerable:!0});};
|
|
||||||
|
|
||||||
var f={};e(f,{convertFileSrc:()=>w,invoke:()=>c,transformCallback:()=>s});function u(){return window.crypto.getRandomValues(new Uint32Array(1))[0]}function s(e,r=!1){let n=u(),t=`_${n}`;return Object.defineProperty(window,t,{value:o=>(r&&Reflect.deleteProperty(window,t),e==null?void 0:e(o)),writable:!1,configurable:!0}),n}async function c(e,r={}){return new Promise((n,t)=>{let o=s(i=>{n(i),Reflect.deleteProperty(window,`_${a}`);},!0),a=s(i=>{t(i),Reflect.deleteProperty(window,`_${o}`);},!0);window.__TAURI_IPC__({cmd:e,callback:o,error:a,...r});})}function w(e,r="asset"){let n=encodeURIComponent(e);return navigator.userAgent.includes("Windows")?`https://${r}.localhost/${n}`:`${r}://localhost/${n}`}
|
|
||||||
|
|
||||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
|
||||||
async function isEnabled() {
|
|
||||||
return await c("plugin:autostart|is_enabled");
|
|
||||||
}
|
|
||||||
async function enable() {
|
|
||||||
await c("plugin:autostart|enable");
|
|
||||||
}
|
|
||||||
async function disable() {
|
|
||||||
await c("plugin:autostart|disable");
|
|
||||||
}
|
|
||||||
|
|
||||||
export { disable, enable, isEnabled };
|
|
||||||
//# sourceMappingURL=index.min.js.map
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"index.min.js","sources":["../../../../node_modules/.pnpm/@tauri-apps+api@1.2.0/node_modules/@tauri-apps/api/chunk-FEIY7W7S.js","../../../../node_modules/.pnpm/@tauri-apps+api@1.2.0/node_modules/@tauri-apps/api/chunk-RCPA6UVN.js","../index.ts"],"sourcesContent":["var d=Object.defineProperty;var e=(c,a)=>{for(var b in a)d(c,b,{get:a[b],enumerable:!0})};export{e as a};\n","import{a as d}from\"./chunk-FEIY7W7S.js\";var f={};d(f,{convertFileSrc:()=>w,invoke:()=>c,transformCallback:()=>s});function u(){return window.crypto.getRandomValues(new Uint32Array(1))[0]}function s(e,r=!1){let n=u(),t=`_${n}`;return Object.defineProperty(window,t,{value:o=>(r&&Reflect.deleteProperty(window,t),e==null?void 0:e(o)),writable:!1,configurable:!0}),n}async function c(e,r={}){return new Promise((n,t)=>{let o=s(i=>{n(i),Reflect.deleteProperty(window,`_${a}`)},!0),a=s(i=>{t(i),Reflect.deleteProperty(window,`_${o}`)},!0);window.__TAURI_IPC__({cmd:e,callback:o,error:a,...r})})}function w(e,r=\"asset\"){let n=encodeURIComponent(e);return navigator.userAgent.includes(\"Windows\")?`https://${r}.localhost/${n}`:`${r}://localhost/${n}`}export{s as a,c as b,w as c,f as d};\n",null],"names":["d","invoke"],"mappings":"AAAA,IAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC;;ACAjD,IAAI,CAAC,CAAC,EAAE,CAACA,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,OAAO,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,C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AAC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;;ACAtuB;AAMO,eAAe,SAAS,GAAA;AAC7B,IAAA,OAAO,MAAMC,CAAM,CAAC,6BAA6B,CAAC,CAAC;AACrD,CAAC;AAEM,eAAe,MAAM,GAAA;AAC1B,IAAA,MAAMA,CAAM,CAAC,yBAAyB,CAAC,CAAC;AAC1C,CAAC;AAEM,eAAe,OAAO,GAAA;AAC3B,IAAA,MAAMA,CAAM,CAAC,0BAA0B,CAAC,CAAC;AAC3C;;;;"}
|
|
@ -1,15 +0,0 @@
|
|||||||
import { invoke } from '@tauri-apps/api/tauri';
|
|
||||||
|
|
||||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
|
||||||
async function isEnabled() {
|
|
||||||
return await invoke("plugin:autostart|is_enabled");
|
|
||||||
}
|
|
||||||
async function enable() {
|
|
||||||
await invoke("plugin:autostart|enable");
|
|
||||||
}
|
|
||||||
async function disable() {
|
|
||||||
await invoke("plugin:autostart|disable");
|
|
||||||
}
|
|
||||||
|
|
||||||
export { disable, enable, isEnabled };
|
|
||||||
//# sourceMappingURL=index.mjs.map
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"index.mjs","sources":["../index.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;AAMO,eAAe,SAAS,GAAA;AAC7B,IAAA,OAAO,MAAM,MAAM,CAAC,6BAA6B,CAAC,CAAC;AACrD,CAAC;AAEM,eAAe,MAAM,GAAA;AAC1B,IAAA,MAAM,MAAM,CAAC,yBAAyB,CAAC,CAAC;AAC1C,CAAC;AAEM,eAAe,OAAO,GAAA;AAC3B,IAAA,MAAM,MAAM,CAAC,0BAA0B,CAAC,CAAC;AAC3C;;;;"}
|
|
@ -1,87 +0,0 @@
|
|||||||
export interface Permissions {
|
|
||||||
/**
|
|
||||||
* `true` if these permissions describe a readonly (unwritable) file.
|
|
||||||
*/
|
|
||||||
readonly: boolean;
|
|
||||||
/**
|
|
||||||
* The underlying raw `st_mode` bits that contain the standard Unix permissions for this file.
|
|
||||||
*/
|
|
||||||
mode: number | undefined;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Metadata information about a file.
|
|
||||||
* This structure is returned from the `metadata` function or method
|
|
||||||
* and represents known metadata about a file such as its permissions, size, modification times, etc.
|
|
||||||
*/
|
|
||||||
export interface Metadata {
|
|
||||||
/**
|
|
||||||
* The last access time of this metadata.
|
|
||||||
*/
|
|
||||||
accessedAt: Date;
|
|
||||||
/**
|
|
||||||
* The creation time listed in this metadata.
|
|
||||||
*/
|
|
||||||
createdAt: Date;
|
|
||||||
/**
|
|
||||||
* The last modification time listed in this metadata.
|
|
||||||
*/
|
|
||||||
modifiedAt: Date;
|
|
||||||
/**
|
|
||||||
* `true` if this metadata is for a directory.
|
|
||||||
*/
|
|
||||||
isDir: boolean;
|
|
||||||
/**
|
|
||||||
* `true` if this metadata is for a regular file.
|
|
||||||
*/
|
|
||||||
isFile: boolean;
|
|
||||||
/**
|
|
||||||
* `true` if this metadata is for a symbolic link.
|
|
||||||
*/
|
|
||||||
isSymlink: boolean;
|
|
||||||
/**
|
|
||||||
* The size of the file, in bytes, this metadata is for.
|
|
||||||
*/
|
|
||||||
size: number;
|
|
||||||
/**
|
|
||||||
* The permissions of the file this metadata is for.
|
|
||||||
*/
|
|
||||||
permissions: Permissions;
|
|
||||||
/**
|
|
||||||
* The ID of the device containing the file. Only available on Unix.
|
|
||||||
*/
|
|
||||||
dev: number | undefined;
|
|
||||||
/**
|
|
||||||
* The inode number. Only available on Unix.
|
|
||||||
*/
|
|
||||||
ino: number | undefined;
|
|
||||||
/**
|
|
||||||
* The rights applied to this file. Only available on Unix.
|
|
||||||
*/
|
|
||||||
mode: number | undefined;
|
|
||||||
/**
|
|
||||||
* The number of hard links pointing to this file. Only available on Unix.
|
|
||||||
*/
|
|
||||||
nlink: number | undefined;
|
|
||||||
/**
|
|
||||||
* The user ID of the owner of this file. Only available on Unix.
|
|
||||||
*/
|
|
||||||
uid: number | undefined;
|
|
||||||
/**
|
|
||||||
* The group ID of the owner of this file. Only available on Unix.
|
|
||||||
*/
|
|
||||||
gid: number | undefined;
|
|
||||||
/**
|
|
||||||
* The device ID of this file (if it is a special one). Only available on Unix.
|
|
||||||
*/
|
|
||||||
rdev: number | undefined;
|
|
||||||
/**
|
|
||||||
* The block size for filesystem I/O. Only available on Unix.
|
|
||||||
*/
|
|
||||||
blksize: number | undefined;
|
|
||||||
/**
|
|
||||||
* The number of blocks allocated to the file, in 512-byte units. Only available on Unix.
|
|
||||||
*/
|
|
||||||
blocks: number | undefined;
|
|
||||||
}
|
|
||||||
export declare function metadata(path: string): Promise<Metadata>;
|
|
||||||
export declare function exists(path: string): Promise<boolean>;
|
|
@ -1,24 +0,0 @@
|
|||||||
var d=Object.defineProperty;var e=(c,a)=>{for(var b in a)d(c,b,{get:a[b],enumerable:!0});};
|
|
||||||
|
|
||||||
var f={};e(f,{convertFileSrc:()=>w,invoke:()=>c,transformCallback:()=>s});function u(){return window.crypto.getRandomValues(new Uint32Array(1))[0]}function s(e,r=!1){let n=u(),t=`_${n}`;return Object.defineProperty(window,t,{value:o=>(r&&Reflect.deleteProperty(window,t),e==null?void 0:e(o)),writable:!1,configurable:!0}),n}async function c(e,r={}){return new Promise((n,t)=>{let o=s(i=>{n(i),Reflect.deleteProperty(window,`_${a}`);},!0),a=s(i=>{t(i),Reflect.deleteProperty(window,`_${o}`);},!0);window.__TAURI_IPC__({cmd:e,callback:o,error:a,...r});})}function w(e,r="asset"){let n=encodeURIComponent(e);return navigator.userAgent.includes("Windows")?`https://${r}.localhost/${n}`:`${r}://localhost/${n}`}
|
|
||||||
|
|
||||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
|
||||||
async function metadata(path) {
|
|
||||||
return await c("plugin:fs-extra|metadata", {
|
|
||||||
path,
|
|
||||||
}).then((metadata) => {
|
|
||||||
const { accessedAtMs, createdAtMs, modifiedAtMs, ...data } = metadata;
|
|
||||||
return {
|
|
||||||
accessedAt: new Date(accessedAtMs),
|
|
||||||
createdAt: new Date(createdAtMs),
|
|
||||||
modifiedAt: new Date(modifiedAtMs),
|
|
||||||
...data,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
async function exists(path) {
|
|
||||||
return await c("plugin:fs-extra|exists", { path });
|
|
||||||
}
|
|
||||||
|
|
||||||
export { exists, metadata };
|
|
||||||
//# sourceMappingURL=index.min.js.map
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"index.min.js","sources":["../../../../node_modules/.pnpm/@tauri-apps+api@1.2.0/node_modules/@tauri-apps/api/chunk-FEIY7W7S.js","../../../../node_modules/.pnpm/@tauri-apps+api@1.2.0/node_modules/@tauri-apps/api/chunk-RCPA6UVN.js","../index.ts"],"sourcesContent":["var d=Object.defineProperty;var e=(c,a)=>{for(var b in a)d(c,b,{get:a[b],enumerable:!0})};export{e as a};\n","import{a as d}from\"./chunk-FEIY7W7S.js\";var f={};d(f,{convertFileSrc:()=>w,invoke:()=>c,transformCallback:()=>s});function u(){return window.crypto.getRandomValues(new Uint32Array(1))[0]}function s(e,r=!1){let n=u(),t=`_${n}`;return Object.defineProperty(window,t,{value:o=>(r&&Reflect.deleteProperty(window,t),e==null?void 0:e(o)),writable:!1,configurable:!0}),n}async function c(e,r={}){return new Promise((n,t)=>{let o=s(i=>{n(i),Reflect.deleteProperty(window,`_${a}`)},!0),a=s(i=>{t(i),Reflect.deleteProperty(window,`_${o}`)},!0);window.__TAURI_IPC__({cmd:e,callback:o,error:a,...r})})}function w(e,r=\"asset\"){let n=encodeURIComponent(e);return navigator.userAgent.includes(\"Windows\")?`https://${r}.localhost/${n}`:`${r}://localhost/${n}`}export{s as a,c as b,w as c,f as d};\n",null],"names":["d","invoke"],"mappings":"AAAA,IAA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L,CAAC;AAEM,eAAe,MAAM,CAAC,IAAY,EAAA;IACvC,OAAO,MAAMA,CAAM,CAAC,wBAAwB,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;AAC1D;;;;"}
|
|
@ -1,22 +0,0 @@
|
|||||||
import { invoke } from '@tauri-apps/api/tauri';
|
|
||||||
|
|
||||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
|
||||||
async function metadata(path) {
|
|
||||||
return await invoke("plugin:fs-extra|metadata", {
|
|
||||||
path,
|
|
||||||
}).then((metadata) => {
|
|
||||||
const { accessedAtMs, createdAtMs, modifiedAtMs, ...data } = metadata;
|
|
||||||
return {
|
|
||||||
accessedAt: new Date(accessedAtMs),
|
|
||||||
createdAt: new Date(createdAtMs),
|
|
||||||
modifiedAt: new Date(modifiedAtMs),
|
|
||||||
...data,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
async function exists(path) {
|
|
||||||
return await invoke("plugin:fs-extra|exists", { path });
|
|
||||||
}
|
|
||||||
|
|
||||||
export { exists, metadata };
|
|
||||||
//# sourceMappingURL=index.mjs.map
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"index.mjs","sources":["../index.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;AAiHO,eAAe,QAAQ,CAAC,IAAY,EAAA;AACzC,IAAA,OAAO,MAAM,MAAM,CAAkB,0BAA0B,EAAE;QAC/D,IAAI;AACL,KAAA,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,KAAI;AACnB,QAAA,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,CAAC;QACtE,OAAO;AACL,YAAA,UAAU,EAAE,IAAI,IAAI,CAAC,YAAY,CAAC;AAClC,YAAA,SAAS,EAAE,IAAI,IAAI,CAAC,WAAW,CAAC;AAChC,YAAA,UAAU,EAAE,IAAI,IAAI,CAAC,YAAY,CAAC;AAClC,YAAA,GAAG,IAAI;SACR,CAAC;AACJ,KAAC,CAAC,CAAC;AACL,CAAC;AAEM,eAAe,MAAM,CAAC,IAAY,EAAA;IACvC,OAAO,MAAM,MAAM,CAAC,wBAAwB,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;AAC1D;;;;"}
|
|
@ -1,45 +0,0 @@
|
|||||||
import { UnlistenFn } from "@tauri-apps/api/event";
|
|
||||||
export interface WatchOptions {
|
|
||||||
recursive?: boolean;
|
|
||||||
}
|
|
||||||
export interface DebouncedWatchOptions extends WatchOptions {
|
|
||||||
delayMs?: number;
|
|
||||||
}
|
|
||||||
export interface RawEvent {
|
|
||||||
path: string | null;
|
|
||||||
operation: number;
|
|
||||||
cookie: number | null;
|
|
||||||
}
|
|
||||||
export type DebouncedEvent = {
|
|
||||||
type: "NoticeWrite";
|
|
||||||
payload: string;
|
|
||||||
} | {
|
|
||||||
type: "NoticeRemove";
|
|
||||||
payload: string;
|
|
||||||
} | {
|
|
||||||
type: "Create";
|
|
||||||
payload: string;
|
|
||||||
} | {
|
|
||||||
type: "Write";
|
|
||||||
payload: string;
|
|
||||||
} | {
|
|
||||||
type: "Chmod";
|
|
||||||
payload: string;
|
|
||||||
} | {
|
|
||||||
type: "Remove";
|
|
||||||
payload: string;
|
|
||||||
} | {
|
|
||||||
type: "Rename";
|
|
||||||
payload: string;
|
|
||||||
} | {
|
|
||||||
type: "Rescan";
|
|
||||||
payload: null;
|
|
||||||
} | {
|
|
||||||
type: "Error";
|
|
||||||
payload: {
|
|
||||||
error: string;
|
|
||||||
path: string | null;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
export declare function watch(paths: string | string[], options: DebouncedWatchOptions, cb: (event: DebouncedEvent) => void): Promise<UnlistenFn>;
|
|
||||||
export declare function watchImmediate(paths: string | string[], options: WatchOptions, cb: (event: RawEvent) => void): Promise<UnlistenFn>;
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,64 +0,0 @@
|
|||||||
import { invoke } from '@tauri-apps/api/tauri';
|
|
||||||
import { appWindow } from '@tauri-apps/api/window';
|
|
||||||
|
|
||||||
const w = appWindow;
|
|
||||||
async function unwatch(id) {
|
|
||||||
await invoke("plugin:fs-watch|unwatch", { id });
|
|
||||||
}
|
|
||||||
async function watch(paths, options, cb) {
|
|
||||||
const opts = {
|
|
||||||
recursive: false,
|
|
||||||
delayMs: 2000,
|
|
||||||
...options,
|
|
||||||
};
|
|
||||||
let watchPaths;
|
|
||||||
if (typeof paths === "string") {
|
|
||||||
watchPaths = [paths];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
watchPaths = paths;
|
|
||||||
}
|
|
||||||
const id = window.crypto.getRandomValues(new Uint32Array(1))[0];
|
|
||||||
await invoke("plugin:fs-watch|watch", {
|
|
||||||
id,
|
|
||||||
paths: watchPaths,
|
|
||||||
options: opts,
|
|
||||||
});
|
|
||||||
const unlisten = await w.listen(`watcher://debounced-event/${id}`, (event) => {
|
|
||||||
cb(event.payload);
|
|
||||||
});
|
|
||||||
return () => {
|
|
||||||
void unwatch(id);
|
|
||||||
unlisten();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
async function watchImmediate(paths, options, cb) {
|
|
||||||
const opts = {
|
|
||||||
recursive: false,
|
|
||||||
...options,
|
|
||||||
delayMs: null,
|
|
||||||
};
|
|
||||||
let watchPaths;
|
|
||||||
if (typeof paths === "string") {
|
|
||||||
watchPaths = [paths];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
watchPaths = paths;
|
|
||||||
}
|
|
||||||
const id = window.crypto.getRandomValues(new Uint32Array(1))[0];
|
|
||||||
await invoke("plugin:fs-watch|watch", {
|
|
||||||
id,
|
|
||||||
paths: watchPaths,
|
|
||||||
options: opts,
|
|
||||||
});
|
|
||||||
const unlisten = await w.listen(`watcher://raw-event/${id}`, (event) => {
|
|
||||||
cb(event.payload);
|
|
||||||
});
|
|
||||||
return () => {
|
|
||||||
void unwatch(id);
|
|
||||||
unlisten();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export { watch, watchImmediate };
|
|
||||||
//# sourceMappingURL=index.mjs.map
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"index.mjs","sources":["../index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAIA,MAAM,CAAC,GAAkB,SAAS,CAAC;AA2BnC,eAAe,OAAO,CAAC,EAAU,EAAA;IAC/B,MAAM,MAAM,CAAC,yBAAyB,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AAClD,CAAC;AAEM,eAAe,KAAK,CACzB,KAAwB,EACxB,OAA8B,EAC9B,EAAmC,EAAA;AAEnC,IAAA,MAAM,IAAI,GAAG;AACX,QAAA,SAAS,EAAE,KAAK;AAChB,QAAA,OAAO,EAAE,IAAI;AACb,QAAA,GAAG,OAAO;KACX,CAAC;AACF,IAAA,IAAI,UAAU,CAAC;AACf,IAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AAC7B,QAAA,UAAU,GAAG,CAAC,KAAK,CAAC,CAAC;AACtB,KAAA;AAAM,SAAA;QACL,UAAU,GAAG,KAAK,CAAC;AACpB,KAAA;AAED,IAAA,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEhE,MAAM,MAAM,CAAC,uBAAuB,EAAE;QACpC,EAAE;AACF,QAAA,KAAK,EAAE,UAAU;AACjB,QAAA,OAAO,EAAE,IAAI;AACd,KAAA,CAAC,CAAC;AAEH,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,MAAM,CAC7B,CAA6B,0BAAA,EAAA,EAAE,CAAE,CAAA,EACjC,CAAC,KAAK,KAAI;AACR,QAAA,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACpB,KAAC,CACF,CAAC;AAEF,IAAA,OAAO,MAAK;AACV,QAAA,KAAK,OAAO,CAAC,EAAE,CAAC,CAAC;AACjB,QAAA,QAAQ,EAAE,CAAC;AACb,KAAC,CAAC;AACJ,CAAC;AAEM,eAAe,cAAc,CAClC,KAAwB,EACxB,OAAqB,EACrB,EAA6B,EAAA;AAE7B,IAAA,MAAM,IAAI,GAAG;AACX,QAAA,SAAS,EAAE,KAAK;AAChB,QAAA,GAAG,OAAO;AACV,QAAA,OAAO,EAAE,IAAI;KACd,CAAC;AACF,IAAA,IAAI,UAAU,CAAC;AACf,IAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AAC7B,QAAA,UAAU,GAAG,CAAC,KAAK,CAAC,CAAC;AACtB,KAAA;AAAM,SAAA;QACL,UAAU,GAAG,KAAK,CAAC;AACpB,KAAA;AAED,IAAA,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEhE,MAAM,MAAM,CAAC,uBAAuB,EAAE;QACpC,EAAE;AACF,QAAA,KAAK,EAAE,UAAU;AACjB,QAAA,OAAO,EAAE,IAAI;AACd,KAAA,CAAC,CAAC;AAEH,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,MAAM,CAC7B,CAAuB,oBAAA,EAAA,EAAE,CAAE,CAAA,EAC3B,CAAC,KAAK,KAAI;AACR,QAAA,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACpB,KAAC,CACF,CAAC;AAEF,IAAA,OAAO,MAAK;AACV,QAAA,KAAK,OAAO,CAAC,EAAE,CAAC,CAAC;AACjB,QAAA,QAAQ,EAAE,CAAC;AACb,KAAC,CAAC;AACJ;;;;"}
|
|
@ -1,87 +0,0 @@
|
|||||||
import { UnlistenFn } from "@tauri-apps/api/event";
|
|
||||||
export type LogOptions = {
|
|
||||||
file?: string;
|
|
||||||
line?: number;
|
|
||||||
} & Record<string, string | undefined>;
|
|
||||||
/**
|
|
||||||
* Logs a message at the error level.
|
|
||||||
*
|
|
||||||
* @param message
|
|
||||||
*
|
|
||||||
* # Examples
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import { error } from 'tauri-plugin-log-api';
|
|
||||||
*
|
|
||||||
* const err_info = "No connection";
|
|
||||||
* const port = 22;
|
|
||||||
*
|
|
||||||
* error(`Error: ${err_info} on port ${port}`);
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export declare function error(message: string, options?: LogOptions): Promise<void>;
|
|
||||||
/**
|
|
||||||
* Logs a message at the warn level.
|
|
||||||
*
|
|
||||||
* @param message
|
|
||||||
*
|
|
||||||
* # Examples
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import { warn } from 'tauri-plugin-log-api';
|
|
||||||
*
|
|
||||||
* const warn_description = "Invalid Input";
|
|
||||||
*
|
|
||||||
* warn(`Warning! {warn_description}!`);
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export declare function warn(message: string, options?: LogOptions): Promise<void>;
|
|
||||||
/**
|
|
||||||
* Logs a message at the info level.
|
|
||||||
*
|
|
||||||
* @param message
|
|
||||||
*
|
|
||||||
* # Examples
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import { info } from 'tauri-plugin-log-api';
|
|
||||||
*
|
|
||||||
* const conn_info = { port: 40, speed: 3.20 };
|
|
||||||
*
|
|
||||||
* info(`Connected to port {conn_info.port} at {conn_info.speed} Mb/s`);
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export declare function info(message: string, options?: LogOptions): Promise<void>;
|
|
||||||
/**
|
|
||||||
* Logs a message at the debug level.
|
|
||||||
*
|
|
||||||
* @param message
|
|
||||||
*
|
|
||||||
* # Examples
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import { debug } from 'tauri-plugin-log-api';
|
|
||||||
*
|
|
||||||
* const pos = { x: 3.234, y: -1.223 };
|
|
||||||
*
|
|
||||||
* debug(`New position: x: {pos.x}, y: {pos.y}`);
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export declare function debug(message: string, options?: LogOptions): Promise<void>;
|
|
||||||
/**
|
|
||||||
* Logs a message at the trace level.
|
|
||||||
*
|
|
||||||
* @param message
|
|
||||||
*
|
|
||||||
* # Examples
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import { trace } from 'tauri-plugin-log-api';
|
|
||||||
*
|
|
||||||
* let pos = { x: 3.234, y: -1.223 };
|
|
||||||
*
|
|
||||||
* trace(`Position is: x: {pos.x}, y: {pos.y}`);
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export declare function trace(message: string, options?: LogOptions): Promise<void>;
|
|
||||||
export declare function attachConsole(): Promise<UnlistenFn>;
|
|
@ -1,180 +0,0 @@
|
|||||||
var d=Object.defineProperty;var e=(c,a)=>{for(var b in a)d(c,b,{get:a[b],enumerable:!0});};
|
|
||||||
|
|
||||||
var f={};e(f,{convertFileSrc:()=>w,invoke:()=>c$1,transformCallback:()=>s$1});function u$1(){return window.crypto.getRandomValues(new Uint32Array(1))[0]}function s$1(e,r=!1){let n=u$1(),t=`_${n}`;return Object.defineProperty(window,t,{value:o=>(r&&Reflect.deleteProperty(window,t),e==null?void 0:e(o)),writable:!1,configurable:!0}),n}async function c$1(e,r={}){return new Promise((n,t)=>{let o=s$1(i=>{n(i),Reflect.deleteProperty(window,`_${a}`);},!0),a=s$1(i=>{t(i),Reflect.deleteProperty(window,`_${o}`);},!0);window.__TAURI_IPC__({cmd:e,callback:o,error:a,...r});})}function w(e,r="asset"){let n=encodeURIComponent(e);return navigator.userAgent.includes("Windows")?`https://${r}.localhost/${n}`:`${r}://localhost/${n}`}
|
|
||||||
|
|
||||||
async function a(i){return c$1("tauri",i)}
|
|
||||||
|
|
||||||
var W={};e(W,{TauriEvent:()=>c,emit:()=>D,listen:()=>E,once:()=>_});async function s(n,t){return a({__tauriModule:"Event",message:{cmd:"unlisten",event:n,eventId:t}})}async function m(n,t,i){await a({__tauriModule:"Event",message:{cmd:"emit",event:n,windowLabel:t,payload:i}});}async function o(n,t,i){return a({__tauriModule:"Event",message:{cmd:"listen",event:n,windowLabel:t,handler:s$1(i)}}).then(r=>async()=>s(n,r))}async function u(n,t,i){return o(n,t,r=>{i(r),s(n,r.id).catch(()=>{});})}var c=(e=>(e.WINDOW_RESIZED="tauri://resize",e.WINDOW_MOVED="tauri://move",e.WINDOW_CLOSE_REQUESTED="tauri://close-requested",e.WINDOW_CREATED="tauri://window-created",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_FILE_DROP="tauri://file-drop",e.WINDOW_FILE_DROP_HOVER="tauri://file-drop-hover",e.WINDOW_FILE_DROP_CANCELLED="tauri://file-drop-cancelled",e.MENU="tauri://menu",e.CHECK_UPDATE="tauri://update",e.UPDATE_AVAILABLE="tauri://update-available",e.INSTALL_UPDATE="tauri://update-install",e.STATUS_UPDATE="tauri://update-status",e.DOWNLOAD_PROGRESS="tauri://update-download-progress",e))(c||{});async function E(n,t){return o(n,null,t)}async function _(n,t){return u(n,null,t)}async function D(n,t){return m(n,void 0,t)}
|
|
||||||
|
|
||||||
var LogLevel;
|
|
||||||
(function (LogLevel) {
|
|
||||||
/**
|
|
||||||
* The "trace" level.
|
|
||||||
*
|
|
||||||
* Designates very low priority, often extremely verbose, information.
|
|
||||||
*/
|
|
||||||
LogLevel[LogLevel["Trace"] = 1] = "Trace";
|
|
||||||
/**
|
|
||||||
* The "debug" level.
|
|
||||||
*
|
|
||||||
* Designates lower priority information.
|
|
||||||
*/
|
|
||||||
LogLevel[LogLevel["Debug"] = 2] = "Debug";
|
|
||||||
/**
|
|
||||||
* The "info" level.
|
|
||||||
*
|
|
||||||
* Designates useful information.
|
|
||||||
*/
|
|
||||||
LogLevel[LogLevel["Info"] = 3] = "Info";
|
|
||||||
/**
|
|
||||||
* The "warn" level.
|
|
||||||
*
|
|
||||||
* Designates hazardous situations.
|
|
||||||
*/
|
|
||||||
LogLevel[LogLevel["Warn"] = 4] = "Warn";
|
|
||||||
/**
|
|
||||||
* The "error" level.
|
|
||||||
*
|
|
||||||
* Designates very serious errors.
|
|
||||||
*/
|
|
||||||
LogLevel[LogLevel["Error"] = 5] = "Error";
|
|
||||||
})(LogLevel || (LogLevel = {}));
|
|
||||||
async function log(level, message, options) {
|
|
||||||
var _a, _b;
|
|
||||||
const traces = (_a = new Error().stack) === null || _a === void 0 ? void 0 : _a.split("\n").map((line) => line.split("@"));
|
|
||||||
const filtered = traces === null || traces === void 0 ? void 0 : traces.filter(([name, location]) => {
|
|
||||||
return name.length > 0 && location !== "[native code]";
|
|
||||||
});
|
|
||||||
const { file, line, ...keyValues } = options !== null && options !== void 0 ? options : {};
|
|
||||||
await c$1("plugin:log|log", {
|
|
||||||
level,
|
|
||||||
message,
|
|
||||||
location: (_b = filtered === null || filtered === void 0 ? void 0 : filtered[0]) === null || _b === void 0 ? void 0 : _b.filter((v) => v.length > 0).join("@"),
|
|
||||||
file,
|
|
||||||
line,
|
|
||||||
keyValues,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Logs a message at the error level.
|
|
||||||
*
|
|
||||||
* @param message
|
|
||||||
*
|
|
||||||
* # Examples
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import { error } from 'tauri-plugin-log-api';
|
|
||||||
*
|
|
||||||
* const err_info = "No connection";
|
|
||||||
* const port = 22;
|
|
||||||
*
|
|
||||||
* error(`Error: ${err_info} on port ${port}`);
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
async function error(message, options) {
|
|
||||||
await log(LogLevel.Error, message, options);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Logs a message at the warn level.
|
|
||||||
*
|
|
||||||
* @param message
|
|
||||||
*
|
|
||||||
* # Examples
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import { warn } from 'tauri-plugin-log-api';
|
|
||||||
*
|
|
||||||
* const warn_description = "Invalid Input";
|
|
||||||
*
|
|
||||||
* warn(`Warning! {warn_description}!`);
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
async function warn(message, options) {
|
|
||||||
await log(LogLevel.Warn, message, options);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Logs a message at the info level.
|
|
||||||
*
|
|
||||||
* @param message
|
|
||||||
*
|
|
||||||
* # Examples
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import { info } from 'tauri-plugin-log-api';
|
|
||||||
*
|
|
||||||
* const conn_info = { port: 40, speed: 3.20 };
|
|
||||||
*
|
|
||||||
* info(`Connected to port {conn_info.port} at {conn_info.speed} Mb/s`);
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
async function info(message, options) {
|
|
||||||
await log(LogLevel.Info, message, options);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Logs a message at the debug level.
|
|
||||||
*
|
|
||||||
* @param message
|
|
||||||
*
|
|
||||||
* # Examples
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import { debug } from 'tauri-plugin-log-api';
|
|
||||||
*
|
|
||||||
* const pos = { x: 3.234, y: -1.223 };
|
|
||||||
*
|
|
||||||
* debug(`New position: x: {pos.x}, y: {pos.y}`);
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
async function debug(message, options) {
|
|
||||||
await log(LogLevel.Debug, message, options);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Logs a message at the trace level.
|
|
||||||
*
|
|
||||||
* @param message
|
|
||||||
*
|
|
||||||
* # Examples
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import { trace } from 'tauri-plugin-log-api';
|
|
||||||
*
|
|
||||||
* let pos = { x: 3.234, y: -1.223 };
|
|
||||||
*
|
|
||||||
* trace(`Position is: x: {pos.x}, y: {pos.y}`);
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
async function trace(message, options) {
|
|
||||||
await log(LogLevel.Trace, message, options);
|
|
||||||
}
|
|
||||||
async function attachConsole() {
|
|
||||||
return await E("log://log", (event) => {
|
|
||||||
const payload = event.payload;
|
|
||||||
// Strip ANSI escape codes
|
|
||||||
const message = payload.message.replace(
|
|
||||||
// eslint-disable-next-line no-control-regex
|
|
||||||
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, "");
|
|
||||||
switch (payload.level) {
|
|
||||||
case LogLevel.Trace:
|
|
||||||
console.log(message);
|
|
||||||
break;
|
|
||||||
case LogLevel.Debug:
|
|
||||||
console.debug(message);
|
|
||||||
break;
|
|
||||||
case LogLevel.Info:
|
|
||||||
console.info(message);
|
|
||||||
break;
|
|
||||||
case LogLevel.Warn:
|
|
||||||
console.warn(message);
|
|
||||||
break;
|
|
||||||
case LogLevel.Error:
|
|
||||||
console.error(message);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
||||||
throw new Error(`unknown log level ${payload.level}`);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export { attachConsole, debug, error, info, trace, warn };
|
|
||||||
//# sourceMappingURL=index.min.js.map
|
|
File diff suppressed because one or more lines are too long
@ -1,175 +0,0 @@
|
|||||||
import { invoke } from '@tauri-apps/api/tauri';
|
|
||||||
import { listen } from '@tauri-apps/api/event';
|
|
||||||
|
|
||||||
var LogLevel;
|
|
||||||
(function (LogLevel) {
|
|
||||||
/**
|
|
||||||
* The "trace" level.
|
|
||||||
*
|
|
||||||
* Designates very low priority, often extremely verbose, information.
|
|
||||||
*/
|
|
||||||
LogLevel[LogLevel["Trace"] = 1] = "Trace";
|
|
||||||
/**
|
|
||||||
* The "debug" level.
|
|
||||||
*
|
|
||||||
* Designates lower priority information.
|
|
||||||
*/
|
|
||||||
LogLevel[LogLevel["Debug"] = 2] = "Debug";
|
|
||||||
/**
|
|
||||||
* The "info" level.
|
|
||||||
*
|
|
||||||
* Designates useful information.
|
|
||||||
*/
|
|
||||||
LogLevel[LogLevel["Info"] = 3] = "Info";
|
|
||||||
/**
|
|
||||||
* The "warn" level.
|
|
||||||
*
|
|
||||||
* Designates hazardous situations.
|
|
||||||
*/
|
|
||||||
LogLevel[LogLevel["Warn"] = 4] = "Warn";
|
|
||||||
/**
|
|
||||||
* The "error" level.
|
|
||||||
*
|
|
||||||
* Designates very serious errors.
|
|
||||||
*/
|
|
||||||
LogLevel[LogLevel["Error"] = 5] = "Error";
|
|
||||||
})(LogLevel || (LogLevel = {}));
|
|
||||||
async function log(level, message, options) {
|
|
||||||
var _a, _b;
|
|
||||||
const traces = (_a = new Error().stack) === null || _a === void 0 ? void 0 : _a.split("\n").map((line) => line.split("@"));
|
|
||||||
const filtered = traces === null || traces === void 0 ? void 0 : traces.filter(([name, location]) => {
|
|
||||||
return name.length > 0 && location !== "[native code]";
|
|
||||||
});
|
|
||||||
const { file, line, ...keyValues } = options !== null && options !== void 0 ? options : {};
|
|
||||||
await invoke("plugin:log|log", {
|
|
||||||
level,
|
|
||||||
message,
|
|
||||||
location: (_b = filtered === null || filtered === void 0 ? void 0 : filtered[0]) === null || _b === void 0 ? void 0 : _b.filter((v) => v.length > 0).join("@"),
|
|
||||||
file,
|
|
||||||
line,
|
|
||||||
keyValues,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Logs a message at the error level.
|
|
||||||
*
|
|
||||||
* @param message
|
|
||||||
*
|
|
||||||
* # Examples
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import { error } from 'tauri-plugin-log-api';
|
|
||||||
*
|
|
||||||
* const err_info = "No connection";
|
|
||||||
* const port = 22;
|
|
||||||
*
|
|
||||||
* error(`Error: ${err_info} on port ${port}`);
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
async function error(message, options) {
|
|
||||||
await log(LogLevel.Error, message, options);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Logs a message at the warn level.
|
|
||||||
*
|
|
||||||
* @param message
|
|
||||||
*
|
|
||||||
* # Examples
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import { warn } from 'tauri-plugin-log-api';
|
|
||||||
*
|
|
||||||
* const warn_description = "Invalid Input";
|
|
||||||
*
|
|
||||||
* warn(`Warning! {warn_description}!`);
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
async function warn(message, options) {
|
|
||||||
await log(LogLevel.Warn, message, options);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Logs a message at the info level.
|
|
||||||
*
|
|
||||||
* @param message
|
|
||||||
*
|
|
||||||
* # Examples
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import { info } from 'tauri-plugin-log-api';
|
|
||||||
*
|
|
||||||
* const conn_info = { port: 40, speed: 3.20 };
|
|
||||||
*
|
|
||||||
* info(`Connected to port {conn_info.port} at {conn_info.speed} Mb/s`);
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
async function info(message, options) {
|
|
||||||
await log(LogLevel.Info, message, options);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Logs a message at the debug level.
|
|
||||||
*
|
|
||||||
* @param message
|
|
||||||
*
|
|
||||||
* # Examples
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import { debug } from 'tauri-plugin-log-api';
|
|
||||||
*
|
|
||||||
* const pos = { x: 3.234, y: -1.223 };
|
|
||||||
*
|
|
||||||
* debug(`New position: x: {pos.x}, y: {pos.y}`);
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
async function debug(message, options) {
|
|
||||||
await log(LogLevel.Debug, message, options);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Logs a message at the trace level.
|
|
||||||
*
|
|
||||||
* @param message
|
|
||||||
*
|
|
||||||
* # Examples
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import { trace } from 'tauri-plugin-log-api';
|
|
||||||
*
|
|
||||||
* let pos = { x: 3.234, y: -1.223 };
|
|
||||||
*
|
|
||||||
* trace(`Position is: x: {pos.x}, y: {pos.y}`);
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
async function trace(message, options) {
|
|
||||||
await log(LogLevel.Trace, message, options);
|
|
||||||
}
|
|
||||||
async function attachConsole() {
|
|
||||||
return await listen("log://log", (event) => {
|
|
||||||
const payload = event.payload;
|
|
||||||
// Strip ANSI escape codes
|
|
||||||
const message = payload.message.replace(
|
|
||||||
// eslint-disable-next-line no-control-regex
|
|
||||||
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, "");
|
|
||||||
switch (payload.level) {
|
|
||||||
case LogLevel.Trace:
|
|
||||||
console.log(message);
|
|
||||||
break;
|
|
||||||
case LogLevel.Debug:
|
|
||||||
console.debug(message);
|
|
||||||
break;
|
|
||||||
case LogLevel.Info:
|
|
||||||
console.info(message);
|
|
||||||
break;
|
|
||||||
case LogLevel.Warn:
|
|
||||||
console.warn(message);
|
|
||||||
break;
|
|
||||||
case LogLevel.Error:
|
|
||||||
console.error(message);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
||||||
throw new Error(`unknown log level ${payload.level}`);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export { attachConsole, debug, error, info, trace, warn };
|
|
||||||
//# sourceMappingURL=index.mjs.map
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"index.mjs","sources":["../index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAQA,IAAK,QA+BJ,CAAA;AA/BD,CAAA,UAAK,QAAQ,EAAA;AACX;;;;AAIG;AACH,IAAA,QAAA,CAAA,QAAA,CAAA,OAAA,CAAA,GAAA,CAAA,CAAA,GAAA,OAAS,CAAA;AACT;;;;AAIG;AACH,IAAA,QAAA,CAAA,QAAA,CAAA,OAAA,CAAA,GAAA,CAAA,CAAA,GAA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AAG,KAAK,CAAC,OAAwB,CAAC;;AAG/C,QAAA,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO;;QAErC,6EAA6E,EAC7E,EAAE,CACH,CAAC;QAEF,QAAQ,OAAO,CAAC,KAAK;YACnB,KAAK,QAAQ,CAAC,KAAK;AACjB,gBAAA,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBACrB,MAAM;YACR,KAAK,QAAQ,CAAC,KAAK;AACjB,gBAAA,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBACvB,MAAM;YACR,KAAK,QAAQ,CAAC,IAAI;AAChB,gBAAA,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACtB,MAAM;YACR,KAAK,QAAQ,CAAC,IAAI;AAChB,gBAAA,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACtB,MAAM;YACR,KAAK,QAAQ,CAAC,KAAK;AACjB,gBAAA,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBACvB,MAAM;AACR,YAAA;;gBAEE,MAAM,IAAI,KAAK,CAAC,CAAA,kBAAA,EAAqB,OAAO,CAAC,KAAK,CAAE,CAAA,CAAC,CAAC;AACzD,SAAA;AACH,KAAC,CAAC,CAAC;AACL;;;;"}
|
|
@ -1,27 +0,0 @@
|
|||||||
/**
|
|
||||||
* Well known window positions.
|
|
||||||
*/
|
|
||||||
export declare enum Position {
|
|
||||||
TopLeft = 0,
|
|
||||||
TopRight = 1,
|
|
||||||
BottomLeft = 2,
|
|
||||||
BottomRight = 3,
|
|
||||||
TopCenter = 4,
|
|
||||||
BottomCenter = 5,
|
|
||||||
LeftCenter = 6,
|
|
||||||
RightCenter = 7,
|
|
||||||
Center = 8,
|
|
||||||
TrayLeft = 9,
|
|
||||||
TrayBottomLeft = 10,
|
|
||||||
TrayRight = 11,
|
|
||||||
TrayBottomRight = 12,
|
|
||||||
TrayCenter = 13,
|
|
||||||
TrayBottomCenter = 14
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Moves the `Window` to the given {@link Position} using `WindowExt.move_window()`
|
|
||||||
* All positions are relative to the **current** screen.
|
|
||||||
*
|
|
||||||
* @param to The {@link Position} to move to.
|
|
||||||
*/
|
|
||||||
export declare function moveWindow(to: Position): Promise<void>;
|
|
@ -1,40 +0,0 @@
|
|||||||
var d=Object.defineProperty;var e=(c,a)=>{for(var b in a)d(c,b,{get:a[b],enumerable:!0});};
|
|
||||||
|
|
||||||
var f={};e(f,{convertFileSrc:()=>w,invoke:()=>c,transformCallback:()=>s});function u(){return window.crypto.getRandomValues(new Uint32Array(1))[0]}function s(e,r=!1){let n=u(),t=`_${n}`;return Object.defineProperty(window,t,{value:o=>(r&&Reflect.deleteProperty(window,t),e==null?void 0:e(o)),writable:!1,configurable:!0}),n}async function c(e,r={}){return new Promise((n,t)=>{let o=s(i=>{n(i),Reflect.deleteProperty(window,`_${a}`);},!0),a=s(i=>{t(i),Reflect.deleteProperty(window,`_${o}`);},!0);window.__TAURI_IPC__({cmd:e,callback:o,error:a,...r});})}function w(e,r="asset"){let n=encodeURIComponent(e);return navigator.userAgent.includes("Windows")?`https://${r}.localhost/${n}`:`${r}://localhost/${n}`}
|
|
||||||
|
|
||||||
// Copyright 2021 Jonas Kruckenberg
|
|
||||||
/**
|
|
||||||
* Well known window positions.
|
|
||||||
*/
|
|
||||||
var Position;
|
|
||||||
(function (Position) {
|
|
||||||
Position[Position["TopLeft"] = 0] = "TopLeft";
|
|
||||||
Position[Position["TopRight"] = 1] = "TopRight";
|
|
||||||
Position[Position["BottomLeft"] = 2] = "BottomLeft";
|
|
||||||
Position[Position["BottomRight"] = 3] = "BottomRight";
|
|
||||||
Position[Position["TopCenter"] = 4] = "TopCenter";
|
|
||||||
Position[Position["BottomCenter"] = 5] = "BottomCenter";
|
|
||||||
Position[Position["LeftCenter"] = 6] = "LeftCenter";
|
|
||||||
Position[Position["RightCenter"] = 7] = "RightCenter";
|
|
||||||
Position[Position["Center"] = 8] = "Center";
|
|
||||||
Position[Position["TrayLeft"] = 9] = "TrayLeft";
|
|
||||||
Position[Position["TrayBottomLeft"] = 10] = "TrayBottomLeft";
|
|
||||||
Position[Position["TrayRight"] = 11] = "TrayRight";
|
|
||||||
Position[Position["TrayBottomRight"] = 12] = "TrayBottomRight";
|
|
||||||
Position[Position["TrayCenter"] = 13] = "TrayCenter";
|
|
||||||
Position[Position["TrayBottomCenter"] = 14] = "TrayBottomCenter";
|
|
||||||
})(Position || (Position = {}));
|
|
||||||
/**
|
|
||||||
* Moves the `Window` to the given {@link Position} using `WindowExt.move_window()`
|
|
||||||
* All positions are relative to the **current** screen.
|
|
||||||
*
|
|
||||||
* @param to The {@link Position} to move to.
|
|
||||||
*/
|
|
||||||
async function moveWindow(to) {
|
|
||||||
await c("plugin:positioner|move_window", {
|
|
||||||
position: to,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export { Position, moveWindow };
|
|
||||||
//# sourceMappingURL=index.min.js.map
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"index.min.js","sources":["../../../../node_modules/.pnpm/@tauri-apps+api@1.2.0/node_modules/@tauri-apps/api/chunk-FEIY7W7S.js","../../../../node_modules/.pnpm/@tauri-apps+api@1.2.0/node_modules/@tauri-apps/api/chunk-RCPA6UVN.js","../index.ts"],"sourcesContent":["var d=Object.defineProperty;var e=(c,a)=>{for(var b in a)d(c,b,{get:a[b],enumerable:!0})};export{e as a};\n","import{a as d}from\"./chunk-FEIY7W7S.js\";var f={};d(f,{convertFileSrc:()=>w,invoke:()=>c,transformCallback:()=>s});function u(){return window.crypto.getRandomValues(new Uint32Array(1))[0]}function s(e,r=!1){let n=u(),t=`_${n}`;return Object.defineProperty(window,t,{value:o=>(r&&Reflect.deleteProperty(window,t),e==null?void 0:e(o)),writable:!1,configurable:!0}),n}async function c(e,r={}){return new Promise((n,t)=>{let o=s(i=>{n(i),Reflect.deleteProperty(window,`_${a}`)},!0),a=s(i=>{t(i),Reflect.deleteProperty(window,`_${o}`)},!0);window.__TAURI_IPC__({cmd:e,callback:o,error:a,...r})})}function w(e,r=\"asset\"){let n=encodeURIComponent(e);return navigator.userAgent.includes(\"Windows\")?`https://${r}.localhost/${n}`:`${r}://localhost/${n}`}export{s as a,c as b,w as c,f as d};\n",null],"names":["d","invoke"],"mappings":"AAAA,IAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC;;ACAjD,IAAI,CAAC,CAAC,EAAE,CAACA,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,OAAO,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAA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AA,QAAQ,EAAE,EAAE;AACb,KAAA,CAAC,CAAC;AACL;;;;"}
|
|
@ -1,38 +0,0 @@
|
|||||||
import { invoke } from '@tauri-apps/api/tauri';
|
|
||||||
|
|
||||||
// Copyright 2021 Jonas Kruckenberg
|
|
||||||
/**
|
|
||||||
* Well known window positions.
|
|
||||||
*/
|
|
||||||
var Position;
|
|
||||||
(function (Position) {
|
|
||||||
Position[Position["TopLeft"] = 0] = "TopLeft";
|
|
||||||
Position[Position["TopRight"] = 1] = "TopRight";
|
|
||||||
Position[Position["BottomLeft"] = 2] = "BottomLeft";
|
|
||||||
Position[Position["BottomRight"] = 3] = "BottomRight";
|
|
||||||
Position[Position["TopCenter"] = 4] = "TopCenter";
|
|
||||||
Position[Position["BottomCenter"] = 5] = "BottomCenter";
|
|
||||||
Position[Position["LeftCenter"] = 6] = "LeftCenter";
|
|
||||||
Position[Position["RightCenter"] = 7] = "RightCenter";
|
|
||||||
Position[Position["Center"] = 8] = "Center";
|
|
||||||
Position[Position["TrayLeft"] = 9] = "TrayLeft";
|
|
||||||
Position[Position["TrayBottomLeft"] = 10] = "TrayBottomLeft";
|
|
||||||
Position[Position["TrayRight"] = 11] = "TrayRight";
|
|
||||||
Position[Position["TrayBottomRight"] = 12] = "TrayBottomRight";
|
|
||||||
Position[Position["TrayCenter"] = 13] = "TrayCenter";
|
|
||||||
Position[Position["TrayBottomCenter"] = 14] = "TrayBottomCenter";
|
|
||||||
})(Position || (Position = {}));
|
|
||||||
/**
|
|
||||||
* Moves the `Window` to the given {@link Position} using `WindowExt.move_window()`
|
|
||||||
* All positions are relative to the **current** screen.
|
|
||||||
*
|
|
||||||
* @param to The {@link Position} to move to.
|
|
||||||
*/
|
|
||||||
async function moveWindow(to) {
|
|
||||||
await invoke("plugin:positioner|move_window", {
|
|
||||||
position: to,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export { Position, moveWindow };
|
|
||||||
//# sourceMappingURL=index.mjs.map
|
|
@ -1 +0,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IAAA,QAAA,CAAA,QAAA,CAAA,YAAA,CAAA,GAAA,EAAA,CAAA,GAAA,YAAU,CAAA;AACV,IAAA,QAAA,CAAA,QAAA,CAAA,kBAAA,CAAA,GAAA,EAAA,CAAA,GAAA,kBAAgB,CAAA;AAClB,CAAC,EAhBW,QAAQ,KAAR,QAAQ,GAgBnB,EAAA,CAAA,CAAA,CAAA;AAED;;;;;AAKG;AACI,eAAe,UAAU,CAAC,EAAY,EAAA;IAC3C,MAAM,MAAM,CAAC,+BAA+B,EAAE;AAC5C,QAAA,QAAQ,EAAE,EAAE;AACb,KAAA,CAAC,CAAC;AACL;;;;"}
|
|
@ -1,95 +0,0 @@
|
|||||||
export interface QueryResult {
|
|
||||||
/** The number of rows affected by the query. */
|
|
||||||
rowsAffected: number;
|
|
||||||
/**
|
|
||||||
* The last inserted `id`.
|
|
||||||
*
|
|
||||||
* This value is always `0` when using the Postgres driver. If the
|
|
||||||
* last inserted id is required on Postgres, the `select` function
|
|
||||||
* must be used, with a `RETURNING` clause
|
|
||||||
* (`INSERT INTO todos (title) VALUES ($1) RETURNING id`).
|
|
||||||
*/
|
|
||||||
lastInsertId: number;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* **Database**
|
|
||||||
*
|
|
||||||
* The `Database` class serves as the primary interface for
|
|
||||||
* communicating with the rust side of the sql plugin.
|
|
||||||
*/
|
|
||||||
export default class Database {
|
|
||||||
path: string;
|
|
||||||
constructor(path: string);
|
|
||||||
/**
|
|
||||||
* **load**
|
|
||||||
*
|
|
||||||
* A static initializer which connects to the underlying database and
|
|
||||||
* returns a `Database` instance once a connection to the database is established.
|
|
||||||
*
|
|
||||||
* # Sqlite
|
|
||||||
*
|
|
||||||
* The path is relative to `tauri::api::path::BaseDirectory::App` and must start with `sqlite:`.
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* const db = await Database.load("sqlite:test.db");
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
static load(path: string): Promise<Database>;
|
|
||||||
/**
|
|
||||||
* **get**
|
|
||||||
*
|
|
||||||
* A static initializer which synchronously returns an instance of
|
|
||||||
* the Database class while deferring the actual database connection
|
|
||||||
* until the first invocation or selection on the database.
|
|
||||||
*
|
|
||||||
* # Sqlite
|
|
||||||
*
|
|
||||||
* The path is relative to `tauri::api::path::BaseDirectory::App` and must start with `sqlite:`.
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* const db = Database.get("sqlite:test.db");
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
static get(path: string): Database;
|
|
||||||
/**
|
|
||||||
* **execute**
|
|
||||||
*
|
|
||||||
* Passes a SQL expression to the database for execution.
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* const result = await db.execute(
|
|
||||||
* "UPDATE todos SET title = $1, completed = $2 WHERE id = $3",
|
|
||||||
* [ todos.title, todos.status, todos.id ]
|
|
||||||
* );
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
execute(query: string, bindValues?: unknown[]): Promise<QueryResult>;
|
|
||||||
/**
|
|
||||||
* **select**
|
|
||||||
*
|
|
||||||
* Passes in a SELECT query to the database for execution.
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* const result = await db.select(
|
|
||||||
* "SELECT * from todos WHERE id = $1", id
|
|
||||||
* );
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
select<T>(query: string, bindValues?: unknown[]): Promise<T>;
|
|
||||||
/**
|
|
||||||
* **close**
|
|
||||||
*
|
|
||||||
* Closes the database connection pool.
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* const success = await db.close()
|
|
||||||
* ```
|
|
||||||
* @param db - Optionally state the name of a database if you are managing more than one. Otherwise, all database pools will be in scope.
|
|
||||||
*/
|
|
||||||
close(db?: string): Promise<boolean>;
|
|
||||||
}
|
|
@ -1,119 +0,0 @@
|
|||||||
var d=Object.defineProperty;var e=(c,a)=>{for(var b in a)d(c,b,{get:a[b],enumerable:!0});};
|
|
||||||
|
|
||||||
var f={};e(f,{convertFileSrc:()=>w,invoke:()=>c,transformCallback:()=>s});function u(){return window.crypto.getRandomValues(new Uint32Array(1))[0]}function s(e,r=!1){let n=u(),t=`_${n}`;return Object.defineProperty(window,t,{value:o=>(r&&Reflect.deleteProperty(window,t),e==null?void 0:e(o)),writable:!1,configurable:!0}),n}async function c(e,r={}){return new Promise((n,t)=>{let o=s(i=>{n(i),Reflect.deleteProperty(window,`_${a}`);},!0),a=s(i=>{t(i),Reflect.deleteProperty(window,`_${o}`);},!0);window.__TAURI_IPC__({cmd:e,callback:o,error:a,...r});})}function w(e,r="asset"){let n=encodeURIComponent(e);return navigator.userAgent.includes("Windows")?`https://${r}.localhost/${n}`:`${r}://localhost/${n}`}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* **Database**
|
|
||||||
*
|
|
||||||
* The `Database` class serves as the primary interface for
|
|
||||||
* communicating with the rust side of the sql plugin.
|
|
||||||
*/
|
|
||||||
class Database {
|
|
||||||
constructor(path) {
|
|
||||||
this.path = path;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* **load**
|
|
||||||
*
|
|
||||||
* A static initializer which connects to the underlying database and
|
|
||||||
* returns a `Database` instance once a connection to the database is established.
|
|
||||||
*
|
|
||||||
* # Sqlite
|
|
||||||
*
|
|
||||||
* The path is relative to `tauri::api::path::BaseDirectory::App` and must start with `sqlite:`.
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* const db = await Database.load("sqlite:test.db");
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
static async load(path) {
|
|
||||||
const _path = await c("plugin:sql|load", {
|
|
||||||
db: path,
|
|
||||||
});
|
|
||||||
return new Database(_path);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* **get**
|
|
||||||
*
|
|
||||||
* A static initializer which synchronously returns an instance of
|
|
||||||
* the Database class while deferring the actual database connection
|
|
||||||
* until the first invocation or selection on the database.
|
|
||||||
*
|
|
||||||
* # Sqlite
|
|
||||||
*
|
|
||||||
* The path is relative to `tauri::api::path::BaseDirectory::App` and must start with `sqlite:`.
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* const db = Database.get("sqlite:test.db");
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
static get(path) {
|
|
||||||
return new Database(path);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* **execute**
|
|
||||||
*
|
|
||||||
* Passes a SQL expression to the database for execution.
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* const result = await db.execute(
|
|
||||||
* "UPDATE todos SET title = $1, completed = $2 WHERE id = $3",
|
|
||||||
* [ todos.title, todos.status, todos.id ]
|
|
||||||
* );
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
async execute(query, bindValues) {
|
|
||||||
const [rowsAffected, lastInsertId] = await c("plugin:sql|execute", {
|
|
||||||
db: this.path,
|
|
||||||
query,
|
|
||||||
values: bindValues !== null && bindValues !== void 0 ? bindValues : [],
|
|
||||||
});
|
|
||||||
return {
|
|
||||||
lastInsertId,
|
|
||||||
rowsAffected,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* **select**
|
|
||||||
*
|
|
||||||
* Passes in a SELECT query to the database for execution.
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* const result = await db.select(
|
|
||||||
* "SELECT * from todos WHERE id = $1", id
|
|
||||||
* );
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
async select(query, bindValues) {
|
|
||||||
const result = await c("plugin:sql|select", {
|
|
||||||
db: this.path,
|
|
||||||
query,
|
|
||||||
values: bindValues !== null && bindValues !== void 0 ? bindValues : [],
|
|
||||||
});
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* **close**
|
|
||||||
*
|
|
||||||
* Closes the database connection pool.
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* const success = await db.close()
|
|
||||||
* ```
|
|
||||||
* @param db - Optionally state the name of a database if you are managing more than one. Otherwise, all database pools will be in scope.
|
|
||||||
*/
|
|
||||||
async close(db) {
|
|
||||||
const success = await c("plugin:sql|close", {
|
|
||||||
db,
|
|
||||||
});
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export { Database as default };
|
|
||||||
//# sourceMappingURL=index.min.js.map
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"index.min.js","sources":["../../../../node_modules/.pnpm/@tauri-apps+api@1.2.0/node_modules/@tauri-apps/api/chunk-FEIY7W7S.js","../../../../node_modules/.pnpm/@tauri-apps+api@1.2.0/node_modules/@tauri-apps/api/chunk-RCPA6UVN.js","../index.ts"],"sourcesContent":["var d=Object.defineProperty;var e=(c,a)=>{for(var b in a)d(c,b,{get:a[b],enumerable:!0})};export{e as a};\n","import{a as d}from\"./chunk-FEIY7W7S.js\";var f={};d(f,{convertFileSrc:()=>w,invoke:()=>c,transformCallback:()=>s});function u(){return window.crypto.getRandomValues(new Uint32Array(1))[0]}function s(e,r=!1){let n=u(),t=`_${n}`;return Object.defineProperty(window,t,{value:o=>(r&&Reflect.deleteProperty(window,t),e==null?void 0:e(o)),writable:!1,configurable:!0}),n}async function c(e,r={}){return new Promise((n,t)=>{let o=s(i=>{n(i),Reflect.deleteProperty(window,`_${a}`)},!0),a=s(i=>{t(i),Reflect.deleteProperty(window,`_${o}`)},!0);window.__TAURI_IPC__({cmd:e,callback:o,error:a,...r})})}function w(e,r=\"asset\"){let n=encodeURIComponent(e);return navigator.userAgent.includes(\"Windows\")?`https://${r}.localhost/${n}`:`${r}://localhost/${n}`}export{s as a,c as b,w as c,f as d};\n",null],"names":["d","invoke"],"mappings":"AAAA,IAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAA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E,UAAsB,EAAA;QACjD,MAAM,CAAC,YAAY,EAAE,YAAY,CAAC,GAAG,MAAMA,CAAM,CAC/C,oBAAoB,EACpB;YACE,EAAE,EAAE,IAAI,CAAC,IAAI;YACb,KAAK;AACL,YAAA,MAAM,EAAE,UAAU,KAAA,IAAA,IAAV,UAAU,KAAV,KAAA,CAAA,GAAA,UAAU,GAAI,EAAE;AACzB,SAAA,CACF,CAAC;QAEF,OAAO;YACL,YAAY;YACZ,YAAY;SACb,CAAC;KACH;AAED;;;;;;;;;;;AAWG;AACH,IAAA,MAAM,MAAM,CAAI,KAAa,EAAE,UAAsB,EAAA;AACnD,QAAA,MAAM,MAAM,GAAG,MAAMA,CAAM,CAAI,mBAAmB,EAAE;YAClD,EAAE,EAAE,IAAI,CAAC,IAAI;YACb,KAAK;AACL,YAAA,MAAM,EAAE,UAAU,KAAA,IAAA,IAAV,UAAU,KAAV,KAAA,CAAA,GAAA,UAAU,GAAI,EAAE;AACzB,SAAA,CAAC,CAAC;AAEH,QAAA,OAAO,MAAM,CAAC;KACf;AAED;;;;;;;;;;AAUG;IACH,MAAM,KAAK,CAAC,EAAW,EAAA;AACrB,QAAA,MAAM,OAAO,GAAG,MAAMA,CAAM,CAAU,kBAAkB,EAAE;YACxD,EAAE;AACH,SAAA,CAAC,CAAC;AACH,QAAA,OAAO,OAAO,CAAC;KAChB;AACF;;;;"}
|
|
@ -1,117 +0,0 @@
|
|||||||
import { invoke } from '@tauri-apps/api/tauri';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* **Database**
|
|
||||||
*
|
|
||||||
* The `Database` class serves as the primary interface for
|
|
||||||
* communicating with the rust side of the sql plugin.
|
|
||||||
*/
|
|
||||||
class Database {
|
|
||||||
constructor(path) {
|
|
||||||
this.path = path;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* **load**
|
|
||||||
*
|
|
||||||
* A static initializer which connects to the underlying database and
|
|
||||||
* returns a `Database` instance once a connection to the database is established.
|
|
||||||
*
|
|
||||||
* # Sqlite
|
|
||||||
*
|
|
||||||
* The path is relative to `tauri::api::path::BaseDirectory::App` and must start with `sqlite:`.
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* const db = await Database.load("sqlite:test.db");
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
static async load(path) {
|
|
||||||
const _path = await invoke("plugin:sql|load", {
|
|
||||||
db: path,
|
|
||||||
});
|
|
||||||
return new Database(_path);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* **get**
|
|
||||||
*
|
|
||||||
* A static initializer which synchronously returns an instance of
|
|
||||||
* the Database class while deferring the actual database connection
|
|
||||||
* until the first invocation or selection on the database.
|
|
||||||
*
|
|
||||||
* # Sqlite
|
|
||||||
*
|
|
||||||
* The path is relative to `tauri::api::path::BaseDirectory::App` and must start with `sqlite:`.
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* const db = Database.get("sqlite:test.db");
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
static get(path) {
|
|
||||||
return new Database(path);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* **execute**
|
|
||||||
*
|
|
||||||
* Passes a SQL expression to the database for execution.
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* const result = await db.execute(
|
|
||||||
* "UPDATE todos SET title = $1, completed = $2 WHERE id = $3",
|
|
||||||
* [ todos.title, todos.status, todos.id ]
|
|
||||||
* );
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
async execute(query, bindValues) {
|
|
||||||
const [rowsAffected, lastInsertId] = await invoke("plugin:sql|execute", {
|
|
||||||
db: this.path,
|
|
||||||
query,
|
|
||||||
values: bindValues !== null && bindValues !== void 0 ? bindValues : [],
|
|
||||||
});
|
|
||||||
return {
|
|
||||||
lastInsertId,
|
|
||||||
rowsAffected,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* **select**
|
|
||||||
*
|
|
||||||
* Passes in a SELECT query to the database for execution.
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* const result = await db.select(
|
|
||||||
* "SELECT * from todos WHERE id = $1", id
|
|
||||||
* );
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
async select(query, bindValues) {
|
|
||||||
const result = await invoke("plugin:sql|select", {
|
|
||||||
db: this.path,
|
|
||||||
query,
|
|
||||||
values: bindValues !== null && bindValues !== void 0 ? bindValues : [],
|
|
||||||
});
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* **close**
|
|
||||||
*
|
|
||||||
* Closes the database connection pool.
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* const success = await db.close()
|
|
||||||
* ```
|
|
||||||
* @param db - Optionally state the name of a database if you are managing more than one. Otherwise, all database pools will be in scope.
|
|
||||||
*/
|
|
||||||
async close(db) {
|
|
||||||
const success = await invoke("plugin:sql|close", {
|
|
||||||
db,
|
|
||||||
});
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export { Database as default };
|
|
||||||
//# sourceMappingURL=index.mjs.map
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"index.mjs","sources":["../index.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAgBA;;;;;AAKG;AACW,MAAO,QAAQ,CAAA;AAE3B,IAAA,WAAA,CAAY,IAAY,EAAA;AACtB,QAAA,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;KAClB;AAED;;;;;;;;;;;;;;AAcG;AACH,IAAA,aAAa,IAAI,CAAC,IAAY,EAAA;AAC5B,QAAA,MAAM,KAAK,GAAG,MAAM,MAAM,CAAS,iBAAiB,EAAE;AACpD,YAAA,EAAE,EAAE,IAAI;AACT,SAAA,CAAC,CAAC;AAEH,QAAA,OAAO,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC;KAC5B;AAED;;;;;;;;;;;;;;;AAeG;IACH,OAAO,GAAG,CAAC,IAAY,EAAA;AACrB,QAAA,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;KAC3B;AAED;;;;;;;;;;;;AAYG;AACH,IAAA,MAAM,OAAO,CAAC,KAAa,EAAE,UAAsB,EAAA;QACjD,MAAM,CAAC,YAAY,EAAE,YAAY,CAAC,GAAG,MAAM,MAAM,CAC/C,oBAAoB,EACpB;YACE,EAAE,EAAE,IAAI,CAAC,IAAI;YACb,KAAK;AACL,YAAA,MAAM,EAAE,UAAU,KAAA,IAAA,IAAV,UAAU,KAAV,KAAA,CAAA,GAAA,UAAU,GAAI,EAAE;AACzB,SAAA,CACF,CAAC;QAEF,OAAO;YACL,YAAY;YACZ,YAAY;SACb,CAAC;KACH;AAED;;;;;;;;;;;AAWG;AACH,IAAA,MAAM,MAAM,CAAI,KAAa,EAAE,UAAsB,EAAA;AACnD,QAAA,MAAM,MAAM,GAAG,MAAM,MAAM,CAAI,mBAAmB,EAAE;YAClD,EAAE,EAAE,IAAI,CAAC,IAAI;YACb,KAAK;AACL,YAAA,MAAM,EAAE,UAAU,KAAA,IAAA,IAAV,UAAU,KAAV,KAAA,CAAA,GAAA,UAAU,GAAI,EAAE;AACzB,SAAA,CAAC,CAAC;AAEH,QAAA,OAAO,MAAM,CAAC;KACf;AAED;;;;;;;;;;AAUG;IACH,MAAM,KAAK,CAAC,EAAW,EAAA;AACrB,QAAA,MAAM,OAAO,GAAG,MAAM,MAAM,CAAU,kBAAkB,EAAE;YACxD,EAAE;AACH,SAAA,CAAC,CAAC;AACH,QAAA,OAAO,OAAO,CAAC;KAChB;AACF;;;;"}
|
|
@ -1,105 +0,0 @@
|
|||||||
import { UnlistenFn } from "@tauri-apps/api/event";
|
|
||||||
/**
|
|
||||||
* A key-value store persisted by the backend layer.
|
|
||||||
*/
|
|
||||||
export declare class Store {
|
|
||||||
path: string;
|
|
||||||
constructor(path: string);
|
|
||||||
/**
|
|
||||||
* Inserts a key-value pair into the store.
|
|
||||||
*
|
|
||||||
* @param key
|
|
||||||
* @param value
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
set(key: string, value: unknown): Promise<void>;
|
|
||||||
/**
|
|
||||||
* Returns the value for the given `key` or `null` the key does not exist.
|
|
||||||
*
|
|
||||||
* @param key
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
get<T>(key: string): Promise<T | null>;
|
|
||||||
/**
|
|
||||||
* Returns `true` if the given `key` exists in the store.
|
|
||||||
*
|
|
||||||
* @param key
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
has(key: string): Promise<boolean>;
|
|
||||||
/**
|
|
||||||
* Removes a key-value pair from the store.
|
|
||||||
*
|
|
||||||
* @param key
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
delete(key: string): Promise<boolean>;
|
|
||||||
/**
|
|
||||||
* Clears the store, removing all key-value pairs.
|
|
||||||
*
|
|
||||||
* Note: To clear the storage and reset it to it's `default` value, use `reset` instead.
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
clear(): Promise<void>;
|
|
||||||
/**
|
|
||||||
* Resets the store to it's `default` value.
|
|
||||||
*
|
|
||||||
* If no default value has been set, this method behaves identical to `clear`.
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
reset(): Promise<void>;
|
|
||||||
/**
|
|
||||||
* Returns a list of all key in the store.
|
|
||||||
*
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
keys(): Promise<string[]>;
|
|
||||||
/**
|
|
||||||
* Returns a list of all values in the store.
|
|
||||||
*
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
values(): Promise<string[]>;
|
|
||||||
/**
|
|
||||||
* Returns a list of all entries in the store.
|
|
||||||
*
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
entries<T>(): Promise<Array<[key: string, value: T]>>;
|
|
||||||
/**
|
|
||||||
* Returns the number of key-value pairs in the store.
|
|
||||||
*
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
length(): Promise<string[]>;
|
|
||||||
/**
|
|
||||||
* Attempts to load the on-disk state at the stores `path` into memory.
|
|
||||||
*
|
|
||||||
* This method is useful if the on-disk state was edited by the user and you want to synchronize the changes.
|
|
||||||
*
|
|
||||||
* Note: This method does not emit change events.
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
load(): Promise<void>;
|
|
||||||
/**
|
|
||||||
* Saves the store to disk at the stores `path`.
|
|
||||||
*
|
|
||||||
* As the store is only persistet to disk before the apps exit, changes might be lost in a crash.
|
|
||||||
* This method let's you persist the store to disk whenever you deem necessary.
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
save(): Promise<void>;
|
|
||||||
/**
|
|
||||||
* Listen to changes on a store key.
|
|
||||||
* @param key
|
|
||||||
* @param cb
|
|
||||||
* @returns A promise resolving to a function to unlisten to the event.
|
|
||||||
*/
|
|
||||||
onKeyChange<T>(key: string, cb: (value: T | null) => void): Promise<UnlistenFn>;
|
|
||||||
/**
|
|
||||||
* Listen to changes on the store.
|
|
||||||
* @param cb
|
|
||||||
* @returns A promise resolving to a function to unlisten to the event.
|
|
||||||
*/
|
|
||||||
onChange(cb: (key: string, value: unknown) => void): Promise<UnlistenFn>;
|
|
||||||
}
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,177 +0,0 @@
|
|||||||
import { invoke } from '@tauri-apps/api/tauri';
|
|
||||||
import { appWindow } from '@tauri-apps/api/window';
|
|
||||||
|
|
||||||
// Copyright 2021 Tauri Programme within The Commons Conservancy
|
|
||||||
/**
|
|
||||||
* A key-value store persisted by the backend layer.
|
|
||||||
*/
|
|
||||||
class Store {
|
|
||||||
constructor(path) {
|
|
||||||
this.path = path;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Inserts a key-value pair into the store.
|
|
||||||
*
|
|
||||||
* @param key
|
|
||||||
* @param value
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
async set(key, value) {
|
|
||||||
return await invoke("plugin:store|set", {
|
|
||||||
path: this.path,
|
|
||||||
key,
|
|
||||||
value,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Returns the value for the given `key` or `null` the key does not exist.
|
|
||||||
*
|
|
||||||
* @param key
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
async get(key) {
|
|
||||||
return await invoke("plugin:store|get", {
|
|
||||||
path: this.path,
|
|
||||||
key,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Returns `true` if the given `key` exists in the store.
|
|
||||||
*
|
|
||||||
* @param key
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
async has(key) {
|
|
||||||
return await invoke("plugin:store|has", {
|
|
||||||
path: this.path,
|
|
||||||
key,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Removes a key-value pair from the store.
|
|
||||||
*
|
|
||||||
* @param key
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
async delete(key) {
|
|
||||||
return await invoke("plugin:store|delete", {
|
|
||||||
path: this.path,
|
|
||||||
key,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Clears the store, removing all key-value pairs.
|
|
||||||
*
|
|
||||||
* Note: To clear the storage and reset it to it's `default` value, use `reset` instead.
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
async clear() {
|
|
||||||
return await invoke("plugin:store|clear", {
|
|
||||||
path: this.path,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Resets the store to it's `default` value.
|
|
||||||
*
|
|
||||||
* If no default value has been set, this method behaves identical to `clear`.
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
async reset() {
|
|
||||||
return await invoke("plugin:store|reset", {
|
|
||||||
path: this.path,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Returns a list of all key in the store.
|
|
||||||
*
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
async keys() {
|
|
||||||
return await invoke("plugin:store|keys", {
|
|
||||||
path: this.path,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Returns a list of all values in the store.
|
|
||||||
*
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
async values() {
|
|
||||||
return await invoke("plugin:store|values", {
|
|
||||||
path: this.path,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Returns a list of all entries in the store.
|
|
||||||
*
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
async entries() {
|
|
||||||
return await invoke("plugin:store|entries", {
|
|
||||||
path: this.path,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Returns the number of key-value pairs in the store.
|
|
||||||
*
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
async length() {
|
|
||||||
return await invoke("plugin:store|length", {
|
|
||||||
path: this.path,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Attempts to load the on-disk state at the stores `path` into memory.
|
|
||||||
*
|
|
||||||
* This method is useful if the on-disk state was edited by the user and you want to synchronize the changes.
|
|
||||||
*
|
|
||||||
* Note: This method does not emit change events.
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
async load() {
|
|
||||||
return await invoke("plugin:store|load", {
|
|
||||||
path: this.path,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Saves the store to disk at the stores `path`.
|
|
||||||
*
|
|
||||||
* As the store is only persisted to disk before the apps exit, changes might be lost in a crash.
|
|
||||||
* This method lets you persist the store to disk whenever you deem necessary.
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
async save() {
|
|
||||||
return await invoke("plugin:store|save", {
|
|
||||||
path: this.path,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Listen to changes on a store key.
|
|
||||||
* @param key
|
|
||||||
* @param cb
|
|
||||||
* @returns A promise resolving to a function to unlisten to the event.
|
|
||||||
*/
|
|
||||||
async onKeyChange(key, cb) {
|
|
||||||
return await appWindow.listen("store://change", (event) => {
|
|
||||||
if (event.payload.path === this.path && event.payload.key === key) {
|
|
||||||
cb(event.payload.value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Listen to changes on the store.
|
|
||||||
* @param cb
|
|
||||||
* @returns A promise resolving to a function to unlisten to the event.
|
|
||||||
*/
|
|
||||||
async onChange(cb) {
|
|
||||||
return await appWindow.listen("store://change", (event) => {
|
|
||||||
if (event.payload.path === this.path) {
|
|
||||||
cb(event.payload.key, event.payload.value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export { Store };
|
|
||||||
//# sourceMappingURL=index.mjs.map
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"index.mjs","sources":["../index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAAA;AAcA;;AAEG;MACU,KAAK,CAAA;AAEhB,IAAA,WAAA,CAAY,IAAY,EAAA;AACtB,QAAA,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;KAClB;AAED;;;;;;AAMG;AACH,IAAA,MAAM,GAAG,CAAC,GAAW,EAAE,KAAc,EAAA;AACnC,QAAA,OAAO,MAAM,MAAM,CAAC,kBAAkB,EAAE;YACtC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,GAAG;YACH,KAAK;AACN,SAAA,CAAC,CAAC;KACJ;AAED;;;;;AAKG;IACH,MAAM,GAAG,CAAI,GAAW,EAAA;AACtB,QAAA,OAAO,MAAM,MAAM,CAAC,kBAAkB,EAAE;YACtC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,GAAG;AACJ,SAAA,CAAC,CAAC;KACJ;AAED;;;;;AAKG;IACH,MAAM,GAAG,CAAC,GAAW,EAAA;AACnB,QAAA,OAAO,MAAM,MAAM,CAAC,kBAAkB,EAAE;YACtC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,GAAG;AACJ,SAAA,CAAC,C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mB,EAAE;YACvC,IAAI,EAAE,IAAI,CAAC,IAAI;AAChB,SAAA,CAAC,CAAC;KACJ;AAED;;;;;;AAMG;AACH,IAAA,MAAM,IAAI,GAAA;AACR,QAAA,OAAO,MAAM,MAAM,CAAC,mBAAmB,EAAE;YACvC,IAAI,EAAE,IAAI,CAAC,IAAI;AAChB,SAAA,CAAC,CAAC;KACJ;AAED;;;;;AAKG;AACH,IAAA,MAAM,WAAW,CACf,GAAW,EACX,EAA6B,EAAA;QAE7B,OAAO,MAAM,SAAS,CAAC,MAAM,CAC3B,gBAAgB,EAChB,CAAC,KAAK,KAAI;AACR,YAAA,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,KAAK,GAAG,EAAE;AACjE,gBAAA,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AACzB,aAAA;AACH,SAAC,CACF,CAAC;KACH;AAED;;;;AAIG;IACH,MAAM,QAAQ,CACZ,EAA0C,EAAA;QAE1C,OAAO,MAAM,SAAS,CAAC,MAAM,CAC3B,gBAAgB,EAChB,CAAC,KAAK,KAAI;YACR,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE;AACpC,gBAAA,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC5C,aAAA;AACH,SAAC,CACF,CAAC;KACH;AACF;;;;"}
|
|
@ -1,99 +0,0 @@
|
|||||||
type BytesDto = string | number[];
|
|
||||||
export type ClientPath = string | Iterable<number> | ArrayLike<number> | ArrayBuffer;
|
|
||||||
export type VaultPath = string | Iterable<number> | ArrayLike<number> | ArrayBuffer;
|
|
||||||
export type RecordPath = string | Iterable<number> | ArrayLike<number> | ArrayBuffer;
|
|
||||||
export type StoreKey = string | Iterable<number> | ArrayLike<number> | ArrayBuffer;
|
|
||||||
export interface ConnectionLimits {
|
|
||||||
maxPendingIncoming?: number;
|
|
||||||
maxPendingOutgoing?: number;
|
|
||||||
maxEstablishedIncoming?: number;
|
|
||||||
maxEstablishedOutgoing?: number;
|
|
||||||
maxEstablishedPerPeer?: number;
|
|
||||||
maxEstablishedTotal?: number;
|
|
||||||
}
|
|
||||||
export interface PeerAddress {
|
|
||||||
known: string[];
|
|
||||||
use_relay_fallback: boolean;
|
|
||||||
}
|
|
||||||
export interface AddressInfo {
|
|
||||||
peers: Map<string, PeerAddress>;
|
|
||||||
relays: string[];
|
|
||||||
}
|
|
||||||
export interface ClientAccess {
|
|
||||||
useVaultDefault?: boolean;
|
|
||||||
useVaultExceptions?: Map<VaultPath, boolean>;
|
|
||||||
writeVaultDefault?: boolean;
|
|
||||||
writeVaultExceptions?: Map<VaultPath, boolean>;
|
|
||||||
cloneVaultDefault?: boolean;
|
|
||||||
cloneVaultExceptions?: Map<VaultPath, boolean>;
|
|
||||||
readStore?: boolean;
|
|
||||||
writeStore?: boolean;
|
|
||||||
}
|
|
||||||
export interface Permissions {
|
|
||||||
default?: ClientAccess;
|
|
||||||
exceptions?: Map<VaultPath, ClientAccess>;
|
|
||||||
}
|
|
||||||
export interface NetworkConfig {
|
|
||||||
requestTimeout?: Duration;
|
|
||||||
connectionTimeout?: Duration;
|
|
||||||
connectionsLimit?: ConnectionLimits;
|
|
||||||
enableMdns?: boolean;
|
|
||||||
enableRelay?: boolean;
|
|
||||||
addresses?: AddressInfo;
|
|
||||||
peerPermissions?: Map<string, Permissions>;
|
|
||||||
permissionsDefault?: Permissions;
|
|
||||||
}
|
|
||||||
export interface Duration {
|
|
||||||
secs: number;
|
|
||||||
nanos: number;
|
|
||||||
}
|
|
||||||
export declare class Location {
|
|
||||||
type: string;
|
|
||||||
payload: Record<string, unknown>;
|
|
||||||
constructor(type: string, payload: Record<string, unknown>);
|
|
||||||
static generic(vault: VaultPath, record: RecordPath): Location;
|
|
||||||
static counter(vault: VaultPath, counter: number): Location;
|
|
||||||
}
|
|
||||||
declare class ProcedureExecutor {
|
|
||||||
procedureArgs: Record<string, unknown>;
|
|
||||||
constructor(procedureArgs: Record<string, unknown>);
|
|
||||||
generateSLIP10Seed(outputLocation: Location, sizeBytes?: number): Promise<Uint8Array>;
|
|
||||||
deriveSLIP10(chain: number[], source: "Seed" | "Key", sourceLocation: Location, outputLocation: Location): Promise<Uint8Array>;
|
|
||||||
recoverBIP39(mnemonic: string, outputLocation: Location, passphrase?: string): Promise<Uint8Array>;
|
|
||||||
generateBIP39(outputLocation: Location, passphrase?: string): Promise<Uint8Array>;
|
|
||||||
getEd25519PublicKey(privateKeyLocation: Location): Promise<Uint8Array>;
|
|
||||||
signEd25519(privateKeyLocation: Location, msg: string): Promise<Uint8Array>;
|
|
||||||
}
|
|
||||||
export declare class Client {
|
|
||||||
path: string;
|
|
||||||
name: BytesDto;
|
|
||||||
constructor(path: string, name: ClientPath);
|
|
||||||
getVault(name: VaultPath): Vault;
|
|
||||||
getStore(): Store;
|
|
||||||
}
|
|
||||||
export declare class Store {
|
|
||||||
path: string;
|
|
||||||
client: BytesDto;
|
|
||||||
constructor(path: string, client: BytesDto);
|
|
||||||
get(key: StoreKey): Promise<Uint8Array>;
|
|
||||||
insert(key: StoreKey, value: number[], lifetime?: Duration): Promise<void>;
|
|
||||||
remove(key: StoreKey): Promise<Uint8Array | null>;
|
|
||||||
}
|
|
||||||
export declare class Vault extends ProcedureExecutor {
|
|
||||||
path: string;
|
|
||||||
client: BytesDto;
|
|
||||||
name: BytesDto;
|
|
||||||
constructor(path: string, client: ClientPath, name: VaultPath);
|
|
||||||
insert(recordPath: RecordPath, secret: number[]): Promise<void>;
|
|
||||||
remove(location: Location): Promise<void>;
|
|
||||||
}
|
|
||||||
export declare class Stronghold {
|
|
||||||
path: string;
|
|
||||||
constructor(path: string, password: string);
|
|
||||||
private reload;
|
|
||||||
unload(): Promise<void>;
|
|
||||||
loadClient(client: ClientPath): Promise<Client>;
|
|
||||||
createClient(client: ClientPath): Promise<Client>;
|
|
||||||
save(): Promise<void>;
|
|
||||||
}
|
|
||||||
export {};
|
|
@ -1,217 +0,0 @@
|
|||||||
var d=Object.defineProperty;var e=(c,a)=>{for(var b in a)d(c,b,{get:a[b],enumerable:!0});};
|
|
||||||
|
|
||||||
var f={};e(f,{convertFileSrc:()=>w,invoke:()=>c,transformCallback:()=>s});function u(){return window.crypto.getRandomValues(new Uint32Array(1))[0]}function s(e,r=!1){let n=u(),t=`_${n}`;return Object.defineProperty(window,t,{value:o=>(r&&Reflect.deleteProperty(window,t),e==null?void 0:e(o)),writable:!1,configurable:!0}),n}async function c(e,r={}){return new Promise((n,t)=>{let o=s(i=>{n(i),Reflect.deleteProperty(window,`_${a}`);},!0),a=s(i=>{t(i),Reflect.deleteProperty(window,`_${o}`);},!0);window.__TAURI_IPC__({cmd:e,callback:o,error:a,...r});})}function w(e,r="asset"){let n=encodeURIComponent(e);return navigator.userAgent.includes("Windows")?`https://${r}.localhost/${n}`:`${r}://localhost/${n}`}
|
|
||||||
|
|
||||||
function toBytesDto(v) {
|
|
||||||
if (typeof v === "string") {
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
return Array.from(v instanceof ArrayBuffer ? new Uint8Array(v) : v);
|
|
||||||
}
|
|
||||||
class Location {
|
|
||||||
constructor(type, payload) {
|
|
||||||
this.type = type;
|
|
||||||
this.payload = payload;
|
|
||||||
}
|
|
||||||
static generic(vault, record) {
|
|
||||||
return new Location("Generic", {
|
|
||||||
vault: toBytesDto(vault),
|
|
||||||
record: toBytesDto(record),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
static counter(vault, counter) {
|
|
||||||
return new Location("Counter", {
|
|
||||||
vault: toBytesDto(vault),
|
|
||||||
counter,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class ProcedureExecutor {
|
|
||||||
constructor(procedureArgs) {
|
|
||||||
this.procedureArgs = procedureArgs;
|
|
||||||
}
|
|
||||||
async generateSLIP10Seed(outputLocation, sizeBytes) {
|
|
||||||
return await c("plugin:stronghold|execute_procedure", {
|
|
||||||
...this.procedureArgs,
|
|
||||||
procedure: {
|
|
||||||
type: "SLIP10Generate",
|
|
||||||
payload: {
|
|
||||||
output: outputLocation,
|
|
||||||
sizeBytes,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}).then((n) => Uint8Array.from(n));
|
|
||||||
}
|
|
||||||
async deriveSLIP10(chain, source, sourceLocation, outputLocation) {
|
|
||||||
return await c("plugin:stronghold|execute_procedure", {
|
|
||||||
...this.procedureArgs,
|
|
||||||
procedure: {
|
|
||||||
type: "SLIP10Derive",
|
|
||||||
payload: {
|
|
||||||
chain,
|
|
||||||
input: {
|
|
||||||
type: source,
|
|
||||||
payload: sourceLocation,
|
|
||||||
},
|
|
||||||
output: outputLocation,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}).then((n) => Uint8Array.from(n));
|
|
||||||
}
|
|
||||||
async recoverBIP39(mnemonic, outputLocation, passphrase) {
|
|
||||||
return await c("plugin:stronghold|execute_procedure", {
|
|
||||||
...this.procedureArgs,
|
|
||||||
procedure: {
|
|
||||||
type: "BIP39Recover",
|
|
||||||
payload: {
|
|
||||||
mnemonic,
|
|
||||||
passphrase,
|
|
||||||
output: outputLocation,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}).then((n) => Uint8Array.from(n));
|
|
||||||
}
|
|
||||||
async generateBIP39(outputLocation, passphrase) {
|
|
||||||
return await c("plugin:stronghold|execute_procedure", {
|
|
||||||
...this.procedureArgs,
|
|
||||||
procedure: {
|
|
||||||
type: "BIP39Generate",
|
|
||||||
payload: {
|
|
||||||
output: outputLocation,
|
|
||||||
passphrase,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}).then((n) => Uint8Array.from(n));
|
|
||||||
}
|
|
||||||
async getEd25519PublicKey(privateKeyLocation) {
|
|
||||||
return await c("plugin:stronghold|execute_procedure", {
|
|
||||||
...this.procedureArgs,
|
|
||||||
procedure: {
|
|
||||||
type: "PublicKey",
|
|
||||||
payload: {
|
|
||||||
type: "Ed25519",
|
|
||||||
privateKey: privateKeyLocation,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}).then((n) => Uint8Array.from(n));
|
|
||||||
}
|
|
||||||
async signEd25519(privateKeyLocation, msg) {
|
|
||||||
return await c("plugin:stronghold|execute_procedure", {
|
|
||||||
...this.procedureArgs,
|
|
||||||
procedure: {
|
|
||||||
type: "Ed25519Sign",
|
|
||||||
payload: {
|
|
||||||
privateKey: privateKeyLocation,
|
|
||||||
msg,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}).then((n) => Uint8Array.from(n));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class Client {
|
|
||||||
constructor(path, name) {
|
|
||||||
this.path = path;
|
|
||||||
this.name = toBytesDto(name);
|
|
||||||
}
|
|
||||||
getVault(name) {
|
|
||||||
return new Vault(this.path, this.name, toBytesDto(name));
|
|
||||||
}
|
|
||||||
getStore() {
|
|
||||||
return new Store(this.path, this.name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class Store {
|
|
||||||
constructor(path, client) {
|
|
||||||
this.path = path;
|
|
||||||
this.client = client;
|
|
||||||
}
|
|
||||||
async get(key) {
|
|
||||||
return await c("plugin:stronghold|get_store_record", {
|
|
||||||
snapshotPath: this.path,
|
|
||||||
client: this.client,
|
|
||||||
key: toBytesDto(key),
|
|
||||||
}).then((v) => Uint8Array.from(v));
|
|
||||||
}
|
|
||||||
async insert(key, value, lifetime) {
|
|
||||||
return await c("plugin:stronghold|save_store_record", {
|
|
||||||
snapshotPath: this.path,
|
|
||||||
client: this.client,
|
|
||||||
key: toBytesDto(key),
|
|
||||||
value,
|
|
||||||
lifetime,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
async remove(key) {
|
|
||||||
return await c("plugin:stronghold|remove_store_record", {
|
|
||||||
snapshotPath: this.path,
|
|
||||||
client: this.client,
|
|
||||||
key: toBytesDto(key),
|
|
||||||
}).then((v) => (v != null ? Uint8Array.from(v) : null));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class Vault extends ProcedureExecutor {
|
|
||||||
constructor(path, client, name) {
|
|
||||||
super({
|
|
||||||
snapshotPath: path,
|
|
||||||
client,
|
|
||||||
vault: name,
|
|
||||||
});
|
|
||||||
this.path = path;
|
|
||||||
this.client = toBytesDto(client);
|
|
||||||
this.name = toBytesDto(name);
|
|
||||||
}
|
|
||||||
async insert(recordPath, secret) {
|
|
||||||
return await c("plugin:stronghold|save_secret", {
|
|
||||||
snapshotPath: this.path,
|
|
||||||
client: this.client,
|
|
||||||
vault: this.name,
|
|
||||||
recordPath: toBytesDto(recordPath),
|
|
||||||
secret,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
async remove(location) {
|
|
||||||
return await c("plugin:stronghold|remove_secret", {
|
|
||||||
snapshotPath: this.path,
|
|
||||||
client: this.client,
|
|
||||||
vault: this.name,
|
|
||||||
location,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class Stronghold {
|
|
||||||
constructor(path, password) {
|
|
||||||
this.path = path;
|
|
||||||
void this.reload(password);
|
|
||||||
}
|
|
||||||
async reload(password) {
|
|
||||||
return await c("plugin:stronghold|initialize", {
|
|
||||||
snapshotPath: this.path,
|
|
||||||
password,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
async unload() {
|
|
||||||
return await c("plugin:stronghold|destroy", {
|
|
||||||
snapshotPath: this.path,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
async loadClient(client) {
|
|
||||||
return await c("plugin:stronghold|load_client", {
|
|
||||||
snapshotPath: this.path,
|
|
||||||
client: toBytesDto(client),
|
|
||||||
}).then(() => new Client(this.path, client));
|
|
||||||
}
|
|
||||||
async createClient(client) {
|
|
||||||
return await c("plugin:stronghold|create_client", {
|
|
||||||
snapshotPath: this.path,
|
|
||||||
client: toBytesDto(client),
|
|
||||||
}).then(() => new Client(this.path, client));
|
|
||||||
}
|
|
||||||
async save() {
|
|
||||||
return await c("plugin:stronghold|save", {
|
|
||||||
snapshotPath: this.path,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export { Client, Location, Store, Stronghold, Vault };
|
|
||||||
//# sourceMappingURL=index.min.js.map
|
|
File diff suppressed because one or more lines are too long
@ -1,215 +0,0 @@
|
|||||||
import { invoke } from '@tauri-apps/api/tauri';
|
|
||||||
|
|
||||||
function toBytesDto(v) {
|
|
||||||
if (typeof v === "string") {
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
return Array.from(v instanceof ArrayBuffer ? new Uint8Array(v) : v);
|
|
||||||
}
|
|
||||||
class Location {
|
|
||||||
constructor(type, payload) {
|
|
||||||
this.type = type;
|
|
||||||
this.payload = payload;
|
|
||||||
}
|
|
||||||
static generic(vault, record) {
|
|
||||||
return new Location("Generic", {
|
|
||||||
vault: toBytesDto(vault),
|
|
||||||
record: toBytesDto(record),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
static counter(vault, counter) {
|
|
||||||
return new Location("Counter", {
|
|
||||||
vault: toBytesDto(vault),
|
|
||||||
counter,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class ProcedureExecutor {
|
|
||||||
constructor(procedureArgs) {
|
|
||||||
this.procedureArgs = procedureArgs;
|
|
||||||
}
|
|
||||||
async generateSLIP10Seed(outputLocation, sizeBytes) {
|
|
||||||
return await invoke("plugin:stronghold|execute_procedure", {
|
|
||||||
...this.procedureArgs,
|
|
||||||
procedure: {
|
|
||||||
type: "SLIP10Generate",
|
|
||||||
payload: {
|
|
||||||
output: outputLocation,
|
|
||||||
sizeBytes,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}).then((n) => Uint8Array.from(n));
|
|
||||||
}
|
|
||||||
async deriveSLIP10(chain, source, sourceLocation, outputLocation) {
|
|
||||||
return await invoke("plugin:stronghold|execute_procedure", {
|
|
||||||
...this.procedureArgs,
|
|
||||||
procedure: {
|
|
||||||
type: "SLIP10Derive",
|
|
||||||
payload: {
|
|
||||||
chain,
|
|
||||||
input: {
|
|
||||||
type: source,
|
|
||||||
payload: sourceLocation,
|
|
||||||
},
|
|
||||||
output: outputLocation,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}).then((n) => Uint8Array.from(n));
|
|
||||||
}
|
|
||||||
async recoverBIP39(mnemonic, outputLocation, passphrase) {
|
|
||||||
return await invoke("plugin:stronghold|execute_procedure", {
|
|
||||||
...this.procedureArgs,
|
|
||||||
procedure: {
|
|
||||||
type: "BIP39Recover",
|
|
||||||
payload: {
|
|
||||||
mnemonic,
|
|
||||||
passphrase,
|
|
||||||
output: outputLocation,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}).then((n) => Uint8Array.from(n));
|
|
||||||
}
|
|
||||||
async generateBIP39(outputLocation, passphrase) {
|
|
||||||
return await invoke("plugin:stronghold|execute_procedure", {
|
|
||||||
...this.procedureArgs,
|
|
||||||
procedure: {
|
|
||||||
type: "BIP39Generate",
|
|
||||||
payload: {
|
|
||||||
output: outputLocation,
|
|
||||||
passphrase,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}).then((n) => Uint8Array.from(n));
|
|
||||||
}
|
|
||||||
async getEd25519PublicKey(privateKeyLocation) {
|
|
||||||
return await invoke("plugin:stronghold|execute_procedure", {
|
|
||||||
...this.procedureArgs,
|
|
||||||
procedure: {
|
|
||||||
type: "PublicKey",
|
|
||||||
payload: {
|
|
||||||
type: "Ed25519",
|
|
||||||
privateKey: privateKeyLocation,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}).then((n) => Uint8Array.from(n));
|
|
||||||
}
|
|
||||||
async signEd25519(privateKeyLocation, msg) {
|
|
||||||
return await invoke("plugin:stronghold|execute_procedure", {
|
|
||||||
...this.procedureArgs,
|
|
||||||
procedure: {
|
|
||||||
type: "Ed25519Sign",
|
|
||||||
payload: {
|
|
||||||
privateKey: privateKeyLocation,
|
|
||||||
msg,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}).then((n) => Uint8Array.from(n));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class Client {
|
|
||||||
constructor(path, name) {
|
|
||||||
this.path = path;
|
|
||||||
this.name = toBytesDto(name);
|
|
||||||
}
|
|
||||||
getVault(name) {
|
|
||||||
return new Vault(this.path, this.name, toBytesDto(name));
|
|
||||||
}
|
|
||||||
getStore() {
|
|
||||||
return new Store(this.path, this.name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class Store {
|
|
||||||
constructor(path, client) {
|
|
||||||
this.path = path;
|
|
||||||
this.client = client;
|
|
||||||
}
|
|
||||||
async get(key) {
|
|
||||||
return await invoke("plugin:stronghold|get_store_record", {
|
|
||||||
snapshotPath: this.path,
|
|
||||||
client: this.client,
|
|
||||||
key: toBytesDto(key),
|
|
||||||
}).then((v) => Uint8Array.from(v));
|
|
||||||
}
|
|
||||||
async insert(key, value, lifetime) {
|
|
||||||
return await invoke("plugin:stronghold|save_store_record", {
|
|
||||||
snapshotPath: this.path,
|
|
||||||
client: this.client,
|
|
||||||
key: toBytesDto(key),
|
|
||||||
value,
|
|
||||||
lifetime,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
async remove(key) {
|
|
||||||
return await invoke("plugin:stronghold|remove_store_record", {
|
|
||||||
snapshotPath: this.path,
|
|
||||||
client: this.client,
|
|
||||||
key: toBytesDto(key),
|
|
||||||
}).then((v) => (v != null ? Uint8Array.from(v) : null));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class Vault extends ProcedureExecutor {
|
|
||||||
constructor(path, client, name) {
|
|
||||||
super({
|
|
||||||
snapshotPath: path,
|
|
||||||
client,
|
|
||||||
vault: name,
|
|
||||||
});
|
|
||||||
this.path = path;
|
|
||||||
this.client = toBytesDto(client);
|
|
||||||
this.name = toBytesDto(name);
|
|
||||||
}
|
|
||||||
async insert(recordPath, secret) {
|
|
||||||
return await invoke("plugin:stronghold|save_secret", {
|
|
||||||
snapshotPath: this.path,
|
|
||||||
client: this.client,
|
|
||||||
vault: this.name,
|
|
||||||
recordPath: toBytesDto(recordPath),
|
|
||||||
secret,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
async remove(location) {
|
|
||||||
return await invoke("plugin:stronghold|remove_secret", {
|
|
||||||
snapshotPath: this.path,
|
|
||||||
client: this.client,
|
|
||||||
vault: this.name,
|
|
||||||
location,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class Stronghold {
|
|
||||||
constructor(path, password) {
|
|
||||||
this.path = path;
|
|
||||||
void this.reload(password);
|
|
||||||
}
|
|
||||||
async reload(password) {
|
|
||||||
return await invoke("plugin:stronghold|initialize", {
|
|
||||||
snapshotPath: this.path,
|
|
||||||
password,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
async unload() {
|
|
||||||
return await invoke("plugin:stronghold|destroy", {
|
|
||||||
snapshotPath: this.path,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
async loadClient(client) {
|
|
||||||
return await invoke("plugin:stronghold|load_client", {
|
|
||||||
snapshotPath: this.path,
|
|
||||||
client: toBytesDto(client),
|
|
||||||
}).then(() => new Client(this.path, client));
|
|
||||||
}
|
|
||||||
async createClient(client) {
|
|
||||||
return await invoke("plugin:stronghold|create_client", {
|
|
||||||
snapshotPath: this.path,
|
|
||||||
client: toBytesDto(client),
|
|
||||||
}).then(() => new Client(this.path, client));
|
|
||||||
}
|
|
||||||
async save() {
|
|
||||||
return await invoke("plugin:stronghold|save", {
|
|
||||||
snapshotPath: this.path,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export { Client, Location, Store, Stronghold, Vault };
|
|
||||||
//# sourceMappingURL=index.mjs.map
|
|
File diff suppressed because one or more lines are too long
@ -1,3 +0,0 @@
|
|||||||
type ProgressHandler = (progress: number, total: number) => void;
|
|
||||||
export default function upload(url: string, filePath: string, progressHandler?: ProgressHandler, headers?: Map<string, string>): Promise<void>;
|
|
||||||
export {};
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,38 +0,0 @@
|
|||||||
import { invoke } from '@tauri-apps/api/tauri';
|
|
||||||
import { appWindow } from '@tauri-apps/api/window';
|
|
||||||
|
|
||||||
const handlers = new Map();
|
|
||||||
let listening = false;
|
|
||||||
async function listenToUploadEventIfNeeded() {
|
|
||||||
if (listening) {
|
|
||||||
return await Promise.resolve();
|
|
||||||
}
|
|
||||||
return await appWindow
|
|
||||||
.listen("upload://progress", ({ payload }) => {
|
|
||||||
const handler = handlers.get(payload.id);
|
|
||||||
if (handler != null) {
|
|
||||||
handler(payload.progress, payload.total);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
listening = true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
async function upload(url, filePath, progressHandler, headers) {
|
|
||||||
const ids = new Uint32Array(1);
|
|
||||||
window.crypto.getRandomValues(ids);
|
|
||||||
const id = ids[0];
|
|
||||||
if (progressHandler != null) {
|
|
||||||
handlers.set(id, progressHandler);
|
|
||||||
}
|
|
||||||
await listenToUploadEventIfNeeded();
|
|
||||||
await invoke("plugin:upload|upload", {
|
|
||||||
id,
|
|
||||||
url,
|
|
||||||
filePath,
|
|
||||||
headers: headers !== null && headers !== void 0 ? headers : {},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export { upload as default };
|
|
||||||
//# sourceMappingURL=index.mjs.map
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"index.mjs","sources":["../index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAUA,MAAM,QAAQ,GAAiC,IAAI,GAAG,EAAE,CAAC;AACzD,IAAI,SAAS,GAAG,KAAK,CAAC;AAEtB,eAAe,2BAA2B,GAAA;AACxC,IAAA,IAAI,SAAS,EAAE;AACb,QAAA,OAAO,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;AAChC,KAAA;AACD,IAAA,OAAO,MAAM,SAAS;SACnB,MAAM,CAAkB,mBAAmB,EAAE,CAAC,EAAE,OAAO,EAAE,KAAI;QAC5D,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACzC,IAAI,OAAO,IAAI,IAAI,EAAE;YACnB,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;AAC1C,SAAA;AACH,KAAC,CAAC;SACD,IAAI,CAAC,MAAK;QACT,SAAS,GAAG,IAAI,CAAC;AACnB,KAAC,CAAC,CAAC;AACP,CAAC;AAEc,eAAe,MAAM,CAClC,GAAW,EACX,QAAgB,EAChB,eAAiC,EACjC,OAA6B,EAAA;AAE7B,IAAA,MAAM,GAAG,GAAG,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;AAC/B,IAAA,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;AACnC,IAAA,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;IAElB,IAAI,eAAe,IAAI,IAAI,EAAE;AAC3B,QAAA,QAAQ,CAAC,GAAG,CAAC,EAAE,EAAE,eAAe,CAAC,CAAC;AACnC,KAAA;IAED,MAAM,2BAA2B,EAAE,CAAC;IAEpC,MAAM,MAAM,CAAC,sBAAsB,EAAE;QACnC,EAAE;QACF,GAAG;QACH,QAAQ;AACR,QAAA,OAAO,EAAE,OAAO,KAAA,IAAA,IAAP,OAAO,KAAP,KAAA,CAAA,GAAA,OAAO,GAAI,EAAE;AACvB,KAAA,CAAC,CAAC;AACL;;;;"}
|
|
@ -1,18 +0,0 @@
|
|||||||
export interface MessageKind<T, D> {
|
|
||||||
type: T;
|
|
||||||
data: D;
|
|
||||||
}
|
|
||||||
export interface CloseFrame {
|
|
||||||
code: number;
|
|
||||||
reason: string;
|
|
||||||
}
|
|
||||||
export type Message = MessageKind<"Text", string> | MessageKind<"Binary", number[]> | MessageKind<"Ping", number[]> | MessageKind<"Pong", number[]> | MessageKind<"Close", CloseFrame | null>;
|
|
||||||
export default class WebSocket {
|
|
||||||
id: number;
|
|
||||||
private readonly listeners;
|
|
||||||
constructor(id: number, listeners: Array<(arg: Message) => void>);
|
|
||||||
static connect(url: string, options?: unknown): Promise<WebSocket>;
|
|
||||||
addListener(cb: (arg: Message) => void): void;
|
|
||||||
send(message: Message | string | number[]): Promise<void>;
|
|
||||||
disconnect(): Promise<void>;
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
var d=Object.defineProperty;var e=(c,a)=>{for(var b in a)d(c,b,{get:a[b],enumerable:!0});};
|
|
||||||
|
|
||||||
var f={};e(f,{convertFileSrc:()=>w,invoke:()=>c,transformCallback:()=>s});function u(){return window.crypto.getRandomValues(new Uint32Array(1))[0]}function s(e,r=!1){let n=u(),t=`_${n}`;return Object.defineProperty(window,t,{value:o=>(r&&Reflect.deleteProperty(window,t),e==null?void 0:e(o)),writable:!1,configurable:!0}),n}async function c(e,r={}){return new Promise((n,t)=>{let o=s(i=>{n(i),Reflect.deleteProperty(window,`_${a}`);},!0),a=s(i=>{t(i),Reflect.deleteProperty(window,`_${o}`);},!0);window.__TAURI_IPC__({cmd:e,callback:o,error:a,...r});})}function w(e,r="asset"){let n=encodeURIComponent(e);return navigator.userAgent.includes("Windows")?`https://${r}.localhost/${n}`:`${r}://localhost/${n}`}
|
|
||||||
|
|
||||||
class WebSocket {
|
|
||||||
constructor(id, listeners) {
|
|
||||||
this.id = id;
|
|
||||||
this.listeners = listeners;
|
|
||||||
}
|
|
||||||
static async connect(url, options) {
|
|
||||||
const listeners = [];
|
|
||||||
const handler = (message) => {
|
|
||||||
listeners.forEach((l) => l(message));
|
|
||||||
};
|
|
||||||
return await c("plugin:websocket|connect", {
|
|
||||||
url,
|
|
||||||
callbackFunction: s(handler),
|
|
||||||
options,
|
|
||||||
}).then((id) => new WebSocket(id, listeners));
|
|
||||||
}
|
|
||||||
addListener(cb) {
|
|
||||||
this.listeners.push(cb);
|
|
||||||
}
|
|
||||||
async send(message) {
|
|
||||||
let m;
|
|
||||||
if (typeof message === "string") {
|
|
||||||
m = { type: "Text", data: message };
|
|
||||||
}
|
|
||||||
else if (typeof message === "object" && "type" in message) {
|
|
||||||
m = message;
|
|
||||||
}
|
|
||||||
else if (Array.isArray(message)) {
|
|
||||||
m = { type: "Binary", data: message };
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw new Error("invalid `message` type, expected a `{ type: string, data: any }` object, a string or a numeric array");
|
|
||||||
}
|
|
||||||
return await c("plugin:websocket|send", {
|
|
||||||
id: this.id,
|
|
||||||
message: m,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
async disconnect() {
|
|
||||||
return await this.send({
|
|
||||||
type: "Close",
|
|
||||||
data: {
|
|
||||||
code: 1000,
|
|
||||||
reason: "Disconnected by client",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export { WebSocket as default };
|
|
||||||
//# sourceMappingURL=index.min.js.map
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"index.min.js","sources":["../../../../node_modules/.pnpm/@tauri-apps+api@1.2.0/node_modules/@tauri-apps/api/chunk-FEIY7W7S.js","../../../../node_modules/.pnpm/@tauri-apps+api@1.2.0/node_modules/@tauri-apps/api/chunk-RCPA6UVN.js","../index.ts"],"sourcesContent":["var d=Object.defineProperty;var e=(c,a)=>{for(var b in a)d(c,b,{get:a[b],enumerable:!0})};export{e as a};\n","import{a as d}from\"./chunk-FEIY7W7S.js\";var f={};d(f,{convertFileSrc:()=>w,invoke:()=>c,transformCallback:()=>s});function u(){return window.crypto.getRandomValues(new Uint32Array(1))[0]}function s(e,r=!1){let n=u(),t=`_${n}`;return Object.defineProperty(window,t,{value:o=>(r&&Reflect.deleteProperty(window,t),e==null?void 0:e(o)),writable:!1,configurable:!0}),n}async function c(e,r={}){return new Promise((n,t)=>{let o=s(i=>{n(i),Reflect.deleteProperty(window,`_${a}`)},!0),a=s(i=>{t(i),Reflect.deleteProperty(window,`_${o}`)},!0);window.__TAURI_IPC__({cmd:e,callback:o,error:a,...r})})}function w(e,r=\"asset\"){let n=encodeURIComponent(e);return navigator.userAgent.includes(\"Windows\")?`https://${r}.localhost/${n}`:`${r}://localhost/${n}`}export{s as a,c as b,w as c,f as d};\n",null],"names":["d","invoke","transformCallback"],"mappings":"AAAA,IAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC;;ACAjD,IAAI,CAAC,CAAC,EAAE,CAACA,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,OAAO,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,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CAAC;AACrB,YAAA,IAAI,EAAE,OAAO;AACb,YAAA,IAAI,EAAE;AACJ,gBAAA,IAAI,EAAE,IAAI;AACV,gBAAA,MAAM,EAAE,wBAAwB;AACjC,aAAA;AACF,SAAA,CAAC,CAAC;KACJ;AACF;;;;"}
|
|
@ -1,53 +0,0 @@
|
|||||||
import { invoke, transformCallback } from '@tauri-apps/api/tauri';
|
|
||||||
|
|
||||||
class WebSocket {
|
|
||||||
constructor(id, listeners) {
|
|
||||||
this.id = id;
|
|
||||||
this.listeners = listeners;
|
|
||||||
}
|
|
||||||
static async connect(url, options) {
|
|
||||||
const listeners = [];
|
|
||||||
const handler = (message) => {
|
|
||||||
listeners.forEach((l) => l(message));
|
|
||||||
};
|
|
||||||
return await invoke("plugin:websocket|connect", {
|
|
||||||
url,
|
|
||||||
callbackFunction: transformCallback(handler),
|
|
||||||
options,
|
|
||||||
}).then((id) => new WebSocket(id, listeners));
|
|
||||||
}
|
|
||||||
addListener(cb) {
|
|
||||||
this.listeners.push(cb);
|
|
||||||
}
|
|
||||||
async send(message) {
|
|
||||||
let m;
|
|
||||||
if (typeof message === "string") {
|
|
||||||
m = { type: "Text", data: message };
|
|
||||||
}
|
|
||||||
else if (typeof message === "object" && "type" in message) {
|
|
||||||
m = message;
|
|
||||||
}
|
|
||||||
else if (Array.isArray(message)) {
|
|
||||||
m = { type: "Binary", data: message };
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw new Error("invalid `message` type, expected a `{ type: string, data: any }` object, a string or a numeric array");
|
|
||||||
}
|
|
||||||
return await invoke("plugin:websocket|send", {
|
|
||||||
id: this.id,
|
|
||||||
message: m,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
async disconnect() {
|
|
||||||
return await this.send({
|
|
||||||
type: "Close",
|
|
||||||
data: {
|
|
||||||
code: 1000,
|
|
||||||
reason: "Disconnected by client",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export { WebSocket as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