visaljs 0.0.5 → 0.0.6

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 (433) hide show
  1. package/cli.js +469 -53
  2. package/node/include/js_node.h +36 -0
  3. package/node/prelude/async_hooks.js +63 -8
  4. package/node/prelude/buffer.js +0 -0
  5. package/node/prelude/diagnostics_channel.js +322 -0
  6. package/node/prelude/dns.js +3 -2
  7. package/node/prelude/events.js +17 -3
  8. package/node/prelude/fs.js +177 -5
  9. package/node/prelude/fs_promises.js +24 -0
  10. package/node/prelude/http.js +13 -4
  11. package/node/prelude/http2.js +0 -0
  12. package/node/prelude/internal/async_context.js +27 -0
  13. package/node/prelude/internal/crypto/asym.js +0 -0
  14. package/node/prelude/internal/crypto/cipher.js +0 -0
  15. package/node/prelude/internal/crypto/kdf.js +0 -0
  16. package/node/prelude/internal/crypto/keys.js +0 -0
  17. package/node/prelude/internal/crypto/random.js +0 -0
  18. package/node/prelude/internal/crypto/util.js +0 -0
  19. package/node/prelude/internal/errors.js +11 -0
  20. package/node/prelude/internal/process_events.js +14 -0
  21. package/node/prelude/internal/process_signals.js +42 -0
  22. package/node/prelude/internal/querystring.js +0 -0
  23. package/node/prelude/internal/timers.js +233 -0
  24. package/node/prelude/internal/timers_global.js +9 -0
  25. package/node/prelude/internal/zlib_brotli.js +6 -0
  26. package/node/prelude/internal/zlib_engines.js +4 -0
  27. package/node/prelude/internal/zlib_zstd.js +6 -0
  28. package/node/prelude/module.js +22 -6
  29. package/node/prelude/net.js +9 -8
  30. package/node/prelude/os.js +0 -0
  31. package/node/prelude/path.js +1599 -186
  32. package/node/prelude/path_posix.js +9 -0
  33. package/node/prelude/path_win32.js +9 -0
  34. package/node/prelude/process.js +3 -0
  35. package/node/prelude/querystring.js +0 -0
  36. package/node/prelude/stream.js +18 -6
  37. package/node/prelude/stream_promises.js +0 -0
  38. package/node/prelude/stream_web.js +0 -0
  39. package/node/prelude/string_decoder.js +0 -0
  40. package/node/prelude/timers.js +92 -0
  41. package/node/prelude/timers_promises.js +133 -0
  42. package/node/prelude/tty.js +0 -0
  43. package/node/prelude/url.js +0 -0
  44. package/node/prelude/util.js +0 -0
  45. package/node/prelude/zlib.js +912 -72
  46. package/node/src/host_brotli.c +157 -0
  47. package/node/src/host_fs.c +95 -1
  48. package/node/src/host_loop.c +10 -4
  49. package/node/src/host_os.c +0 -0
  50. package/node/src/host_signal.c +70 -0
  51. package/node/src/host_sys.c +50 -0
  52. package/node/src/host_zlib.c +314 -0
  53. package/node/src/host_zstd.c +179 -0
  54. package/node/third_party/brotli/LICENSE +19 -0
  55. package/node/third_party/brotli/common/constants.c +15 -0
  56. package/node/third_party/brotli/common/constants.h +201 -0
  57. package/node/third_party/brotli/common/context.c +156 -0
  58. package/node/third_party/brotli/common/context.h +113 -0
  59. package/node/third_party/brotli/common/dictionary.c +5916 -0
  60. package/node/third_party/brotli/common/dictionary.h +64 -0
  61. package/node/third_party/brotli/common/platform.c +23 -0
  62. package/node/third_party/brotli/common/platform.h +541 -0
  63. package/node/third_party/brotli/common/shared_dictionary.c +521 -0
  64. package/node/third_party/brotli/common/shared_dictionary_internal.h +75 -0
  65. package/node/third_party/brotli/common/transform.c +291 -0
  66. package/node/third_party/brotli/common/transform.h +85 -0
  67. package/node/third_party/brotli/common/version.h +51 -0
  68. package/node/third_party/brotli/dec/bit_reader.c +78 -0
  69. package/node/third_party/brotli/dec/bit_reader.h +423 -0
  70. package/node/third_party/brotli/dec/decode.c +2875 -0
  71. package/node/third_party/brotli/dec/huffman.c +342 -0
  72. package/node/third_party/brotli/dec/huffman.h +122 -0
  73. package/node/third_party/brotli/dec/prefix.h +733 -0
  74. package/node/third_party/brotli/dec/state.c +183 -0
  75. package/node/third_party/brotli/dec/state.h +400 -0
  76. package/node/third_party/brotli/enc/backward_references.c +207 -0
  77. package/node/third_party/brotli/enc/backward_references.h +40 -0
  78. package/node/third_party/brotli/enc/backward_references_hq.c +939 -0
  79. package/node/third_party/brotli/enc/backward_references_hq.h +96 -0
  80. package/node/third_party/brotli/enc/backward_references_inc.h +189 -0
  81. package/node/third_party/brotli/enc/bit_cost.c +36 -0
  82. package/node/third_party/brotli/enc/bit_cost.h +64 -0
  83. package/node/third_party/brotli/enc/bit_cost_inc.h +127 -0
  84. package/node/third_party/brotli/enc/block_encoder_inc.h +34 -0
  85. package/node/third_party/brotli/enc/block_splitter.c +217 -0
  86. package/node/third_party/brotli/enc/block_splitter.h +52 -0
  87. package/node/third_party/brotli/enc/block_splitter_inc.h +481 -0
  88. package/node/third_party/brotli/enc/brotli_bit_stream.c +1336 -0
  89. package/node/third_party/brotli/enc/brotli_bit_stream.h +89 -0
  90. package/node/third_party/brotli/enc/cluster.c +57 -0
  91. package/node/third_party/brotli/enc/cluster.h +49 -0
  92. package/node/third_party/brotli/enc/cluster_inc.h +325 -0
  93. package/node/third_party/brotli/enc/command.c +28 -0
  94. package/node/third_party/brotli/enc/command.h +191 -0
  95. package/node/third_party/brotli/enc/compound_dictionary.c +207 -0
  96. package/node/third_party/brotli/enc/compound_dictionary.h +74 -0
  97. package/node/third_party/brotli/enc/compress_fragment.c +800 -0
  98. package/node/third_party/brotli/enc/compress_fragment.h +86 -0
  99. package/node/third_party/brotli/enc/compress_fragment_two_pass.c +657 -0
  100. package/node/third_party/brotli/enc/compress_fragment_two_pass.h +72 -0
  101. package/node/third_party/brotli/enc/dictionary_hash.c +1848 -0
  102. package/node/third_party/brotli/enc/dictionary_hash.h +25 -0
  103. package/node/third_party/brotli/enc/encode.c +1996 -0
  104. package/node/third_party/brotli/enc/encoder_dict.c +640 -0
  105. package/node/third_party/brotli/enc/encoder_dict.h +157 -0
  106. package/node/third_party/brotli/enc/entropy_encode.c +504 -0
  107. package/node/third_party/brotli/enc/entropy_encode.h +123 -0
  108. package/node/third_party/brotli/enc/entropy_encode_static.h +542 -0
  109. package/node/third_party/brotli/enc/fast_log.c +105 -0
  110. package/node/third_party/brotli/enc/fast_log.h +67 -0
  111. package/node/third_party/brotli/enc/find_match_length.h +72 -0
  112. package/node/third_party/brotli/enc/hash.h +728 -0
  113. package/node/third_party/brotli/enc/hash_composite_inc.h +140 -0
  114. package/node/third_party/brotli/enc/hash_forgetful_chain_inc.h +295 -0
  115. package/node/third_party/brotli/enc/hash_longest_match64_inc.h +262 -0
  116. package/node/third_party/brotli/enc/hash_longest_match_inc.h +258 -0
  117. package/node/third_party/brotli/enc/hash_longest_match_quickly_inc.h +266 -0
  118. package/node/third_party/brotli/enc/hash_rolling_inc.h +212 -0
  119. package/node/third_party/brotli/enc/hash_to_binary_tree_inc.h +330 -0
  120. package/node/third_party/brotli/enc/histogram.c +100 -0
  121. package/node/third_party/brotli/enc/histogram.h +64 -0
  122. package/node/third_party/brotli/enc/histogram_inc.h +51 -0
  123. package/node/third_party/brotli/enc/literal_cost.c +180 -0
  124. package/node/third_party/brotli/enc/literal_cost.h +32 -0
  125. package/node/third_party/brotli/enc/memory.c +194 -0
  126. package/node/third_party/brotli/enc/memory.h +131 -0
  127. package/node/third_party/brotli/enc/metablock.c +677 -0
  128. package/node/third_party/brotli/enc/metablock.h +106 -0
  129. package/node/third_party/brotli/enc/metablock_inc.h +185 -0
  130. package/node/third_party/brotli/enc/params.h +47 -0
  131. package/node/third_party/brotli/enc/prefix.h +54 -0
  132. package/node/third_party/brotli/enc/quality.h +202 -0
  133. package/node/third_party/brotli/enc/ringbuffer.h +168 -0
  134. package/node/third_party/brotli/enc/state.h +104 -0
  135. package/node/third_party/brotli/enc/static_dict.c +542 -0
  136. package/node/third_party/brotli/enc/static_dict.h +41 -0
  137. package/node/third_party/brotli/enc/static_dict_lut.h +5866 -0
  138. package/node/third_party/brotli/enc/utf8_util.c +85 -0
  139. package/node/third_party/brotli/enc/utf8_util.h +33 -0
  140. package/node/third_party/brotli/enc/write_bits.h +88 -0
  141. package/node/third_party/brotli/include/brotli/decode.h +409 -0
  142. package/node/third_party/brotli/include/brotli/encode.h +501 -0
  143. package/node/third_party/brotli/include/brotli/port.h +305 -0
  144. package/node/third_party/brotli/include/brotli/shared_dictionary.h +100 -0
  145. package/node/third_party/brotli/include/brotli/types.h +83 -0
  146. package/node/third_party/libuv/LICENSE +0 -0
  147. package/node/third_party/libuv/include/uv/aix.h +0 -0
  148. package/node/third_party/libuv/include/uv/bsd.h +0 -0
  149. package/node/third_party/libuv/include/uv/darwin.h +0 -0
  150. package/node/third_party/libuv/include/uv/errno.h +0 -0
  151. package/node/third_party/libuv/include/uv/linux.h +0 -0
  152. package/node/third_party/libuv/include/uv/os390.h +0 -0
  153. package/node/third_party/libuv/include/uv/posix.h +0 -0
  154. package/node/third_party/libuv/include/uv/sunos.h +0 -0
  155. package/node/third_party/libuv/include/uv/threadpool.h +0 -0
  156. package/node/third_party/libuv/include/uv/tree.h +0 -0
  157. package/node/third_party/libuv/include/uv/unix.h +0 -0
  158. package/node/third_party/libuv/include/uv/version.h +0 -0
  159. package/node/third_party/libuv/include/uv/win.h +0 -0
  160. package/node/third_party/libuv/include/uv.h +0 -0
  161. package/node/third_party/libuv/src/fs-poll.c +0 -0
  162. package/node/third_party/libuv/src/heap-inl.h +0 -0
  163. package/node/third_party/libuv/src/idna.c +0 -0
  164. package/node/third_party/libuv/src/idna.h +0 -0
  165. package/node/third_party/libuv/src/inet.c +0 -0
  166. package/node/third_party/libuv/src/queue.h +0 -0
  167. package/node/third_party/libuv/src/random.c +0 -0
  168. package/node/third_party/libuv/src/strscpy.c +0 -0
  169. package/node/third_party/libuv/src/strscpy.h +0 -0
  170. package/node/third_party/libuv/src/strtok.c +0 -0
  171. package/node/third_party/libuv/src/strtok.h +0 -0
  172. package/node/third_party/libuv/src/thread-common.c +0 -0
  173. package/node/third_party/libuv/src/threadpool.c +0 -0
  174. package/node/third_party/libuv/src/timer.c +0 -0
  175. package/node/third_party/libuv/src/unix/async.c +0 -0
  176. package/node/third_party/libuv/src/unix/bsd-ifaddrs.c +0 -0
  177. package/node/third_party/libuv/src/unix/core.c +0 -0
  178. package/node/third_party/libuv/src/unix/darwin-proctitle.c +0 -0
  179. package/node/third_party/libuv/src/unix/darwin-stub.h +0 -0
  180. package/node/third_party/libuv/src/unix/darwin-syscalls.h +0 -0
  181. package/node/third_party/libuv/src/unix/darwin.c +0 -0
  182. package/node/third_party/libuv/src/unix/dl.c +0 -0
  183. package/node/third_party/libuv/src/unix/fs.c +0 -0
  184. package/node/third_party/libuv/src/unix/fsevents.c +0 -0
  185. package/node/third_party/libuv/src/unix/getaddrinfo.c +0 -0
  186. package/node/third_party/libuv/src/unix/getnameinfo.c +0 -0
  187. package/node/third_party/libuv/src/unix/internal.h +0 -0
  188. package/node/third_party/libuv/src/unix/kqueue.c +0 -0
  189. package/node/third_party/libuv/src/unix/linux.c +0 -0
  190. package/node/third_party/libuv/src/unix/loop-watcher.c +0 -0
  191. package/node/third_party/libuv/src/unix/loop.c +0 -0
  192. package/node/third_party/libuv/src/unix/pipe.c +0 -0
  193. package/node/third_party/libuv/src/unix/poll.c +0 -0
  194. package/node/third_party/libuv/src/unix/process.c +0 -0
  195. package/node/third_party/libuv/src/unix/procfs-exepath.c +0 -0
  196. package/node/third_party/libuv/src/unix/proctitle.c +0 -0
  197. package/node/third_party/libuv/src/unix/random-devurandom.c +0 -0
  198. package/node/third_party/libuv/src/unix/random-getentropy.c +0 -0
  199. package/node/third_party/libuv/src/unix/random-getrandom.c +0 -0
  200. package/node/third_party/libuv/src/unix/random-sysctl-linux.c +0 -0
  201. package/node/third_party/libuv/src/unix/signal.c +0 -0
  202. package/node/third_party/libuv/src/unix/stream.c +0 -0
  203. package/node/third_party/libuv/src/unix/tcp.c +0 -0
  204. package/node/third_party/libuv/src/unix/thread.c +0 -0
  205. package/node/third_party/libuv/src/unix/tty.c +0 -0
  206. package/node/third_party/libuv/src/unix/udp.c +0 -0
  207. package/node/third_party/libuv/src/uv-common.c +0 -0
  208. package/node/third_party/libuv/src/uv-common.h +0 -0
  209. package/node/third_party/libuv/src/uv-data-getter-setters.c +0 -0
  210. package/node/third_party/libuv/src/version.c +0 -0
  211. package/node/third_party/llhttp/LICENSE +0 -0
  212. package/node/third_party/llhttp/api.c +0 -0
  213. package/node/third_party/llhttp/http.c +0 -0
  214. package/node/third_party/llhttp/llhttp.c +0 -0
  215. package/node/third_party/llhttp/llhttp.h +0 -0
  216. package/node/third_party/zlib/LICENSE +19 -0
  217. package/node/third_party/zlib/README.chromium +38 -0
  218. package/node/third_party/zlib/adler32.c +197 -0
  219. package/node/third_party/zlib/chromeconf.h +203 -0
  220. package/node/third_party/zlib/contrib/optimizations/insert_string.h +80 -0
  221. package/node/third_party/zlib/cpu_features.c +213 -0
  222. package/node/third_party/zlib/cpu_features.h +22 -0
  223. package/node/third_party/zlib/crc32.c +1192 -0
  224. package/node/third_party/zlib/crc32.h +9446 -0
  225. package/node/third_party/zlib/deflate.c +2289 -0
  226. package/node/third_party/zlib/deflate.h +407 -0
  227. package/node/third_party/zlib/gzguts.h +214 -0
  228. package/node/third_party/zlib/inffast.c +327 -0
  229. package/node/third_party/zlib/inffast.h +26 -0
  230. package/node/third_party/zlib/inffixed.h +94 -0
  231. package/node/third_party/zlib/inflate.c +1528 -0
  232. package/node/third_party/zlib/inflate.h +126 -0
  233. package/node/third_party/zlib/inftrees.c +299 -0
  234. package/node/third_party/zlib/inftrees.h +62 -0
  235. package/node/third_party/zlib/trees.c +1161 -0
  236. package/node/third_party/zlib/trees.h +128 -0
  237. package/node/third_party/zlib/zconf.h +558 -0
  238. package/node/third_party/zlib/zlib.h +1967 -0
  239. package/node/third_party/zlib/zutil.c +299 -0
  240. package/node/third_party/zlib/zutil.h +275 -0
  241. package/node/third_party/zstd/LICENSE +30 -0
  242. package/node/third_party/zstd/common/allocations.h +55 -0
  243. package/node/third_party/zstd/common/bits.h +205 -0
  244. package/node/third_party/zstd/common/bitstream.h +454 -0
  245. package/node/third_party/zstd/common/compiler.h +464 -0
  246. package/node/third_party/zstd/common/cpu.h +249 -0
  247. package/node/third_party/zstd/common/debug.c +30 -0
  248. package/node/third_party/zstd/common/debug.h +107 -0
  249. package/node/third_party/zstd/common/entropy_common.c +340 -0
  250. package/node/third_party/zstd/common/error_private.c +64 -0
  251. package/node/third_party/zstd/common/error_private.h +158 -0
  252. package/node/third_party/zstd/common/fse.h +625 -0
  253. package/node/third_party/zstd/common/fse_decompress.c +315 -0
  254. package/node/third_party/zstd/common/huf.h +277 -0
  255. package/node/third_party/zstd/common/mem.h +422 -0
  256. package/node/third_party/zstd/common/pool.c +371 -0
  257. package/node/third_party/zstd/common/pool.h +81 -0
  258. package/node/third_party/zstd/common/portability_macros.h +171 -0
  259. package/node/third_party/zstd/common/threading.c +182 -0
  260. package/node/third_party/zstd/common/threading.h +142 -0
  261. package/node/third_party/zstd/common/xxhash.c +18 -0
  262. package/node/third_party/zstd/common/xxhash.h +7094 -0
  263. package/node/third_party/zstd/common/zstd_common.c +48 -0
  264. package/node/third_party/zstd/common/zstd_deps.h +123 -0
  265. package/node/third_party/zstd/common/zstd_internal.h +324 -0
  266. package/node/third_party/zstd/common/zstd_trace.h +156 -0
  267. package/node/third_party/zstd/compress/clevels.h +134 -0
  268. package/node/third_party/zstd/compress/fse_compress.c +625 -0
  269. package/node/third_party/zstd/compress/hist.c +191 -0
  270. package/node/third_party/zstd/compress/hist.h +82 -0
  271. package/node/third_party/zstd/compress/huf_compress.c +1464 -0
  272. package/node/third_party/zstd/compress/zstd_compress.c +7843 -0
  273. package/node/third_party/zstd/compress/zstd_compress_internal.h +1636 -0
  274. package/node/third_party/zstd/compress/zstd_compress_literals.c +235 -0
  275. package/node/third_party/zstd/compress/zstd_compress_literals.h +39 -0
  276. package/node/third_party/zstd/compress/zstd_compress_sequences.c +442 -0
  277. package/node/third_party/zstd/compress/zstd_compress_sequences.h +55 -0
  278. package/node/third_party/zstd/compress/zstd_compress_superblock.c +688 -0
  279. package/node/third_party/zstd/compress/zstd_compress_superblock.h +32 -0
  280. package/node/third_party/zstd/compress/zstd_cwksp.h +765 -0
  281. package/node/third_party/zstd/compress/zstd_double_fast.c +778 -0
  282. package/node/third_party/zstd/compress/zstd_double_fast.h +42 -0
  283. package/node/third_party/zstd/compress/zstd_fast.c +985 -0
  284. package/node/third_party/zstd/compress/zstd_fast.h +30 -0
  285. package/node/third_party/zstd/compress/zstd_lazy.c +2199 -0
  286. package/node/third_party/zstd/compress/zstd_lazy.h +193 -0
  287. package/node/third_party/zstd/compress/zstd_ldm.c +745 -0
  288. package/node/third_party/zstd/compress/zstd_ldm.h +109 -0
  289. package/node/third_party/zstd/compress/zstd_ldm_geartab.h +106 -0
  290. package/node/third_party/zstd/compress/zstd_opt.c +1580 -0
  291. package/node/third_party/zstd/compress/zstd_opt.h +72 -0
  292. package/node/third_party/zstd/compress/zstd_preSplit.c +238 -0
  293. package/node/third_party/zstd/compress/zstd_preSplit.h +33 -0
  294. package/node/third_party/zstd/compress/zstdmt_compress.c +1923 -0
  295. package/node/third_party/zstd/compress/zstdmt_compress.h +102 -0
  296. package/node/third_party/zstd/decompress/huf_decompress.c +1944 -0
  297. package/node/third_party/zstd/decompress/zstd_ddict.c +244 -0
  298. package/node/third_party/zstd/decompress/zstd_ddict.h +44 -0
  299. package/node/third_party/zstd/decompress/zstd_decompress.c +2410 -0
  300. package/node/third_party/zstd/decompress/zstd_decompress_block.c +2209 -0
  301. package/node/third_party/zstd/decompress/zstd_decompress_block.h +73 -0
  302. package/node/third_party/zstd/decompress/zstd_decompress_internal.h +240 -0
  303. package/node/third_party/zstd/zdict.h +481 -0
  304. package/node/third_party/zstd/zstd.h +3198 -0
  305. package/node/third_party/zstd/zstd_errors.h +107 -0
  306. package/package.json +2 -3
  307. package/runtime/include/js_atoms.gen.h +0 -0
  308. package/runtime/include/js_atoms.h +0 -0
  309. package/runtime/include/js_bigint.h +0 -0
  310. package/runtime/include/js_buffer.h +0 -0
  311. package/runtime/include/js_builtins.h +0 -0
  312. package/runtime/include/js_console.h +5 -2
  313. package/runtime/include/js_convert.h +0 -0
  314. package/runtime/include/js_core.def +0 -0
  315. package/runtime/include/js_error.h +0 -0
  316. package/runtime/include/js_exception.h +0 -0
  317. package/runtime/include/js_function.h +0 -0
  318. package/runtime/include/js_gc.h +0 -0
  319. package/runtime/include/js_generator.h +0 -0
  320. package/runtime/include/js_host.h +5 -3
  321. package/runtime/include/js_jobs.h +18 -1
  322. package/runtime/include/js_module.h +0 -0
  323. package/runtime/include/js_object.h +0 -0
  324. package/runtime/include/js_ops.h +0 -0
  325. package/runtime/include/js_promise.h +1 -0
  326. package/runtime/include/js_regexp.h +0 -0
  327. package/runtime/include/js_runtime.h +0 -0
  328. package/runtime/include/js_symbol.h +0 -0
  329. package/runtime/include/js_web.h +0 -0
  330. package/runtime/include/jscell.h +0 -0
  331. package/runtime/include/jscontext.h +14 -0
  332. package/runtime/include/jsnum.h +0 -0
  333. package/runtime/include/jsstring.h +0 -0
  334. package/runtime/include/jsvalue.h +0 -0
  335. package/runtime/src/arguments.c +0 -0
  336. package/runtime/src/array.c +0 -0
  337. package/runtime/src/arraybuffer.c +0 -0
  338. package/runtime/src/async_iter.c +0 -0
  339. package/runtime/src/atoms.c +0 -0
  340. package/runtime/src/base64.c +0 -0
  341. package/runtime/src/bigint.c +0 -0
  342. package/runtime/src/blob.c +0 -0
  343. package/runtime/src/buffer.c +20 -16
  344. package/runtime/src/builtin_table.c +0 -0
  345. package/runtime/src/builtins.c +0 -0
  346. package/runtime/src/builtins_util.h +0 -0
  347. package/runtime/src/collections.c +0 -0
  348. package/runtime/src/components.c +0 -0
  349. package/runtime/src/console.c +15 -2
  350. package/runtime/src/convert.c +0 -0
  351. package/runtime/src/core_all.c +0 -0
  352. package/runtime/src/crypto.c +0 -0
  353. package/runtime/src/crypto_host.c +0 -0
  354. package/runtime/src/crypto_kdf.c +0 -0
  355. package/runtime/src/crypto_key.c +0 -0
  356. package/runtime/src/date.c +0 -0
  357. package/runtime/src/domexception.c +0 -0
  358. package/runtime/src/elements.c +0 -0
  359. package/runtime/src/elements.h +0 -0
  360. package/runtime/src/encoding.c +0 -0
  361. package/runtime/src/error.c +0 -0
  362. package/runtime/src/events.c +1 -1
  363. package/runtime/src/exception.c +0 -0
  364. package/runtime/src/fetch.c +0 -0
  365. package/runtime/src/function.c +0 -0
  366. package/runtime/src/gc.c +2 -0
  367. package/runtime/src/generator.c +0 -0
  368. package/runtime/src/global.c +0 -0
  369. package/runtime/src/headers.c +0 -0
  370. package/runtime/src/inspect.c +0 -0
  371. package/runtime/src/internal.h +0 -0
  372. package/runtime/src/iterate.c +0 -0
  373. package/runtime/src/iterator.c +0 -0
  374. package/runtime/src/jobs.c +123 -44
  375. package/runtime/src/jsnum.c +0 -0
  376. package/runtime/src/json.c +0 -0
  377. package/runtime/src/math.c +0 -0
  378. package/runtime/src/module.c +0 -0
  379. package/runtime/src/number.c +0 -0
  380. package/runtime/src/object.c +0 -0
  381. package/runtime/src/ops.c +0 -0
  382. package/runtime/src/os.c +0 -0
  383. package/runtime/src/os.h +0 -0
  384. package/runtime/src/process.c +92 -8
  385. package/runtime/src/promise.c +7 -2
  386. package/runtime/src/proxy.c +0 -0
  387. package/runtime/src/reflect.c +0 -0
  388. package/runtime/src/regexp.c +0 -0
  389. package/runtime/src/regexp_anchor.h +0 -0
  390. package/runtime/src/regexp_message.h +0 -0
  391. package/runtime/src/shape.c +0 -0
  392. package/runtime/src/shape.h +0 -0
  393. package/runtime/src/streams.c +0 -0
  394. package/runtime/src/streams.h +0 -0
  395. package/runtime/src/string.c +0 -0
  396. package/runtime/src/string_builtins.c +0 -0
  397. package/runtime/src/symbol.c +0 -0
  398. package/runtime/src/test_host.c +0 -0
  399. package/runtime/src/typedarray.c +0 -0
  400. package/runtime/src/tznames.gen.h +0 -0
  401. package/runtime/src/uri.c +0 -0
  402. package/runtime/src/url.c +0 -0
  403. package/runtime/src/weak.c +1 -4
  404. package/runtime/src/web.c +0 -0
  405. package/runtime/src/wrapper.c +0 -0
  406. package/runtime/src/writable.c +0 -0
  407. package/runtime/third_party/ada-idna/LICENSE-MIT +0 -0
  408. package/runtime/third_party/ada-idna/README.md +0 -0
  409. package/runtime/third_party/ada-idna/convert.mjs +0 -0
  410. package/runtime/third_party/ada-idna/idna.c +0 -0
  411. package/runtime/third_party/ada-idna/idna.h +0 -0
  412. package/runtime/third_party/ada-idna/idna_tables.h +0 -0
  413. package/runtime/third_party/quickjs-dtoa/LICENSE +0 -0
  414. package/runtime/third_party/quickjs-dtoa/README.md +0 -0
  415. package/runtime/third_party/quickjs-dtoa/dtoa.c +0 -0
  416. package/runtime/third_party/quickjs-dtoa/dtoa.h +0 -0
  417. package/runtime/third_party/quickjs-dtoa/dtoa_compat.h +0 -0
  418. package/runtime/third_party/quickjs-regexp/LICENSE +0 -0
  419. package/runtime/third_party/quickjs-regexp/README.md +0 -0
  420. package/runtime/third_party/quickjs-regexp/cutils.c +0 -0
  421. package/runtime/third_party/quickjs-regexp/cutils.h +0 -0
  422. package/runtime/third_party/quickjs-regexp/libregexp-opcode.h +0 -0
  423. package/runtime/third_party/quickjs-regexp/libregexp.c +0 -0
  424. package/runtime/third_party/quickjs-regexp/libregexp.h +0 -0
  425. package/runtime/third_party/quickjs-regexp/libunicode-table.h +0 -0
  426. package/runtime/third_party/quickjs-regexp/libunicode.c +0 -0
  427. package/runtime/third_party/quickjs-regexp/libunicode.h +0 -0
  428. package/runtime/third_party/v8-ieee754/LICENSE +0 -0
  429. package/runtime/third_party/v8-ieee754/README.md +0 -0
  430. package/runtime/third_party/v8-ieee754/convert.py +0 -0
  431. package/runtime/third_party/v8-ieee754/ieee754.c +0 -0
  432. package/runtime/third_party/v8-ieee754/ieee754.h +0 -0
  433. package/runtime/tools/regexp_compile.c +0 -0
