@binblink/wasmnest-plugin-sdk-desktop 0.0.0-stage → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +307 -2
- package/README_en.md +284 -0
- package/bin/cli.js +602 -0
- package/bin/manifest-gen.js +458 -0
- package/bin/manifest-validate.js +494 -0
- package/bin/permission-vocabulary.json +5 -0
- package/bin/plugin-watch.js +331 -0
- package/bin/wasm-hash.js +124 -0
- package/dev-shell/README.md +122 -0
- package/dev-shell/index.html +12 -0
- package/dev-shell/package.json +28 -0
- package/dev-shell/pnpm-workspace.yaml +9 -0
- package/dev-shell/postcss.config.js +6 -0
- package/dev-shell/src/App.vue +90 -0
- package/dev-shell/src/components/LogPanel.vue +90 -0
- package/dev-shell/src/loader.ts +104 -0
- package/dev-shell/src/locale.ts +29 -0
- package/dev-shell/src/locales.ts +50 -0
- package/dev-shell/src/main.ts +46 -0
- package/dev-shell/src/mock/app-env.ts +102 -0
- package/dev-shell/src/mock/commands.ts +54 -0
- package/dev-shell/src/mock/domain-context.ts +46 -0
- package/dev-shell/src/mock/events.ts +16 -0
- package/dev-shell/src/mock/file-transfer.ts +512 -0
- package/dev-shell/src/mock/tauri-ipc.ts +109 -0
- package/dev-shell/src/registry.ts +90 -0
- package/dev-shell/src/shell/components/AppMountSlot.vue +241 -0
- package/dev-shell/src/shell/components/ShellIcon.vue +141 -0
- package/dev-shell/src/shell/components/ShellStatusBar.vue +87 -0
- package/dev-shell/src/shell/components/ShellToolbar.vue +287 -0
- package/dev-shell/src/shell/mount/appSession.ts +45 -0
- package/dev-shell/src/shell/mount/devAppMount.ts +80 -0
- package/dev-shell/src/shell/types.ts +121 -0
- package/dev-shell/src/styles/dev.css +27 -0
- package/dev-shell/src/styles/shell.css +752 -0
- package/dev-shell/src/styles/style.css +1178 -0
- package/dev-shell/src/theme.ts +140 -0
- package/dev-shell/src/vite-env.d.ts +24 -0
- package/dev-shell/tailwind.config.js +98 -0
- package/dev-shell/vite.config.ts +174 -0
- package/dist/index.d.ts +150 -0
- package/dist/index.js +238 -0
- package/dist/types.d.ts +632 -0
- package/dist/types.js +0 -0
- package/dist/vite-plugin.d.ts +25 -0
- package/dist/vite-plugin.js +80 -0
- package/go/.gitignore +5 -0
- package/go/README.md +80 -0
- package/go/gen/wasmnest/api-call/host-api-call/empty.s +3 -0
- package/go/gen/wasmnest/api-call/host-api-call/host-api-call.wasm.go +13 -0
- package/go/gen/wasmnest/api-call/host-api-call/host-api-call.wit.go +34 -0
- package/go/gen/wasmnest/app/host-app/empty.s +3 -0
- package/go/gen/wasmnest/app/host-app/host-app.wasm.go +29 -0
- package/go/gen/wasmnest/app/host-app/host-app.wit.go +108 -0
- package/go/gen/wasmnest/auth-center/host-auth-center/abi.go +14 -0
- package/go/gen/wasmnest/auth-center/host-auth-center/empty.s +3 -0
- package/go/gen/wasmnest/auth-center/host-auth-center/host-auth-center.wasm.go +49 -0
- package/go/gen/wasmnest/auth-center/host-auth-center/host-auth-center.wit.go +225 -0
- package/go/gen/wasmnest/clipboard/host-clipboard/abi.go +14 -0
- package/go/gen/wasmnest/clipboard/host-clipboard/empty.s +3 -0
- package/go/gen/wasmnest/clipboard/host-clipboard/host-clipboard.wasm.go +17 -0
- package/go/gen/wasmnest/clipboard/host-clipboard/host-clipboard.wit.go +68 -0
- package/go/gen/wasmnest/connection-registry/host-connection-registry/empty.s +3 -0
- package/go/gen/wasmnest/connection-registry/host-connection-registry/host-connection-registry.wasm.go +13 -0
- package/go/gen/wasmnest/connection-registry/host-connection-registry/host-connection-registry.wit.go +50 -0
- package/go/gen/wasmnest/crypto/host-crypto/abi.go +18 -0
- package/go/gen/wasmnest/crypto/host-crypto/empty.s +3 -0
- package/go/gen/wasmnest/crypto/host-crypto/host-crypto.wasm.go +37 -0
- package/go/gen/wasmnest/crypto/host-crypto/host-crypto.wit.go +139 -0
- package/go/gen/wasmnest/fs-desktop/host-fs-desktop/abi.go +14 -0
- package/go/gen/wasmnest/fs-desktop/host-fs-desktop/empty.s +3 -0
- package/go/gen/wasmnest/fs-desktop/host-fs-desktop/host-fs-desktop.wasm.go +21 -0
- package/go/gen/wasmnest/fs-desktop/host-fs-desktop/host-fs-desktop.wit.go +62 -0
- package/go/gen/wasmnest/http/host-http/abi.go +14 -0
- package/go/gen/wasmnest/http/host-http/empty.s +3 -0
- package/go/gen/wasmnest/http/host-http/host-http.wasm.go +13 -0
- package/go/gen/wasmnest/http/host-http/host-http.wit.go +40 -0
- package/go/gen/wasmnest/http-endpoint/host-http-endpoint/empty.s +3 -0
- package/go/gen/wasmnest/http-endpoint/host-http-endpoint/host-http-endpoint.wasm.go +17 -0
- package/go/gen/wasmnest/http-endpoint/host-http-endpoint/host-http-endpoint.wit.go +69 -0
- package/go/gen/wasmnest/mdns/host-mdns/empty.s +3 -0
- package/go/gen/wasmnest/mdns/host-mdns/host-mdns.wasm.go +29 -0
- package/go/gen/wasmnest/mdns/host-mdns/host-mdns.wit.go +101 -0
- package/go/gen/wasmnest/notify/host-notify/empty.s +3 -0
- package/go/gen/wasmnest/notify/host-notify/host-notify.wasm.go +13 -0
- package/go/gen/wasmnest/notify/host-notify/host-notify.wit.go +64 -0
- package/go/gen/wasmnest/peer/host-peer/abi.go +14 -0
- package/go/gen/wasmnest/peer/host-peer/empty.s +3 -0
- package/go/gen/wasmnest/peer/host-peer/host-peer.wasm.go +85 -0
- package/go/gen/wasmnest/peer/host-peer/host-peer.wit.go +357 -0
- package/go/gen/wasmnest/platform-desktop/host-platform-desktop/empty.s +3 -0
- package/go/gen/wasmnest/platform-desktop/host-platform-desktop/host-platform-desktop.wasm.go +21 -0
- package/go/gen/wasmnest/platform-desktop/host-platform-desktop/host-platform-desktop.wit.go +70 -0
- package/go/gen/wasmnest/plugin/abi-form/abi-form.exports.go +11 -0
- package/go/gen/wasmnest/plugin/abi-form/abi-form.wasm.go +13 -0
- package/go/gen/wasmnest/plugin/abi-form/abi-form.wit.go +7 -0
- package/go/gen/wasmnest/plugin/abi-form/empty.s +3 -0
- package/go/gen/wasmnest/plugin/command/command.exports.go +11 -0
- package/go/gen/wasmnest/plugin/command/command.wasm.go +19 -0
- package/go/gen/wasmnest/plugin/command/command.wit.go +6 -0
- package/go/gen/wasmnest/plugin/command/empty.s +3 -0
- package/go/gen/wasmnest/plugin/events/empty.s +3 -0
- package/go/gen/wasmnest/plugin/events/events.exports.go +52 -0
- package/go/gen/wasmnest/plugin/events/events.wasm.go +74 -0
- package/go/gen/wasmnest/plugin/events/events.wit.go +195 -0
- package/go/gen/wasmnest/plugin/host-bus/empty.s +3 -0
- package/go/gen/wasmnest/plugin/host-bus/host-bus.wasm.go +29 -0
- package/go/gen/wasmnest/plugin/host-bus/host-bus.wit.go +94 -0
- package/go/gen/wasmnest/plugin/host-config/abi.go +14 -0
- package/go/gen/wasmnest/plugin/host-config/empty.s +3 -0
- package/go/gen/wasmnest/plugin/host-config/host-config.wasm.go +13 -0
- package/go/gen/wasmnest/plugin/host-config/host-config.wit.go +21 -0
- package/go/gen/wasmnest/plugin/host-events/empty.s +3 -0
- package/go/gen/wasmnest/plugin/host-events/host-events.wasm.go +9 -0
- package/go/gen/wasmnest/plugin/host-events/host-events.wit.go +27 -0
- package/go/gen/wasmnest/plugin/host-fs/abi.go +14 -0
- package/go/gen/wasmnest/plugin/host-fs/empty.s +3 -0
- package/go/gen/wasmnest/plugin/host-fs/host-fs.wasm.go +33 -0
- package/go/gen/wasmnest/plugin/host-fs/host-fs.wit.go +86 -0
- package/go/gen/wasmnest/plugin/host-log/empty.s +3 -0
- package/go/gen/wasmnest/plugin/host-log/host-log.wasm.go +25 -0
- package/go/gen/wasmnest/plugin/host-log/host-log.wit.go +65 -0
- package/go/gen/wasmnest/plugin/host-metrics/empty.s +3 -0
- package/go/gen/wasmnest/plugin/host-metrics/host-metrics.wasm.go +13 -0
- package/go/gen/wasmnest/plugin/host-metrics/host-metrics.wit.go +34 -0
- package/go/gen/wasmnest/plugin/host-platform/empty.s +3 -0
- package/go/gen/wasmnest/plugin/host-platform/host-platform.wasm.go +21 -0
- package/go/gen/wasmnest/plugin/host-platform/host-platform.wit.go +85 -0
- package/go/gen/wasmnest/plugin/host-plugin-database/abi.go +14 -0
- package/go/gen/wasmnest/plugin/host-plugin-database/empty.s +3 -0
- package/go/gen/wasmnest/plugin/host-plugin-database/host-plugin-database.wasm.go +29 -0
- package/go/gen/wasmnest/plugin/host-plugin-database/host-plugin-database.wit.go +70 -0
- package/go/gen/wasmnest/plugin/host-storage/abi.go +14 -0
- package/go/gen/wasmnest/plugin/host-storage/empty.s +3 -0
- package/go/gen/wasmnest/plugin/host-storage/host-storage.wasm.go +21 -0
- package/go/gen/wasmnest/plugin/host-storage/host-storage.wit.go +44 -0
- package/go/gen/wasmnest/plugin/host-worker/empty.s +3 -0
- package/go/gen/wasmnest/plugin/host-worker/host-worker.wasm.go +17 -0
- package/go/gen/wasmnest/plugin/host-worker/host-worker.wit.go +50 -0
- package/go/gen/wasmnest/plugin/lifecycle/empty.s +3 -0
- package/go/gen/wasmnest/plugin/lifecycle/lifecycle.exports.go +32 -0
- package/go/gen/wasmnest/plugin/lifecycle/lifecycle.wasm.go +41 -0
- package/go/gen/wasmnest/plugin/lifecycle/lifecycle.wit.go +9 -0
- package/go/gen/wasmnest/plugin/manifest/empty.s +3 -0
- package/go/gen/wasmnest/plugin/manifest/manifest.exports.go +11 -0
- package/go/gen/wasmnest/plugin/manifest/manifest.wasm.go +13 -0
- package/go/gen/wasmnest/plugin/manifest/manifest.wit.go +6 -0
- package/go/gen/wasmnest/plugin/plugin/plugin.wit.go +4 -0
- package/go/gen/wasmnest/process/host-process/empty.s +3 -0
- package/go/gen/wasmnest/process/host-process/host-process.wasm.go +21 -0
- package/go/gen/wasmnest/process/host-process/host-process.wit.go +56 -0
- package/go/gen/wasmnest/pty/host-pty/abi.go +14 -0
- package/go/gen/wasmnest/pty/host-pty/empty.s +3 -0
- package/go/gen/wasmnest/pty/host-pty/host-pty.wasm.go +33 -0
- package/go/gen/wasmnest/pty/host-pty/host-pty.wit.go +164 -0
- package/go/gen/wasmnest/task/host-task/abi.go +14 -0
- package/go/gen/wasmnest/task/host-task/empty.s +3 -0
- package/go/gen/wasmnest/task/host-task/host-task.wasm.go +29 -0
- package/go/gen/wasmnest/task/host-task/host-task.wit.go +110 -0
- package/go/gen/wasmnest/timer/host-timer/empty.s +3 -0
- package/go/gen/wasmnest/timer/host-timer/host-timer.wasm.go +13 -0
- package/go/gen/wasmnest/timer/host-timer/host-timer.wit.go +25 -0
- package/go/gen/wasmnest/ws/host-websocket/empty.s +3 -0
- package/go/gen/wasmnest/ws/host-websocket/host-websocket.wasm.go +29 -0
- package/go/gen/wasmnest/ws/host-websocket/host-websocket.wit.go +109 -0
- package/go/gen/wasmnest/ws-server/host-websocket-server/empty.s +3 -0
- package/go/gen/wasmnest/ws-server/host-websocket-server/host-websocket-server.wasm.go +49 -0
- package/go/gen/wasmnest/ws-server/host-websocket-server/host-websocket-server.wit.go +220 -0
- package/go/go.mod +14 -0
- package/go/go.sum +2 -0
- package/go/sdk/dispatch.go +49 -0
- package/go/sdk/dispatch_test.go +81 -0
- package/go/sdk/entry_native.go +13 -0
- package/go/sdk/entry_wasip2.go +188 -0
- package/go/sdk/host_http_wasip2.go +42 -0
- package/go/sdk/host_wasip2.go +251 -0
- package/go/sdk/plugin.go +103 -0
- package/go/testplugin/index.js +1 -0
- package/go/testplugin/main.go +67 -0
- package/go/testplugin/plugin.json +24 -0
- package/go/tools/assemble-wit.mjs +152 -0
- package/go/tools/gen-bindings.mjs +51 -0
- package/go/wit/core.wit +273 -0
- package/go/wit/deps/api-call/cap-api-call.wit +20 -0
- package/go/wit/deps/app/cap-app.wit +54 -0
- package/go/wit/deps/auth-center/cap-auth-center.wit +124 -0
- package/go/wit/deps/clipboard/clipboard.wit +48 -0
- package/go/wit/deps/clocks/monotonic-clock.wit +45 -0
- package/go/wit/deps/clocks/wall-clock.wit +42 -0
- package/go/wit/deps/clocks/world.wit +6 -0
- package/go/wit/deps/connection-registry/cap-connection-registry.wit +40 -0
- package/go/wit/deps/crypto/cap-crypto.wit +68 -0
- package/go/wit/deps/filesystem/preopens.wit +8 -0
- package/go/wit/deps/filesystem/types.wit +634 -0
- package/go/wit/deps/filesystem/world.wit +6 -0
- package/go/wit/deps/fs-desktop/cap-fs-desktop.wit +29 -0
- package/go/wit/deps/http/http.wit +28 -0
- package/go/wit/deps/http-endpoint/cap-http.wit +44 -0
- package/go/wit/deps/io/error.wit +34 -0
- package/go/wit/deps/io/poll.wit +41 -0
- package/go/wit/deps/io/streams.wit +262 -0
- package/go/wit/deps/io/world.wit +6 -0
- package/go/wit/deps/mdns/mdns.wit +45 -0
- package/go/wit/deps/notify/notify.wit +51 -0
- package/go/wit/deps/peer/peer.wit +126 -0
- package/go/wit/deps/platform-desktop/cap-platform-desktop.wit +38 -0
- package/go/wit/deps/process/cap-process.wit +25 -0
- package/go/wit/deps/pty/pty.wit +80 -0
- package/go/wit/deps/random/insecure-seed.wit +25 -0
- package/go/wit/deps/random/insecure.wit +22 -0
- package/go/wit/deps/random/random.wit +26 -0
- package/go/wit/deps/random/world.wit +7 -0
- package/go/wit/deps/sockets/instance-network.wit +9 -0
- package/go/wit/deps/sockets/ip-name-lookup.wit +51 -0
- package/go/wit/deps/sockets/network.wit +145 -0
- package/go/wit/deps/sockets/tcp-create-socket.wit +27 -0
- package/go/wit/deps/sockets/tcp.wit +353 -0
- package/go/wit/deps/sockets/udp-create-socket.wit +27 -0
- package/go/wit/deps/sockets/udp.wit +266 -0
- package/go/wit/deps/sockets/world.wit +11 -0
- package/go/wit/deps/task/cap-task.wit +56 -0
- package/go/wit/deps/timer/cap-timer.wit +14 -0
- package/go/wit/deps/wasi-cli/command.wit +7 -0
- package/go/wit/deps/wasi-cli/environment.wit +18 -0
- package/go/wit/deps/wasi-cli/exit.wit +4 -0
- package/go/wit/deps/wasi-cli/imports.wit +20 -0
- package/go/wit/deps/wasi-cli/run.wit +4 -0
- package/go/wit/deps/wasi-cli/stdio.wit +17 -0
- package/go/wit/deps/wasi-cli/terminal.wit +49 -0
- package/go/wit/deps/ws/ws.wit +50 -0
- package/go/wit/deps/ws-server/cap-ws.wit +99 -0
- package/go/wit/go-plugin.wit +28 -0
- package/go/wit/plugin-face.wit +355 -0
- package/go/wit/wasmnest.wit +25 -0
- package/package.json +100 -3
- package/src/config.ts +49 -0
- package/src/global-dialog.ts +169 -0
- package/src/index.ts +88 -0
- package/src/runtime.ts +54 -0
- package/src/types.ts +681 -0
- package/src/ui/AppUpdateSection.d.ts +44 -0
- package/src/ui/AppUpdateSection.vue +253 -0
- package/src/ui/MarkdownEditor.vue +520 -0
- package/src/ui/NumberField.d.ts +49 -0
- package/src/ui/NumberField.vue +390 -0
- package/src/ui/PluginGlobalDialog.vue +401 -0
- package/src/ui/Select.d.ts +36 -0
- package/src/ui/Select.vue +220 -0
- package/src/ui/TerminalInputRail.vue +184 -0
- package/src/ui/apply-select-position.ts +65 -0
- package/src/ui/markdown-editor-syntax.ts +234 -0
- package/src/ui/markdown-editor.d.ts +36 -0
- package/src/ui/plugin-global-dialog.d.ts +12 -0
- package/src/ui/select-position.ts +79 -0
- package/src/ui/terminal-input-rail.d.ts +30 -0
- package/src/ui/zoom-compensation.d.ts +9 -0
- package/src/ui/zoom-compensation.ts +52 -0
- package/src/update.ts +123 -0
- package/src/vite-plugin.ts +124 -0
- package/template/README.md +39 -0
- package/template/package.json +23 -0
- package/template/plugin.json +14 -0
- package/template/rust/Cargo.toml +21 -0
- package/template/rust/src/lib.rs +39 -0
- package/template/src/env.d.ts +24 -0
- package/template/src/index.ts +37 -0
- package/template/tsconfig.json +17 -0
- package/template/vite.config.ts +21 -0
- package/tools/componentize/Cargo.lock +299 -0
- package/tools/componentize/Cargo.toml +18 -0
- package/tools/componentize/src/main.rs +197 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
// src/runtime.ts
|
|
2
|
+
var SHARED_KEY = "__WASMNEST_SHARED__";
|
|
3
|
+
function getSharedModule(name) {
|
|
4
|
+
const shared = window[SHARED_KEY];
|
|
5
|
+
if (!shared) throw new Error("[PluginSDK] Shared runtime not initialized");
|
|
6
|
+
const mod = shared[name];
|
|
7
|
+
if (!mod) throw new Error(`[PluginSDK] Shared module "${name}" not found`);
|
|
8
|
+
return mod;
|
|
9
|
+
}
|
|
10
|
+
function getI18n() {
|
|
11
|
+
return getSharedModule("i18n");
|
|
12
|
+
}
|
|
13
|
+
function getVue() {
|
|
14
|
+
return getSharedModule("vue");
|
|
15
|
+
}
|
|
16
|
+
function getVueI18n() {
|
|
17
|
+
return getSharedModule("vue-i18n");
|
|
18
|
+
}
|
|
19
|
+
function getPinia() {
|
|
20
|
+
return getSharedModule("pinia");
|
|
21
|
+
}
|
|
22
|
+
function getRouter() {
|
|
23
|
+
return getSharedModule("router");
|
|
24
|
+
}
|
|
25
|
+
function getPluginContext() {
|
|
26
|
+
const vue = getVue();
|
|
27
|
+
const context = vue.inject("pluginContext");
|
|
28
|
+
if (!context)
|
|
29
|
+
throw new Error(
|
|
30
|
+
"[PluginSDK] PluginContext not available \u2014 ensure component is rendered inside PluginViewHost"
|
|
31
|
+
);
|
|
32
|
+
return context;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// src/global-dialog.ts
|
|
36
|
+
var seq = 0;
|
|
37
|
+
var current = null;
|
|
38
|
+
var queue = [];
|
|
39
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
40
|
+
var timers = /* @__PURE__ */ new Map();
|
|
41
|
+
function getGlobalDialog() {
|
|
42
|
+
return current;
|
|
43
|
+
}
|
|
44
|
+
function subscribeGlobalDialog(listener) {
|
|
45
|
+
listeners.add(listener);
|
|
46
|
+
listener(current);
|
|
47
|
+
return () => {
|
|
48
|
+
listeners.delete(listener);
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function emit() {
|
|
52
|
+
for (const fn of [...listeners]) fn(current);
|
|
53
|
+
}
|
|
54
|
+
function clearTimer(id) {
|
|
55
|
+
const timer = timers.get(id);
|
|
56
|
+
if (timer) {
|
|
57
|
+
clearTimeout(timer);
|
|
58
|
+
timers.delete(id);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function resolveDialogDeadline(entry) {
|
|
62
|
+
if (entry.deadlineAt != null && entry.deadlineAt > 0) return entry.deadlineAt;
|
|
63
|
+
if (entry.timeoutSec != null && entry.timeoutSec > 0) return entry.createdAt + entry.timeoutSec * 1e3;
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
function startTimeout(entry) {
|
|
67
|
+
clearTimer(entry._id);
|
|
68
|
+
const deadline = resolveDialogDeadline(entry);
|
|
69
|
+
if (deadline == null) return;
|
|
70
|
+
const delay = Math.max(0, deadline - Date.now());
|
|
71
|
+
timers.set(
|
|
72
|
+
entry._id,
|
|
73
|
+
setTimeout(() => {
|
|
74
|
+
try {
|
|
75
|
+
entry.onTimeout?.();
|
|
76
|
+
} catch (e) {
|
|
77
|
+
console.error("[PluginDialog] onTimeout failed:", e);
|
|
78
|
+
}
|
|
79
|
+
closeGlobalDialog(entry._id);
|
|
80
|
+
}, delay)
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
function fireOnClose(entry) {
|
|
84
|
+
try {
|
|
85
|
+
entry.onClose?.();
|
|
86
|
+
} catch (e) {
|
|
87
|
+
console.error("[PluginDialog] onClose failed:", e);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function closeGlobalDialog(id) {
|
|
91
|
+
if (current && current._id === id) {
|
|
92
|
+
const closed = current;
|
|
93
|
+
clearTimer(id);
|
|
94
|
+
current = null;
|
|
95
|
+
const next = queue.shift() ?? null;
|
|
96
|
+
current = next;
|
|
97
|
+
emit();
|
|
98
|
+
fireOnClose(closed);
|
|
99
|
+
if (next) startTimeout(next);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const idx = queue.findIndex((e) => e._id === id);
|
|
103
|
+
if (idx >= 0) {
|
|
104
|
+
const [removed] = queue.splice(idx, 1);
|
|
105
|
+
fireOnClose(removed);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function updateGlobalDialog(id, options) {
|
|
109
|
+
if (current && current._id === id) {
|
|
110
|
+
current = { ...current, ...options };
|
|
111
|
+
emit();
|
|
112
|
+
startTimeout(current);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const idx = queue.findIndex((e) => e._id === id);
|
|
116
|
+
if (idx >= 0) {
|
|
117
|
+
queue[idx] = { ...queue[idx], ...options };
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function openGlobalDialog(input) {
|
|
121
|
+
const entry = {
|
|
122
|
+
...input,
|
|
123
|
+
_id: ++seq,
|
|
124
|
+
createdAt: Date.now()
|
|
125
|
+
};
|
|
126
|
+
if (current) {
|
|
127
|
+
queue.push(entry);
|
|
128
|
+
} else {
|
|
129
|
+
current = entry;
|
|
130
|
+
emit();
|
|
131
|
+
startTimeout(entry);
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
close: () => closeGlobalDialog(entry._id),
|
|
135
|
+
update: (options) => updateGlobalDialog(entry._id, options)
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// src/config.ts
|
|
140
|
+
var PLUGIN_CONFIG_STORAGE_KEY = "config";
|
|
141
|
+
function defineConfiguration(title, properties) {
|
|
142
|
+
const props = {};
|
|
143
|
+
for (const [key, value] of Object.entries(properties)) {
|
|
144
|
+
props[key] = {
|
|
145
|
+
type: value.type,
|
|
146
|
+
title: value.title ?? key,
|
|
147
|
+
description: value.description,
|
|
148
|
+
default: value.default,
|
|
149
|
+
enum: value.enum
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
return { title, properties: props };
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// src/update.ts
|
|
156
|
+
import { computed, getCurrentInstance, inject, ref } from "vue";
|
|
157
|
+
function resolveHostApi() {
|
|
158
|
+
if (!getCurrentInstance()) return void 0;
|
|
159
|
+
return inject("pluginContext", void 0)?.appUpdate;
|
|
160
|
+
}
|
|
161
|
+
function useAppUpdate(options = {}) {
|
|
162
|
+
const hostApi = options.check ? void 0 : resolveHostApi();
|
|
163
|
+
const checker = options.check ?? (() => {
|
|
164
|
+
if (!hostApi) {
|
|
165
|
+
return Promise.reject(
|
|
166
|
+
new Error("[PluginSDK] app update capability is not provided by this host")
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
return hostApi.check();
|
|
170
|
+
});
|
|
171
|
+
const status = ref("idle");
|
|
172
|
+
const latestVersion = ref();
|
|
173
|
+
const currentVersion = ref();
|
|
174
|
+
const reason = ref();
|
|
175
|
+
let inFlight = null;
|
|
176
|
+
const supported = computed(() => Boolean(options.check || hostApi));
|
|
177
|
+
async function run() {
|
|
178
|
+
status.value = "checking";
|
|
179
|
+
reason.value = void 0;
|
|
180
|
+
try {
|
|
181
|
+
const result = await checker();
|
|
182
|
+
currentVersion.value = result.currentVersion;
|
|
183
|
+
latestVersion.value = result.latestVersion;
|
|
184
|
+
reason.value = result.reason;
|
|
185
|
+
switch (result.status) {
|
|
186
|
+
case "up-to-date":
|
|
187
|
+
case "available":
|
|
188
|
+
case "incompatible":
|
|
189
|
+
status.value = result.status;
|
|
190
|
+
break;
|
|
191
|
+
case "idle":
|
|
192
|
+
case "checking":
|
|
193
|
+
status.value = "error";
|
|
194
|
+
break;
|
|
195
|
+
default:
|
|
196
|
+
status.value = "error";
|
|
197
|
+
}
|
|
198
|
+
} catch {
|
|
199
|
+
status.value = "error";
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
function check() {
|
|
203
|
+
if (!inFlight) {
|
|
204
|
+
const pending = run().finally(() => {
|
|
205
|
+
if (inFlight === pending) inFlight = null;
|
|
206
|
+
});
|
|
207
|
+
inFlight = pending;
|
|
208
|
+
}
|
|
209
|
+
return inFlight;
|
|
210
|
+
}
|
|
211
|
+
return {
|
|
212
|
+
status,
|
|
213
|
+
latestVersion,
|
|
214
|
+
currentVersion,
|
|
215
|
+
reason,
|
|
216
|
+
checking: computed(() => status.value === "checking"),
|
|
217
|
+
supported,
|
|
218
|
+
check
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
export {
|
|
222
|
+
PLUGIN_CONFIG_STORAGE_KEY,
|
|
223
|
+
closeGlobalDialog,
|
|
224
|
+
defineConfiguration,
|
|
225
|
+
getGlobalDialog,
|
|
226
|
+
getI18n,
|
|
227
|
+
getPinia,
|
|
228
|
+
getPluginContext,
|
|
229
|
+
getRouter,
|
|
230
|
+
getSharedModule,
|
|
231
|
+
getVue,
|
|
232
|
+
getVueI18n,
|
|
233
|
+
openGlobalDialog,
|
|
234
|
+
resolveDialogDeadline,
|
|
235
|
+
subscribeGlobalDialog,
|
|
236
|
+
updateGlobalDialog,
|
|
237
|
+
useAppUpdate
|
|
238
|
+
};
|