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,166 @@
1
+ // fs.Dir, opendir and opendirSync: a directory's entries as Dirents, one read at a time (and, with
2
+ // recursive, its subdirectories' after them, as Node's). Linked into programs that name them
3
+ // (internal/features.js).
4
+ import { fsReaddir } from "visaljs:host";
5
+ import { Dir as DirWrapper, Dirent } from "../fs.js";
6
+ import { codeError, systemError, validateFunction } from "./errors.js";
7
+ import { features, provideClass } from "./features.js";
8
+ import { getOptions, getValidatedPath } from "./fs_utils.js";
9
+ import { codes } from "./streams/errors.js";
10
+ import { validateUint32 } from "./streams/validators.js";
11
+
12
+ const closed = () => codeError(Error, "ERR_DIR_CLOSED", "Directory handle was closed");
13
+
14
+ /* a directory's entries now: [name, type, …] as Dirents of that directory */
15
+ function entriesOf(path) {
16
+ const r = fsReaddir(path);
17
+ if (typeof r === "number") {
18
+ const e = systemError(r, "opendir"); /* Node's message names the call, not the path */
19
+ e.path = path;
20
+ throw e;
21
+ }
22
+ const entries = [];
23
+ for (let i = 0; i < r.length; i += 2) entries.push(new Dirent(r[i], r[i + 1], path));
24
+ return entries;
25
+ }
26
+
27
+ class Dir {
28
+ #path;
29
+ #entries;
30
+ #queue = []; /* subdirectories to read next (recursive) */
31
+ #recursive;
32
+ #closed = false;
33
+ #busy = false;
34
+
35
+ constructor(path, entries, options) {
36
+ /* Node's takes the directory's handle first: a program can't make one */
37
+ if (path == null) throw codeError(TypeError, "ERR_MISSING_ARGS", 'The "handle" argument must be specified');
38
+ this.#path = path;
39
+ this.#entries = entries;
40
+ this.#recursive = Boolean(options?.recursive);
41
+ validateUint32({ bufferSize: 32, ...options }.bufferSize, "options.bufferSize", true); /* as Node's: a given null too */
42
+ }
43
+
44
+ get path() {
45
+ if (!(#path in this)) throw new codes.ERR_INVALID_THIS("Dir");
46
+ return this.#path;
47
+ }
48
+
49
+ /** The next entry, or null at the end. */
50
+ readSync() {
51
+ if (this.#closed) throw closed();
52
+ if (this.#busy) throw codeError(Error, "ERR_DIR_CONCURRENT_OPERATION", "Cannot do synchronous work on directory handle with concurrent asynchronous operations");
53
+ return this.#next();
54
+ }
55
+
56
+ #next() {
57
+ for (;;) {
58
+ const dirent = this.#entries.shift();
59
+ if (dirent !== undefined) {
60
+ /* links aren't followed, as Node's */
61
+ if (this.#recursive && dirent.isDirectory()) this.#queue.push(`${dirent.parentPath}/${dirent.name}`);
62
+ return dirent;
63
+ }
64
+ if (this.#queue.length === 0) return null;
65
+ this.#entries = entriesOf(this.#queue.shift());
66
+ }
67
+ }
68
+
69
+ /** read([callback]): the next entry, or null, as a promise or to the callback. */
70
+ read(callback) {
71
+ if (callback !== undefined) {
72
+ validateFunction(callback, "callback");
73
+ return this.#later(() => this.#next(), callback);
74
+ }
75
+ return this.#promise(() => this.#next());
76
+ }
77
+
78
+ closeSync() {
79
+ if (this.#closed) throw closed();
80
+ if (this.#busy) throw codeError(Error, "ERR_DIR_CONCURRENT_OPERATION", "Cannot do synchronous work on directory handle with concurrent asynchronous operations");
81
+ this.#closed = true;
82
+ this.#entries = [];
83
+ this.#queue = [];
84
+ }
85
+
86
+ close(callback) {
87
+ if (callback !== undefined) {
88
+ validateFunction(callback, "callback");
89
+ return this.#later(() => this.closeSync(), callback);
90
+ }
91
+ return this.#promise(() => this.closeSync());
92
+ }
93
+
94
+ /* an operation on a later tick, as Node's on the thread pool: the handle is busy until then */
95
+ #later(fn, callback) {
96
+ if (this.#closed) {
97
+ process.nextTick(callback, closed());
98
+ return;
99
+ }
100
+ this.#busy = true;
101
+ process.nextTick(() => {
102
+ this.#busy = false;
103
+ let result, error = null;
104
+ try {
105
+ result = fn();
106
+ } catch (e) {
107
+ error = e;
108
+ }
109
+ if (error) callback(error);
110
+ else callback(null, result);
111
+ });
112
+ }
113
+
114
+ #promise(fn) {
115
+ return new Promise((resolve, reject) => this.#later(fn, (err, result) => (err ? reject(err) : resolve(result))));
116
+ }
117
+
118
+ /** The entries, then the directory closed. */
119
+ async *entries() {
120
+ try {
121
+ for (;;) {
122
+ const dirent = await this.read();
123
+ if (dirent === null) break;
124
+ yield dirent;
125
+ }
126
+ } finally {
127
+ if (!this.#closed) this.closeSync();
128
+ }
129
+ }
130
+
131
+ [Symbol.asyncIterator]() {
132
+ return this.entries();
133
+ }
134
+
135
+ [Symbol.dispose ?? Symbol.for("nodejs.dispose")]() {
136
+ if (!this.#closed) this.closeSync();
137
+ }
138
+
139
+ async [Symbol.asyncDispose ?? Symbol.for("nodejs.asyncDispose")]() {
140
+ if (!this.#closed) this.closeSync();
141
+ }
142
+ }
143
+
144
+ function opendirSync(path, options) {
145
+ path = getValidatedPath(path);
146
+ options = getOptions(options, { encoding: "utf8" });
147
+ return new Dir(path, entriesOf(path), options);
148
+ }
149
+
150
+ /* the arguments checked now, as Node's; the directory opened, then the Dir made, on a later tick */
151
+ function opendir(path, options, callback) {
152
+ callback = typeof options === "function" ? options : callback;
153
+ validateFunction(callback, "callback");
154
+ path = getValidatedPath(path);
155
+ options = getOptions(options, { encoding: "utf8" });
156
+ let entries, error = null;
157
+ try {
158
+ entries = entriesOf(path);
159
+ } catch (e) {
160
+ error = e;
161
+ }
162
+ process.nextTick(() => (error ? callback(error) : callback(null, new Dir(path, entries, options))));
163
+ }
164
+
165
+ Object.assign(features, { opendirSync, opendir, opendirPromise: async (path, options) => opendirSync(path, options) });
166
+ provideClass(DirWrapper, Dir);
@@ -0,0 +1,287 @@
1
+ // fs/promises' open and FileHandle, as Node's: an fd's calls as promises (read, write, readv,
2
+ // writev, readFile, writeFile, appendFile, stat, truncate, sync, datasync, utimes, chmod, chown),
3
+ // read streams, write streams and readLines on it, close and Symbol.asyncDispose, and its 'close'
4
+ // event. The I/O happens when the method is called, as node:fs/promises' other calls. Linked into
5
+ // programs that name them (internal/features.js).
6
+ import { EventEmitter } from "../events.js";
7
+ import {
8
+ closeSync, createReadStream, createWriteStream, fchmodSync, fchownSync, fdatasyncSync, fstatSync, fsyncSync, ftruncateSync, futimesSync,
9
+ openSync, readSync, readvSync, writeSync, writevSync,
10
+ } from "../fs.js";
11
+ import { createInterface } from "../readline.js";
12
+ import { notSupported } from "./errors.js";
13
+ import { features } from "./features.js";
14
+ import {
15
+ getOptions, kIoMaxLength, validateBufferArray, validateOffsetLengthRead, validateOffsetLengthWrite, validatePosition,
16
+ validateStringAfterArrayBufferView,
17
+ } from "./fs_utils.js";
18
+ import "./fs_streams.js"; /* its streams */
19
+ import { AbortError, codes } from "./streams/errors.js";
20
+ import { kEmptyObject, validateAbortSignal, validateBuffer, validateInteger, validateObject } from "./streams/validators.js";
21
+
22
+ const { ERR_FS_FILE_TOO_LARGE, ERR_INVALID_ARG_VALUE } = codes;
23
+ const kReadChunk = 512 * 1024;
24
+ const kWriteFileMaxChunkSize = 512 * 1024;
25
+
26
+ function checkAborted(signal) {
27
+ if (signal?.aborted) throw new AbortError(undefined, { cause: signal.reason });
28
+ }
29
+
30
+ /* an iterable, or async iterable, of chunks: not a string or bytes */
31
+ const isCustomIterable = (obj) =>
32
+ obj != null && typeof obj !== "string" && !ArrayBuffer.isView(obj) &&
33
+ (typeof obj[Symbol.asyncIterator] === "function" || typeof obj[Symbol.iterator] === "function");
34
+
35
+ /* Node's validateEncoding: hex takes whole bytes */
36
+ function validateEncoding(data, encoding) {
37
+ if (typeof encoding === "string" && encoding.toLowerCase() === "hex" && data.length % 2 !== 0) {
38
+ throw new ERR_INVALID_ARG_VALUE("encoding", encoding, `is invalid for data of length ${data.length}`);
39
+ }
40
+ }
41
+
42
+ /* EBADF for a handle that's closed, as Node's */
43
+ function closedError(syscall) {
44
+ const e = new Error("file closed");
45
+ e.errno = -9;
46
+ e.code = "EBADF";
47
+ e.syscall = syscall;
48
+ return e;
49
+ }
50
+
51
+ export class FileHandle extends EventEmitter {
52
+ #fd;
53
+ #closing = null;
54
+
55
+ constructor(fd) {
56
+ super();
57
+ this.#fd = fd;
58
+ }
59
+
60
+ get fd() {
61
+ return this.#fd;
62
+ }
63
+
64
+ /* the call on the fd as a promise; EBADF once the handle is closed */
65
+ #call(syscall, fn) {
66
+ return new Promise((resolve, reject) => {
67
+ if (this.#fd < 0) return reject(closedError(syscall));
68
+ try {
69
+ resolve(fn(this.#fd));
70
+ } catch (e) {
71
+ reject(e);
72
+ }
73
+ });
74
+ }
75
+
76
+ /** read(buffer, offset, length, position), read(buffer, options) or read(options): { bytesRead,
77
+ * buffer }. Node's argument handling (lib/internal/fs/promises.js). */
78
+ read(bufferOrParams, offset, length, position) {
79
+ return this.#call("read", (fd) => {
80
+ let buffer = bufferOrParams;
81
+ if (!ArrayBuffer.isView(buffer)) {
82
+ if (bufferOrParams !== undefined && bufferOrParams !== null) validateObject(bufferOrParams, "options");
83
+ ({ buffer = Buffer.alloc(16384), offset = 0, length = buffer.byteLength - offset, position = null } = bufferOrParams ?? kEmptyObject);
84
+ validateBuffer(buffer);
85
+ }
86
+ if (offset !== null && typeof offset === "object") {
87
+ ({ offset = 0, length = buffer.byteLength - offset, position = null } = offset);
88
+ }
89
+ if (offset == null) offset = 0;
90
+ else validateInteger(offset, "offset", 0);
91
+ length ??= buffer.byteLength - offset;
92
+ if (position == null) position = -1;
93
+ else validatePosition(position, "position", length);
94
+ if (length === 0) return { __proto__: null, bytesRead: length, buffer };
95
+ if (buffer.byteLength === 0) throw new ERR_INVALID_ARG_VALUE("buffer", buffer, "is empty and cannot be written");
96
+ validateOffsetLengthRead(offset, length, buffer.byteLength);
97
+ return { __proto__: null, bytesRead: readSync(fd, buffer, offset, length, position) || 0, buffer };
98
+ });
99
+ }
100
+
101
+ /** write(buffer[, offset[, length[, position]]]), write(buffer, options) or write(string[, position[,
102
+ * encoding]]): { bytesWritten, buffer }. */
103
+ write(buffer, offsetOrOptions, length, position) {
104
+ return this.#call("write", (fd) => {
105
+ if (buffer?.byteLength === 0) return { __proto__: null, bytesWritten: 0, buffer };
106
+ let offset = offsetOrOptions;
107
+ if (ArrayBuffer.isView(buffer)) {
108
+ if (typeof offset === "object") {
109
+ ({ offset = 0, length = buffer.byteLength - offset, position = null } = offsetOrOptions ?? kEmptyObject);
110
+ }
111
+ if (offset == null) offset = 0;
112
+ else validateInteger(offset, "offset", 0);
113
+ if (typeof length !== "number") length = buffer.byteLength - offset;
114
+ if (typeof position !== "number") position = null;
115
+ validateOffsetLengthWrite(offset, length, buffer.byteLength);
116
+ return { __proto__: null, bytesWritten: writeSync(fd, buffer, offset, length, position) || 0, buffer };
117
+ }
118
+ validateStringAfterArrayBufferView(buffer, "buffer");
119
+ validateEncoding(buffer, length);
120
+ return { __proto__: null, bytesWritten: writeSync(fd, buffer, offset, length) || 0, buffer };
121
+ });
122
+ }
123
+
124
+ readv(buffers, position) {
125
+ return this.#call("read", (fd) => {
126
+ validateBufferArray(buffers);
127
+ return { __proto__: null, bytesRead: readvSync(fd, buffers, typeof position === "number" ? position : null), buffers };
128
+ });
129
+ }
130
+
131
+ writev(buffers, position) {
132
+ return this.#call("write", (fd) => {
133
+ validateBufferArray(buffers);
134
+ if (buffers.length === 0) return { __proto__: null, bytesWritten: 0, buffers };
135
+ return { __proto__: null, bytesWritten: writevSync(fd, buffers, typeof position === "number" ? position : null), buffers };
136
+ });
137
+ }
138
+
139
+ /** The rest of the file from its current position: a Buffer, or a string with an encoding. An
140
+ * abort signal is checked before and between reads, as Node's. */
141
+ readFile(options) {
142
+ return this.#call("read", async (fd) => {
143
+ options = getOptions(options, { flag: "r" });
144
+ const { signal, encoding } = options;
145
+ validateAbortSignal(signal, "options.signal");
146
+ checkAborted(signal);
147
+ const st = fstatSync(fd);
148
+ if (st.isFile() && st.size > kIoMaxLength) throw new ERR_FS_FILE_TOO_LARGE(st.size);
149
+ const chunks = [];
150
+ let total = 0;
151
+ for (;;) {
152
+ await undefined; /* a turn for an abort, as Node's reads on its thread pool */
153
+ checkAborted(signal);
154
+ const chunk = Buffer.allocUnsafe(kReadChunk);
155
+ const n = readSync(fd, chunk, 0, kReadChunk, null);
156
+ if (n === 0) break;
157
+ chunks.push(n === kReadChunk ? chunk : chunk.subarray(0, n));
158
+ total += n;
159
+ }
160
+ const all = Buffer.concat(chunks, total);
161
+ return encoding && encoding !== "buffer" ? all.toString(encoding) : all;
162
+ });
163
+ }
164
+
165
+ /** The data written from the current position: a string, bytes, or an iterable or stream of them,
166
+ * in chunks, an abort signal checked between them (Node's writeFileHandle). */
167
+ writeFile(data, options) {
168
+ return this.#call("write", async () => {
169
+ options = getOptions(options, { encoding: "utf8", mode: 0o666, flag: "w", flush: false });
170
+ if (!ArrayBuffer.isView(data) && !isCustomIterable(data)) {
171
+ validateStringAfterArrayBufferView(data, "data");
172
+ data = Buffer.from(data, options.encoding || "utf8");
173
+ }
174
+ const { signal, encoding } = options;
175
+ validateAbortSignal(signal, "options.signal");
176
+ checkAborted(signal);
177
+ if (isCustomIterable(data)) {
178
+ for await (const buf of data) {
179
+ checkAborted(signal);
180
+ const toWrite = ArrayBuffer.isView(buf) ? buf : Buffer.from(buf, encoding || "utf8");
181
+ let remaining = toWrite.byteLength;
182
+ while (remaining > 0) {
183
+ const writeSize = Math.min(kWriteFileMaxChunkSize, remaining);
184
+ const { bytesWritten } = await this.write(toWrite, toWrite.byteLength - remaining, writeSize);
185
+ remaining -= bytesWritten;
186
+ checkAborted(signal);
187
+ }
188
+ }
189
+ return;
190
+ }
191
+ data = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
192
+ let remaining = data.byteLength;
193
+ if (remaining === 0) return;
194
+ do {
195
+ checkAborted(signal);
196
+ const { bytesWritten } = await this.write(data, 0, Math.min(kWriteFileMaxChunkSize, data.byteLength));
197
+ remaining -= bytesWritten;
198
+ data = new Uint8Array(data.buffer, data.byteOffset + bytesWritten, data.byteLength - bytesWritten);
199
+ } while (remaining > 0);
200
+ });
201
+ }
202
+
203
+ appendFile(data, options) {
204
+ return this.writeFile(data, options);
205
+ }
206
+
207
+ stat(options) {
208
+ return this.#call("fstat", (fd) => fstatSync(fd, options ?? { bigint: false }));
209
+ }
210
+
211
+ truncate(len = 0) {
212
+ return this.#call("ftruncate", (fd) => void ftruncateSync(fd, len));
213
+ }
214
+
215
+ sync() {
216
+ return this.#call("fsync", (fd) => void fsyncSync(fd));
217
+ }
218
+
219
+ datasync() {
220
+ return this.#call("fdatasync", (fd) => void fdatasyncSync(fd));
221
+ }
222
+
223
+ utimes(atime, mtime) {
224
+ return this.#call("futime", (fd) => void futimesSync(fd, atime, mtime));
225
+ }
226
+
227
+ chmod(mode) {
228
+ return this.#call("fchmod", (fd) => void fchmodSync(fd, mode));
229
+ }
230
+
231
+ chown(uid, gid) {
232
+ return this.#call("fchown", (fd) => void fchownSync(fd, uid, gid));
233
+ }
234
+
235
+ /* streams on the handle, as Node's: they read and write through it, and close it */
236
+ createReadStream(options = undefined) {
237
+ return createReadStream(undefined, { ...options, fd: this });
238
+ }
239
+
240
+ createWriteStream(options = undefined) {
241
+ return createWriteStream(undefined, { ...options, fd: this });
242
+ }
243
+
244
+ /** The lines: node:readline's interface on a read stream. */
245
+ readLines(options) {
246
+ return createInterface({ input: this.createReadStream(options), crlfDelay: Infinity });
247
+ }
248
+
249
+ readableWebStream() {
250
+ throw notSupported("FileHandle.readableWebStream");
251
+ }
252
+
253
+ /** Closes the fd, once: 'close' follows. */
254
+ close() {
255
+ if (this.#closing) return this.#closing;
256
+ if (this.#fd < 0) return Promise.resolve();
257
+ const fd = this.#fd;
258
+ this.#closing = new Promise((resolve, reject) => {
259
+ try {
260
+ closeSync(fd);
261
+ this.#fd = -1;
262
+ this.emit("close");
263
+ resolve();
264
+ } catch (e) {
265
+ reject(e);
266
+ }
267
+ });
268
+ return this.#closing;
269
+ }
270
+
271
+ [Symbol.asyncDispose ?? Symbol.for("nodejs.asyncDispose")]() {
272
+ return this.close();
273
+ }
274
+ }
275
+
276
+ /** fs/promises' open(path[, flags[, mode]]): a FileHandle. */
277
+ function promisesOpen(path, flags = "r", mode = 0o666) {
278
+ return new Promise((resolve, reject) => {
279
+ try {
280
+ resolve(new FileHandle(openSync(path, flags, mode)));
281
+ } catch (e) {
282
+ reject(e);
283
+ }
284
+ });
285
+ }
286
+
287
+ Object.assign(features, { promisesOpen, FileHandle });