@bytecodealliance/jco 1.32.1 → 1.34.0

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 (264) hide show
  1. package/README.md +12 -1
  2. package/dist/bundle.d.ts +2 -0
  3. package/dist/bundle.d.ts.map +1 -1
  4. package/dist/bundle.js +12 -0
  5. package/dist/bundle.js.map +1 -1
  6. package/dist/cmd/componentize.d.ts +33 -0
  7. package/dist/cmd/componentize.d.ts.map +1 -1
  8. package/dist/cmd/componentize.js +92 -8
  9. package/dist/cmd/componentize.js.map +1 -1
  10. package/dist/cmd/new.js +2 -1
  11. package/dist/cmd/new.js.map +1 -1
  12. package/dist/cmd/run.d.ts.map +1 -1
  13. package/dist/cmd/run.js +58 -1
  14. package/dist/cmd/run.js.map +1 -1
  15. package/dist/cmd/transpile.d.ts +5 -1
  16. package/dist/cmd/transpile.d.ts.map +1 -1
  17. package/dist/cmd/transpile.js +124 -0
  18. package/dist/cmd/transpile.js.map +1 -1
  19. package/dist/engine-compat.d.ts +11 -0
  20. package/dist/engine-compat.d.ts.map +1 -0
  21. package/dist/engine-compat.js +56 -0
  22. package/dist/engine-compat.js.map +1 -0
  23. package/dist/jco.js +12 -1
  24. package/dist/jco.js.map +1 -1
  25. package/dist/node-builtins/assert.d.ts +3 -0
  26. package/dist/node-builtins/assert.d.ts.map +1 -0
  27. package/dist/node-builtins/assert.js +65 -0
  28. package/dist/node-builtins/assert.js.map +1 -0
  29. package/dist/node-builtins/async-hooks.d.ts +3 -0
  30. package/dist/node-builtins/async-hooks.d.ts.map +1 -0
  31. package/dist/node-builtins/async-hooks.js +27 -0
  32. package/dist/node-builtins/async-hooks.js.map +1 -0
  33. package/dist/node-builtins/buffer.d.ts +4 -0
  34. package/dist/node-builtins/buffer.d.ts.map +1 -0
  35. package/dist/node-builtins/buffer.js +87 -0
  36. package/dist/node-builtins/buffer.js.map +1 -0
  37. package/dist/node-builtins/child-process.d.ts +3 -0
  38. package/dist/node-builtins/child-process.d.ts.map +1 -0
  39. package/dist/node-builtins/child-process.js +23 -0
  40. package/dist/node-builtins/child-process.js.map +1 -0
  41. package/dist/node-builtins/cluster.d.ts +3 -0
  42. package/dist/node-builtins/cluster.d.ts.map +1 -0
  43. package/dist/node-builtins/cluster.js +28 -0
  44. package/dist/node-builtins/cluster.js.map +1 -0
  45. package/dist/node-builtins/console.d.ts +3 -0
  46. package/dist/node-builtins/console.d.ts.map +1 -0
  47. package/dist/node-builtins/console.js +39 -0
  48. package/dist/node-builtins/console.js.map +1 -0
  49. package/dist/node-builtins/crypto.d.ts +3 -0
  50. package/dist/node-builtins/crypto.d.ts.map +1 -0
  51. package/dist/node-builtins/crypto.js +5 -0
  52. package/dist/node-builtins/crypto.js.map +1 -0
  53. package/dist/node-builtins/dgram.d.ts +4 -0
  54. package/dist/node-builtins/dgram.d.ts.map +1 -0
  55. package/dist/node-builtins/dgram.js +13 -0
  56. package/dist/node-builtins/dgram.js.map +1 -0
  57. package/dist/node-builtins/diagnostics-channel.d.ts +3 -0
  58. package/dist/node-builtins/diagnostics-channel.d.ts.map +1 -0
  59. package/dist/node-builtins/diagnostics-channel.js +26 -0
  60. package/dist/node-builtins/diagnostics-channel.js.map +1 -0
  61. package/dist/node-builtins/dns.d.ts +3 -0
  62. package/dist/node-builtins/dns.d.ts.map +1 -0
  63. package/dist/node-builtins/dns.js +12 -0
  64. package/dist/node-builtins/dns.js.map +1 -0
  65. package/dist/node-builtins/domain.d.ts +3 -0
  66. package/dist/node-builtins/domain.d.ts.map +1 -0
  67. package/dist/node-builtins/domain.js +19 -0
  68. package/dist/node-builtins/domain.js.map +1 -0
  69. package/dist/node-builtins/events.d.ts +3 -0
  70. package/dist/node-builtins/events.d.ts.map +1 -0
  71. package/dist/node-builtins/events.js +39 -0
  72. package/dist/node-builtins/events.js.map +1 -0
  73. package/dist/node-builtins/ffi.d.ts +3 -0
  74. package/dist/node-builtins/ffi.d.ts.map +1 -0
  75. package/dist/node-builtins/ffi.js +59 -0
  76. package/dist/node-builtins/ffi.js.map +1 -0
  77. package/dist/node-builtins/fs.d.ts +3 -0
  78. package/dist/node-builtins/fs.d.ts.map +1 -0
  79. package/dist/node-builtins/fs.js +16 -0
  80. package/dist/node-builtins/fs.js.map +1 -0
  81. package/dist/node-builtins/globals.d.ts +19 -0
  82. package/dist/node-builtins/globals.d.ts.map +1 -0
  83. package/dist/node-builtins/globals.js +56 -0
  84. package/dist/node-builtins/globals.js.map +1 -0
  85. package/dist/node-builtins/http-common.d.ts +6 -0
  86. package/dist/node-builtins/http-common.d.ts.map +1 -0
  87. package/dist/node-builtins/http-common.js +111 -0
  88. package/dist/node-builtins/http-common.js.map +1 -0
  89. package/dist/node-builtins/http.d.ts +4 -0
  90. package/dist/node-builtins/http.d.ts.map +1 -0
  91. package/dist/node-builtins/http.js +15 -0
  92. package/dist/node-builtins/http.js.map +1 -0
  93. package/dist/node-builtins/http2.d.ts +4 -0
  94. package/dist/node-builtins/http2.d.ts.map +1 -0
  95. package/dist/node-builtins/http2.js +79 -0
  96. package/dist/node-builtins/http2.js.map +1 -0
  97. package/dist/node-builtins/https.d.ts +3 -0
  98. package/dist/node-builtins/https.d.ts.map +1 -0
  99. package/dist/node-builtins/https.js +5 -0
  100. package/dist/node-builtins/https.js.map +1 -0
  101. package/dist/node-builtins/index.d.ts +10 -0
  102. package/dist/node-builtins/index.d.ts.map +1 -0
  103. package/dist/node-builtins/index.js +164 -0
  104. package/dist/node-builtins/index.js.map +1 -0
  105. package/dist/node-builtins/inspector.d.ts +12 -0
  106. package/dist/node-builtins/inspector.d.ts.map +1 -0
  107. package/dist/node-builtins/inspector.js +70 -0
  108. package/dist/node-builtins/inspector.js.map +1 -0
  109. package/dist/node-builtins/module.d.ts +3 -0
  110. package/dist/node-builtins/module.d.ts.map +1 -0
  111. package/dist/node-builtins/module.js +55 -0
  112. package/dist/node-builtins/module.js.map +1 -0
  113. package/dist/node-builtins/net.d.ts +3 -0
  114. package/dist/node-builtins/net.d.ts.map +1 -0
  115. package/dist/node-builtins/net.js +46 -0
  116. package/dist/node-builtins/net.js.map +1 -0
  117. package/dist/node-builtins/os.d.ts +3 -0
  118. package/dist/node-builtins/os.d.ts.map +1 -0
  119. package/dist/node-builtins/os.js +39 -0
  120. package/dist/node-builtins/os.js.map +1 -0
  121. package/dist/node-builtins/path.d.ts +3 -0
  122. package/dist/node-builtins/path.d.ts.map +1 -0
  123. package/dist/node-builtins/path.js +91 -0
  124. package/dist/node-builtins/path.js.map +1 -0
  125. package/dist/node-builtins/perf-hooks.d.ts +3 -0
  126. package/dist/node-builtins/perf-hooks.d.ts.map +1 -0
  127. package/dist/node-builtins/perf-hooks.js +12 -0
  128. package/dist/node-builtins/perf-hooks.js.map +1 -0
  129. package/dist/node-builtins/process.d.ts +3 -0
  130. package/dist/node-builtins/process.d.ts.map +1 -0
  131. package/dist/node-builtins/process.js +9 -0
  132. package/dist/node-builtins/process.js.map +1 -0
  133. package/dist/node-builtins/querystring.d.ts +3 -0
  134. package/dist/node-builtins/querystring.d.ts.map +1 -0
  135. package/dist/node-builtins/querystring.js +18 -0
  136. package/dist/node-builtins/querystring.js.map +1 -0
  137. package/dist/node-builtins/readline.d.ts +3 -0
  138. package/dist/node-builtins/readline.d.ts.map +1 -0
  139. package/dist/node-builtins/readline.js +11 -0
  140. package/dist/node-builtins/readline.js.map +1 -0
  141. package/dist/node-builtins/repl.d.ts +9 -0
  142. package/dist/node-builtins/repl.d.ts.map +1 -0
  143. package/dist/node-builtins/repl.js +12 -0
  144. package/dist/node-builtins/repl.js.map +1 -0
  145. package/dist/node-builtins/shared.d.ts +24 -0
  146. package/dist/node-builtins/shared.d.ts.map +1 -0
  147. package/dist/node-builtins/shared.js +68 -0
  148. package/dist/node-builtins/shared.js.map +1 -0
  149. package/dist/node-builtins/sqlite.d.ts +3 -0
  150. package/dist/node-builtins/sqlite.d.ts.map +1 -0
  151. package/dist/node-builtins/sqlite.js +9 -0
  152. package/dist/node-builtins/sqlite.js.map +1 -0
  153. package/dist/node-builtins/stream.d.ts +3 -0
  154. package/dist/node-builtins/stream.d.ts.map +1 -0
  155. package/dist/node-builtins/stream.js +64 -0
  156. package/dist/node-builtins/stream.js.map +1 -0
  157. package/dist/node-builtins/string-decoder.d.ts +3 -0
  158. package/dist/node-builtins/string-decoder.d.ts.map +1 -0
  159. package/dist/node-builtins/string-decoder.js +14 -0
  160. package/dist/node-builtins/string-decoder.js.map +1 -0
  161. package/dist/node-builtins/test.d.ts +4 -0
  162. package/dist/node-builtins/test.d.ts.map +1 -0
  163. package/dist/node-builtins/test.js +8 -0
  164. package/dist/node-builtins/test.js.map +1 -0
  165. package/dist/node-builtins/timers.d.ts +4 -0
  166. package/dist/node-builtins/timers.d.ts.map +1 -0
  167. package/dist/node-builtins/timers.js +9 -0
  168. package/dist/node-builtins/timers.js.map +1 -0
  169. package/dist/node-builtins/tls.d.ts +3 -0
  170. package/dist/node-builtins/tls.d.ts.map +1 -0
  171. package/dist/node-builtins/tls.js +10 -0
  172. package/dist/node-builtins/tls.js.map +1 -0
  173. package/dist/node-builtins/trace-events.d.ts +3 -0
  174. package/dist/node-builtins/trace-events.d.ts.map +1 -0
  175. package/dist/node-builtins/trace-events.js +9 -0
  176. package/dist/node-builtins/trace-events.js.map +1 -0
  177. package/dist/node-builtins/tty.d.ts +8 -0
  178. package/dist/node-builtins/tty.d.ts.map +1 -0
  179. package/dist/node-builtins/tty.js +12 -0
  180. package/dist/node-builtins/tty.js.map +1 -0
  181. package/dist/node-builtins/types.d.ts +159 -0
  182. package/dist/node-builtins/types.d.ts.map +1 -0
  183. package/dist/node-builtins/types.js +2 -0
  184. package/dist/node-builtins/types.js.map +1 -0
  185. package/dist/node-builtins/unenv.d.ts +6 -0
  186. package/dist/node-builtins/unenv.d.ts.map +1 -0
  187. package/dist/node-builtins/unenv.js +27 -0
  188. package/dist/node-builtins/unenv.js.map +1 -0
  189. package/dist/node-builtins/url-pattern.d.ts +8 -0
  190. package/dist/node-builtins/url-pattern.d.ts.map +1 -0
  191. package/dist/node-builtins/url-pattern.js +19 -0
  192. package/dist/node-builtins/url-pattern.js.map +1 -0
  193. package/dist/node-builtins/url.d.ts +4 -0
  194. package/dist/node-builtins/url.d.ts.map +1 -0
  195. package/dist/node-builtins/url.js +100 -0
  196. package/dist/node-builtins/url.js.map +1 -0
  197. package/dist/node-builtins/util.d.ts +3 -0
  198. package/dist/node-builtins/util.d.ts.map +1 -0
  199. package/dist/node-builtins/util.js +7 -0
  200. package/dist/node-builtins/util.js.map +1 -0
  201. package/dist/node-builtins/v8.d.ts +3 -0
  202. package/dist/node-builtins/v8.d.ts.map +1 -0
  203. package/dist/node-builtins/v8.js +6 -0
  204. package/dist/node-builtins/v8.js.map +1 -0
  205. package/dist/node-builtins/vfs.d.ts +3 -0
  206. package/dist/node-builtins/vfs.d.ts.map +1 -0
  207. package/dist/node-builtins/vfs.js +42 -0
  208. package/dist/node-builtins/vfs.js.map +1 -0
  209. package/dist/node-builtins/vm.d.ts +4 -0
  210. package/dist/node-builtins/vm.d.ts.map +1 -0
  211. package/dist/node-builtins/vm.js +6 -0
  212. package/dist/node-builtins/vm.js.map +1 -0
  213. package/dist/node-builtins/wasi-sockets.d.ts +10 -0
  214. package/dist/node-builtins/wasi-sockets.d.ts.map +1 -0
  215. package/dist/node-builtins/wasi-sockets.js +25 -0
  216. package/dist/node-builtins/wasi-sockets.js.map +1 -0
  217. package/dist/node-builtins/wasi.d.ts +10 -0
  218. package/dist/node-builtins/wasi.d.ts.map +1 -0
  219. package/dist/node-builtins/wasi.js +14 -0
  220. package/dist/node-builtins/wasi.js.map +1 -0
  221. package/dist/node-builtins/worker-threads.d.ts +3 -0
  222. package/dist/node-builtins/worker-threads.d.ts.map +1 -0
  223. package/dist/node-builtins/worker-threads.js +16 -0
  224. package/dist/node-builtins/worker-threads.js.map +1 -0
  225. package/dist/node-builtins/zlib.d.ts +3 -0
  226. package/dist/node-builtins/zlib.d.ts.map +1 -0
  227. package/dist/node-builtins/zlib.js +6 -0
  228. package/dist/node-builtins/zlib.js.map +1 -0
  229. package/dist/node-wit.d.ts +102 -0
  230. package/dist/node-wit.d.ts.map +1 -0
  231. package/dist/node-wit.js +469 -0
  232. package/dist/node-wit.js.map +1 -0
  233. package/lib/wasi_snapshot_preview1.command.wasm +0 -0
  234. package/lib/wasi_snapshot_preview1.reactor.wasm +0 -0
  235. package/lib/wit/builtin/0.2.10/wasi-clocks/package.wit +35 -0
  236. package/lib/wit/builtin/0.2.10/wasi-io/package.wit +47 -0
  237. package/lib/wit/builtin/0.2.10/wasi-sockets/package.wit +168 -0
  238. package/lib/wit/builtin/jco-node-0.1.0/child-process.wit +42 -0
  239. package/lib/wit/builtin/jco-node-0.1.0/cluster.wit +112 -0
  240. package/lib/wit/builtin/jco-node-0.1.0/console.wit +12 -0
  241. package/lib/wit/builtin/jco-node-0.1.0/dgram.wit +142 -0
  242. package/lib/wit/builtin/jco-node-0.1.0/dns.wit +145 -0
  243. package/lib/wit/builtin/jco-node-0.1.0/ffi.wit +116 -0
  244. package/lib/wit/builtin/jco-node-0.1.0/fs.wit +208 -0
  245. package/lib/wit/builtin/jco-node-0.1.0/http.wit +151 -0
  246. package/lib/wit/builtin/jco-node-0.1.0/http2.wit +190 -0
  247. package/lib/wit/builtin/jco-node-0.1.0/inspector.wit +142 -0
  248. package/lib/wit/builtin/jco-node-0.1.0/os.wit +120 -0
  249. package/lib/wit/builtin/jco-node-0.1.0/process.wit +245 -0
  250. package/lib/wit/builtin/jco-node-0.1.0/sqlite.wit +154 -0
  251. package/lib/wit/builtin/jco-node-0.1.0/tls.wit +108 -0
  252. package/lib/wit/builtin/jco-node-0.1.0/trace-events.wit +27 -0
  253. package/lib/wit/builtin/jco-node-0.1.0/tty.wit +59 -0
  254. package/lib/wit/builtin/jco-node-0.1.0/types.wit +12 -0
  255. package/lib/wit/builtin/jco-node-0.1.0/v8.wit +102 -0
  256. package/lib/wit/builtin/jco-node-0.1.0/wasi.wit +57 -0
  257. package/lib/wit/builtin/jco-node-0.1.0/worker-threads.wit +67 -0
  258. package/lib/wit/builtin/jco-node-0.1.0/zlib.wit +77 -0
  259. package/lib/wit/builtin/wasi-tls-0.2.0-draft/LICENSE.md +8 -0
  260. package/lib/wit/builtin/wasi-tls-0.2.0-draft/README.md +25 -0
  261. package/lib/wit/builtin/wasi-tls-0.2.0-draft/deps/io/package.wit +66 -0
  262. package/lib/wit/builtin/wasi-tls-0.2.0-draft/types.wit +27 -0
  263. package/lib/wit/builtin/wasi-tls-0.2.0-draft/world.wit +8 -0
  264. package/package.json +9 -5
