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
@@ -0,0 +1,338 @@
1
+ // node:readline's Interface, which node:readline/promises extends: an input stream read a line at
2
+ // a time, as Node's Interface reads one that isn't a terminal: 'line' for each line (ended by \n,
3
+ // \r\n or \r), a question's answer to its callback, the prompt written to the output, and the lines
4
+ // as an async iterator. A terminal is read in its normal mode, the terminal editing the line and
5
+ // echoing it; Node's own editor in raw mode (keys, history, completion) isn't provided, nor is
6
+ // emitKeypressEvents. The cursor functions write ANSI escapes.
7
+ import { EventEmitter } from "../events.js";
8
+ import { codeError, invalidArgType, invalidArgValue, notSupported, validateFunction, validateString } from "./errors.js";
9
+ import { Readable } from "../stream.js";
10
+ import { StringDecoder } from "../string_decoder.js";
11
+
12
+ /* what ends a line; a \r at a chunk's end may be a \r\n split across chunks: a \n first in the
13
+ * next chunk, within crlfDelay, belongs to it */
14
+ const lineEnding = /\r?\n|\r(?!\n)/g;
15
+ const kMinCrlfDelay = 100;
16
+ const kPromisifyCustom = Symbol.for("nodejs.util.promisify.custom");
17
+
18
+ export const kQuestion = Symbol("question");
19
+ export const kQuestionCancel = Symbol("questionCancel");
20
+
21
+ function validateSignal(signal, name) {
22
+ if (signal !== undefined && (signal === null || typeof signal !== "object" || !("aborted" in signal))) {
23
+ throw invalidArgType(name, "an instance of AbortSignal", signal);
24
+ }
25
+ }
26
+
27
+ /** Node's AbortError: name and code, the signal's reason as its cause. */
28
+ export function abortError(signal) {
29
+ const error = new Error("The operation was aborted", { cause: signal?.reason });
30
+ error.code = "ABORT_ERR";
31
+ error.name = "AbortError";
32
+ return error;
33
+ }
34
+
35
+ /** Interface(input, output, completer, terminal), or Interface({ input, output, … }). A function,
36
+ * as Node's is: callable without new. */
37
+ export function Interface(input, output, completer, terminal) {
38
+ if (!(this instanceof Interface)) return new Interface(input, output, completer, terminal);
39
+ EventEmitter.call(this);
40
+ let prompt = "> ";
41
+ let crlfDelay;
42
+ let signal;
43
+ if (input?.input) {
44
+ ({ output, completer, terminal, signal, crlfDelay } = input);
45
+ if (input.prompt !== undefined) prompt = input.prompt;
46
+ input = input.input;
47
+ }
48
+ if (completer !== undefined && typeof completer !== "function") throw invalidArgValue("completer", "must be a function", completer);
49
+ validateSignal(signal, "options.signal");
50
+ this.input = input;
51
+ this.output = output;
52
+ this.completer = completer;
53
+ this.terminal = terminal === undefined ? Boolean(output?.isTTY) : Boolean(terminal);
54
+ this.crlfDelay = crlfDelay ? Math.max(kMinCrlfDelay, crlfDelay) : kMinCrlfDelay;
55
+ this.line = "";
56
+ this.cursor = 0;
57
+ this.history = [];
58
+ this.closed = false;
59
+ this.paused = false;
60
+ this._prompt = prompt;
61
+ this._oldPrompt = prompt;
62
+ this._questionCallback = null;
63
+ this._lineBuffer = null;
64
+ this._sawReturnAt = 0;
65
+ this._decoder = new StringDecoder("utf8");
66
+ this._lines = undefined;
67
+
68
+ const ondata = (data) => this._normalWrite(data);
69
+ const onend = () => {
70
+ if (typeof this._lineBuffer === "string" && this._lineBuffer.length > 0) this.emit("line", this._lineBuffer);
71
+ this.close();
72
+ };
73
+ const onerror = (err) => this.emit("error", err);
74
+ input.on("error", onerror);
75
+ input.on("data", ondata);
76
+ input.on("end", onend);
77
+ this.once("close", () => {
78
+ input.removeListener("error", onerror);
79
+ input.removeListener("data", ondata);
80
+ input.removeListener("end", onend);
81
+ });
82
+ if (signal) {
83
+ const onAbort = () => this.close();
84
+ if (signal.aborted) process.nextTick(onAbort);
85
+ else {
86
+ signal.addEventListener("abort", onAbort, { once: true });
87
+ this.once("close", () => signal.removeEventListener("abort", onAbort));
88
+ }
89
+ }
90
+ input.resume();
91
+ }
92
+ Object.setPrototypeOf(Interface.prototype, EventEmitter.prototype);
93
+ Object.setPrototypeOf(Interface, EventEmitter);
94
+
95
+ Interface.prototype.setPrompt = function setPrompt(prompt) {
96
+ this._prompt = prompt;
97
+ };
98
+
99
+ Interface.prototype.getPrompt = function getPrompt() {
100
+ return this._prompt;
101
+ };
102
+
103
+ Interface.prototype._writeToOutput = function _writeToOutput(text) {
104
+ validateString(text, "stringToWrite");
105
+ if (this.output !== null && this.output !== undefined) this.output.write(text);
106
+ };
107
+
108
+ /** Writes the prompt, and reads again if paused. */
109
+ Interface.prototype.prompt = function prompt() {
110
+ if (this.paused) this.resume();
111
+ if (this.closed) throw codeError(Error, "ERR_USE_AFTER_CLOSE", "readline was closed");
112
+ this._writeToOutput(this._prompt);
113
+ };
114
+
115
+ Interface.prototype[kQuestion] = function question(query, cb) {
116
+ if (this.closed) throw codeError(Error, "ERR_USE_AFTER_CLOSE", "readline was closed");
117
+ if (this._questionCallback) this.prompt();
118
+ else {
119
+ this._oldPrompt = this._prompt;
120
+ this.setPrompt(query);
121
+ this._questionCallback = cb;
122
+ this.prompt();
123
+ }
124
+ };
125
+
126
+ /* a question given up: its prompt goes, and the line is cleared, as Node's clearLine */
127
+ Interface.prototype[kQuestionCancel] = function questionCancel() {
128
+ if (!this._questionCallback) return;
129
+ this._questionCallback = null;
130
+ this.setPrompt(this._oldPrompt);
131
+ this._writeToOutput("\r\n");
132
+ this.line = "";
133
+ this.cursor = 0;
134
+ };
135
+
136
+ /** question(query[, { signal }], cb): writes the query, and gives the next line to cb instead of
137
+ * 'line'. */
138
+ Interface.prototype.question = function question(query, options, cb) {
139
+ cb = typeof options === "function" ? options : cb;
140
+ if (options !== null && typeof options === "object") {
141
+ const { signal } = options;
142
+ if (signal) {
143
+ validateSignal(signal, "options.signal");
144
+ if (signal.aborted) return;
145
+ const onAbort = () => this[kQuestionCancel]();
146
+ signal.addEventListener("abort", onAbort, { once: true });
147
+ const cleanup = () => signal.removeEventListener("abort", onAbort);
148
+ const original = cb;
149
+ cb = typeof cb === "function" ? (answer) => {
150
+ cleanup();
151
+ return original(answer);
152
+ } : cleanup;
153
+ }
154
+ }
155
+ if (typeof cb === "function") this[kQuestion](query, cb);
156
+ };
157
+
158
+ /* util.promisify(rl.question): the answer, or an AbortError */
159
+ Interface.prototype.question[kPromisifyCustom] = function question(query, options) {
160
+ if (options === null || typeof options !== "object") options = {};
161
+ return new Promise((resolve, reject) => {
162
+ let cb = resolve;
163
+ const { signal } = options;
164
+ if (signal) {
165
+ validateSignal(signal, "options.signal");
166
+ if (signal.aborted) return reject(abortError(signal));
167
+ const onAbort = () => reject(abortError(signal));
168
+ signal.addEventListener("abort", onAbort, { once: true });
169
+ cb = (answer) => {
170
+ signal.removeEventListener("abort", onAbort);
171
+ resolve(answer);
172
+ };
173
+ }
174
+ this.question(query, options, cb);
175
+ });
176
+ };
177
+
178
+ Interface.prototype.pause = function pause() {
179
+ if (this.paused) return;
180
+ this.input.pause();
181
+ this.paused = true;
182
+ this.emit("pause");
183
+ return this;
184
+ };
185
+
186
+ Interface.prototype.resume = function resume() {
187
+ if (!this.paused) return;
188
+ this.input.resume();
189
+ this.paused = false;
190
+ this.emit("resume");
191
+ return this;
192
+ };
193
+
194
+ /** Ends reading: the input is paused and 'close' emitted, once. */
195
+ Interface.prototype.close = function close() {
196
+ if (this.closed) return;
197
+ this.pause();
198
+ this.closed = true;
199
+ this.emit("close");
200
+ };
201
+
202
+ /** Data as if it had come from the input. */
203
+ Interface.prototype.write = function write(data) {
204
+ if (this.closed) throw codeError(Error, "ERR_USE_AFTER_CLOSE", "readline was closed");
205
+ if (this.paused) this.resume();
206
+ this._normalWrite(data);
207
+ };
208
+
209
+ Interface.prototype._onLine = function _onLine(line) {
210
+ if (this._questionCallback) {
211
+ const cb = this._questionCallback;
212
+ this._questionCallback = null;
213
+ this.setPrompt(this._oldPrompt);
214
+ cb(line);
215
+ } else this.emit("line", line);
216
+ };
217
+
218
+ /* Node's _normalWrite: the chunk decoded, split into lines; what follows the last ending waits */
219
+ Interface.prototype._normalWrite = function _normalWrite(chunk) {
220
+ if (chunk === undefined) return;
221
+ let string = this._decoder.write(chunk);
222
+ if (this._sawReturnAt && Date.now() - this._sawReturnAt <= this.crlfDelay) {
223
+ if (string.codePointAt(0) === 10) string = string.slice(1);
224
+ this._sawReturnAt = 0;
225
+ }
226
+ lineEnding.lastIndex = 0;
227
+ let match = lineEnding.exec(string);
228
+ if (match === null) {
229
+ if (string) this._lineBuffer = this._lineBuffer ? this._lineBuffer + string : string;
230
+ return;
231
+ }
232
+ if (this._lineBuffer) {
233
+ string = this._lineBuffer + string;
234
+ this._lineBuffer = null;
235
+ lineEnding.lastIndex = 0;
236
+ match = lineEnding.exec(string);
237
+ }
238
+ this._sawReturnAt = string.endsWith("\r") ? Date.now() : 0;
239
+ const indexes = [0, match.index, lineEnding.lastIndex];
240
+ while ((match = lineEnding.exec(string)) !== null) indexes.push(match.index, lineEnding.lastIndex);
241
+ const last = indexes.length - 1;
242
+ this._lineBuffer = string.slice(indexes[last]);
243
+ for (let i = 1; i < last; i += 2) {
244
+ this._onLine(string.slice(indexes[i - 1], indexes[i]));
245
+ if (this.closed) break;
246
+ }
247
+ };
248
+
249
+ /** The lines, as an async iterator; reading pauses while the iterator's buffer is full. */
250
+ Interface.prototype[Symbol.asyncIterator] = function asyncIterator() {
251
+ if (this._lines === undefined) {
252
+ const onLine = (line) => {
253
+ if (!readable.push(line)) this.pause();
254
+ };
255
+ const onClose = () => readable.push(null);
256
+ const onError = (err) => readable.destroy(err);
257
+ const readable = new Readable({
258
+ objectMode: true,
259
+ read: () => this.resume(),
260
+ destroy: (err, cb) => {
261
+ this.off("line", onLine);
262
+ this.off("close", onClose);
263
+ this.off("error", onError);
264
+ this.close();
265
+ cb(err);
266
+ },
267
+ });
268
+ this.on("error", onError);
269
+ this.on("line", onLine);
270
+ this.on("close", onClose);
271
+ this._lines = readable;
272
+ }
273
+ return this._lines[Symbol.asyncIterator]();
274
+ };
275
+
276
+ export function createInterface(input, output, completer, terminal) {
277
+ return new Interface(input, output, completer, terminal);
278
+ }
279
+
280
+ /* ---- the cursor: ANSI escapes ------------------------------------------------------------ */
281
+
282
+ const CSI = "\x1b[";
283
+
284
+ /* a write, or with no stream the callback on a later tick */
285
+ function writeTo(stream, data, callback) {
286
+ if (callback !== undefined) validateFunction(callback, "callback");
287
+ if (stream === null || stream === undefined || data === "") {
288
+ if (typeof callback === "function") process.nextTick(callback, null);
289
+ return true;
290
+ }
291
+ return stream.write(data, callback);
292
+ }
293
+
294
+ /** The escape that clears the line: to its start (dir < 0), its end (dir > 0) or all of it. */
295
+ export function clearLineEscape(dir) {
296
+ return dir < 0 ? CSI + "1K" : dir > 0 ? CSI + "0K" : CSI + "2K";
297
+ }
298
+
299
+ export function cursorToEscape(x, y) {
300
+ if (Number.isNaN(x)) throw codeError(TypeError, "ERR_INVALID_ARG_VALUE", "The argument 'x' is invalid. Received NaN");
301
+ if (Number.isNaN(y)) throw codeError(TypeError, "ERR_INVALID_ARG_VALUE", "The argument 'y' is invalid. Received NaN");
302
+ if (typeof x !== "number") throw codeError(TypeError, "ERR_INVALID_CURSOR_POS", "Cannot set cursor row without setting its column");
303
+ return typeof y !== "number" ? CSI + (x + 1) + "G" : CSI + (y + 1) + ";" + (x + 1) + "H";
304
+ }
305
+
306
+ export function moveCursorEscape(dx, dy) {
307
+ let data = "";
308
+ if (dx < 0) data += CSI + -dx + "D";
309
+ else if (dx > 0) data += CSI + dx + "C";
310
+ if (dy < 0) data += CSI + -dy + "A";
311
+ else if (dy > 0) data += CSI + dy + "B";
312
+ return data;
313
+ }
314
+
315
+ export function clearLine(stream, dir, callback) {
316
+ return writeTo(stream, clearLineEscape(dir), callback);
317
+ }
318
+
319
+ export function clearScreenDown(stream, callback) {
320
+ return writeTo(stream, CSI + "0J", callback);
321
+ }
322
+
323
+ export function cursorTo(stream, x, y, callback) {
324
+ if (typeof y === "function") {
325
+ callback = y;
326
+ y = undefined;
327
+ }
328
+ if (stream === null || stream === undefined || (typeof x !== "number" && typeof y !== "number")) return writeTo(null, "", callback);
329
+ return writeTo(stream, cursorToEscape(x, y), callback);
330
+ }
331
+
332
+ export function moveCursor(stream, dx, dy, callback) {
333
+ return writeTo(stream, moveCursorEscape(dx, dy), callback);
334
+ }
335
+
336
+ export function emitKeypressEvents() {
337
+ throw notSupported("readline.emitKeypressEvents");
338
+ }
@@ -1,6 +1,7 @@
1
1
  // net.SocketAddress and net.BlockList (Node's lib/internal/socketaddress.js and blocklist.js,
