visaljs 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (428) hide show
  1. package/README.md +63 -2
  2. package/THIRD_PARTY_LICENSES +1216 -0
  3. package/cli.js +4414 -325
  4. package/node/include/js_node.h +57 -1
  5. package/node/include/js_uv.h +8 -1
  6. package/node/prelude/_stream_duplex.js +4 -0
  7. package/node/prelude/_stream_passthrough.js +4 -0
  8. package/node/prelude/_stream_readable.js +4 -0
  9. package/node/prelude/_stream_transform.js +4 -0
  10. package/node/prelude/_stream_writable.js +4 -0
  11. package/node/prelude/assert.js +1334 -0
  12. package/node/prelude/assert_strict.js +12 -0
  13. package/node/prelude/async_hooks.js +1 -1
  14. package/node/prelude/buffer.js +43 -3
  15. package/node/prelude/child_process.js +1098 -0
  16. package/node/prelude/cluster.js +52 -0
  17. package/node/prelude/console.js +328 -0
  18. package/node/prelude/constants.js +10 -0
  19. package/node/prelude/crypto.js +1 -1
  20. package/node/prelude/diagnostics_channel.js +1 -1
  21. package/node/prelude/dns.js +1 -1
  22. package/node/prelude/domain.js +115 -0
  23. package/node/prelude/events.js +144 -16
  24. package/node/prelude/fs.js +1138 -151
  25. package/node/prelude/fs_promises.js +117 -11
  26. package/node/prelude/http.js +104 -27
  27. package/node/prelude/http2.js +1 -1
  28. package/node/prelude/https.js +148 -0
  29. package/node/prelude/inspector.js +27 -0
  30. package/node/prelude/inspector_promises.js +4 -0
  31. package/node/prelude/internal/async_context.js +1 -1
  32. package/node/prelude/internal/buffer_transcode.js +44 -0
  33. package/node/prelude/internal/comparisons.js +916 -0
  34. package/node/prelude/internal/compression_streams.js +153 -0
  35. package/node/prelude/internal/crypto/asym.js +27 -14
  36. package/node/prelude/internal/crypto/cipher.js +16 -5
  37. package/node/prelude/internal/crypto/diffiehellman.js +3 -2
  38. package/node/prelude/internal/crypto/hash.js +2 -1
  39. package/node/prelude/internal/crypto/kdf.js +14 -9
  40. package/node/prelude/internal/crypto/keys.js +63 -50
  41. package/node/prelude/internal/crypto/random.js +2 -1
  42. package/node/prelude/internal/crypto/util.js +4 -4
  43. package/node/prelude/internal/dotenv.js +98 -0
  44. package/node/prelude/internal/errors.js +21 -5
  45. package/node/prelude/internal/events_extras.js +116 -0
  46. package/node/prelude/internal/events_on.js +100 -0
  47. package/node/prelude/internal/features.js +55 -0
  48. package/node/prelude/internal/fetch.js +364 -0
  49. package/node/prelude/internal/form_data.js +376 -0
  50. package/node/prelude/internal/fs_bigint_stats.js +41 -0
  51. package/node/prelude/internal/fs_blob.js +19 -0
  52. package/node/prelude/internal/fs_cp.js +709 -0
  53. package/node/prelude/internal/fs_dir.js +166 -0
  54. package/node/prelude/internal/fs_filehandle.js +287 -0
  55. package/node/prelude/internal/fs_glob.js +296 -0
  56. package/node/prelude/internal/fs_statfs.js +42 -0
  57. package/node/prelude/internal/fs_stats.js +89 -0
  58. package/node/prelude/internal/fs_streams.js +541 -0
  59. package/node/prelude/internal/fs_utils.js +286 -0
  60. package/node/prelude/internal/fs_watch.js +580 -0
  61. package/node/prelude/internal/http_agent.js +26 -0
  62. package/node/prelude/internal/mime.js +249 -0
  63. package/node/prelude/internal/net.js +1 -0
  64. package/node/prelude/internal/parse_args.js +288 -0
  65. package/node/prelude/internal/perf_histogram.js +435 -0
  66. package/node/prelude/internal/perf_observe.js +119 -0
  67. package/node/prelude/internal/performance_global.js +19 -0
  68. package/node/prelude/internal/process_events.js +49 -1
  69. package/node/prelude/internal/process_memory.js +14 -0
  70. package/node/prelude/internal/process_more.js +414 -0
  71. package/node/prelude/internal/process_signals.js +2 -1
  72. package/node/prelude/internal/process_stdin.js +52 -0
  73. package/node/prelude/internal/process_stdio.js +36 -0
  74. package/node/prelude/internal/querystring.js +0 -0
  75. package/node/prelude/internal/readline.js +338 -0
  76. package/node/prelude/internal/socketaddress.js +8 -4
  77. package/node/prelude/internal/source_map.js +122 -0
  78. package/node/prelude/internal/stream_compose.js +74 -0
  79. package/node/prelude/internal/stream_from.js +6 -0
  80. package/node/prelude/internal/stream_operators.js +23 -0
  81. package/node/prelude/internal/stream_pipeline.js +7 -0
  82. package/node/prelude/internal/stream_transform.js +10 -0
  83. package/node/prelude/internal/stream_web_adapters.js +143 -0
  84. package/node/prelude/internal/streams/add_abort_signal.js +58 -0
  85. package/node/prelude/internal/streams/compose.js +244 -0
  86. package/node/prelude/internal/streams/destroy.js +358 -0
  87. package/node/prelude/internal/streams/duplex.js +199 -0
  88. package/node/prelude/internal/streams/duplexify.js +378 -0
  89. package/node/prelude/internal/streams/end_of_stream.js +387 -0
  90. package/node/prelude/internal/streams/errors.js +216 -0
  91. package/node/prelude/internal/streams/from.js +211 -0
  92. package/node/prelude/internal/streams/legacy.js +120 -0
  93. package/node/prelude/internal/streams/operators.js +375 -0
  94. package/node/prelude/internal/streams/passthrough.js +45 -0
  95. package/node/prelude/internal/streams/pipeline.js +468 -0
  96. package/node/prelude/internal/streams/readable.js +1835 -0
  97. package/node/prelude/internal/streams/state.js +48 -0
  98. package/node/prelude/internal/streams/transform.js +203 -0
  99. package/node/prelude/internal/streams/utils.js +355 -0
  100. package/node/prelude/internal/streams/validators.js +108 -0
  101. package/node/prelude/internal/streams/writable.js +1160 -0
  102. package/node/prelude/internal/structured_clone.js +238 -0
  103. package/node/prelude/internal/system_errors.js +37 -0
  104. package/node/prelude/internal/test_runner/mock.js +431 -0
  105. package/node/prelude/internal/test_runner/reporters.js +404 -0
  106. package/node/prelude/internal/test_runner/test.js +1571 -0
  107. package/node/prelude/internal/timers.js +38 -7
  108. package/node/prelude/internal/timers_global.js +1 -1
  109. package/node/prelude/internal/tls/common.js +8 -2
  110. package/node/prelude/internal/tls/wrap.js +3 -15
  111. package/node/prelude/internal/tls/x509.js +1 -1
  112. package/node/prelude/internal/tty_read_stream.js +39 -0
  113. package/node/prelude/internal/tty_streams.js +3 -0
  114. package/node/prelude/internal/util_debuglog.js +68 -0
  115. package/node/prelude/internal/util_diff.js +63 -0
  116. package/node/prelude/internal/util_more.js +111 -0
  117. package/node/prelude/internal/util_styles.js +76 -0
  118. package/node/prelude/internal/zlib_engines.js +1 -1
  119. package/node/prelude/module.js +194 -7
  120. package/node/prelude/net.js +2 -1
  121. package/node/prelude/os.js +88 -11
  122. package/node/prelude/path.js +11 -7
  123. package/node/prelude/path_posix.js +1 -1
  124. package/node/prelude/path_win32.js +1 -1
  125. package/node/prelude/perf_hooks.js +147 -0
  126. package/node/prelude/process.js +36 -1
  127. package/node/prelude/punycode.js +188 -0
  128. package/node/prelude/querystring.js +1 -1
  129. package/node/prelude/readline.js +8 -0
  130. package/node/prelude/readline_promises.js +88 -0
  131. package/node/prelude/repl.js +38 -0
  132. package/node/prelude/sea.js +23 -0
  133. package/node/prelude/stream.js +70 -1332
  134. package/node/prelude/stream_consumers.js +34 -0
  135. package/node/prelude/stream_promises.js +1 -1
  136. package/node/prelude/stream_web.js +15 -2
  137. package/node/prelude/string_decoder.js +1 -1
  138. package/node/prelude/sys.js +7 -0
  139. package/node/prelude/test.js +56 -0
  140. package/node/prelude/test_reporters.js +269 -0
  141. package/node/prelude/timers.js +7 -84
  142. package/node/prelude/timers_promises.js +1 -1
  143. package/node/prelude/tls.js +2 -1
  144. package/node/prelude/trace_events.js +52 -0
  145. package/node/prelude/tty.js +10 -4
  146. package/node/prelude/url.js +88 -27
  147. package/node/prelude/util.js +121 -5
  148. package/node/prelude/util_types.js +4 -3
  149. package/node/prelude/v8.js +814 -0
  150. package/node/prelude/vm.js +86 -0
  151. package/node/prelude/wasi.js +10 -0
  152. package/node/prelude/worker_threads.js +56 -0
  153. package/node/prelude/zlib.js +58 -25
  154. package/node/src/host_brotli.c +59 -11
  155. package/node/src/host_fs.c +342 -11
  156. package/node/src/host_fswatch.c +170 -0
  157. package/node/src/host_http.c +143 -20
  158. package/node/src/host_loop.c +25 -2
  159. package/node/src/host_net.c +55 -7
  160. package/node/src/host_os.c +55 -1
  161. package/node/src/host_proc.c +291 -0
  162. package/node/src/host_process.c +488 -0
  163. package/node/src/host_sys.c +64 -2
  164. package/node/src/host_zlib.c +27 -7
  165. package/node/src/host_zstd.c +41 -6
  166. package/node/third_party/hdrhistogram/LICENSE +42 -0
  167. package/node/third_party/hdrhistogram/README.md +5 -0
  168. package/node/third_party/libuv/LICENSE +0 -0
  169. package/node/third_party/libuv/LICENSE-extra +36 -0
  170. package/node/third_party/libuv/include/uv/aix.h +0 -0
  171. package/node/third_party/libuv/include/uv/bsd.h +0 -0
  172. package/node/third_party/libuv/include/uv/darwin.h +0 -0
  173. package/node/third_party/libuv/include/uv/errno.h +0 -0
  174. package/node/third_party/libuv/include/uv/linux.h +0 -0
  175. package/node/third_party/libuv/include/uv/os390.h +0 -0
  176. package/node/third_party/libuv/include/uv/posix.h +0 -0
  177. package/node/third_party/libuv/include/uv/sunos.h +0 -0
  178. package/node/third_party/libuv/include/uv/threadpool.h +0 -0
  179. package/node/third_party/libuv/include/uv/tree.h +0 -0
  180. package/node/third_party/libuv/include/uv/unix.h +0 -0
  181. package/node/third_party/libuv/include/uv/version.h +0 -0
  182. package/node/third_party/libuv/include/uv/win.h +0 -0
  183. package/node/third_party/libuv/include/uv.h +0 -0
  184. package/node/third_party/libuv/src/fs-poll.c +0 -0
  185. package/node/third_party/libuv/src/heap-inl.h +0 -0
  186. package/node/third_party/libuv/src/idna.c +0 -0
  187. package/node/third_party/libuv/src/idna.h +0 -0
  188. package/node/third_party/libuv/src/inet.c +0 -0
  189. package/node/third_party/libuv/src/queue.h +0 -0
  190. package/node/third_party/libuv/src/random.c +0 -0
  191. package/node/third_party/libuv/src/strscpy.c +0 -0
  192. package/node/third_party/libuv/src/strscpy.h +0 -0
  193. package/node/third_party/libuv/src/strtok.c +0 -0
  194. package/node/third_party/libuv/src/strtok.h +0 -0
  195. package/node/third_party/libuv/src/thread-common.c +0 -0
  196. package/node/third_party/libuv/src/threadpool.c +0 -0
  197. package/node/third_party/libuv/src/timer.c +0 -0
  198. package/node/third_party/libuv/src/unix/async.c +0 -0
  199. package/node/third_party/libuv/src/unix/bsd-ifaddrs.c +0 -0
  200. package/node/third_party/libuv/src/unix/core.c +0 -0
  201. package/node/third_party/libuv/src/unix/darwin-proctitle.c +0 -0
  202. package/node/third_party/libuv/src/unix/darwin-stub.h +0 -0
  203. package/node/third_party/libuv/src/unix/darwin-syscalls.h +0 -0
  204. package/node/third_party/libuv/src/unix/darwin.c +0 -0
  205. package/node/third_party/libuv/src/unix/dl.c +0 -0
  206. package/node/third_party/libuv/src/unix/fs.c +0 -0
  207. package/node/third_party/libuv/src/unix/fsevents.c +0 -0
  208. package/node/third_party/libuv/src/unix/getaddrinfo.c +0 -0
  209. package/node/third_party/libuv/src/unix/getnameinfo.c +0 -0
  210. package/node/third_party/libuv/src/unix/internal.h +0 -0
  211. package/node/third_party/libuv/src/unix/kqueue.c +0 -0
  212. package/node/third_party/libuv/src/unix/linux.c +0 -0
  213. package/node/third_party/libuv/src/unix/loop-watcher.c +0 -0
  214. package/node/third_party/libuv/src/unix/loop.c +0 -0
  215. package/node/third_party/libuv/src/unix/pipe.c +0 -0
  216. package/node/third_party/libuv/src/unix/poll.c +0 -0
  217. package/node/third_party/libuv/src/unix/process.c +0 -0
  218. package/node/third_party/libuv/src/unix/procfs-exepath.c +0 -0
  219. package/node/third_party/libuv/src/unix/proctitle.c +0 -0
  220. package/node/third_party/libuv/src/unix/random-devurandom.c +0 -0
  221. package/node/third_party/libuv/src/unix/random-getentropy.c +0 -0
  222. package/node/third_party/libuv/src/unix/random-getrandom.c +0 -0
  223. package/node/third_party/libuv/src/unix/random-sysctl-linux.c +0 -0
  224. package/node/third_party/libuv/src/unix/signal.c +0 -0
  225. package/node/third_party/libuv/src/unix/stream.c +0 -0
  226. package/node/third_party/libuv/src/unix/tcp.c +0 -0
  227. package/node/third_party/libuv/src/unix/thread.c +0 -0
  228. package/node/third_party/libuv/src/unix/tty.c +0 -0
  229. package/node/third_party/libuv/src/unix/udp.c +0 -0
  230. package/node/third_party/libuv/src/uv-common.c +0 -0
  231. package/node/third_party/libuv/src/uv-common.h +0 -0
  232. package/node/third_party/libuv/src/uv-data-getter-setters.c +0 -0
  233. package/node/third_party/libuv/src/version.c +0 -0
  234. package/node/third_party/llhttp/LICENSE +0 -0
  235. package/node/third_party/llhttp/api.c +0 -0
  236. package/node/third_party/llhttp/http.c +0 -0
  237. package/node/third_party/llhttp/llhttp.c +0 -0
  238. package/node/third_party/llhttp/llhttp.h +0 -0
  239. package/node/third_party/nodejs/LICENSE +47 -0
  240. package/node/third_party/nodejs/README.md +5 -0
  241. package/node/third_party/parseargs/LICENSE +21 -0
  242. package/node/third_party/parseargs/README.md +5 -0
  243. package/node/third_party/punycode/LICENSE +20 -0
  244. package/node/third_party/punycode/README.md +5 -0
  245. package/node/third_party/zlib/LICENSE.chromium +27 -0
  246. package/package.json +1 -5
  247. package/prebuilt/darwin-arm64/boringssl-4a47438eaf7e73ba.a +0 -0
  248. package/prebuilt/darwin-arm64/brotli-7995bbdacc52e51c.a +0 -0
  249. package/prebuilt/darwin-arm64/uv-72ab666eae197cd8.a +0 -0
  250. package/prebuilt/darwin-arm64/zlib-4ce2317a4c3f5fb5.a +0 -0
  251. package/prebuilt/darwin-arm64/zstd-015315ac7c784c73.a +0 -0
  252. package/prebuilt/darwin-x64/boringssl-4a47438eaf7e73ba.a +0 -0
  253. package/prebuilt/darwin-x64/brotli-7995bbdacc52e51c.a +0 -0
  254. package/prebuilt/darwin-x64/uv-72ab666eae197cd8.a +0 -0
  255. package/prebuilt/darwin-x64/zlib-4ce2317a4c3f5fb5.a +0 -0
  256. package/prebuilt/darwin-x64/zstd-015315ac7c784c73.a +0 -0
  257. package/prebuilt/linux-arm64/boringssl-4a47438eaf7e73ba.a +0 -0
  258. package/prebuilt/linux-arm64/brotli-65481ff838ce9def.a +0 -0
  259. package/prebuilt/linux-arm64/uv-f1353f50ff983f3c.a +0 -0
  260. package/prebuilt/linux-arm64/zlib-4ce2317a4c3f5fb5.a +0 -0
  261. package/prebuilt/linux-arm64/zstd-015315ac7c784c73.a +0 -0
  262. package/prebuilt/linux-arm64-musl/boringssl-4a47438eaf7e73ba.a +0 -0
  263. package/prebuilt/linux-arm64-musl/brotli-65481ff838ce9def.a +0 -0
  264. package/prebuilt/linux-arm64-musl/uv-f1353f50ff983f3c.a +0 -0
  265. package/prebuilt/linux-arm64-musl/zlib-4ce2317a4c3f5fb5.a +0 -0
  266. package/prebuilt/linux-arm64-musl/zstd-015315ac7c784c73.a +0 -0
  267. package/prebuilt/linux-x64/boringssl-4a47438eaf7e73ba.a +0 -0
  268. package/prebuilt/linux-x64/brotli-65481ff838ce9def.a +0 -0
  269. package/prebuilt/linux-x64/uv-f1353f50ff983f3c.a +0 -0
  270. package/prebuilt/linux-x64/zlib-4ce2317a4c3f5fb5.a +0 -0
  271. package/prebuilt/linux-x64/zstd-015315ac7c784c73.a +0 -0
  272. package/prebuilt/linux-x64-musl/boringssl-4a47438eaf7e73ba.a +0 -0
  273. package/prebuilt/linux-x64-musl/brotli-65481ff838ce9def.a +0 -0
  274. package/prebuilt/linux-x64-musl/uv-f1353f50ff983f3c.a +0 -0
  275. package/prebuilt/linux-x64-musl/zlib-4ce2317a4c3f5fb5.a +0 -0
  276. package/prebuilt/linux-x64-musl/zstd-015315ac7c784c73.a +0 -0
  277. package/prebuilt/win32-x64/boringssl-ce573858472b7fc9.a +0 -0
  278. package/prebuilt/win32-x64/brotli-20d86a61f30baeb3.a +0 -0
  279. package/prebuilt/win32-x64/uv-b11bae65d7fced82.a +0 -0
  280. package/prebuilt/win32-x64/zlib-4ce2317a4c3f5fb5.a +0 -0
  281. package/prebuilt/win32-x64/zstd-015315ac7c784c73.a +0 -0
  282. package/runtime/include/js_atoms.gen.h +0 -0
  283. package/runtime/include/js_atoms.h +1 -1
  284. package/runtime/include/js_bigint.h +1 -1
  285. package/runtime/include/js_buffer.h +4 -4
  286. package/runtime/include/js_builtins.h +41 -3
  287. package/runtime/include/js_console.h +9 -4
  288. package/runtime/include/js_convert.h +1 -1
  289. package/runtime/include/js_core.def +5 -4
  290. package/runtime/include/js_crypto.h +1 -1
  291. package/runtime/include/js_error.h +1 -1
  292. package/runtime/include/js_exception.h +21 -1
  293. package/runtime/include/js_function.h +33 -9
  294. package/runtime/include/js_gc.h +172 -30
  295. package/runtime/include/js_generator.h +2 -2
  296. package/runtime/include/js_host.h +19 -1
  297. package/runtime/include/js_jobs.h +5 -5
  298. package/runtime/include/js_module.h +1 -1
  299. package/runtime/include/js_object.h +142 -15
  300. package/runtime/include/js_ops.h +107 -5
  301. package/runtime/include/js_promise.h +3 -3
  302. package/runtime/include/js_regexp.h +1 -1
  303. package/runtime/include/js_runtime.h +0 -0
  304. package/runtime/include/js_symbol.h +1 -1
  305. package/runtime/include/js_web.h +2 -1
  306. package/runtime/include/jscell.h +22 -15
  307. package/runtime/include/jscontext.h +74 -39
  308. package/runtime/include/jsnum.h +1 -1
  309. package/runtime/include/jsstring.h +19 -6
  310. package/runtime/include/jsvalue.h +7 -3
  311. package/runtime/src/arguments.c +2 -2
  312. package/runtime/src/array.c +4 -1
  313. package/runtime/src/arraybuffer.c +19 -7
  314. package/runtime/src/async_iter.c +4 -3
  315. package/runtime/src/atoms.c +1 -1
  316. package/runtime/src/base64.c +2 -2
  317. package/runtime/src/bigint.c +1 -1
  318. package/runtime/src/blob.c +22 -9
  319. package/runtime/src/boringssl_support.cc +1 -1
  320. package/runtime/src/buffer.c +299 -91
  321. package/runtime/src/builtin_table.c +1 -1
  322. package/runtime/src/builtins.c +30 -4
  323. package/runtime/src/builtins_util.h +0 -0
  324. package/runtime/src/collections.c +18 -3
  325. package/runtime/src/components.c +1 -1
  326. package/runtime/src/console.c +14 -7
  327. package/runtime/src/convert.c +0 -0
  328. package/runtime/src/core_all.c +1 -1
  329. package/runtime/src/crypto.c +1 -1
  330. package/runtime/src/crypto_asym.c +1 -1
  331. package/runtime/src/crypto_bn.c +1 -1
  332. package/runtime/src/crypto_cipher.c +10 -3
  333. package/runtime/src/crypto_hash.c +1 -1
  334. package/runtime/src/crypto_host.c +1 -1
  335. package/runtime/src/crypto_internal.h +1 -1
  336. package/runtime/src/crypto_kdf.c +1 -1
  337. package/runtime/src/crypto_key.c +14 -1
  338. package/runtime/src/crypto_pkey.c +1 -1
  339. package/runtime/src/crypto_subtle.c +142 -58
  340. package/runtime/src/crypto_tls.c +1 -1
  341. package/runtime/src/date.c +5 -2
  342. package/runtime/src/domexception.c +2 -2
  343. package/runtime/src/elements.c +56 -17
  344. package/runtime/src/elements.h +7 -2
  345. package/runtime/src/encoding.c +1 -1
  346. package/runtime/src/error.c +4 -4
  347. package/runtime/src/events.c +23 -14
  348. package/runtime/src/exception.c +1 -1
  349. package/runtime/src/fetch.c +241 -17
  350. package/runtime/src/function.c +31 -19
  351. package/runtime/src/gc.c +1716 -207
  352. package/runtime/src/gc_visit.h +87 -0
  353. package/runtime/src/generator.c +5 -3
  354. package/runtime/src/global.c +14 -6
  355. package/runtime/src/headers.c +10 -10
  356. package/runtime/src/inspect.c +76 -17
  357. package/runtime/src/internal.h +5 -2
  358. package/runtime/src/iterate.c +94 -2
  359. package/runtime/src/iterator.c +1 -1
  360. package/runtime/src/jobs.c +11 -5
  361. package/runtime/src/jsnum.c +2 -2
  362. package/runtime/src/json.c +1 -1
  363. package/runtime/src/math.c +9 -1
  364. package/runtime/src/module.c +3 -3
  365. package/runtime/src/number.c +0 -0
  366. package/runtime/src/object.c +107 -74
  367. package/runtime/src/ops.c +21 -3
  368. package/runtime/src/os.c +192 -1
  369. package/runtime/src/os.h +33 -2
  370. package/runtime/src/process.c +73 -8
  371. package/runtime/src/promise.c +4 -4
  372. package/runtime/src/proxy.c +1 -1
  373. package/runtime/src/reflect.c +1 -1
  374. package/runtime/src/regexp.c +134 -2
  375. package/runtime/src/regexp_anchor.h +1 -1
  376. package/runtime/src/regexp_message.h +1 -1
  377. package/runtime/src/shape.c +10 -19
  378. package/runtime/src/shape.h +0 -0
  379. package/runtime/src/streams.c +22 -8
  380. package/runtime/src/streams.h +0 -0
  381. package/runtime/src/string.c +64 -25
  382. package/runtime/src/string_builtins.c +7 -7
  383. package/runtime/src/symbol.c +2 -7
  384. package/runtime/src/test_host.c +3 -3
  385. package/runtime/src/tls_roots.gen.h +102 -620
  386. package/runtime/src/typedarray.c +8 -3
  387. package/runtime/src/tznames.gen.h +2 -1
  388. package/runtime/src/uri.c +1 -1
  389. package/runtime/src/url.c +42 -39
  390. package/runtime/src/weak.c +15 -12
  391. package/runtime/src/web.c +21 -3
  392. package/runtime/src/wrapper.c +0 -0
  393. package/runtime/src/writable.c +7 -6
  394. package/runtime/third_party/ada-idna/LICENSE-MIT +0 -0
  395. package/runtime/third_party/ada-idna/README.md +7 -7
  396. package/runtime/third_party/ada-idna/convert.mjs +89 -27
  397. package/runtime/third_party/ada-idna/idna.c +30 -31
  398. package/runtime/third_party/ada-idna/idna.h +0 -0
  399. package/runtime/third_party/ada-idna/idna_tables.h +2272 -1952
  400. package/runtime/third_party/boringssl/third_party/fiat/LICENSE +15 -0
  401. package/runtime/third_party/mozilla-ca/LICENSE +373 -0
  402. package/runtime/third_party/mozilla-ca/README.md +9 -0
  403. package/runtime/third_party/nodejs/LICENSE +47 -0
  404. package/runtime/third_party/nodejs/README.md +7 -0
  405. package/runtime/third_party/quickjs-dtoa/LICENSE +0 -0
  406. package/runtime/third_party/quickjs-dtoa/README.md +1 -1
  407. package/runtime/third_party/quickjs-dtoa/dtoa.c +0 -0
  408. package/runtime/third_party/quickjs-dtoa/dtoa.h +0 -0
  409. package/runtime/third_party/quickjs-dtoa/dtoa_compat.h +0 -0
  410. package/runtime/third_party/quickjs-regexp/LICENSE +0 -0
  411. package/runtime/third_party/quickjs-regexp/README.md +2 -2
  412. package/runtime/third_party/quickjs-regexp/cutils.c +0 -0
  413. package/runtime/third_party/quickjs-regexp/cutils.h +0 -0
  414. package/runtime/third_party/quickjs-regexp/libregexp-opcode.h +0 -0
  415. package/runtime/third_party/quickjs-regexp/libregexp.c +0 -0
  416. package/runtime/third_party/quickjs-regexp/libregexp.h +0 -0
  417. package/runtime/third_party/quickjs-regexp/libunicode-table.h +0 -0
  418. package/runtime/third_party/quickjs-regexp/libunicode.c +0 -0
  419. package/runtime/third_party/quickjs-regexp/libunicode.h +0 -0
  420. package/runtime/third_party/unicode/LICENSE +39 -0
  421. package/runtime/third_party/unicode/README.md +9 -0
  422. package/runtime/third_party/v8-ieee754/LICENSE +0 -0
  423. package/runtime/third_party/v8-ieee754/LICENSE.fdlibm +10 -0
  424. package/runtime/third_party/v8-ieee754/README.md +3 -2
  425. package/runtime/third_party/v8-ieee754/convert.py +0 -0
  426. package/runtime/third_party/v8-ieee754/ieee754.c +0 -0
  427. package/runtime/third_party/v8-ieee754/ieee754.h +0 -0
  428. package/runtime/tools/regexp_compile.c +2 -2
