From 91efcf0d7f5aa9c6f07473973e09b60e2d856b5b Mon Sep 17 00:00:00 2001 From: Curve Date: Tue, 6 Feb 2024 16:57:25 +0100 Subject: [PATCH] feat(interface): update bindings --- interface/src/utils.ts | 31 +++++++++++++++++++++++++++++++ interface/types/global.d.ts | 15 ++++++++------- 2 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 interface/src/utils.ts diff --git a/interface/src/utils.ts b/interface/src/utils.ts new file mode 100644 index 0000000..2ced547 --- /dev/null +++ b/interface/src/utils.ts @@ -0,0 +1,31 @@ +export function chooseFile(setter: (value: string) => void, cancel?: () => void) +{ + window.saucer.call("choose-path", []).then(result => + { + if (result) + { + setter(result); + return; + } + + if (!cancel) + { + return; + } + + cancel(); + }); +} + +export function chooseFolder(setter: (value: string) => void) +{ + window.saucer.call("choose-folder", []).then(result => + { + if (!result) + { + return; + } + + setter(result); + }); +} diff --git a/interface/types/global.d.ts b/interface/types/global.d.ts index 8e87caf..3726512 100644 --- a/interface/types/global.d.ts +++ b/interface/types/global.d.ts @@ -4,21 +4,22 @@ interface Window { call: { - (func: "load", args: [string: path]): Promise; + (func: "load", args: [string: path]): Promise; (func: "list", args: []): Promise; (func: "decompile", args: [string: name]): Promise; (func: "cancel", args: []): Promise; - (func: "export", args: []): Promise; + (func: "export", args: [string: path]): Promise; - (func: "java-path", args: []): Promise; - (func: "unluac-path", args: []): Promise; + (func: "java-path", args: []): Promise; + (func: "unluac-path", args: []): Promise; - (func: "set-java-path", args: [string: path]): Promise; - (func: "set-unluac-path", args: [string: path]): Promise; + (func: "set-java-path", args: [string?: path]): Promise; + (func: "set-unluac-path", args: [string?: path]): Promise; - (func: "choose-path", args: []): Promise; + (func: "choose-path", args: [string?: path]): Promise; + (func: "choose-folder", args: [string?: path]): Promise; }; }