@volter/tabnode 0.2.14-volter.88

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 (429) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +78 -0
  3. package/THIRD-PARTY-NOTICES.md +12 -0
  4. package/dist/__sw__.js +526 -0
  5. package/dist/assets/runtime-worker-4MKaHFVb.js +75221 -0
  6. package/dist/assets/runtime-worker-4MKaHFVb.js.map +1 -0
  7. package/dist/code-transforms.d.ts +21 -0
  8. package/dist/code-transforms.d.ts.map +1 -0
  9. package/dist/config/cdn.d.ts +12 -0
  10. package/dist/config/cdn.d.ts.map +1 -0
  11. package/dist/create-runtime.d.ts +22 -0
  12. package/dist/create-runtime.d.ts.map +1 -0
  13. package/dist/host-globals.d.ts +62 -0
  14. package/dist/host-globals.d.ts.map +1 -0
  15. package/dist/index.cjs +36021 -0
  16. package/dist/index.cjs.map +1 -0
  17. package/dist/index.d.ts +127 -0
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/index.mjs +36020 -0
  20. package/dist/index.mjs.map +1 -0
  21. package/dist/node-internals.d.ts +68 -0
  22. package/dist/node-internals.d.ts.map +1 -0
  23. package/dist/node-lib/binding/blob.d.ts +12 -0
  24. package/dist/node-lib/binding/blob.d.ts.map +1 -0
  25. package/dist/node-lib/binding/buffer.d.ts +144 -0
  26. package/dist/node-lib/binding/buffer.d.ts.map +1 -0
  27. package/dist/node-lib/binding/cares_wrap.d.ts +14 -0
  28. package/dist/node-lib/binding/cares_wrap.d.ts.map +1 -0
  29. package/dist/node-lib/binding/fds.d.ts +30 -0
  30. package/dist/node-lib/binding/fds.d.ts.map +1 -0
  31. package/dist/node-lib/binding/fs.d.ts +157 -0
  32. package/dist/node-lib/binding/fs.d.ts.map +1 -0
  33. package/dist/node-lib/binding/handles.d.ts +81 -0
  34. package/dist/node-lib/binding/handles.d.ts.map +1 -0
  35. package/dist/node-lib/binding/http_parser.d.ts +122 -0
  36. package/dist/node-lib/binding/http_parser.d.ts.map +1 -0
  37. package/dist/node-lib/binding/index.d.ts +3 -0
  38. package/dist/node-lib/binding/index.d.ts.map +1 -0
  39. package/dist/node-lib/binding/llhttp-wasm.d.ts +22 -0
  40. package/dist/node-lib/binding/llhttp-wasm.d.ts.map +1 -0
  41. package/dist/node-lib/binding/misc.d.ts +123 -0
  42. package/dist/node-lib/binding/misc.d.ts.map +1 -0
  43. package/dist/node-lib/binding/pipe_wrap.d.ts +84 -0
  44. package/dist/node-lib/binding/pipe_wrap.d.ts.map +1 -0
  45. package/dist/node-lib/binding/process_wrap.d.ts +173 -0
  46. package/dist/node-lib/binding/process_wrap.d.ts.map +1 -0
  47. package/dist/node-lib/binding/spawn_sync.d.ts +30 -0
  48. package/dist/node-lib/binding/spawn_sync.d.ts.map +1 -0
  49. package/dist/node-lib/binding/stream_wrap.d.ts +191 -0
  50. package/dist/node-lib/binding/stream_wrap.d.ts.map +1 -0
  51. package/dist/node-lib/binding/stubs.d.ts +23 -0
  52. package/dist/node-lib/binding/stubs.d.ts.map +1 -0
  53. package/dist/node-lib/binding/tcp_wrap.d.ts +98 -0
  54. package/dist/node-lib/binding/tcp_wrap.d.ts.map +1 -0
  55. package/dist/node-lib/binding/tty_wrap.d.ts +36 -0
  56. package/dist/node-lib/binding/tty_wrap.d.ts.map +1 -0
  57. package/dist/node-lib/binding/util.d.ts +126 -0
  58. package/dist/node-lib/binding/util.d.ts.map +1 -0
  59. package/dist/node-lib/binding/uv.d.ts +32 -0
  60. package/dist/node-lib/binding/uv.d.ts.map +1 -0
  61. package/dist/node-lib/binding/zlib-pako.d.ts +22 -0
  62. package/dist/node-lib/binding/zlib-pako.d.ts.map +1 -0
  63. package/dist/node-lib/binding/zlib.d.ts +38 -0
  64. package/dist/node-lib/binding/zlib.d.ts.map +1 -0
  65. package/dist/node-lib/buffer-module.d.ts +51 -0
  66. package/dist/node-lib/buffer-module.d.ts.map +1 -0
  67. package/dist/node-lib/child-process-module.d.ts +26 -0
  68. package/dist/node-lib/child-process-module.d.ts.map +1 -0
  69. package/dist/node-lib/events-module.d.ts +58 -0
  70. package/dist/node-lib/events-module.d.ts.map +1 -0
  71. package/dist/node-lib/fs-module.d.ts +5 -0
  72. package/dist/node-lib/fs-module.d.ts.map +1 -0
  73. package/dist/node-lib/http-bridge.d.ts +43 -0
  74. package/dist/node-lib/http-bridge.d.ts.map +1 -0
  75. package/dist/node-lib/http-module.d.ts +35 -0
  76. package/dist/node-lib/http-module.d.ts.map +1 -0
  77. package/dist/node-lib/internals/addresses.d.ts +40 -0
  78. package/dist/node-lib/internals/addresses.d.ts.map +1 -0
  79. package/dist/node-lib/internals/buffer-and-streams.d.ts +96 -0
  80. package/dist/node-lib/internals/buffer-and-streams.d.ts.map +1 -0
  81. package/dist/node-lib/internals/child-process.d.ts +27 -0
  82. package/dist/node-lib/internals/child-process.d.ts.map +1 -0
  83. package/dist/node-lib/internals/events-util.d.ts +83 -0
  84. package/dist/node-lib/internals/events-util.d.ts.map +1 -0
  85. package/dist/node-lib/internals/index.d.ts +2 -0
  86. package/dist/node-lib/internals/index.d.ts.map +1 -0
  87. package/dist/node-lib/internals/modules.d.ts +67 -0
  88. package/dist/node-lib/internals/modules.d.ts.map +1 -0
  89. package/dist/node-lib/internals/readline-access.d.ts +2 -0
  90. package/dist/node-lib/internals/readline-access.d.ts.map +1 -0
  91. package/dist/node-lib/internals/runtime.d.ts +150 -0
  92. package/dist/node-lib/internals/runtime.d.ts.map +1 -0
  93. package/dist/node-lib/internals/util.d.ts +33 -0
  94. package/dist/node-lib/internals/util.d.ts.map +1 -0
  95. package/dist/node-lib/lazy.d.ts +31 -0
  96. package/dist/node-lib/lazy.d.ts.map +1 -0
  97. package/dist/node-lib/load.d.ts +27 -0
  98. package/dist/node-lib/load.d.ts.map +1 -0
  99. package/dist/node-lib/module-hooks.d.ts +89 -0
  100. package/dist/node-lib/module-hooks.d.ts.map +1 -0
  101. package/dist/node-lib/net-module.d.ts +181 -0
  102. package/dist/node-lib/net-module.d.ts.map +1 -0
  103. package/dist/node-lib/node-versions.d.ts +27 -0
  104. package/dist/node-lib/node-versions.d.ts.map +1 -0
  105. package/dist/node-lib/public-modules.d.ts +2 -0
  106. package/dist/node-lib/public-modules.d.ts.map +1 -0
  107. package/dist/node-lib/require-hook.d.ts +15 -0
  108. package/dist/node-lib/require-hook.d.ts.map +1 -0
  109. package/dist/node-lib/small-modules.d.ts +16 -0
  110. package/dist/node-lib/small-modules.d.ts.map +1 -0
  111. package/dist/node-lib/sources.d.ts +4 -0
  112. package/dist/node-lib/sources.d.ts.map +1 -0
  113. package/dist/node-lib/stream-module.d.ts +77 -0
  114. package/dist/node-lib/stream-module.d.ts.map +1 -0
  115. package/dist/node-lib/timers.d.ts +19 -0
  116. package/dist/node-lib/timers.d.ts.map +1 -0
  117. package/dist/node-lib/util-module.d.ts +76 -0
  118. package/dist/node-lib/util-module.d.ts.map +1 -0
  119. package/dist/node-resolution.d.ts +50 -0
  120. package/dist/node-resolution.d.ts.map +1 -0
  121. package/dist/node-resolver.d.ts +7 -0
  122. package/dist/node-resolver.d.ts.map +1 -0
  123. package/dist/npm/index.d.ts +73 -0
  124. package/dist/npm/index.d.ts.map +1 -0
  125. package/dist/npm/registry.d.ts +111 -0
  126. package/dist/npm/registry.d.ts.map +1 -0
  127. package/dist/npm/resolver.d.ts +79 -0
  128. package/dist/npm/resolver.d.ts.map +1 -0
  129. package/dist/npm/tarball.d.ts +28 -0
  130. package/dist/npm/tarball.d.ts.map +1 -0
  131. package/dist/process-tokens.d.ts +77 -0
  132. package/dist/process-tokens.d.ts.map +1 -0
  133. package/dist/punycode-source.d.ts +3 -0
  134. package/dist/punycode-source.d.ts.map +1 -0
  135. package/dist/runtime-interface.d.ts +74 -0
  136. package/dist/runtime-interface.d.ts.map +1 -0
  137. package/dist/runtime.d.ts +144 -0
  138. package/dist/runtime.d.ts.map +1 -0
  139. package/dist/server-bridge.d.ts +147 -0
  140. package/dist/server-bridge.d.ts.map +1 -0
  141. package/dist/shims/async_hooks.d.ts +50 -0
  142. package/dist/shims/async_hooks.d.ts.map +1 -0
  143. package/dist/shims/child_process.d.ts +104 -0
  144. package/dist/shims/child_process.d.ts.map +1 -0
  145. package/dist/shims/cluster.d.ts +52 -0
  146. package/dist/shims/cluster.d.ts.map +1 -0
  147. package/dist/shims/command-line.d.ts +43 -0
  148. package/dist/shims/command-line.d.ts.map +1 -0
  149. package/dist/shims/constants.d.ts +222 -0
  150. package/dist/shims/constants.d.ts.map +1 -0
  151. package/dist/shims/crypto-constants.d.ts +12 -0
  152. package/dist/shims/crypto-constants.d.ts.map +1 -0
  153. package/dist/shims/crypto.d.ts +144 -0
  154. package/dist/shims/crypto.d.ts.map +1 -0
  155. package/dist/shims/dgram.d.ts +34 -0
  156. package/dist/shims/dgram.d.ts.map +1 -0
  157. package/dist/shims/dns.d.ts +91 -0
  158. package/dist/shims/dns.d.ts.map +1 -0
  159. package/dist/shims/domain.d.ts +25 -0
  160. package/dist/shims/domain.d.ts.map +1 -0
  161. package/dist/shims/esbuild.d.ts +205 -0
  162. package/dist/shims/esbuild.d.ts.map +1 -0
  163. package/dist/shims/fs.d.ts +25 -0
  164. package/dist/shims/fs.d.ts.map +1 -0
  165. package/dist/shims/http2.d.ts +81 -0
  166. package/dist/shims/http2.d.ts.map +1 -0
  167. package/dist/shims/inspector.d.ts +25 -0
  168. package/dist/shims/inspector.d.ts.map +1 -0
  169. package/dist/shims/module.d.ts +22 -0
  170. package/dist/shims/module.d.ts.map +1 -0
  171. package/dist/shims/os.d.ts +159 -0
  172. package/dist/shims/os.d.ts.map +1 -0
  173. package/dist/shims/path.d.ts +52 -0
  174. package/dist/shims/path.d.ts.map +1 -0
  175. package/dist/shims/perf_hooks.d.ts +50 -0
  176. package/dist/shims/perf_hooks.d.ts.map +1 -0
  177. package/dist/shims/process.d.ts +226 -0
  178. package/dist/shims/process.d.ts.map +1 -0
  179. package/dist/shims/rollup.d.ts +71 -0
  180. package/dist/shims/rollup.d.ts.map +1 -0
  181. package/dist/shims/string_decoder.d.ts +41 -0
  182. package/dist/shims/string_decoder.d.ts.map +1 -0
  183. package/dist/shims/sync-child.d.ts +64 -0
  184. package/dist/shims/sync-child.d.ts.map +1 -0
  185. package/dist/shims/tls.d.ts +53 -0
  186. package/dist/shims/tls.d.ts.map +1 -0
  187. package/dist/shims/url.d.ts +84 -0
  188. package/dist/shims/url.d.ts.map +1 -0
  189. package/dist/shims/v8.d.ts +73 -0
  190. package/dist/shims/v8.d.ts.map +1 -0
  191. package/dist/shims/vfs-adapter.d.ts +126 -0
  192. package/dist/shims/vfs-adapter.d.ts.map +1 -0
  193. package/dist/shims/vm.d.ts +52 -0
  194. package/dist/shims/vm.d.ts.map +1 -0
  195. package/dist/shims/wasi.d.ts +78 -0
  196. package/dist/shims/wasi.d.ts.map +1 -0
  197. package/dist/shims/worker_threads.d.ts +66 -0
  198. package/dist/shims/worker_threads.d.ts.map +1 -0
  199. package/dist/shims/zlib-constants.d.ts +66 -0
  200. package/dist/shims/zlib-constants.d.ts.map +1 -0
  201. package/dist/shims/zlib.d.ts +102 -0
  202. package/dist/shims/zlib.d.ts.map +1 -0
  203. package/dist/transform.d.ts +24 -0
  204. package/dist/transform.d.ts.map +1 -0
  205. package/dist/types/package-json.d.ts +18 -0
  206. package/dist/types/package-json.d.ts.map +1 -0
  207. package/dist/utils/binary-encoding.d.ts +13 -0
  208. package/dist/utils/binary-encoding.d.ts.map +1 -0
  209. package/dist/utils/glob.d.ts +19 -0
  210. package/dist/utils/glob.d.ts.map +1 -0
  211. package/dist/utils/hash.d.ts +6 -0
  212. package/dist/utils/hash.d.ts.map +1 -0
  213. package/dist/virtual-fs.d.ts +259 -0
  214. package/dist/virtual-fs.d.ts.map +1 -0
  215. package/dist/vite-plugin.cjs +50 -0
  216. package/dist/vite-plugin.cjs.map +1 -0
  217. package/dist/vite-plugin.d.ts +36 -0
  218. package/dist/vite-plugin.d.ts.map +1 -0
  219. package/dist/vite-plugin.mjs +31 -0
  220. package/dist/vite-plugin.mjs.map +1 -0
  221. package/dist/worker/runtime-worker.d.ts +8 -0
  222. package/dist/worker/runtime-worker.d.ts.map +1 -0
  223. package/dist/worker-runtime.d.ts +50 -0
  224. package/dist/worker-runtime.d.ts.map +1 -0
  225. package/package.json +88 -0
  226. package/src/code-transforms.ts +560 -0
  227. package/src/config/cdn.ts +13 -0
  228. package/src/create-runtime.ts +89 -0
  229. package/src/host-globals.ts +121 -0
  230. package/src/index.ts +235 -0
  231. package/src/node-internals.ts +283 -0
  232. package/src/node-lib/LICENSE +47 -0
  233. package/src/node-lib/_http_agent.js +547 -0
  234. package/src/node-lib/_http_client.js +996 -0
  235. package/src/node-lib/_http_common.js +269 -0
  236. package/src/node-lib/_http_incoming.js +453 -0
  237. package/src/node-lib/_http_outgoing.js +1262 -0
  238. package/src/node-lib/_http_server.js +1230 -0
  239. package/src/node-lib/assert/strict.js +3 -0
  240. package/src/node-lib/assert.js +844 -0
  241. package/src/node-lib/binding/blob.ts +35 -0
  242. package/src/node-lib/binding/buffer.ts +465 -0
  243. package/src/node-lib/binding/cares_wrap.ts +57 -0
  244. package/src/node-lib/binding/fds.ts +80 -0
  245. package/src/node-lib/binding/fs.ts +857 -0
  246. package/src/node-lib/binding/handles.ts +187 -0
  247. package/src/node-lib/binding/http_parser.ts +536 -0
  248. package/src/node-lib/binding/index.ts +77 -0
  249. package/src/node-lib/binding/llhttp-wasm.ts +670 -0
  250. package/src/node-lib/binding/misc.ts +252 -0
  251. package/src/node-lib/binding/pipe_wrap.ts +166 -0
  252. package/src/node-lib/binding/process_wrap.ts +371 -0
  253. package/src/node-lib/binding/spawn_sync.ts +141 -0
  254. package/src/node-lib/binding/stream_wrap.ts +413 -0
  255. package/src/node-lib/binding/stubs.ts +19 -0
  256. package/src/node-lib/binding/tcp_wrap.ts +254 -0
  257. package/src/node-lib/binding/tty_wrap.ts +56 -0
  258. package/src/node-lib/binding/util.ts +274 -0
  259. package/src/node-lib/binding/uv.ts +102 -0
  260. package/src/node-lib/binding/zlib-pako.ts +50 -0
  261. package/src/node-lib/binding/zlib.ts +259 -0
  262. package/src/node-lib/buffer-module.ts +70 -0
  263. package/src/node-lib/buffer.js +1373 -0
  264. package/src/node-lib/child-process-module.ts +58 -0
  265. package/src/node-lib/child_process.js +1046 -0
  266. package/src/node-lib/constants.js +41 -0
  267. package/src/node-lib/diagnostics_channel.js +438 -0
  268. package/src/node-lib/events-module.ts +80 -0
  269. package/src/node-lib/events.js +1223 -0
  270. package/src/node-lib/fs-module.ts +43 -0
  271. package/src/node-lib/fs.js +3377 -0
  272. package/src/node-lib/http-bridge.ts +299 -0
  273. package/src/node-lib/http-module.ts +53 -0
  274. package/src/node-lib/http.js +198 -0
  275. package/src/node-lib/https.js +429 -0
  276. package/src/node-lib/internal/assert/assertion_error.js +417 -0
  277. package/src/node-lib/internal/assert/calltracker.js +153 -0
  278. package/src/node-lib/internal/assert/myers_diff.js +177 -0
  279. package/src/node-lib/internal/assert/utils.js +278 -0
  280. package/src/node-lib/internal/buffer.js +1120 -0
  281. package/src/node-lib/internal/child_process/serialization.js +169 -0
  282. package/src/node-lib/internal/child_process.js +1135 -0
  283. package/src/node-lib/internal/constants.js +56 -0
  284. package/src/node-lib/internal/deps/minimatch/index.js +1628 -0
  285. package/src/node-lib/internal/errors.js +1912 -0
  286. package/src/node-lib/internal/events/abort_listener.js +54 -0
  287. package/src/node-lib/internal/events/symbols.js +11 -0
  288. package/src/node-lib/internal/fixed_queue.js +119 -0
  289. package/src/node-lib/internal/freelist.js +30 -0
  290. package/src/node-lib/internal/fs/cp/cp-sync.js +242 -0
  291. package/src/node-lib/internal/fs/cp/cp.js +382 -0
  292. package/src/node-lib/internal/fs/dir.js +369 -0
  293. package/src/node-lib/internal/fs/glob.js +763 -0
  294. package/src/node-lib/internal/fs/promises.js +1312 -0
  295. package/src/node-lib/internal/fs/read/context.js +129 -0
  296. package/src/node-lib/internal/fs/recursive_watch.js +275 -0
  297. package/src/node-lib/internal/fs/rimraf.js +311 -0
  298. package/src/node-lib/internal/fs/streams.js +571 -0
  299. package/src/node-lib/internal/fs/sync_write_stream.js +49 -0
  300. package/src/node-lib/internal/fs/utils.js +987 -0
  301. package/src/node-lib/internal/fs/watchers.js +418 -0
  302. package/src/node-lib/internal/http.js +62 -0
  303. package/src/node-lib/internal/mime.js +389 -0
  304. package/src/node-lib/internal/modules/customization_hooks.js +406 -0
  305. package/src/node-lib/internal/net.js +95 -0
  306. package/src/node-lib/internal/querystring.js +119 -0
  307. package/src/node-lib/internal/readline/callbacks.js +132 -0
  308. package/src/node-lib/internal/readline/emitKeypressEvents.js +99 -0
  309. package/src/node-lib/internal/readline/interface.js +1418 -0
  310. package/src/node-lib/internal/readline/promises.js +144 -0
  311. package/src/node-lib/internal/readline/utils.js +405 -0
  312. package/src/node-lib/internal/socket_list.js +108 -0
  313. package/src/node-lib/internal/stream_base_commons.js +280 -0
  314. package/src/node-lib/internal/streams/add-abort-signal.js +60 -0
  315. package/src/node-lib/internal/streams/compose.js +257 -0
  316. package/src/node-lib/internal/streams/destroy.js +361 -0
  317. package/src/node-lib/internal/streams/duplex.js +203 -0
  318. package/src/node-lib/internal/streams/duplexify.js +379 -0
  319. package/src/node-lib/internal/streams/duplexpair.js +62 -0
  320. package/src/node-lib/internal/streams/end-of-stream.js +331 -0
  321. package/src/node-lib/internal/streams/from.js +208 -0
  322. package/src/node-lib/internal/streams/lazy_transform.js +57 -0
  323. package/src/node-lib/internal/streams/legacy.js +125 -0
  324. package/src/node-lib/internal/streams/operators.js +436 -0
  325. package/src/node-lib/internal/streams/passthrough.js +47 -0
  326. package/src/node-lib/internal/streams/pipeline.js +465 -0
  327. package/src/node-lib/internal/streams/readable.js +1762 -0
  328. package/src/node-lib/internal/streams/state.js +51 -0
  329. package/src/node-lib/internal/streams/transform.js +204 -0
  330. package/src/node-lib/internal/streams/utils.js +363 -0
  331. package/src/node-lib/internal/streams/writable.js +1163 -0
  332. package/src/node-lib/internal/tty.js +260 -0
  333. package/src/node-lib/internal/util/colors.js +40 -0
  334. package/src/node-lib/internal/util/comparisons.js +1028 -0
  335. package/src/node-lib/internal/util/debuglog.js +524 -0
  336. package/src/node-lib/internal/util/inspect.js +2535 -0
  337. package/src/node-lib/internal/util/parse_args/parse_args.js +412 -0
  338. package/src/node-lib/internal/util/parse_args/utils.js +197 -0
  339. package/src/node-lib/internal/util.js +1003 -0
  340. package/src/node-lib/internal/validators.js +654 -0
  341. package/src/node-lib/internals/addresses.ts +159 -0
  342. package/src/node-lib/internals/buffer-and-streams.ts +224 -0
  343. package/src/node-lib/internals/child-process.ts +64 -0
  344. package/src/node-lib/internals/events-util.ts +105 -0
  345. package/src/node-lib/internals/index.ts +66 -0
  346. package/src/node-lib/internals/modules.ts +117 -0
  347. package/src/node-lib/internals/readline-access.ts +16 -0
  348. package/src/node-lib/internals/runtime.ts +277 -0
  349. package/src/node-lib/internals/util.ts +98 -0
  350. package/src/node-lib/lazy.ts +158 -0
  351. package/src/node-lib/load.ts +390 -0
  352. package/src/node-lib/module-hooks.ts +281 -0
  353. package/src/node-lib/net-module.ts +248 -0
  354. package/src/node-lib/net.js +2540 -0
  355. package/src/node-lib/node-versions.ts +34 -0
  356. package/src/node-lib/os.js +356 -0
  357. package/src/node-lib/path.js +1694 -0
  358. package/src/node-lib/primordials.js +743 -0
  359. package/src/node-lib/public-modules.ts +109 -0
  360. package/src/node-lib/punycode.js +455 -0
  361. package/src/node-lib/querystring.js +484 -0
  362. package/src/node-lib/readline/promises.js +73 -0
  363. package/src/node-lib/readline.js +523 -0
  364. package/src/node-lib/require-hook.ts +27 -0
  365. package/src/node-lib/small-modules.ts +35 -0
  366. package/src/node-lib/sources.ts +200 -0
  367. package/src/node-lib/stream/promises.js +44 -0
  368. package/src/node-lib/stream-module.ts +101 -0
  369. package/src/node-lib/stream.js +152 -0
  370. package/src/node-lib/timers.ts +33 -0
  371. package/src/node-lib/tty.js +168 -0
  372. package/src/node-lib/util-module.ts +104 -0
  373. package/src/node-lib/util.js +689 -0
  374. package/src/node-lib/wasi.js +179 -0
  375. package/src/node-lib/zlib.js +1036 -0
  376. package/src/node-resolution.ts +241 -0
  377. package/src/node-resolver.ts +33 -0
  378. package/src/npm/index.ts +425 -0
  379. package/src/npm/registry.ts +235 -0
  380. package/src/npm/resolver.ts +589 -0
  381. package/src/npm/tarball.ts +246 -0
  382. package/src/process-tokens.ts +156 -0
  383. package/src/punycode-source.ts +6 -0
  384. package/src/runtime-interface.ts +85 -0
  385. package/src/runtime.ts +3073 -0
  386. package/src/server-bridge.ts +971 -0
  387. package/src/shims/async_hooks.ts +181 -0
  388. package/src/shims/child_process.ts +1591 -0
  389. package/src/shims/cluster.ts +79 -0
  390. package/src/shims/command-line.ts +79 -0
  391. package/src/shims/constants.ts +68 -0
  392. package/src/shims/crypto-constants.ts +11 -0
  393. package/src/shims/crypto.ts +1061 -0
  394. package/src/shims/dgram.ts +47 -0
  395. package/src/shims/dns.ts +185 -0
  396. package/src/shims/domain.ts +58 -0
  397. package/src/shims/esbuild.ts +1638 -0
  398. package/src/shims/fs.ts +82 -0
  399. package/src/shims/http2.ts +96 -0
  400. package/src/shims/inspector.ts +30 -0
  401. package/src/shims/module.ts +86 -0
  402. package/src/shims/os.ts +195 -0
  403. package/src/shims/path.ts +246 -0
  404. package/src/shims/perf_hooks.ts +92 -0
  405. package/src/shims/process.ts +804 -0
  406. package/src/shims/rollup.ts +149 -0
  407. package/src/shims/string_decoder.ts +396 -0
  408. package/src/shims/sync-child.ts +469 -0
  409. package/src/shims/tls.ts +94 -0
  410. package/src/shims/url.ts +217 -0
  411. package/src/shims/v8.ts +113 -0
  412. package/src/shims/vfs-adapter.ts +408 -0
  413. package/src/shims/vm.ts +132 -0
  414. package/src/shims/wasi.ts +1440 -0
  415. package/src/shims/worker_threads.ts +114 -0
  416. package/src/shims/zlib-constants.ts +65 -0
  417. package/src/shims/zlib.ts +228 -0
  418. package/src/transform.ts +324 -0
  419. package/src/types/external.d.ts +55 -0
  420. package/src/types/package-json.ts +17 -0
  421. package/src/types/pako-zlib.d.ts +30 -0
  422. package/src/types/sha.js.d.ts +14 -0
  423. package/src/utils/binary-encoding.ts +43 -0
  424. package/src/utils/glob.ts +54 -0
  425. package/src/utils/hash.ts +12 -0
  426. package/src/virtual-fs.ts +1048 -0
  427. package/src/vite-plugin.ts +76 -0
  428. package/src/worker/runtime-worker.ts +128 -0
  429. package/src/worker-runtime.ts +145 -0