@@ -0,0 +1,387 @@
1
+ import { bindContext } from "../async_context.js";
2
+ import * as __internal_errors from "./errors.js";
3
+ import * as __internal_util from "./validators.js";
4
+ import * as __internal_validators from "./validators.js";
5
+ import * as __internal_streams_utils from "./utils.js";
6
+
7
+ // Ported from https://github.com/mafintosh/end-of-stream with
8
+ // permission from the author, Mathias Buus (@mafintosh).
9
+
10
+ 'use strict';
11
+
12
+ const {
13
+ AbortError,
14
+ codes: {
15
+ ERR_INVALID_ARG_TYPE,
16
+ ERR_STREAM_PREMATURE_CLOSE,
17
+ },
18
+ } = __internal_errors;
19
+ const {
20
+ kEmptyObject,
21
+ once,
22
+ addAbortListener,
23
+ } = __internal_util;
24
+ const {
25
+ validateAbortSignal,
26
+ validateFunction,
27
+ validateObject,
28
+ validateBoolean,
29
+ } = __internal_validators;
30
+
31
+ const {
32
+ isClosed,
33
+ isReadable,
34
+ isReadableNodeStream,
35
+ isReadableStream,
36
+ isReadableFinished,
37
+ isReadableErrored,
38
+ isWritable,
39
+ isWritableNodeStream,
40
+ isWritableStream,
41
+ isWritableFinished,
42
+ isWritableErrored,
43
+ isNodeStream,
44
+ willEmitClose: _willEmitClose,
45
+ kIsClosedPromise,
46
+ } = __internal_streams_utils;
47
+
48
+
49
+ function isRequest(stream) {
50
+ return stream.setHeader && typeof stream.abort === 'function';
51
+ }
52
+
53
+ const nop = () => {};
54
+
55
+ /* the callback runs in the async context it was given in (an AsyncResource's scope in Node) */
56
+ function bindAsyncResource(fn, type) {
57
+ void type;
58
+ return bindContext(fn);
59
+ }
60
+
61
+ /**
62
+ * Returns the current stream error tracked by eos(), if any.
63
+ * @param {import('stream').Stream} stream
64
+ * @returns {Error | null}
65
+ */
66
+ function getEosErrored(stream) {
67
+ const errored = isWritableErrored(stream) || isReadableErrored(stream);
68
+ return typeof errored !== 'boolean' && errored || null;
69
+ }
70
+
71
+ /**
72
+ * Returns the error eos() would report from an immediate close, including
73
+ * premature close detection for unfinished readable or writable sides.
74
+ * @param {import('stream').Stream} stream
75
+ * @param {boolean} readable
76
+ * @param {boolean | null} readableFinished
77
+ * @param {boolean} writable
78
+ * @param {boolean | null} writableFinished
79
+ * @returns {Error | null}
80
+ */
81
+ function getEosOnCloseError(stream, readable, readableFinished, writable, writableFinished) {
82
+ const errored = getEosErrored(stream);
83
+ if (errored) {
84
+ return errored;
85
+ }
86
+
87
+ if (readable && !readableFinished && isReadableNodeStream(stream, true)) {
88
+ if (!isReadableFinished(stream, false)) {
89
+ return new ERR_STREAM_PREMATURE_CLOSE();
90
+ }
91
+ }
92
+ if (writable && !writableFinished) {
93
+ if (!isWritableFinished(stream, false)) {
94
+ return new ERR_STREAM_PREMATURE_CLOSE();
95
+ }
96
+ }
97
+
98
+ return null;
99
+ }
100
+
101
+ // Internal only: if eos() can settle immediately, invoke the callback before
102
+ // returning cleanup. Callers must tolerate cleanup yet to be assigned.
103
+ const kEosNodeSynchronousCallback = Symbol('kEosNodeSynchronousCallback');
104
+
105
+ function eos(stream, options, callback) {
106
+ if (arguments.length === 2) {
107
+ callback = options;
108
+ options = kEmptyObject;
109
+ } else if (options == null) {
110
+ options = kEmptyObject;
111
+ } else {
112
+ validateObject(options, 'options');
113
+ }
114
+ validateFunction(callback, 'callback');
115
+ validateAbortSignal(options.signal, 'options.signal');
116
+
117
+ if (isReadableStream(stream) || isWritableStream(stream)) {
118
+ return eosWeb(stream, options, callback);
119
+ }
120
+
121
+ if (!isNodeStream(stream)) {
122
+ throw new ERR_INVALID_ARG_TYPE('stream', ['ReadableStream', 'WritableStream', 'Stream'], stream);
123
+ }
124
+
125
+ const readable = options.readable ?? isReadableNodeStream(stream);
126
+ const writable = options.writable ?? isWritableNodeStream(stream);
127
+
128
+ // TODO (ronag): Improve soft detection to include core modules and
129
+ // common ecosystem modules that do properly emit 'close' but fail
130
+ // this generic check.
131
+ let willEmitClose = (
132
+ _willEmitClose(stream) &&
133
+ isReadableNodeStream(stream) === readable &&
134
+ isWritableNodeStream(stream) === writable
135
+ );
136
+ let writableFinished = isWritableFinished(stream, false);
137
+ let readableFinished = isReadableFinished(stream, false);
138
+
139
+ const wState = stream._writableState;
140
+ const rState = stream._readableState;
141
+
142
+ /**
143
+ * @type {Error | null | undefined}
144
+ * undefined: to be determined
145
+ * null: no error
146
+ * Error: an error occurred
147
+ */
148
+ let immediateResult;
149
+ if (isClosed(stream)) {
150
+ immediateResult = getEosOnCloseError(
151
+ stream,
152
+ readable,
153
+ readableFinished,
154
+ writable,
155
+ writableFinished,
156
+ );
157
+ } else if (wState?.errorEmitted || rState?.errorEmitted) {
158
+ if (!willEmitClose) {
159
+ immediateResult = getEosErrored(stream);
160
+ }
161
+ } else if (
162
+ !readable &&
163
+ (!willEmitClose || isReadable(stream)) &&
164
+ (writableFinished || isWritable(stream) === false) &&
165
+ (wState == null || wState.pendingcb === undefined || wState.pendingcb === 0)
166
+ ) {
167
+ immediateResult = getEosErrored(stream);
168
+ } else if (
169
+ !writable &&
170
+ (!willEmitClose || isWritable(stream)) &&
171
+ (readableFinished || isReadable(stream) === false)
172
+ ) {
173
+ immediateResult = getEosErrored(stream);
174
+ } else if ((rState && stream.req && stream.aborted)) {
175
+ immediateResult = getEosErrored(stream);
176
+ }
177
+ let cleanup = () => {
178
+ callback = nop;
179
+ };
180
+ if (immediateResult !== undefined) {
181
+ if (options.error !== false) {
182
+ stream.on('error', nop);
183
+ cleanup = () => {
184
+ callback = nop;
185
+ stream.removeListener('error', nop);
186
+ };
187
+ }
188
+ } else if (options.signal?.aborted) {
189
+ immediateResult = new AbortError(undefined, { cause: options.signal.reason });
190
+ }
191
+ if (immediateResult !== undefined && options[kEosNodeSynchronousCallback]) {
192
+ Reflect.apply(callback, stream, immediateResult === null ? [] : [immediateResult]);
193
+ return cleanup;
194
+ }
195
+
196
+ // Avoid AsyncResource.bind() because it calls Object.defineProperties which
197
+ // is a bottleneck here.
198
+ callback = bindAsyncResource(callback, 'STREAM_END_OF_STREAM');
199
+
200
+ if (immediateResult !== undefined) {
201
+ process.nextTick(() => Reflect.apply(callback, stream, immediateResult === null ? [] : [immediateResult]));
202
+ return cleanup;
203
+ }
204
+
205
+ callback = once(callback);
206
+
207
+ const onlegacyfinish = () => {
208
+ if (!stream.writable) {
209
+ onfinish();
210
+ }
211
+ };
212
+
213
+ const onfinish = () => {
214
+ writableFinished = true;
215
+ // Stream should not be destroyed here. If it is that
216
+ // means that user space is doing something differently and
217
+ // we cannot trust willEmitClose.
218
+ if (stream.destroyed) {
219
+ willEmitClose = false;
220
+ }
221
+
222
+ if (willEmitClose && (!stream.readable || readable)) {
223
+ return;
224
+ }
225
+
226
+ if (!readable || readableFinished) {
227
+ callback.call(stream);
228
+ }
229
+ };
230
+
231
+ const onend = () => {
232
+ readableFinished = true;
233
+ // Stream should not be destroyed here. If it is that
234
+ // means that user space is doing something differently and
235
+ // we cannot trust willEmitClose.
236
+ if (stream.destroyed) {
237
+ willEmitClose = false;
238
+ }
239
+
240
+ if (willEmitClose && (!stream.writable || writable)) {
241
+ return;
242
+ }
243
+
244
+ if (!writable || writableFinished) {
245
+ callback.call(stream);
246
+ }
247
+ };
248
+
249
+ const onerror = (err) => {
250
+ callback.call(stream, err);
251
+ };
252
+
253
+ const onclose = () => {
254
+ const error = getEosOnCloseError(stream, readable, readableFinished, writable, writableFinished);
255
+ if (error === null) {
256
+ callback.call(stream);
257
+ } else {
258
+ callback.call(stream, error);
259
+ }
260
+ };
261
+
262
+ const onrequest = () => {
263
+ stream.req.on('finish', onfinish);
264
+ };
265
+
266
+ if (isRequest(stream)) {
267
+ stream.on('complete', onfinish);
268
+ if (!willEmitClose) {
269
+ stream.on('abort', onclose);
270
+ }
271
+ if (stream.req) {
272
+ onrequest();
273
+ } else {
274
+ stream.on('request', onrequest);
275
+ }
276
+ } else if (writable && !wState) { // legacy streams
277
+ stream.on('end', onlegacyfinish);
278
+ stream.on('close', onlegacyfinish);
279
+ }
280
+
281
+ // Not all streams will emit 'close' after 'aborted'.
282
+ if (!willEmitClose && typeof stream.aborted === 'boolean') {
283
+ stream.on('aborted', onclose);
284
+ }
285
+
286
+ stream.on('end', onend);
287
+ stream.on('finish', onfinish);
288
+ if (options.error !== false) {
289
+ stream.on('error', onerror);
290
+ }
291
+ stream.on('close', onclose);
292
+
293
+ cleanup = () => {
294
+ callback = nop;
295
+ stream.removeListener('aborted', onclose);
296
+ stream.removeListener('complete', onfinish);
297
+ stream.removeListener('abort', onclose);
298
+ stream.removeListener('request', onrequest);
299
+ if (stream.req) stream.req.removeListener('finish', onfinish);
300
+ stream.removeListener('end', onlegacyfinish);
301
+ stream.removeListener('close', onlegacyfinish);
302
+ stream.removeListener('finish', onfinish);
303
+ stream.removeListener('end', onend);
304
+ stream.removeListener('error', onerror);
305
+ stream.removeListener('close', onclose);
306
+ };
307
+
308
+ if (options.signal) {
309
+ const abort = () => {
310
+ // Keep it because cleanup removes it.
311
+ const endCallback = callback;
312
+ cleanup();
313
+ endCallback.call(
314
+ stream,
315
+ new AbortError(undefined, { cause: options.signal.reason }));
316
+ };
317
+ const disposable = addAbortListener(options.signal, abort);
318
+ const originalCallback = callback;
319
+ callback = once((...args) => {
320
+ disposable[Symbol.dispose]();
321
+ Reflect.apply(originalCallback, stream, args);
322
+ });
323
+ }
324
+
325
+ return cleanup;
326
+ }
327
+
328
+ function eosWeb(stream, options, callback) {
329
+ // Avoid AsyncResource.bind() because it calls Object.defineProperties which
330
+ // is a bottleneck here.
331
+ callback = once(bindAsyncResource(callback, 'STREAM_END_OF_STREAM'));
332
+
333
+ let isAborted = false;
334
+ let abort = nop;
335
+ if (options.signal) {
336
+ abort = () => {
337
+ isAborted = true;
338
+ callback.call(stream, new AbortError(undefined, { cause: options.signal.reason }));
339
+ };
340
+ if (options.signal.aborted) {
341
+ process.nextTick(abort);
342
+ } else {
343
+ const disposable = addAbortListener(options.signal, abort);
344
+ const originalCallback = callback;
345
+ callback = once((...args) => {
346
+ disposable[Symbol.dispose]();
347
+ originalCallback.apply(stream, args);
348
+ });
349
+ }
350
+ }
351
+ const resolverFn = (...args) => {
352
+ if (!isAborted) {
353
+ process.nextTick(() => callback.apply(stream, args));
354
+ }
355
+ };
356
+ stream[kIsClosedPromise].promise.then(resolverFn, resolverFn, );
357
+ return nop;
358
+ }
359
+
360
+ function finished(stream, opts) {
361
+ let autoCleanup = false;
362
+ if (opts === null) {
363
+ opts = kEmptyObject;
364
+ }
365
+ if (opts?.cleanup) {
366
+ validateBoolean(opts.cleanup, 'cleanup');
367
+ autoCleanup = opts.cleanup;
368
+ }
369
+ return new Promise((resolve, reject) => {
370
+ const cleanup = eos(stream, opts, (err) => {
371
+ if (autoCleanup) {
372
+ cleanup();
373
+ }
374
+ if (err) {
375
+ reject(err);
376
+ } else {
377
+ resolve();
378
+ }
379
+ });
380
+ });
381
+ }
382
+
383
+ export {
384
+ eos,
385
+ finished,
386
+ kEosNodeSynchronousCallback,
387
+ };
@@ -0,0 +1,216 @@
1
+ // The errors node:stream throws, as Node's lib/internal/errors.js builds them: each code a class
2
+ // (`new ERR_STREAM_DESTROYED("write")`) whose instances are Node's TypeError, RangeError or Error
3
+ // with that `code` and Node's message. Only the codes the streams use.
4
+ // Ported from Node.js (Copyright Node.js contributors, MIT): node/third_party/nodejs/LICENSE.
5
+ import { utilInspect } from "visaljs:host";
6
+ import { codeError } from "../errors.js";
7
+
8
+ const kTypes = ["string", "function", "number", "object", "Function", "Object", "boolean", "bigint", "symbol"];
9
+ const classRegExp = /^[A-Z][a-zA-Z0-9]*$/;
10
+
11
+ function formatList(array, type = "and") {
12
+ switch (array.length) {
13
+ case 0: return "";
14
+ case 1: return `${array[0]}`;
15
+ case 2: return `${array[0]} ${type} ${array[1]}`;
16
+ case 3: return `${array[0]}, ${array[1]}, ${type} ${array[2]}`;
17
+ default: return `${array.slice(0, -1).join(", ")}, ${type} ${array[array.length - 1]}`;
18
+ }
19
+ }
20
+
21
+ function addNumericalSeparator(val) {
22
+ let res = "";
23
+ let i = val.length;
24
+ const start = val[0] === "-" ? 1 : 0;
25
+ for (; i >= start + 4; i -= 3) res = `_${val.slice(i - 3, i)}${res}`;
26
+ return `${val.slice(0, i)}${res}`;
27
+ }
28
+
29
+ /** Node's determineSpecificType: how a received value is named in a message */
30
+ export function determineSpecificType(value) {
31
+ if (value === null) return "null";
32
+ if (value === undefined) return "undefined";
33
+ const type = typeof value;
34
+ switch (type) {
35
+ case "bigint":
36
+ return `type bigint (${value}n)`;
37
+ case "number":
38
+ if (value === 0) return 1 / value === -Infinity ? "type number (-0)" : "type number (0)";
39
+ if (value !== value) return "type number (NaN)";
40
+ if (value === Infinity) return "type number (Infinity)";
41
+ if (value === -Infinity) return "type number (-Infinity)";
42
+ return `type number (${value})`;
43
+ case "boolean":
44
+ return value ? "type boolean (true)" : "type boolean (false)";
45
+ case "symbol":
46
+ return `type symbol (${String(value)})`;
47
+ case "function":
48
+ return `function ${value.name}`;
49
+ case "object":
50
+ if (value.constructor && "name" in value.constructor) return `an instance of ${value.constructor.name}`;
51
+ return `${utilInspect(value, { depth: -1 })}`;
52
+ case "string":
53
+ if (value.length > 28) value = `${value.slice(0, 25)}...`;
54
+ if (value.indexOf("'") === -1) return `type string ('${value}')`;
55
+ return `type string (${JSON.stringify(value)})`;
56
+ default: {
57
+ let inspected = utilInspect(value, { colors: false });
58
+ if (inspected.length > 28) inspected = `${inspected.slice(0, 25)}...`;
59
+ return `type ${type} (${inspected})`;
60
+ }
61
+ }
62
+ }
63
+
64
+ function invalidArgTypeMessage(name, expected, actual) {
65
+ if (!Array.isArray(expected)) expected = [expected];
66
+ let msg = "The ";
67
+ if (name.endsWith(" argument")) msg += `${name} `;
68
+ else msg += `"${name}" ${name.includes(".") ? "property" : "argument"} `;
69
+ msg += "must be ";
70
+ const types = [];
71
+ const instances = [];
72
+ const other = [];
73
+ for (const value of expected) {
74
+ if (kTypes.includes(value)) types.push(value.toLowerCase());
75
+ else if (classRegExp.exec(value) !== null) instances.push(value);
76
+ else other.push(value);
77
+ }
78
+ if (instances.length > 0) {
79
+ const pos = types.indexOf("object");
80
+ if (pos !== -1) {
81
+ types.splice(pos, 1);
82
+ instances.push("Object");
83
+ }
84
+ }
85
+ if (types.length > 0) {
86
+ msg += `${types.length > 1 ? "one of type" : "of type"} ${formatList(types, "or")}`;
87
+ if (instances.length > 0 || other.length > 0) msg += " or ";
88
+ }
89
+ if (instances.length > 0) {
90
+ msg += `an instance of ${formatList(instances, "or")}`;
91
+ if (other.length > 0) msg += " or ";
92
+ }
93
+ if (other.length > 0) {
94
+ if (other.length > 1) msg += `one of ${formatList(other, "or")}`;
95
+ else {
96
+ if (other[0].toLowerCase() !== other[0]) msg += "an ";
97
+ msg += `${other[0]}`;
98
+ }
99
+ }
100
+ return msg + `. Received ${determineSpecificType(actual)}`;
101
+ }
102
+
103
+ /** util.format's %s: a string as it is, an object inspected shallowly, a bigint with its n */
104
+ function formatS(arg) {
105
+ if (typeof arg === "bigint") return `${arg}n`;
106
+ if (typeof arg === "object" && arg !== null) return utilInspect(arg, { depth: 0, colors: false, compact: 3 });
107
+ return String(arg);
108
+ }
109
+
110
+ /** A code's class: `new` gives Base's instance with the code and the message format(…args) makes. */
111
+ function E(code, format, Base) {
112
+ const make = typeof format === "function" ? format : (...args) => {
113
+ let i = 0;
114
+ return format.replace(/%s/g, () => formatS(args[i++]));
115
+ };
116
+ const Ctor = function (...args) {
117
+ return codeError(Base, code, make(...args));
118
+ };
119
+ Object.defineProperty(Ctor, "name", { value: code });
120
+ Ctor.prototype = Base.prototype;
121
+ return Ctor;
122
+ }
123
+
124
+ export const codes = {
125
+ ERR_INVALID_ARG_TYPE: E("ERR_INVALID_ARG_TYPE", invalidArgTypeMessage, TypeError),
126
+ ERR_INVALID_ARG_VALUE: E("ERR_INVALID_ARG_VALUE", (name, value, reason = "is invalid") => {
127
+ let inspected = utilInspect(value);
128
+ if (inspected.length > 128) inspected = `${inspected.slice(0, 128)}...`;
129
+ return `The ${name.includes(".") ? "property" : "argument"} '${name}' ${reason}. Received ${inspected}`;
130
+ }, TypeError),
131
+ ERR_INVALID_RETURN_VALUE: E("ERR_INVALID_RETURN_VALUE",
132
+ (input, name, value) => `Expected ${input} to be returned from the "${name}" function but got ${determineSpecificType(value)}.`, TypeError),
133
+ ERR_MISSING_ARGS: E("ERR_MISSING_ARGS", (...args) => {
134
+ const len = args.length;
135
+ const wrap = (a) => `"${a}"`;
136
+ args = args.map((a) => (Array.isArray(a) ? a.map(wrap).join(" or ") : wrap(a)));
137
+ return `The ${formatList(args)} argument${len > 1 ? "s" : ""} must be specified`;
138
+ }, TypeError),
139
+ ERR_METHOD_NOT_IMPLEMENTED: E("ERR_METHOD_NOT_IMPLEMENTED", "The %s method is not implemented", Error),
140
+ ERR_MULTIPLE_CALLBACK: E("ERR_MULTIPLE_CALLBACK", "Callback called multiple times", Error),
141
+ ERR_OUT_OF_RANGE: E("ERR_OUT_OF_RANGE", (str, range, input, replaceDefaultBoolean = false) => {
142
+ let msg = replaceDefaultBoolean ? str : `The value of "${str}" is out of range.`;
143
+ let received;
144
+ if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
145
+ received = addNumericalSeparator(String(input));
146
+ } else if (typeof input === "bigint") {
147
+ received = String(input);
148
+ if (input > 2n ** 32n || input < -(2n ** 32n)) received = addNumericalSeparator(received);
149
+ received += "n";
150
+ } else {
151
+ received = utilInspect(input);
152
+ }
153
+ return msg + ` It must be ${range}. Received ${received}`;
154
+ }, RangeError),
155
+ ERR_STREAM_PREMATURE_CLOSE: E("ERR_STREAM_PREMATURE_CLOSE", "Premature close", Error),
156
+ ERR_STREAM_DESTROYED: E("ERR_STREAM_DESTROYED", "Cannot call %s after a stream was destroyed", Error),
157
+ ERR_UNKNOWN_ENCODING: E("ERR_UNKNOWN_ENCODING", "Unknown encoding: %s", TypeError),
158
+ ERR_STREAM_NULL_VALUES: E("ERR_STREAM_NULL_VALUES", "May not write null values to stream", TypeError),
159
+ ERR_STREAM_PUSH_AFTER_EOF: E("ERR_STREAM_PUSH_AFTER_EOF", "stream.push() after EOF", Error),
160
+ ERR_ILLEGAL_CONSTRUCTOR: E("ERR_ILLEGAL_CONSTRUCTOR", "Illegal constructor", TypeError),
161
+ ERR_STREAM_WRITE_AFTER_END: E("ERR_STREAM_WRITE_AFTER_END", "write after end", Error),
162
+ ERR_STREAM_UNSHIFT_AFTER_END_EVENT: E("ERR_STREAM_UNSHIFT_AFTER_END_EVENT", "stream.unshift() after end event", Error),
163
+ ERR_STREAM_UNABLE_TO_PIPE: E("ERR_STREAM_UNABLE_TO_PIPE", "Cannot pipe to a closed or destroyed stream", Error),
164
+ ERR_STREAM_ITER_MISSING_FLAG: E("ERR_STREAM_ITER_MISSING_FLAG", "The stream/iter API requires the --experimental-stream-iter flag", TypeError),
165
+ ERR_STREAM_CANNOT_PIPE: E("ERR_STREAM_CANNOT_PIPE", "Cannot pipe, not readable", Error),
166
+ ERR_STREAM_ALREADY_FINISHED: E("ERR_STREAM_ALREADY_FINISHED", "Cannot call %s after a stream was finished", Error),
167
+ ERR_INVALID_STATE: E("ERR_INVALID_STATE", "Invalid state: %s", Error),
168
+ ERR_INCOMPATIBLE_OPTION_PAIR: E("ERR_INCOMPATIBLE_OPTION_PAIR", 'Option "%s" cannot be used in combination with option "%s"', TypeError),
169
+ ERR_DIR_CLOSED: E("ERR_DIR_CLOSED", "Directory handle was closed", Error),
170
+ ERR_FS_FILE_TOO_LARGE: E("ERR_FS_FILE_TOO_LARGE", "File size (%s) is greater than 2 GiB", RangeError),
171
+ ERR_INVALID_THIS: E("ERR_INVALID_THIS", 'Value of "this" must be of type %s', TypeError),
172
+ ERR_MISSING_OPTION: E("ERR_MISSING_OPTION", "%s is required", TypeError),
173
+ ERR_FEATURE_UNAVAILABLE_ON_PLATFORM: E("ERR_FEATURE_UNAVAILABLE_ON_PLATFORM",
174
+ "The feature %s is unavailable on the current platform, which is being used to run Node.js", TypeError),
175
+ };
176
+
177
+ /** Node's SystemError for fs (ERR_FS_EISDIR, ERR_FS_CP_*): "<prefix>: <syscall> returned <code>
178
+ * (<message>) <path>", with the context as properties. */
179
+ export function fsSystemError(key, prefix, context) {
180
+ let message = `${prefix}: ${context.syscall} returned ${context.code} (${context.message})`;
181
+ if (context.path !== undefined) message += ` ${context.path}`;
182
+ if (context.dest !== undefined) message += ` => ${context.dest}`;
183
+ const err = codeError(Error, key, message);
184
+ err.name = "SystemError";
185
+ Object.defineProperties(err, {
186
+ info: { value: context, enumerable: true, configurable: true, writable: false },
187
+ errno: { value: context.errno, enumerable: true, configurable: true, writable: true },
188
+ syscall: { value: context.syscall, enumerable: true, configurable: true, writable: true },
189
+ path: { value: context.path, enumerable: true, configurable: true, writable: true },
190
+ });
191
+ return err;
192
+ }
193
+ codes.ERR_INVALID_STATE.TypeError = E("ERR_INVALID_STATE", "Invalid state: %s", TypeError);
194
+
195
+ export class AbortError extends Error {
196
+ constructor(message = "The operation was aborted", options = undefined) {
197
+ if (options !== undefined && typeof options !== "object") throw new codes.ERR_INVALID_ARG_TYPE("options", "Object", options);
198
+ super(message, options);
199
+ this.code = "ABORT_ERR";
200
+ this.name = "AbortError";
201
+ }
202
+ }
203
+
204
+ /** Two errors as one: the outer one, with the inner one added (an AggregateError of both). */
205
+ export function aggregateTwoErrors(innerError, outerError) {
206
+ if (innerError && outerError && innerError !== outerError) {
207
+ if (Array.isArray(outerError.errors)) {
208
+ outerError.errors.push(innerError);
209
+ return outerError;
210
+ }
211
+ const err = new AggregateError([outerError, innerError], outerError.message);
212
+ err.code = outerError.code;
213
+ return err;
214
+ }
215
+ return innerError || outerError;
216
+ }