visaljs 0.0.7 → 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 +4413 -324
  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 -1
  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,13 +1,17 @@
1
- // node:module (ADR 0009, 0012): createRequire, which the bundler's code uses for a require() it
1
+ // node:module: createRequire, which the bundler's code uses for a require() it
2
2
  // couldn't resolve at build time. A compiled program can't load new code: such a require gives
3
3
  // a package the bundler found the program may ask for and bundled (the require table), else
4
- // throws as Node's does for a module it can't find (as a computed import() rejects).
4
+ // throws as Node's does for a module it can't find (as a computed import() rejects). A JSON file
5
+ // is data, not code: a path ending in .json is read and parsed when asked for, as Node does
6
+ // (yargs's --config, a package.json found at run time).
5
7
  // builtinModules and isBuiltin list Node's built-in modules.
6
8
  //
7
- // It imports nothing: the bundler's own runtime imports it, and so runs it before any helper the
9
+ // It imports only the host primitives: the bundler's own runtime imports it, and so runs it before any helper the
8
10
  // bundler would wrap an imported module in. The bundler's runtime has its own copy, so the table
9
11
  // isn't this module's: the module the bundler generates puts it on globalThis, under this
10
12
  // symbol (name → a function giving the module's exports; cli/src/bundle.ts).
13
+ import { fsReadFile, fsStat } from "visaljs:host";
14
+
11
15
  export const REQUIRE_TABLE = Symbol.for("visaljs.requireTable");
12
16
 
