@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,299 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 4
4
+
5
+ [[package]]
6
+ name = "anyhow"
7
+ version = "1.0.104"
8
+ source = "registry+https://github.com/rust-lang/crates.io-index"
9
+ checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470"
10
+
11
+ [[package]]
12
+ name = "bitflags"
13
+ version = "2.13.1"
14
+ source = "registry+https://github.com/rust-lang/crates.io-index"
15
+ checksum = "b588b76d00fde79687d7646a9b5bdf3cc0f655e0bbd080335a95d7e96f3587da"
16
+
17
+ [[package]]
18
+ name = "equivalent"
19
+ version = "1.0.2"
20
+ source = "registry+https://github.com/rust-lang/crates.io-index"
21
+ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
22
+
23
+ [[package]]
24
+ name = "foldhash"
25
+ version = "0.2.0"
26
+ source = "registry+https://github.com/rust-lang/crates.io-index"
27
+ checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb"
28
+
29
+ [[package]]
30
+ name = "hashbrown"
31
+ version = "0.17.1"
32
+ source = "registry+https://github.com/rust-lang/crates.io-index"
33
+ checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
34
+ dependencies = [
35
+ "foldhash",
36
+ ]
37
+
38
+ [[package]]
39
+ name = "id-arena"
40
+ version = "2.3.0"
41
+ source = "registry+https://github.com/rust-lang/crates.io-index"
42
+ checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954"
43
+
44
+ [[package]]
45
+ name = "indexmap"
46
+ version = "2.14.0"
47
+ source = "registry+https://github.com/rust-lang/crates.io-index"
48
+ checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9"
49
+ dependencies = [
50
+ "equivalent",
51
+ "hashbrown",
52
+ "serde",
53
+ "serde_core",
54
+ ]
55
+
56
+ [[package]]
57
+ name = "itoa"
58
+ version = "1.0.18"
59
+ source = "registry+https://github.com/rust-lang/crates.io-index"
60
+ checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
61
+
62
+ [[package]]
63
+ name = "leb128fmt"
64
+ version = "0.1.0"
65
+ source = "registry+https://github.com/rust-lang/crates.io-index"
66
+ checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2"
67
+
68
+ [[package]]
69
+ name = "log"
70
+ version = "0.4.33"
71
+ source = "registry+https://github.com/rust-lang/crates.io-index"
72
+ checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad"
73
+
74
+ [[package]]
75
+ name = "memchr"
76
+ version = "2.8.3"
77
+ source = "registry+https://github.com/rust-lang/crates.io-index"
78
+ checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
79
+
80
+ [[package]]
81
+ name = "proc-macro2"
82
+ version = "1.0.107"
83
+ source = "registry+https://github.com/rust-lang/crates.io-index"
84
+ checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
85
+ dependencies = [
86
+ "unicode-ident",
87
+ ]
88
+
89
+ [[package]]
90
+ name = "quote"
91
+ version = "1.0.47"
92
+ source = "registry+https://github.com/rust-lang/crates.io-index"
93
+ checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
94
+ dependencies = [
95
+ "proc-macro2",
96
+ ]
97
+
98
+ [[package]]
99
+ name = "semver"
100
+ version = "1.0.28"
101
+ source = "registry+https://github.com/rust-lang/crates.io-index"
102
+ checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd"
103
+
104
+ [[package]]
105
+ name = "serde"
106
+ version = "1.0.229"
107
+ source = "registry+https://github.com/rust-lang/crates.io-index"
108
+ checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
109
+ dependencies = [
110
+ "serde_core",
111
+ ]
112
+
113
+ [[package]]
114
+ name = "serde_core"
115
+ version = "1.0.229"
116
+ source = "registry+https://github.com/rust-lang/crates.io-index"
117
+ checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
118
+ dependencies = [
119
+ "serde_derive",
120
+ ]
121
+
122
+ [[package]]
123
+ name = "serde_derive"
124
+ version = "1.0.229"
125
+ source = "registry+https://github.com/rust-lang/crates.io-index"
126
+ checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
127
+ dependencies = [
128
+ "proc-macro2",
129
+ "quote",
130
+ "syn",
131
+ ]
132
+
133
+ [[package]]
134
+ name = "serde_json"
135
+ version = "1.0.151"
136
+ source = "registry+https://github.com/rust-lang/crates.io-index"
137
+ checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14"
138
+ dependencies = [
139
+ "itoa",
140
+ "memchr",
141
+ "serde",
142
+ "serde_core",
143
+ "zmij",
144
+ ]
145
+
146
+ [[package]]
147
+ name = "syn"
148
+ version = "3.0.3"
149
+ source = "registry+https://github.com/rust-lang/crates.io-index"
150
+ checksum = "53e9bae58849f64dfa4f5d5ae372c8341f7305f82a3868709269343628b659a3"
151
+ dependencies = [
152
+ "proc-macro2",
153
+ "quote",
154
+ "unicode-ident",
155
+ ]
156
+
157
+ [[package]]
158
+ name = "unicode-ident"
159
+ version = "1.0.24"
160
+ source = "registry+https://github.com/rust-lang/crates.io-index"
161
+ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
162
+
163
+ [[package]]
164
+ name = "wasm-encoder"
165
+ version = "0.256.0"
166
+ source = "registry+https://github.com/rust-lang/crates.io-index"
167
+ checksum = "ec1492381bfd5ea51c2a99a919b676662559925cb8d7490547ec2e14c1ad3eb1"
168
+ dependencies = [
169
+ "leb128fmt",
170
+ "wasmparser",
171
+ ]
172
+
173
+ [[package]]
174
+ name = "wasm-metadata"
175
+ version = "0.256.0"
176
+ source = "registry+https://github.com/rust-lang/crates.io-index"
177
+ checksum = "d6187f9fce741db43bea48f1ec42174897d763b8cdea7df726f2dd05561848d7"
178
+ dependencies = [
179
+ "anyhow",
180
+ "indexmap",
181
+ "wasm-encoder",
182
+ "wasmparser",
183
+ ]
184
+
185
+ [[package]]
186
+ name = "wasmnest-componentize"
187
+ version = "0.0.1"
188
+ dependencies = [
189
+ "wit-component",
190
+ "wit-parser",
191
+ ]
192
+
193
+ [[package]]
194
+ name = "wasmparser"
195
+ version = "0.256.0"
196
+ source = "registry+https://github.com/rust-lang/crates.io-index"
197
+ checksum = "60bd825ffedc6cba8a642924ba7ae424afbc47811cffbcb7b92031ec24e59b4c"
198
+ dependencies = [
199
+ "bitflags",
200
+ "hashbrown",
201
+ "indexmap",
202
+ "semver",
203
+ ]
204
+
205
+ [[package]]
206
+ name = "wit-component"
207
+ version = "0.256.0"
208
+ source = "registry+https://github.com/rust-lang/crates.io-index"
209
+ checksum = "c3d537ec182eed18f560184b870287cf443c4eccc315af178db3eae8811c3b6c"
210
+ dependencies = [
211
+ "anyhow",
212
+ "bitflags",
213
+ "indexmap",
214
+ "log",
215
+ "serde",
216
+ "serde_derive",
217
+ "serde_json",
218
+ "wasm-encoder",
219
+ "wasm-metadata",
220
+ "wasmparser",
221
+ "wit-parser",
222
+ ]
223
+
224
+ [[package]]
225
+ name = "wit-parser"
226
+ version = "0.256.0"
227
+ source = "registry+https://github.com/rust-lang/crates.io-index"
228
+ checksum = "fa073dadefba859cb03f689a0c2e3efc51f883bf86b907eaa9709bfd9e3a00a9"
229
+ dependencies = [
230
+ "anyhow",
231
+ "hashbrown",
232
+ "id-arena",
233
+ "indexmap",
234
+ "log",
235
+ "semver",
236
+ "serde",
237
+ "serde_derive",
238
+ "serde_json",
239
+ "unicode-ident",
240
+ "wasmparser",
241
+ ]
242
+
243
+ [[package]]
244
+ name = "zmij"
245
+ version = "1.0.23"
246
+ source = "registry+https://github.com/rust-lang/crates.io-index"
247
+ checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
248
+
249
+ [[patch.unused]]
250
+ name = "wasmnest-plugin-api"
251
+ version = "0.0.2"
252
+
253
+ [[patch.unused]]
254
+ name = "wasmnest-plugin-api-macros"
255
+ version = "0.0.2"
256
+
257
+ [[patch.unused]]
258
+ name = "wasmnest-crypto-engine"
259
+ version = "0.0.1"
260
+
261
+ [[patch.unused]]
262
+ name = "wasmnest-discovery-engine"
263
+ version = "0.0.1"
264
+
265
+ [[patch.unused]]
266
+ name = "wasmnest-host-kit"
267
+ version = "0.0.1"
268
+
269
+ [[patch.unused]]
270
+ name = "wasmnest-link-crypto"
271
+ version = "0.0.1"
272
+
273
+ [[patch.unused]]
274
+ name = "wasmnest-pty-engine"
275
+ version = "0.0.1"
276
+
277
+ [[patch.unused]]
278
+ name = "wasmnest-server-base"
279
+ version = "0.0.1"
280
+
281
+ [[patch.unused]]
282
+ name = "wasmnest-server-core"
283
+ version = "0.0.1"
284
+
285
+ [[patch.unused]]
286
+ name = "wasmnest-server-http"
287
+ version = "0.0.1"
288
+
289
+ [[patch.unused]]
290
+ name = "wasmnest-server-peer-net"
291
+ version = "0.0.1"
292
+
293
+ [[patch.unused]]
294
+ name = "wasmnest-server-websocket"
295
+ version = "0.0.1"
296
+
297
+ [[patch.unused]]
298
+ name = "wasmnest-wasm-core"
299
+ version = "0.0.1"
@@ -0,0 +1,18 @@
1
+ [package]
2
+ name = "wasmnest-componentize"
3
+ version = "0.0.1"
4
+ license = "MIT"
5
+ edition = "2021"
6
+ description = "WasmNest 插件组件化工具(仓库级,双端共用)— 将 wit-bindgen 产出的 core module 编码为 Component Model 组件(等价 wasm-tools component new)"
7
+
8
+ [[bin]]
9
+ name = "componentize"
10
+ path = "src/main.rs"
11
+
12
+ [dependencies]
13
+ # 与宿主 src-tauri dev-dep 同版本(spike 实证 0.256 编码产物 00 61 73 6d 0d 00 01 00),
14
+ # 保证编码行为一致;与 wit-bindgen 版本无锁(独立演进,见迁移 spec §4 S2)
15
+ wit-component = "=0.256.0"
16
+ # `--list-packages` 需要遍历 decoded resolve 的 world 成员类型(WorldKey / WorldItem);
17
+ # 必须与 wit-component 同一 wit-parser 版本,否则类型不是同一个 crate(编译期即红)
18
+ wit-parser = "=0.256.0"
@@ -0,0 +1,197 @@
1
+ //! 插件组件化工具(迁移阶段 B 构建链)
2
+ //!
3
+ //! 将 wit-bindgen 产出的 core module(含 `component-type` 自定义段)编码为
4
+ //! Component Model 组件,等价于 `wasm-tools component new`:
5
+ //! - 产物已是组件(魔法字节 `0d 00 01 00`)时直接复制(幂等,支持增量构建)
6
+ //! - 编码失败的输入(无组件元数据)给出明确错误
7
+ //!
8
+ //! 用法:`componentize <input.wasm> -o <output.wasm>`
9
+ //! 插件构建脚本(wasm-apps/*/scripts/build.js)在 cargo build 后调用本工具。
10
+ //!
11
+ //! 另有只读模式 `componentize --list-packages <component.wasm>`:解码组件,
12
+ //! 输出其 world 实际 import / export 的 `wasmnest:` WIT 包 → 版本 JSON
13
+ //! (ADR 0061 拆包后的发布下限:`compat.witPackages` 必须来自**二进制本身**,
14
+ //! 不能从源码猜)。同一包出现两个版本即失败(组件不可能合法地同时依赖两版)。
15
+
16
+ use std::collections::BTreeMap;
17
+ use std::process::ExitCode;
18
+
19
+ use wit_parser::{WorldItem, WorldKey};
20
+
21
+ fn main() -> ExitCode {
22
+ let args: Vec<String> = std::env::args().collect();
23
+ let mut input: Option<String> = None;
24
+ let mut output: Option<String> = None;
25
+ let mut list_packages: Option<String> = None;
26
+
27
+ let mut i = 1;
28
+ while i < args.len() {
29
+ match args[i].as_str() {
30
+ "--list-packages" => {
31
+ if i + 1 < args.len() {
32
+ list_packages = Some(args[i + 1].clone());
33
+ i += 1;
34
+ } else {
35
+ eprintln!("Missing value after --list-packages");
36
+ return ExitCode::FAILURE;
37
+ }
38
+ }
39
+ "-o" | "--output" => {
40
+ if i + 1 < args.len() {
41
+ output = Some(args[i + 1].clone());
42
+ i += 1;
43
+ } else {
44
+ eprintln!("Missing value after {}", args[i]);
45
+ return ExitCode::FAILURE;
46
+ }
47
+ }
48
+ a if a.starts_with('-') => {
49
+ eprintln!("Unknown option: {}", a);
50
+ return ExitCode::FAILURE;
51
+ }
52
+ a => input = Some(a.to_string()),
53
+ }
54
+ i += 1;
55
+ }
56
+
57
+ if let Some(path) = list_packages {
58
+ return list_component_packages(&path);
59
+ }
60
+
61
+ let (Some(input), Some(output)) = (input, output) else {
62
+ eprintln!("Usage: componentize <input.wasm> -o <output.wasm>");
63
+ eprintln!(" componentize --list-packages <component.wasm>");
64
+ return ExitCode::FAILURE;
65
+ };
66
+
67
+ let bytes = match std::fs::read(&input) {
68
+ Ok(b) => b,
69
+ Err(e) => {
70
+ eprintln!("Failed to read {}: {}", input, e);
71
+ return ExitCode::FAILURE;
72
+ }
73
+ };
74
+
75
+ // 幂等:产物已是组件(版本字 0d 00 01 00)则直接复制
76
+ if bytes.len() >= 8 && &bytes[0..4] == b"\0asm" && &bytes[4..8] == [0x0d, 0x00, 0x01, 0x00] {
77
+ return match std::fs::write(&output, &bytes) {
78
+ Ok(()) => {
79
+ println!("componentize: {} already a component, copied to {}", input, output);
80
+ ExitCode::SUCCESS
81
+ }
82
+ Err(e) => {
83
+ eprintln!("Failed to write {}: {}", output, e);
84
+ ExitCode::FAILURE
85
+ }
86
+ };
87
+ }
88
+
89
+ let mut encoder = match wit_component::ComponentEncoder::default().module(&bytes) {
90
+ Ok(e) => e,
91
+ Err(e) => {
92
+ eprintln!(
93
+ "componentize: {} is not a componentizable core module (missing WIT metadata): {}",
94
+ input, e
95
+ );
96
+ return ExitCode::FAILURE;
97
+ }
98
+ };
99
+ let encoded = match encoder.encode() {
100
+ Ok(b) => b,
101
+ Err(e) => {
102
+ eprintln!("componentize: encode {} failed: {}", input, e);
103
+ return ExitCode::FAILURE;
104
+ }
105
+ };
106
+
107
+ match std::fs::write(&output, &encoded) {
108
+ Ok(()) => {
109
+ println!("componentize: {} -> {} ({} bytes)", input, output, encoded.len());
110
+ ExitCode::SUCCESS
111
+ }
112
+ Err(e) => {
113
+ eprintln!("Failed to write {}: {}", output, e);
114
+ ExitCode::FAILURE
115
+ }
116
+ }
117
+ }
118
+
119
+ /// `--list-packages`:列出组件 world 实际 import/export 的 `wasmnest:` 包 → 版本
120
+ ///
121
+ /// 只保留 `wasmnest:` 前缀(WASI 包由宿主运行时负责,不进本门禁)。输出为单行
122
+ /// JSON(键排序),供构建脚本写入 `compat.witPackages`。
123
+ fn list_component_packages(path: &str) -> ExitCode {
124
+ let bytes = match std::fs::read(path) {
125
+ Ok(b) => b,
126
+ Err(e) => {
127
+ eprintln!("Failed to read {}: {}", path, e);
128
+ return ExitCode::FAILURE;
129
+ }
130
+ };
131
+ let decoded = match wit_component::decode(&bytes) {
132
+ Ok(d) => d,
133
+ Err(e) => {
134
+ eprintln!("list-packages: decode {} failed: {}", path, e);
135
+ return ExitCode::FAILURE;
136
+ }
137
+ };
138
+ let (resolve, world_id) = match decoded {
139
+ wit_component::DecodedWasm::Component(resolve, world) => (resolve, world),
140
+ wit_component::DecodedWasm::WitPackage(..) => {
141
+ eprintln!(
142
+ "list-packages: {} 是 WIT 包而不是组件(需要构建后的 component)",
143
+ path
144
+ );
145
+ return ExitCode::FAILURE;
146
+ }
147
+ };
148
+ let world = &resolve.worlds[world_id];
149
+ let mut packages: BTreeMap<String, String> = BTreeMap::new();
150
+ let push = |iface_id: wit_parser::InterfaceId, packages: &mut BTreeMap<String, String>| {
151
+ let iface = &resolve.interfaces[iface_id];
152
+ let Some(pkg_id) = iface.package else { return };
153
+ let pkg = &resolve.packages[pkg_id].name;
154
+ if pkg.namespace != "wasmnest" {
155
+ return;
156
+ }
157
+ let name = format!("{}:{}", pkg.namespace, pkg.name);
158
+ let version = pkg
159
+ .version
160
+ .as_ref()
161
+ .map(|v| v.to_string())
162
+ .unwrap_or_default();
163
+ match packages.get(&name) {
164
+ Some(prev) if *prev != version => {
165
+ eprintln!(
166
+ "list-packages: 包 {} 在组件里出现两个版本({} 与 {})",
167
+ name, prev, version
168
+ );
169
+ // 交给外层用 Err 语义处理:这里直接 panic 不如返回标记
170
+ packages.insert(name.clone(), format!("{}!{}", prev, version));
171
+ }
172
+ Some(_) => {}
173
+ None => {
174
+ packages.insert(name, version);
175
+ }
176
+ }
177
+ };
178
+ for (key, item) in world.imports.iter().chain(world.exports.iter()) {
179
+ if let WorldKey::Interface(id) = key {
180
+ push(*id, &mut packages);
181
+ }
182
+ if let WorldItem::Interface { id, .. } = item {
183
+ push(*id, &mut packages);
184
+ }
185
+ }
186
+ if let Some((name, _)) = packages.iter().find(|(_, v)| v.contains('!')) {
187
+ eprintln!("list-packages: 包版本冲突 {}", name);
188
+ return ExitCode::FAILURE;
189
+ }
190
+ let body = packages
191
+ .iter()
192
+ .map(|(k, v)| format!("\"{}\":\"{}\"", k, v))
193
+ .collect::<Vec<_>>()
194
+ .join(",");
195
+ println!("{{{}}}", body);
196
+ ExitCode::SUCCESS
197
+ }