2
2
  // whose C++ side is here in JS): an address is its bytes, 4 or 16; an IPv4 address checked
3
3
  // against an IPv6 rule, or the reverse, compares as an IPv4-mapped IPv6 address (::ffff:a.b.c.d).
4
+ // Ported from Node.js (Copyright Node.js contributors, MIT): node/third_party/nodejs/LICENSE.
4
5
  import { codeError, invalidArgType, invalidArgValue, outOfRange, validateString } from "./errors.js";
5
6
  import { isIPv4, isIPv6 } from "./net.js";
6
7
 
@@ -184,7 +185,7 @@ const kRules = Symbol("kRules");
184
185
 
185
186
  export class BlockList {
186
187
  constructor() {
187
- this[kRules] = []; /* newest first, as Node lists them */
188
+ this[kRules] = []; /* newest first, as Node lists them: addresses, then subnets, then ranges */
188
189
  }
189
190
 
190
191
  static isBlockList(value) {
@@ -200,7 +201,9 @@ export class BlockList {
200
201
  addAddress(address, family = "ipv4") {
201
202
  const sa = toSocketAddress(address, "address", family);
202
203
  const bytes = sa[kDetail].bytes;
203
- this[kRules].unshift({ text: "Address: " + familyName(sa) + " " + sa.address, test: (b) => compare(b, bytes) === 0 });
204
+ const text = "Address: " + familyName(sa) + " " + sa.address;
205
+ if (this[kRules].some((rule) => rule.text === text)) return; /* once each, as Node 24 keeps them */
206
+ this[kRules].unshift({ kind: 0, text, test: (b) => compare(b, bytes) === 0 });
204
207
  }
205
208
 
206
209
  addRange(start, end, family = "ipv4") {
@@ -209,6 +212,7 @@ export class BlockList {
209
212
  const a = from[kDetail].bytes, b = to[kDetail].bytes;
210
213
  if (compare(a, b) > 0) throw invalidArgValue("start", "must come before end", from);
211
214
  this[kRules].unshift({
215
+ kind: 2,
212
216
  text: "Range: " + familyName(from) + " " + from.address + "-" + to.address,
213
217
  test: (x) => compare(x, a) >= 0 && compare(x, b) <= 0,
214
218
  });
@@ -220,7 +224,7 @@ export class BlockList {
220
224
  if (typeof prefix !== "number") throw invalidArgType("prefix", "of type number", prefix);
221
225
  if (!Number.isInteger(prefix) || prefix < 0 || prefix > max) throw outOfRange("prefix", ">= 0 && <= " + max, prefix);
222
226
  const bytes = sa[kDetail].bytes;
223
- this[kRules].unshift({ text: "Subnet: " + familyName(sa) + " " + sa.address + "/" + prefix, test: (x) => inNetwork(x, bytes, prefix) });
227
+ this[kRules].unshift({ kind: 1, text: "Subnet: " + familyName(sa) + " " + sa.address + "/" + prefix, test: (x) => inNetwork(x, bytes, prefix) });
224
228
  }
225
229
 
226
230
  check(address, family = "ipv4") {
@@ -240,7 +244,7 @@ export class BlockList {
240
244
  }
241
245
 
242
246
  get rules() {
243
- return this[kRules].map((rule) => rule.text);
247
+ return this[kRules].toSorted((a, b) => a.kind - b.kind).map((rule) => rule.text);
244
248
  }
245
249
 
246
250
  toJSON() {
@@ -0,0 +1,122 @@
1
+ // module.SourceMap: a source map (version 3) read as Node's lib/internal/source_map/source_map.js
2
+ // reads it: its mappings decoded (base64 VLQ), findEntry by generated position (0-based) and
3
+ // findOrigin (1-based). Linked into programs that name SourceMap; module.js finds it by its symbol.
4
+ // Ported from Node.js (Copyright Node.js contributors, MIT): node/third_party/nodejs/LICENSE.
5
+ const kSourceMap = Symbol.for("visaljs.SourceMap");
6
+
7
+ const base64 = new Map([..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"].map((c, i) => [c, i]));
8
+
9
+ class SourceMap {
10
+ #payload;
11
+ #lineLengths;
12
+ #mappings = []; /* [generatedLine, generatedColumn, source, originalLine, originalColumn, name?], sorted */
13
+
14
+ constructor(payload, { lineLengths } = {}) {
15
+ if (payload === null || typeof payload !== "object") {
16
+ const received = payload === null || payload === undefined ? `${payload}` : `type ${typeof payload} (${typeof payload === "string" ? `'${payload}'` : payload})`;
17
+ const e = new TypeError(`The "payload" argument must be of type object. Received ${received}`);
18
+ e.code = "ERR_INVALID_ARG_TYPE";
19
+ throw e;
20
+ }
21
+ this.#payload = JSON.parse(JSON.stringify(payload));
22
+ this.#lineLengths = lineLengths;
23
+ if (payload.sections) {
24
+ for (const section of payload.sections) {
25
+ const inner = new SourceMap(section.map);
26
+ for (const m of inner.#mappings) {
27
+ this.#mappings.push([m[0] + section.offset.line, m[0] === 0 ? m[1] + section.offset.column : m[1], ...m.slice(2)]);
28
+ }
29
+ }
30
+ } else {
31
+ this.#parse(payload);
32
+ }
33
+ this.#mappings.sort((a, b) => a[0] - b[0] || a[1] - b[1]);
34
+ }
35
+
36
+ get payload() {
37
+ return this.#payload;
38
+ }
39
+
40
+ get lineLengths() {
41
+ return this.#lineLengths;
42
+ }
43
+
44
+ #parse(map) {
45
+ const sources = (map.sources ?? []).map((s) => (map.sourceRoot ? `${map.sourceRoot.replace(/\/?$/, "/")}${s}` : s));
46
+ const names = map.names ?? [];
47
+ const text = map.mappings ?? "";
48
+ let line = 0, column = 0, source = 0, originalLine = 0, originalColumn = 0, name = 0;
49
+ let nameValue; /* a segment without a name keeps the last one's, as Node's parser does */
50
+ let i = 0;
51
+ const vlq = () => {
52
+ let result = 0, shift = 0, digit;
53
+ do {
54
+ digit = base64.get(text[i++]);
55
+ if (digit === undefined) throw new Error("Invalid source map: bad VLQ");
56
+ result += (digit & 31) * 2 ** shift;
57
+ shift += 5;
58
+ } while (digit & 32);
59
+ return result & 1 ? -(result - 1) / 2 : result / 2;
60
+ };
61
+ while (i < text.length) {
62
+ const c = text[i];
63
+ if (c === ";") {
64
+ line++;
65
+ column = 0;
66
+ i++;
67
+ continue;
68
+ }
69
+ if (c === ",") {
70
+ i++;
71
+ continue;
72
+ }
73
+ column += vlq();
74
+ if (i >= text.length || text[i] === "," || text[i] === ";") {
75
+ this.#mappings.push([line, column]);
76
+ continue;
77
+ }
78
+ source += vlq();
79
+ originalLine += vlq();
80
+ originalColumn += vlq();
81
+ if (i < text.length && text[i] !== "," && text[i] !== ";") {
82
+ name += vlq();
83
+ nameValue = names[name];
84
+ }
85
+ this.#mappings.push([line, column, sources[source], originalLine, originalColumn, nameValue]);
86
+ }
87
+ }
88
+
89
+ /* the last mapping at or before the position, on that line or an earlier one, as Node's */
90
+ #find(line, column) {
91
+ let lo = 0, hi = this.#mappings.length - 1, found = -1;
92
+ while (lo <= hi) {
93
+ const mid = (lo + hi) >> 1;
94
+ const m = this.#mappings[mid];
95
+ if (m[0] < line || (m[0] === line && m[1] <= column)) {
96
+ found = mid;
97
+ lo = mid + 1;
98
+ } else hi = mid - 1;
99
+ }
100
+ if (found === -1) return undefined;
101
+ const m = this.#mappings[found];
102
+ return m.length > 2 ? m : undefined;
103
+ }
104
+
105
+ /** findEntry(lineOffset, columnOffset): the mapping there (0-based), or {}. */
106
+ findEntry(lineOffset, columnOffset) {
107
+ const m = this.#find(lineOffset, columnOffset);
108
+ if (!m) return {};
109
+ const entry = { generatedLine: m[0], generatedColumn: m[1], originalSource: m[2], originalLine: m[3], originalColumn: m[4] };
110
+ if (m[5] !== undefined) entry.name = m[5];
111
+ return entry;
112
+ }
113
+
114
+ /** findOrigin(lineNumber, columnNumber): where a generated position (1-based) came from, or {}. */
115
+ findOrigin(lineNumber, columnNumber) {
116
+ const m = this.#find(lineNumber - 1, columnNumber - 1);
117
+ if (!m) return {};
118
+ return { name: m[5], fileName: m[2], lineNumber: m[3] + 1 + (lineNumber - 1 - m[0]), columnNumber: m[4] + 1 + (columnNumber - 1 - m[1]) };
119
+ }
120
+ }
121
+
122
+ globalThis[kSourceMap] = SourceMap;
@@ -0,0 +1,74 @@
1
+ // stream.compose, Duplex.from, readable.compose and stream.duplexPair: Node's
2
+ // internal/streams/compose.js, duplexify.js and duplexpair.js, linked into programs that name
3
+ // them (implicitModules in node/index.ts, internal/features.js).
4
+ // Ported from Node.js (Copyright Node.js contributors, MIT): node/third_party/nodejs/LICENSE.
5
+ import { Duplex } from "../stream.js";
6
+ import { features } from "./features.js";
7
+ import compose from "./streams/compose.js";
8
+ import duplexify from "./streams/duplexify.js";
9
+ /* Duplex.from of web streams converts them */
10
+ import "./stream_web_adapters.js";
11
+
12
+ const kCallback = Symbol("Callback");
13
+ const kInitOtherSide = Symbol("InitOtherSide");
14
+
15
+ /* one end of a duplexPair: what's written to it comes out of the other end */
16
+ class DuplexSide extends Duplex {
17
+ #otherSide = null;
18
+
19
+ constructor(options) {
20
+ super(options);
21
+ this[kCallback] = null;
22
+ this.#otherSide = null;
23
+ }
24
+
25
+ [kInitOtherSide](otherSide) {
26
+ if (this.#otherSide === null) this.#otherSide = otherSide;
27
+ }
28
+
29
+ _read() {
30
+ const callback = this[kCallback];
31
+ if (callback) {
32
+ this[kCallback] = null;
33
+ callback();
34
+ }
35
+ }
36
+
37
+ _write(chunk, encoding, callback) {
38
+ if (chunk.length === 0) {
39
+ process.nextTick(callback);
40
+ } else {
41
+ this.#otherSide.push(chunk);
42
+ this.#otherSide[kCallback] = callback;
43
+ }
44
+ }
45
+
46
+ _final(callback) {
47
+ this.#otherSide.on("end", callback);
48
+ this.#otherSide.push(null);
49
+ }
50
+
51
+ _destroy(err, callback) {
52
+ const otherSide = this.#otherSide;
53
+ if (otherSide !== null && !otherSide.destroyed) {
54
+ process.nextTick(() => {
55
+ if (otherSide.destroyed) return;
56
+ if (err) otherSide.destroy();
57
+ else otherSide.push(null);
58
+ });
59
+ }
60
+ callback(err);
61
+ }
62
+ }
63
+
64
+ function duplexPair(options) {
65
+ const side0 = new DuplexSide(options);
66
+ const side1 = new DuplexSide(options);
67
+ side0[kInitOtherSide](side1);
68
+ side1[kInitOtherSide](side0);
69
+ return [side0, side1];
70
+ }
71
+
72
+ features.compose = compose;
73
+ features.duplexify = duplexify;
74
+ features.duplexPair = duplexPair;
@@ -0,0 +1,6 @@
1
+ // Readable.from, as Node's internal/streams/from.js: linked into programs that name it
2
+ // (implicitModules in node/index.ts, internal/features.js).
3
+ import { features } from "./features.js";
4
+ import from from "./streams/from.js";
5
+
6
+ features.readableFrom = from;
@@ -0,0 +1,23 @@
1
+ // The Readable operators (map, filter, flatMap, drop, take, every, forEach, reduce, toArray,
2
+ // some, find): Node's internal/streams/operators.js, installed on Readable.prototype as
3
+ // lib/stream.js does. Linked into programs that name one (implicitModules in node/index.ts).
4
+ // Ported from Node.js (Copyright Node.js contributors, MIT): node/third_party/nodejs/LICENSE.
5
+ import { Readable } from "../stream.js";
6
+ import { codes } from "./streams/errors.js";
7
+ import "./stream_from.js";
8
+ import { promiseReturningOperators, streamReturningOperators } from "./streams/operators.js";
9
+
10
+ function install(operators, wrap) {
11
+ for (const key of Object.keys(operators)) {
12
+ const op = operators[key];
13
+ function fn(...args) {
14
+ if (new.target) throw new codes.ERR_ILLEGAL_CONSTRUCTOR();
15
+ return wrap(Reflect.apply(op, this, args));
16
+ }
17
+ Object.defineProperty(fn, "name", { __proto__: null, value: op.name });
18
+ Object.defineProperty(fn, "length", { __proto__: null, value: op.length });
19
+ Object.defineProperty(Readable.prototype, key, { __proto__: null, value: fn, enumerable: false, configurable: true, writable: true });
20
+ }
21
+ }
22
+ install(streamReturningOperators, (result) => Readable.from(result));
23
+ install(promiseReturningOperators, (result) => result);
@@ -0,0 +1,7 @@
1
+ // stream.pipeline and stream/promises' pipeline, as Node's internal/streams/pipeline.js: linked
2
+ // into programs that name pipeline (implicitModules in node/index.ts, internal/features.js).
3
+ import { features } from "./features.js";
4
+ import { pipeline, pipelineImpl } from "./streams/pipeline.js";
5
+
6
+ features.pipeline = pipeline;
7
+ features.pipelineImpl = pipelineImpl;
@@ -0,0 +1,10 @@
1
+ // stream.Transform and stream.PassThrough, as Node's internal/streams/transform.js and
2
+ // passthrough.js: linked into programs that name them (implicitModules in node/index.ts,
3
+ // internal/features.js). node:zlib and node:crypto import the class directly.
4
+ import { PassThrough as PassThroughWrapper, Transform as TransformWrapper } from "../stream.js";
5
+ import { provideClass } from "./features.js";
6
+ import PassThrough from "./streams/passthrough.js";
7
+ import Transform from "./streams/transform.js";
8
+
9
+ provideClass(TransformWrapper, Transform);
10
+ provideClass(PassThroughWrapper, PassThrough);