@@ -0,0 +1,159 @@
1
+ /**
2
+ * `internal/socketaddress` and `internal/blocklist`, bound by hand.
3
+ *
4
+ * `net.js` exposes both as `net.SocketAddress` and `net.BlockList` and asks
5
+ * one thing of each: `BlockList.isBlockList(value)` when a program hands one
6
+ * to `createServer` or `connect`, and `blockList.check(address, family)` for
7
+ * every connection. They validate and hold, and the check is address
8
+ * arithmetic; nothing here reaches the network, because there is none.
9
+ */
10
+ import { libRequire } from '../require-hook';
11
+ import { convertIpv6StringToBuffer } from '../binding/cares_wrap';
12
+
13
+ function isIP(value: string): number {
14
+ return (libRequire('internal/net') as { isIP(s: string): number }).isIP(value);
15
+ }
16
+
17
+ /** An address as a big integer, so a range and a subnet are comparisons. */
18
+ function toNumber(address: string, family: string): bigint {
19
+ if (family === 'ipv4') {
20
+ let value = 0n;
21
+ for (const part of address.split('.')) value = (value << 8n) | BigInt(Number(part) & 255);
22
+ return value;
23
+ }
24
+ let value = 0n;
25
+ for (const byte of convertIpv6StringToBuffer(address)) value = (value << 8n) | BigInt(byte);
26
+ return value;
27
+ }
28
+
29
+ const kAddress = Symbol('address');
30
+ const kPort = Symbol('port');
31
+ const kFamily = Symbol('family');
32
+ const kFlowLabel = Symbol('flowlabel');
33
+
34
+ export class SocketAddress {
35
+ constructor(options: { address?: string; port?: number; family?: string; flowlabel?: number } = {}) {
36
+ const family = (options.family ?? 'ipv4').toLowerCase();
37
+ if (family !== 'ipv4' && family !== 'ipv6') {
38
+ throw Object.assign(new TypeError(`The argument 'options.family' must be one of: 'ipv4', 'ipv6'. Received '${options.family}'`), { code: 'ERR_INVALID_ARG_VALUE' });
39
+ }
40
+ const address = options.address ?? (family === 'ipv4' ? '127.0.0.1' : '::');
41
+ if (typeof address !== 'string' || isIP(address) === 0) {
42
+ throw Object.assign(new TypeError(`The argument 'options.address' is invalid. Received '${address}'`), { code: 'ERR_INVALID_ARG_VALUE' });
43
+ }
44
+ const port = options.port ?? 0;
45
+ if (typeof port !== 'number' || !Number.isInteger(port) || port < 0 || port > 65535) {
46
+ throw Object.assign(new RangeError(`The value of "options.port" is out of range. It must be >= 0 && <= 65535. Received ${port}`), { code: 'ERR_OUT_OF_RANGE' });
47
+ }
48
+ (this as Record<symbol, unknown>)[kAddress] = address;
49
+ (this as Record<symbol, unknown>)[kPort] = port;
50
+ (this as Record<symbol, unknown>)[kFamily] = family;
51
+ (this as Record<symbol, unknown>)[kFlowLabel] = options.flowlabel ?? 0;
52
+ }
53
+
54
+ get address(): string { return (this as unknown as Record<symbol, string>)[kAddress]; }
55
+ get port(): number { return (this as unknown as Record<symbol, number>)[kPort]; }
56
+ get family(): string { return (this as unknown as Record<symbol, string>)[kFamily]; }
57
+ get flowlabel(): number { return (this as unknown as Record<symbol, number>)[kFlowLabel]; }
58
+
59
+ toJSON(): { address: string; port: number; family: string; flowlabel: number } {
60
+ return { address: this.address, port: this.port, family: this.family, flowlabel: this.flowlabel };
61
+ }
62
+
63
+ static isSocketAddress(value: unknown): value is SocketAddress {
64
+ return value instanceof SocketAddress;
65
+ }
66
+
67
+ /** Node's `SocketAddress.parse('host:port')`; null for anything it cannot read. */
68
+ static parse(input: string): SocketAddress | undefined {
69
+ try {
70
+ const url = new URL(`http://${input}`);
71
+ const host = url.hostname.startsWith('[') ? url.hostname.slice(1, -1) : url.hostname;
72
+ const family = isIP(host) === 6 ? 'ipv6' : 'ipv4';
73
+ return new SocketAddress({ address: host, port: Number(url.port || 0), family });
74
+ } catch {
75
+ return undefined;
76
+ }
77
+ }
78
+ }
79
+
80
+ type Rule =
81
+ | { kind: 'address'; family: string; value: bigint; text: string }
82
+ | { kind: 'range'; family: string; start: bigint; end: bigint; text: string }
83
+ | { kind: 'subnet'; family: string; network: bigint; mask: bigint; text: string };
84
+
85
+ export class BlockList {
86
+ private entries: Rule[] = [];
87
+
88
+ private static familyOf(family?: string): string {
89
+ const name = (family ?? 'ipv4').toLowerCase();
90
+ if (name !== 'ipv4' && name !== 'ipv6') {
91
+ throw Object.assign(new TypeError(`The argument 'family' must be one of: 'ipv4', 'ipv6'. Received '${family}'`), { code: 'ERR_INVALID_ARG_VALUE' });
92
+ }
93
+ return name;
94
+ }
95
+
96
+ private static addressOf(value: string | SocketAddress, family: string): string {
97
+ if (value instanceof SocketAddress) return value.address;
98
+ if (typeof value !== 'string' || isIP(value) === 0) {
99
+ throw Object.assign(new TypeError(`The argument 'address' is invalid. Received '${String(value)}'`), { code: 'ERR_INVALID_ARG_VALUE' });
100
+ }
101
+ void family;
102
+ return value;
103
+ }
104
+
105
+ addAddress(address: string | SocketAddress, family?: string): void {
106
+ const name = address instanceof SocketAddress ? address.family : BlockList.familyOf(family);
107
+ const text = BlockList.addressOf(address, name);
108
+ this.entries.push({ kind: 'address', family: name, value: toNumber(text, name), text: `Address: ${name.toUpperCase()} ${text}` });
109
+ }
110
+
111
+ addRange(start: string | SocketAddress, end: string | SocketAddress, family?: string): void {
112
+ const name = start instanceof SocketAddress ? start.family : BlockList.familyOf(family);
113
+ const from = BlockList.addressOf(start, name);
114
+ const to = BlockList.addressOf(end, name);
115
+ const low = toNumber(from, name);
116
+ const high = toNumber(to, name);
117
+ if (high < low) {
118
+ throw Object.assign(new TypeError("The argument 'end' is invalid."), { code: 'ERR_INVALID_ARG_VALUE' });
119
+ }
120
+ this.entries.push({ kind: 'range', family: name, start: low, end: high, text: `Range: ${name.toUpperCase()} ${from}-${to}` });
121
+ }
122
+
123
+ addSubnet(network: string | SocketAddress, prefix: number, family?: string): void {
124
+ const name = network instanceof SocketAddress ? network.family : BlockList.familyOf(family);
125
+ const text = BlockList.addressOf(network, name);
126
+ const bits = name === 'ipv4' ? 32 : 128;
127
+ if (typeof prefix !== 'number' || !Number.isInteger(prefix) || prefix < 0 || prefix > bits) {
128
+ throw Object.assign(new RangeError(`The value of "prefix" is out of range. It must be >= 0 && <= ${bits}. Received ${prefix}`), { code: 'ERR_OUT_OF_RANGE' });
129
+ }
130
+ const mask = prefix === 0 ? 0n : ((1n << BigInt(prefix)) - 1n) << BigInt(bits - prefix);
131
+ this.entries.push({ kind: 'subnet', family: name, network: toNumber(text, name) & mask, mask, text: `Subnet: ${name.toUpperCase()} ${text}/${prefix}` });
132
+ }
133
+
134
+ check(address: string | SocketAddress, family?: string): boolean {
135
+ const name = address instanceof SocketAddress ? address.family : (family ?? 'ipv4').toLowerCase();
136
+ if (name !== 'ipv4' && name !== 'ipv6') return false;
137
+ const text = address instanceof SocketAddress ? address.address : address;
138
+ if (typeof text !== 'string' || isIP(text) === 0) return false;
139
+ const value = toNumber(text, name);
140
+ for (const rule of this.entries) {
141
+ if (rule.family !== name) continue;
142
+ if (rule.kind === 'address' && rule.value === value) return true;
143
+ if (rule.kind === 'range' && value >= rule.start && value <= rule.end) return true;
144
+ if (rule.kind === 'subnet' && (value & rule.mask) === rule.network) return true;
145
+ }
146
+ return false;
147
+ }
148
+
149
+ get rules(): string[] {
150
+ return this.entries.map((rule) => rule.text);
151
+ }
152
+
153
+ static isBlockList(value: unknown): value is BlockList {
154
+ return value instanceof BlockList;
155
+ }
156
+ }
157
+
158
+ export const internalSocketAddress = { SocketAddress, kSocketAddressHandle: Symbol('kSocketAddressHandle') };
159
+ export const internalBlockList = { BlockList };
@@ -0,0 +1,224 @@
1
+ /**
2
+ * The internals Node's `buffer` and `stream` name that neither `net` nor
3
+ * `child_process` did.
4
+ *
5
+ * Each object holds exactly the names the vendored files destructure from it.
6
+ * Where a name stands for something a tab cannot have -- a web-stream
7
+ * adapter, ICU's transcoder -- it refuses and says so at the site, rather
8
+ * than answering with something that is not it.
9
+ */
10
+ import { libRequire } from '../require-hook';
11
+ import { createBlobFromFilePath } from '../binding/blob';
12
+
13
+ /** Node's `once(fn)`: the same function, run at most once. */
14
+ export function once<F extends (...args: never[]) => unknown>(
15
+ callback: F, options?: { preserveReturnValue?: boolean },
16
+ ): F {
17
+ let called = false;
18
+ let returned: unknown;
19
+ function ran(this: unknown, ...args: never[]): unknown {
20
+ if (called) return returned;
21
+ called = true;
22
+ const result = Reflect.apply(callback, this, args);
23
+ returned = options?.preserveReturnValue === true ? result : undefined;
24
+ return result;
25
+ }
26
+ return ran as unknown as F;
27
+ }
28
+
29
+ /**
30
+ * Node's `defineLazyProperties`: each key becomes a getter that loads the
31
+ * named module on first read. `buffer.js` hangs `Blob`, `File` and
32
+ * `resolveObjectURL` off its exports this way, so a program that never asks
33
+ * for a Blob never loads one.
34
+ */
35
+ export function defineLazyProperties(target: object, id: string, keys: string[], enumerable = true): void {
36
+ const descriptors: PropertyDescriptorMap = {};
37
+ let module: Record<string, unknown> | undefined;
38
+ for (const key of keys) {
39
+ let value: unknown;
40
+ let loaded = false;
41
+ descriptors[key] = {
42
+ configurable: true,
43
+ enumerable,
44
+ get(): unknown {
45
+ if (!loaded) {
46
+ module ??= libRequire(id) as Record<string, unknown>;
47
+ value = module[key];
48
+ loaded = true;
49
+ }
50
+ return value;
51
+ },
52
+ set(next: unknown): void { value = next; loaded = true; },
53
+ };
54
+ }
55
+ Object.defineProperties(target, descriptors);
56
+ }
57
+
58
+ /** Node's `lazyDOMException`: the realm's own, which every realm here has. */
59
+ export function lazyDOMException(message: string, name: string): Error {
60
+ const Exception = (globalThis as unknown as { DOMException?: new (m: string, n: string) => Error }).DOMException;
61
+ if (typeof Exception === 'function') return new Exception(message, name);
62
+ return Object.assign(new Error(message), { name });
63
+ }
64
+
65
+ /**
66
+ * Node's `encodingsMap`: the number each encoding is to the buffer binding,
67
+ * from `enum encoding` in `node_buffer.h`. Only `buffer.js` and the binding
68
+ * exchange them.
69
+ */
70
+ export const encodingsMap: Record<string, number> = {
71
+ ascii: 0, utf8: 1, 'utf-8': 1, base64: 2, ucs2: 3, 'ucs-2': 3,
72
+ utf16le: 3, 'utf-16le': 3, binary: 4, latin1: 4, hex: 5, buffer: 6, base64url: 7,
73
+ };
74
+
75
+ /** Node's `customInspectSymbol` and the symbol `Buffer.isEncoding` is marked with. */
76
+ export const customInspectSymbol = Symbol.for('nodejs.util.inspect.custom');
77
+ export const kIsEncodingSymbol = Symbol('kIsEncodingSymbol');
78
+
79
+ /** `internal/abort_controller`: the realm's own, which is the web's. */
80
+ export const internalAbortController = {
81
+ AbortController: globalThis.AbortController,
82
+ AbortSignal: globalThis.AbortSignal,
83
+ aborted: (signal: AbortSignal): boolean => signal.aborted,
84
+ };
85
+
86
+ /**
87
+ * `internal/blob` and `internal/file`: the realm's own `Blob` and `File`,
88
+ * which every realm the engine runs in has. `resolveObjectURL` answers
89
+ * nothing, because the engine registers no blob URLs of its own.
90
+ * `createBlobFromFilePath` is the blob binding's, which `fs.openAsBlob` is.
91
+ */
92
+ export const internalBlob = {
93
+ Blob: globalThis.Blob,
94
+ isBlob: (value: unknown): boolean => typeof Blob === 'function' && value instanceof Blob,
95
+ resolveObjectURL: (): undefined => undefined,
96
+ createBlobFromFilePath,
97
+ };
98
+ export const internalFile = {
99
+ File: (globalThis as unknown as { File?: unknown }).File,
100
+ };
101
+
102
+ /**
103
+ * `internal/webstreams/adapters`: what `Readable.toWeb`, `Readable.fromWeb`,
104
+ * `Writable.toWeb`, `Writable.fromWeb` and the `Duplex` pair reach for.
105
+ *
106
+ * Node's own is pure JavaScript over Node's own `ReadableStream` and
107
+ * `WritableStream`, which are themselves a port of the web's. A tab HAS the
108
+ * web's, so this is the one place where the platform is the implementation
109
+ * rather than a thing to port: each adapter is written against the realm's
110
+ * `ReadableStream`/`WritableStream`, which is what a server bundle turning a
111
+ * `node:http` request into a `Request` gets. The engine carried these same
112
+ * six bodies as patches over its hand-written streams; they move here,
113
+ * unchanged in behaviour, now that the streams above them are Node's.
114
+ *
115
+ * What is not here is what Node's adapters add on top: a byte-mode
116
+ * `ReadableStream` with BYOB readers, and the `AbortSignal` options. Named,
117
+ * not guessed at.
118
+ */
119
+ type AnyStream = Record<string, (...args: never[]) => unknown> & Record<string, unknown>;
120
+
121
+ function streamModule(): Record<string, new (options?: unknown) => AnyStream> {
122
+ return libRequire('stream') as Record<string, new (options?: unknown) => AnyStream>;
123
+ }
124
+
125
+ function newReadableStreamFromStreamReadable(readable: AnyStream): ReadableStream {
126
+ return new ReadableStream({
127
+ start(controller) {
128
+ (readable.on as (e: string, l: (v: unknown) => void) => void)('data', (chunk) => {
129
+ controller.enqueue(chunk instanceof Uint8Array ? chunk : new Uint8Array(Buffer_from(chunk)));
130
+ });
131
+ (readable.on as (e: string, l: () => void) => void)('end', () => { try { controller.close(); } catch { /* a stream closed twice is closed */ } });
132
+ (readable.on as (e: string, l: (v: unknown) => void) => void)('error', (error) => { try { controller.error(error); } catch { /* likewise */ } });
133
+ },
134
+ cancel() { (readable.destroy as () => void)(); },
135
+ });
136
+ }
137
+
138
+ /** The bytes of a chunk that is not already one, without importing `buffer` at load. */
139
+ function Buffer_from(chunk: unknown): Uint8Array {
140
+ const { Buffer } = libRequire('buffer') as { Buffer: { from(value: unknown): Uint8Array } };
141
+ return Buffer.from(chunk);
142
+ }
143
+
144
+ function newStreamReadableFromReadableStream(web: ReadableStream): AnyStream {
145
+ const { Readable } = streamModule() as unknown as { Readable: { from(source: unknown): AnyStream } };
146
+ return Readable.from({
147
+ [Symbol.asyncIterator]() {
148
+ const reader = web.getReader();
149
+ return {
150
+ [Symbol.asyncIterator]() { return this; },
151
+ async next() {
152
+ const step = await reader.read();
153
+ return step.done ? { value: undefined, done: true } : { value: step.value, done: false };
154
+ },
155
+ async return(value: unknown) { await reader.cancel(); return { value, done: true }; },
156
+ };
157
+ },
158
+ });
159
+ }
160
+
161
+ function newWritableStreamFromStreamWritable(writable: AnyStream): WritableStream {
162
+ return new WritableStream({
163
+ write(chunk) {
164
+ return new Promise<void>((resolve, reject) => {
165
+ (writable.write as (c: unknown, cb: (e: unknown) => void) => void)(chunk, (error) => (error ? reject(error as Error) : resolve()));
166
+ });
167
+ },
168
+ close() { return new Promise<void>((resolve) => { (writable.end as (cb: () => void) => void)(resolve); }); },
169
+ abort(reason) { (writable.destroy as (e?: Error) => void)(reason instanceof Error ? reason : undefined); },
170
+ });
171
+ }
172
+
173
+ function newStreamWritableFromWritableStream(web: WritableStream): AnyStream {
174
+ const { Writable } = streamModule() as unknown as { Writable: new (options: unknown) => AnyStream };
175
+ const writer = web.getWriter();
176
+ return new Writable({
177
+ write(chunk: unknown, _encoding: unknown, callback: (error?: Error | null) => void) {
178
+ writer.write(chunk instanceof Uint8Array ? chunk : Buffer_from(chunk)).then(() => callback(null), callback);
179
+ },
180
+ final(callback: (error?: Error | null) => void) {
181
+ writer.close().then(() => callback(null), callback);
182
+ },
183
+ destroy(error: Error | null, callback: (error?: Error | null) => void) {
184
+ writer.abort(error ?? undefined).then(() => callback(error), callback);
185
+ },
186
+ });
187
+ }
188
+
189
+ function newReadableWritablePairFromDuplex(duplex: AnyStream): { readable: ReadableStream; writable: WritableStream } {
190
+ return {
191
+ readable: newReadableStreamFromStreamReadable(duplex),
192
+ writable: newWritableStreamFromStreamWritable(duplex),
193
+ };
194
+ }
195
+
196
+ function newStreamDuplexFromReadableWritablePair(pair: { readable: ReadableStream; writable: WritableStream }): AnyStream {
197
+ const { Duplex } = streamModule() as unknown as { Duplex: new (options: unknown) => AnyStream };
198
+ const writer = pair.writable.getWriter();
199
+ const reader = pair.readable.getReader();
200
+ const duplex: AnyStream = new Duplex({
201
+ read() {
202
+ reader.read().then(
203
+ (step) => { (duplex.push as (c: unknown) => void)(step.done ? null : step.value); },
204
+ (error: Error) => { (duplex.destroy as (e: Error) => void)(error); },
205
+ );
206
+ },
207
+ write(chunk: unknown, _encoding: unknown, callback: (error?: Error | null) => void) {
208
+ writer.write(chunk instanceof Uint8Array ? chunk : Buffer_from(chunk)).then(() => callback(null), callback);
209
+ },
210
+ final(callback: (error?: Error | null) => void) {
211
+ writer.close().then(() => callback(null), callback);
212
+ },
213
+ });
214
+ return duplex;
215
+ }
216
+
217
+ export const internalWebStreamsAdapters = {
218
+ newReadableStreamFromStreamReadable,
219
+ newStreamReadableFromReadableStream,
220
+ newWritableStreamFromStreamWritable,
221
+ newStreamWritableFromWritableStream,
222
+ newReadableWritablePairFromDuplex,
223
+ newStreamDuplexFromReadableWritablePair,
224
+ };
@@ -0,0 +1,64 @@
1
+ /**
2
+ * The internals Node's `child_process` names that `net` did not.
3
+ *
4
+ * Each object holds exactly the names `child_process.js` and
5
+ * `internal/child_process.js` destructure from it, over the engine's own
6
+ * modules. Node's real `internal/fs/utils` is two thousand lines about a
7
+ * kernel's descriptors; what `child_process.js` takes from it is one
8
+ * validator, run on the module path a `fork` was given.
9
+ */
10
+ import { libRequire } from '../require-hook';
11
+ import { fileURLToPath } from '../../shims/url';
12
+
13
+ /** The codes the validators below raise, from the vendored `internal/errors.js`. */
14
+ interface ErrorCodes {
15
+ codes: {
16
+ ERR_INVALID_ARG_TYPE: new (name: string, expected: unknown, actual: unknown) => Error;
17
+ ERR_INVALID_ARG_VALUE: new (name: string, value: unknown, reason?: string) => Error;
18
+ };
19
+ }
20
+
21
+ function errorCodes(): ErrorCodes['codes'] {
22
+ return (libRequire('internal/errors') as ErrorCodes).codes;
23
+ }
24
+
25
+ /**
26
+ * Node's `validatePath`: a path is a string or a `Uint8Array`, and it carries
27
+ * no NUL. `fork('a\u0000b')` is a program's own bug and Node says so rather
28
+ * than opening a file whose name stops at the NUL.
29
+ */
30
+ function validatePath(path: unknown, propName = 'path'): void {
31
+ const codes = errorCodes();
32
+ const isString = typeof path === 'string';
33
+ const isBytes = path instanceof Uint8Array;
34
+ if (!isString && !isBytes) {
35
+ throw new codes.ERR_INVALID_ARG_TYPE(propName, ['string', 'Buffer', 'URL'], path);
36
+ }
37
+ if (isString ? !path.includes('\u0000') : !(path as Uint8Array).includes(0)) return;
38
+ throw new codes.ERR_INVALID_ARG_VALUE(
39
+ propName, path, 'must be a string, Uint8Array, or URL without null bytes',
40
+ );
41
+ }
42
+
43
+ /**
44
+ * Node's `getValidatedPath`: a `file:` URL is the path it names, and anything
45
+ * else is validated as it stands. `fork(new URL('file:///app/child.js'))` is
46
+ * an ordinary call and `test-child-process-fork-url.mjs` makes it.
47
+ */
48
+ function getValidatedPath(fileURLOrPath: unknown, propName = 'path'): string | Uint8Array {
49
+ const path = fileURLOrPath instanceof URL || (typeof fileURLOrPath === 'string' && fileURLOrPath.startsWith('file://'))
50
+ ? fileURLToPath(fileURLOrPath as URL | string)
51
+ : fileURLOrPath;
52
+ validatePath(path, propName);
53
+ return path as string | Uint8Array;
54
+ }
55
+
56
+ export const internalFsUtils = { getValidatedPath, validatePath };
57
+
58
+ /**
59
+ * `internal/dgram`: the one name `internal/child_process.js` reads from it,
60
+ * the symbol a `dgram.Socket` keeps its handle under. The engine's `dgram` is
61
+ * a stub with no handle, so nothing is ever sent this way; the symbol exists
62
+ * because the conversion table names it while it is built.
63
+ */
64
+ export const internalDgram = { kStateSymbol: Symbol('state symbol') };
@@ -0,0 +1,105 @@
1
+ import { readlineModule as nodeLibPublicReadline } from './readline-access';
2
+
3
+ /**
4
+ * The internals Node's `events`, `util` and `internal/util/inspect` name that
5
+ * are not vendored.
6
+ *
7
+ * Each is the whole of what those files take from it. Every one of them is
8
+ * required lazily, inside the function that needs it -- Node wrote them that
9
+ * way to break its own cycles -- so nothing here is built unless a program
10
+ * walks the path that asks.
11
+ */
12
+
13
+ /** `internal/console/global`: the realm's console, which `util.debuglog` logs through. */
14
+ export const internalConsoleGlobal = new Proxy({} as Record<string, unknown>, {
15
+ get: (_target, key) => Reflect.get(globalThis.console as unknown as object, key),
16
+ });
17
+
18
+ /**
19
+ * `internal/process/execution`: the one call `internal/util.js` makes into
20
+ * it, reading the working directory where a failure to read it is not an
21
+ * error but an empty answer.
22
+ */
23
+ export const internalProcessExecution = {
24
+ tryGetCwd: (): string => {
25
+ try { return (globalThis as { process?: { cwd?: () => string } }).process?.cwd?.() ?? ''; }
26
+ catch { return ''; }
27
+ },
28
+ };
29
+
30
+ /**
31
+ * `internal/process/warning`: Node emits a warning on the next tick through
32
+ * `process.emitWarning`, and synchronously through this one where the tick
33
+ * would come too late -- a deprecation raised while the process is exiting.
34
+ */
35
+ export const internalProcessWarning = {
36
+ emitWarningSync: (warning: unknown, type?: string, code?: string): void => {
37
+ const realm = (globalThis as { process?: { emitWarning?: (w: unknown, t?: string, c?: string) => void } }).process;
38
+ if (typeof realm?.emitWarning === 'function') { realm.emitWarning(warning, type, code); return; }
39
+ try { console.error(String(warning)); } catch { /* a console that refuses is no reason to fail */ }
40
+ },
41
+ };
42
+
43
+ /**
44
+ * `internal/source_map/source_map_cache`: a tab compiles no source maps into
45
+ * the engine's own error stacks. Each name answers the way Node's does with
46
+ * source maps switched off.
47
+ */
48
+ export const internalSourceMapCache = {
49
+ findSourceMap: (): undefined => void 0,
50
+ maybeCacheSourceMap: (): void => {},
51
+ sourceMapCacheToObject: (): undefined => void 0,
52
+ getSourceMapsSupport: (): { enabled: boolean; nodeModules: boolean; generatedCode: boolean } =>
53
+ ({ enabled: false, nodeModules: false, generatedCode: false }),
54
+ setSourceMapsSupport: (): void => {},
55
+ rekeySourceMap: (): void => {},
56
+ };
57
+
58
+ /**
59
+ * `internal/deps/undici/undici`: what `http.js` reaches for when a program
60
+ * touches `http.WebSocket`, `http.CloseEvent` or `http.MessageEvent`.
61
+ *
62
+ * Node bundles undici to have those classes at all. A tab already has them --
63
+ * they are the platform's, and they are what `new WebSocket(url)` means
64
+ * everywhere else on the page -- so the realm's own are what the engine
65
+ * answers with, rather than a second implementation of the same three names.
66
+ */
67
+ export const internalUndici = {
68
+ get WebSocket() { return (globalThis as { WebSocket?: unknown }).WebSocket; },
69
+ get CloseEvent() { return (globalThis as { CloseEvent?: unknown }).CloseEvent; },
70
+ get MessageEvent() { return (globalThis as { MessageEvent?: unknown }).MessageEvent; },
71
+ };
72
+
73
+ /**
74
+ * `internal/readline/interface`: the one name `internal/fs/promises.js`
75
+ * takes from it, at its top, so every use of `fs/promises` needs it.
76
+ * `filehandle.readLines()` builds one of these over the file's own stream;
77
+ * the engine's `readline` already has that class, over the same streams.
78
+ */
79
+ export const internalReadlineInterface = {
80
+ get Interface() { return readlineInterface(); },
81
+ };
82
+
83
+ // eslint-disable-next-line no-var, vars-on-top
84
+ var readlineInterfaceCache: unknown;
85
+ function readlineInterface(): unknown {
86
+ // Required late, not imported: `readline` is an EventEmitter, and this file
87
+ // is on the loader's own path.
88
+ return readlineInterfaceCache ??= (nodeLibPublicReadline() as { Interface: unknown }).Interface;
89
+ }
90
+
91
+ /**
92
+ * `internal/worker/js_transferable`: the marks Node puts on an object that
93
+ * can cross a `postMessage`. `internal/fs/promises.js` marks its `FileHandle`
94
+ * so one can be sent to a worker. Nothing crosses a thread boundary here --
95
+ * a handle is a number in this engine's own table -- so the marks are the
96
+ * symbols and a no-op, which is what an unmarked object gets anyway.
97
+ */
98
+ export const internalJsTransferable = {
99
+ markTransferMode: (): void => {},
100
+ kDeserialize: Symbol.for('nodejs.transfer.deserialize'),
101
+ kTransfer: Symbol.for('nodejs.transfer.transfer'),
102
+ kTransferList: Symbol.for('nodejs.transfer.transferList'),
103
+ kClone: Symbol.for('nodejs.transfer.clone'),
104
+ setDeserializerCreateObjectFunction: (): void => {},
105
+ };
@@ -0,0 +1,66 @@
1
+ /**
2
+ * The internals Node's own files name that are not vendored.
3
+ *
4
+ * Node's own `internal/util`, `internal/async_hooks`, `internal/timers` and
5
+ * the rest are large files whose subject is a Node the engine does not have:
6
+ * an async-hooks graph, a timer wheel, a snapshot builder. What the vendored
7
+ * files actually take from each is a handful of names, so each is bound by
8
+ * hand to exactly those, over the engine's own modules. This table is the
9
+ * whole list; anything a vendored file asks for that is not here, not
10
+ * vendored and not a public module fails loudly in `load.ts` rather than
11
+ * arriving as `undefined` inside Node's code.
12
+ */
13
+ import { internalUtilTypes } from './util';
14
+ import {
15
+ internalConsoleGlobal, internalProcessExecution,
16
+ internalProcessWarning, internalSourceMapCache, internalUndici, internalReadlineInterface, internalJsTransferable,
17
+ } from './events-util';
18
+ import {
19
+ internalAsyncHooks, internalTimers, internalStreamsState, internalTaskQueues,
20
+ internalEventTarget, internalOptions, internalPerfObserve, internalAssert,
21
+ internalStartupSnapshot, internalPermission,
22
+ } from './runtime';
23
+ import { internalSocketAddress, internalBlockList } from './addresses';
24
+ import { internalFsUtils, internalDgram } from './child-process';
25
+ import {
26
+ internalAbortController, internalBlob, internalFile, internalWebStreamsAdapters,
27
+ } from './buffer-and-streams';
28
+ import { internalBootstrapRealm, internalUrl, internalEncoding } from './modules';
29
+
30
+ /** Built on the first ask, for the reason `./binding/index.ts` gives. */
31
+ // eslint-disable-next-line no-var, vars-on-top
32
+ var __table: Record<string, () => unknown> | undefined;
33
+ export function nodeLibInternal(name: string): (() => unknown) | undefined {
34
+ __table ??= {
35
+ 'internal/util/types': () => internalUtilTypes,
36
+ 'internal/async_hooks': () => internalAsyncHooks,
37
+ 'internal/timers': () => internalTimers,
38
+ 'internal/streams/state': () => internalStreamsState,
39
+ 'internal/process/task_queues': () => internalTaskQueues,
40
+ 'internal/process/permission': () => internalPermission,
41
+ 'internal/event_target': () => internalEventTarget,
42
+ 'internal/options': () => internalOptions,
43
+ 'internal/perf/observe': () => internalPerfObserve,
44
+ 'internal/assert': () => internalAssert,
45
+ 'internal/v8/startup_snapshot': () => internalStartupSnapshot,
46
+ 'internal/fs/utils': () => internalFsUtils,
47
+ 'internal/dgram': () => internalDgram,
48
+ 'internal/abort_controller': () => internalAbortController,
49
+ 'internal/blob': () => internalBlob,
50
+ 'internal/file': () => internalFile,
51
+ 'internal/webstreams/adapters': () => internalWebStreamsAdapters,
52
+ 'internal/socketaddress': () => internalSocketAddress,
53
+ 'internal/blocklist': () => internalBlockList,
54
+ 'internal/bootstrap/realm': () => internalBootstrapRealm,
55
+ 'internal/url': () => internalUrl,
56
+ 'internal/encoding': () => internalEncoding,
57
+ 'internal/console/global': () => internalConsoleGlobal,
58
+ 'internal/process/execution': () => internalProcessExecution,
59
+ 'internal/process/warning': () => internalProcessWarning,
60
+ 'internal/source_map/source_map_cache': () => internalSourceMapCache,
61
+ 'internal/deps/undici/undici': () => internalUndici,
62
+ 'internal/readline/interface': () => internalReadlineInterface,
63
+ 'internal/worker/js_transferable': () => internalJsTransferable,
64
+ };;
65
+ return __table[name];
66
+ }