xbintsc 0.6.24 → 0.6.28

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 (224) hide show
  1. package/AGENTS.md +1 -1
  2. package/dist/src/cli/extensions.js +11 -3
  3. package/dist/src/cli/extensions.js.map +1 -1
  4. package/dist/src/cli/help.d.ts +1 -1
  5. package/dist/src/cli/help.js +1 -1
  6. package/dist/src/codegen/generator/state.js +7 -0
  7. package/dist/src/codegen/generator/state.js.map +1 -1
  8. package/dist/src/codegen/generator/tables.js +19 -1
  9. package/dist/src/codegen/generator/tables.js.map +1 -1
  10. package/dist/src/driver/bundler/graph.js +9 -5
  11. package/dist/src/driver/bundler/graph.js.map +1 -1
  12. package/dist/src/driver/fingerprint.d.ts +2 -2
  13. package/dist/src/driver/fingerprint.js +3 -3
  14. package/dist/src/driver/fingerprint.js.map +1 -1
  15. package/dist/src/driver/link-features.js +1 -1
  16. package/dist/src/driver/link-features.js.map +1 -1
  17. package/dist/src/driver/paths.js +8 -4
  18. package/dist/src/driver/paths.js.map +1 -1
  19. package/dist/src/driver/runtime-objects.d.ts +1 -1
  20. package/dist/src/driver/runtime-objects.js +13 -1
  21. package/dist/src/driver/runtime-objects.js.map +1 -1
  22. package/dist/src/driver/version.d.ts +1 -1
  23. package/dist/src/driver/version.js +1 -1
  24. package/dist/src/extensions/catalog.js +5 -1
  25. package/dist/src/extensions/catalog.js.map +1 -1
  26. package/dist/src/extensions/gui/index.js +0 -1
  27. package/dist/src/extensions/gui/index.js.map +1 -1
  28. package/dist/src/extensions/link-feature.d.ts +8 -0
  29. package/dist/src/extensions/node/stream-web/index.d.ts +6 -1
  30. package/dist/src/extensions/node/stream-web/index.js +59 -4
  31. package/dist/src/extensions/node/stream-web/index.js.map +1 -1
  32. package/dist/src/extensions/node/worker_threads/index.d.ts +14 -4
  33. package/dist/src/extensions/node/worker_threads/index.js +24 -11
  34. package/dist/src/extensions/node/worker_threads/index.js.map +1 -1
  35. package/dist/src/extensions/registry.d.ts +9 -1
  36. package/dist/src/extensions/registry.js +4 -1
  37. package/dist/src/extensions/registry.js.map +1 -1
  38. package/dist/src/extensions/wasm-asset.d.ts +16 -0
  39. package/dist/src/extensions/wasm-asset.js +28 -0
  40. package/dist/src/extensions/wasm-asset.js.map +1 -0
  41. package/dist/src/extensions/wasm.d.ts +17 -0
  42. package/dist/src/extensions/wasm.js +68 -0
  43. package/dist/src/extensions/wasm.js.map +1 -0
  44. package/dist/src/extensions/webworker/index.d.ts +24 -0
  45. package/dist/src/extensions/webworker/index.js +54 -0
  46. package/dist/src/extensions/webworker/index.js.map +1 -0
  47. package/dist/src/index.d.ts +1 -0
  48. package/dist/src/index.js +1 -0
  49. package/dist/src/index.js.map +1 -1
  50. package/dist/tests/driver/link-features.test.js +9 -0
  51. package/dist/tests/driver/link-features.test.js.map +1 -1
  52. package/dist/tests/e2e/async-fs.test.js +44 -0
  53. package/dist/tests/e2e/async-fs.test.js.map +1 -1
  54. package/dist/tests/e2e/harness.d.ts +6 -0
  55. package/dist/tests/e2e/harness.js +13 -1
  56. package/dist/tests/e2e/harness.js.map +1 -1
  57. package/dist/tests/e2e/node-crypto-random.test.d.ts +8 -0
  58. package/dist/tests/e2e/node-crypto-random.test.js +148 -0
  59. package/dist/tests/e2e/node-crypto-random.test.js.map +1 -0
  60. package/dist/tests/e2e/node-modules.test.js +1 -1
  61. package/dist/tests/e2e/node-modules.test.js.map +1 -1
  62. package/dist/tests/e2e/web-streams.test.d.ts +8 -0
  63. package/dist/tests/e2e/web-streams.test.js +274 -0
  64. package/dist/tests/e2e/web-streams.test.js.map +1 -0
  65. package/dist/tests/e2e/web-worker.test.d.ts +7 -0
  66. package/dist/tests/e2e/web-worker.test.js +74 -0
  67. package/dist/tests/e2e/web-worker.test.js.map +1 -0
  68. package/dist/tests/e2e/webassembly.test.d.ts +8 -0
  69. package/dist/tests/e2e/webassembly.test.js +113 -0
  70. package/dist/tests/e2e/webassembly.test.js.map +1 -0
  71. package/dist/tests/e2e/worker-api.test.d.ts +14 -0
  72. package/dist/tests/e2e/worker-api.test.js +460 -0
  73. package/dist/tests/e2e/worker-api.test.js.map +1 -0
  74. package/dist/tests/e2e/worker-threads.test.d.ts +8 -0
  75. package/dist/tests/e2e/worker-threads.test.js +160 -0
  76. package/dist/tests/e2e/worker-threads.test.js.map +1 -0
  77. package/dist/tests/extensions/wasm.test.d.ts +1 -0
  78. package/dist/tests/extensions/wasm.test.js +53 -0
  79. package/dist/tests/extensions/wasm.test.js.map +1 -0
  80. package/doc/ai/cli.md +1 -1
  81. package/doc/ai/contributing.md +11 -4
  82. package/doc/ai/extensions.md +25 -2
  83. package/doc/ai/language-support.md +14 -2
  84. package/doc/ai/zh-CN/cli.md +1 -1
  85. package/doc/ai/zh-CN/contributing.md +8 -3
  86. package/doc/ai/zh-CN/extensions.md +23 -2
  87. package/doc/ai/zh-CN/language-support.md +13 -2
  88. package/doc/gui/api.md +1 -1
  89. package/doc/implemented/cli.md +1 -1
  90. package/doc/implemented/extensions.md +6 -5
  91. package/doc/implemented/node/stream-web.md +31 -0
  92. package/doc/implemented/node/worker-threads.md +88 -5
  93. package/doc/implemented/node.md +2 -1
  94. package/doc/implemented/streams.md +82 -0
  95. package/doc/implemented/wasm.md +80 -18
  96. package/doc/implemented/web-worker.md +84 -0
  97. package/doc/implemented.md +6 -2
  98. package/doc/unimplemented/deviations.md +1 -0
  99. package/doc/unimplemented/node/worker-threads.md +23 -0
  100. package/doc/unimplemented/node.md +1 -0
  101. package/doc/unimplemented/stdlib.md +2 -1
  102. package/doc/unimplemented/wasm.md +21 -9
  103. package/doc/unimplemented.md +1 -1
  104. package/doc/zh-CN/gui/api.md +1 -1
  105. package/doc/zh-CN/implemented/cli.md +1 -1
  106. package/doc/zh-CN/implemented/extensions.md +7 -6
  107. package/doc/zh-CN/implemented/node/stream-web.md +24 -0
  108. package/doc/zh-CN/implemented/node/worker-threads.md +77 -4
  109. package/doc/zh-CN/implemented/node.md +2 -1
  110. package/doc/zh-CN/implemented/streams.md +60 -0
  111. package/doc/zh-CN/implemented/wasm.md +73 -16
  112. package/doc/zh-CN/implemented/web-worker.md +79 -0
  113. package/doc/zh-CN/implemented.md +6 -2
  114. package/doc/zh-CN/unimplemented/deviations.md +1 -0
  115. package/doc/zh-CN/unimplemented/node/worker-threads.md +20 -0
  116. package/doc/zh-CN/unimplemented/node.md +1 -0
  117. package/doc/zh-CN/unimplemented/stdlib.md +2 -1
  118. package/doc/zh-CN/unimplemented/wasm.md +16 -8
  119. package/doc/zh-CN/unimplemented.md +1 -1
  120. package/llms.txt +2 -0
  121. package/package.json +8 -7
  122. package/runtime/ext_gui/browser.cpp +1 -1
  123. package/runtime/ext_node/stream_web/stream_web.c +20 -6
  124. package/runtime/worker/worker_api.c +422 -0
  125. package/runtime/worker/worker_codec.c +489 -0
  126. package/runtime/worker/worker_core.c +445 -0
  127. package/runtime/worker/worker_internal.h +223 -0
  128. package/runtime/worker/worker_platform.c +344 -0
  129. package/runtime/worker/worker_ports.c +203 -0
  130. package/runtime/worker/worker_transport.c +464 -0
  131. package/runtime/worker/worker_wire.c +150 -0
  132. package/runtime/xt_builtins.c +15 -0
  133. package/runtime/xt_constructors.c +49 -2
  134. package/runtime/xt_stdlib2/error.inc +4 -0
  135. package/runtime/xt_streams/common.inc +232 -0
  136. package/runtime/xt_streams/constructors.inc +232 -0
  137. package/runtime/xt_streams/encoding.inc +124 -0
  138. package/runtime/xt_streams/readable-extra.inc +372 -0
  139. package/runtime/xt_streams/readable.inc +415 -0
  140. package/runtime/xt_streams/transform.inc +195 -0
  141. package/runtime/xt_streams/writable.inc +542 -0
  142. package/runtime/xt_streams.c +30 -0
  143. package/runtime/xt_wasm/wasm.h +148 -0
  144. package/runtime/xt_wasm/wasm_api.c +357 -0
  145. package/runtime/xt_wasm/wasm_api.h +37 -0
  146. package/runtime/xt_wasm/wasm_bridge.c +30 -0
  147. package/runtime/xt_wasm/wasm_instance.c +591 -0
  148. package/runtime/xt_wasm/wasm_module.c +270 -0
  149. package/runtime/xt_wasm/wasm_values.c +177 -0
  150. package/runtime/xt_webassembly.c +15 -4
  151. package/scripts/fetch-vendored.ts +187 -20
  152. package/scripts/package-release.ts +3 -2
  153. package/src/cli/extensions.ts +11 -3
  154. package/src/cli/help.ts +1 -1
  155. package/src/codegen/generator/state.ts +7 -0
  156. package/src/codegen/generator/tables.ts +19 -1
  157. package/src/driver/bundler/graph.ts +9 -5
  158. package/src/driver/fingerprint.ts +3 -3
  159. package/src/driver/link-features.ts +1 -1
  160. package/src/driver/paths.ts +8 -4
  161. package/src/driver/runtime-objects.ts +13 -1
  162. package/src/driver/version.ts +1 -1
  163. package/src/extensions/catalog.ts +5 -1
  164. package/src/extensions/gui/index.ts +0 -1
  165. package/src/extensions/link-feature.ts +8 -0
  166. package/src/extensions/node/stream-web/index.ts +59 -4
  167. package/src/extensions/node/worker_threads/index.ts +24 -11
  168. package/src/extensions/registry.ts +13 -2
  169. package/src/extensions/wasm-asset.ts +32 -0
  170. package/src/extensions/wasm.ts +74 -0
  171. package/src/extensions/webworker/index.ts +58 -0
  172. package/src/index.ts +1 -0
  173. package/vendor/wasm3/.pin +1 -0
  174. package/vendor/wasm3/LICENSE +21 -0
  175. package/vendor/wasm3/m3_api_libc.c +265 -0
  176. package/vendor/wasm3/m3_api_libc.h +19 -0
  177. package/vendor/wasm3/m3_api_meta_wasi.c +1107 -0
  178. package/vendor/wasm3/m3_api_tracer.c +173 -0
  179. package/vendor/wasm3/m3_api_tracer.h +19 -0
  180. package/vendor/wasm3/m3_api_uvwasi.c +1290 -0
  181. package/vendor/wasm3/m3_api_wasi.c +1207 -0
  182. package/vendor/wasm3/m3_api_wasi.h +74 -0
  183. package/vendor/wasm3/m3_api_wasi_host.h +137 -0
  184. package/vendor/wasm3/m3_api_wasi_posix.h +979 -0
  185. package/vendor/wasm3/m3_api_wasi_win32.h +1093 -0
  186. package/vendor/wasm3/m3_atomic.h +114 -0
  187. package/vendor/wasm3/m3_bind.c +174 -0
  188. package/vendor/wasm3/m3_bind.h +20 -0
  189. package/vendor/wasm3/m3_code.c +232 -0
  190. package/vendor/wasm3/m3_code.h +74 -0
  191. package/vendor/wasm3/m3_compile.c +6603 -0
  192. package/vendor/wasm3/m3_compile.h +354 -0
  193. package/vendor/wasm3/m3_config.h +448 -0
  194. package/vendor/wasm3/m3_config_platforms.h +345 -0
  195. package/vendor/wasm3/m3_core.c +1034 -0
  196. package/vendor/wasm3/m3_core.h +526 -0
  197. package/vendor/wasm3/m3_deterministic.c +65 -0
  198. package/vendor/wasm3/m3_deterministic.h +59 -0
  199. package/vendor/wasm3/m3_env.c +3146 -0
  200. package/vendor/wasm3/m3_env.h +748 -0
  201. package/vendor/wasm3/m3_exception.h +33 -0
  202. package/vendor/wasm3/m3_exec.c +8 -0
  203. package/vendor/wasm3/m3_exec.h +4110 -0
  204. package/vendor/wasm3/m3_exec_atomic.h +146 -0
  205. package/vendor/wasm3/m3_exec_defs.h +76 -0
  206. package/vendor/wasm3/m3_function.c +278 -0
  207. package/vendor/wasm3/m3_function.h +244 -0
  208. package/vendor/wasm3/m3_host.h +226 -0
  209. package/vendor/wasm3/m3_host_none.h +76 -0
  210. package/vendor/wasm3/m3_host_posix.h +543 -0
  211. package/vendor/wasm3/m3_host_win32.h +253 -0
  212. package/vendor/wasm3/m3_info.c +616 -0
  213. package/vendor/wasm3/m3_info.h +38 -0
  214. package/vendor/wasm3/m3_math_utils.h +560 -0
  215. package/vendor/wasm3/m3_module.c +431 -0
  216. package/vendor/wasm3/m3_parse.c +1549 -0
  217. package/vendor/wasm3/m3_snapshot.c +3825 -0
  218. package/vendor/wasm3/m3_validate.c +1770 -0
  219. package/vendor/wasm3/m3_validate.h +25 -0
  220. package/vendor/wasm3/m3_wasi.h +10 -0
  221. package/vendor/wasm3/m3_xxh64.c +211 -0
  222. package/vendor/wasm3/wasm3.h +684 -0
  223. package/vendor/wasm3/wasm3_defs.h +350 -0
  224. package/runtime/ext_node/worker_threads/worker_threads.c +0 -214
