pull/468/head
FabianLars 2 years ago
parent e92a1b1f15
commit e99b14d2db
No known key found for this signature in database
GPG Key ID: 3B12BC1DEBF61125

@ -116,6 +116,6 @@ if (files.length > 0) {
console.log(missing.join("\n")); console.log(missing.join("\n"));
process.exit(1); process.exit(1);
} }
} },
); );
} }

@ -52,7 +52,7 @@ https.get(url, options, (response) => {
} }
} else if (kind === "npm") { } else if (kind === "npm") {
const versions = Object.keys(data.versions || {}).filter((v) => const versions = Object.keys(data.versions || {}).filter((v) =>
v.startsWith(target) v.startsWith(target),
); );
console.log(versions[versions.length - 1] || "0.0.0"); console.log(versions[versions.length - 1] || "0.0.0");
} }

@ -1,4 +1,4 @@
<!DOCTYPE html> <!doctype html>
<html lang="en" theme="dark"> <html lang="en" theme="dark">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />

@ -1,4 +1,4 @@
<!DOCTYPE html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />

@ -5,7 +5,7 @@ import { createConfig } from "../../shared/rollup.config.mjs";
export default createConfig({ export default createConfig({
input: "guest-js/index.ts", input: "guest-js/index.ts",
pkg: JSON.parse( pkg: JSON.parse(
readFileSync(new URL("./package.json", import.meta.url), "utf8") readFileSync(new URL("./package.json", import.meta.url), "utf8"),
), ),
external: [/^@tauri-apps\/api/], external: [/^@tauri-apps\/api/],
}); });

@ -93,7 +93,7 @@ const r2 = await auth.verifyRegistration(
challenge, challenge,
app, app,
registerResult.registerData, registerResult.registerData,
registerResult.clientData registerResult.clientData,
); );
const j2 = JSON.parse(r2); const j2 = JSON.parse(r2);
@ -108,7 +108,7 @@ const counter = await auth.verifySignature(
signData.signData, signData.signData,
clientData, clientData,
keyHandle, keyHandle,
pubkey pubkey,
); );
if (counter && counter > 0) { if (counter && counter > 0) {

@ -34,7 +34,7 @@ export class Authenticator {
application, application,
registerData, registerData,
clientData, clientData,
} },
); );
} }
@ -68,7 +68,7 @@ export class Authenticator {
clientData, clientData,
keyHandle, keyHandle,
pubkey, pubkey,
} },
); );
} }
} }

@ -5,7 +5,7 @@ import { createConfig } from "../../shared/rollup.config.mjs";
export default createConfig({ export default createConfig({
input: "guest-js/index.ts", input: "guest-js/index.ts",
pkg: JSON.parse( pkg: JSON.parse(
readFileSync(new URL("./package.json", import.meta.url), "utf8") readFileSync(new URL("./package.json", import.meta.url), "utf8"),
), ),
external: [/^@tauri-apps\/api/], external: [/^@tauri-apps\/api/],
}); });

