visaljs 0.0.6 → 0.0.8

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 (428) hide show
  1. package/README.md +63 -2
  2. package/THIRD_PARTY_LICENSES +1216 -0
  3. package/cli.js +4414 -325
  4. package/node/include/js_node.h +57 -1
  5. package/node/include/js_uv.h +8 -1
  6. package/node/prelude/_stream_duplex.js +4 -0
  7. package/node/prelude/_stream_passthrough.js +4 -0
  8. package/node/prelude/_stream_readable.js +4 -0
  9. package/node/prelude/_stream_transform.js +4 -0
  10. package/node/prelude/_stream_writable.js +4 -0
  11. package/node/prelude/assert.js +1334 -0
  12. package/node/prelude/assert_strict.js +12 -0
  13. package/node/prelude/async_hooks.js +1 -1
  14. package/node/prelude/buffer.js +43 -3
  15. package/node/prelude/child_process.js +1098 -0
  16. package/node/prelude/cluster.js +52 -0
  17. package/node/prelude/console.js +328 -0
  18. package/node/prelude/constants.js +10 -0
  19. package/node/prelude/crypto.js +1 -1
  20. package/node/prelude/diagnostics_channel.js +1 -1
  21. package/node/prelude/dns.js +1 -1
  22. package/node/prelude/domain.js +115 -0
  23. package/node/prelude/events.js +144 -16
  24. package/node/prelude/fs.js +1138 -151
  25. package/node/prelude/fs_promises.js +117 -11
  26. package/node/prelude/http.js +104 -27
  27. package/node/prelude/http2.js +1 -1
  28. package/node/prelude/https.js +148 -0
  29. package/node/prelude/inspector.js +27 -0
  30. package/node/prelude/inspector_promises.js +4 -0
  31. package/node/prelude/internal/async_context.js +1 -1
  32. package/node/prelude/internal/buffer_transcode.js +44 -0
  33. package/node/prelude/internal/comparisons.js +916 -0
  34. package/node/prelude/internal/compression_streams.js +153 -0
  35. package/node/prelude/internal/crypto/asym.js +27 -14
  36. package/node/prelude/internal/crypto/cipher.js +16 -5
  37. package/node/prelude/internal/crypto/diffiehellman.js +3 -2
  38. package/node/prelude/internal/crypto/hash.js +2 -1
  39. package/node/prelude/internal/crypto/kdf.js +14 -9
  40. package/node/prelude/internal/crypto/keys.js +63 -50
  41. package/node/prelude/internal/crypto/random.js +2 -1
  42. package/node/prelude/internal/crypto/util.js +4 -4
  43. package/node/prelude/internal/dotenv.js +98 -0
  44. package/node/prelude/internal/errors.js +21 -5
  45. package/node/prelude/internal/events_extras.js +116 -0
  46. package/node/prelude/internal/events_on.js +100 -0
  47. package/node/prelude/internal/features.js +55 -0
  48. package/node/prelude/internal/fetch.js +364 -0
  49. package/node/prelude/internal/form_data.js +376 -0
  50. package/node/prelude/internal/fs_bigint_stats.js +41 -0
  51. package/node/prelude/internal/fs_blob.js +19 -0
  52. package/node/prelude/internal/fs_cp.js +709 -0
  53. package/node/prelude/internal/fs_dir.js +166 -0
  54. package/node/prelude/internal/fs_filehandle.js +287 -0
  55. package/node/prelude/internal/fs_glob.js +296 -0
  56. package/node/prelude/internal/fs_statfs.js +42 -0
  57. package/node/prelude/internal/fs_stats.js +89 -0
  58. package/node/prelude/internal/fs_streams.js +541 -0
  59. package/node/prelude/internal/fs_utils.js +286 -0
  60. package/node/prelude/internal/fs_watch.js +580 -0
  61. package/node/prelude/internal/http_agent.js +26 -0
  62. package/node/prelude/internal/mime.js +249 -0
  63. package/node/prelude/internal/net.js +1 -0
  64. package/node/prelude/internal/parse_args.js +288 -0
  65. package/node/prelude/internal/perf_histogram.js +435 -0
  66. package/node/prelude/internal/perf_observe.js +119 -0
  67. package/node/prelude/internal/performance_global.js +19 -0
  68. package/node/prelude/internal/process_events.js +49 -1
  69. package/node/prelude/internal/process_memory.js +14 -0
  70. package/node/prelude/internal/process_more.js +414 -0
  71. package/node/prelude/internal/process_signals.js +2 -1
  72. package/node/prelude/internal/process_stdin.js +52 -0
  73. package/node/prelude/internal/process_stdio.js +36 -0
  74. package/node/prelude/internal/querystring.js +0 -0
  75. package/node/prelude/internal/readline.js +338 -0
  76. package/node/prelude/internal/socketaddress.js +8 -4
  77. package/node/prelude/internal/source_map.js +122 -0
  78. package/node/prelude/internal/stream_compose.js +74 -0
  79. package/node/prelude/internal/stream_from.js +6 -0
  80. package/node/prelude/internal/stream_operators.js +23 -0
  81. package/node/prelude/internal/stream_pipeline.js +7 -0
  82. package/node/prelude/internal/stream_transform.js +10 -0
  83. package/node/prelude/internal/stream_web_adapters.js +143 -0
  84. package/node/prelude/internal/streams/add_abort_signal.js +58 -0
  85. package/node/prelude/internal/streams/compose.js +244 -0
  86. package/node/prelude/internal/streams/destroy.js +358 -0
  87. package/node/prelude/internal/streams/duplex.js +199 -0
  88. package/node/prelude/internal/streams/duplexify.js +378 -0
  89. package/node/prelude/internal/streams/end_of_stream.js +387 -0
  90. package/node/prelude/internal/streams/errors.js +216 -0
  91. package/node/prelude/internal/streams/from.js +211 -0
  92. package/node/prelude/internal/streams/legacy.js +120 -0
  93. package/node/prelude/internal/streams/operators.js +375 -0
  94. package/node/prelude/internal/streams/passthrough.js +45 -0
  95. package/node/prelude/internal/streams/pipeline.js +468 -0
  96. package/node/prelude/internal/streams/readable.js +1835 -0
  97. package/node/prelude/internal/streams/state.js +48 -0
  98. package/node/prelude/internal/streams/transform.js +203 -0
  99. package/node/prelude/internal/streams/utils.js +355 -0
  100. package/node/prelude/internal/streams/validators.js +108 -0
  101. package/node/prelude/internal/streams/writable.js +1160 -0
  102. package/node/prelude/internal/structured_clone.js +238 -0
  103. package/node/prelude/internal/system_errors.js +37 -0
  104. package/node/prelude/internal/test_runner/mock.js +431 -0
  105. package/node/prelude/internal/test_runner/reporters.js +404 -0
  106. package/node/prelude/internal/test_runner/test.js +1571 -0
  107. package/node/prelude/internal/timers.js +38 -7
  108. package/node/prelude/internal/timers_global.js +1 -1
  109. package/node/prelude/internal/tls/common.js +8 -2
  110. package/node/prelude/internal/tls/wrap.js +3 -15
  111. package/node/prelude/internal/tls/x509.js +1 -1
  112. package/node/prelude/internal/tty_read_stream.js +39 -0
  113. package/node/prelude/internal/tty_streams.js +3 -0
  114. package/node/prelude/internal/util_debuglog.js +68 -0
  115. package/node/prelude/internal/util_diff.js +63 -0
  116. package/node/prelude/internal/util_more.js +111 -0
  117. package/node/prelude/internal/util_styles.js +76 -0
  118. package/node/prelude/internal/zlib_engines.js +1 -1
  119. package/node/prelude/module.js +194 -7
  120. package/node/prelude/net.js +2 -1
  121. package/node/prelude/os.js +88 -11
  122. package/node/prelude/path.js +11 -7
  123. package/node/prelude/path_posix.js +1 -1
  124. package/node/prelude/path_win32.js +1 -1
  125. package/node/prelude/perf_hooks.js +147 -0
  126. package/node/prelude/process.js +36 -1
  127. package/node/prelude/punycode.js +188 -0
  128. package/node/prelude/querystring.js +1 -1
  129. package/node/prelude/readline.js +8 -0
  130. package/node/prelude/readline_promises.js +88 -0
  131. package/node/prelude/repl.js +38 -0
  132. package/node/prelude/sea.js +23 -0
  133. package/node/prelude/stream.js +70 -1332
  134. package/node/prelude/stream_consumers.js +34 -0
  135. package/node/prelude/stream_promises.js +1 -1
  136. package/node/prelude/stream_web.js +15 -2
  137. package/node/prelude/string_decoder.js +1 -1
  138. package/node/prelude/sys.js +7 -0
  139. package/node/prelude/test.js +56 -0
  140. package/node/prelude/test_reporters.js +269 -0
  141. package/node/prelude/timers.js +7 -84
  142. package/node/prelude/timers_promises.js +1 -1
  143. package/node/prelude/tls.js +2 -1
  144. package/node/prelude/trace_events.js +52 -0
  145. package/node/prelude/tty.js +10 -4
  146. package/node/prelude/url.js +88 -27
  147. package/node/prelude/util.js +121 -5
  148. package/node/prelude/util_types.js +4 -3
  149. package/node/prelude/v8.js +814 -0
  150. package/node/prelude/vm.js +86 -0
  151. package/node/prelude/wasi.js +10 -0
  152. package/node/prelude/worker_threads.js +56 -0
  153. package/node/prelude/zlib.js +58 -25
  154. package/node/src/host_brotli.c +59 -11
  155. package/node/src/host_fs.c +342 -11
  156. package/node/src/host_fswatch.c +170 -0
  157. package/node/src/host_http.c +143 -20
  158. package/node/src/host_loop.c +25 -2
  159. package/node/src/host_net.c +55 -7
  160. package/node/src/host_os.c +55 -1
  161. package/node/src/host_proc.c +291 -0
  162. package/node/src/host_process.c +488 -0
  163. package/node/src/host_sys.c +64 -2
  164. package/node/src/host_zlib.c +27 -7
  165. package/node/src/host_zstd.c +41 -6
  166. package/node/third_party/hdrhistogram/LICENSE +42 -0
  167. package/node/third_party/hdrhistogram/README.md +5 -0
  168. package/node/third_party/libuv/LICENSE +0 -0
  169. package/node/third_party/libuv/LICENSE-extra +36 -0
  170. package/node/third_party/libuv/include/uv/aix.h +0 -0
  171. package/node/third_party/libuv/include/uv/bsd.h +0 -0
  172. package/node/third_party/libuv/include/uv/darwin.h +0 -0
  173. package/node/third_party/libuv/include/uv/errno.h +0 -0
  174. package/node/third_party/libuv/include/uv/linux.h +0 -0
  175. package/node/third_party/libuv/include/uv/os390.h +0 -0
  176. package/node/third_party/libuv/include/uv/posix.h +0 -0
  177. package/node/third_party/libuv/include/uv/sunos.h +0 -0
  178. package/node/third_party/libuv/include/uv/threadpool.h +0 -0
  179. package/node/third_party/libuv/include/uv/tree.h +0 -0
  180. package/node/third_party/libuv/include/uv/unix.h +0 -0
  181. package/node/third_party/libuv/include/uv/version.h +0 -0
  182. package/node/third_party/libuv/include/uv/win.h +0 -0
  183. package/node/third_party/libuv/include/uv.h +0 -0
  184. package/node/third_party/libuv/src/fs-poll.c +0 -0
  185. package/node/third_party/libuv/src/heap-inl.h +0 -0
  186. package/node/third_party/libuv/src/idna.c +0 -0
  187. package/node/third_party/libuv/src/idna.h +0 -0
  188. package/node/third_party/libuv/src/inet.c +0 -0
  189. package/node/third_party/libuv/src/queue.h +0 -0
  190. package/node/third_party/libuv/src/random.c +0 -0
  191. package/node/third_party/libuv/src/strscpy.c +0 -0
  192. package/node/third_party/libuv/src/strscpy.h +0 -0
  193. package/node/third_party/libuv/src/strtok.c +0 -0
  194. package/node/third_party/libuv/src/strtok.h +0 -0
  195. package/node/third_party/libuv/src/thread-common.c +0 -0
  196. package/node/third_party/libuv/src/threadpool.c +0 -0
  197. package/node/third_party/libuv/src/timer.c +0 -0
  198. package/node/third_party/libuv/src/unix/async.c +0 -0
  199. package/node/third_party/libuv/src/unix/bsd-ifaddrs.c +0 -0
  200. package/node/third_party/libuv/src/unix/core.c +0 -0
  201. package/node/third_party/libuv/src/unix/darwin-proctitle.c +0 -0
  202. package/node/third_party/libuv/src/unix/darwin-stub.h +0 -0
  203. package/node/third_party/libuv/src/unix/darwin-syscalls.h +0 -0
  204. package/node/third_party/libuv/src/unix/darwin.c +0 -0
  205. package/node/third_party/libuv/src/unix/dl.c +0 -0
  206. package/node/third_party/libuv/src/unix/fs.c +0 -0
  207. package/node/third_party/libuv/src/unix/fsevents.c +0 -0
  208. package/node/third_party/libuv/src/unix/getaddrinfo.c +0 -0
  209. package/node/third_party/libuv/src/unix/getnameinfo.c +0 -0
  210. package/node/third_party/libuv/src/unix/internal.h +0 -0
  211. package/node/third_party/libuv/src/unix/kqueue.c +0 -0
  212. package/node/third_party/libuv/src/unix/linux.c +0 -0
  213. package/node/third_party/libuv/src/unix/loop-watcher.c +0 -0
  214. package/node/third_party/libuv/src/unix/loop.c +0 -0
  215. package/node/third_party/libuv/src/unix/pipe.c +0 -0
  216. package/node/third_party/libuv/src/unix/poll.c +0 -0
  217. package/node/third_party/libuv/src/unix/process.c +0 -0
  218. package/node/third_party/libuv/src/unix/procfs-exepath.c +0 -0
  219. package/node/third_party/libuv/src/unix/proctitle.c +0 -0
  220. package/node/third_party/libuv/src/unix/random-devurandom.c +0 -0
  221. package/node/third_party/libuv/src/unix/random-getentropy.c +0 -0
  222. package/node/third_party/libuv/src/unix/random-getrandom.c +0 -0
  223. package/node/third_party/libuv/src/unix/random-sysctl-linux.c +0 -0
  224. package/node/third_party/libuv/src/unix/signal.c +0 -0
  225. package/node/third_party/libuv/src/unix/stream.c +0 -0
  226. package/node/third_party/libuv/src/unix/tcp.c +0 -0
  227. package/node/third_party/libuv/src/unix/thread.c +0 -0
  228. package/node/third_party/libuv/src/unix/tty.c +0 -0
  229. package/node/third_party/libuv/src/unix/udp.c +0 -0
  230. package/node/third_party/libuv/src/uv-common.c +0 -0
  231. package/node/third_party/libuv/src/uv-common.h +0 -0
  232. package/node/third_party/libuv/src/uv-data-getter-setters.c +0 -0
  233. package/node/third_party/libuv/src/version.c +0 -0
  234. package/node/third_party/llhttp/LICENSE +0 -0
  235. package/node/third_party/llhttp/api.c +0 -0
  236. package/node/third_party/llhttp/http.c +0 -0
  237. package/node/third_party/llhttp/llhttp.c +0 -0
  238. package/node/third_party/llhttp/llhttp.h +0 -0
  239. package/node/third_party/nodejs/LICENSE +47 -0
  240. package/node/third_party/nodejs/README.md +5 -0
  241. package/node/third_party/parseargs/LICENSE +21 -0
  242. package/node/third_party/parseargs/README.md +5 -0
  243. package/node/third_party/punycode/LICENSE +20 -0
  244. package/node/third_party/punycode/README.md +5 -0
  245. package/node/third_party/zlib/LICENSE.chromium +27 -0
  246. package/package.json +1 -5
  247. package/prebuilt/darwin-arm64/boringssl-4a47438eaf7e73ba.a +0 -0
  248. package/prebuilt/darwin-arm64/brotli-7995bbdacc52e51c.a +0 -0
  249. package/prebuilt/darwin-arm64/uv-72ab666eae197cd8.a +0 -0
  250. package/prebuilt/darwin-arm64/zlib-4ce2317a4c3f5fb5.a +0 -0
  251. package/prebuilt/darwin-arm64/zstd-015315ac7c784c73.a +0 -0
  252. package/prebuilt/darwin-x64/boringssl-4a47438eaf7e73ba.a +0 -0
  253. package/prebuilt/darwin-x64/brotli-7995bbdacc52e51c.a +0 -0
  254. package/prebuilt/darwin-x64/uv-72ab666eae197cd8.a +0 -0
  255. package/prebuilt/darwin-x64/zlib-4ce2317a4c3f5fb5.a +0 -0
  256. package/prebuilt/darwin-x64/zstd-015315ac7c784c73.a +0 -0
  257. package/prebuilt/linux-arm64/boringssl-4a47438eaf7e73ba.a +0 -0
  258. package/prebuilt/linux-arm64/brotli-65481ff838ce9def.a +0 -0
  259. package/prebuilt/linux-arm64/uv-f1353f50ff983f3c.a +0 -0
  260. package/prebuilt/linux-arm64/zlib-4ce2317a4c3f5fb5.a +0 -0
  261. package/prebuilt/linux-arm64/zstd-015315ac7c784c73.a +0 -0
  262. package/prebuilt/linux-arm64-musl/boringssl-4a47438eaf7e73ba.a +0 -0
  263. package/prebuilt/linux-arm64-musl/brotli-65481ff838ce9def.a +0 -0
  264. package/prebuilt/linux-arm64-musl/uv-f1353f50ff983f3c.a +0 -0
  265. package/prebuilt/linux-arm64-musl/zlib-4ce2317a4c3f5fb5.a +0 -0
  266. package/prebuilt/linux-arm64-musl/zstd-015315ac7c784c73.a +0 -0
  267. package/prebuilt/linux-x64/boringssl-4a47438eaf7e73ba.a +0 -0
  268. package/prebuilt/linux-x64/brotli-65481ff838ce9def.a +0 -0
  269. package/prebuilt/linux-x64/uv-f1353f50ff983f3c.a +0 -0
  270. package/prebuilt/linux-x64/zlib-4ce2317a4c3f5fb5.a +0 -0
  271. package/prebuilt/linux-x64/zstd-015315ac7c784c73.a +0 -0
  272. package/prebuilt/linux-x64-musl/boringssl-4a47438eaf7e73ba.a +0 -0
  273. package/prebuilt/linux-x64-musl/brotli-65481ff838ce9def.a +0 -0
  274. package/prebuilt/linux-x64-musl/uv-f1353f50ff983f3c.a +0 -0
  275. package/prebuilt/linux-x64-musl/zlib-4ce2317a4c3f5fb5.a +0 -0
  276. package/prebuilt/linux-x64-musl/zstd-015315ac7c784c73.a +0 -0
  277. package/prebuilt/win32-x64/boringssl-ce573858472b7fc9.a +0 -0
  278. package/prebuilt/win32-x64/brotli-20d86a61f30baeb3.a +0 -0
  279. package/prebuilt/win32-x64/uv-b11bae65d7fced82.a +0 -0
  280. package/prebuilt/win32-x64/zlib-4ce2317a4c3f5fb5.a +0 -0
  281. package/prebuilt/win32-x64/zstd-015315ac7c784c73.a +0 -0
  282. package/runtime/include/js_atoms.gen.h +0 -0
  283. package/runtime/include/js_atoms.h +1 -1
  284. package/runtime/include/js_bigint.h +1 -1
  285. package/runtime/include/js_buffer.h +4 -4
  286. package/runtime/include/js_builtins.h +41 -3
  287. package/runtime/include/js_console.h +9 -4
  288. package/runtime/include/js_convert.h +1 -1
  289. package/runtime/include/js_core.def +5 -4
  290. package/runtime/include/js_crypto.h +1 -1
  291. package/runtime/include/js_error.h +1 -1
  292. package/runtime/include/js_exception.h +21 -1
  293. package/runtime/include/js_function.h +33 -9
  294. package/runtime/include/js_gc.h +172 -30
  295. package/runtime/include/js_generator.h +2 -2
  296. package/runtime/include/js_host.h +19 -1
  297. package/runtime/include/js_jobs.h +5 -5
  298. package/runtime/include/js_module.h +1 -1
  299. package/runtime/include/js_object.h +142 -15
  300. package/runtime/include/js_ops.h +107 -5
  301. package/runtime/include/js_promise.h +3 -3
  302. package/runtime/include/js_regexp.h +1 -1
  303. package/runtime/include/js_runtime.h +0 -0
  304. package/runtime/include/js_symbol.h +1 -1
  305. package/runtime/include/js_web.h +2 -1
  306. package/runtime/include/jscell.h +22 -15
  307. package/runtime/include/jscontext.h +74 -39
  308. package/runtime/include/jsnum.h +1 -1
  309. package/runtime/include/jsstring.h +19 -6
  310. package/runtime/include/jsvalue.h +7 -3
  311. package/runtime/src/arguments.c +2 -2
  312. package/runtime/src/array.c +4 -1
  313. package/runtime/src/arraybuffer.c +19 -7
  314. package/runtime/src/async_iter.c +4 -3
  315. package/runtime/src/atoms.c +1 -1
  316. package/runtime/src/base64.c +2 -2
  317. package/runtime/src/bigint.c +1 -1
  318. package/runtime/src/blob.c +22 -9
  319. package/runtime/src/boringssl_support.cc +1 -1
  320. package/runtime/src/buffer.c +299 -91
  321. package/runtime/src/builtin_table.c +1 -1
  322. package/runtime/src/builtins.c +30 -4
  323. package/runtime/src/builtins_util.h +0 -0
  324. package/runtime/src/collections.c +18 -3
  325. package/runtime/src/components.c +1 -1
  326. package/runtime/src/console.c +14 -7
  327. package/runtime/src/convert.c +0 -0
  328. package/runtime/src/core_all.c +1 -1
  329. package/runtime/src/crypto.c +1 -1
  330. package/runtime/src/crypto_asym.c +1 -1
  331. package/runtime/src/crypto_bn.c +1 -1
  332. package/runtime/src/crypto_cipher.c +10 -3
  333. package/runtime/src/crypto_hash.c +1 -1
  334. package/runtime/src/crypto_host.c +1 -1
  335. package/runtime/src/crypto_internal.h +1 -1
  336. package/runtime/src/crypto_kdf.c +1 -1
  337. package/runtime/src/crypto_key.c +14 -1
  338. package/runtime/src/crypto_pkey.c +1 -1
  339. package/runtime/src/crypto_subtle.c +142 -58
  340. package/runtime/src/crypto_tls.c +1 -1
  341. package/runtime/src/date.c +5 -2
  342. package/runtime/src/domexception.c +2 -2
  343. package/runtime/src/elements.c +56 -17
  344. package/runtime/src/elements.h +7 -2
  345. package/runtime/src/encoding.c +1 -1
  346. package/runtime/src/error.c +4 -4
  347. package/runtime/src/events.c +23 -14
  348. package/runtime/src/exception.c +1 -1
  349. package/runtime/src/fetch.c +241 -17
  350. package/runtime/src/function.c +31 -19
  351. package/runtime/src/gc.c +1716 -207
  352. package/runtime/src/gc_visit.h +87 -0
  353. package/runtime/src/generator.c +5 -3
  354. package/runtime/src/global.c +14 -6
  355. package/runtime/src/headers.c +10 -10
  356. package/runtime/src/inspect.c +76 -17
  357. package/runtime/src/internal.h +5 -2
  358. package/runtime/src/iterate.c +94 -2
  359. package/runtime/src/iterator.c +1 -1
  360. package/runtime/src/jobs.c +11 -5
  361. package/runtime/src/jsnum.c +2 -2
  362. package/runtime/src/json.c +1 -1
  363. package/runtime/src/math.c +9 -1
  364. package/runtime/src/module.c +3 -3
  365. package/runtime/src/number.c +0 -0
  366. package/runtime/src/object.c +107 -74
  367. package/runtime/src/ops.c +21 -3
  368. package/runtime/src/os.c +192 -1
  369. package/runtime/src/os.h +33 -2
  370. package/runtime/src/process.c +73 -8
  371. package/runtime/src/promise.c +4 -4
  372. package/runtime/src/proxy.c +1 -1
  373. package/runtime/src/reflect.c +1 -1
  374. package/runtime/src/regexp.c +134 -2
  375. package/runtime/src/regexp_anchor.h +1 -1
  376. package/runtime/src/regexp_message.h +1 -1
  377. package/runtime/src/shape.c +10 -19
  378. package/runtime/src/shape.h +0 -0
  379. package/runtime/src/streams.c +22 -8
  380. package/runtime/src/streams.h +0 -0
  381. package/runtime/src/string.c +64 -25
  382. package/runtime/src/string_builtins.c +7 -7
  383. package/runtime/src/symbol.c +2 -7
  384. package/runtime/src/test_host.c +3 -3
  385. package/runtime/src/tls_roots.gen.h +102 -620
  386. package/runtime/src/typedarray.c +8 -3
  387. package/runtime/src/tznames.gen.h +2 -1
  388. package/runtime/src/uri.c +1 -1
  389. package/runtime/src/url.c +42 -39
  390. package/runtime/src/weak.c +15 -12
  391. package/runtime/src/web.c +21 -3
  392. package/runtime/src/wrapper.c +0 -0
  393. package/runtime/src/writable.c +7 -6
  394. package/runtime/third_party/ada-idna/LICENSE-MIT +0 -0
  395. package/runtime/third_party/ada-idna/README.md +7 -7
  396. package/runtime/third_party/ada-idna/convert.mjs +89 -27
  397. package/runtime/third_party/ada-idna/idna.c +30 -31
  398. package/runtime/third_party/ada-idna/idna.h +0 -0
  399. package/runtime/third_party/ada-idna/idna_tables.h +2272 -1952
  400. package/runtime/third_party/boringssl/third_party/fiat/LICENSE +15 -0
  401. package/runtime/third_party/mozilla-ca/LICENSE +373 -0
  402. package/runtime/third_party/mozilla-ca/README.md +9 -0
  403. package/runtime/third_party/nodejs/LICENSE +47 -0
  404. package/runtime/third_party/nodejs/README.md +7 -0
  405. package/runtime/third_party/quickjs-dtoa/LICENSE +0 -0
  406. package/runtime/third_party/quickjs-dtoa/README.md +1 -1
  407. package/runtime/third_party/quickjs-dtoa/dtoa.c +0 -0
  408. package/runtime/third_party/quickjs-dtoa/dtoa.h +0 -0
  409. package/runtime/third_party/quickjs-dtoa/dtoa_compat.h +0 -0
  410. package/runtime/third_party/quickjs-regexp/LICENSE +0 -0
  411. package/runtime/third_party/quickjs-regexp/README.md +2 -2
  412. package/runtime/third_party/quickjs-regexp/cutils.c +0 -0
  413. package/runtime/third_party/quickjs-regexp/cutils.h +0 -0
  414. package/runtime/third_party/quickjs-regexp/libregexp-opcode.h +0 -0
  415. package/runtime/third_party/quickjs-regexp/libregexp.c +0 -0
  416. package/runtime/third_party/quickjs-regexp/libregexp.h +0 -0
  417. package/runtime/third_party/quickjs-regexp/libunicode-table.h +0 -0
  418. package/runtime/third_party/quickjs-regexp/libunicode.c +0 -0
  419. package/runtime/third_party/quickjs-regexp/libunicode.h +0 -0
  420. package/runtime/third_party/unicode/LICENSE +39 -0
  421. package/runtime/third_party/unicode/README.md +9 -0
  422. package/runtime/third_party/v8-ieee754/LICENSE +0 -0
  423. package/runtime/third_party/v8-ieee754/LICENSE.fdlibm +10 -0
  424. package/runtime/third_party/v8-ieee754/README.md +3 -2
  425. package/runtime/third_party/v8-ieee754/convert.py +0 -0
  426. package/runtime/third_party/v8-ieee754/ieee754.c +0 -0
  427. package/runtime/third_party/v8-ieee754/ieee754.h +0 -0
  428. package/runtime/tools/regexp_compile.c +2 -2