@@ -0,0 +1,190 @@
1
+ /// Guest-owned callbacks used by the direct Node-compatible HTTP/2 implementation.
2
+ interface http2-callbacks {
3
+ variant errno {
4
+ number(s64),
5
+ symbolic(string),
6
+ }
7
+
8
+ record error {
9
+ name: string,
10
+ message: string,
11
+ code: option<string>,
12
+ errno: option<errno>,
13
+ syscall: option<string>,
14
+ hostname: option<string>,
15
+ address: option<string>,
16
+ port: option<u16>,
17
+ }
18
+
19
+ record header {
20
+ name: string,
21
+ value: list<u8>,
22
+ }
23
+
24
+ record incoming-stream {
25
+ session-id: u32,
26
+ id: u32,
27
+ headers: list<header>,
28
+ body: list<u8>,
29
+ remote-address: option<string>,
30
+ remote-port: option<u16>,
31
+ }
32
+
33
+ record outgoing-response {
34
+ headers: list<header>,
35
+ trailers: list<header>,
36
+ body: list<u8>,
37
+ }
38
+
39
+ resource stream-listener {
40
+ handle: func(input: incoming-stream) -> result<outgoing-response, error>;
41
+ }
42
+
43
+ resource server-error-listener {
44
+ handle: func(reason: error);
45
+ }
46
+
47
+ /// Redeem each registration once; the host owns the resources until the server closes.
48
+ take-stream-listener: func(id: u32) -> option<stream-listener>;
49
+ take-server-error-listener: func(id: u32) -> option<server-error-listener>;
50
+ }
51
+
52
+ /// Typed host boundary for Node-compatible HTTP/2 clients and servers.
53
+ interface http2 {
54
+ variant errno {
55
+ number(s64),
56
+ symbolic(string),
57
+ }
58
+
59
+ record error {
60
+ name: string,
61
+ message: string,
62
+ code: option<string>,
63
+ errno: option<errno>,
64
+ syscall: option<string>,
65
+ hostname: option<string>,
66
+ address: option<string>,
67
+ port: option<u16>,
68
+ }
69
+
70
+ record header {
71
+ name: string,
72
+ value: list<u8>,
73
+ }
74
+
75
+ record custom-setting {
76
+ id: u16,
77
+ value: u32,
78
+ }
79
+
80
+ record http2-settings {
81
+ header-table-size: option<u32>,
82
+ enable-push: option<bool>,
83
+ initial-window-size: option<u32>,
84
+ max-frame-size: option<u32>,
85
+ max-concurrent-streams: option<u32>,
86
+ max-header-list-size: option<u32>,
87
+ enable-connect-protocol: option<bool>,
88
+ custom-settings: list<custom-setting>,
89
+ }
90
+
91
+ record client-options {
92
+ settings: http2-settings,
93
+ /// One-use configuration issued by the shared jco:node/tls provider.
94
+ tls-context: option<u32>,
95
+ }
96
+
97
+ record request-options {
98
+ end-stream: option<bool>,
99
+ wait-for-trailers: option<bool>,
100
+ }
101
+
102
+ record response {
103
+ headers: list<header>,
104
+ trailers: list<header>,
105
+ body: list<u8>,
106
+ }
107
+
108
+ record stream-state {
109
+ state: option<u32>,
110
+ local-window-size: option<u32>,
111
+ local-close: option<u32>,
112
+ remote-close: option<u32>,
113
+ }
114
+
115
+ record ping-response {
116
+ duration-ms: f64,
117
+ payload: list<u8>,
118
+ }
119
+
120
+ record session-info {
121
+ alpn-protocol: option<string>,
122
+ encrypted: bool,
123
+ local-settings: http2-settings,
124
+ remote-settings: http2-settings,
125
+ }
126
+
127
+ record server-options {
128
+ secure: bool,
129
+ tls-context: option<u32>,
130
+ settings: http2-settings,
131
+ allow-http1: option<bool>,
132
+ strict-field-whitespace-validation: option<bool>,
133
+ }
134
+
135
+ record listen-options {
136
+ port: option<u16>,
137
+ host: option<string>,
138
+ backlog: option<u32>,
139
+ path: option<string>,
140
+ exclusive: option<bool>,
141
+ ipv6-only: option<bool>,
142
+ reuse-port: option<bool>,
143
+ }
144
+
145
+ record tcp-address {
146
+ address: string,
147
+ family: string,
148
+ port: u16,
149
+ }
150
+
151
+ variant server-address {
152
+ tcp(tcp-address),
153
+ pipe(string),
154
+ }
155
+
156
+ resource client-stream {
157
+ write: func(chunk: list<u8>) -> result<bool, error>;
158
+ finish: func() -> result<response, error>;
159
+ close: func(code: u32) -> result<_, error>;
160
+ id: func() -> option<u32>;
161
+ state: func() -> stream-state;
162
+ }
163
+
164
+ resource client-session {
165
+ constructor(authority: string, options: client-options);
166
+ ready: func() -> result<session-info, error>;
167
+ request: func(headers: list<header>, options: request-options) -> result<own<client-stream>, error>;
168
+ close: func() -> result<_, error>;
169
+ destroy: func(code: u32) -> result<_, error>;
170
+ settings: func(settings: http2-settings) -> result<http2-settings, error>;
171
+ ping: func(payload: list<u8>) -> result<ping-response, error>;
172
+ goaway: func(code: u32, last-stream-id: option<u32>, opaque-data: list<u8>) -> result<_, error>;
173
+ ref: func();
174
+ unref: func();
175
+ }
176
+
177
+ resource server {
178
+ constructor(
179
+ options: server-options,
180
+ listener: u32,
181
+ error-listener: u32,
182
+ );
183
+ listen: func(options: listen-options) -> result<server-address, error>;
184
+ close: func() -> result<bool, error>;
185
+ address: func() -> option<server-address>;
186
+ update-settings: func(settings: http2-settings) -> result<_, error>;
187
+ ref: func();
188
+ unref: func();
189
+ }
190
+ }
@@ -0,0 +1,142 @@
1
+ package jco:node@0.1.0;
2
+
3
+ /// Host-backed adapter for Node's `inspector` module (and `inspector/promises`).
4
+ ///
5
+ /// The inspector is host machinery by definition: a V8 WebSocket server and a Chrome DevTools
6
+ /// Protocol dispatcher wired into the running isolate. WASI expresses none of it, so unlike Jco's
7
+ /// portable shims every observable operation forwards to the host's real `node:inspector` over
8
+ /// this interface. Guest-side code owns Node-faithful argument validation, session state, the
9
+ /// `EventEmitter` surface, and error reconstruction; the host owns the V8 machinery.
10
+ ///
11
+ /// Protocol payloads are JSON by definition (CDP), so `session-post`, notifications, and the
12
+ /// broadcast namespaces carry their parameters and results as JSON strings without loss. The
13
+ /// `console` forwarder JSON-encodes its arguments, which is lossy for functions, symbols, and
14
+ /// cycles -- best-effort, and documented as such guest-side.
15
+ ///
16
+ /// Callbacks run the other way: the host must call back into the component when a protocol
17
+ /// response or a notification arrives. A component cannot implement a resource declared in an
18
+ /// *imported* interface -- its methods would run host-side -- so the callback resources live in the
19
+ /// guest-*exported* `inspector-callbacks` interface below. This import carries only a `u32`
20
+ /// callback id; the host redeems it for an owned resource handle through the exported `take-*`
21
+ /// functions and invokes the resource method to re-enter the guest. The host must never do so while
22
+ /// a guest->host call is still on the stack (component re-entrance); the Node adapter queues
23
+ /// deliveries and flushes them on a later turn, which makes guest-side callbacks always
24
+ /// asynchronous even where Node fires them synchronously. Node does not promise synchronous
25
+ /// delivery.
26
+ ///
27
+ /// The one exception is a `session-post` whose CDP command resolves in-isolate: the host returns
28
+ /// that response directly from the import call, so the promise-based `Session.post` can `await` it
29
+ /// without any callback re-entering a suspended task. The `post-callback` resource remains for
30
+ /// genuinely deferred responses, and notifications arrive between guest tasks.
31
+ ///
32
+ /// Session ids are `u32` allocated guest-side (like `cluster`'s worker ids), so `new Session()`
33
+ /// touches no host state. Deny-by-default: declaring the import grants nothing; an application
34
+ /// opts in by mapping the interface to a host adapter at transpile time.
35
+ interface inspector {
36
+ /// A failure reported by the host, carrying Node's own error code where it has one.
37
+ record failure {
38
+ code: string,
39
+ message: string,
40
+ }
41
+
42
+ /// Why an operation the guest asked for cannot be carried out.
43
+ variant error {
44
+ /// No inspector capability was granted to this component.
45
+ denied(string),
46
+ /// The host runtime has no usable `node:inspector` (for example, a browser host).
47
+ unavailable(string),
48
+ /// No session with this id is connected.
49
+ no-such-session(u32),
50
+ /// The host's inspector call failed.
51
+ failed(failure),
52
+ }
53
+
54
+ /// Which inspector a session attaches to. `main-thread` is `connectToMainThread`, valid only
55
+ /// from a worker.
56
+ enum connect-kind {
57
+ local,
58
+ main-thread,
59
+ }
60
+
61
+ /// Which experimental broadcast namespace an `emit` targets.
62
+ enum broadcast-target {
63
+ network,
64
+ dom-storage,
65
+ }
66
+
67
+ /// Activate the inspector, optionally waiting for a client to attach before returning.
68
+ open: func(port: option<u32>, host: option<string>, wait: bool) -> result<_, error>;
69
+
70
+ /// Deactivate the inspector.
71
+ close: func() -> result<_, error>;
72
+
73
+ /// The active inspector WebSocket URL, or none when it is not active.
74
+ url: func() -> result<option<string>, error>;
75
+
76
+ /// Block until a client has connected and is ready to step. Requires an active inspector.
77
+ wait-for-debugger: func() -> result<_, error>;
78
+
79
+ /// Emit through the inspector's own `console`, optionally into a named context. `args-json` is
80
+ /// the JSON-encoded argument list.
81
+ console-call: func(context: option<string>, method: string, args-json: string) -> result<_, error>;
82
+
83
+ /// Connect a session. `listener` is the id of the guest-exported `notification-listener` the
84
+ /// host redeems once and keeps for the session's lifetime, calling it per notification.
85
+ session-connect: func(session: u32, kind: connect-kind, listener: u32) -> result<_, error>;
86
+
87
+ /// The outcome of a CDP command the host resolved synchronously.
88
+ ///
89
+ /// In-isolate protocol methods (`Runtime.evaluate`, `Debugger.*`, ...) resolve during the post
90
+ /// call, so their response is returned directly. This matters beyond efficiency: a guest that
91
+ /// `await`s the result would otherwise need the host to call back in while the guest is
92
+ /// suspended, which the component model forbids.
93
+ variant command-response {
94
+ /// Success: the JSON-encoded CDP result, absent when the result is empty.
95
+ ok(option<string>),
96
+ /// Failure: the protocol error, carrying Node's `ERR_INSPECTOR_COMMAND` code.
97
+ failed(failure),
98
+ }
99
+
100
+ /// Post a CDP command on a session.
101
+ ///
102
+ /// Returns `some(response)` when the command resolved synchronously (the common case), `none`
103
+ /// when the response is deferred. For a deferred response, if `callback` is present it is the id
104
+ /// of a guest-exported `post-callback` the host redeems and calls once the response arrives. A
105
+ /// guest must not `await` a deferred response -- delivery would re-enter a suspended task -- so
106
+ /// the promise-based `Session.post` only awaits synchronous responses.
107
+ session-post: func(session: u32, method: string, params-json: option<string>, callback: option<u32>) -> result<option<command-response>, error>;
108
+
109
+ /// Disconnect a session, releasing its notification listener.
110
+ session-disconnect: func(session: u32) -> result<_, error>;
111
+
112
+ /// Feed one event to an experimental broadcast namespace (`Network`, `DOMStorage`). `params-json`
113
+ /// is the JSON-encoded parameter object.
114
+ emit: func(target: broadcast-target, event: string, params-json: string) -> result<_, error>;
115
+
116
+ /// Register a network resource for the inspector to serve (`NetworkResources.put`).
117
+ put-network-resource: func(url: string, data: string) -> result<_, error>;
118
+ }
119
+
120
+ /// Callback channel the host uses to re-enter the component. Guest-*exported*: the component owns
121
+ /// the resource implementations, and the host redeems ids for handles through the `take-*`
122
+ /// functions. See the `inspector` interface docs for why the callbacks cannot live on the import.
123
+ interface inspector-callbacks {
124
+ /// A one-shot response to a `session-post`, matching Node's `(err, result)` callback.
125
+ resource post-callback {
126
+ /// Deliver the response. `error-json` is a JSON `{ code, message }` when the command
127
+ /// failed, otherwise absent; `result-json` is the JSON-encoded CDP result on success.
128
+ done: func(error-json: option<string>, result-json: option<string>);
129
+ }
130
+
131
+ /// The long-lived channel for one connected session's notifications.
132
+ resource notification-listener {
133
+ /// Deliver one CDP notification. `params-json` is the JSON-encoded parameter object.
134
+ notify: func(method: string, params-json: string);
135
+ }
136
+
137
+ /// Redeem a `session-post` callback id for its resource. Absent if the id is unknown.
138
+ take-post-callback: func(id: u32) -> option<post-callback>;
139
+
140
+ /// Redeem a session's notification-listener id for its resource. Absent if the id is unknown.
141
+ take-notification-listener: func(id: u32) -> option<notification-listener>;
142
+ }
@@ -0,0 +1,120 @@
1
+ package jco:node@0.1.0;
2
+
3
+ /// Typed, runtime-neutral host boundary for Node-compatible OS information.
4
+ interface os {
5
+ variant errno {
6
+ number(s64),
7
+ symbolic(string),
8
+ }
9
+
10
+ record error-info {
11
+ errno: option<errno>,
12
+ code: option<string>,
13
+ message: option<string>,
14
+ syscall: option<string>,
15
+ }
16
+
17
+ record error {
18
+ name: string,
19
+ message: string,
20
+ code: option<string>,
21
+ errno: option<errno>,
22
+ syscall: option<string>,
23
+ info: option<error-info>,
24
+ }
25
+
26
+ record constant-entry {
27
+ name: string,
28
+ value: s64,
29
+ }
30
+
31
+ record os-constants {
32
+ uv-udp-reuseaddr: s32,
33
+ dlopen: list<constant-entry>,
34
+ errno: list<constant-entry>,
35
+ signals: list<constant-entry>,
36
+ priority: list<constant-entry>,
37
+ }
38
+
39
+ record static-properties {
40
+ eol: string,
41
+ dev-null: string,
42
+ constants: os-constants,
43
+ }
44
+
45
+ enum byte-order {
46
+ be,
47
+ le,
48
+ }
49
+
50
+ record cpu-times {
51
+ user: u64,
52
+ nice: u64,
53
+ sys: u64,
54
+ idle: u64,
55
+ irq: u64,
56
+ }
57
+
58
+ record cpu-info {
59
+ model: string,
60
+ speed: u32,
61
+ times: cpu-times,
62
+ }
63
+
64
+ record load-average {
65
+ one: f64,
66
+ five: f64,
67
+ fifteen: f64,
68
+ }
69
+
70
+ enum network-family {
71
+ ipv4,
72
+ ipv6,
73
+ }
74
+
75
+ record network-interface {
76
+ name: string,
77
+ address: string,
78
+ netmask: string,
79
+ family: network-family,
80
+ mac: string,
81
+ internal: bool,
82
+ scopeid: option<u32>,
83
+ cidr: option<string>,
84
+ }
85
+
86
+ variant user-info-value {
87
+ text(string),
88
+ bytes(list<u8>),
89
+ }
90
+
91
+ record user-info-record {
92
+ username: user-info-value,
93
+ uid: s64,
94
+ gid: s64,
95
+ shell: option<user-info-value>,
96
+ homedir: user-info-value,
97
+ }
98
+
99
+ get-static-properties: func() -> result<static-properties, error>;
100
+ arch: func() -> result<string, error>;
101
+ available-parallelism: func() -> result<u32, error>;
102
+ cpus: func() -> result<list<cpu-info>, error>;
103
+ endianness: func() -> result<byte-order, error>;
104
+ freemem: func() -> result<u64, error>;
105
+ get-priority: func(pid: s32) -> result<s32, error>;
106
+ homedir: func() -> result<string, error>;
107
+ hostname: func() -> result<string, error>;
108
+ loadavg: func() -> result<load-average, error>;
109
+ machine: func() -> result<string, error>;
110
+ network-interfaces: func() -> result<list<network-interface>, error>;
111
+ platform: func() -> result<string, error>;
112
+ release: func() -> result<string, error>;
113
+ set-priority: func(pid: s32, priority: s32) -> result<_, error>;
114
+ tmpdir: func() -> result<string, error>;
115
+ totalmem: func() -> result<u64, error>;
116
+ %type: func() -> result<string, error>;
117
+ uptime: func() -> result<f64, error>;
118
+ user-info: func(encoding: option<string>) -> result<user-info-record, error>;
119
+ version: func() -> result<string, error>;
120
+ }
@@ -0,0 +1,245 @@
1
+ package jco:node@0.1.0;
2
+
3
+ /// Explicit access to the embedding process. No capability is granted by default.
4
+ /// The Node provider affects the embedding Node process, not a virtual WASI process.
5
+ interface process {
6
+ variant errno {
7
+ number(s64),
8
+ symbolic(string)
9
+ }
10
+
11
+ record error {
12
+ name: string,
13
+ message: string,
14
+ code: option<string>,
15
+ errno: option<errno>,
16
+ syscall: option<string>,
17
+ path: option<string>
18
+ }
19
+
20
+ record process-metadata {
21
+ arch: string,
22
+ platform: string,
23
+ pid: u32,
24
+ ppid: u32,
25
+ argv: list<string>,
26
+ argv0: string,
27
+ exec-argv: list<string>,
28
+ exec-path: string,
29
+ version: string,
30
+ versions: list<tuple<string, string>>,
31
+ release-json: string,
32
+ config-json: string,
33
+ features-json: string,
34
+ has-permission: bool,
35
+ }
36
+
37
+ enum flag {
38
+ no-deprecation,
39
+ throw-deprecation,
40
+ trace-deprecation,
41
+ trace-process-warnings
42
+ }
43
+
44
+ variant exit-code {
45
+ number(f64),
46
+ text(string)
47
+ }
48
+
49
+ record state {
50
+ title: string,
51
+ debug-port: f64,
52
+ exit-code: option<exit-code>,
53
+ no-deprecation: option<bool>,
54
+ throw-deprecation: option<bool>,
55
+ trace-deprecation: option<bool>,
56
+ trace-process-warnings: option<bool>,
57
+ source-maps-enabled: bool,
58
+ connected: option<bool>,
59
+ }
60
+
61
+ enum identity {
62
+ uid,
63
+ euid,
64
+ gid,
65
+ egid
66
+ }
67
+
68
+ variant id {
69
+ number(u32),
70
+ name(string)
71
+ }
72
+
73
+ variant signal {
74
+ number(s32),
75
+ name(string)
76
+ }
77
+
78
+ variant mask {
79
+ number(u32),
80
+ text(string)
81
+ }
82
+
83
+ variant path {
84
+ text(string),
85
+ url(string),
86
+ bytes(list<u8>)
87
+ }
88
+
89
+ record warning {
90
+ name: string,
91
+ message: string,
92
+ stack: option<string>,
93
+ code: option<string>,
94
+ detail: option<string>
95
+ }
96
+
97
+ record report-options {
98
+ compact: bool,
99
+ directory: string,
100
+ filename: string,
101
+ signal: string,
102
+ report-on-fatal-error: bool,
103
+ report-on-signal: bool,
104
+ report-on-uncaught-exception: bool,
105
+ exclude-env: bool,
106
+ exclude-network: bool,
107
+ }
108
+
109
+ enum report-option {
110
+ compact,
111
+ directory,
112
+ filename,
113
+ signal,
114
+ report-on-fatal-error,
115
+ report-on-signal,
116
+ report-on-uncaught-exception,
117
+ exclude-env,
118
+ exclude-network
119
+ }
120
+
121
+ variant report-value {
122
+ boolean(bool),
123
+ text(string)
124
+ }
125
+
126
+ record cpu-usage-record {
127
+ user: f64,
128
+ system: f64
129
+ }
130
+
131
+ record memory-usage-record {
132
+ rss: f64,
133
+ heap-total: f64,
134
+ heap-used: f64,
135
+ external: f64,
136
+ array-buffers: f64
137
+ }
138
+
139
+ record resource-usage-record {
140
+ user-cpu-time: f64,
141
+ system-cpu-time: f64,
142
+ max-rss: f64,
143
+ shared-memory-size: f64,
144
+ unshared-data-size: f64,
145
+ unshared-stack-size: f64,
146
+ minor-page-fault: f64,
147
+ major-page-fault: f64,
148
+ swapped-out: f64,
149
+ fs-read: f64,
150
+ fs-write: f64,
151
+ ipc-sent: f64,
152
+ ipc-received: f64,
153
+ signals-count: f64,
154
+ voluntary-context-switches: f64,
155
+ involuntary-context-switches: f64
156
+ }
157
+
158
+ metadata: func() -> result<process-metadata, error>;
159
+
160
+ get-state: func() -> result<state, error>;
161
+
162
+ set-title: func(value: string) -> result<_, error>;
163
+
164
+ set-debug-port: func(value: f64) -> result<_, error>;
165
+
166
+ set-exit-code: func(value: option<exit-code>) -> result<_, error>;
167
+
168
+ set-flag: func(name: flag, value: bool) -> result<_, error>;
169
+
170
+ env-entries: func() -> result<list<tuple<string, string>>, error>;
171
+
172
+ env-get: func(name: string) -> result<option<string>, error>;
173
+
174
+ env-set: func(name: string, value: option<string>) -> result<_, error>;
175
+
176
+ cwd: func() -> result<string, error>;
177
+
178
+ chdir: func(directory: string) -> result<_, error>;
179
+
180
+ cpu-usage: func(previous: option<cpu-usage-record>) -> result<cpu-usage-record, error>;
181
+
182
+ thread-cpu-usage: func(previous: option<cpu-usage-record>) -> result<cpu-usage-record, error>;
183
+
184
+ memory-usage: func() -> result<memory-usage-record, error>;
185
+
186
+ rss: func() -> result<f64, error>;
187
+
188
+ resource-usage: func() -> result<resource-usage-record, error>;
189
+
190
+ /// Split the clock to avoid engines that lift WIT u64 as an imprecise JS number.
191
+ record clock-time {
192
+ seconds: f64,
193
+ nanoseconds: u32
194
+ }
195
+
196
+ hrtime: func() -> result<clock-time, error>;
197
+
198
+ uptime: func() -> result<f64, error>;
199
+
200
+ available-memory: func() -> result<f64, error>;
201
+
202
+ constrained-memory: func() -> result<f64, error>;
203
+
204
+ get-active-resources-info: func() -> result<list<string>, error>;
205
+
206
+ get-id: func(kind: identity) -> result<u32, error>;
207
+
208
+ set-id: func(kind: identity, value: id) -> result<_, error>;
209
+
210
+ getgroups: func() -> result<list<u32>, error>;
211
+
212
+ setgroups: func(groups: list<id>) -> result<_, error>;
213
+
214
+ initgroups: func(user: id, extra-group: id) -> result<_, error>;
215
+
216
+ kill: func(pid: s32, signal: signal) -> result<bool, error>;
217
+
218
+ umask: func(mask: mask) -> result<u32, error>;
219
+
220
+ exit: func(code: option<exit-code>) -> result<_, error>;
221
+
222
+ abort: func() -> result<_, error>;
223
+
224
+ execve: func(file: string, args: list<string>, env: option<list<tuple<string, string>>>) -> result<_, error>;
225
+
226
+ load-env-file: func(path: option<path>) -> result<_, error>;
227
+
228
+ set-source-maps-enabled: func(value: bool) -> result<_, error>;
229
+
230
+ emit-warning: func(warning: warning) -> result<_, error>;
231
+
232
+ permission-has: func(scope: string, reference: option<path>) -> result<bool, error>;
233
+
234
+ get-report: func(error: option<warning>) -> result<string, error>;
235
+
236
+ write-report: func(filename: option<string>, error: option<warning>) -> result<string, error>;
237
+
238
+ get-report-options: func() -> result<report-options, error>;
239
+
240
+ set-report-option: func(name: report-option, value: report-value) -> result<_, error>;
241
+
242
+ allowed-flags: func() -> result<list<string>, error>;
243
+
244
+ allowed-flag: func(value: string) -> result<bool, error>;
245
+ }