13
17
  export const builtinModules = [
@@ -21,9 +25,12 @@ export const builtinModules = [
21
25
  "wasi", "worker_threads", "zlib",
22
26
  ];
23
27
 
28
+ /* the built-ins only named with the node: scheme (`test` alone is an npm package's name) */
29
+ const schemeOnly = ["node:sea", "node:sqlite", "node:test", "node:test/reporters"];
30
+
24
31
  export function isBuiltin(moduleName) {
25
32
  const name = String(moduleName);
26
- return builtinModules.includes(name.startsWith("node:") ? name.slice(5) : name);
33
+ return schemeOnly.includes(name) || builtinModules.includes(name.startsWith("node:") ? name.slice(5) : name);
27
34
  }
28
35
 
29
36
  function withCode(error, code) {
@@ -37,15 +44,26 @@ function notFound(id) {
37
44
  return e;
38
45
  }
39
46
 
47
+ /* require.extensions and Module._extensions (deprecated, still read: a hook saves the old one): a
48
+ * compiled program has no files to load, so each loader says so */
49
+ const extensions = { __proto__: null };
50
+ for (const ext of [".js", ".json", ".node"]) {
51
+ extensions[ext] = function (module, filename) {
52
+ throw withCode(new Error(`Cannot load ${filename}: a compiled program has no files to load at run time`), "ERR_UNKNOWN_FILE_EXTENSION");
53
+ };
54
+ }
55
+
40
56
  export function createRequire(filename) {
41
57
  if (typeof filename !== "string" && !(typeof URL === "function" && filename instanceof URL)) {
42
58
  throw withCode(new TypeError("The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received " +
43
59
  String(filename)), "ERR_INVALID_ARG_VALUE");
44
60
  }
61
+ const base = pathOf(filename);
45
62
  const require = (id) => {
46
63
  const load = globalThis[REQUIRE_TABLE]?.get(id);
47
- if (load === undefined) throw notFound(id);
48
- return load();
64
+ if (load !== undefined) return load();
65
+ if (typeof id === "string" && id.endsWith(".json") && /^(?:\.\.?\/|\/)/.test(id)) return requireJSON(require.cache, id, base);
66
+ throw notFound(id);
49
67
  };
50
68
  require.resolve = (id) => {
51
69
  throw notFound(id);
@@ -53,9 +71,43 @@ export function createRequire(filename) {
53
71
  require.resolve.paths = () => null;
54
72
  require.cache = { __proto__: null };
55
73
  require.main = undefined;
74
+ require.extensions = extensions;
56
75
  return require;
57
76
  }
58
77
 
78
+ function pathOf(filename) {
79
+ const s = typeof filename === "string" ? filename : filename.href;
80
+ return s.startsWith("file:") ? decodeURIComponent(new URL(s).pathname) : s;
81
+ }
82
+
83
+ /* an absolute path without its . and .. segments (node:path's normalize, which this module can't import) */
84
+ function normalize(path) {
85
+ const out = [];
86
+ for (const part of path.split("/")) {
87
+ if (part === "..") out.pop();
88
+ else if (part !== "." && part !== "") out.push(part);
89
+ }
90
+ return "/" + out.join("/");
91
+ }
92
+
93
+ /** A JSON file, by a path absolute or relative to the requiring file's directory: parsed once,
94
+ * then from require.cache, as Node's loader does. */
95
+ function requireJSON(cache, id, from) {
96
+ const path = normalize(id.startsWith("/") ? id : from.slice(0, from.lastIndexOf("/") + 1) + id);
97
+ if (path in cache) return cache[path].exports;
98
+ const text = fsReadFile(path, false);
99
+ if (typeof text !== "string") throw notFound(id);
100
+ let exports;
101
+ try {
102
+ exports = JSON.parse(text.charCodeAt(0) === 0xfeff ? text.slice(1) : text);
103
+ } catch (e) {
104
+ e.message = `${path}: ${e.message}`;
105
+ throw e;
106
+ }
107
+ cache[path] = { id: path, filename: path, loaded: true, exports };
108
+ return exports;
109
+ }
110
+
59
111
  /* internal/errors.js's, here: this module imports nothing */
60
112
  function notSupported(what) {
61
113
  return withCode(new Error(`${what} is not supported by visaljs`), "ERR_VISALJS_UNSUPPORTED");
@@ -66,4 +118,139 @@ export function register() {
66
118
  throw notSupported("module.register()");
67
119
  }
68
120
 
69
- export default { builtinModules, createRequire, isBuiltin, register };
121
+ export function registerHooks() {
122
+ throw notSupported("module.registerHooks()");
123
+ }
124
+
125
+ export function runMain() {
126
+ throw notSupported("module.runMain() (loading a program)");
127
+ }
128
+
129
+ /** Type stripping needs TypeScript's parser at run time, which a compiled program doesn't carry. */
130
+ export function stripTypeScriptTypes() {
131
+ throw notSupported("module.stripTypeScriptTypes()");
132
+ }
133
+
134
+ /** Node's live binding refresh for built-ins' ES module exports: they're always in step here. */
135
+ export function syncBuiltinESMExports() {}
136
+
137
+ /* ---- the compile cache: a compiled program has nothing to compile, so it's disabled ---------------- */
138
+
139
+ export const constants = Object.freeze({ compileCacheStatus: Object.freeze({ FAILED: 0, ENABLED: 1, ALREADY_ENABLED: 2, DISABLED: 3 }) });
140
+
141
+ export function enableCompileCache() {
142
+ return { status: constants.compileCacheStatus.DISABLED, message: "Disabled: a compiled program has no source to compile" };
143
+ }
144
+
145
+ export function getCompileCacheDir() {
146
+ return undefined;
147
+ }
148
+
149
+ export function flushCompileCache() {}
150
+
151
+ /* ---- source maps -------------------------------------------------------------------------------- */
152
+
153
+ let sourceMapsSupport = { enabled: false, nodeModules: false, generatedCode: false };
154
+
155
+ export function getSourceMapsSupport() {
156
+ return { ...sourceMapsSupport };
157
+ }
158
+
159
+ export function setSourceMapsSupport(enabled, options = {}) {
160
+ if (typeof enabled !== "boolean") throw withCode(new TypeError(`The "enabled" argument must be of type boolean.`), "ERR_INVALID_ARG_TYPE");
161
+ sourceMapsSupport = { enabled, nodeModules: Boolean(enabled && options.nodeModules), generatedCode: Boolean(enabled && options.generatedCode) };
162
+ }
163
+
164
+ /** The source map a loaded module carries: none are loaded at run time. */
165
+ export function findSourceMap() {
166
+ return undefined;
167
+ }
168
+
169
+ /** SourceMap: internal/source_map.js, linked when the program names it. */
170
+ export function SourceMap(payload, options) {
171
+ const Impl = globalThis[Symbol.for("visaljs.SourceMap")];
172
+ if (Impl === undefined) throw notSupported("module.SourceMap (named only at run time)");
173
+ if (!new.target) throw new TypeError("Class constructor SourceMap cannot be invoked without 'new'");
174
+ return Reflect.construct(Impl, [payload, options], new.target === SourceMap ? Impl : new.target);
175
+ }
176
+
177
+ /* ---- findPackageJSON ------------------------------------------------------------------------------- */
178
+
179
+ const isDir = (path) => {
180
+ const st = fsStat(path, true);
181
+ return typeof st !== "number" && (st[0] & 0o170000) === 0o040000;
182
+ };
183
+ const exists = (path) => typeof fsStat(path, true) !== "number";
184
+ const dirOf = (path) => path.slice(0, Math.max(path.lastIndexOf("/"), 0)) || "/";
185
+
186
+ /** findPackageJSON(specifier[, base]): the package.json closest to what the specifier resolves to
187
+ * (a path or file: URL, relative to base; or a package, from base's node_modules), or undefined. */
188
+ export function findPackageJSON(specifier, base) {
189
+ const spec = specifier instanceof URL ? specifier.href : String(specifier);
190
+ const baseText = base instanceof URL ? base.href : base === undefined ? undefined : String(base);
191
+ const unresolved = () => withCode(new TypeError(`Failed to resolve module specifier "${spec}" from "${baseText}": ` +
192
+ "Invalid relative URL or base scheme is not hierarchical."), "ERR_UNSUPPORTED_RESOLVE_REQUEST");
193
+ const basePath = baseText === undefined ? undefined : baseText.startsWith("file:") ? pathOf(baseText) : baseText;
194
+ let target;
195
+ if (spec.startsWith("file:")) target = pathOf(spec);
196
+ else if (spec.startsWith("/")) target = normalize(spec);
197
+ else if (spec.startsWith("./") || spec.startsWith("../")) {
198
+ if (basePath === undefined) throw unresolved();
199
+ const from = baseText.endsWith("/") ? basePath : dirOf(basePath);
200
+ target = normalize(`${from}/${spec}`);
201
+ } else {
202
+ /* a package: its directory under the closest node_modules that has it */
203
+ if (basePath === undefined) throw unresolved();
204
+ const name = spec.startsWith("@") ? spec.split("/").slice(0, 2).join("/") : spec.split("/")[0];
205
+ for (let dir = baseText.endsWith("/") ? normalize(basePath) : dirOf(normalize(basePath)); ; dir = dirOf(dir)) {
206
+ const candidate = `${dir === "/" ? "" : dir}/node_modules/${name}/package.json`;
207
+ if (exists(candidate)) return candidate;
208
+ if (dir === "/") throw withCode(new Error(`Cannot find package '${name}' imported from ${basePath}`), "ERR_MODULE_NOT_FOUND");
209
+ }
210
+ }
211
+ for (let dir = isDir(target) ? target : dirOf(target); ; dir = dirOf(dir)) {
212
+ const candidate = `${dir === "/" ? "" : dir}/package.json`;
213
+ if (exists(candidate)) return candidate;
214
+ if (dir === "/") return undefined;
215
+ }
216
+ }
217
+
218
+ /* ---- Module ---------------------------------------------------------------------------------------- */
219
+
220
+ /** Module: Node's CommonJS module record, with its helpers; the module's default export is it. */
221
+ function Module(id = "", parent) {
222
+ this.id = id;
223
+ this.path = id ? dirOf(id) : ".";
224
+ this.exports = {};
225
+ this.filename = null;
226
+ this.loaded = false;
227
+ this.children = [];
228
+ this.paths = [];
229
+ void parent;
230
+ }
231
+
232
+ export const globalPaths = [];
233
+ const wrapper = ["(function (exports, require, module, __filename, __dirname) { ", "\n});"];
234
+
235
+ /* in a pure call, so a program that doesn't use node:module (the bundler's runtime has a copy of it
236
+ * in every program) drops it all */
237
+ const ModuleWithHelpers = /* @__PURE__ */ Object.assign(Module, {
238
+ builtinModules, createRequire, isBuiltin, register, registerHooks, runMain, stripTypeScriptTypes, syncBuiltinESMExports, constants,
239
+ enableCompileCache, getCompileCacheDir, flushCompileCache, getSourceMapsSupport, setSourceMapsSupport, findSourceMap, SourceMap,
240
+ findPackageJSON, globalPaths, Module, wrapper,
241
+ wrap: (script) => wrapper[0] + script + wrapper[1],
242
+ _cache: { __proto__: null },
243
+ _extensions: extensions,
244
+ /* a built-in resolves to itself; a compiled program has no files to resolve to */
245
+ _resolveFilename(request) {
246
+ if (isBuiltin(request)) return request;
247
+ const e = withCode(new Error(`Cannot find module '${request}'`), "MODULE_NOT_FOUND");
248
+ e.requireStack = [];
249
+ throw e;
250
+ },
251
+ _load(request) {
252
+ return createRequire("/")(request);
253
+ },
254
+ });
255
+
256
+ export { ModuleWithHelpers as Module, ModuleWithHelpers as default };
@@ -1,4 +1,4 @@
1
- // node:net (ADR 0012, layer 3): TCP and Unix domain socket servers and sockets over the host
1
+ // node:net: TCP and Unix domain socket servers and sockets over the host
2
2
  // primitives of node/src/host_net.c (libuv), following Node's lib/net.js: a Socket is a Duplex
3
3
  // whose reads start and stop with backpressure, whose end() shuts the write side down, and which
4
4
  // closes once both sides are done (allowHalfOpen: false ends the write side when the peer's
@@ -6,6 +6,7 @@
6
6
  // for autoSelectFamilyAttemptTimeout ms (happy eyeballs, as Node's). Socket timeouts are
7
7
  // unref'd timers, refreshed by activity. SocketAddress and BlockList are in
8
8
  // internal/socketaddress.js.
9
+ // Ported from Node.js (Copyright Node.js contributors, MIT): node/third_party/nodejs/LICENSE.
9
10
  import {
10
11
  errnoMessage, errnoName, netAddress, netBind, netCallback, netChmod, netClose, netConnect, netGuessHandle, netKeepAlive, netListen,
11
12
  netNoDelay, netOpen, netOpenFd, netReadStart, netReadStop, netRef, netReset, netShutdown, netWrite, timerUnref,
@@ -1,13 +1,26 @@
1
- // node:os (ADR 0012, layer 3): the system's facts through libuv, as Node's lib/os.js gets them,
2
- // and the constants of the platform the program was built for. Not provided yet:
3
- // networkInterfaces, getPriority and setPriority (ERR_VISALJS_UNSUPPORTED).
1
+ // node:os: the system's facts through libuv, as Node's lib/os.js gets them,
2
+ // and the constants of the platform the program was built for.
3
+ // Ported from Node.js (Copyright Node.js contributors, MIT): node/third_party/nodejs/LICENSE.
4
4
  import {
5
- osConstants, osCpus, osHomedir, osHostname, osLoadavg, osMemory, osParallelism, osTmpdir, osUname, osUptime, osUserInfo,
5
+ errnoMessage, errnoName, osConstants, osCpus, osGetPriority, osHomedir, osHostname, osInterfaces, osLoadavg, osMemory, osParallelism,
6
+ osSetPriority, osTmpdir, osUname, osUptime, osUserInfo,
6
7
  } from "visaljs:host";
7
- import { notSupported, systemError } from "./internal/errors.js";
8
+ import { codeError, invalidArgType } from "./internal/errors.js";
9
+
10
+ /* Node's SystemError (ERR_SYSTEM_ERROR): "A system error occurred: uv_os_getpriority returned ESRCH
11
+ * (no such process)", with errno, code, syscall and info */
12
+ function osError(errno, syscall) {
13
+ const code = errnoName(errno), message = errnoMessage(errno);
14
+ const e = codeError(Error, "ERR_SYSTEM_ERROR", `A system error occurred: ${syscall} returned ${code} (${message})`);
15
+ e.name = "SystemError";
16
+ e.errno = errno;
17
+ e.syscall = syscall;
18
+ e.info = { errno, code, message, syscall };
19
+ return e;
20
+ }
8
21
 
9
22
  const check = (result, syscall) => {
10
- if (typeof result === "number" && result < 0) throw systemError(result, syscall);
23
+ if (typeof result === "number" && result < 0) throw osError(result, syscall);
11
24
  return result;
12
25
  };
13
26
  const uname = () => check(osUname(), "uv_os_uname");
@@ -89,16 +102,80 @@ export function userInfo(options) {
89
102
  return { uid, gid, username: enc(username), homedir: enc(home), shell: enc(shell) };
90
103
  }
91
104
 
105
+ /* the prefix length of a contiguous netmask, else null (Node's getCIDR) */
106
+ function cidrOf(address, netmask, family) {
107
+ let ones = 0, run = true;
108
+ if (family === "IPv4") {
109
+ for (const part of netmask.split(".")) {
110
+ for (let bit = 7; bit >= 0; bit--) {
111
+ if ((Number(part) >> bit) & 1) {
112
+ if (!run) return null;
113
+ ones++;
114
+ } else run = false;
115
+ }
116
+ }
117
+ } else {
118
+ const groups = expandIPv6(netmask);
119
+ for (const group of groups) {
120
+ for (let bit = 15; bit >= 0; bit--) {
121
+ if ((group >> bit) & 1) {
122
+ if (!run) return null;
123
+ ones++;
124
+ } else run = false;
125
+ }
126
+ }
127
+ }
128
+ return `${address}/${ones}`;
129
+ }
130
+
131
+ /* an IPv6 address's eight groups, :: expanded */
132
+ function expandIPv6(address) {
133
+ const [head, tail] = address.includes("::") ? address.split("::") : [address, undefined];
134
+ const parse = (s) => (s ? s.split(":").map((g) => parseInt(g, 16)) : []);
135
+ const left = parse(head), right = parse(tail);
136
+ return tail === undefined ? left : [...left, ...new Array(8 - left.length - right.length).fill(0), ...right];
137
+ }
138
+
139
+ /** The network interfaces and their addresses: name → [{ address, netmask, family, mac, internal,
140
+ * cidr, scopeid (IPv6) }], as libuv lists them. */
92
141
  export function networkInterfaces() {
93
- throw notSupported("os.networkInterfaces");
142
+ const flat = check(osInterfaces(), "uv_interface_addresses");
143
+ const result = {};
144
+ for (let i = 0; i < flat.length; i += 7) {
145
+ const [name, address, netmask, family, mac, internal, scopeid] = flat.slice(i, i + 7);
146
+ const entry = { address, netmask, family: family === 4 ? "IPv4" : "IPv6", mac, internal, cidr: null };
147
+ entry.cidr = cidrOf(address, netmask, entry.family);
148
+ if (family === 6) entry.scopeid = scopeid;
149
+ (result[name] ??= []).push(entry);
150
+ }
151
+ return result;
152
+ }
153
+
154
+ function validatePid(pid) {
155
+ if (typeof pid !== "number") throw invalidArgType("pid", "of type number", pid);
156
+ if (!Number.isInteger(pid) || pid < -2147483648 || pid > 2147483647) {
157
+ throw codeError(RangeError, "ERR_OUT_OF_RANGE", `The value of "pid" is out of range. It must be an integer. Received ${pid}`);
158
+ }
94
159
  }
95
160
 
96
- export function getPriority() {
97
- throw notSupported("os.getPriority");
161
+ /** A process's scheduling priority (0: this one). */
162
+ export function getPriority(pid = 0) {
163
+ validatePid(pid);
164
+ return check(osGetPriority(pid), "uv_os_getpriority");
98
165
  }
99
166
 
100
- export function setPriority() {
101
- throw notSupported("os.setPriority");
167
+ /** setPriority([pid,] priority): -20 (highest) to 19 (lowest). */
168
+ export function setPriority(pid, priority) {
169
+ if (priority === undefined) {
170
+ priority = pid;
171
+ pid = 0;
172
+ }
173
+ validatePid(pid);
174
+ if (typeof priority !== "number") throw invalidArgType("priority", "of type number", priority);
175
+ if (!Number.isInteger(priority) || priority < -20 || priority > 19) {
176
+ throw codeError(RangeError, "ERR_OUT_OF_RANGE", `The value of "priority" is out of range. It must be >= -20 && <= 19. Received ${priority}`);
177
+ }
178
+ check(osSetPriority(pid, priority), "uv_os_setpriority");
102
179
  }
103
180
 
104
181
  function nameTable(flat) {
@@ -1,9 +1,11 @@
1
- // node:path (ADR 0012, layer 3): Node's lib/path.js (MIT; Node v22), both its win32 and its
1
+ // node:path: Node's lib/path.js (MIT; Node v22), both its win32 and its
2
2
  // posix halves, ported: primordials are the methods they stand for, the working directory is the
3
- // host's, and matchesGlob (minimatch, which visaljs doesn't bundle) is a stub. Results match Node's
3
+ // host's, and matchesGlob is fs.glob's matcher (internal/fs_glob.js). Results match Node's
4
4
  // byte for byte; the default export is win32 on Windows, posix elsewhere, as Node's.
5
+ // Ported from Node.js (Copyright Node.js contributors, MIT): node/third_party/nodejs/LICENSE.
5
6
  import { cwd as hostCwd } from "visaljs:host";
6
- import { invalidArgType, notSupported, validateString } from "./internal/errors.js";
7
+ import { invalidArgType, validateString } from "./internal/errors.js";
8
+ import { feature } from "./internal/features.js";
7
9
 
8
10
  const CHAR_UPPERCASE_A = 65, CHAR_LOWERCASE_A = 97, CHAR_UPPERCASE_Z = 90, CHAR_LOWERCASE_Z = 122;
9
11
  const CHAR_DOT = 46, CHAR_FORWARD_SLASH = 47, CHAR_BACKWARD_SLASH = 92, CHAR_COLON = 58, CHAR_QUESTION_MARK = 63;
@@ -1162,8 +1164,9 @@ const win32 = {
1162
1164
  return ret;
1163
1165
  },
1164
1166
 
1165
- matchesGlob(_path, _pattern) {
1166
- throw notSupported('path.matchesGlob');
1167
+ /* internal/fs_glob.js's, linked when the program names it */
1168
+ matchesGlob(path, pattern) {
1169
+ return feature("matchesGlob")(path, pattern);
1167
1170
  },
1168
1171
 
1169
1172
  sep: '\\',
@@ -1644,8 +1647,9 @@ const posix = {
1644
1647
  return ret;
1645
1648
  },
1646
1649
 
1647
- matchesGlob(_path, _pattern) {
1648
- throw notSupported('path.matchesGlob');
1650
+ /* internal/fs_glob.js's, linked when the program names it */
1651
+ matchesGlob(path, pattern) {
1652
+ return feature("matchesGlob")(path, pattern);
1649
1653
  },
1650
1654
 
1651
1655
  sep: '/',
@@ -1,4 +1,4 @@
1
- // node:path/posix (ADR 0012, layer 3): path.posix, on every platform.
1
+ // node:path/posix: path.posix, on every platform.
2
2
  import { posix } from "./path.js";
3
3
 
4
4
  export const {
@@ -1,4 +1,4 @@
1
- // node:path/win32 (ADR 0012, layer 3): path.win32, on every platform.
1
+ // node:path/win32: path.win32, on every platform.
2
2
  import { win32 } from "./path.js";
3
3
 
4
4
  export const {
@@ -0,0 +1,147 @@
1
+ // node:perf_hooks: `performance`'s clock, marks and measures. The clock is
2
+ // process.hrtime's, from when this module loads: timeOrigin is that time on the epoch clock.
3
+ // PerformanceObserver and the histograms are modules of their own (internal/perf_observe.js,
4
+ // internal/perf_histogram.js), linked when the program names them.
5
+ import { codeError, invalidArgType } from "./internal/errors.js";
6
+ import { features, lazyClass, lazyFunction } from "./internal/features.js";
7
+
8
+ const hrMs = () => {
9
+ const [s, ns] = process.hrtime();
10
+ return s * 1e3 + ns / 1e6;
11
+ };
12
+ const origin = hrMs();
13
+ const timeOrigin = Date.now();
14
+ const now = () => hrMs() - origin;
15
+
16
+ const kConstruct = Symbol("construct");
17
+
18
+ export class PerformanceEntry {
19
+ constructor(key, name, entryType, startTime, duration, detail) {
20
+ if (key !== kConstruct) throw codeError(TypeError, "ERR_ILLEGAL_CONSTRUCTOR", "Illegal constructor");
21
+ this.name = name;
22
+ this.entryType = entryType;
23
+ this.startTime = startTime;
24
+ this.duration = duration;
25
+ this.detail = detail;
26
+ }
27
+
28
+ toJSON() {
29
+ return { name: this.name, entryType: this.entryType, startTime: this.startTime, duration: this.duration, detail: this.detail };
30
+ }
31
+ }
32
+
33
+ export class PerformanceMark extends PerformanceEntry {
34
+ constructor(name, options) {
35
+ if (name === undefined) throw codeError(TypeError, "ERR_MISSING_ARGS", 'The "name" argument must be specified');
36
+ const startTime = options?.startTime ?? now();
37
+ if (typeof startTime !== "number") throw invalidArgType("options.startTime", "of type number", startTime);
38
+ super(kConstruct, String(name), "mark", startTime, 0, options?.detail ?? null);
39
+ }
40
+ }
41
+
42
+ export class PerformanceMeasure extends PerformanceEntry {
43
+ constructor(key, name, startTime, duration, detail) {
44
+ super(key, name, "measure", startTime, duration, detail);
45
+ }
46
+ }
47
+
48
+ /* marks and measures, in the order they were made */
49
+ const entries = [];
50
+
51
+ /** A mark's time: a number as is, else the latest mark of that name. */
52
+ function markTime(mark) {
53
+ if (typeof mark === "number") return mark;
54
+ for (let i = entries.length - 1; i >= 0; i--) {
55
+ if (entries[i].entryType === "mark" && entries[i].name === mark) return entries[i].startTime;
56
+ }
57
+ throw new globalThis.DOMException('The "' + mark + '" performance mark has not been set', "SyntaxError");
58
+ }
59
+
60
+ export class Performance {
61
+ constructor(key) {
62
+ if (key !== kConstruct) throw codeError(TypeError, "ERR_ILLEGAL_CONSTRUCTOR", "Illegal constructor");
63
+ }
64
+
65
+ get timeOrigin() {
66
+ return timeOrigin;
67
+ }
68
+
69
+ now() {
70
+ return now();
71
+ }
72
+
73
+ mark(name, options) {
74
+ const mark = new PerformanceMark(name, options);
75
+ entries.push(mark);
76
+ features.perfObserve?.(mark);
77
+ return mark;
78
+ }
79
+
80
+ /** measure(name, startMark?, endMark?) or measure(name, { start, end, duration, detail }). */
81
+ measure(name, startOrOptions, endMark) {
82
+ let start = 0, end, detail = null;
83
+ if (startOrOptions !== null && typeof startOrOptions === "object") {
84
+ const { start: s, end: e, duration, detail: d } = startOrOptions;
85
+ if (s !== undefined) start = markTime(s);
86
+ end = e !== undefined ? markTime(e) : duration !== undefined ? start + duration : now();
87
+ detail = d ?? null;
88
+ } else {
89
+ if (startOrOptions !== undefined) start = markTime(startOrOptions);
90
+ end = endMark !== undefined ? markTime(endMark) : now();
91
+ }
92
+ const measure = new PerformanceMeasure(kConstruct, String(name), start, end - start, detail);
93
+ entries.push(measure);
94
+ features.perfObserve?.(measure);
95
+ return measure;
96
+ }
97
+
98
+ clearMarks(name) {
99
+ clear("mark", name);
100
+ }
101
+
102
+ clearMeasures(name) {
103
+ clear("measure", name);
104
+ }
105
+
106
+ getEntries() {
107
+ return entries.slice().sort((a, b) => a.startTime - b.startTime);
108
+ }
109
+
110
+ getEntriesByName(name, type) {
111
+ return this.getEntries().filter((e) => e.name === name && (type === undefined || e.entryType === type));
112
+ }
113
+
114
+ getEntriesByType(type) {
115
+ return this.getEntries().filter((e) => e.entryType === type);
116
+ }
117
+
118
+ toJSON() {
119
+ return { timeOrigin };
120
+ }
121
+ }
122
+
123
+ function clear(type, name) {
124
+ for (let i = entries.length - 1; i >= 0; i--) {
125
+ if (entries[i].entryType === type && (name === undefined || entries[i].name === name)) entries.splice(i, 1);
126
+ }
127
+ }
128
+
129
+ export const performance = new Performance(kConstruct);
130
+
131
+ export const constants = {
132
+ NODE_PERFORMANCE_GC_MAJOR: 4, NODE_PERFORMANCE_GC_MINOR: 1, NODE_PERFORMANCE_GC_INCREMENTAL: 8, NODE_PERFORMANCE_GC_WEAKCB: 16,
133
+ NODE_PERFORMANCE_GC_FLAGS_NO: 0, NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED: 2, NODE_PERFORMANCE_GC_FLAGS_FORCED: 4,
134
+ NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING: 8, NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE: 16,
135
+ NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY: 32, NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE: 64,
136
+ };
137
+
138
+ export const PerformanceObserver = lazyClass("PerformanceObserver");
139
+ export const PerformanceObserverEntryList = lazyClass("PerformanceObserverEntryList");
140
+ export const PerformanceResourceTiming = lazyClass("PerformanceResourceTiming");
141
+ export const createHistogram = lazyFunction("createHistogram");
142
+ export const monitorEventLoopDelay = lazyFunction("monitorEventLoopDelay");
143
+
144
+ export default {
145
+ Performance, PerformanceEntry, PerformanceMark, PerformanceMeasure, PerformanceObserver, PerformanceObserverEntryList, PerformanceResourceTiming,
146
+ performance, constants, createHistogram, monitorEventLoopDelay,
147
+ };
@@ -1,4 +1,4 @@
1
- // node:process (ADR 0012, layer 3): the process global, as a module.
1
+ // node:process: the process global, as a module.
2
2
  const p = globalThis.process;
3
3
 
4
4
  export const argv = p.argv;
@@ -9,6 +9,8 @@ export const execPath = p.execPath;
9
9
  export const pid = p.pid;
10
10
  export const platform = p.platform;
11
11
  export const stderr = p.stderr;
12
+ /* made when read, by the module the driver adds when the program names it */
13
+ export const stdin = p.stdin;
12
14
  export const stdout = p.stdout;
13
15
  export const version = p.version;
14
16
  export const versions = p.versions;
@@ -18,6 +20,39 @@ export const exit = (...args) => p.exit(...args);
18
20
  export const hrtime = p.hrtime;
19
21
  export const nextTick = (...args) => p.nextTick(...args);
20
22
  export const kill = (...args) => p.kill(...args);
23
+ /* the members of internal/process_more.js, which the driver adds when the program names them:
24
+ * called through process, so a program that imports node:process links none of them */
25
+ export const chdir = (...args) => p.chdir(...args);
26
+ export const umask = (...args) => p.umask(...args);
27
+ export const memoryUsage = (...args) => p.memoryUsage(...args);
28
+ export const uptime = (...args) => p.uptime(...args);
29
+ export const cpuUsage = (...args) => p.cpuUsage(...args);
30
+ export const threadCpuUsage = (...args) => p.threadCpuUsage(...args);
31
+ export const resourceUsage = (...args) => p.resourceUsage(...args);
32
+ export const availableMemory = (...args) => p.availableMemory(...args);
33
+ export const constrainedMemory = (...args) => p.constrainedMemory(...args);
34
+ export const setuid = (...args) => p.setuid(...args);
35
+ export const setgid = (...args) => p.setgid(...args);
36
+ export const seteuid = (...args) => p.seteuid(...args);
37
+ export const setegid = (...args) => p.setegid(...args);
38
+ export const getgroups = (...args) => p.getgroups(...args);
39
+ export const setgroups = (...args) => p.setgroups(...args);
40
+ export const initgroups = (...args) => p.initgroups(...args);
41
+ export const abort = (...args) => p.abort(...args);
42
+ export const reallyExit = (...args) => p.reallyExit(...args);
43
+ export const execve = (...args) => p.execve(...args);
44
+ export const getBuiltinModule = (...args) => p.getBuiltinModule(...args);
45
+ export const loadEnvFile = (...args) => p.loadEnvFile(...args);
46
+ export const hasUncaughtExceptionCaptureCallback = (...args) => p.hasUncaughtExceptionCaptureCallback(...args);
47
+ export const setUncaughtExceptionCaptureCallback = (...args) => p.setUncaughtExceptionCaptureCallback(...args);
48
+ export const setSourceMapsEnabled = (...args) => p.setSourceMapsEnabled(...args);
49
+ export const getActiveResourcesInfo = (...args) => p.getActiveResourcesInfo(...args);
50
+ export const openStdin = (...args) => p.openStdin(...args);
51
+ export const ref = (...args) => p.ref(...args);
52
+ export const unref = (...args) => p.unref(...args);
53
+ export const assert = (...args) => p.assert(...args);
54
+ export const binding = (...args) => p.binding(...args);
55
+ export const dlopen = (...args) => p.dlopen(...args);
21
56
  /* using it gets the driver to add process's events (node/index.ts) */
22
57
  export const emit = (...args) => p.emit(...args);
23
58