package/cli.js CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
- import { isBuiltin } from "node:module";
2
+ import { createRequire, isBuiltin } from "node:module";
3
3
  import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
4
4
  import { basename, delimiter, dirname, extname, isAbsolute, join, normalize, relative, resolve, sep } from "node:path";
5
- import { parseArgs } from "node:util";
5
+ import { parseArgs, promisify } from "node:util";
6
6
  import ts from "typescript";
7
7
  import { rolldown } from "rolldown";
8
- import { execFileSync, spawn, spawnSync } from "node:child_process";
8
+ import { execFile, execFileSync, spawn, spawnSync } from "node:child_process";
9
9
  import { createHash } from "node:crypto";
10
10
  import { availableParallelism, homedir, tmpdir } from "node:os";
11
11
  //#region \0rolldown/runtime.js
@@ -6661,7 +6661,7 @@ function emitModule(m, p, entry, options) {
6661
6661
  ` for (size_t i = 0; i < ${Math.max(1, nGlobals)}; i++) ${p}mod_globals[i] = JS_UNDEFINED;`,
6662
6662
  ` js_register_roots(rt, ${p}mod_globals, ${Math.max(1, nGlobals)});`,
6663
6663
  ` int status = js_run_event_loop(ctx, ${p}js_script(ctx)); /* then the microtasks (ADR 0008) */`,
6664
- ...entry ? [] : [" if (status == 0) status = js_host_exit_code(); /* process.exitCode */"],
6664
+ ...entry ? [] : [" status = js_host_exit(ctx, status); /* process's beforeExit and exit, process.exitCode */"],
6665
6665
  " js_context_free(ctx);",
6666
6666
  " js_runtime_free(rt);",
6667
6667
  " return status;",
@@ -7066,14 +7066,19 @@ function optimize(m, passes = DEFAULT_PASSES) {
7066
7066
  //#endregion
7067
7067
  //#region node/index.ts
7068
7068
  var node_exports = /* @__PURE__ */ __exportAll({
7069
+ implicitModules: () => implicitModules,
7069
7070
  libraries: () => libraries,
7070
7071
  modules: () => modules,
7071
7072
  preludeDir: () => preludeDir,
7072
- primitives: () => primitives
7073
+ primitives: () => primitives,
7074
+ requireTable: () => requireTable$1
7073
7075
  });
7074
7076
  const DIR = join(import.meta.dirname, "node");
7075
7077
  const UV = join(DIR, "third_party", "libuv");
7076
7078
  const LLHTTP = join(DIR, "third_party", "llhttp");
7079
+ const ZLIB = join(DIR, "third_party", "zlib");
7080
+ const BROTLI = join(DIR, "third_party", "brotli");
7081
+ const ZSTD = join(DIR, "third_party", "zstd");
7077
7082
  const INCLUDE = join(DIR, "include");
7078
7083
  const files = (dir, ext) => readdirSync(dir).filter((f) => f.endsWith(ext)).map((f) => join(dir, f));
7079
7084
  /** Prelude modules may import "visaljs:host". */
@@ -7083,22 +7088,28 @@ const modules = {
7083
7088
  async_hooks: join(preludeDir, "async_hooks.js"),
7084
7089
  buffer: join(preludeDir, "buffer.js"),
7085
7090
  crypto: join(preludeDir, "crypto.js"),
7091
+ diagnostics_channel: join(preludeDir, "diagnostics_channel.js"),
7086
7092
  dns: join(preludeDir, "dns.js"),
7087
7093
  "dns/promises": join(preludeDir, "dns_promises.js"),
7088
7094
  events: join(preludeDir, "events.js"),
7089
7095
  fs: join(preludeDir, "fs.js"),
7096
+ "fs/promises": join(preludeDir, "fs_promises.js"),
7090
7097
  http: join(preludeDir, "http.js"),
7091
7098
  http2: join(preludeDir, "http2.js"),
7092
7099
  module: join(preludeDir, "module.js"),
7093
7100
  net: join(preludeDir, "net.js"),
7094
7101
  os: join(preludeDir, "os.js"),
7095
7102
  path: join(preludeDir, "path.js"),
7103
+ "path/posix": join(preludeDir, "path_posix.js"),
7104
+ "path/win32": join(preludeDir, "path_win32.js"),
7096
7105
  process: join(preludeDir, "process.js"),
7097
7106
  querystring: join(preludeDir, "querystring.js"),
7098
7107
  stream: join(preludeDir, "stream.js"),
7099
7108
  "stream/promises": join(preludeDir, "stream_promises.js"),
7100
7109
  "stream/web": join(preludeDir, "stream_web.js"),
7101
7110
  string_decoder: join(preludeDir, "string_decoder.js"),
7111
+ timers: join(preludeDir, "timers.js"),
7112
+ "timers/promises": join(preludeDir, "timers_promises.js"),
7102
7113
  tls: join(preludeDir, "tls.js"),
7103
7114
  tty: join(preludeDir, "tty.js"),
7104
7115
  url: join(preludeDir, "url.js"),
@@ -7106,6 +7117,36 @@ const modules = {
7106
7117
  "util/types": join(preludeDir, "util_types.js"),
7107
7118
  zlib: join(preludeDir, "zlib.js")
7108
7119
  };
7120
+ /** Prelude modules a program gets without importing them, run before its own code, when its
7121
+ * bundled code may use what they add (`reached` tests the code's text, conservatively). */
7122
+ const implicitModules = [
7123
+ {
7124
+ file: join(preludeDir, "internal", "process_events.js"),
7125
+ reached: (code) => /\bprocess\b/.test(code) && EMITTER_METHOD.test(code)
7126
+ },
7127
+ {
7128
+ file: join(preludeDir, "internal", "process_signals.js"),
7129
+ reached: (code) => /\bprocess\b/.test(code) && /["'`]SIG[A-Z0-9]+["'`]|\.kill\b/.test(code)
7130
+ },
7131
+ {
7132
+ file: join(preludeDir, "internal", "timers_global.js"),
7133
+ reached: (code) => TIMER_USE.test(code)
7134
+ },
7135
+ {
7136
+ file: join(preludeDir, "internal", "zlib_brotli.js"),
7137
+ reached: (_code, program) => /brotli/i.test(program)
7138
+ },
7139
+ {
7140
+ file: join(preludeDir, "internal", "zlib_zstd.js"),
7141
+ reached: (_code, program) => /zstd/i.test(program)
7142
+ }
7143
+ ];
7144
+ const TIMER_USE = /\.(?:unref|hasRef|refresh)\s*\(|\bclass Timeout\b/;
7145
+ const EMITTER_METHOD = /(?:\.|\[\s*["'`])\s*(?:on|once|off|emit|addListener|prependListener|prependOnceListener|removeListener|removeAllListeners|listeners|rawListeners|listenerCount|eventNames|setMaxListeners|getMaxListeners)\b/;
7146
+ /** The table createRequire's require() looks packages up in (node:module): the Symbol.for key
7147
+ * on globalThis of a Map, name → a function giving the module's exports, which the bundler
7148
+ * sets with the packages it finds a program may require() at run time. */
7149
+ const requireTable$1 = "visaljs.requireTable";
7109
7150
  /** The host primitives: the name prelude code imports → its C function (JSNativeFn) and length.
7110
7151
  * Failures return -errno (a number), which the prelude turns into Node's error. */
7111
7152
  const primitives = {
@@ -7125,6 +7166,18 @@ const primitives = {
7125
7166
  c: "js_host_fs_unlink",
7126
7167
  length: 1
7127
7168
  },
7169
+ fsStat: {
7170
+ c: "js_host_fs_stat",
7171
+ length: 2
7172
+ },
7173
+ fsReaddir: {
7174
+ c: "js_host_fs_readdir",
7175
+ length: 1
7176
+ },
7177
+ fsReadAt: {
7178
+ c: "js_host_fs_read_at",
7179
+ length: 3
7180
+ },
7128
7181
  errnoName: {
7129
7182
  c: "js_host_errno_name",
7130
7183
  length: 1
@@ -7145,6 +7198,26 @@ const primitives = {
7145
7198
  c: "js_host_timer_unref",
7146
7199
  length: 2
7147
7200
  },
7201
+ timerStart: {
7202
+ c: "js_host_timer_start",
7203
+ length: 4
7204
+ },
7205
+ timerRef: {
7206
+ c: "js_host_timer_ref",
7207
+ length: 2
7208
+ },
7209
+ timerClear: {
7210
+ c: "js_host_timer_clear",
7211
+ length: 1
7212
+ },
7213
+ asyncContextGet: {
7214
+ c: "js_host_async_context_get",
7215
+ length: 0
7216
+ },
7217
+ asyncContextSet: {
7218
+ c: "js_host_async_context_set",
7219
+ length: 1
7220
+ },
7148
7221
  osUname: {
7149
7222
  c: "js_host_os_uname",
7150
7223
  length: 0
@@ -7189,6 +7262,18 @@ const primitives = {
7189
7262
  c: "js_host_os_constants",
7190
7263
  length: 0
7191
7264
  },
7265
+ signalStart: {
7266
+ c: "js_host_signal_start",
7267
+ length: 2
7268
+ },
7269
+ signalStop: {
7270
+ c: "js_host_signal_stop",
7271
+ length: 1
7272
+ },
7273
+ processKill: {
7274
+ c: "js_host_process_kill",
7275
+ length: 2
7276
+ },
7192
7277
  utilInspect: {
7193
7278
  c: "js_util_inspect",
7194
7279
  length: 2
@@ -7560,6 +7645,74 @@ const primitives = {
7560
7645
  dnsLookup: {
7561
7646
  c: "js_host_dns_lookup",
7562
7647
  length: 3
7648
+ },
7649
+ zlibNew: {
7650
+ c: "js_host_zlib_new",
7651
+ length: 1
7652
+ },
7653
+ zlibInit: {
7654
+ c: "js_host_zlib_init",
7655
+ length: 6
7656
+ },
7657
+ zlibWrite: {
7658
+ c: "js_host_zlib_write",
7659
+ length: 9
7660
+ },
7661
+ zlibParams: {
7662
+ c: "js_host_zlib_params",
7663
+ length: 3
7664
+ },
7665
+ zlibReset: {
7666
+ c: "js_host_zlib_reset",
7667
+ length: 1
7668
+ },
7669
+ zlibClose: {
7670
+ c: "js_host_zlib_close",
7671
+ length: 1
7672
+ },
7673
+ zlibCrc32: {
7674
+ c: "js_host_zlib_crc32",
7675
+ length: 2
7676
+ },
7677
+ brotliNew: {
7678
+ c: "js_host_brotli_new",
7679
+ length: 1
7680
+ },
7681
+ brotliInit: {
7682
+ c: "js_host_brotli_init",
7683
+ length: 2
7684
+ },
7685
+ brotliWrite: {
7686
+ c: "js_host_brotli_write",
7687
+ length: 9
7688
+ },
7689
+ brotliReset: {
7690
+ c: "js_host_brotli_reset",
7691
+ length: 1
7692
+ },
7693
+ brotliClose: {
7694
+ c: "js_host_brotli_close",
7695
+ length: 1
7696
+ },
7697
+ zstdNew: {
7698
+ c: "js_host_zstd_new",
7699
+ length: 1
7700
+ },
7701
+ zstdInit: {
7702
+ c: "js_host_zstd_init",
7703
+ length: 4
7704
+ },
7705
+ zstdWrite: {
7706
+ c: "js_host_zstd_write",
7707
+ length: 9
7708
+ },
7709
+ zstdReset: {
7710
+ c: "js_host_zstd_reset",
7711
+ length: 1
7712
+ },
7713
+ zstdClose: {
7714
+ c: "js_host_zstd_close",
7715
+ length: 1
7563
7716
  }
7564
7717
  };
7565
7718
  const UV_COMMON = [
@@ -7664,10 +7817,28 @@ const UV_PLATFORM = {
7664
7817
  ]
7665
7818
  }
7666
7819
  };
7820
+ const BROTLI_OS = {
7821
+ linux: "OS_LINUX",
7822
+ darwin: "OS_MACOSX",
7823
+ freebsd: "OS_FREEBSD"
7824
+ };
7667
7825
  /** The C libraries to build and link (before libjsrt, which they use). */
7668
7826
  function libraries(runtimeInclude) {
7669
7827
  const uv = UV_PLATFORM[process.platform];
7670
7828
  const uvSources = uv ? [...UV_COMMON, ...uv.sources].map((f) => join(UV, "src", `${f}.c`)) : [];
7829
+ const zlibHeaders = [...files(ZLIB, ".h"), ...files(join(ZLIB, "contrib", "optimizations"), ".h")];
7830
+ const brotliHeaders = [
7831
+ "common",
7832
+ "dec",
7833
+ "enc",
7834
+ join("include", "brotli")
7835
+ ].flatMap((d) => files(join(BROTLI, d), ".h"));
7836
+ const zstdHeaders = [
7837
+ "",
7838
+ "common",
7839
+ "compress",
7840
+ "decompress"
7841
+ ].flatMap((d) => files(join(ZSTD, d), ".h"));
7671
7842
  const uvHeaders = [
7672
7843
  join(UV, "include"),
7673
7844
  join(UV, "include", "uv"),
@@ -7675,37 +7846,87 @@ function libraries(runtimeInclude) {
7675
7846
  join(UV, "src", "unix"),
7676
7847
  join(UV, "src", "win")
7677
7848
  ].flatMap((d) => files(d, ".h"));
7678
- return [{
7679
- name: "jsnode",
7680
- sources: [...files(join(DIR, "src"), ".c"), ...files(LLHTTP, ".c")],
7681
- headers: [
7682
- ...files(INCLUDE, ".h"),
7683
- ...files(runtimeInclude, ".h"),
7684
- ...files(LLHTTP, ".h"),
7685
- ...uvHeaders
7686
- ],
7687
- flags: [
7688
- `-I${INCLUDE}`,
7689
- `-I${runtimeInclude}`,
7690
- `-I${LLHTTP}`,
7691
- `-I${join(UV, "include")}`
7692
- ]
7693
- }, {
7694
- name: "uv",
7695
- sources: uvSources,
7696
- headers: uvHeaders,
7697
- flags: [
7698
- "-std=gnu11",
7699
- "-w",
7700
- "-fno-strict-aliasing",
7701
- "-D_FILE_OFFSET_BITS=64",
7702
- "-D_LARGEFILE_SOURCE",
7703
- ...(uv?.defines ?? []).map((d) => `-D${d}`),
7704
- `-I${join(UV, "include")}`,
7705
- `-I${join(UV, "src")}`
7706
- ],
7707
- link: uv?.link ?? []
7708
- }];
7849
+ return [
7850
+ {
7851
+ name: "jsnode",
7852
+ sources: [...files(join(DIR, "src"), ".c"), ...files(LLHTTP, ".c")],
7853
+ headers: [
7854
+ ...files(INCLUDE, ".h"),
7855
+ ...files(runtimeInclude, ".h"),
7856
+ ...files(LLHTTP, ".h"),
7857
+ ...uvHeaders,
7858
+ ...zlibHeaders,
7859
+ ...brotliHeaders,
7860
+ ...zstdHeaders
7861
+ ],
7862
+ flags: [
7863
+ `-I${INCLUDE}`,
7864
+ `-I${runtimeInclude}`,
7865
+ `-I${LLHTTP}`,
7866
+ `-I${join(UV, "include")}`,
7867
+ `-I${ZLIB}`,
7868
+ `-I${join(BROTLI, "include")}`,
7869
+ `-I${ZSTD}`
7870
+ ]
7871
+ },
7872
+ {
7873
+ name: "zlib",
7874
+ sources: files(ZLIB, ".c"),
7875
+ headers: zlibHeaders,
7876
+ flags: [
7877
+ "-w",
7878
+ "-DCPU_NO_SIMD",
7879
+ "-DHAVE_HIDDEN",
7880
+ `-I${ZLIB}`
7881
+ ]
7882
+ },
7883
+ {
7884
+ name: "brotli",
7885
+ sources: [
7886
+ "common",
7887
+ "dec",
7888
+ "enc"
7889
+ ].flatMap((d) => files(join(BROTLI, d), ".c")),
7890
+ headers: brotliHeaders,
7891
+ flags: [
7892
+ "-w",
7893
+ ...BROTLI_OS[process.platform] ? [`-D${BROTLI_OS[process.platform]}`] : [],
7894
+ `-I${join(BROTLI, "include")}`
7895
+ ]
7896
+ },
7897
+ {
7898
+ name: "zstd",
7899
+ sources: [
7900
+ "common",
7901
+ "compress",
7902
+ "decompress"
7903
+ ].flatMap((d) => files(join(ZSTD, d), ".c")),
7904
+ headers: zstdHeaders,
7905
+ flags: [
7906
+ "-w",
7907
+ "-DXXH_NAMESPACE=ZSTD_",
7908
+ "-DZSTD_MULTITHREAD",
7909
+ "-DZSTD_DISABLE_ASM",
7910
+ `-I${ZSTD}`
7911
+ ]
7912
+ },
7913
+ {
7914
+ name: "uv",
7915
+ sources: uvSources,
7916
+ headers: uvHeaders,
7917
+ flags: [
7918
+ "-std=gnu11",
7919
+ "-w",
7920
+ "-fno-strict-aliasing",
7921
+ "-D_FILE_OFFSET_BITS=64",
7922
+ "-D_LARGEFILE_SOURCE",
7923
+ ...(uv?.defines ?? []).map((d) => `-D${d}`),
7924
+ `-I${join(UV, "include")}`,
7925
+ `-I${join(UV, "src")}`
7926
+ ],
7927
+ link: uv?.link ?? []
7928
+ }
7929
+ ];
7709
7930
  }
7710
7931
  //#endregion
7711
7932
  //#region cli/src/hosts.ts
@@ -7725,17 +7946,56 @@ function hostPrimitives(hosts) {
7725
7946
  //#region cli/src/bundle.ts
7726
7947
  /** A bundling failure, already formatted as `file:line:col: Kind: message` lines. */
7727
7948
  var BundleError = class extends Error {};
7728
- /** Bundles `entry` with the ADR 0009 configuration, `node:*` imports resolved to the host
7729
- * packages' modules. Warnings go to `warn`, with their location ("file:line:col: ", or ""). */
7730
- async function bundle(entry, hosts, warn) {
7949
+ async function bundle(entry, hosts, warn, extras = {}) {
7950
+ const rollup = (implicit, warn, required) => rollupOnce(entry, hosts, implicit, warn, required, extras);
7951
+ const b = await rollup([], warn, []);
7952
+ const program = programCode(b.code, dirname(resolve(entry)), hosts);
7953
+ const implicit = hosts.flatMap((h) => h.implicitModules ?? []).filter((m) => m.reached(b.code, program)).map((m) => m.file);
7954
+ const required = hosts.some((h) => h.requireTable) ? requiredPackages(b.code, entry, extras.requires ?? []) : [];
7955
+ if (required.length) implicit.unshift(REQUIRE_TABLE);
7956
+ return implicit.length ? rollup(implicit, () => {}, required) : b;
7957
+ }
7958
+ /** A bundle's code without its host prelude modules: rolldown marks each module's code with
7959
+ * `//#region <path, relative to cwd>` … `//#endregion`. */
7960
+ function programCode(code, cwd, hosts) {
7961
+ const preludes = hosts.map((h) => h.preludeDir + sep);
7962
+ return code.replace(/^\/\/#region (.*)\n[^]*?^\/\/#endregion$/gm, (region, path) => preludes.some((dir) => resolve(cwd, path).startsWith(dir)) ? "" : region);
7963
+ }
7964
+ /** The packages a bundle names in a call the bundler couldn't follow as a require() (and those
7965
+ * `given`):
7966
+ * ``a(`react-dom`)``, where `a` is a bundle's createRequire(import.meta.url) (Vite's, for the
7967
+ * packages it left external). Only in code that calls createRequire; a call of a plain name with
7968
+ * one string, naming a package (not a built-in) that resolves from the entry. A call that isn't a
7969
+ * require() but names an installed package bundles it needlessly: the build lists them. */
7970
+ function requiredPackages(code, entry, given) {
7971
+ if (!/\bcreateRequire\s*\(/.test(code)) return [];
7972
+ const require = createRequire(resolve(entry));
7973
+ const names = /* @__PURE__ */ new Set();
7974
+ const called = code.matchAll(/(?<![.\w$])[\w$]+\s*\(\s*(["'`])((?:@[a-z0-9][\w.-]*\/)?[a-z0-9][\w.-]*(?:\/[\w.-]+)*)\1\s*\)/g);
7975
+ for (const name of [...given, ...Array.from(called, (m) => m[2])]) {
7976
+ if (names.has(name) || isBuiltin(name)) continue;
7977
+ try {
7978
+ require.resolve(name);
7979
+ names.add(name);
7980
+ } catch {}
7981
+ }
7982
+ return [...names].sort();
7983
+ }
7984
+ async function rollupOnce(entry, hosts, implicit, warn, required, extras) {
7731
7985
  try {
7732
7986
  const build = await rolldown({
7733
- input: resolve(entry),
7987
+ input: implicit.length ? IMPLICIT_ENTRY : resolve(entry),
7734
7988
  cwd: dirname(resolve(entry)),
7735
7989
  platform: "node",
7736
7990
  logLevel: "warn",
7737
7991
  onLog: (_level, log) => log.code !== "EVAL" && warn(logText(log), logWhere(log)),
7738
- plugins: [hostModules(hosts)]
7992
+ plugins: [
7993
+ hostModules(hosts),
7994
+ implicitEntry(entry, implicit),
7995
+ requireTable(hosts, required),
7996
+ ...generatedEntry(entry, extras.source),
7997
+ ...extras.plugins ?? []
7998
+ ]
7739
7999
  });
7740
8000
  try {
7741
8001
  const { output } = await build.generate({
@@ -7750,7 +8010,8 @@ async function bundle(entry, hosts, warn) {
7750
8010
  return {
7751
8011
  code: chunk.code,
7752
8012
  map: chunk.map?.toString() ?? "",
7753
- modules: chunk.moduleIds.filter((id) => !id.startsWith("\0")).length
8013
+ modules: chunk.moduleIds.filter((id) => !id.startsWith("\0")).length,
8014
+ required: [...required]
7754
8015
  };
7755
8016
  } finally {
7756
8017
  await build.close();
@@ -7783,6 +8044,7 @@ function hostModules(hosts) {
7783
8044
  if (!source.startsWith("node:") && !isBuiltin(source)) return null;
7784
8045
  const name = source.replace(/^node:/, "");
7785
8046
  const file = Object.hasOwn(modules, name) ? modules[name] : void 0;
8047
+ if (file && importer === ROLLDOWN_RUNTIME) return RUNTIME_COPY + file;
7786
8048
  if (file) return kind === "require-call" ? REQUIRED + file : file;
7787
8049
  const provided = Object.keys(modules).sort().map((m) => `node:${m}`).join(", ");
7788
8050
  this.error({
@@ -7791,17 +8053,50 @@ function hostModules(hosts) {
7791
8053
  });
7792
8054
  },
7793
8055
  load(id) {
8056
+ if (id.startsWith(RUNTIME_COPY)) return readFileSync(id.slice(RUNTIME_COPY.length), "utf8");
7794
8057
  if (!id.startsWith(REQUIRED)) return null;
7795
8058
  return `const ns = require(${JSON.stringify(id.slice(REQUIRED.length))});
7796
8059
  const m = ns.default;
7797
- for (const k of Object.keys(ns)) if (k !== "default" && !Object.hasOwn(m, k)) m[k] = ns[k];
8060
+ for (const k of Object.keys(ns)) if (k !== "default" && !(k in m)) m[k] = ns[k];
7798
8061
  module.exports = m;
7799
8062
  `;
7800
8063
  }
7801
8064
  };
7802
8065
  }
8066
+ /** The entry when the program gets implicit modules: they, then the program's entry. */
8067
+ const IMPLICIT_ENTRY = "\0visaljs-entry";
8068
+ function implicitEntry(entry, implicit) {
8069
+ return {
8070
+ name: "visaljs-implicit",
8071
+ resolveId: (source) => source === IMPLICIT_ENTRY ? source : null,
8072
+ load: (id) => id === IMPLICIT_ENTRY ? [...implicit, resolve(entry)].map((f) => `import ${JSON.stringify(f)};\n`).join("") : null
8073
+ };
8074
+ }
8075
+ /** A generated entry: `entry`'s path (its imports resolve from there), `source` its code. */
8076
+ function generatedEntry(entry, source) {
8077
+ if (source === void 0) return [];
8078
+ const id = resolve(entry);
8079
+ return [{
8080
+ name: "visaljs-generated-entry",
8081
+ resolveId: (s) => s === id ? id : null,
8082
+ load: (i) => i === id ? source : null
8083
+ }];
8084
+ }
8085
+ /** The module that registers the packages a require() made at run time reaches: run first. */
8086
+ const REQUIRE_TABLE = "\0visaljs-require-table";
8087
+ function requireTable(hosts, required) {
8088
+ const table = hosts.findLast((h) => h.requireTable)?.requireTable;
8089
+ return {
8090
+ name: "visaljs-require-table",
8091
+ resolveId: (source) => source === REQUIRE_TABLE ? source : null,
8092
+ load: (id) => id === REQUIRE_TABLE && table ? `Object.defineProperty(globalThis, Symbol.for(${JSON.stringify(table)}), { value: new Map([\n` + required.map((name) => ` [${JSON.stringify(name)}, () => require(${JSON.stringify(name)})],\n`).join("") + "]) });\n" : null
8093
+ };
8094
+ }
7803
8095
  /** The prefix of the CommonJS module a require() of a built-in resolves to (hostModules.load). */
7804
8096
  const REQUIRED = "\0visaljs-require:";
8097
+ /** rolldown's runtime helpers, and the prefix of the copy of a host module they import (hostModules). */
8098
+ const ROLLDOWN_RUNTIME = "\0rolldown/runtime.js";
8099
+ const RUNTIME_COPY = "\0visaljs-runtime:";
7805
8100
  /** rolldown's messages carry ANSI colors and a code frame: keep the first line, without the `[CODE]` tag. */
7806
8101
  function formatLog(log, kind) {
7807
8102
  return `${logWhere(log)}${kind}: ${logText(log)}`;
@@ -8153,6 +8448,89 @@ function packageOf(file) {
8153
8448
  return name.startsWith("@") && i + 2 < parts.length ? `${name}/${parts[i + 2]}` : name;
8154
8449
  }
8155
8450
  //#endregion
8451
+ //#region cli/src/frameworks/vinext.ts
8452
+ /** The project's package.json's dependencies and devDependencies. */
8453
+ function dependencies(root) {
8454
+ const file = join(root, "package.json");
8455
+ if (!existsSync(file)) return {};
8456
+ const pkg = JSON.parse(readFileSync(file, "utf8"));
8457
+ return {
8458
+ ...pkg.devDependencies,
8459
+ ...pkg.dependencies
8460
+ };
8461
+ }
8462
+ /** The script a package installed in the project runs as `name` (its package.json's "bin"). */
8463
+ function packageBin(root, pkg, name) {
8464
+ let manifest;
8465
+ try {
8466
+ manifest = createRequire(join(root, "package.json")).resolve(`${pkg}/package.json`);
8467
+ } catch {
8468
+ throw new FrameworkError(`${pkg} isn't installed in ${root}: run npm install first`);
8469
+ }
8470
+ const { bin } = JSON.parse(readFileSync(manifest, "utf8"));
8471
+ const script = typeof bin === "string" ? bin : bin?.[name];
8472
+ if (!script) throw new FrameworkError(`${pkg} has no ${name} command`);
8473
+ return join(dirname(manifest), script);
8474
+ }
8475
+ const MARKER = join("dist", "server", "vinext-server.json");
8476
+ const BUILD_ENTRIES = ["dist/server/index.js", "dist/server/entry.js"];
8477
+ const vinext = {
8478
+ name: "vinext",
8479
+ detect: (root) => "vinext" in dependencies(root),
8480
+ async build(root) {
8481
+ const vite = packageBin(root, "vite", "vite");
8482
+ try {
8483
+ await promisify(execFile)(process.execPath, [vite, "build"], {
8484
+ cwd: root,
8485
+ maxBuffer: 64 << 20,
8486
+ env: {
8487
+ ...process.env,
8488
+ FORCE_COLOR: "0"
8489
+ }
8490
+ });
8491
+ } catch (e) {
8492
+ const { stdout = "", stderr = "" } = e;
8493
+ throw new FrameworkError(`vite build failed in ${root}:\n${`${stdout}${stderr}`.trimEnd().split("\n").slice(-30).join("\n")}`);
8494
+ }
8495
+ return "Built the app with vite build (dist/)";
8496
+ },
8497
+ entry(root) {
8498
+ if (!existsSync(join(root, MARKER))) throw new FrameworkError(`${root} has no vinext build (no ${MARKER}): run \`vite build\`, or build without --no-framework-build`);
8499
+ return "import { startProdServer } from \"vinext/server/prod-server\";\nawait startProdServer();\n";
8500
+ },
8501
+ plugins(root) {
8502
+ const choose = BUILD_ENTRIES.filter((f) => existsSync(join(root, f))).map((f) => `entryPath.replaceAll("\\\\", "/").endsWith(${JSON.stringify("/" + f)}) ? import(${JSON.stringify(join(root, f))}) : `).join("");
8503
+ return [{
8504
+ name: "visaljs-vinext",
8505
+ transform: {
8506
+ filter: { id: /[\\/]vinext[\\/]dist[\\/]server[\\/]prod-server\.js$/ },
8507
+ handler(code) {
8508
+ const call = "import(resolveServerEntryImportUrl(entryPath))";
8509
+ if (!code.includes(call)) this.error("vinext's prod-server.js no longer imports its build as visaljs expects: this vinext version isn't supported yet");
8510
+ return {
8511
+ code: code.replace(call, `(${choose}Promise.reject(new Error("visaljs: the build has no " + entryPath)))`),
8512
+ map: null
8513
+ };
8514
+ }
8515
+ }
8516
+ }];
8517
+ },
8518
+ requires(root) {
8519
+ const file = join(root, "dist", "server", "vinext-externals.json");
8520
+ return existsSync(file) ? JSON.parse(readFileSync(file, "utf8")) : [];
8521
+ },
8522
+ notes: () => ["It serves ./dist under the working directory, as `vinext start` does: run it from the project"]
8523
+ };
8524
+ //#endregion
8525
+ //#region cli/src/frameworks/index.ts
8526
+ /** A framework's failure, as the message to print. */
8527
+ var FrameworkError = class extends Error {};
8528
+ const FRAMEWORKS = [vinext];
8529
+ /** The framework of the project in `root`, or undefined. */
8530
+ function detectFramework(root) {
8531
+ return FRAMEWORKS.find((f) => f.detect(root));
8532
+ }
8533
+ //#endregion
8156
8534
  //#region cli/src/regexp.ts
8157
8535
  /** The program's regex literals, in source order. */
8158
8536
  function regexpLiterals(program) {
@@ -8316,8 +8694,11 @@ function lineCount(text) {
8316
8694
  }
8317
8695
  //#endregion
8318
8696
  //#region cli/src/main.ts
8319
- const VERSION = "0.0.5";
8320
- const USAGE = `usage: visaljs build <entry.js> [options]
8697
+ const VERSION = "0.0.6";
8698
+ const USAGE = `usage: visaljs build [entry.js | project directory] [options]
8699
+
8700
+ A project (the current directory when none is given) builds its framework's production server: a
8701
+ vinext app is built with its own \`vite build\` first, then its server is compiled.
8321
8702
 
8322
8703
  options:
8323
8704
  -o <file> output binary
@@ -8328,6 +8709,7 @@ options:
8328
8709
  --embed-source embed the source text: Function.prototype.toString returns it
8329
8710
  --all-builtins install every built-in, not only those the program names
8330
8711
  --no-bundle skip the bundler: the input is one ES module (a bundle)
8712
+ --no-framework-build a project: compile its existing build output, without building it first
8331
8713
  --script compile as a classic script (sloppy mode, no bundler)
8332
8714
  -q, --quiet don't report each step of the build
8333
8715
  --verbose list each place a warning is about
@@ -8353,6 +8735,7 @@ async function main(argv, io) {
8353
8735
  "embed-source": { type: "boolean" },
8354
8736
  "all-builtins": { type: "boolean" },
8355
8737
  "no-bundle": { type: "boolean" },
8738
+ "no-framework-build": { type: "boolean" },
8356
8739
  script: { type: "boolean" },
8357
8740
  quiet: {
8358
8741
  type: "boolean",
@@ -8382,29 +8765,61 @@ async function main(argv, io) {
8382
8765
  const [command, ...rest] = positionals;
8383
8766
  switch (command) {
8384
8767
  case "build":
8385
- if (rest.length !== 1) {
8386
- io.stderr(`visaljs build: expected one entry file\n${USAGE}`);
8768
+ if (rest.length > 1) {
8769
+ io.stderr(`visaljs build: expected one entry file or project directory\n${USAGE}`);
8387
8770
  return 2;
8388
8771
  }
8389
- return await build(rest[0], values, io);
8772
+ return await build(rest[0] ?? ".", values, io);
8390
8773
  default:
8391
8774
  io.stderr(`visaljs: unknown command '${command}'\n${USAGE}`);
8392
8775
  return 2;
8393
8776
  }
8394
8777
  }
8395
8778
  async function build(entry, options, io) {
8396
- let source;
8397
- try {
8779
+ let framework;
8780
+ let source = "";
8781
+ if (statSync(entry, { throwIfNoEntry: false })?.isDirectory()) {
8782
+ const root = resolve(entry);
8783
+ const fw = detectFramework(root);
8784
+ if (!fw) {
8785
+ io.stderr(`visaljs: ${entry === "." ? "the current directory" : entry} isn't a project of a framework visaljs knows (${FRAMEWORKS.map((f) => f.name).join(", ")}): give an entry file\n`);
8786
+ return 1;
8787
+ }
8788
+ framework = {
8789
+ fw,
8790
+ root
8791
+ };
8792
+ entry = join(root, "visaljs-entry.js");
8793
+ } else try {
8398
8794
  source = readFileSync(entry, "utf8");
8399
8795
  } catch (e) {
8400
8796
  io.stderr(`visaljs: cannot read ${entry}: ${e.message}\n`);
8401
8797
  return 1;
8402
8798
  }
8403
8799
  const dump = options["dump-ast"] === true || options["dump-ir"] === true;
8404
- const report = new Report(io.stderr, options.quiet || dump ? void 0 : io.report);
8800
+ const style = options.quiet || dump ? void 0 : io.report;
8801
+ const report = new Report(io.stderr, style);
8405
8802
  const binary = !dump && !options["emit-c"];
8406
8803
  const hosts = DEFAULT_HOSTS;
8407
8804
  const primitives = hostPrimitives(hosts);
8805
+ let frameworkExtras = {};
8806
+ if (framework) {
8807
+ const { fw, root } = framework;
8808
+ if (style) report.note(` 🧭 A ${fw.name} app: compiling its production server`);
8809
+ try {
8810
+ if (fw.build && options["no-framework-build"] !== true) await report.step("🏗️ ", `Building the ${fw.name} app`, () => fw.build(root), (what) => what);
8811
+ source = fw.entry(root);
8812
+ } catch (e) {
8813
+ if (!(e instanceof FrameworkError)) throw e;
8814
+ io.stderr(`visaljs: ${e.message}\n`);
8815
+ return 1;
8816
+ }
8817
+ frameworkExtras = {
8818
+ source,
8819
+ plugins: fw.plugins?.(root) ?? [],
8820
+ requires: fw.requires?.(root) ?? []
8821
+ };
8822
+ }
8408
8823
  let compilers;
8409
8824
  if (binary) try {
8410
8825
  compilers = await report.step("🔍", "Detecting C compilers", findCompilers, detected);
@@ -8416,7 +8831,7 @@ async function build(entry, options, io) {
8416
8831
  const bundled = !script && options["no-bundle"] !== true;
8417
8832
  let map;
8418
8833
  if (bundled) try {
8419
- const b = await report.step("📦", "Rolling the modules into a single file", () => bundle(entry, hosts, (message, where) => report.warn(message, where)), (b) => `Rolled ${count(b.modules, "module")} into a single file (${size(Buffer.byteLength(b.code))})`);
8834
+ const b = await report.step("📦", "Rolling the modules into a single file", () => bundle(entry, hosts, (message, where) => report.warn(message, where), frameworkExtras), (b) => `Rolled ${count(b.modules, "module")} into a single file (${size(Buffer.byteLength(b.code))})` + (b.required.length ? `; for a require() at run time: ${b.required.join(", ")}` : ""));
8420
8835
  source = b.code;
8421
8836
  if (b.map) map = new SourceMap(b.map, displayPath);
8422
8837
  } catch (e) {
@@ -8464,7 +8879,7 @@ async function build(entry, options, io) {
8464
8879
  report.finish("📂", (time) => `Wrote ${displayPath(resolve(options["emit-c"], "program.c"))} in ${time}`);
8465
8880
  return 0;
8466
8881
  }
8467
- let output = options.output ?? basename(entry).replace(/\.[cm]?js$/, "");
8882
+ let output = options.output ?? (framework ? join(framework.root, basename(framework.root)) : basename(entry).replace(/\.[cm]?js$/, ""));
8468
8883
  if (process.platform === "win32" && !extname(output)) output += ".exe";
8469
8884
  const opt = options.debug ? ["-O0"] : ["-O2"];
8470
8885
  const dir = scratchDir();
@@ -8495,6 +8910,7 @@ async function build(entry, options, io) {
8495
8910
  }
8496
8911
  const bytes = statSync(output).size;
8497
8912
  report.finish("🎉", (time) => `Built ${displayPath(resolve(output))} in ${time}: ${size(bytes)}, ${sizeQuip(bytes)}`);
8913
+ if (framework?.fw.notes && style) for (const note of framework.fw.notes(framework.root)) report.note(` • ${note}`);
8498
8914
  return 0;
8499
8915
  }
8500
8916
  /** "Detected GCC 13.3.0", else the compilers numbered in the order they're tried, under the