@@ -0,0 +1,74 @@
1
+ //
2
+ // m3_api_wasi.h
3
+ //
4
+ // Created by Volodymyr Shymanskyy on 11/20/19.
5
+ // Copyright © 2019 Volodymyr Shymanskyy. All rights reserved.
6
+ //
7
+
8
+ #ifndef m3_api_wasi_h
9
+ #define m3_api_wasi_h
10
+
11
+ #include "m3_core.h"
12
+
13
+ // What every WASI backend hands the guest as its environment. A Wasm module gets
14
+ // no host environment of its own, and a few programs want these set; WASM3 and
15
+ // WASM3_ARCH are how a guest tells it is running under Wasm3 (see print_version).
16
+ #if !defined(d_m3WasiDefaultEnvironment)
17
+ # define d_m3WasiDefaultEnvironment \
18
+ "TERM=xterm-256color", \
19
+ "COLORTERM=truecolor", \
20
+ "LANG=en_US.UTF-8", \
21
+ "PWD=/", \
22
+ "HOME=/", \
23
+ "PATH=/", \
24
+ "WASM3=1", \
25
+ "WASM3_ARCH=" M3_ARCH
26
+ #endif
27
+
28
+ #if defined(d_m3HasUVWASI)
29
+ # include "uvwasi.h"
30
+ #endif
31
+
32
+ d_m3BeginExternC
33
+
34
+ typedef struct m3_wasi_context_t {
35
+ i32 exit_code;
36
+ u32 argc;
37
+ ccstr_t* argv;
38
+
39
+ #if defined(d_m3HasUVWASI)
40
+ uvwasi_t uvwasi;
41
+ #endif
42
+ } m3_wasi_context_t;
43
+
44
+ #define M3WASI m3_wasi_context_t*
45
+
46
+ // ----------------------------------------------------------------------
47
+ // Free-standing WASI
48
+ // ----------------------------------------------------------------------
49
+
50
+ M3Result m3_NewCustomWASI (M3WASI*);
51
+ void m3_FreeCustomWASI(M3WASI);
52
+
53
+ M3Result m3_LinkCustomWASI(IM3Module, M3WASI);
54
+
55
+ #if defined(d_m3HasUVWASI)
56
+ M3Result m3_LinkCustomWASIWithOptions (IM3Module io_module, uvwasi_options_t uvwasiOptions);
57
+ #endif
58
+
59
+
60
+ // ----------------------------------------------------------------------
61
+ // Global WASI
62
+ // ----------------------------------------------------------------------
63
+ M3Result m3_LinkWASI (IM3Module io_module);
64
+
65
+ #if defined(d_m3HasUVWASI)
66
+ M3Result m3_LinkWASIWithOptions (IM3Module io_module, uvwasi_options_t uvwasiOptions);
67
+ #endif
68
+
69
+ m3_wasi_context_t* m3_GetWasiContext (void);
70
+
71
+
72
+ d_m3EndExternC
73
+
74
+ #endif // m3_api_wasi_h
@@ -0,0 +1,137 @@
1
+ //
2
+ // m3_api_wasi_host.h
3
+ //
4
+ // What the simple WASI implementation asks of the system underneath it.
5
+ //
6
+ // m3_api_wasi.c is the WASI interface itself: it decodes the guest's arguments,
7
+ // bounds-checks every pointer against guest memory, and writes results back in the
8
+ // layout the calling WASI revision asks for. Everything below that - descriptors,
9
+ // paths, clocks, entropy - is one of the implementations of this header, of which
10
+ // exactly one is ever built:
11
+ //
12
+ // m3_api_wasi_posix.h openat, fstatat, readv and the rest of POSIX
13
+ // m3_api_wasi_win32.h the Win32 API, which has none of those
14
+ //
15
+ // Both are headers, and m3_api_wasi.c includes whichever one it is built for: a new
16
+ // .c would have to be added to every source list that names its sources one by one,
17
+ // and most of those are build scripts outside this repository. That leaves the whole
18
+ // of it in one translation unit, so this header carries the types the two sides
19
+ // agree on and nothing else - every m3_wasi_host_* call is static, and the
20
+ // implementation that is built is the only declaration of it there is.
21
+ //
22
+ // The two know nothing of each other. Neither touches guest memory: a path arrives
23
+ // NUL-terminated, a buffer arrives already checked, and a result comes back in host
24
+ // types, which leaves the bounds checking in the one place that can do it.
25
+ //
26
+ // Every one of those calls writes each of its out-parameters on every path it can
27
+ // return by, and only a call that returns __WASI_ERRNO_SUCCESS writes anything worth
28
+ // reading. Sharing a translation unit with the caller is what makes that worth
29
+ // saying: a value left behind on an error path is one the compiler will warn about.
30
+ //
31
+
32
+ #ifndef m3_api_wasi_host_h
33
+ #define m3_api_wasi_host_h
34
+
35
+ #include "m3_core.h"
36
+
37
+ #if defined(d_m3HasWASI)
38
+
39
+ // Fixup wasi_core.h
40
+ # if defined(M3_COMPILER_MSVC)
41
+ # define _Static_assert(...)
42
+ # define __attribute__(...)
43
+ # define _Noreturn
44
+ # endif
45
+
46
+ # include "extra/wasi_core.h"
47
+
48
+ # include <stdio.h> // SEEK_SET and friends, which fd_seek is asked in
49
+
50
+ d_m3BeginExternC
51
+
52
+ // Guest paths arrive as (pointer, length); the calls below want them NUL-terminated,
53
+ // so they are copied out into a buffer of this size.
54
+ # define d_m3WasiMaxPath 512
55
+
56
+ // The preopened directories the guest is offered. The names are what it sees and are
57
+ // the same wherever it runs; the descriptor each one holds is the host's to fill in,
58
+ // and what sits behind that descriptor is the host's business - POSIX opens the
59
+ // directory, Win32 cannot and keeps a placeholder.
60
+ # define d_m3WasiPreopenCount 5
61
+
62
+ typedef struct m3_wasi_preopen_t {
63
+ int fd;
64
+ ccstr_t path;
65
+ ccstr_t real_path;
66
+ } m3_wasi_preopen_t;
67
+
68
+ // Defined here rather than declared because this header has exactly one includer
69
+ static m3_wasi_preopen_t m3_wasi_preopen[d_m3WasiPreopenCount] = {
70
+ { 0, "<stdin>", "" },
71
+ { 1, "<stdout>", "" },
72
+ { 2, "<stderr>", "" },
73
+ { -1, "/", "." },
74
+ { -1, "./", "." },
75
+ };
76
+
77
+ // A filestat as the host can fill one in, before it is written out in whichever
78
+ // layout the calling WASI revision asks for
79
+ typedef struct m3_wasi_filestat_t {
80
+ uint64_t dev;
81
+ uint64_t ino;
82
+ uint64_t nlink;
83
+ uint64_t size;
84
+ __wasi_timestamp_t atim;
85
+ __wasi_timestamp_t mtim;
86
+ __wasi_timestamp_t ctim;
87
+ __wasi_filetype_t filetype;
88
+ } m3_wasi_filestat_t;
89
+
90
+ // A scatter/gather list the caller has already resolved to host addresses and
91
+ // checked against guest memory.
92
+ //
93
+ // The guest may name any number of buffers, and the caller hands them over this many
94
+ // at a time: a fixed batch is what keeps both sides free of an allocation and of a
95
+ // variable length array, which MSVC has not got. A short transfer ends the whole
96
+ // call, exactly as it would have within one batch, so batching changes nothing the
97
+ // guest can observe - and one batch covers every list a C library actually writes.
98
+ # define d_m3WasiMaxIovs 8
99
+
100
+ typedef struct m3_wasi_iovec_t {
101
+ void* buf;
102
+ size_t len;
103
+ } m3_wasi_iovec_t;
104
+
105
+ // One thing poll_oneoff is waiting for, with the guest's tagged union already
106
+ // decoded and the difference between the two WASI revisions' layouts already gone.
107
+ // Which fields carry anything is decided by 'type': a clock subscription fills in
108
+ // the three below it, a descriptor subscription fills in 'fd'.
109
+ typedef struct m3_wasi_pollsub_t {
110
+ __wasi_userdata_t userdata;
111
+ __wasi_eventtype_t type;
112
+
113
+ __wasi_clockid_t clockId;
114
+ __wasi_timestamp_t timeout; // nanoseconds; a point in time when isAbsolute
115
+ bool isAbsolute;
116
+
117
+ __wasi_fd_t fd;
118
+ } m3_wasi_pollsub_t;
119
+
120
+ // One thing that turned out to be ready. 'error' describes that subscription alone -
121
+ // a descriptor that was never open is one event with EBADF, not a failed call - and
122
+ // the fields below it are only filled in for a descriptor event.
123
+ typedef struct m3_wasi_pollevent_t {
124
+ __wasi_userdata_t userdata;
125
+ __wasi_errno_t error;
126
+ __wasi_eventtype_t type;
127
+
128
+ __wasi_filesize_t nbytes;
129
+ __wasi_eventrwflags_t flags;
130
+ } m3_wasi_pollevent_t;
131
+
132
+
133
+ d_m3EndExternC
134
+
135
+ #endif // d_m3HasWASI
136
+
137
+ #endif // m3_api_wasi_host_h