@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.
Files changed (271) hide show
  1. package/README.md +307 -2
  2. package/README_en.md +284 -0
  3. package/bin/cli.js +602 -0
  4. package/bin/manifest-gen.js +458 -0
  5. package/bin/manifest-validate.js +494 -0
  6. package/bin/permission-vocabulary.json +5 -0
  7. package/bin/plugin-watch.js +331 -0
  8. package/bin/wasm-hash.js +124 -0
  9. package/dev-shell/README.md +122 -0
  10. package/dev-shell/index.html +12 -0
  11. package/dev-shell/package.json +28 -0
  12. package/dev-shell/pnpm-workspace.yaml +9 -0
  13. package/dev-shell/postcss.config.js +6 -0
  14. package/dev-shell/src/App.vue +90 -0
  15. package/dev-shell/src/components/LogPanel.vue +90 -0
  16. package/dev-shell/src/loader.ts +104 -0
  17. package/dev-shell/src/locale.ts +29 -0
  18. package/dev-shell/src/locales.ts +50 -0
  19. package/dev-shell/src/main.ts +46 -0
  20. package/dev-shell/src/mock/app-env.ts +102 -0
  21. package/dev-shell/src/mock/commands.ts +54 -0
  22. package/dev-shell/src/mock/domain-context.ts +46 -0
  23. package/dev-shell/src/mock/events.ts +16 -0
  24. package/dev-shell/src/mock/file-transfer.ts +512 -0
  25. package/dev-shell/src/mock/tauri-ipc.ts +109 -0
  26. package/dev-shell/src/registry.ts +90 -0
  27. package/dev-shell/src/shell/components/AppMountSlot.vue +241 -0
  28. package/dev-shell/src/shell/components/ShellIcon.vue +141 -0
  29. package/dev-shell/src/shell/components/ShellStatusBar.vue +87 -0
  30. package/dev-shell/src/shell/components/ShellToolbar.vue +287 -0
  31. package/dev-shell/src/shell/mount/appSession.ts +45 -0
  32. package/dev-shell/src/shell/mount/devAppMount.ts +80 -0
  33. package/dev-shell/src/shell/types.ts +121 -0
  34. package/dev-shell/src/styles/dev.css +27 -0
  35. package/dev-shell/src/styles/shell.css +752 -0
  36. package/dev-shell/src/styles/style.css +1178 -0
  37. package/dev-shell/src/theme.ts +140 -0
  38. package/dev-shell/src/vite-env.d.ts +24 -0
  39. package/dev-shell/tailwind.config.js +98 -0
  40. package/dev-shell/vite.config.ts +174 -0
  41. package/dist/index.d.ts +150 -0
  42. package/dist/index.js +238 -0
  43. package/dist/types.d.ts +632 -0
  44. package/dist/types.js +0 -0
  45. package/dist/vite-plugin.d.ts +25 -0
  46. package/dist/vite-plugin.js +80 -0
  47. package/go/.gitignore +5 -0
  48. package/go/README.md +80 -0
  49. package/go/gen/wasmnest/api-call/host-api-call/empty.s +3 -0
  50. package/go/gen/wasmnest/api-call/host-api-call/host-api-call.wasm.go +13 -0
  51. package/go/gen/wasmnest/api-call/host-api-call/host-api-call.wit.go +34 -0
  52. package/go/gen/wasmnest/app/host-app/empty.s +3 -0
  53. package/go/gen/wasmnest/app/host-app/host-app.wasm.go +29 -0
  54. package/go/gen/wasmnest/app/host-app/host-app.wit.go +108 -0
  55. package/go/gen/wasmnest/auth-center/host-auth-center/abi.go +14 -0
  56. package/go/gen/wasmnest/auth-center/host-auth-center/empty.s +3 -0
  57. package/go/gen/wasmnest/auth-center/host-auth-center/host-auth-center.wasm.go +49 -0
  58. package/go/gen/wasmnest/auth-center/host-auth-center/host-auth-center.wit.go +225 -0
  59. package/go/gen/wasmnest/clipboard/host-clipboard/abi.go +14 -0
  60. package/go/gen/wasmnest/clipboard/host-clipboard/empty.s +3 -0
  61. package/go/gen/wasmnest/clipboard/host-clipboard/host-clipboard.wasm.go +17 -0
  62. package/go/gen/wasmnest/clipboard/host-clipboard/host-clipboard.wit.go +68 -0
  63. package/go/gen/wasmnest/connection-registry/host-connection-registry/empty.s +3 -0
  64. package/go/gen/wasmnest/connection-registry/host-connection-registry/host-connection-registry.wasm.go +13 -0
  65. package/go/gen/wasmnest/connection-registry/host-connection-registry/host-connection-registry.wit.go +50 -0
  66. package/go/gen/wasmnest/crypto/host-crypto/abi.go +18 -0
  67. package/go/gen/wasmnest/crypto/host-crypto/empty.s +3 -0
  68. package/go/gen/wasmnest/crypto/host-crypto/host-crypto.wasm.go +37 -0
  69. package/go/gen/wasmnest/crypto/host-crypto/host-crypto.wit.go +139 -0
  70. package/go/gen/wasmnest/fs-desktop/host-fs-desktop/abi.go +14 -0
  71. package/go/gen/wasmnest/fs-desktop/host-fs-desktop/empty.s +3 -0
  72. package/go/gen/wasmnest/fs-desktop/host-fs-desktop/host-fs-desktop.wasm.go +21 -0
  73. package/go/gen/wasmnest/fs-desktop/host-fs-desktop/host-fs-desktop.wit.go +62 -0
  74. package/go/gen/wasmnest/http/host-http/abi.go +14 -0
  75. package/go/gen/wasmnest/http/host-http/empty.s +3 -0
  76. package/go/gen/wasmnest/http/host-http/host-http.wasm.go +13 -0
  77. package/go/gen/wasmnest/http/host-http/host-http.wit.go +40 -0
  78. package/go/gen/wasmnest/http-endpoint/host-http-endpoint/empty.s +3 -0
  79. package/go/gen/wasmnest/http-endpoint/host-http-endpoint/host-http-endpoint.wasm.go +17 -0
  80. package/go/gen/wasmnest/http-endpoint/host-http-endpoint/host-http-endpoint.wit.go +69 -0
  81. package/go/gen/wasmnest/mdns/host-mdns/empty.s +3 -0
  82. package/go/gen/wasmnest/mdns/host-mdns/host-mdns.wasm.go +29 -0
  83. package/go/gen/wasmnest/mdns/host-mdns/host-mdns.wit.go +101 -0
  84. package/go/gen/wasmnest/notify/host-notify/empty.s +3 -0
  85. package/go/gen/wasmnest/notify/host-notify/host-notify.wasm.go +13 -0
  86. package/go/gen/wasmnest/notify/host-notify/host-notify.wit.go +64 -0
  87. package/go/gen/wasmnest/peer/host-peer/abi.go +14 -0
  88. package/go/gen/wasmnest/peer/host-peer/empty.s +3 -0
  89. package/go/gen/wasmnest/peer/host-peer/host-peer.wasm.go +85 -0
  90. package/go/gen/wasmnest/peer/host-peer/host-peer.wit.go +357 -0
  91. package/go/gen/wasmnest/platform-desktop/host-platform-desktop/empty.s +3 -0
  92. package/go/gen/wasmnest/platform-desktop/host-platform-desktop/host-platform-desktop.wasm.go +21 -0
  93. package/go/gen/wasmnest/platform-desktop/host-platform-desktop/host-platform-desktop.wit.go +70 -0
  94. package/go/gen/wasmnest/plugin/abi-form/abi-form.exports.go +11 -0
  95. package/go/gen/wasmnest/plugin/abi-form/abi-form.wasm.go +13 -0
  96. package/go/gen/wasmnest/plugin/abi-form/abi-form.wit.go +7 -0
  97. package/go/gen/wasmnest/plugin/abi-form/empty.s +3 -0
  98. package/go/gen/wasmnest/plugin/command/command.exports.go +11 -0
  99. package/go/gen/wasmnest/plugin/command/command.wasm.go +19 -0
  100. package/go/gen/wasmnest/plugin/command/command.wit.go +6 -0
  101. package/go/gen/wasmnest/plugin/command/empty.s +3 -0
  102. package/go/gen/wasmnest/plugin/events/empty.s +3 -0
  103. package/go/gen/wasmnest/plugin/events/events.exports.go +52 -0
  104. package/go/gen/wasmnest/plugin/events/events.wasm.go +74 -0
  105. package/go/gen/wasmnest/plugin/events/events.wit.go +195 -0
  106. package/go/gen/wasmnest/plugin/host-bus/empty.s +3 -0
  107. package/go/gen/wasmnest/plugin/host-bus/host-bus.wasm.go +29 -0
  108. package/go/gen/wasmnest/plugin/host-bus/host-bus.wit.go +94 -0
  109. package/go/gen/wasmnest/plugin/host-config/abi.go +14 -0
  110. package/go/gen/wasmnest/plugin/host-config/empty.s +3 -0
  111. package/go/gen/wasmnest/plugin/host-config/host-config.wasm.go +13 -0
  112. package/go/gen/wasmnest/plugin/host-config/host-config.wit.go +21 -0
  113. package/go/gen/wasmnest/plugin/host-events/empty.s +3 -0
  114. package/go/gen/wasmnest/plugin/host-events/host-events.wasm.go +9 -0
  115. package/go/gen/wasmnest/plugin/host-events/host-events.wit.go +27 -0
  116. package/go/gen/wasmnest/plugin/host-fs/abi.go +14 -0
  117. package/go/gen/wasmnest/plugin/host-fs/empty.s +3 -0
  118. package/go/gen/wasmnest/plugin/host-fs/host-fs.wasm.go +33 -0
  119. package/go/gen/wasmnest/plugin/host-fs/host-fs.wit.go +86 -0
  120. package/go/gen/wasmnest/plugin/host-log/empty.s +3 -0
  121. package/go/gen/wasmnest/plugin/host-log/host-log.wasm.go +25 -0
  122. package/go/gen/wasmnest/plugin/host-log/host-log.wit.go +65 -0
  123. package/go/gen/wasmnest/plugin/host-metrics/empty.s +3 -0
  124. package/go/gen/wasmnest/plugin/host-metrics/host-metrics.wasm.go +13 -0
  125. package/go/gen/wasmnest/plugin/host-metrics/host-metrics.wit.go +34 -0
  126. package/go/gen/wasmnest/plugin/host-platform/empty.s +3 -0
  127. package/go/gen/wasmnest/plugin/host-platform/host-platform.wasm.go +21 -0
  128. package/go/gen/wasmnest/plugin/host-platform/host-platform.wit.go +85 -0
  129. package/go/gen/wasmnest/plugin/host-plugin-database/abi.go +14 -0
  130. package/go/gen/wasmnest/plugin/host-plugin-database/empty.s +3 -0
  131. package/go/gen/wasmnest/plugin/host-plugin-database/host-plugin-database.wasm.go +29 -0
  132. package/go/gen/wasmnest/plugin/host-plugin-database/host-plugin-database.wit.go +70 -0
  133. package/go/gen/wasmnest/plugin/host-storage/abi.go +14 -0
  134. package/go/gen/wasmnest/plugin/host-storage/empty.s +3 -0
  135. package/go/gen/wasmnest/plugin/host-storage/host-storage.wasm.go +21 -0
  136. package/go/gen/wasmnest/plugin/host-storage/host-storage.wit.go +44 -0
  137. package/go/gen/wasmnest/plugin/host-worker/empty.s +3 -0
  138. package/go/gen/wasmnest/plugin/host-worker/host-worker.wasm.go +17 -0
  139. package/go/gen/wasmnest/plugin/host-worker/host-worker.wit.go +50 -0
  140. package/go/gen/wasmnest/plugin/lifecycle/empty.s +3 -0
  141. package/go/gen/wasmnest/plugin/lifecycle/lifecycle.exports.go +32 -0
  142. package/go/gen/wasmnest/plugin/lifecycle/lifecycle.wasm.go +41 -0
  143. package/go/gen/wasmnest/plugin/lifecycle/lifecycle.wit.go +9 -0
  144. package/go/gen/wasmnest/plugin/manifest/empty.s +3 -0
  145. package/go/gen/wasmnest/plugin/manifest/manifest.exports.go +11 -0
  146. package/go/gen/wasmnest/plugin/manifest/manifest.wasm.go +13 -0
  147. package/go/gen/wasmnest/plugin/manifest/manifest.wit.go +6 -0
  148. package/go/gen/wasmnest/plugin/plugin/plugin.wit.go +4 -0
  149. package/go/gen/wasmnest/process/host-process/empty.s +3 -0
  150. package/go/gen/wasmnest/process/host-process/host-process.wasm.go +21 -0
  151. package/go/gen/wasmnest/process/host-process/host-process.wit.go +56 -0
  152. package/go/gen/wasmnest/pty/host-pty/abi.go +14 -0
  153. package/go/gen/wasmnest/pty/host-pty/empty.s +3 -0
  154. package/go/gen/wasmnest/pty/host-pty/host-pty.wasm.go +33 -0
  155. package/go/gen/wasmnest/pty/host-pty/host-pty.wit.go +164 -0
  156. package/go/gen/wasmnest/task/host-task/abi.go +14 -0
  157. package/go/gen/wasmnest/task/host-task/empty.s +3 -0
  158. package/go/gen/wasmnest/task/host-task/host-task.wasm.go +29 -0
  159. package/go/gen/wasmnest/task/host-task/host-task.wit.go +110 -0
  160. package/go/gen/wasmnest/timer/host-timer/empty.s +3 -0
  161. package/go/gen/wasmnest/timer/host-timer/host-timer.wasm.go +13 -0
  162. package/go/gen/wasmnest/timer/host-timer/host-timer.wit.go +25 -0
  163. package/go/gen/wasmnest/ws/host-websocket/empty.s +3 -0
  164. package/go/gen/wasmnest/ws/host-websocket/host-websocket.wasm.go +29 -0
  165. package/go/gen/wasmnest/ws/host-websocket/host-websocket.wit.go +109 -0
  166. package/go/gen/wasmnest/ws-server/host-websocket-server/empty.s +3 -0
  167. package/go/gen/wasmnest/ws-server/host-websocket-server/host-websocket-server.wasm.go +49 -0
  168. package/go/gen/wasmnest/ws-server/host-websocket-server/host-websocket-server.wit.go +220 -0
  169. package/go/go.mod +14 -0
  170. package/go/go.sum +2 -0
  171. package/go/sdk/dispatch.go +49 -0
  172. package/go/sdk/dispatch_test.go +81 -0
  173. package/go/sdk/entry_native.go +13 -0
  174. package/go/sdk/entry_wasip2.go +188 -0
  175. package/go/sdk/host_http_wasip2.go +42 -0
  176. package/go/sdk/host_wasip2.go +251 -0
  177. package/go/sdk/plugin.go +103 -0
  178. package/go/testplugin/index.js +1 -0
  179. package/go/testplugin/main.go +67 -0
  180. package/go/testplugin/plugin.json +24 -0
  181. package/go/tools/assemble-wit.mjs +152 -0
  182. package/go/tools/gen-bindings.mjs +51 -0
  183. package/go/wit/core.wit +273 -0
  184. package/go/wit/deps/api-call/cap-api-call.wit +20 -0
  185. package/go/wit/deps/app/cap-app.wit +54 -0
  186. package/go/wit/deps/auth-center/cap-auth-center.wit +124 -0
  187. package/go/wit/deps/clipboard/clipboard.wit +48 -0
  188. package/go/wit/deps/clocks/monotonic-clock.wit +45 -0
  189. package/go/wit/deps/clocks/wall-clock.wit +42 -0
  190. package/go/wit/deps/clocks/world.wit +6 -0
  191. package/go/wit/deps/connection-registry/cap-connection-registry.wit +40 -0
  192. package/go/wit/deps/crypto/cap-crypto.wit +68 -0
  193. package/go/wit/deps/filesystem/preopens.wit +8 -0
  194. package/go/wit/deps/filesystem/types.wit +634 -0
  195. package/go/wit/deps/filesystem/world.wit +6 -0
  196. package/go/wit/deps/fs-desktop/cap-fs-desktop.wit +29 -0
  197. package/go/wit/deps/http/http.wit +28 -0
  198. package/go/wit/deps/http-endpoint/cap-http.wit +44 -0
  199. package/go/wit/deps/io/error.wit +34 -0
  200. package/go/wit/deps/io/poll.wit +41 -0
  201. package/go/wit/deps/io/streams.wit +262 -0
  202. package/go/wit/deps/io/world.wit +6 -0
  203. package/go/wit/deps/mdns/mdns.wit +45 -0
  204. package/go/wit/deps/notify/notify.wit +51 -0
  205. package/go/wit/deps/peer/peer.wit +126 -0
  206. package/go/wit/deps/platform-desktop/cap-platform-desktop.wit +38 -0
  207. package/go/wit/deps/process/cap-process.wit +25 -0
  208. package/go/wit/deps/pty/pty.wit +80 -0
  209. package/go/wit/deps/random/insecure-seed.wit +25 -0
  210. package/go/wit/deps/random/insecure.wit +22 -0
  211. package/go/wit/deps/random/random.wit +26 -0
  212. package/go/wit/deps/random/world.wit +7 -0
  213. package/go/wit/deps/sockets/instance-network.wit +9 -0
  214. package/go/wit/deps/sockets/ip-name-lookup.wit +51 -0
  215. package/go/wit/deps/sockets/network.wit +145 -0
  216. package/go/wit/deps/sockets/tcp-create-socket.wit +27 -0
  217. package/go/wit/deps/sockets/tcp.wit +353 -0
  218. package/go/wit/deps/sockets/udp-create-socket.wit +27 -0
  219. package/go/wit/deps/sockets/udp.wit +266 -0
  220. package/go/wit/deps/sockets/world.wit +11 -0
  221. package/go/wit/deps/task/cap-task.wit +56 -0
  222. package/go/wit/deps/timer/cap-timer.wit +14 -0
  223. package/go/wit/deps/wasi-cli/command.wit +7 -0
  224. package/go/wit/deps/wasi-cli/environment.wit +18 -0
  225. package/go/wit/deps/wasi-cli/exit.wit +4 -0
  226. package/go/wit/deps/wasi-cli/imports.wit +20 -0
  227. package/go/wit/deps/wasi-cli/run.wit +4 -0
  228. package/go/wit/deps/wasi-cli/stdio.wit +17 -0
  229. package/go/wit/deps/wasi-cli/terminal.wit +49 -0
  230. package/go/wit/deps/ws/ws.wit +50 -0
  231. package/go/wit/deps/ws-server/cap-ws.wit +99 -0
  232. package/go/wit/go-plugin.wit +28 -0
  233. package/go/wit/plugin-face.wit +355 -0
  234. package/go/wit/wasmnest.wit +25 -0
  235. package/package.json +100 -3
  236. package/src/config.ts +49 -0
  237. package/src/global-dialog.ts +169 -0
  238. package/src/index.ts +88 -0
  239. package/src/runtime.ts +54 -0
  240. package/src/types.ts +681 -0
  241. package/src/ui/AppUpdateSection.d.ts +44 -0
  242. package/src/ui/AppUpdateSection.vue +253 -0
  243. package/src/ui/MarkdownEditor.vue +520 -0
  244. package/src/ui/NumberField.d.ts +49 -0
  245. package/src/ui/NumberField.vue +390 -0
  246. package/src/ui/PluginGlobalDialog.vue +401 -0
  247. package/src/ui/Select.d.ts +36 -0
  248. package/src/ui/Select.vue +220 -0
  249. package/src/ui/TerminalInputRail.vue +184 -0
  250. package/src/ui/apply-select-position.ts +65 -0
  251. package/src/ui/markdown-editor-syntax.ts +234 -0
  252. package/src/ui/markdown-editor.d.ts +36 -0
  253. package/src/ui/plugin-global-dialog.d.ts +12 -0
  254. package/src/ui/select-position.ts +79 -0
  255. package/src/ui/terminal-input-rail.d.ts +30 -0
  256. package/src/ui/zoom-compensation.d.ts +9 -0
  257. package/src/ui/zoom-compensation.ts +52 -0
  258. package/src/update.ts +123 -0
  259. package/src/vite-plugin.ts +124 -0
  260. package/template/README.md +39 -0
  261. package/template/package.json +23 -0
  262. package/template/plugin.json +14 -0
  263. package/template/rust/Cargo.toml +21 -0
  264. package/template/rust/src/lib.rs +39 -0
  265. package/template/src/env.d.ts +24 -0
  266. package/template/src/index.ts +37 -0
  267. package/template/tsconfig.json +17 -0
  268. package/template/vite.config.ts +21 -0
  269. package/tools/componentize/Cargo.lock +299 -0
  270. package/tools/componentize/Cargo.toml +18 -0
  271. package/tools/componentize/src/main.rs +197 -0