@ -36,7 +36,7 @@ type ClipResponse = Clip<"PlainText", string>;
*/ */
async function writeText( async function writeText(
text: string, text: string,
opts?: { label?: string } opts?: { label?: string },
): Promise<void> { ): Promise<void> {
return window.__TAURI_INVOKE__("plugin:clipboard|write", { return window.__TAURI_INVOKE__("plugin:clipboard|write", {
data: { data: {
@ -60,7 +60,7 @@ async function writeText(
*/ */
async function readText(): Promise<string> { async function readText(): Promise<string> {
const kind: ClipResponse = await window.__TAURI_INVOKE__( const kind: ClipResponse = await window.__TAURI_INVOKE__(
"plugin:clipboard|read" "plugin:clipboard|read",
); );
return kind.options; return kind.options;
} }

@ -103,16 +103,16 @@ interface ConfirmDialogOptions {
} }
async function open( async function open(
options?: OpenDialogOptions & { multiple?: false; directory?: false } options?: OpenDialogOptions & { multiple?: false; directory?: false },
): Promise<null | FileResponse>; ): Promise<null | FileResponse>;
async function open( async function open(
options?: OpenDialogOptions & { multiple?: true; directory?: false } options?: OpenDialogOptions & { multiple?: true; directory?: false },
): Promise<null | FileResponse[]>; ): Promise<null | FileResponse[]>;
async function open( async function open(
options?: OpenDialogOptions & { multiple?: false; directory?: true } options?: OpenDialogOptions & { multiple?: false; directory?: true },
): Promise<null | string>; ): Promise<null | string>;
async function open( async function open(
options?: OpenDialogOptions & { multiple?: true; directory?: true } options?: OpenDialogOptions & { multiple?: true; directory?: true },
): Promise<null | string[]>; ): Promise<null | string[]>;
/** /**
* Open a file/directory selection dialog. * Open a file/directory selection dialog.
@ -167,7 +167,7 @@ async function open(
* @since 2.0.0 * @since 2.0.0
*/ */
async function open( async function open(
options: OpenDialogOptions = {} options: OpenDialogOptions = {},
): Promise<null | string | string[] | FileResponse | FileResponse[]> { ): Promise<null | string | string[] | FileResponse | FileResponse[]> {
if (typeof options === "object") { if (typeof options === "object") {
Object.freeze(options); Object.freeze(options);
@ -227,7 +227,7 @@ async function save(options: SaveDialogOptions = {}): Promise<string | null> {
*/ */
async function message( async function message(
message: string, message: string,
options?: string | MessageDialogOptions options?: string | MessageDialogOptions,
): Promise<void> { ): Promise<void> {
const opts = typeof options === "string" ? { title: options } : options; const opts = typeof options === "string" ? { title: options } : options;
return window.__TAURI_INVOKE__("plugin:dialog|message", { return window.__TAURI_INVOKE__("plugin:dialog|message", {
@ -256,7 +256,7 @@ async function message(
*/ */
async function ask( async function ask(
message: string, message: string,
options?: string | ConfirmDialogOptions options?: string | ConfirmDialogOptions,
): Promise<boolean> { ): Promise<boolean> {
const opts = typeof options === "string" ? { title: options } : options; const opts = typeof options === "string" ? { title: options } : options;
return window.__TAURI_INVOKE__("plugin:dialog|ask", { return window.__TAURI_INVOKE__("plugin:dialog|ask", {
@ -286,7 +286,7 @@ async function ask(
*/ */
async function confirm( async function confirm(
message: string, message: string,
options?: string | ConfirmDialogOptions options?: string | ConfirmDialogOptions,
): Promise<boolean> { ): Promise<boolean> {
const opts = typeof options === "string" ? { title: options } : options; const opts = typeof options === "string" ? { title: options } : options;
return window.__TAURI_INVOKE__("plugin:dialog|confirm", { return window.__TAURI_INVOKE__("plugin:dialog|confirm", {

@ -5,7 +5,7 @@ import { createConfig } from "../../shared/rollup.config.mjs";
export default createConfig({ export default createConfig({
input: "guest-js/index.ts", input: "guest-js/index.ts",
pkg: JSON.parse( pkg: JSON.parse(
readFileSync(new URL("./package.json", import.meta.url), "utf8") readFileSync(new URL("./package.json", import.meta.url), "utf8"),
), ),
external: [/^@tauri-apps\/api/], external: [/^@tauri-apps\/api/],
}); });

@ -229,7 +229,7 @@ interface FileEntry {
*/ */
async function readTextFile( async function readTextFile(
filePath: string, filePath: string,
options: FsOptions = {} options: FsOptions = {},
): Promise<string> { ): Promise<string> {
return await window.__TAURI_INVOKE__("plugin:fs|read_text_file", { return await window.__TAURI_INVOKE__("plugin:fs|read_text_file", {
path: filePath, path: filePath,
@ -250,7 +250,7 @@ async function readTextFile(
*/ */
async function readBinaryFile( async function readBinaryFile(
filePath: string, filePath: string,
options: FsOptions = {} options: FsOptions = {},
): Promise<Uint8Array> { ): Promise<Uint8Array> {
const arr = await window.__TAURI_INVOKE__<number[]>("plugin:fs|read_file", { const arr = await window.__TAURI_INVOKE__<number[]>("plugin:fs|read_file", {
path: filePath, path: filePath,
@ -274,7 +274,7 @@ async function readBinaryFile(
async function writeTextFile( async function writeTextFile(
path: string, path: string,
contents: string, contents: string,
options?: FsOptions options?: FsOptions,
): Promise<void>; ): Promise<void>;
/** /**
@ -291,7 +291,7 @@ async function writeTextFile(
*/ */
async function writeTextFile( async function writeTextFile(
file: FsTextFileOption, file: FsTextFileOption,
options?: FsOptions options?: FsOptions,
): Promise<void>; ): Promise<void>;
/** /**
@ -304,7 +304,7 @@ async function writeTextFile(
async function writeTextFile( async function writeTextFile(
path: string | FsTextFileOption, path: string | FsTextFileOption,
contents?: string | FsOptions, contents?: string | FsOptions,
options?: FsOptions options?: FsOptions,
): Promise<void> { ): Promise<void> {
if (typeof options === "object") { if (typeof options === "object") {
Object.freeze(options); Object.freeze(options);
@ -352,7 +352,7 @@ async function writeTextFile(
async function writeBinaryFile( async function writeBinaryFile(
path: string, path: string,
contents: BinaryFileContents, contents: BinaryFileContents,
options?: FsOptions options?: FsOptions,
): Promise<void>; ): Promise<void>;
/** /**
@ -372,7 +372,7 @@ async function writeBinaryFile(
*/ */
async function writeBinaryFile( async function writeBinaryFile(
file: FsBinaryFileOption, file: FsBinaryFileOption,
options?: FsOptions options?: FsOptions,
): Promise<void>; ): Promise<void>;
/** /**
@ -385,7 +385,7 @@ async function writeBinaryFile(
async function writeBinaryFile( async function writeBinaryFile(
path: string | FsBinaryFileOption, path: string | FsBinaryFileOption,
contents?: BinaryFileContents | FsOptions, contents?: BinaryFileContents | FsOptions,
options?: FsOptions options?: FsOptions,
): Promise<void> { ): Promise<void> {
if (typeof options === "object") { if (typeof options === "object") {
Object.freeze(options); Object.freeze(options);
@ -415,7 +415,7 @@ async function writeBinaryFile(
contents: Array.from( contents: Array.from(
file.contents instanceof ArrayBuffer file.contents instanceof ArrayBuffer
? new Uint8Array(file.contents) ? new Uint8Array(file.contents)
: file.contents : file.contents,
), ),
options: fileOptions, options: fileOptions,
}); });
@ -443,7 +443,7 @@ async function writeBinaryFile(
*/ */
async function readDir( async function readDir(
dir: string, dir: string,
options: FsDirOptions = {} options: FsDirOptions = {},
): Promise<FileEntry[]> { ): Promise<FileEntry[]> {
return await window.__TAURI_INVOKE__("plugin:fs|read_dir", { return await window.__TAURI_INVOKE__("plugin:fs|read_dir", {
path: dir, path: dir,
@ -468,7 +468,7 @@ async function readDir(
*/ */
async function createDir( async function createDir(
dir: string, dir: string,
options: FsDirOptions = {} options: FsDirOptions = {},
): Promise<void> { ): Promise<void> {
return await window.__TAURI_INVOKE__("plugin:fs|create_dir", { return await window.__TAURI_INVOKE__("plugin:fs|create_dir", {
path: dir, path: dir,
@ -492,7 +492,7 @@ async function createDir(
*/ */
async function removeDir( async function removeDir(
dir: string, dir: string,
options: FsDirOptions = {} options: FsDirOptions = {},
): Promise<void> { ): Promise<void> {
return await window.__TAURI_INVOKE__("plugin:fs|remove_dir", { return await window.__TAURI_INVOKE__("plugin:fs|remove_dir", {
path: dir, path: dir,
@ -516,7 +516,7 @@ async function removeDir(
async function copyFile( async function copyFile(
source: string, source: string,
destination: string, destination: string,
options: FsOptions = {} options: FsOptions = {},
): Promise<void> { ): Promise<void> {
return await window.__TAURI_INVOKE__("plugin:fs|copy_file", { return await window.__TAURI_INVOKE__("plugin:fs|copy_file", {
source, source,
@ -540,7 +540,7 @@ async function copyFile(
*/ */
async function removeFile( async function removeFile(
file: string, file: string,
options: FsOptions = {} options: FsOptions = {},
): Promise<void> { ): Promise<void> {
return await window.__TAURI_INVOKE__("plugin:fs|remove_file", { return await window.__TAURI_INVOKE__("plugin:fs|remove_file", {
path: file, path: file,
@ -564,7 +564,7 @@ async function removeFile(
async function renameFile( async function renameFile(
oldPath: string, oldPath: string,
newPath: string, newPath: string,
options: FsOptions = {} options: FsOptions = {},
): Promise<void> { ): Promise<void> {
return await window.__TAURI_INVOKE__("plugin:fs|rename_file", { return await window.__TAURI_INVOKE__("plugin:fs|rename_file", {
oldPath, oldPath,

@ -5,7 +5,7 @@ import { createConfig } from "../../shared/rollup.config.mjs";
export default createConfig({ export default createConfig({
input: "guest-js/index.ts", input: "guest-js/index.ts",
pkg: JSON.parse( pkg: JSON.parse(
readFileSync(new URL("./package.json", import.meta.url), "utf8") readFileSync(new URL("./package.json", import.meta.url), "utf8"),
), ),
external: [/^@tauri-apps\/api/], external: [/^@tauri-apps\/api/],
}); });

@ -36,7 +36,7 @@ export type ShortcutHandler = (shortcut: string) => void;
*/ */
async function register( async function register(
shortcut: string, shortcut: string,
handler: ShortcutHandler handler: ShortcutHandler,
): Promise<void> { ): Promise<void> {
return await window.__TAURI_INVOKE__("plugin:globalShortcut|register", { return await window.__TAURI_INVOKE__("plugin:globalShortcut|register", {
shortcut, shortcut,
@ -61,7 +61,7 @@ async function register(
*/ */
async function registerAll( async function registerAll(
shortcuts: string[], shortcuts: string[],
handler: ShortcutHandler handler: ShortcutHandler,
): Promise<void> { ): Promise<void> {
return await window.__TAURI_INVOKE__("plugin:globalShortcut|register_all", { return await window.__TAURI_INVOKE__("plugin:globalShortcut|register_all", {
shortcuts, shortcuts,

@ -5,7 +5,7 @@ import { createConfig } from "../../shared/rollup.config.mjs";
export default createConfig({ export default createConfig({
input: "guest-js/index.ts", input: "guest-js/index.ts",
pkg: JSON.parse( pkg: JSON.parse(
readFileSync(new URL("./package.json", import.meta.url), "utf8") readFileSync(new URL("./package.json", import.meta.url), "utf8"),
), ),
external: [/^@tauri-apps\/api/], external: [/^@tauri-apps\/api/],
}); });

@ -123,7 +123,7 @@ class Body {
const append = ( const append = (
key: string, key: string,
v: string | Uint8Array | FilePart<Uint8Array> | File v: string | Uint8Array | FilePart<Uint8Array> | File,
): void => { ): void => {
if (v !== null) { if (v !== null) {
let r; let r;
@ -208,12 +208,12 @@ class Body {
* @since 2.0.0 * @since 2.0.0
*/ */
static bytes( static bytes(
bytes: Iterable<number> | ArrayLike<number> | ArrayBuffer bytes: Iterable<number> | ArrayLike<number> | ArrayBuffer,
): Body { ): Body {
// stringifying Uint8Array doesn't return an array of numbers, so we create one here // stringifying Uint8Array doesn't return an array of numbers, so we create one here
return new Body( return new Body(
"Bytes", "Bytes",
Array.from(bytes instanceof ArrayBuffer ? new Uint8Array(bytes) : bytes) Array.from(bytes instanceof ArrayBuffer ? new Uint8Array(bytes) : bytes),
); );
} }
} }
@ -349,7 +349,7 @@ class Client {
} else if (response.ok) { } else if (response.ok) {
throw Error( throw Error(
`Failed to parse response \`${response.data}\` as JSON: ${e}; `Failed to parse response \`${response.data}\` as JSON: ${e};
try setting the \`responseType\` option to \`ResponseType.Text\` or \`ResponseType.Binary\` if the API does not return a JSON response.` try setting the \`responseType\` option to \`ResponseType.Text\` or \`ResponseType.Binary\` if the API does not return a JSON response.`,
); );
} }
} }
@ -400,7 +400,7 @@ class Client {
async post<T>( async post<T>(
url: string, url: string,
body?: Body, body?: Body,
options?: RequestOptions options?: RequestOptions,
): Promise<Response<T>> { ): Promise<Response<T>> {
return this.request({ return this.request({
method: "POST", method: "POST",
@ -430,7 +430,7 @@ class Client {
async put<T>( async put<T>(
url: string, url: string,
body?: Body, body?: Body,
options?: RequestOptions options?: RequestOptions,
): Promise<Response<T>> { ): Promise<Response<T>> {
return this.request({ return this.request({
method: "PUT", method: "PUT",
@ -515,7 +515,7 @@ let defaultClient: Client | null = null;
*/ */
async function fetch<T>( async function fetch<T>(
url: string, url: string,
options?: FetchOptions options?: FetchOptions,
): Promise<Response<T>> { ): Promise<Response<T>> {
if (defaultClient === null) { if (defaultClient === null) {
defaultClient = await getClient(); defaultClient = await getClient();

@ -541,13 +541,13 @@ async function channels(): Promise<Channel[]> {
} }
async function onNotificationReceived( async function onNotificationReceived(
cb: (notification: Options) => void cb: (notification: Options) => void,
): Promise<PluginListener> { ): Promise<PluginListener> {
return addPluginListener("notification", "notification", cb); return addPluginListener("notification", "notification", cb);
} }
async function onAction( async function onAction(
cb: (notification: Options) => void cb: (notification: Options) => void,
): Promise<PluginListener> { ): Promise<PluginListener> {
return addPluginListener("notification", "actionPerformed", cb); return addPluginListener("notification", "actionPerformed", cb);
} }

@ -5,7 +5,7 @@ import { createConfig } from "../../shared/rollup.config.mjs";
export default createConfig({ export default createConfig({
input: "guest-js/index.ts", input: "guest-js/index.ts",
pkg: JSON.parse( pkg: JSON.parse(
readFileSync(new URL("./package.json", import.meta.url), "utf8") readFileSync(new URL("./package.json", import.meta.url), "utf8"),
), ),
external: [/^@tauri-apps\/api/], external: [/^@tauri-apps\/api/],
}); });

@ -5,7 +5,7 @@ import { createConfig } from "../../shared/rollup.config.mjs";
export default createConfig({ export default createConfig({
input: "guest-js/index.ts", input: "guest-js/index.ts",
pkg: JSON.parse( pkg: JSON.parse(
readFileSync(new URL("./package.json", import.meta.url), "utf8") readFileSync(new URL("./package.json", import.meta.url), "utf8"),
), ),
external: [/^@tauri-apps\/api/], external: [/^@tauri-apps\/api/],
}); });

@ -5,7 +5,7 @@ import { createConfig } from "../../shared/rollup.config.mjs";
export default createConfig({ export default createConfig({
input: "guest-js/index.ts", input: "guest-js/index.ts",
pkg: JSON.parse( pkg: JSON.parse(
readFileSync(new URL("./package.json", import.meta.url), "utf8") readFileSync(new URL("./package.json", import.meta.url), "utf8"),
), ),
external: [/^@tauri-apps\/api/], external: [/^@tauri-apps\/api/],
}); });

@ -122,7 +122,7 @@ async function execute<O extends IOPayload>(
onEvent: (event: CommandEvent<O>) => void, onEvent: (event: CommandEvent<O>) => void,
program: string, program: string,
args: string | string[] = [], args: string | string[] = [],
options?: InternalSpawnOptions options?: InternalSpawnOptions,
): Promise<number> { ): Promise<number> {
if (typeof args === "object") { if (typeof args === "object") {
Object.freeze(args); Object.freeze(args);
@ -153,7 +153,7 @@ class EventEmitter<E extends Record<string, any>> {
*/ */
addListener<N extends keyof E>( addListener<N extends keyof E>(
eventName: N, eventName: N,
listener: (arg: E[typeof eventName]) => void listener: (arg: E[typeof eventName]) => void,
): this { ): this {
return this.on(eventName, listener); return this.on(eventName, listener);
} }
@ -165,7 +165,7 @@ class EventEmitter<E extends Record<string, any>> {
*/ */
removeListener<N extends keyof E>( removeListener<N extends keyof E>(
eventName: N, eventName: N,
listener: (arg: E[typeof eventName]) => void listener: (arg: E[typeof eventName]) => void,
): this { ): this {
return this.off(eventName, listener); return this.off(eventName, listener);
} }
@ -182,7 +182,7 @@ class EventEmitter<E extends Record<string, any>> {
*/ */
on<N extends keyof E>( on<N extends keyof E>(
eventName: N, eventName: N,
listener: (arg: E[typeof eventName]) => void listener: (arg: E[typeof eventName]) => void,
): this { ): this {
if (eventName in this.eventListeners) { if (eventName in this.eventListeners) {
// eslint-disable-next-line security/detect-object-injection // eslint-disable-next-line security/detect-object-injection
@ -204,7 +204,7 @@ class EventEmitter<E extends Record<string, any>> {
*/ */
once<N extends keyof E>( once<N extends keyof E>(
eventName: N, eventName: N,
listener: (arg: E[typeof eventName]) => void listener: (arg: E[typeof eventName]) => void,
): this { ): this {
const wrapper = (arg: E[typeof eventName]): void => { const wrapper = (arg: E[typeof eventName]): void => {
this.removeListener(eventName, wrapper); this.removeListener(eventName, wrapper);
@ -222,12 +222,12 @@ class EventEmitter<E extends Record<string, any>> {
*/ */
off<N extends keyof E>( off<N extends keyof E>(
eventName: N, eventName: N,
listener: (arg: E[typeof eventName]) => void listener: (arg: E[typeof eventName]) => void,
): this { ): this {
if (eventName in this.eventListeners) { if (eventName in this.eventListeners) {
// eslint-disable-next-line security/detect-object-injection // eslint-disable-next-line security/detect-object-injection
this.eventListeners[eventName] = this.eventListeners[eventName].filter( this.eventListeners[eventName] = this.eventListeners[eventName].filter(
(l) => l !== listener (l) => l !== listener,
); );
} }
return this; return this;
@ -295,7 +295,7 @@ class EventEmitter<E extends Record<string, any>> {
*/ */
prependListener<N extends keyof E>( prependListener<N extends keyof E>(
eventName: N, eventName: N,
listener: (arg: E[typeof eventName]) => void listener: (arg: E[typeof eventName]) => void,
): this { ): this {
if (eventName in this.eventListeners) { if (eventName in this.eventListeners) {
// eslint-disable-next-line security/detect-object-injection // eslint-disable-next-line security/detect-object-injection
@ -317,7 +317,7 @@ class EventEmitter<E extends Record<string, any>> {
*/ */
prependOnceListener<N extends keyof E>( prependOnceListener<N extends keyof E>(
eventName: N, eventName: N,
listener: (arg: E[typeof eventName]) => void listener: (arg: E[typeof eventName]) => void,
): this { ): this {
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
const wrapper = (arg: any): void => { const wrapper = (arg: any): void => {
@ -434,7 +434,7 @@ class Command<O extends IOPayload> extends EventEmitter<CommandEvents> {
private constructor( private constructor(
program: string, program: string,
args: string | string[] = [], args: string | string[] = [],
options?: SpawnOptions options?: SpawnOptions,
) { ) {
super(); super();
this.program = program; this.program = program;
@ -446,12 +446,12 @@ class Command<O extends IOPayload> extends EventEmitter<CommandEvents> {
static create( static create(
program: string, program: string,
args?: string | string[], args?: string | string[],
options?: SpawnOptions & { encoding: "raw" } options?: SpawnOptions & { encoding: "raw" },
): Command<Uint8Array>; ): Command<Uint8Array>;
static create( static create(
program: string, program: string,
args?: string | string[], args?: string | string[],
options?: SpawnOptions options?: SpawnOptions,
): Command<string>; ): Command<string>;
/** /**
@ -469,7 +469,7 @@ class Command<O extends IOPayload> extends EventEmitter<CommandEvents> {
static create<O extends IOPayload>( static create<O extends IOPayload>(
program: string, program: string,
args: string | string[] = [], args: string | string[] = [],
options?: SpawnOptions options?: SpawnOptions,
): Command<O> { ): Command<O> {
return new Command(program, args, options); return new Command(program, args, options);
} }
@ -478,12 +478,12 @@ class Command<O extends IOPayload> extends EventEmitter<CommandEvents> {
static sidecar( static sidecar(
program: string, program: string,
args?: string | string[], args?: string | string[],
options?: SpawnOptions & { encoding: "raw" } options?: SpawnOptions & { encoding: "raw" },
): Command<Uint8Array>; ): Command<Uint8Array>;
static sidecar( static sidecar(
program: string, program: string,
args?: string | string[], args?: string | string[],
options?: SpawnOptions options?: SpawnOptions,
): Command<string>; ): Command<string>;
/** /**
@ -501,7 +501,7 @@ class Command<O extends IOPayload> extends EventEmitter<CommandEvents> {
static sidecar<O extends IOPayload>( static sidecar<O extends IOPayload>(
program: string, program: string,
args: string | string[] = [], args: string | string[] = [],
options?: SpawnOptions options?: SpawnOptions,
): Command<O> { ): Command<O> {
const instance = new Command<O>(program, args, options); const instance = new Command<O>(program, args, options);
instance.options.sidecar = true; instance.options.sidecar = true;
@ -535,7 +535,7 @@ class Command<O extends IOPayload> extends EventEmitter<CommandEvents> {
}, },
this.program, this.program,
this.args, this.args,
this.options this.options,
).then((pid) => new Child(pid)); ).then((pid) => new Child(pid));
} }

@ -5,7 +5,7 @@ import { createConfig } from "../../shared/rollup.config.mjs";
export default createConfig({ export default createConfig({
input: "guest-js/index.ts", input: "guest-js/index.ts",
pkg: JSON.parse( pkg: JSON.parse(
readFileSync(new URL("./package.json", import.meta.url), "utf8") readFileSync(new URL("./package.json", import.meta.url), "utf8"),
), ),
external: [/^@tauri-apps\/api/], external: [/^@tauri-apps\/api/],
}); });

@ -12,7 +12,7 @@
if ( if (
target.href && target.href &&
["http://", "https://", "mailto:", "tel:"].some((v) => ["http://", "https://", "mailto:", "tel:"].some((v) =>
target.href.startsWith(v) target.href.startsWith(v),
) && ) &&
target.target === "_blank" target.target === "_blank"
) { ) {

@ -31,7 +31,7 @@ export type StoreKey =
| ArrayBuffer; | ArrayBuffer;
function toBytesDto( function toBytesDto(
v: ClientPath | VaultPath | RecordPath | StoreKey v: ClientPath | VaultPath | RecordPath | StoreKey,
): string | number[] { ): string | number[] {
if (typeof v === "string") { if (typeof v === "string") {
return v; return v;
@ -133,7 +133,7 @@ class ProcedureExecutor {
*/ */
async generateSLIP10Seed( async generateSLIP10Seed(
outputLocation: Location, outputLocation: Location,
sizeBytes?: number sizeBytes?: number,
): Promise<Uint8Array> { ): Promise<Uint8Array> {
return await window return await window
.__TAURI_INVOKE__<number[]>("plugin:stronghold|execute_procedure", { .__TAURI_INVOKE__<number[]>("plugin:stronghold|execute_procedure", {
@ -162,7 +162,7 @@ class ProcedureExecutor {
chain: number[], chain: number[],
source: "Seed" | "Key", source: "Seed" | "Key",
sourceLocation: Location, sourceLocation: Location,
outputLocation: Location outputLocation: Location,
): Promise<Uint8Array> { ): Promise<Uint8Array> {
return await window return await window
.__TAURI_INVOKE__<number[]>("plugin:stronghold|execute_procedure", { .__TAURI_INVOKE__<number[]>("plugin:stronghold|execute_procedure", {
@ -193,7 +193,7 @@ class ProcedureExecutor {
async recoverBIP39( async recoverBIP39(
mnemonic: string, mnemonic: string,
outputLocation: Location, outputLocation: Location,
passphrase?: string passphrase?: string,
): Promise<Uint8Array> { ): Promise<Uint8Array> {
return await window return await window
.__TAURI_INVOKE__<number[]>("plugin:stronghold|execute_procedure", { .__TAURI_INVOKE__<number[]>("plugin:stronghold|execute_procedure", {
@ -219,7 +219,7 @@ class ProcedureExecutor {
*/ */
async generateBIP39( async generateBIP39(
outputLocation: Location, outputLocation: Location,
passphrase?: string passphrase?: string,
): Promise<Uint8Array> { ): Promise<Uint8Array> {
return await window return await window
.__TAURI_INVOKE__<number[]>("plugin:stronghold|execute_procedure", { .__TAURI_INVOKE__<number[]>("plugin:stronghold|execute_procedure", {
@ -267,7 +267,7 @@ class ProcedureExecutor {
*/ */
async signEd25519( async signEd25519(
privateKeyLocation: Location, privateKeyLocation: Location,
msg: string msg: string,
): Promise<Uint8Array> { ): Promise<Uint8Array> {
return await window return await window
.__TAURI_INVOKE__<number[]>("plugin:stronghold|execute_procedure", { .__TAURI_INVOKE__<number[]>("plugin:stronghold|execute_procedure", {
@ -330,7 +330,7 @@ export class Store {
async insert( async insert(
key: StoreKey, key: StoreKey,
value: number[], value: number[],
lifetime?: Duration lifetime?: Duration,
): Promise<void> { ): Promise<void> {
return await window.__TAURI_INVOKE__( return await window.__TAURI_INVOKE__(
"plugin:stronghold|save_store_record", "plugin:stronghold|save_store_record",
@ -340,7 +340,7 @@ export class Store {
key: toBytesDto(key), key: toBytesDto(key),
value, value,
lifetime, lifetime,
} },
); );
} }
@ -352,7 +352,7 @@ export class Store {
snapshotPath: this.path, snapshotPath: this.path,
client: this.client, client: this.client,
key: toBytesDto(key), key: toBytesDto(key),
} },
) )
.then((v) => (v != null ? Uint8Array.from(v) : null)); .then((v) => (v != null ? Uint8Array.from(v) : null));
} }

@ -40,7 +40,7 @@ class Update {
} }
async downloadAndInstall( async downloadAndInstall(
onEvent?: (progress: DownloadEvent) => void onEvent?: (progress: DownloadEvent) => void,
): Promise<void> { ): Promise<void> {
const channel = new Channel<DownloadEvent>(); const channel = new Channel<DownloadEvent>();
if (onEvent != null) { if (onEvent != null) {
@ -54,7 +54,7 @@ class Update {
async function check(options?: CheckOptions): Promise<Update> { async function check(options?: CheckOptions): Promise<Update> {
return invoke<UpdateResponse>("plugin:updater|check", { ...options }).then( return invoke<UpdateResponse>("plugin:updater|check", { ...options }).then(
(response) => new Update(response) (response) => new Update(response),
); );
} }

@ -5,7 +5,7 @@ import { createConfig } from "../../shared/rollup.config.mjs";
export default createConfig({ export default createConfig({
input: "guest-js/index.ts", input: "guest-js/index.ts",
pkg: JSON.parse( pkg: JSON.parse(
readFileSync(new URL("./package.json", import.meta.url), "utf8") readFileSync(new URL("./package.json", import.meta.url), "utf8"),
), ),
external: [/^@tauri-apps\/api/], external: [/^@tauri-apps\/api/],
}); });

@ -67,7 +67,7 @@ upload(
"https://example.com/file-upload", "https://example.com/file-upload",
"./path/to/my/file.txt", "./path/to/my/file.txt",
(progress, total) => console.log(`Uploaded ${progress} of ${total} bytes`), // a callback that will be called with the upload progress (progress, total) => console.log(`Uploaded ${progress} of ${total} bytes`), // a callback that will be called with the upload progress
{ "Content-Type": "text/plain" } // optional headers to send with the request { "Content-Type": "text/plain" }, // optional headers to send with the request
); );
``` ```
@ -78,7 +78,7 @@ download(
"https://example.com/file-download-link", "https://example.com/file-download-link",
"./path/to/save/my/file.txt", "./path/to/save/my/file.txt",
(progress, total) => console.log(`Downloaded ${progress} of ${total} bytes`), // a callback that will be called with the download progress (progress, total) => console.log(`Downloaded ${progress} of ${total} bytes`), // a callback that will be called with the download progress
{ "Content-Type": "text/plain" } // optional headers to send with the request { "Content-Type": "text/plain" }, // optional headers to send with the request
); );
``` ```

@ -258,7 +258,7 @@ function getAll(): WebviewWindow[] {
new WebviewWindow(w.label, { new WebviewWindow(w.label, {
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor // @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
skip: true, skip: true,
}) }),
); );
} }
@ -309,7 +309,7 @@ class WebviewWindowHandle {
*/ */
async listen<T>( async listen<T>(
event: EventName, event: EventName,
handler: EventCallback<T> handler: EventCallback<T>,
): Promise<UnlistenFn> { ): Promise<UnlistenFn> {
if (this._handleTauriEvent(event, handler)) { if (this._handleTauriEvent(event, handler)) {
return Promise.resolve(() => { return Promise.resolve(() => {
@ -435,7 +435,7 @@ class WindowManager extends WebviewWindowHandle {
"plugin:window|inner_position", "plugin:window|inner_position",
{ {
label: this.label, label: this.label,
} },
) )
.then(({ x, y }) => new PhysicalPosition(x, y)); .then(({ x, y }) => new PhysicalPosition(x, y));
} }
@ -458,7 +458,7 @@ class WindowManager extends WebviewWindowHandle {
"plugin:window|outer_position", "plugin:window|outer_position",
{ {
label: this.label, label: this.label,
} },
) )
.then(({ x, y }) => new PhysicalPosition(x, y)); .then(({ x, y }) => new PhysicalPosition(x, y));
} }
@ -482,7 +482,7 @@ class WindowManager extends WebviewWindowHandle {
"plugin:window|inner_size", "plugin:window|inner_size",
{ {
label: this.label, label: this.label,
} },
) )
.then(({ width, height }) => new PhysicalSize(width, height)); .then(({ width, height }) => new PhysicalSize(width, height));
} }
@ -506,7 +506,7 @@ class WindowManager extends WebviewWindowHandle {
"plugin:window|outer_size", "plugin:window|outer_size",
{ {
label: this.label, label: this.label,
} },
) )
.then(({ width, height }) => new PhysicalSize(width, height)); .then(({ width, height }) => new PhysicalSize(width, height));
} }
@ -782,7 +782,7 @@ class WindowManager extends WebviewWindowHandle {
* @since 2.0.0 * @since 2.0.0
*/ */
async requestUserAttention( async requestUserAttention(
requestType: UserAttentionType | null requestType: UserAttentionType | null,
): Promise<void> { ): Promise<void> {
let requestType_ = null; let requestType_ = null;
if (requestType) { if (requestType) {
@ -1182,7 +1182,7 @@ class WindowManager extends WebviewWindowHandle {
async setSize(size: LogicalSize | PhysicalSize): Promise<void> { async setSize(size: LogicalSize | PhysicalSize): Promise<void> {
if (!size || (size.type !== "Logical" && size.type !== "Physical")) { if (!size || (size.type !== "Logical" && size.type !== "Physical")) {
throw new Error( throw new Error(
"the `size` argument must be either a LogicalSize or a PhysicalSize instance" "the `size` argument must be either a LogicalSize or a PhysicalSize instance",
); );
} }
@ -1212,11 +1212,11 @@ class WindowManager extends WebviewWindowHandle {
* @since 2.0.0 * @since 2.0.0
*/ */
async setMinSize( async setMinSize(
size: LogicalSize | PhysicalSize | null | undefined size: LogicalSize | PhysicalSize | null | undefined,
): Promise<void> { ): Promise<void> {
if (size && size.type !== "Logical" && size.type !== "Physical") { if (size && size.type !== "Logical" && size.type !== "Physical") {
throw new Error( throw new Error(
"the `size` argument must be either a LogicalSize or a PhysicalSize instance" "the `size` argument must be either a LogicalSize or a PhysicalSize instance",
); );
} }
@ -1248,11 +1248,11 @@ class WindowManager extends WebviewWindowHandle {
* @since 2.0.0 * @since 2.0.0
*/ */
async setMaxSize( async setMaxSize(
size: LogicalSize | PhysicalSize | null | undefined size: LogicalSize | PhysicalSize | null | undefined,
): Promise<void> { ): Promise<void> {
if (size && size.type !== "Logical" && size.type !== "Physical") { if (size && size.type !== "Logical" && size.type !== "Physical") {
throw new Error( throw new Error(
"the `size` argument must be either a LogicalSize or a PhysicalSize instance" "the `size` argument must be either a LogicalSize or a PhysicalSize instance",
); );
} }
@ -1284,14 +1284,14 @@ class WindowManager extends WebviewWindowHandle {
* @since 2.0.0 * @since 2.0.0
*/ */
async setPosition( async setPosition(
position: LogicalPosition | PhysicalPosition position: LogicalPosition | PhysicalPosition,
): Promise<void> { ): Promise<void> {
if ( if (
!position || !position ||
(position.type !== "Logical" && position.type !== "Physical") (position.type !== "Logical" && position.type !== "Physical")
) { ) {
throw new Error( throw new Error(
"the `position` argument must be either a LogicalPosition or a PhysicalPosition instance" "the `position` argument must be either a LogicalPosition or a PhysicalPosition instance",
); );
} }
@ -1484,14 +1484,14 @@ class WindowManager extends WebviewWindowHandle {
* @since 2.0.0 * @since 2.0.0
*/ */
async setCursorPosition( async setCursorPosition(
position: LogicalPosition | PhysicalPosition position: LogicalPosition | PhysicalPosition,
): Promise<void> { ): Promise<void> {
if ( if (
!position || !position ||
(position.type !== "Logical" && position.type !== "Physical") (position.type !== "Logical" && position.type !== "Physical")
) { ) {
throw new Error( throw new Error(
"the `position` argument must be either a LogicalPosition or a PhysicalPosition instance" "the `position` argument must be either a LogicalPosition or a PhysicalPosition instance",
); );
} }
@ -1626,7 +1626,7 @@ class WindowManager extends WebviewWindowHandle {
*/ */
/* eslint-disable @typescript-eslint/promise-function-async */ /* eslint-disable @typescript-eslint/promise-function-async */
async onCloseRequested( async onCloseRequested(
handler: (event: CloseRequestedEvent) => void | Promise<void> handler: (event: CloseRequestedEvent) => void | Promise<void>,
): Promise<UnlistenFn> { ): Promise<UnlistenFn> {
return this.listen<null>(TauriEvent.WINDOW_CLOSE_REQUESTED, (event) => { return this.listen<null>(TauriEvent.WINDOW_CLOSE_REQUESTED, (event) => {
const evt = new CloseRequestedEvent(event); const evt = new CloseRequestedEvent(event);
@ -1663,13 +1663,13 @@ class WindowManager extends WebviewWindowHandle {
TauriEvent.WINDOW_FOCUS, TauriEvent.WINDOW_FOCUS,
(event) => { (event) => {
handler({ ...event, payload: true }); handler({ ...event, payload: true });
} },
); );
const unlistenBlur = await this.listen<PhysicalPosition>( const unlistenBlur = await this.listen<PhysicalPosition>(
TauriEvent.WINDOW_BLUR, TauriEvent.WINDOW_BLUR,
(event) => { (event) => {
handler({ ...event, payload: false }); handler({ ...event, payload: false });
} },
); );
return () => { return () => {
unlistenFocus(); unlistenFocus();
@ -1701,11 +1701,11 @@ class WindowManager extends WebviewWindowHandle {
* @since 2.0.0 * @since 2.0.0
*/ */
async onScaleChanged( async onScaleChanged(
handler: EventCallback<ScaleFactorChanged> handler: EventCallback<ScaleFactorChanged>,
): Promise<UnlistenFn> { ): Promise<UnlistenFn> {
return this.listen<ScaleFactorChanged>( return this.listen<ScaleFactorChanged>(
TauriEvent.WINDOW_SCALE_FACTOR_CHANGED, TauriEvent.WINDOW_SCALE_FACTOR_CHANGED,
handler handler,
); );
} }
@ -1760,27 +1760,27 @@ class WindowManager extends WebviewWindowHandle {
* @since 2.0.0 * @since 2.0.0
*/ */
async onFileDropEvent( async onFileDropEvent(
handler: EventCallback<FileDropEvent> handler: EventCallback<FileDropEvent>,
): Promise<UnlistenFn> { ): Promise<UnlistenFn> {
const unlistenFileDrop = await this.listen<string[]>( const unlistenFileDrop = await this.listen<string[]>(
TauriEvent.WINDOW_FILE_DROP, TauriEvent.WINDOW_FILE_DROP,
(event) => { (event) => {
handler({ ...event, payload: { type: "drop", paths: event.payload } }); handler({ ...event, payload: { type: "drop", paths: event.payload } });
} },
); );
const unlistenFileHover = await this.listen<string[]>( const unlistenFileHover = await this.listen<string[]>(
TauriEvent.WINDOW_FILE_DROP_HOVER, TauriEvent.WINDOW_FILE_DROP_HOVER,
(event) => { (event) => {
handler({ ...event, payload: { type: "hover", paths: event.payload } }); handler({ ...event, payload: { type: "hover", paths: event.payload } });
} },
); );
const unlistenCancel = await this.listen<null>( const unlistenCancel = await this.listen<null>(
TauriEvent.WINDOW_FILE_DROP_CANCELLED, TauriEvent.WINDOW_FILE_DROP_CANCELLED,
(event) => { (event) => {
handler({ ...event, payload: { type: "cancel" } }); handler({ ...event, payload: { type: "cancel" } });
} },
); );
return () => { return () => {
@ -1963,11 +1963,11 @@ if ("__TAURI_METADATA__" in window) {
{ {
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor // @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
skip: true, skip: true,
} },
); );
} else { } else {
console.warn( console.warn(
`Could not find "window.__TAURI_METADATA__". The "appWindow" value will reference the "main" window label.\nNote that this is not an issue if running this frontend on a browser instead of a Tauri window.` `Could not find "window.__TAURI_METADATA__". The "appWindow" value will reference the "main" window label.\nNote that this is not an issue if running this frontend on a browser instead of a Tauri window.`,
); );
appWindow = new WebviewWindow("main", { appWindow = new WebviewWindow("main", {
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor // @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor

@ -5,7 +5,7 @@ import { createConfig } from "../../shared/rollup.config.mjs";
export default createConfig({ export default createConfig({
input: "guest-js/index.ts", input: "guest-js/index.ts",
pkg: JSON.parse( pkg: JSON.parse(
readFileSync(new URL("./package.json", import.meta.url), "utf8") readFileSync(new URL("./package.json", import.meta.url), "utf8"),
), ),
external: [/^@tauri-apps\/api/], external: [/^@tauri-apps\/api/],
}); });

Loading…
Cancel
Save