@@ -1,6 +1,6 @@
1
- /* Typed arrays (ECMAScript §23.2, §10.4.5), the typedarray component (ADR 0014), which needs the
1
+ /* Typed arrays (ECMAScript §23.2, §10.4.5), the typedarray component, which needs the
2
2
  * arraybuffer component: %TypedArray%, its prototype's methods, and one constructor per element
3
- * type. BigInt64Array and BigUint64Array exist when the bigint component does (ADR 0016), which
3
+ * type. BigInt64Array and BigUint64Array exist when the bigint component does, which
4
4
  * is installed before this one; their elements are 64-bit integers read and written as BigInts.
5
5
  *
6
6
  * A typed array is an integer-indexed exotic object. Its class hooks and internal methods
@@ -94,7 +94,7 @@ static double load_number(const JSTypedArray *ta, size_t i) {
94
94
  }
95
95
  }
96
96
 
97
- /* An element: a Number, or for BigInt64Array and BigUint64Array its 64 bits (ADR 0016). */
97
+ /* An element: a Number, or for BigInt64Array and BigUint64Array its 64 bits. */
98
98
  typedef union {
99
99
  double num;
100
100
  uint64_t raw;
@@ -1234,6 +1234,10 @@ static double hook_typed_array_length(JSValue v) {
1234
1234
  return out_of_bounds(as_ta(v)) ? -1 : (double)ta_length(as_ta(v));
1235
1235
  }
1236
1236
 
1237
+ static bool hook_view_bytes(JSValue v, uint8_t **data, size_t *length) {
1238
+ return !js_is_array_buffer(v) && js_buffer_source_bytes(v, data, length);
1239
+ }
1240
+
1237
1241
  /* ---- Realm ----------------------------------------------------------------------------------- */
1238
1242
 
1239
1243
  static const JSBuiltin typed_array_statics[] = {
@@ -1325,6 +1329,7 @@ static void install_typedarray(JSContext *ctx, JSObject *global) {
1325
1329
  }
1326
1330
  ctx->rt->is_typed_array = hook_is_typed_array;
1327
1331
  ctx->rt->typed_array_length = hook_typed_array_length;
1332
+ ctx->rt->view_bytes = hook_view_bytes;
1328
1333
  }
1329
1334
 
1330
1335
  const JSComponent js_component_typedarray = { "typedarray", install_typedarray };
@@ -1,4 +1,5 @@
1
- /* Generated by runtime/tools/gen_tznames.mjs from the ICU data of Node v22.22.2. Do not edit. */
1
+ /* Generated by runtime/tools/gen_tznames.mjs from the ICU data of Node v24.21.0. Do not edit. */
2
+ /* CLDR data, Copyright Unicode, Inc. (Unicode License v3): runtime/third_party/unicode/LICENSE. */
2
3
  /* Each zone's standard and daylight names (indices into tz_names), sorted by zone id. */
3
4
  static const char *const tz_names[] = {
4
5
  "Greenwich Mean Time",
package/runtime/src/uri.c CHANGED
@@ -1,5 +1,5 @@
1
1
  /* The URI handling functions (§19.2.6): encodeURI, encodeURIComponent, decodeURI and
2
- * decodeURIComponent. Core built-ins (ADR 0014): their entries are in js_core.def. */
2
+ * decodeURIComponent. Core built-ins: their entries are in js_core.def. */
3
3
  #include "builtins_util.h"
4
4
 
5
5
  #include <stdlib.h>
package/runtime/src/url.c CHANGED
@@ -1,7 +1,7 @@
1
- /* URL and URLSearchParams (WHATWG URL), the url component (ADR 0017), which needs nothing else.
1
+ /* URL and URLSearchParams (WHATWG URL), the url component, which needs nothing else.
2
2
  * The basic URL parser is the standard's state machine, in C, on code points; hosts go
3
3
  * through IDNA as Ada does it (runtime/third_party/ada-idna), so results match Node's, whose
4
- * URL is Ada (2.9.2 in Node v22). A record keeps each component serialized (ASCII): a
4
+ * URL is Ada (4.0.0 in Node v24). A record keeps each component serialized (ASCII): a
5
5
  * non-opaque path is its serialization, "/a/b", whose segments are what the slashes delimit.
6
6
  * The API is Node's: its errors, its inspection, and URLSearchParams' iteration. */
7
7
  #include <stdio.h>
@@ -122,8 +122,8 @@ static bool in_set(int set, uint32_t c) {
122
122
  case SET_USERINFO:
123
123
  if (c == '/' || c == ':' || c == ';' || c == '=' || c == '@' || (c >= '[' && c <= '^') || c == '|') return true;
124
124
  /* fallthrough */
125
- case SET_PATH: /* without ^, which the standard added after Ada 2.9.2 (Node v22) */
126
- if (c == '?' || c == '`' || c == '{' || c == '}') return true;
125
+ case SET_PATH:
126
+ if (c == '?' || c == '^' || c == '`' || c == '{' || c == '}') return true;
127
127
  /* fallthrough */
128
128
  case SET_QUERY:
129
129
  return c == ' ' || c == '"' || c == '#' || c == '<' || c == '>';
@@ -724,12 +724,6 @@ static bool basic_parse(const uint32_t *in, size_t n, const URLRecord *base, URL
724
724
  p--;
725
725
  state = ST_FILE_HOST;
726
726
  } else if (c == ':' && !inside_brackets) {
727
- if (buffer.n == 0 && override == ST_HOST && !is_special(url)) { /* Ada: host "" and a port */
728
- buf_clear(&url->host);
729
- url->has_host = true;
730
- state = ST_PORT;
731
- break;
732
- }
733
727
  if (buffer.n == 0) FAIL();
734
728
  if (override == ST_HOSTNAME) FAIL();
735
729
  if (!parse_host(buffer.v, buffer.n, !is_special(url), &url->host)) FAIL();
@@ -863,9 +857,8 @@ static bool basic_parse(const uint32_t *in, size_t n, const URLRecord *base, URL
863
857
  if (c == END || c == '/' || (is_special(url) && c == '\\') || (!override && (c == '?' || c == '#'))) {
864
858
  bool slash = c == '/' || (is_special(url) && c == '\\');
865
859
  if (is_double_dot(&pbuf)) {
866
- bool was_empty = url->path.n == 0; /* Ada: nothing to shorten adds no segment, unless special */
867
860
  shorten_path(url);
868
- if (!slash && (is_special(url) || !was_empty)) path_append(url, "", 0);
861
+ if (!slash) path_append(url, "", 0);
869
862
  } else if (is_single_dot(&pbuf) && !slash) {
870
863
  path_append(url, "", 0);
871
864
  } else if (!is_single_dot(&pbuf)) {
@@ -890,6 +883,11 @@ static bool basic_parse(const uint32_t *in, size_t n, const URLRecord *base, URL
890
883
  }
891
884
  break;
892
885
  case ST_OPAQUE_PATH:
886
+ /* a space just before the query or fragment: %20, so the path doesn't end in one */
887
+ if ((c == '?' || c == '#') && url->path.n && url->path.v[url->path.n - 1] == ' ') {
888
+ url->path.v[--url->path.n] = '\0';
889
+ buf_append(&url->path, "%20", 3);
890
+ }
893
891
  if (c == '?') {
894
892
  buf_clear(&url->query);
895
893
  url->has_query = true;
@@ -1088,14 +1086,14 @@ static ParamsObject *as_params(JSValue v) {
1088
1086
  static JSValue buf_string(JSContext *ctx, const char *s, size_t n) { return js_new_string_latin1(ctx, (const uint8_t *)(s ? s : ""), (uint32_t)n); }
1089
1087
 
1090
1088
  /* Appends a name/value pair to a params list. */
1091
- static void params_append(ParamsObject *p, JSValue name, JSValue value) {
1089
+ static void params_append(JSContext *ctx, ParamsObject *p, JSValue name, JSValue value) {
1092
1090
  if (p->n + 2 > p->cap) {
1093
1091
  size_t cap = p->cap;
1094
1092
  p->list = grow(p->list, &cap, p->n + 2, sizeof *p->list);
1095
1093
  p->cap = (uint32_t)cap;
1096
1094
  }
1097
- p->list[p->n++] = name;
1098
- p->list[p->n++] = value;
1095
+ js_store(ctx, &p->obj.cell, &p->list[p->n++], name);
1096
+ js_store(ctx, &p->obj.cell, &p->list[p->n++], value);
1099
1097
  }
1100
1098
 
1101
1099
  /* The application/x-www-form-urlencoded parser (URL §5.1) into a params list. */
@@ -1121,7 +1119,7 @@ static int params_parse(JSContext *ctx, ParamsObject *p, const uint8_t *in, size
1121
1119
  free(name.v);
1122
1120
  free(value.v);
1123
1121
  if (js_is_exception(vs)) return -1;
1124
- params_append(p, ns, vs);
1122
+ params_append(ctx, p, ns, vs);
1125
1123
  }
1126
1124
  if (!amp) break;
1127
1125
  start = end + 1;
@@ -1487,11 +1485,16 @@ BUILTIN(url_set_port) {
1487
1485
  CPs in = { 0 };
1488
1486
  if (setter_input(ctx, ARG(0), &in) < 0) return JS_EXCEPTION;
1489
1487
  if (!cannot_have_credentials(u->rec)) {
1490
- size_t k = 0; /* Ada removes tabs and newlines before the empty check */
1491
- for (size_t i = 0; i < in.n; i++)
1492
- if (in.v[i] != '\t' && in.v[i] != '\n' && in.v[i] != '\r') in.v[k++] = in.v[i];
1493
- if (k == 0) u->rec->port = -1;
1494
- else parse_override(ctx, in.v, k, u->rec, ST_PORT);
1488
+ /* the empty string clears the port; anything else is parsed, its tabs and newlines removed
1489
+ first (only those: nothing changes) */
1490
+ if (in.n == 0) {
1491
+ u->rec->port = -1;
1492
+ } else {
1493
+ size_t k = 0;
1494
+ for (size_t i = 0; i < in.n; i++)
1495
+ if (in.v[i] != '\t' && in.v[i] != '\n' && in.v[i] != '\r') in.v[k++] = in.v[i];
1496
+ if (k) parse_override(ctx, in.v, k, u->rec, ST_PORT);
1497
+ }
1495
1498
  }
1496
1499
  free(in.v);
1497
1500
  return JS_UNDEFINED;
@@ -1552,7 +1555,7 @@ BUILTIN(url_search_params) {
1552
1555
  THIS_URL();
1553
1556
  if (js_is_empty(u->search_params)) {
1554
1557
  JSValue p = new_params(ctx, ctx->intrinsics[JS_INTRINSIC_URL_SEARCH_PARAMS_PROTOTYPE]);
1555
- js_store(ctx, &u->obj.cell, &((ParamsObject *)js_as_object(p))->url, this_val);
1558
+ js_store(ctx, &js_as_object(p)->cell, &((ParamsObject *)js_as_object(p))->url, this_val);
1556
1559
  js_store(ctx, &u->obj.cell, &u->search_params, p);
1557
1560
  if (refresh_params(ctx, u) < 0) return JS_EXCEPTION;
1558
1561
  }
@@ -1651,7 +1654,7 @@ static int pair_from_iterable(JSContext *ctx, ParamsObject *p, JSValue pair) {
1651
1654
  if (js_is_exception(name) || js_is_exception(name = to_usv(ctx, name))) return -1;
1652
1655
  JSValue value = js_get_value(ctx, pair, js_int32(1));
1653
1656
  if (js_is_exception(value) || js_is_exception(value = to_usv(ctx, value))) return -1;
1654
- params_append(p, name, value);
1657
+ params_append(ctx, p, name, value);
1655
1658
  return 0;
1656
1659
  }
1657
1660
  if (!js_is_object(pair)) goto bad;
@@ -1673,7 +1676,7 @@ static int pair_from_iterable(JSContext *ctx, ParamsObject *p, JSValue pair) {
1673
1676
  p->list = grow(p->list, &cap, p->n + 1, sizeof *p->list);
1674
1677
  p->cap = (uint32_t)cap;
1675
1678
  }
1676
- p->list[p->n++] = e;
1679
+ js_store(ctx, &p->obj.cell, &p->list[p->n++], e);
1677
1680
  }
1678
1681
  if (length != 2) goto bad;
1679
1682
  return 0;
@@ -1691,13 +1694,13 @@ BUILTIN(params_ctor) {
1691
1694
  JSValue self = new_params(ctx, proto);
1692
1695
  ParamsObject *p = (ParamsObject *)js_as_object(self);
1693
1696
  JSValue init = ARG(0);
1694
- if (js_is_nullish(init)) return self;
1697
+ if (js_is_undefined(init)) return self; /* null is the string "null" (Node 24, the standard) */
1695
1698
  if (js_is_object(init)) {
1696
1699
  ParamsObject *other = as_params(init);
1697
1700
  JSValue method = js_get_value(ctx, init, JS_SYMBOL(iterator));
1698
1701
  if (js_is_exception(method)) return method;
1699
1702
  if (other && js_same_bits(method, ctx->intrinsics[JS_INTRINSIC_URL_SEARCH_PARAMS_ENTRIES])) {
1700
- for (uint32_t i = 0; i < other->n; i += 2) params_append(p, other->list[i], other->list[i + 1]);
1703
+ for (uint32_t i = 0; i < other->n; i += 2) params_append(ctx, p, other->list[i], other->list[i + 1]);
1701
1704
  return self;
1702
1705
  }
1703
1706
  if (!js_is_nullish(method)) { /* sequence<sequence<USVString>> */
@@ -1729,8 +1732,8 @@ BUILTIN(params_ctor) {
1729
1732
  if (js_is_exception(value) || js_is_exception(value = to_usv(ctx, value))) return JS_EXCEPTION;
1730
1733
  uint32_t k = 0;
1731
1734
  while (k < p->n && !js_string_equals(ctx, p->list[k], name)) k += 2;
1732
- if (k < p->n) p->list[k + 1] = value;
1733
- else params_append(p, name, value);
1735
+ if (k < p->n) js_store(ctx, &p->obj.cell, &p->list[k + 1], value);
1736
+ else params_append(ctx, p, name, value);
1734
1737
  }
1735
1738
  return self;
1736
1739
  }
@@ -1767,7 +1770,7 @@ BUILTIN(params_append_method) {
1767
1770
  if (js_is_exception(name)) return name;
1768
1771
  JSValue value = to_usv(ctx, argv[1]);
1769
1772
  if (js_is_exception(value)) return value;
1770
- params_append(sp, name, value);
1773
+ params_append(ctx, sp, name, value);
1771
1774
  update_url(ctx, sp);
1772
1775
  return JS_UNDEFINED;
1773
1776
  }
@@ -1800,8 +1803,8 @@ BUILTIN(params_delete) {
1800
1803
  uint32_t k = 0;
1801
1804
  for (uint32_t i = 0; i < sp->n; i += 2) {
1802
1805
  if (pair_matches(ctx, sp, i, name, value)) continue;
1803
- sp->list[k++] = sp->list[i];
1804
- sp->list[k++] = sp->list[i + 1];
1806
+ sp->list[k++] = sp->list[i]; /* barrier: same owner */
1807
+ sp->list[k++] = sp->list[i + 1]; /* barrier: same owner */
1805
1808
  }
1806
1809
  sp->n = k;
1807
1810
  update_url(ctx, sp);
@@ -1855,13 +1858,13 @@ BUILTIN(params_set) {
1855
1858
  if (js_string_equals(ctx, sp->list[i], name)) {
1856
1859
  if (found) continue;
1857
1860
  found = true;
1858
- sp->list[i + 1] = value;
1861
+ js_store(ctx, &sp->obj.cell, &sp->list[i + 1], value);
1859
1862
  }
1860
- sp->list[k++] = sp->list[i];
1861
- sp->list[k++] = sp->list[i + 1];
1863
+ sp->list[k++] = sp->list[i]; /* barrier: same owner */
1864
+ sp->list[k++] = sp->list[i + 1]; /* barrier: same owner */
1862
1865
  }
1863
1866
  sp->n = k;
1864
- if (!found) params_append(sp, name, value);
1867
+ if (!found) params_append(ctx, sp, name, value);
1865
1868
  update_url(ctx, sp);
1866
1869
  return JS_UNDEFINED;
1867
1870
  }
@@ -1874,12 +1877,12 @@ BUILTIN(params_sort) {
1874
1877
  JSValue name = sp->list[i], value = sp->list[i + 1];
1875
1878
  uint32_t k = i;
1876
1879
  while (k > 0 && js_string_compare(ctx, sp->list[k - 2], name) > 0) {
1877
- sp->list[k] = sp->list[k - 2];
1878
- sp->list[k + 1] = sp->list[k - 1];
1880
+ sp->list[k] = sp->list[k - 2]; /* barrier: same owner */
1881
+ sp->list[k + 1] = sp->list[k - 1]; /* barrier: same owner */
1879
1882
  k -= 2;
1880
1883
  }
1881
- sp->list[k] = name;
1882
- sp->list[k + 1] = value;
1884
+ sp->list[k] = name; /* barrier: same owner */
1885
+ sp->list[k + 1] = value; /* barrier: same owner */
1883
1886
  }
1884
1887
  update_url(ctx, sp);
1885
1888
  return JS_UNDEFINED;
@@ -1,4 +1,4 @@
1
- /* Weak collections and references (ECMAScript §24.3–24.4, §26.1–26.2; ADR 0002): WeakMap
1
+ /* Weak collections and references (ECMAScript §24.3–24.4, §26.1–26.2): WeakMap
2
2
  * and WeakSet (ephemerons), WeakRef with the kept-alive set, FinalizationRegistry.
3
3
  *
4
4
  * Each such object keeps its weak slots in malloc'd memory its class visit doesn't trace,
@@ -59,7 +59,7 @@ typedef struct WeakEntry {
59
59
 
60
60
  typedef struct WeakTable {
61
61
  JSObject obj;
62
- WeakEntry *entries; /* malloc'd; NULL until the first key */
62
+ WeakEntry *entries; /* malloc'd, the heap's external memory; NULL until the first key */
63
63
  uint32_t cap, count, used; /* used: count + tombstones */
64
64
  } WeakTable;
65
65
 
@@ -83,10 +83,10 @@ static void insert_fresh(WeakEntry *entries, uint32_t cap, JSValue key, JSValue
83
83
  entries[i] = (WeakEntry){ key, value };
84
84
  }
85
85
 
86
- static void table_set(WeakTable *t, JSValue key, JSValue value) {
86
+ static void table_set(JSContext *ctx, WeakTable *t, JSValue key, JSValue value) {
87
87
  WeakEntry *e = find(t, key);
88
88
  if (e) {
89
- e->value = value; /* malloc'd memory: no write barrier (ADR 0002) */
89
+ e->value = value; /* malloc'd memory: no write barrier */
90
90
  return;
91
91
  }
92
92
  if ((t->used + 1) * 4 > t->cap * 3) { /* grow (or just drop tombstones) at 3/4 */
@@ -99,6 +99,7 @@ static void table_set(WeakTable *t, JSValue key, JSValue value) {
99
99
  if (!js_is_empty(k) && !js_same_bits(k, TOMBSTONE)) insert_fresh(entries, cap, k, t->entries[i].value);
100
100
  }
101
101
  free(t->entries);
102
+ js_gc_external_add(ctx->rt, ((size_t)cap - t->cap) * sizeof *entries); /* external memory */
102
103
  t->entries = entries;
103
104
  t->cap = cap;
104
105
  t->used = t->count;
@@ -118,8 +119,9 @@ static bool table_delete(WeakTable *t, JSValue key) {
118
119
  }
119
120
 
120
121
  static void table_finalize(JSRuntime *rt, JSCell *c) {
121
- (void)rt;
122
- free(((WeakTable *)c)->entries);
122
+ WeakTable *t = (WeakTable *)c;
123
+ js_gc_external_sub(rt, (size_t)t->cap * sizeof *t->entries);
124
+ free(t->entries);
123
125
  }
124
126
 
125
127
  static const JSClass weak_map_class = { "WeakMap", sizeof(WeakTable), NULL, NULL, NULL, NULL, NULL, table_finalize, NULL };
@@ -200,7 +202,7 @@ BUILTIN(weak_map_set) {
200
202
  WeakTable *t = this_table(ctx, this_val, &weak_map_class, "WeakMap.prototype.set");
201
203
  if (!t) return JS_EXCEPTION;
202
204
  if (!can_be_held_weakly(ARG(0))) return js_throw_type_error(ctx, "Invalid value used as weak map key");
203
- table_set(t, ARG(0), ARG(1));
205
+ table_set(ctx, t, ARG(0), ARG(1));
204
206
  return this_val;
205
207
  }
206
208
 
@@ -209,7 +211,7 @@ BUILTIN(weak_set_add) {
209
211
  WeakTable *t = this_table(ctx, this_val, &weak_set_class, "WeakSet.prototype.add");
210
212
  if (!t) return JS_EXCEPTION;
211
213
  if (!can_be_held_weakly(ARG(0))) return js_throw_type_error(ctx, "Invalid value used in weak set");
212
- if (!find(t, ARG(0))) table_set(t, ARG(0), JS_UNDEFINED);
214
+ if (!find(t, ARG(0))) table_set(ctx, t, ARG(0), JS_UNDEFINED);
213
215
  return this_val;
214
216
  }
215
217
  BUILTIN(weak_set_has) {
@@ -333,7 +335,8 @@ BUILTIN(registry_register) {
333
335
  r->cap = r->cap ? r->cap * 2 : 8;
334
336
  r->cells = xrealloc(r->cells, r->cap * sizeof *r->cells);
335
337
  }
336
- r->cells[r->count++] = (Registration){ target, held, token };
338
+ r->cells[r->count++] = (Registration){ target, held, token }; /* barrier: below */
339
+ js_write_barrier(ctx, &r->obj.cell, NULL, held); /* target and token are weak */
337
340
  return JS_UNDEFINED;
338
341
  }
339
342
 
@@ -347,7 +350,7 @@ BUILTIN(registry_unregister) {
347
350
  uint32_t n = 0;
348
351
  for (uint32_t i = 0; i < r->count; i++) {
349
352
  if (js_same_bits(r->cells[i].token, token)) removed = true;
350
- else r->cells[n++] = r->cells[i];
353
+ else r->cells[n++] = r->cells[i]; /* barrier: same owner */
351
354
  }
352
355
  r->count = n;
353
356
  return js_bool(removed);
@@ -363,7 +366,7 @@ static int cleanup_registry(Registry *r) {
363
366
  continue;
364
367
  }
365
368
  JSValue held = r->cells[i].held; /* on the C stack: still alive after the removal */
366
- r->cells[i] = r->cells[--r->count];
369
+ r->cells[i] = r->cells[--r->count]; /* barrier: same owner */
367
370
  JSValue result = js_call(ctx, r->cleanup, JS_UNDEFINED, 1, &held);
368
371
  if (js_is_exception(result)) return -1;
369
372
  i = 0; /* the callback may have registered or unregistered */
@@ -371,7 +374,7 @@ static int cleanup_registry(Registry *r) {
371
374
  return 0;
372
375
  }
373
376
 
374
- /* The host's FINALIZATION_CLEANUP tasks (ADR 0008): one registry at a time, each followed by
377
+ /* The host's FINALIZATION_CLEANUP tasks: one registry at a time, each followed by
375
378
  * a checkpoint. 0, or -1 after an uncaught error (reported). */
376
379
  int js_run_finalization_cleanups(JSContext *ctx) {
377
380
  JSRuntime *rt = ctx->rt;
package/runtime/src/web.c CHANGED
@@ -1,4 +1,4 @@
1
- /* Node's error shapes for the web-standard host layer (ADR 0012, layer 2), written in C for the
1
+ /* Node's error shapes for the web-standard host layer, written in C for the
2
2
  * components that throw them (the prelude has the same in JS, node/prelude/internal/errors.js). */
3
3
  #include "js_web.h"
4
4
 
@@ -11,6 +11,7 @@
11
11
  #include "internal.h"
12
12
  #include "js_bigint.h"
13
13
  #include "js_console.h"
14
+ #include "js_host.h"
14
15
  #include "js_symbol.h"
15
16
  #include "js_atoms.h"
16
17
  #include "js_convert.h"
@@ -70,8 +71,8 @@ void js_node_received(JSContext *ctx, JSValue v, char *buf, size_t cap) {
70
71
  } else if (js_is_function(v)) {
71
72
  JSValue n = js_get_value(ctx, v, JS_ATOM(name));
72
73
  if (js_is_exception(n)) js_discard(js_take_exception(ctx));
73
- if (js_is_string(n) && js_string_length(n) != 0) to_utf8(ctx, n, s, sizeof s);
74
- else strcpy(s, "<anonymous>");
74
+ if (js_is_string(n)) to_utf8(ctx, n, s, sizeof s);
75
+ else s[0] = '\0'; /* determineSpecificType: `function ${value.name}`, empty when anonymous */
75
76
  snprintf(buf, cap, " Received function %s", s);
76
77
  } else if (js_is_object(v)) {
77
78
  if (constructor_name(ctx, v, s, sizeof s)) snprintf(buf, cap, " Received an instance of %s", s);
@@ -212,3 +213,20 @@ JSValue js_decode_utf8_bytes(JSContext *ctx, const uint8_t *p, size_t n) {
212
213
  return s;
213
214
  }
214
215
 
216
+
217
+ /* cloneClass(value): an object's internal class, as structuredClone (node/prelude/internal/
218
+ * structured_clone.js) sorts values: "Object" (an ordinary object, a class instance's too),
219
+ * "Array", "Date", "Map", "TypedArray", "Proxy", "Arguments", "Function", a primitive wrapper's
220
+ * type ("Number", "String", …), a web class's name ("URL", "Blob", …); undefined for a primitive. */
221
+ JSValue js_host_clone_class(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target) {
222
+ UNUSED_ARGS;
223
+ JSValue v = ARG(0);
224
+ if (!js_is_object(v)) return JS_UNDEFINED;
225
+ if (js_is_function(v)) return js_new_string_cstr(ctx, "Function");
226
+ if (js_is_wrapper(v)) {
227
+ JSValue p = js_wrapped_value(v);
228
+ return js_new_string_cstr(ctx, js_is_string(p) ? "String" : js_is_number(p) ? "Number" : js_is_bool(p) ? "Boolean"
229
+ : js_is_bigint(p) ? "BigInt" : "Symbol");
230
+ }
231
+ return js_new_string_cstr(ctx, js_as_object(v)->shape->cls->name);
232
+ }
File without changes
@@ -1,5 +1,5 @@
1
1
  /* WritableStream and TransformStream (WHATWG Streams §5, §6), and ReadableStream's pipeTo and
2
- * pipeThrough (§4.9.4), in the streams component (ADR 0012, layer 2), as Node has them. The
2
+ * pipeThrough (§4.9.4), in the streams component, as Node has them. The
3
3
  * algorithms are the standard's, named as it names them: a writable stream's queue holds the
4
4
  * chunks written and the close request (EMPTY), its controller hands them to the sink one at a
5
5
  * time, and backpressure follows the queue's size against the highWaterMark. A transform stream
@@ -165,7 +165,7 @@ static WController *controller_of(WStream *s) { return as_wcontroller(s->control
165
165
  static bool close_queued_or_in_flight(WStream *s) { return !js_is_undefined(s->close_request) || !js_is_undefined(s->in_flight_close); }
166
166
  static bool has_operation_in_flight(WStream *s) { return !js_is_undefined(s->in_flight_write) || !js_is_undefined(s->in_flight_close); }
167
167
 
168
- static void queue_push(WController *k, JSValue chunk, double size) {
168
+ static void queue_push(JSContext *ctx, WController *k, JSValue chunk, double size) {
169
169
  if (k->head > 0 && k->n == k->cap) {
170
170
  memmove(k->queue, k->queue + k->head, (k->n - k->head) * sizeof *k->queue);
171
171
  k->n -= k->head;
@@ -178,8 +178,9 @@ static void queue_push(WController *k, JSValue chunk, double size) {
178
178
  k->queue = q;
179
179
  k->cap = cap;
180
180
  }
181
- k->queue[k->n++] = chunk;
182
- k->queue[k->n++] = js_number(size);
181
+ k->queue[k->n++] = chunk; /* barrier: below */
182
+ js_write_barrier(ctx, &k->obj.cell, NULL, chunk);
183
+ k->queue[k->n++] = js_number(size); /* barrier: not a cell */
183
184
  k->queue_size += size;
184
185
  }
185
186
  static bool queue_empty(const WController *k) { return k->head == k->n; }
@@ -426,7 +427,7 @@ static JSValue stream_close(JSContext *ctx, WStream *s) {
426
427
  Writer *w = as_writer(s->writer);
427
428
  if (w && s->backpressure && s->state == W_WRITABLE) resolve(ctx, w->ready, JS_UNDEFINED);
428
429
  WController *k = controller_of(s);
429
- queue_push(k, JS_EMPTY, 0);
430
+ queue_push(ctx, k, JS_EMPTY, 0);
430
431
  advance_queue_if_needed(ctx, k);
431
432
  return promise;
432
433
  }
@@ -458,7 +459,7 @@ static JSValue writer_write(JSContext *ctx, Writer *w, JSValue chunk) {
458
459
  error_if_needed(ctx, k, js_new_error(ctx, JS_RANGE_ERROR, js_new_string_cstr(ctx, "Invalid size")));
459
460
  return promise;
460
461
  }
461
- queue_push(k, chunk, size);
462
+ queue_push(ctx, k, chunk, size);
462
463
  if (!close_queued_or_in_flight(s) && s->state == W_WRITABLE) update_backpressure(ctx, s, desired_size(k) <= 0);
463
464
  advance_queue_if_needed(ctx, k);
464
465
  return promise;
File without changes
@@ -1,15 +1,15 @@
1
1
  # ada-idna
2
2
 
3
3
  UTS #46 domain-to-ASCII from [Ada](https://github.com/ada-url/ada) by Yagiz Nizipli and Daniel
4
- Lemire, the URL library Node uses, ported to C: `URL` hosts come out exactly as Node's (ADR 0017).
4
+ Lemire, the URL library Node uses, ported to C: `URL` hosts come out exactly as Node's.
5
5
  MIT license (`LICENSE-MIT`; Ada is also Apache-2.0).
6
6
 
7
- - **Upstream:** `src/ada_idna.cpp` of Ada **v2.9.2** (commit
8
- `1cca580d8586ca3818d43e0bb11c7a47d77ca5ee`), the version Node v22 bundles
9
- (`process.versions.ada`); IDNA 15.0.0.
10
- - **`idna_tables.h`** is generated by `convert.mjs` from that file: the mapping table (packed:
11
- first code point, status and mapping length in 32 bits, the mapping's index apart), the bidi
12
- classes, and the code point sets of the label rules as ranges.
7
+ - **Upstream:** `src/ada_idna.cpp` of Ada **v4.0.0**, the version Node v24 bundles
8
+ (`process.versions.ada`); IDNA 17.0.0.
9
+ - **`idna_tables.h`** is generated by `convert.mjs` from that file: Ada keeps its tables in a
10
+ raw-DEFLATE blob, which the script inflates and reads as Ada does, into the mapping table
11
+ (packed: first code point, status and mapping length in 32 bits, the mapping's index apart),
12
+ the bidi classes, and the code point sets of the label rules as ranges.
13
13
  - **`idna.c`** is the algorithm (mapping, punycode, label validity, to-ASCII), converted by hand
14
14
  from C++ to C step for step, Ada's quirks included (they are Node's behavior). Normalization to
15
15
  NFC uses QuickJS's libunicode (`third_party/quickjs-regexp`) instead of Ada's tables.
@@ -1,21 +1,97 @@
1
1
  // Generates idna_tables.h from Ada's ada_idna.cpp (the single-file IDNA of ada-url/ada, the
2
2
  // version Node bundles): the UTS #46 mapping table and the label-validity data, packed for C.
3
+ // Ada 4 keeps its tables in a raw-DEFLATE blob, read here as Ada reads it: a two-level table
4
+ // (64 code points a block) of statuses and UTF-8 mappings, bidi ranges and combining ranges.
3
5
  //
4
6
  // node runtime/third_party/ada-idna/convert.mjs <ada>/src/ada_idna.cpp
7
+ import { Buffer } from "node:buffer";
5
8
  import { readFileSync, writeFileSync } from "node:fs";
6
9
  import { join } from "node:path";
7
10
  import process from "node:process";
11
+ import { inflateRawSync } from "node:zlib";
8
12
 
9
13
  const source = readFileSync(process.argv[2], "utf8");
10
14
  const version = /\/\/ IDNA\s+([\d.]+)/.exec(source)[1];
11
15
 
16
+ /** A `constexpr` number of the source, by name. */
17
+ function constant(name) {
18
+ const m = new RegExp(`constexpr\\s+(?:size_t|uint32_t|uint16_t)\\s+${name}\\s*=\\s*(0x[0-9a-fA-F]+|\\d+)u?;`).exec(source);
19
+ if (!m) throw new Error(`no constant ${name}`);
20
+ return Number(m[1]);
21
+ }
22
+
12
23
  /** The numbers of the C++ array `name` (comments dropped). */
13
24
  function array(name) {
14
- const m = new RegExp(`\\b${name}\\[[^\\]]*\\](?:\\[[^\\]]*\\])?\\s*=\\s*\\{([\\s\\S]*?)\\};`).exec(source);
25
+ const m = new RegExp(`\\b${name}\\[[^\\]]*\\]\\s*=\\s*\\{([\\s\\S]*?)\\};`).exec(source);
15
26
  if (!m) throw new Error(`no array ${name}`);
16
27
  return m[1].replace(/\/\/.*$/gm, "").match(/0x[0-9a-fA-F]+|\d+/g).map(Number);
17
28
  }
18
29
 
30
+ /* the blob: inflated, little-endian sections at the offsets Ada names */
31
+ const blob = inflateRawSync(Buffer.from(array("compressed")));
32
+ if (blob.length !== constant("uncompressed_size")) throw new Error("the inflated tables aren't Ada's size");
33
+ const section = (name, size) => {
34
+ const at = constant(`off_${name}`), count = constant(`count_${name}`);
35
+ const read = { 1: (i) => blob[at + i], 2: (i) => blob.readUInt16LE(at + 2 * i), 4: (i) => blob.readUInt32LE(at + 4 * i),
36
+ 8: (i) => blob.readBigUInt64LE(at + 8 * i) }[size];
37
+ return Array.from({ length: count }, (_, i) => read(i));
38
+ };
39
+
40
+ /* ---- the mapping: each code point's status, and its mapping when mapped ---------------------- */
41
+
42
+ const VALID = 0xffff, DISALLOWED = 0xfffe, IGNORED = 0, BOOL_FLAG = 0x8000;
43
+ const stage1 = section("idna_stage1", 2);
44
+ const stage2 = section("idna_stage2", 2);
45
+ const boolBlocks = section("idna_bool_blocks", 8);
46
+ const utf8 = section("idna_utf8_mappings", 1);
47
+ const LOW_END = constant("IDNA_LOW_RANGE_END");
48
+ const HIGH_IGNORED_START = constant("IDNA_HIGH_IGNORED_START");
49
+ const HIGH_IGNORED_END = constant("IDNA_HIGH_IGNORED_END");
50
+
51
+ /** Ada's idna_lookup: VALID, DISALLOWED, IGNORED, or an offset into the UTF-8 mappings. */
52
+ function lookup(cp) {
53
+ if (cp < LOW_END) {
54
+ const ref = stage1[cp >> 6];
55
+ if (ref & BOOL_FLAG) {
56
+ const bit = (ref & ~BOOL_FLAG) * 64 + (cp & 63);
57
+ return (boolBlocks[bit >> 6] >> BigInt(bit & 63)) & 1n ? VALID : DISALLOWED;
58
+ }
59
+ return stage2[ref + (cp & 63)];
60
+ }
61
+ return cp >= HIGH_IGNORED_START && cp < HIGH_IGNORED_END ? IGNORED : DISALLOWED;
62
+ }
63
+
64
+ /** The code points of the NUL-terminated UTF-8 mapping at `at`. */
65
+ function mappingAt(at) {
66
+ let end = at;
67
+ while (utf8[end] !== 0) end++;
68
+ return [...Buffer.from(utf8.slice(at, end)).toString("utf8")].map((c) => c.codePointAt(0));
69
+ }
70
+
71
+ /* ranges of equal status (and, mapped, equal mapping), as idna.c reads them: status 0 ignored,
72
+ 1 valid, 2 disallowed, 3 mapped */
73
+ const entries = [];
74
+ for (let cp = 0; cp <= 0x10ffff; cp++) {
75
+ const v = lookup(cp);
76
+ const status = v === VALID ? 1 : v === DISALLOWED ? 2 : v === IGNORED ? 0 : 3;
77
+ const mapping = status === 3 ? mappingAt(v) : null;
78
+ const last = entries[entries.length - 1];
79
+ if (last && last.status === status && (status !== 3 || last.mapping.join() === mapping.join())) continue;
80
+ entries.push({ first: cp, status, mapping });
81
+ }
82
+ const mappings = [];
83
+ const keys = [];
84
+ const indices = [];
85
+ for (const { first, status, mapping } of entries) {
86
+ if (first >= 1 << 21 || (mapping && mapping.length >= 32)) throw new Error("table entry out of range");
87
+ keys.push((first | (status << 21) | ((mapping ? mapping.length : 0) << 23)) >>> 0);
88
+ indices.push(mapping ? mappings.length : 0);
89
+ if (mapping) mappings.push(...mapping);
90
+ }
91
+ if (mappings.length > 0xffff) throw new Error("mappings past a 16-bit index");
92
+
93
+ /* ---- label validity ----------------------------------------------------------------------- */
94
+
19
95
  /** Sorted code points as [first, last] ranges. */
20
96
  function ranges(points) {
21
97
  const out = [];
@@ -34,28 +110,14 @@ function rows(values, perLine, hex = true) {
34
110
  return lines.join("\n");
35
111
  }
36
112
 
37
- /* table[i] = { first code point, descriptor }: code (0 ignored, 1 valid, 2 disallowed, 3 mapped)
38
- * in the low byte; for a mapping, its index in `mappings` (bits 8-23) and length (bits 24-31).
39
- * Packed: first | code << 21 | length << 23, and the index apart. */
40
- const table = array("table");
41
- const keys = [];
42
- const indices = [];
43
- for (let i = 0; i < table.length; i += 2) {
44
- const [first, d] = [table[i], table[i + 1]];
45
- const code = d & 0xff;
46
- const mapped = code > 2;
47
- if (first >= 1 << 21 || (mapped && d >>> 24 >= 32)) throw new Error("table entry out of range");
48
- keys.push((first | ((mapped ? 3 : code) << 21) | ((mapped ? d >>> 24 : 0) << 23)) >>> 0);
49
- indices.push(mapped ? (d >>> 8) & 0xffff : 0);
50
- }
51
- const mappings = array("mappings");
52
-
53
- /* the bidi classes, in Ada's enum order */
54
- const DIRECTIONS = ["NONE", "BN", "CS", "ES", "ON", "EN", "L", "R", "NSM", "AL", "AN", "ET", "WS", "RLO", "LRO", "PDF", "RLE", "RLI", "FSI", "PDI", "LRI", "B", "S", "LRE"];
55
- const dirSource = /dir_table\[\]\s*=\s*\{([\s\S]*?)\};/.exec(source)[1];
56
- const dirs = [...dirSource.matchAll(/\{(0x[0-9a-f]+),\s*(0x[0-9a-f]+),\s*direction::(\w+)\}/g)].map((m) => [Number(m[1]), Number(m[2]), DIRECTIONS.indexOf(m[3])]);
57
-
58
- const sets = Object.fromEntries(["combining", "virama", "R", "L", "D"].map((n) => [n, ranges(array(`static uint32_t ${n}`))]));
113
+ /* the bidi classes: Ada's ranges, in its enum's order (idna.c's enum idna_direction) */
114
+ const dirFirst = section("dir_start", 4);
115
+ const dirLast = section("dir_final", 4);
116
+ const dirClass = section("dir_value", 1);
117
+ const combiningFlat = section("combining_flat", 4);
118
+ const combining = [];
119
+ for (let i = 0; i < combiningFlat.length; i += 2) combining.push([combiningFlat[i], combiningFlat[i + 1]]);
120
+ const sets = { combining, ...Object.fromEntries(["virama", "R", "L", "D"].map((n) => [n, ranges(array(`constexpr static uint32_t ${n}`))])) };
59
121
 
60
122
  const out = [];
61
123
  out.push(`/* Generated by runtime/third_party/ada-idna/convert.mjs from Ada's ada_idna.cpp (IDNA ${version}). Do not edit.`);
@@ -70,10 +132,10 @@ out.push(`static const uint16_t idna_table_index[${indices.length}] = {\n${rows(
70
132
  out.push(`static const uint32_t idna_mappings[${mappings.length}] = {\n${rows(mappings, 10)}\n};`);
71
133
  out.push("");
72
134
  out.push("/* Bidi classes (RFC 5893), as Ada's ranges: first, last, class (enum idna_direction). */");
73
- out.push(`#define IDNA_DIR_COUNT ${dirs.length}`);
74
- out.push(`static const uint32_t idna_dir_first[${dirs.length}] = {\n${rows(dirs.map((d) => d[0]), 10)}\n};`);
75
- out.push(`static const uint32_t idna_dir_last[${dirs.length}] = {\n${rows(dirs.map((d) => d[1]), 10)}\n};`);
76
- out.push(`static const uint8_t idna_dir_class[${dirs.length}] = {\n${rows(dirs.map((d) => d[2]), 24, false)}\n};`);
135
+ out.push(`#define IDNA_DIR_COUNT ${dirFirst.length}`);
136
+ out.push(`static const uint32_t idna_dir_first[${dirFirst.length}] = {\n${rows(dirFirst, 10)}\n};`);
137
+ out.push(`static const uint32_t idna_dir_last[${dirLast.length}] = {\n${rows(dirLast, 10)}\n};`);
138
+ out.push(`static const uint8_t idna_dir_class[${dirClass.length}] = {\n${rows(dirClass, 24, false)}\n};`);
77
139
  out.push("");
78
140
  out.push("/* Code point sets of the label-validity rules, as sorted [first, last] ranges. */");
79
141
  for (const [name, rs] of Object.entries(sets)) {