@@ -0,0 +1,287 @@
1
+ <template>
2
+ <!-- 壳标题栏(与宿主 ShellToolbar 同构:品牌 · 当前位置 │ app 切换 · 主题 · 语言 · 日志) -->
3
+ <header class="shell-toolbar flex items-center gap-2 px-2 pl-3 select-none flex-shrink-0">
4
+ <!-- 品牌标志:与应用图标(src-tauri/icons/icon.svg)逐字同源——品牌 ink 斜向
5
+ 渐变底 + 编织 W。品牌固定色,不跟主题反色。 -->
6
+ <div class="flex items-center gap-2 min-w-0 shrink-0">
7
+ <svg class="w-[19px] h-[19px] shrink-0" viewBox="0 0 100 100" aria-hidden="true">
8
+ <defs>
9
+ <linearGradient id="shell-toolbar-logo-bg" x1="0%" y1="0%" x2="100%" y2="100%">
10
+ <stop offset="0%" stop-color="#16181C" />
11
+ <stop offset="100%" stop-color="#08090B" />
12
+ </linearGradient>
13
+ </defs>
14
+ <rect width="100" height="100" rx="22.5" fill="url(#shell-toolbar-logo-bg)" />
15
+ <g transform="translate(15.855,17.193) scale(0.68289)">
16
+ <polygon points="4.54,22.28 26.06,92.71 32.32,59.81 19.46,17.72" fill="#FF9E2C" />
17
+ <polygon points="24.22,90.61 51.10,56.86 51.10,34.38 29.84,61.08" fill="#F5F7F9" />
18
+ <polygon points="48.90,56.86 75.78,90.61 70.16,61.08 48.90,34.38" fill="#F5F7F9" />
19
+ <polygon points="73.94,92.71 95.46,22.28 80.54,17.72 67.68,59.81" fill="#F5F7F9" />
20
+ </g>
21
+ </svg>
22
+ <b class="text-[calc(13px*var(--ui-scale))] font-semibold tracking-tight text-[var(--text-primary)]"
23
+ >WasmNest</b
24
+ >
25
+ <span
26
+ class="tb-where text-[calc(11px*var(--ui-scale))] text-[var(--text-tertiary)] whitespace-nowrap overflow-hidden text-ellipsis min-w-0"
27
+ role="status"
28
+ aria-atomic="true"
29
+ >
30
+ {{ where }}
31
+ </span>
32
+ </div>
33
+
34
+ <!-- 右侧:app 切换 · 主题 · 语言 · 日志 -->
35
+ <div class="flex items-center gap-0.5 ml-auto shrink-0">
36
+ <!-- app 切换:多于一个被调试 app 时出现(宿主同形态是多任务面板,
37
+ dev-shell 无多任务层,这里用下拉直切) -->
38
+ <div v-if="apps.length > 1" class="relative shrink-0">
39
+ <button
40
+ class="tb-btn"
41
+ :aria-expanded="switcherOpen"
42
+ :title="t('devshell.toolbar.switchApp')"
43
+ @click="switcherOpen = !switcherOpen"
44
+ >
45
+ <ShellIcon name="layers" :size="15" />
46
+ {{ currentApp?.name ?? t('devshell.toolbar.noApp') }}
47
+ </button>
48
+ <div v-if="switcherOpen" class="tb-menu" role="menu">
49
+ <button
50
+ v-for="app in apps"
51
+ :key="app.id"
52
+ class="tb-menu-item"
53
+ role="menuitem"
54
+ :class="{ on: app.id === currentAppId }"
55
+ @click="pick(app.id)"
56
+ >
57
+ <ShellIcon :name="app.id === currentAppId ? 'check' : 'file'" :size="13" />
58
+ <span class="truncate">{{ app.name }}</span>
59
+ </button>
60
+ </div>
61
+ </div>
62
+
63
+ <!-- 主题切换:图标反映**当前**主题(深色=月亮 / 浅色=太阳),文案给点击后的动作 -->
64
+ <button class="tb-btn" :title="themeActionLabel" :aria-label="themeActionLabel" @click="toggleTheme">
65
+ <ShellIcon :name="isDark ? 'theme' : 'sun'" :size="15" />
66
+ </button>
67
+
68
+ <!-- 语言切换(中 / EN 分段按钮) -->
69
+ <div class="flex items-center rounded-btn bg-[var(--bg-hover)] p-0.5 shrink-0">
70
+ <button
71
+ v-for="opt in localeOptions"
72
+ :key="opt.value"
73
+ class="px-2 py-0.5 rounded text-xs transition-colors duration-200"
74
+ :class="
75
+ locale === opt.value
76
+ ? 'bg-[var(--color-primary)]/10 text-[var(--color-primary)]'
77
+ : 'text-[var(--text-secondary)] hover:text-[var(--text-primary)]'
78
+ "
79
+ @click="setLocale(opt.value)"
80
+ >
81
+ {{ opt.label }}
82
+ </button>
83
+ </div>
84
+
85
+ <span class="tb-sep mx-[5px]" aria-hidden="true"></span>
86
+
87
+ <!-- 日志面板开关(dev-shell 专有:命令 mock 命中情况都在这里) -->
88
+ <button
89
+ class="tb-btn"
90
+ :class="{ on: logOpen }"
91
+ :aria-pressed="logOpen"
92
+ :title="t('devshell.logs.title')"
93
+ :aria-label="t('devshell.logs.title')"
94
+ @click="emit('toggle-log')"
95
+ >
96
+ <ShellIcon name="info" :size="15" />
97
+ </button>
98
+ </div>
99
+ </header>
100
+ </template>
101
+
102
+ <script setup lang="ts">
103
+ /**
104
+ * ShellToolbar — dev-shell 壳标题栏(与宿主 `src/shell/components/ShellToolbar.vue` 同构)
105
+ *
106
+ * 与宿主的差异(都是「宿主面在浏览器里不存在」这一条原因,不是偷懒):
107
+ * - 裁掉**窗口控制**(最小化 / 最大化 / 关闭):浏览器没有宿主窗口;
108
+ * - 裁掉**通知中心 / 快捷设置 / 多任务面板**入口:它们是宿主覆层,dev-shell
109
+ * 不复刻宿主的应用管理面(那不是 app 开发者要调的界面);
110
+ * - 「返回 / 主屏」导航同样裁掉:dev-shell 没有主屏,界面就是被调试 app 本身。
111
+ *
112
+ * 保留的是**影响 app 观感的部分**:品牌标志、当前位置、主题切换(深浅色直接
113
+ * 决定 app 的配色验证结果)、工具栏高度(`--toolbar-h`,app 的可用高度与真机
114
+ * 一致)。
115
+ */
116
+ import { computed, ref, watch } from 'vue'
117
+ import { useI18n } from 'vue-i18n'
118
+ import ShellIcon from './ShellIcon.vue'
119
+ import { useHostUi } from '../../theme'
120
+ import { saveLocale, type DevLocale } from '../../locale'
121
+ import type { DevAppRecord } from '../../registry'
122
+
123
+ const props = defineProps<{
124
+ /** 被调试 app 列表 */
125
+ apps: DevAppRecord[]
126
+ /** 当前被调试 app 的 id */
127
+ currentAppId: string
128
+ /** 日志面板是否开着 */
129
+ logOpen: boolean
130
+ }>()
131
+
132
+ const emit = defineEmits<{
133
+ (e: 'select-app', appId: string): void
134
+ (e: 'toggle-log'): void
135
+ }>()
136
+
137
+ const { t, locale } = useI18n()
138
+ const { theme, setTheme } = useHostUi()
139
+
140
+ const switcherOpen = ref(false)
141
+
142
+ const currentApp = computed(() => props.apps.find((a) => a.id === props.currentAppId) ?? null)
143
+
144
+ /** 当前位置(role=status 播报):dev-shell 的「当前面」= 正在调试的 app */
145
+ const where = computed(() =>
146
+ currentApp.value
147
+ ? t('devshell.toolbar.debugging', { name: currentApp.value.name })
148
+ : t('devshell.toolbar.noApp'),
149
+ )
150
+
151
+ /** 当前生效暗色(system 跟随系统偏好) */
152
+ const isDark = computed(() => {
153
+ const mode = theme.value
154
+ if (mode === 'dark') return true
155
+ if (mode === 'light') return false
156
+ return window.matchMedia('(prefers-color-scheme: dark)').matches
157
+ })
158
+
159
+ /**
160
+ * 主题按钮文案:说「点一下会变成什么」。
161
+ *
162
+ * 与图标互补——图标画的是**当前**状态(深色=月亮 / 浅色=太阳),文案给动作方向;
163
+ * 两者都跟着 isDark 变,避免"图标永远一个月亮、看不出深浅"的哑按钮。
164
+ */
165
+ const themeActionLabel = computed(() =>
166
+ isDark.value ? t('devshell.toolbar.themeToLight') : t('devshell.toolbar.themeToDark'),
167
+ )
168
+
169
+ function toggleTheme() {
170
+ setTheme(isDark.value ? 'light' : 'dark')
171
+ }
172
+
173
+ // 语言切换选项(语言名用自身文字展示,无需翻译)
174
+ const localeOptions: { value: DevLocale; label: string }[] = [
175
+ { value: 'zh-CN', label: '中' },
176
+ { value: 'en', label: 'EN' },
177
+ ]
178
+
179
+ function setLocale(next: DevLocale) {
180
+ locale.value = next
181
+ saveLocale(next)
182
+ }
183
+
184
+ function pick(appId: string) {
185
+ switcherOpen.value = false
186
+ emit('select-app', appId)
187
+ }
188
+
189
+ // 切换 app 后收起下拉(否则菜单悬在旧 app 名旁)
190
+ watch(
191
+ () => props.currentAppId,
192
+ () => {
193
+ switcherOpen.value = false
194
+ },
195
+ )
196
+ </script>
197
+
198
+ <style scoped>
199
+ .shell-toolbar {
200
+ height: var(--toolbar-h);
201
+ background: var(--bg-card);
202
+ border-bottom: 1px solid var(--border);
203
+ position: relative;
204
+ z-index: 30;
205
+ }
206
+ .tb-btn {
207
+ min-width: 32px;
208
+ height: 28px;
209
+ padding: 0 7px;
210
+ border-radius: var(--radius-button);
211
+ color: var(--text-secondary);
212
+ display: inline-flex;
213
+ align-items: center;
214
+ justify-content: center;
215
+ gap: 6px;
216
+ font-size: calc(12px * var(--ui-scale));
217
+ position: relative;
218
+ transition:
219
+ background-color var(--motion-duration-fast) var(--motion-ease),
220
+ color var(--motion-duration-fast) var(--motion-ease);
221
+ }
222
+ .tb-btn:hover {
223
+ background: var(--bg-hover);
224
+ color: var(--text-primary);
225
+ }
226
+ .tb-btn:active:not(:disabled) {
227
+ background: var(--border);
228
+ }
229
+ .tb-btn:disabled {
230
+ opacity: 0.35;
231
+ cursor: default;
232
+ }
233
+ .tb-btn:disabled:hover {
234
+ background: none;
235
+ color: var(--text-secondary);
236
+ }
237
+ /* 当前面(选中态):实底而不是 12% 主色淡染——淡染在浅色主题下几乎与卡片底同色,
238
+ 开合状态看不出来 */
239
+ .tb-btn.on {
240
+ background: var(--bg-hover);
241
+ color: var(--text-primary);
242
+ }
243
+ .tb-sep {
244
+ width: 1px;
245
+ height: 18px;
246
+ background: var(--border-strong);
247
+ flex-shrink: 0;
248
+ }
249
+ /* app 切换下拉:贴工具栏右缘的浮层(与宿主覆层同一层级,Esc 之外的点外部关闭
250
+ 由 App.vue 统一处理) */
251
+ .tb-menu {
252
+ position: absolute;
253
+ top: calc(100% + 4px);
254
+ right: 0;
255
+ min-width: 200px;
256
+ max-height: 320px;
257
+ overflow-y: auto;
258
+ padding: 4px;
259
+ border-radius: var(--radius-card);
260
+ border: 1px solid var(--border);
261
+ background: var(--bg-card);
262
+ box-shadow: var(--shadow-card-hover);
263
+ z-index: 40;
264
+ }
265
+ .tb-menu-item {
266
+ display: flex;
267
+ align-items: center;
268
+ gap: 8px;
269
+ width: 100%;
270
+ padding: 6px 8px;
271
+ border-radius: var(--radius-button);
272
+ color: var(--text-secondary);
273
+ font-size: calc(12px * var(--ui-scale));
274
+ text-align: left;
275
+ transition:
276
+ background-color var(--motion-duration-fast) var(--motion-ease),
277
+ color var(--motion-duration-fast) var(--motion-ease);
278
+ }
279
+ .tb-menu-item:hover {
280
+ background: var(--bg-hover);
281
+ color: var(--text-primary);
282
+ }
283
+ .tb-menu-item.on {
284
+ color: var(--text-primary);
285
+ font-weight: 500;
286
+ }
287
+ </style>
@@ -0,0 +1,45 @@
1
+ /**
2
+ * 后台运行应用的「上次停在哪一页」记忆(壳机制面,零业务语义)
3
+ *
4
+ * 与宿主 `src/shell/mount/appSession.ts` **同构副本**:应用界面离开时挂载槽会卸载
5
+ * 该 app 的整包实例,再点应用图标是一次全新挂载——不记路径就只能回到落地页。
6
+ *
7
+ * 数据来源:**app 自报**(挂载契约 `AppMountEnv.onEvent('route', { path })`)。
8
+ * 宿主不解析应用内部路由语义,只按 appId 原样存一个路径串,下次挂载时作为
9
+ * `initialRoute` 交回。
10
+ *
11
+ * 进程内内存态,不落盘:重启应用后各自回落地页。
12
+ */
13
+ import { ref } from 'vue'
14
+
15
+ /** appId → 应用内部路由路径(读时才展开,避免调用方直接改表) */
16
+ const lastRoutes = ref<Readonly<Record<string, string>>>({})
17
+
18
+ /**
19
+ * 记录应用当前页(app 挂载包自报)。
20
+ *
21
+ * 非法输入(空 id / 空路径 / 根路径 / 非绝对路径)直接忽略:根路径不是「一页」,
22
+ * 记下来只会让下次挂载多推一次无意义的路由。
23
+ */
24
+ export function rememberAppRoute(appId: string, path: string): void {
25
+ if (!appId || !path || !path.startsWith('/') || path === '/') return
26
+ if (lastRoutes.value[appId] === path) return
27
+ lastRoutes.value = { ...lastRoutes.value, [appId]: path }
28
+ }
29
+
30
+ /** 应用上次停留的路径;无记录 → undefined(调用方回落落地页) */
31
+ export function lastRouteOf(appId: string): string | undefined {
32
+ return lastRoutes.value[appId]
33
+ }
34
+
35
+ /** 忘掉一个应用的页面记忆(停用 / 卸载时调用;幂等) */
36
+ export function forgetAppRoute(appId: string): void {
37
+ if (!(appId in lastRoutes.value)) return
38
+ const { [appId]: _dropped, ...rest } = lastRoutes.value
39
+ lastRoutes.value = rest
40
+ }
41
+
42
+ /** 清空全部记忆(「全部关闭」与测试隔离用) */
43
+ export function clearAppRoutes(): void {
44
+ lastRoutes.value = {}
45
+ }
@@ -0,0 +1,80 @@
1
+ /**
2
+ * 应用装载(桌面端 dev-shell)
3
+ * -----------------------------------------------------------------------------
4
+ * 与宿主 `src/shell/mount/useAppMount.ts` **同构**,只有一处本质差别:
5
+ *
6
+ * | | 宿主 | dev-shell |
7
+ * |---|---|---|
8
+ * | app 来源 | 独立构建的整包 `index.js`(`convertFileSrc` + 动态 import) | **源码** `src/entry.ts`(vite 已解析进构建图,HMR 直达) |
9
+ * | 契约校验 | 装载失败 → 显性报错面 | 同(`mountApp` 缺失 → 抛错) |
10
+ *
11
+ * 契约(`AppMountEnv` / `AppMountHandle`)逐字段对齐宿主,见
12
+ * `dev-shell/src/shell/types.ts` 与漂移锁
13
+ * `dev-shell/__tests__/shell/contractDrift.test.ts`。
14
+ */
15
+ import type { AppBundleModule, AppMountEnv, AppMountHandle } from '../types'
16
+
17
+ /** 已挂载实例(appId → handle);同一 app 重复挂载先卸载旧实例 */
18
+ const mounted = new Map<string, AppMountHandle>()
19
+
20
+ /**
21
+ * 装载并挂载一个 app
22
+ *
23
+ * @param module app 的挂载包模块(app 的 `src/entry.ts`)
24
+ * @throws app 未导出 `mountApp`(契约不匹配)→ 显性报错,不静默空挂
25
+ */
26
+ export async function mountAppSource(
27
+ appId: string,
28
+ module: AppBundleModule | null | undefined,
29
+ root: HTMLElement,
30
+ env: AppMountEnv,
31
+ ): Promise<AppMountHandle> {
32
+ await unmountApp(appId)
33
+ if (!module || typeof module.mountApp !== 'function') {
34
+ throw new Error(
35
+ `app "${appId}" 的挂载包未导出 mountApp(契约不匹配)——该 app 的入口应为 src/entry.ts`,
36
+ )
37
+ }
38
+ const handle = await module.mountApp(root, env)
39
+ mounted.set(appId, handle)
40
+ return handle
41
+ }
42
+
43
+ /** 卸载一个已挂载的 app 实例(幂等) */
44
+ export async function unmountApp(appId: string): Promise<void> {
45
+ const handle = mounted.get(appId)
46
+ if (!handle) return
47
+ mounted.delete(appId)
48
+ try {
49
+ await handle.unmount()
50
+ } catch (e) {
51
+ console.error(`[dev-shell] 卸载 app 失败:${appId}`, e)
52
+ }
53
+ }
54
+
55
+ /** 通知已挂载 app:宿主路由变化(应用内存路由消化) */
56
+ export async function notifyAppRoute(appId: string, route: string): Promise<void> {
57
+ const handle = mounted.get(appId)
58
+ if (!handle) return
59
+ try {
60
+ handle.setRoute?.(route)
61
+ } catch (e) {
62
+ console.error(`[dev-shell] 通知 app 路由失败:${appId}`, e)
63
+ }
64
+ }
65
+
66
+ /** 通知已挂载 app:宿主面事实变更(语言 / 主题) */
67
+ export async function notifyAppFact(
68
+ appId: string,
69
+ fact: 'locale' | 'theme',
70
+ value: string,
71
+ ): Promise<void> {
72
+ const handle = mounted.get(appId)
73
+ if (!handle) return
74
+ try {
75
+ if (fact === 'locale') handle.setLocale?.(value)
76
+ else handle.setTheme?.(value)
77
+ } catch (e) {
78
+ console.error(`[dev-shell] 通知 app ${fact} 失败:${appId}`, e)
79
+ }
80
+ }
@@ -0,0 +1,121 @@
1
+ /**
2
+ * 挂载契约(桌面端 dev-shell)——与宿主 `src/shell/mount/useAppMount.ts` **同形**
3
+ * -----------------------------------------------------------------------------
4
+ * 桌面 UI 宿主修正(机制 B)后,桌面 app 是**独立构建的挂载包**:入口导出
5
+ * `mountApp(root, env)`,宿主经挂载槽装载。dev-shell 走的是**同一条路径**——
6
+ * 它加载 app 的 `src/entry.ts` 源码并调用 `mountApp`,因此本文件必须与宿主
7
+ * `useAppMount.ts` 的契约逐字段对齐。
8
+ *
9
+ * 为什么逐字段对齐是硬要求:app 的 `entry.ts` 自带一份契约声明(各 app 独立
10
+ * 重复,宿主侧有 drift 锁钉住),dev-shell 是**第三份**声明。三份不一致时,
11
+ * 应用在真机正常、在 dev-shell 里某个字段静默为 undefined——预览与真机不等价,
12
+ * 而这正是 dev-shell 唯一不该发生的事。
13
+ *
14
+ * 漂移门禁:`dev-shell/__tests__/shell/contractDrift.test.ts` 逐字段比对本文件
15
+ * 与宿主 `useAppMount.ts`;宿主改了契约而本文件没跟上时该锁直接测红。
16
+ */
17
+
18
+ /** app 前端挂载环境(宿主注入;令牌/凭证已绑定本 app) */
19
+ export interface AppMountEnv {
20
+ /** 插件 id(= 应用 id) */
21
+ appId: string
22
+ /** 挂载契约版本(与宿主 MOUNT_CONTRACT 比对;不匹配 = 显性报错) */
23
+ mountContract: string
24
+ /** 宿主面命令(白名单代理,ADR 0058 方案 A):plugin_list_loaded / get_app_settings 等;白名单真源在桌面 src-tauri APP_FRONTEND_INVOKE_WHITELIST */
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
+ }
35
+ /** 插件面命令(plugin_invoke,本 app 通道令牌已绑定) */
36
+ appInvoke: <T = unknown>(command: string, ...args: unknown[]) => Promise<T>
37
+ /** 本 app 插件 KV 存储(plugin_storage_*,宿主面凭证已绑定) */
38
+ appStorageGet: <T = unknown>(key: string) => Promise<T | undefined>
39
+ appStorageSet: (key: string, value: unknown) => Promise<void>
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>
50
+ /** 宿主面事实(挂载时快照;后续变更经 handle.setLocale / setTheme 通知) */
51
+ locale: string
52
+ theme: string
53
+ platform?: string
54
+ /** 宿主路由传入的应用初始路径(应用以内存路由消化) */
55
+ initialRoute: string
56
+ /**
57
+ * 宿主面事件出口(可选)。当前两种事件:
58
+ * - `'navigate'`(payload = 宿主任一已知路径字符串):请求壳路由跳转;
59
+ * - `'route'`(payload = `{ path: string }`):应用**自报内部当前页**——应用跑内存
60
+ * 路由,宿主 history 看不到它的内部跳转,壳据此记住「切回该应用时回到哪一页」。
61
+ */
62
+ onEvent?: (type: string, payload: unknown) => void
63
+ /** 自定义监控面板装载(只对 monitor 的 env 注入;dev-shell 可省略) */
64
+ mountMonitorPanel?: (
65
+ root: HTMLElement,
66
+ appId: string,
67
+ panelId: string,
68
+ ) => Promise<MonitorPanelHandle>
69
+ }
70
+
71
+ /** 监控面板环境(收窄只读面;与宿主同形) */
72
+ export interface MonitorPanelEnv {
73
+ appId: string
74
+ panelId: string
75
+ appInvoke: <T = unknown>(command: string, ...args: unknown[]) => Promise<T>
76
+ appStorageGet: <T = unknown>(key: string) => Promise<T | undefined>
77
+ locale: string
78
+ theme: string
79
+ platform?: string
80
+ }
81
+
82
+ /** 监控面板句柄 */
83
+ export interface MonitorPanelHandle {
84
+ unmount(): Promise<void>
85
+ }
86
+
87
+ /** 提供方 app bundle 可选导出 */
88
+ export type MountMonitorPanel = (
89
+ root: HTMLElement,
90
+ env: MonitorPanelEnv,
91
+ ) => Promise<MonitorPanelHandle>
92
+
93
+ /** app 前端挂载句柄(宿主卸载 / 路由通知用) */
94
+ export interface AppMountHandle {
95
+ /** 卸载应用实例(销毁 Vue 实例 / 路由 / 监听) */
96
+ unmount(): Promise<void>
97
+ /** 宿主路由变化通知(应用内存路由消化;未实现 = 不支持宿主内路由切换) */
98
+ setRoute?(route: string): void
99
+ /**
100
+ * 前台 / 后台切换通知(可选):`false` = 界面已切到后台,DOM 与实例保留但
101
+ * 脱离文档不再渲染;`true` = 回到前台(同一实例,不会重新 mount)。
102
+ * 表面保活(2026-10-23)契约,旧应用不实现零影响。
103
+ */
104
+ setActive?(active: boolean): void
105
+ /** 宿主面事实变更通知(语言 / 主题) */
106
+ setLocale?(locale: string): void
107
+ setTheme?(theme: string): void
108
+ }
109
+
110
+ /**
111
+ * app 挂载包模块面(dev-shell 侧)
112
+ *
113
+ * `mountApp` 必有(否则契约不匹配,dev-shell 显性报错)。
114
+ * 与宿主 `useAppMount.ts` 的 `AppBundleModule` 同形。自绘预览面(mountPreview)
115
+ * 已随宿主退役(2026-10-30:多任务卡改挂载保活实例的真实页面,应用不再自报预览)。
116
+ */
117
+ export interface AppBundleModule {
118
+ mountContract?: string
119
+ mountApp?: (root: HTMLElement, env: AppMountEnv) => Promise<AppMountHandle>
120
+ mountMonitorPanel?: MountMonitorPanel
121
+ }
@@ -0,0 +1,27 @@
1
+ /* Dev Shell 附加样式(宿主 style.css / shell.css 之外的本环境专有样式) */
2
+
3
+ html,
4
+ body,
5
+ #app {
6
+ height: 100%;
7
+ }
8
+
9
+ body {
10
+ margin: 0;
11
+ overflow: hidden;
12
+ }
13
+
14
+ ::-webkit-scrollbar {
15
+ width: 8px;
16
+ height: 8px;
17
+ }
18
+ ::-webkit-scrollbar-track {
19
+ background: transparent;
20
+ }
21
+ ::-webkit-scrollbar-thumb {
22
+ background: color-mix(in srgb, var(--text-secondary) 30%, transparent);
23
+ border-radius: 4px;
24
+ }
25
+ ::-webkit-scrollbar-thumb:hover {
26
+ background: color-mix(in srgb, var(--text-secondary) 45%, transparent);
27
+ }