@binblink/wasmnest-plugin-sdk-desktop 0.0.1 → 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 +24 -4
- package/README_en.md +1 -1
- package/bin/cli.js +5 -5
- package/bin/manifest-gen.js +4 -0
- package/bin/manifest-validate.js +68 -6
- package/bin/permission-vocabulary.json +2 -2
- package/dev-shell/README.md +6 -5
- package/dev-shell/src/loader.ts +0 -5
- package/dev-shell/src/mock/commands.ts +1 -1
- package/dev-shell/src/mock/domain-context.ts +1 -1
- package/dev-shell/src/shell/types.ts +21 -32
- package/dev-shell/src/styles/shell.css +208 -2
- package/dev-shell/src/styles/style.css +72 -26
- package/dist/index.d.ts +44 -3
- package/dist/index.js +69 -1
- package/dist/types.d.ts +52 -5
- 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 +12 -1
- package/src/index.ts +8 -0
- package/src/types.ts +681 -630
- package/src/ui/AppUpdateSection.d.ts +44 -0
- package/src/ui/AppUpdateSection.vue +253 -0
- package/src/ui/NumberField.d.ts +49 -0
- package/src/ui/NumberField.vue +390 -0
- package/src/ui/Select.vue +4 -4
- package/src/update.ts +123 -0
- package/template/README.md +39 -39
- package/tools/componentize/Cargo.lock +30 -1
- package/tools/componentize/Cargo.toml +3 -0
- package/tools/componentize/src/main.rs +197 -94
- package/dev-shell/src/mock/agent-hub-commands.ts +0 -1065
- package/dev-shell/src/mock/agent-hub.ts +0 -42
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ wasmnest-plugin-desktop create com.example.my-app "My App" --author "you" --rust
|
|
|
30
30
|
cd my-app
|
|
31
31
|
pnpm install
|
|
32
32
|
ppnpm run dev # 浏览器开发环境(Dev Shell:空壳宿主 + HMR)
|
|
33
|
-
ppnpm run build # 构建产物 dist/(vite 前端 +
|
|
33
|
+
ppnpm run build # 构建产物 dist/(vite 前端 + full 形态时 cargo wasm32)
|
|
34
34
|
ppnpm run manifest # 按源码自动填充 plugin.json 的 contributes / permissions
|
|
35
35
|
```
|
|
36
36
|
|
|
@@ -40,7 +40,7 @@ ppnpm run manifest # 按源码自动填充 plugin.json 的 contributes / permi
|
|
|
40
40
|
wasmnest-plugin-desktop build --resources-dir ../wasmnest-desktop/src-tauri/resources/plugins/desktop
|
|
41
41
|
# 把产物复制到 src-tauri/resources/plugins/desktop/{id}/(内置 wasm 应用随安装包分发的方式)
|
|
42
42
|
|
|
43
|
-
wasmnest-plugin-desktop build --frontend-only / --rust-only # 只构建一半(
|
|
43
|
+
wasmnest-plugin-desktop build --frontend-only / --rust-only # 只构建一半(full 形态)
|
|
44
44
|
wasmnest-plugin-desktop dev [pluginDir] [--port <port>] [--host] [--open]
|
|
45
45
|
wasmnest-plugin-desktop manifest --check # 只检查不写入(CI)
|
|
46
46
|
wasmnest-plugin-desktop validate [--dir] # 校验 plugin.json(id 格式 / 必填 / pluginType / 权限白名单 / 产物存在性)
|
|
@@ -65,7 +65,7 @@ wasmnest-plugin-desktop doctor # 环境自检(Node / Rust / wasm32
|
|
|
65
65
|
"description": "示例插件",
|
|
66
66
|
"author": "you",
|
|
67
67
|
"main": "index.js",
|
|
68
|
-
"pluginType": "
|
|
68
|
+
"pluginType": "frontend",
|
|
69
69
|
"permissions": ["storage", "ui:sidebar"],
|
|
70
70
|
"contributes": {
|
|
71
71
|
"commands": [{ "id": "my-plugin.hello", "title": "Hello" }],
|
|
@@ -76,7 +76,7 @@ wasmnest-plugin-desktop doctor # 环境自检(Node / Rust / wasm32
|
|
|
76
76
|
|
|
77
77
|
必填字段:`name` / `version` / `platform` / `main` / `pluginType` / `permissions` / `contributes`
|
|
78
78
|
(校验真源 `bin/manifest-validate.js`;宿主反序列化无缺省,缺失即拒装)。
|
|
79
|
-
`pluginType` 取值 `
|
|
79
|
+
`pluginType` 取值 `frontend` / `backend` / `full`(语言无关三形态,2026-10-26 重定义,旧值 rust / rust-ts / ts-only 已退役);`full` 时必须给 `rustLibrary`
|
|
80
80
|
(与 Cargo.toml 包名一致)。
|
|
81
81
|
|
|
82
82
|
> `sandbox` 已从 manifest 退役(审计票 06 裁决 2:前端不做隔离)——Rust 端类型会
|
|
@@ -236,6 +236,24 @@ context.events.on('task:status-changed', (payload) => {
|
|
|
236
236
|
})
|
|
237
237
|
```
|
|
238
238
|
|
|
239
|
+
## 应用更新检查(宿主统一默认实现)
|
|
240
|
+
|
|
241
|
+
manifest 声明 `update`(缺省 = 不参与检查)后,宿主负责查 GitHub Release、校验身份 / 完整性并做平台兼容裁决;应用设置页直接嵌入 SDK 默认卡片:
|
|
242
|
+
|
|
243
|
+
```vue
|
|
244
|
+
<script setup lang="ts">
|
|
245
|
+
import AppUpdateSection from '@binblink/wasmnest-plugin-sdk-desktop/ui/app-update'
|
|
246
|
+
</script>
|
|
247
|
+
|
|
248
|
+
<template>
|
|
249
|
+
<AppUpdateSection />
|
|
250
|
+
</template>
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
- 默认数据面 = `PluginContext.appUpdate.check`(宿主注入,appId / 凭证已绑定);应用也可给 `AppUpdateSection` 传 `check` 使用自实现,或只用 `useAppUpdate()` 自己画 UI。
|
|
254
|
+
- 检查结果状态:`up-to-date` / `available` / `incompatible` / `error`;不兼容会带原因 key,不出现更新按钮。
|
|
255
|
+
- **安装动作不在应用内**:统一在宿主应用管理页执行(需先停用、替换目录并重新审批)。
|
|
256
|
+
|
|
239
257
|
## 共享 UI 组件
|
|
240
258
|
|
|
241
259
|
`./ui` 子路径导出的组件遵循宿主设计 token,插件 UI 与宿主观感一致(**禁止使用原生 `<select>` 等系统控件外观**):
|
|
@@ -266,6 +284,7 @@ const options = [
|
|
|
266
284
|
| `./ui/terminal-input-rail` | `TerminalInputRail` | 终端输入导航条(终端右侧悬浮,一根横线 = 一次用户输入,位置映射 buffer 相对位置) |
|
|
267
285
|
| `./ui/plugin-global-dialog` | `PluginGlobalDialog` | 宿主全局弹窗(应用根挂载一次;渲染由全局弹窗控制器驱动,插件经 `context.ui.showDialog` 操控,挂载方无 props) |
|
|
268
286
|
| `./ui/zoom-compensation` | (无组件) | fixed 定位覆盖层在根元素 CSS zoom 下的坐标换算(自校准;当前 F=1,作防御性 no-op 保留) |
|
|
287
|
+
| `./ui/app-update` | `AppUpdateSection` | 应用更新检查(宿主统一 GitHub Release 判定;可传 `check` / `labels` 覆盖) |
|
|
269
288
|
|
|
270
289
|
## 子路径导出总览
|
|
271
290
|
|
|
@@ -279,6 +298,7 @@ const options = [
|
|
|
279
298
|
| `@binblink/wasmnest-plugin-sdk-desktop/ui/terminal-input-rail` | `TerminalInputRail` |
|
|
280
299
|
| `@binblink/wasmnest-plugin-sdk-desktop/ui/plugin-global-dialog` | `PluginGlobalDialog` |
|
|
281
300
|
| `@binblink/wasmnest-plugin-sdk-desktop/ui/zoom-compensation` | zoom 坐标换算工具 |
|
|
301
|
+
| `@binblink/wasmnest-plugin-sdk-desktop/ui/app-update` | `AppUpdateSection`(应用更新检查) |
|
|
282
302
|
|
|
283
303
|
## 本地开发本 SDK
|
|
284
304
|
|
package/README_en.md
CHANGED
|
@@ -65,7 +65,7 @@ A minimal plugin needs just two files:
|
|
|
65
65
|
"description": "Example plugin",
|
|
66
66
|
"author": "you",
|
|
67
67
|
"main": "index.js",
|
|
68
|
-
"pluginType": "
|
|
68
|
+
"pluginType": "frontend",
|
|
69
69
|
"permissions": ["storage", "ui:sidebar"],
|
|
70
70
|
"contributes": {
|
|
71
71
|
"commands": [{ "id": "my-plugin.hello", "title": "Hello" }],
|
package/bin/cli.js
CHANGED
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
* wasmnest-plugin-desktop validate [--dir <dir>]
|
|
11
11
|
* wasmnest-plugin-desktop doctor
|
|
12
12
|
*
|
|
13
|
-
* create 从 SDK
|
|
13
|
+
* create 从 SDK 内置模板生成插件工程(默认纯前端 frontend;--rust 附带 WASM 后端脚手架出 full);
|
|
14
14
|
* --registry 时引用已发布的 SDK 版本,否则引用本地 SDK 相对路径
|
|
15
|
-
* build 串联 vite build → cargo wasm32(
|
|
15
|
+
* build 串联 vite build → cargo wasm32(full 形态插件);--resources-dir 时复制产物到宿主资源目录,
|
|
16
16
|
* 并把 wasm 字节的 SHA-256 注入**产物** plugin.json 的 wasmHash(源清单不带该键,见 bin/wasm-hash.js)
|
|
17
17
|
* dev 启动浏览器开发环境(dev-shell):vite dev server + HMR;加载应用的挂载包入口
|
|
18
18
|
* (src/entry.ts,导出 mountApp)源码,Rust 后端不在浏览器运行
|
|
@@ -185,9 +185,9 @@ function cmdCreate(positional, flags) {
|
|
|
185
185
|
// crate 名 / 结构体名是内部实现标识符,保持 wasmnest_plugin_* / *Plugin 不变
|
|
186
186
|
const pkgName = `@wasmnest/wasm-app-${last}`
|
|
187
187
|
|
|
188
|
-
//
|
|
188
|
+
// 产物形态(语言无关三档,wasmnest-apps#21):默认纯前端;--rust 附带 WASM 后端
|
|
189
189
|
const withRust = flags.rust === true
|
|
190
|
-
const pluginType = withRust ? '
|
|
190
|
+
const pluginType = withRust ? 'full' : 'frontend'
|
|
191
191
|
const rustLibraryLine = withRust ? ` "rustLibrary": "${crate}",\n` : ''
|
|
192
192
|
|
|
193
193
|
// SDK 依赖标识:--registry 引用已发布版本(npm + crates.io),默认引用本地 SDK 相对路径
|
|
@@ -279,7 +279,7 @@ function cmdBuild(flags) {
|
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
-
// 2. WASM 构建(
|
|
282
|
+
// 2. WASM 构建(full 形态插件)
|
|
283
283
|
if (hasWasm && !frontendOnly) {
|
|
284
284
|
console.log('\n[wasmnest-plugin-desktop] ====== 构建 WASM (cargo) ======')
|
|
285
285
|
run(
|
package/bin/manifest-gen.js
CHANGED
|
@@ -92,6 +92,10 @@ const RUST_PERMISSION_RULES = [
|
|
|
92
92
|
{ re: /\bplugin_db_\w+\b/, perm: 'storage' },
|
|
93
93
|
// 运行监控(WIT `host-metrics.snapshot`):只读、全局可见(一次授权看全部插件)
|
|
94
94
|
{ re: /\bmetrics_snapshot\b/, perm: 'metrics:read' },
|
|
95
|
+
// 内网穿透(T06):服务端 / 客户端分域;`configure` / `status` 是共用面
|
|
96
|
+
// (任一权限即可),不单独推导,避免给应用注入它没声明的位。
|
|
97
|
+
{ re: /\btunnel_(expose|unexpose|issue_pairing_ticket)\b/, perm: 'tunnel:serve' },
|
|
98
|
+
{ re: /\btunnel_(connect|close)\b/, perm: 'tunnel:connect' },
|
|
95
99
|
]
|
|
96
100
|
|
|
97
101
|
/**
|
package/bin/manifest-validate.js
CHANGED
|
@@ -18,7 +18,13 @@ import { WASM_HASH_PATTERN } from './wasm-hash.js'
|
|
|
18
18
|
const SDK_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..')
|
|
19
19
|
const VOCABULARY_PATH = join(SDK_ROOT, 'bin', 'permission-vocabulary.json')
|
|
20
20
|
|
|
21
|
-
const VALID_PLUGIN_TYPES = new Set(['
|
|
21
|
+
const VALID_PLUGIN_TYPES = new Set(['frontend', 'backend', 'full'])
|
|
22
|
+
/** 退役 pluginType → 迁移出路(fail-visible:点名旧值并给出新值,不静默拒绝) */
|
|
23
|
+
const RETIRED_PLUGIN_TYPES = new Map([
|
|
24
|
+
['ts-only', 'frontend'],
|
|
25
|
+
['rust', 'backend'],
|
|
26
|
+
['rust-ts', 'full'],
|
|
27
|
+
])
|
|
22
28
|
|
|
23
29
|
/**
|
|
24
30
|
* 适配平台取值域(manifest `platform`,必填,与 id/name/version 同档)
|
|
@@ -112,16 +118,24 @@ export function validateManifest(dir) {
|
|
|
112
118
|
}
|
|
113
119
|
|
|
114
120
|
// pluginType / sandbox / rustLibrary
|
|
121
|
+
// pluginType 是语言无关的形态三档(frontend / backend / full,2026-10-26 语义
|
|
122
|
+
// 重定义,wasmnest-apps#21);旧值(rust / rust-ts / ts-only)退役——点名拒绝
|
|
123
|
+
// 并给出迁移出路(与宿主 serde 反序列化的错误口径一致,两侧都判死不留兼容期)
|
|
115
124
|
if (manifest.pluginType && !VALID_PLUGIN_TYPES.has(manifest.pluginType)) {
|
|
125
|
+
const retired = RETIRED_PLUGIN_TYPES.get(manifest.pluginType)
|
|
116
126
|
errors.push(
|
|
117
|
-
|
|
127
|
+
retired
|
|
128
|
+
? `pluginType "${manifest.pluginType}" 已退役(形态三档重定义,2026-10-26,wasmnest-apps#21):改用 "${retired}"——词汇只表达形态,不表达后端语言`
|
|
129
|
+
: `pluginType 非法: "${manifest.pluginType}"(允许: ${[...VALID_PLUGIN_TYPES].join(' / ')})`,
|
|
118
130
|
)
|
|
119
131
|
}
|
|
120
132
|
if (manifest.sandbox && !['inline', 'isolated'].includes(manifest.sandbox)) {
|
|
121
133
|
errors.push(`sandbox 非法: "${manifest.sandbox}"(允许: inline / isolated)`)
|
|
122
134
|
}
|
|
123
|
-
|
|
124
|
-
|
|
135
|
+
// rustLibrary(wasm 模块名):前后端形态(full)必填——纯后端(backend)多为
|
|
136
|
+
// 构建链/内置注册形态,产物命名另有真源,不在此强制
|
|
137
|
+
if (manifest.pluginType === 'full' && !manifest.rustLibrary) {
|
|
138
|
+
errors.push('pluginType=full 时必须提供 rustLibrary(与 Cargo.toml 包名一致;键名暂保留历史拼写,见 wasmnest-apps#21 键位子决策)')
|
|
125
139
|
}
|
|
126
140
|
|
|
127
141
|
// type(装配角色,ADR 0032):L1 基础服务 / L2 内部统一业务 / L3 业务应用
|
|
@@ -149,9 +163,9 @@ export function validateManifest(dir) {
|
|
|
149
163
|
`lifecycle 非法: "${manifest.lifecycle}"(允许: ${[...VALID_LIFECYCLES].join(' / ')},缺省即 persistent)`,
|
|
150
164
|
)
|
|
151
165
|
} else if (manifest.lifecycle === 'ephemeral') {
|
|
152
|
-
if (manifest.pluginType !== '
|
|
166
|
+
if (manifest.pluginType !== 'backend') {
|
|
153
167
|
errors.push(
|
|
154
|
-
`lifecycle="ephemeral" 只能配 pluginType="
|
|
168
|
+
`lifecycle="ephemeral" 只能配 pluginType="backend"(即用即弃 worker 无页面产物): ${JSON.stringify(manifest.pluginType)}`,
|
|
155
169
|
)
|
|
156
170
|
} else {
|
|
157
171
|
errors.push(
|
|
@@ -428,5 +442,53 @@ export function validateManifest(dir) {
|
|
|
428
442
|
}
|
|
429
443
|
}
|
|
430
444
|
|
|
445
|
+
// update(应用更新源声明,2026-11-02 应用版本更新全链路):缺省 = 不参与
|
|
446
|
+
// 更新检查;声明后 repo / slug / tagPrefix 会成为宿主拼 URL 与资产名的输入,
|
|
447
|
+
// 形态非法在构建期拦下(与内核 `app_update::resolve_update_source` 同判据)。
|
|
448
|
+
if (manifest.update !== undefined && manifest.update !== null) {
|
|
449
|
+
const update = manifest.update
|
|
450
|
+
if (typeof update !== 'object' || Array.isArray(update)) {
|
|
451
|
+
errors.push(`update 必须是对象: ${JSON.stringify(update)}`)
|
|
452
|
+
} else {
|
|
453
|
+
if (update.provider !== undefined && update.provider !== 'github-release') {
|
|
454
|
+
errors.push(`update.provider 非法: "${update.provider}"(当前只支持 github-release)`)
|
|
455
|
+
}
|
|
456
|
+
if (update.repo !== undefined) {
|
|
457
|
+
const repo = update.repo
|
|
458
|
+
if (
|
|
459
|
+
typeof repo !== 'string' ||
|
|
460
|
+
!/^[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+$/.test(repo) ||
|
|
461
|
+
repo.split('/').some((part) => part === '.' || part === '..')
|
|
462
|
+
) {
|
|
463
|
+
errors.push(`update.repo 非法: ${JSON.stringify(repo)}(须为 GitHub 的 owner/name)`)
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
if (update.slug !== undefined) {
|
|
467
|
+
const slug = update.slug
|
|
468
|
+
if (typeof slug !== 'string' || !/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/.test(slug)) {
|
|
469
|
+
errors.push(`update.slug 非法: ${JSON.stringify(slug)}(小写字母数字与 '-',不能以 '-' 开头/结尾)`)
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
if (update.tagPrefix !== undefined) {
|
|
473
|
+
const prefix = update.tagPrefix
|
|
474
|
+
if (
|
|
475
|
+
typeof prefix !== 'string' ||
|
|
476
|
+
prefix.trim() === '' ||
|
|
477
|
+
prefix.includes('/') ||
|
|
478
|
+
prefix.includes('..') ||
|
|
479
|
+
/\s/.test(prefix)
|
|
480
|
+
) {
|
|
481
|
+
errors.push(`update.tagPrefix 非法: ${JSON.stringify(prefix)}(非空,不含 '/'、'..' 或空白)`)
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
const extraKeys = Object.keys(update).filter(
|
|
485
|
+
(k) => !['provider', 'repo', 'tagPrefix', 'slug'].includes(k),
|
|
486
|
+
)
|
|
487
|
+
if (extraKeys.length) {
|
|
488
|
+
errors.push(`update 含未知字段: ${extraKeys.join(', ')}(只允许 provider / repo / tagPrefix / slug)`)
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
431
493
|
return { manifest, errors, warnings }
|
|
432
494
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_generated": "生成物,勿手改。真源 packages/plugin-sdk-desktop/rust/src/permission.rs;重跑:SDK 包目录 pnpm run gen:permissions",
|
|
3
|
-
"permissions": ["terminal:input", "terminal:output", "session:read", "connection:read", "ui:sidebar", "ui:toolbox", "ui:statusbar", "ui:dialog", "ui:pageToolbar", "ui:settings", "ui:input", "ui:fileHandler", "network:http", "storage", "fs:read", "fs:write", "fs:pick", "broadcast", "timer:schedule", "process:run", "app:cli", "app:path", "peer", "mdns", "ws:client", "ws:server", "auth", "pty:spawn", "pty:io", "task:run", "crypto:aead", "crypto:asym", "crypto:kdf", "metrics:read", "notify"],
|
|
4
|
-
"apiMap": { "terminal:input": ["terminal.onInput"], "terminal:output": ["terminal.onOutput"], "session:read": ["session.predictTerminalSize","session.openTerminal","session.closeTerminal","session.isTerminalOpen"], "connection:read": [], "ui:sidebar": ["ui.registerSidebarPanel","ui.registerPage"], "ui:toolbox": ["ui.registerToolboxPage"], "ui:statusbar": ["ui.registerStatusBarItem","ui.registerTitleBarItem"], "ui:dialog": ["ui.showDialog"], "ui:pageToolbar": ["ui.registerPageToolbarItem"], "ui:settings": ["ui.registerSettingsSection"], "ui:input": ["ui.registerInputExtension","ui.registerTerminalToolbarItem"], "ui:fileHandler": ["ui.registerFileHandler"], "network:http": ["http.registerEndpoint"], "storage": ["storage.get","storage.set","storage.delete","storage.flush"], "fs:read": ["fs.read","fs.copy"], "fs:write": ["fs.write","fs.copy"], "fs:pick": ["platform.pickFiles","platform.pickFolder","platform.pickFolders"], "broadcast": [], "timer:schedule": ["timer.register"], "process:run": ["process.run","process.kill"], "app:cli": ["app.cliInstall","app.cliUninstall"], "app:path": ["app.pathRegister","app.pathUnregister"], "peer": ["peer.listDevices","peer.dial","peer.disconnect","peer.respondConsent","peer.listTrusted","peer.revokeTrusted","peer.sendFiles","peer.listTransfers","peer.cancelTransfer","peer.retryTransfer","peer.clearTransferHistory","peer.listReceiving","peer.respondTransfer","peer.cancelReceiving","peer.clearReceivingHistory","peer.getReceiveSettings","peer.setReceivePolicy","peer.listSharedDirectories","peer.removeSharedDirectory","peer.addSharedDirectory","peer.listSharedRoots","peer.browseDirectory","peer.pullFiles","peer.pickFiles","peer.dialEndpoint","peer.close","peer.setSharedRoots"], "mdns": ["mdns.browse","mdns.stopBrowse","mdns.advertise","mdns.stopAdvertise","mdns.isAdvertising"], "ws:client": ["ws.connect","ws.sendText","ws.sendBinary","ws.close","ws.isConnected"], "ws:server": ["ws.registerEndpoint","ws.sendTextToClient","ws.sendBinaryToClient","ws.broadcastText","ws.broadcastBinary","ws.closeClient","ws.unregisterEndpoint","ws.listClients","ws.listEndpoints"], "auth": [], "pty:spawn": ["pty.spawn","pty.kill"], "pty:io": ["pty.write","pty.resize","pty.ringFetch","pty.isRunning"], "task:run": [], "crypto:aead": ["crypto.aeadEncrypt","crypto.aeadDecrypt","crypto.aeadGenerateKey","crypto.aeadGenerateNonce"], "crypto:asym": ["crypto.keyAgreementGenerate","crypto.keyAgreementShared"], "crypto:kdf": ["crypto.kdfDerive"], "metrics:read": ["metrics.snapshot"], "notify": [] }
|
|
3
|
+
"permissions": ["terminal:input", "terminal:output", "session:read", "connection:read", "ui:sidebar", "ui:toolbox", "ui:statusbar", "ui:dialog", "ui:pageToolbar", "ui:settings", "ui:input", "ui:fileHandler", "network:http", "storage", "fs:read", "fs:write", "fs:pick", "broadcast", "timer:schedule", "process:run", "app:cli", "app:path", "peer", "mdns", "ws:client", "ws:server", "auth", "pty:spawn", "pty:io", "task:run", "worker:run", "crypto:aead", "crypto:asym", "crypto:kdf", "metrics:read", "notify", "clipboard:read", "clipboard:write", "tunnel:serve", "tunnel:connect", "tunnel:probe"],
|
|
4
|
+
"apiMap": { "terminal:input": ["terminal.onInput"], "terminal:output": ["terminal.onOutput"], "session:read": ["session.predictTerminalSize","session.openTerminal","session.closeTerminal","session.isTerminalOpen"], "connection:read": [], "ui:sidebar": ["ui.registerSidebarPanel","ui.registerPage"], "ui:toolbox": ["ui.registerToolboxPage"], "ui:statusbar": ["ui.registerStatusBarItem","ui.registerTitleBarItem"], "ui:dialog": ["ui.showDialog"], "ui:pageToolbar": ["ui.registerPageToolbarItem"], "ui:settings": ["ui.registerSettingsSection"], "ui:input": ["ui.registerInputExtension","ui.registerTerminalToolbarItem"], "ui:fileHandler": ["ui.registerFileHandler"], "network:http": ["http.registerEndpoint"], "storage": ["storage.get","storage.set","storage.delete","storage.flush"], "fs:read": ["fs.read","fs.copy"], "fs:write": ["fs.write","fs.copy"], "fs:pick": ["platform.pickFiles","platform.pickFolder","platform.pickFolders"], "broadcast": [], "timer:schedule": ["timer.register"], "process:run": ["process.run","process.kill"], "app:cli": ["app.cliInstall","app.cliUninstall"], "app:path": ["app.pathRegister","app.pathUnregister"], "peer": ["peer.listDevices","peer.dial","peer.disconnect","peer.respondConsent","peer.listTrusted","peer.revokeTrusted","peer.sendFiles","peer.listTransfers","peer.cancelTransfer","peer.retryTransfer","peer.clearTransferHistory","peer.listReceiving","peer.respondTransfer","peer.cancelReceiving","peer.clearReceivingHistory","peer.getReceiveSettings","peer.setReceivePolicy","peer.listSharedDirectories","peer.removeSharedDirectory","peer.addSharedDirectory","peer.listSharedRoots","peer.browseDirectory","peer.pullFiles","peer.pickFiles","peer.dialEndpoint","peer.close","peer.setSharedRoots"], "mdns": ["mdns.browse","mdns.stopBrowse","mdns.advertise","mdns.stopAdvertise","mdns.isAdvertising"], "ws:client": ["ws.connect","ws.sendText","ws.sendBinary","ws.close","ws.isConnected"], "ws:server": ["ws.registerEndpoint","ws.sendTextToClient","ws.sendBinaryToClient","ws.broadcastText","ws.broadcastBinary","ws.closeClient","ws.unregisterEndpoint","ws.listClients","ws.listEndpoints"], "auth": [], "pty:spawn": ["pty.spawn","pty.kill"], "pty:io": ["pty.write","pty.resize","pty.ringFetch","pty.isRunning"], "task:run": [], "worker:run": ["worker.submit","worker.cancel"], "crypto:aead": ["crypto.aeadEncrypt","crypto.aeadDecrypt","crypto.aeadGenerateKey","crypto.aeadGenerateNonce"], "crypto:asym": ["crypto.keyAgreementGenerate","crypto.keyAgreementShared"], "crypto:kdf": ["crypto.kdfDerive"], "metrics:read": ["metrics.snapshot"], "notify": [], "clipboard:read": ["clipboard.readText"], "clipboard:write": ["clipboard.writeText"], "tunnel:serve": ["tunnel.expose","tunnel.unexpose","tunnel.issuePairingTicket"], "tunnel:connect": ["tunnel.connect","tunnel.close"], "tunnel:probe": ["tunnel.probeRelay"] }
|
|
5
5
|
}
|
package/dev-shell/README.md
CHANGED
|
@@ -97,15 +97,16 @@ WASMNEST_DEV_PLUGINS="<应用目录>[::<入口文件>]" pnpm exec vite --config
|
|
|
97
97
|
### 领域种子(devMock)
|
|
98
98
|
|
|
99
99
|
app 在 `src/index.ts` 导出 `devMock`(各 app 自持演示数据)时,dev-shell 按种子
|
|
100
|
-
子域挂载对应领域 mock(file-transfer 的 peer / transfer
|
|
100
|
+
子域挂载对应领域 mock(file-transfer 的 peer / transfer 域;agent-hub 的域 mock 已随应用并入 bedcode 退役)。
|
|
101
101
|
**没有导出的 app**(如 ai-chatbox / bedcode / monitor)只校验壳与布局:其命令会在
|
|
102
102
|
日志面板里报「未注册 mock」,这是预期状态,不是 dev-shell 的故障。
|
|
103
103
|
|
|
104
|
-
###
|
|
104
|
+
### 预览面(已退役)
|
|
105
105
|
|
|
106
|
-
宿主的多任务卡片预览面(`mountPreview
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
宿主的多任务卡片预览面(`mountPreview` / `AppPreviewEnv`)已于 2026-10-30 整体退役:
|
|
107
|
+
卡片改为挂载保活实例的真实页面,应用不再自报预览。dev-shell 侧的契约类型同步删除
|
|
108
|
+
(`src/shell/types.ts`),`contractDrift` 漂移锁不再比对 `AppPreview*`——应用若仍导出
|
|
109
|
+
`mountPreview`,宿主与 dev-shell 都不再消费。
|
|
109
110
|
|
|
110
111
|
## 常见问题
|
|
111
112
|
|
package/dev-shell/src/loader.ts
CHANGED
|
@@ -21,7 +21,6 @@ import type { AppBundleModule } from './shell/types'
|
|
|
21
21
|
import { apps, getDevMock, pushLog, registerDevMock, type DevAppState } from './registry'
|
|
22
22
|
import { createDomainContext } from './mock/domain-context'
|
|
23
23
|
import { registerFileTransferMock } from './mock/file-transfer'
|
|
24
|
-
import { registerAgentHubMock } from './mock/agent-hub'
|
|
25
24
|
|
|
26
25
|
export const ready = ref(false)
|
|
27
26
|
|
|
@@ -97,10 +96,6 @@ export function prepareAppMocks(appId: string): { dispose(): void } {
|
|
|
97
96
|
disposers.push(registerFileTransferMock(context, appId))
|
|
98
97
|
pushLog('info', appId, '已注册领域命令 mock(通用接线,种子来自 app devMock)')
|
|
99
98
|
}
|
|
100
|
-
if (seed.detection || seed.install || seed.skills || seed.providers || seed.usage) {
|
|
101
|
-
disposers.push(registerAgentHubMock(context, appId))
|
|
102
|
-
pushLog('info', appId, '已注册领域命令 mock(通用接线,种子来自 app devMock)')
|
|
103
|
-
}
|
|
104
99
|
return {
|
|
105
100
|
dispose() {
|
|
106
101
|
for (const d of disposers) d.dispose()
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* 必须由前端 mock 顶上,否则 app 首屏就是空态 / 报错——而 dev-shell 的意义正是
|
|
6
6
|
* 「不跑真后端也能调 UI」。
|
|
7
7
|
*
|
|
8
|
-
* 领域 mock(file-transfer
|
|
8
|
+
* 领域 mock(file-transfer)在这里注册命令 handler,种子数据来自
|
|
9
9
|
* app 自己导出的 `devMock`(各 app 持有自己的演示数据,dev-shell 不写死业务内容)。
|
|
10
10
|
*
|
|
11
11
|
* 未注册的命令**显性失败**(reject + warn 日志),不静默返回 undefined:静默
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 领域 mock 的接线适配器(dev-shell 内部用)
|
|
3
3
|
* -----------------------------------------------------------------------------
|
|
4
|
-
* 领域 mock(file-transfer
|
|
4
|
+
* 领域 mock(file-transfer)此前把命令 handler 注册进 app 的
|
|
5
5
|
* `PluginContext`。挂载包形态下 **app 自己持 context**(宿主注入 env,app 在
|
|
6
6
|
* `entry.ts` 里造 context),dev-shell 触不到它——但领域 mock 仍需要两条通道:
|
|
7
7
|
*
|
|
@@ -23,12 +23,30 @@ export interface AppMountEnv {
|
|
|
23
23
|
mountContract: string
|
|
24
24
|
/** 宿主面命令(白名单代理,ADR 0058 方案 A):plugin_list_loaded / get_app_settings 等;白名单真源在桌面 src-tauri APP_FRONTEND_INVOKE_WHITELIST */
|
|
25
25
|
invoke: <T = unknown>(command: string, args?: Record<string, unknown>) => Promise<T>
|
|
26
|
+
/** 应用更新检查(宿主统一默认实现;dev-shell 无真实发布源,可省略) */
|
|
27
|
+
appUpdate?: {
|
|
28
|
+
check: () => Promise<{
|
|
29
|
+
status: 'idle' | 'checking' | 'up-to-date' | 'available' | 'incompatible' | 'error'
|
|
30
|
+
latestVersion?: string
|
|
31
|
+
currentVersion?: string
|
|
32
|
+
reason?: { key: string; params?: Record<string, string> }
|
|
33
|
+
}>
|
|
34
|
+
}
|
|
26
35
|
/** 插件面命令(plugin_invoke,本 app 通道令牌已绑定) */
|
|
27
36
|
appInvoke: <T = unknown>(command: string, ...args: unknown[]) => Promise<T>
|
|
28
37
|
/** 本 app 插件 KV 存储(plugin_storage_*,宿主面凭证已绑定) */
|
|
29
38
|
appStorageGet: <T = unknown>(key: string) => Promise<T | undefined>
|
|
30
39
|
appStorageSet: (key: string, value: unknown) => Promise<void>
|
|
31
40
|
appStorageDelete: (key: string) => Promise<void>
|
|
41
|
+
/**
|
|
42
|
+
* 本应用链路加密策略(可选:旧宿主不注入 = 无此能力,应用必须显性提示)
|
|
43
|
+
*
|
|
44
|
+
* 策略属于应用(2026-11-04 裁决):应用在自己的设置页决定 off / preferred /
|
|
45
|
+
* required,覆盖本应用全部 HTTP / WS 端点;宿主不设全局下限、只执行与只读审计。
|
|
46
|
+
* 通道令牌已绑定本 app,只能读写自己。
|
|
47
|
+
*/
|
|
48
|
+
appLinkCryptoGet?: () => Promise<'off' | 'preferred' | 'required'>
|
|
49
|
+
appLinkCryptoSet?: (policy: 'off' | 'preferred' | 'required') => Promise<void>
|
|
32
50
|
/** 宿主面事实(挂载时快照;后续变更经 handle.setLocale / setTheme 通知) */
|
|
33
51
|
locale: string
|
|
34
52
|
theme: string
|
|
@@ -89,44 +107,15 @@ export interface AppMountHandle {
|
|
|
89
107
|
setTheme?(theme: string): void
|
|
90
108
|
}
|
|
91
109
|
|
|
92
|
-
/**
|
|
93
|
-
* 应用预览环境(宿主注入;只读面)
|
|
94
|
-
*
|
|
95
|
-
* 与 {@link AppMountEnv} 的差异是**收窄**而非放行:不提供宿主面 `invoke`、写 / 删
|
|
96
|
-
* 存储、事件出口(navigate / route)。预览是卡片里的旁路展示,不能请求宿主导航、
|
|
97
|
-
* 不能写存储、不能上报路由;安全边界仍由 Rust 权限仲裁(预览没有新增权限)。
|
|
98
|
-
*/
|
|
99
|
-
export interface AppPreviewEnv {
|
|
100
|
-
/** 插件 id(= 应用 id) */
|
|
101
|
-
appId: string
|
|
102
|
-
/** 应用上次自报的内部路径;无记录 = undefined(应用自行回落落地页) */
|
|
103
|
-
lastRoute?: string
|
|
104
|
-
/** 本 app 插件面命令(与主界面同一令牌 / 权限;预览侧只读使用) */
|
|
105
|
-
appInvoke: <T = unknown>(command: string, ...args: unknown[]) => Promise<T>
|
|
106
|
-
/** 本 app 插件 KV 只读访问 */
|
|
107
|
-
appStorageGet: <T = unknown>(key: string) => Promise<T | undefined>
|
|
108
|
-
locale: string
|
|
109
|
-
theme: string
|
|
110
|
-
platform?: string
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/** 应用预览句柄(卸载卡片时宿主调用;预览实例不登记到主应用 mounted 表) */
|
|
114
|
-
export interface AppPreviewHandle {
|
|
115
|
-
unmount(): Promise<void>
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/** entry.ts 可选导出;未导出 = 不支持预览(缺失不是错误,是能力声明) */
|
|
119
|
-
export type MountPreview = (root: HTMLElement, env: AppPreviewEnv) => Promise<AppPreviewHandle>
|
|
120
|
-
|
|
121
110
|
/**
|
|
122
111
|
* app 挂载包模块面(dev-shell 侧)
|
|
123
112
|
*
|
|
124
|
-
* `mountApp` 必有(否则契约不匹配,dev-shell
|
|
125
|
-
* 与宿主 `useAppMount.ts` 的 `AppBundleModule`
|
|
113
|
+
* `mountApp` 必有(否则契约不匹配,dev-shell 显性报错)。
|
|
114
|
+
* 与宿主 `useAppMount.ts` 的 `AppBundleModule` 同形。自绘预览面(mountPreview)
|
|
115
|
+
* 已随宿主退役(2026-10-30:多任务卡改挂载保活实例的真实页面,应用不再自报预览)。
|
|
126
116
|
*/
|
|
127
117
|
export interface AppBundleModule {
|
|
128
118
|
mountContract?: string
|
|
129
119
|
mountApp?: (root: HTMLElement, env: AppMountEnv) => Promise<AppMountHandle>
|
|
130
|
-
mountPreview?: MountPreview
|
|
131
120
|
mountMonitorPanel?: MountMonitorPanel
|
|
132
121
|
}
|