@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,371 @@
1
+ /**
2
+ * `internalBinding('process_wrap')`: one run of the engine, seen as libuv sees
3
+ * a child process.
4
+ *
5
+ * libuv's `uv_spawn` starts a program with its descriptors already wired and
6
+ * answers through `onexit` when it ends; `uv_process_kill` ends it. That is
7
+ * the whole of what `internal/child_process.js` asks of a process, and it is
8
+ * the whole of this file. Nothing here knows about `ChildProcess`, `stdio`
9
+ * streams, `exec`'s buffering, `fork`'s IPC protocol or what a signal means:
10
+ * those are Node's own and are vendored.
11
+ *
12
+ * What the engine already did for a spawned command stays and becomes this
13
+ * file's implementation, through the one door the engine's process model
14
+ * installs below: the routing of a command to the engine's `node`, to a
15
+ * program the page registered, to a WALI pack, or to the shell. A `pipe`
16
+ * stdio entry is paired with an end of its own here, so the child's writes to
17
+ * fd 1 are reads on the parent's handle and the parent's writes to the stdin
18
+ * handle are the child's fd 0 -- which is what a `uv_stdio_container_t` with
19
+ * `UV_CREATE_PIPE` is.
20
+ */
21
+ import {
22
+ LibuvStreamWrap, WriteWrap, streamBaseState, kReadBytesOrError, kArrayBufferOffset,
23
+ } from './stream_wrap';
24
+ import { Pipe, constants as pipeConstants } from './pipe_wrap';
25
+ import { UV_ENOENT, UV_ESRCH } from './uv';
26
+ import {
27
+ registerHandle, refHandle, unrefHandle, handleHasRef, releaseHandle, __adoptHandle,
28
+ type OwnedHandle,
29
+ } from './handles';
30
+ import type { ProcessToken } from '../../process-tokens';
31
+
32
+ /** One entry of Node's `options.stdio`, as `getValidStdio` builds it. */
33
+ export interface StdioEntry {
34
+ type: 'pipe' | 'overlapped' | 'ignore' | 'inherit' | 'fd' | 'wrap';
35
+ handle?: LibuvStreamWrap;
36
+ fd?: number;
37
+ ipc?: boolean;
38
+ readable?: boolean;
39
+ writable?: boolean;
40
+ }
41
+
42
+ /** What `ChildProcess.prototype.spawn` hands `Process.spawn`. */
43
+ export interface ProcessSpawnOptions {
44
+ file: string;
45
+ args?: string[];
46
+ cwd?: string;
47
+ envPairs?: string[];
48
+ stdio: StdioEntry[];
49
+ detached?: boolean;
50
+ windowsHide?: boolean;
51
+ uid?: number;
52
+ gid?: number;
53
+ }
54
+
55
+ /** The channel a forked child is started with, at the descriptor it is told. */
56
+ export interface RunChannel {
57
+ /** The number the child's `NODE_CHANNEL_FD` names. */
58
+ fd: number;
59
+ /** The child's end of the channel, which its own `Pipe.open(fd)` finds. */
60
+ pipe: Pipe;
61
+ /** `json` or `advanced`, as `NODE_CHANNEL_SERIALIZATION_MODE` says. */
62
+ serialization: string;
63
+ }
64
+
65
+ /** What the binding asks the engine's process model to run. */
66
+ export interface RunRequest {
67
+ /** The program, as the caller named it: a path, a name, or the shell. */
68
+ file: string;
69
+ /** argv, the file first, as Node builds it. */
70
+ args: string[];
71
+ cwd?: string;
72
+ env: Record<string, string>;
73
+ detached: boolean;
74
+ /** Where the child's fd 1 goes; null where nothing reads it. */
75
+ stdout: ((text: string) => void) | null;
76
+ /** Where the child's fd 2 goes; null where nothing reads it. */
77
+ stderr: ((text: string) => void) | null;
78
+ /**
79
+ * True when fd 2 is a pipe the parent holds. A run that ends uncaught or
80
+ * with a nonzero `process.exit` on that pipe writes one receipt to the
81
+ * host realm's console, because the parent may never read the pipe — the
82
+ * tab's extension host dies this way, its stderr going into `@vscode/spdlog`
83
+ * which does not load. Inherit and the host's own stdio are false.
84
+ */
85
+ stderrIsPipe: boolean;
86
+ /** True when the child's fd 0 is a pipe whose writer has not closed. */
87
+ stdinIsPipe: boolean;
88
+ /** The IPC channel the child is started with, where it has one. */
89
+ channel?: RunChannel;
90
+ /** Called once, when the run has ended. */
91
+ exit(code: number, signal: string | null): void;
92
+ }
93
+
94
+ /** One run in flight, as the engine's process model hands it back. */
95
+ export interface StartedRun {
96
+ /** The run's own name, so a handle it holds is counted as its own. */
97
+ token: ProcessToken | null;
98
+ /** The run's process number, which is what its own `process.pid` reports. */
99
+ pid?: number;
100
+ /** libuv's `uv_process_kill`: 0, or `UV_ESRCH` for a run already over. */
101
+ kill(signal: string): number;
102
+ /** Bytes the parent wrote to the child's fd 0. */
103
+ writeStdin(bytes: Uint8Array): void;
104
+ /** The parent closed the child's fd 0. */
105
+ endStdin(): void;
106
+ }
107
+
108
+ /**
109
+ * The engine's process model, installed by `initChildProcess`. Until it is
110
+ * there is no engine to run anything, and a spawn answers `ENOENT`, which is
111
+ * what a machine carrying no such program answers.
112
+ */
113
+ export interface ProcessRunner {
114
+ /** Whether the engine has a program under this name at all. */
115
+ resolves(request: RunRequest): boolean;
116
+ start(request: RunRequest): StartedRun;
117
+ }
118
+
119
+ let runner: ProcessRunner | null = null;
120
+
121
+ /** The engine's process model takes this door once, when the VFS is known. */
122
+ export function setProcessRunner(next: ProcessRunner): void {
123
+ runner = next;
124
+ }
125
+
126
+ let nextPid = 1001 + Math.floor(Math.random() * 30000);
127
+ let nextAsyncId = 1;
128
+
129
+ /** `envPairs` is `KEY=value` strings; the engine's shell takes a record. */
130
+ function environmentOf(envPairs: string[] | undefined): Record<string, string> {
131
+ const env: Record<string, string> = {};
132
+ for (const pair of envPairs ?? []) {
133
+ const at = pair.indexOf('=');
134
+ if (at <= 0) continue;
135
+ env[pair.slice(0, at)] = pair.slice(at + 1);
136
+ }
137
+ return env;
138
+ }
139
+
140
+ /** A signal named by number, as the name libuv reports for it. */
141
+ const signalNames: Record<number, string> = {
142
+ 1: 'SIGHUP', 2: 'SIGINT', 3: 'SIGQUIT', 6: 'SIGABRT', 9: 'SIGKILL',
143
+ 10: 'SIGUSR1', 12: 'SIGUSR2', 13: 'SIGPIPE', 14: 'SIGALRM', 15: 'SIGTERM',
144
+ };
145
+ function signalNameOf(signal: number | string): string {
146
+ if (typeof signal === 'string') return signal;
147
+ return signalNames[signal] ?? 'SIGTERM';
148
+ }
149
+
150
+ /**
151
+ * The directory a child starts in when the caller named none: its parent's.
152
+ * `execve` keeps the calling process's working directory, and Node's `fork`
153
+ * passes no `cwd` at all -- `fork('./child.js')` from a program running in
154
+ * `/work` means `/work/child.js`, and resolved against the engine's shell's
155
+ * own root it meant `/child.js` and a child that exited 1.
156
+ */
157
+ function spawningDirectory(): string | undefined {
158
+ const realm = (globalThis as unknown as { process?: { cwd?: () => string } }).process;
159
+ if (typeof realm?.cwd !== 'function') return undefined;
160
+ try { return realm.cwd(); } catch { return undefined; }
161
+ }
162
+
163
+ /** Where an `inherit` entry's bytes go: the spawning program's own stream. */
164
+ function inheritedWriter(fd: number): ((text: string) => void) | null {
165
+ if (fd !== 1 && fd !== 2) return null;
166
+ const realm = (globalThis as unknown as {
167
+ process?: { stdout?: { write(text: string): unknown }; stderr?: { write(text: string): unknown } };
168
+ }).process;
169
+ const stream = fd === 1 ? realm?.stdout : realm?.stderr;
170
+ if (!stream || typeof stream.write !== 'function') return null;
171
+ return (text: string) => {
172
+ try { stream.write(text); } catch { /* a stream that refuses still lets the child run */ }
173
+ };
174
+ }
175
+
176
+ /**
177
+ * libuv's `uv_process_t`.
178
+ *
179
+ * The handle registers with the run that made it, as every handle here does,
180
+ * so a parent waiting on a child is not idle: Node's loop holds a process
181
+ * handle exactly that way, and `unref()` is how a program gives it up.
182
+ */
183
+ export class Process implements OwnedHandle {
184
+ /** Set by `internal/child_process.js`; the only way an end is reported. */
185
+ onexit: ((exitCode: number, signalCode: string | null) => void) | null = null;
186
+ /**
187
+ * A process that never started has no pid, and `ChildProcess` copies this
188
+ * one straight onto itself: a child whose `spawn` answered `ENOENT` reports
189
+ * `pid === undefined`, as Node's does, rather than a number naming nothing.
190
+ */
191
+ pid: number | undefined = undefined;
192
+
193
+ private run: StartedRun | null = null;
194
+ private ended = false;
195
+ private closed = false;
196
+ /** The stdio entries this run was started with, and their far ends. */
197
+ private stdio: StdioEntry[] = [];
198
+ private readonly asyncId = nextAsyncId++;
199
+
200
+ constructor() {
201
+ registerHandle(this);
202
+ }
203
+
204
+ getAsyncId(): number {
205
+ return this.asyncId;
206
+ }
207
+
208
+ ref(): void {
209
+ refHandle(this);
210
+ }
211
+
212
+ unref(): void {
213
+ unrefHandle(this);
214
+ }
215
+
216
+ hasRef(): boolean {
217
+ return handleHasRef(this);
218
+ }
219
+
220
+ /**
221
+ * libuv's `uv_spawn`. Answers 0 for a run that started and a `UV_*` code for
222
+ * one that could not, which is what `ChildProcess.prototype.spawn` turns
223
+ * into an `error` event or a throw.
224
+ */
225
+ spawn(options: ProcessSpawnOptions): number {
226
+ if (!runner) return UV_ENOENT;
227
+ const env = environmentOf(options.envPairs);
228
+ this.stdio = options.stdio ?? [];
229
+
230
+ const request: RunRequest = {
231
+ file: options.file,
232
+ args: options.args ?? [options.file],
233
+ cwd: options.cwd ?? spawningDirectory(),
234
+ env,
235
+ detached: options.detached === true,
236
+ stdout: null,
237
+ stderr: null,
238
+ stderrIsPipe: false,
239
+ stdinIsPipe: false,
240
+ exit: (code, signal) => { this.reportExit(code, signal); },
241
+ };
242
+
243
+ let stdinFar: Pipe | null = null;
244
+ for (let index = 0; index < this.stdio.length; index += 1) {
245
+ const entry = this.stdio[index];
246
+ if (!entry) continue;
247
+ const far = this.pairFarEnd(entry);
248
+ if (entry.ipc) {
249
+ if (far) {
250
+ request.channel = {
251
+ fd: index,
252
+ pipe: far,
253
+ serialization: env.NODE_CHANNEL_SERIALIZATION_MODE || 'json',
254
+ };
255
+ }
256
+ continue;
257
+ }
258
+ if (index === 0) {
259
+ stdinFar = far;
260
+ request.stdinIsPipe = far !== null;
261
+ continue;
262
+ }
263
+ if (index !== 1 && index !== 2) continue;
264
+ if (far) {
265
+ const to = index;
266
+ const write = (text: string): void => { this.toPipe(to, text); };
267
+ if (index === 1) request.stdout = write;
268
+ else {
269
+ request.stderr = write;
270
+ request.stderrIsPipe = true;
271
+ }
272
+ } else if (entry.type === 'inherit' || entry.type === 'fd') {
273
+ const inherited = inheritedWriter(entry.fd ?? index);
274
+ if (index === 1) request.stdout = inherited;
275
+ else request.stderr = inherited;
276
+ }
277
+ }
278
+
279
+ if (!runner.resolves(request)) {
280
+ this.closeFarEnds();
281
+ return UV_ENOENT;
282
+ }
283
+
284
+ this.run = runner.start(request);
285
+ // The number the parent reads off the handle is the child's own
286
+ // `process.pid`, as it is in Node; a runner that names none is given one.
287
+ this.pid = this.run.pid ?? nextPid++;
288
+ if (stdinFar) this.readStdinFrom(stdinFar);
289
+ return 0;
290
+ }
291
+
292
+ /**
293
+ * libuv's `uv_process_kill`: the run ends, or it was over already. Signal 0
294
+ * is the question "is it still there?", which kills nothing and answers 0
295
+ * for a run in flight and `ESRCH` for one that has ended.
296
+ */
297
+ kill(signal: number | string): number {
298
+ if (this.ended || !this.run) return UV_ESRCH;
299
+ if (signal === 0) return 0;
300
+ return this.run.kill(signalNameOf(signal));
301
+ }
302
+
303
+ close(callback?: () => void): void {
304
+ if (!this.closed) {
305
+ this.closed = true;
306
+ releaseHandle(this);
307
+ }
308
+ if (callback) queueMicrotask(callback);
309
+ }
310
+
311
+ /**
312
+ * The other half of a `pipe` entry: the end the child holds. It belongs to
313
+ * no run -- the parent holds the handle Node gave it and the child holds the
314
+ * one it opens; this is the wire between them.
315
+ */
316
+ private pairFarEnd(entry: StdioEntry): Pipe | null {
317
+ if (entry.type !== 'pipe' && entry.type !== 'overlapped') return null;
318
+ if (!entry.handle) return null;
319
+ const far = new Pipe(entry.ipc ? pipeConstants.IPC : pipeConstants.SOCKET);
320
+ __adoptHandle(far, null);
321
+ LibuvStreamWrap.pair(entry.handle, far);
322
+ return far;
323
+ }
324
+
325
+ /** The far end of fd `index`, whoever holds it now. */
326
+ private farEndAt(index: number): LibuvStreamWrap | null {
327
+ return this.stdio[index]?.handle?.peer ?? null;
328
+ }
329
+
330
+ private closeFarEnds(): void {
331
+ for (let index = 0; index < this.stdio.length; index += 1) {
332
+ const far = this.farEndAt(index);
333
+ if (!far) continue;
334
+ try { far.close(); } catch { /* an end already closed is already given up */ }
335
+ }
336
+ }
337
+
338
+ /** The child wrote to fd `index`; the parent's handle reads it. */
339
+ private toPipe(index: number, text: string): void {
340
+ const far = this.farEndAt(index);
341
+ if (!far || far.closed) return;
342
+ far.writeUtf8String(new WriteWrap(), text);
343
+ }
344
+
345
+ /** Bytes the parent writes reach the child's fd 0; the parent's EOF ends it. */
346
+ private readStdinFrom(far: Pipe): void {
347
+ far.onread = (arrayBuffer: ArrayBuffer | null): void => {
348
+ const length = streamBaseState[kReadBytesOrError];
349
+ if (length <= 0 || arrayBuffer === null) { this.run?.endStdin(); return; }
350
+ this.run?.writeStdin(new Uint8Array(arrayBuffer, streamBaseState[kArrayBufferOffset], length).slice());
351
+ };
352
+ far.readStart();
353
+ }
354
+
355
+ /**
356
+ * The run has ended. The child's ends of the pairings close, so the parent's
357
+ * streams read EOF as they do when a real child's descriptors go, and
358
+ * `onexit` fires once, after them: Node's `flushStdio` runs on the tick
359
+ * after `onexit` and must find the bytes already delivered.
360
+ */
361
+ private reportExit(code: number, signal: string | null): void {
362
+ if (this.ended) return;
363
+ this.ended = true;
364
+ this.closeFarEnds();
365
+ const report = this.onexit;
366
+ this.run = null;
367
+ if (report) report(code, signal);
368
+ }
369
+ }
370
+
371
+ export default { Process };
@@ -0,0 +1,141 @@
1
+ /**
2
+ * `internalBinding('spawn_sync')`: a child run to its end before the call
3
+ * returns.
4
+ *
5
+ * libuv's `uv_spawn_sync` answers one record -- a status, a signal, the bytes
6
+ * each descriptor produced, and an error where the child never started -- and
7
+ * `internal/child_process.js`'s `spawnSync` is four lines over it. That
8
+ * record is what this file answers, over `src/shims/sync-child.ts`: a thread
9
+ * of its own running a second engine, with every filesystem call crossing
10
+ * back to the caller. Where a realm cannot block at all, the error is
11
+ * `UV_ENOSYS`, which is what Node reports for a child it could not start.
12
+ */
13
+ import { libRequire } from '../require-hook';
14
+ import { UV_ENOSYS, UV_ENOENT, UV_EACCES, UV_ENOBUFS } from './uv';
15
+ import { runSyncChild, syncChildRefusal } from '../../shims/sync-child';
16
+ import { __substrateLineFor, __substrateShellLine } from '../../shims/command-line';
17
+
18
+ /** One entry of Node's `options.stdio`, as `getValidStdio(stdio, true)` builds it. */
19
+ interface SyncStdioEntry {
20
+ type: 'pipe' | 'overlapped' | 'ignore' | 'inherit' | 'fd' | 'wrap';
21
+ fd?: number;
22
+ input?: Uint8Array;
23
+ }
24
+
25
+ /** What `child_process.js`'s `spawnSync` hands the binding. */
26
+ interface SyncSpawnOptions {
27
+ file: string;
28
+ args?: string[];
29
+ cwd?: string;
30
+ envPairs?: string[];
31
+ stdio?: SyncStdioEntry[];
32
+ maxBuffer?: number;
33
+ killSignal?: number;
34
+ }
35
+
36
+ /** What libuv answers for one synchronous child. */
37
+ interface SyncSpawnResult {
38
+ pid: number;
39
+ output: Array<Uint8Array | null> | null;
40
+ status: number | null;
41
+ signal: string | null;
42
+ error?: number;
43
+ }
44
+
45
+ let nextPid = 1001 + Math.floor(Math.random() * 30000);
46
+
47
+ function environmentOf(envPairs: string[] | undefined): Record<string, string> | undefined {
48
+ if (!envPairs) return undefined;
49
+ const env: Record<string, string> = {};
50
+ for (const pair of envPairs) {
51
+ const at = pair.indexOf('=');
52
+ if (at <= 0) continue;
53
+ env[pair.slice(0, at)] = pair.slice(at + 1);
54
+ }
55
+ return env;
56
+ }
57
+
58
+ /** The program a caller can still write to: the engine's own stdout and stderr. */
59
+ function inheritedWriter(fd: number): ((text: string) => void) | undefined {
60
+ const realm = (globalThis as unknown as {
61
+ process?: { stdout?: { write(text: string): unknown }; stderr?: { write(text: string): unknown } };
62
+ }).process;
63
+ const stream = fd === 1 ? realm?.stdout : realm?.stderr;
64
+ if (!stream || typeof stream.write !== 'function') return undefined;
65
+ return (text: string) => {
66
+ try { stream.write(text); } catch { /* a stream that refuses still lets the child run */ }
67
+ };
68
+ }
69
+
70
+ /**
71
+ * libuv's synchronous spawn. Everything above it -- the encoding of the
72
+ * output, the `Error` an `error` number becomes, `execSync`'s throw -- is
73
+ * Node's own and is vendored.
74
+ */
75
+ /** Node's own `Buffer`, read when a child answers rather than when this loads. */
76
+ function bufferClass(): { from(value: unknown, encoding?: string): Uint8Array & { toString(encoding?: string): string } } {
77
+ return (libRequire('buffer') as { Buffer: { from(value: unknown, encoding?: string): Uint8Array & { toString(encoding?: string): string } } }).Buffer;
78
+ }
79
+
80
+ function spawn(options: SyncSpawnOptions): SyncSpawnResult {
81
+ const Buffer = bufferClass();
82
+ const pid = nextPid++;
83
+ const argv = options.args ?? [options.file];
84
+ const stdio = options.stdio ?? [];
85
+ const nothing = (error: number): SyncSpawnResult => ({ pid, output: null, status: null, signal: null, error });
86
+
87
+ if (syncChildRefusal() !== null) return nothing(UV_ENOSYS);
88
+
89
+ const input = stdio[0]?.input;
90
+ const realm = (globalThis as unknown as { process?: { cwd?: () => string; env?: Record<string, string> } }).process;
91
+ let answer;
92
+ try {
93
+ answer = runSyncChild({
94
+ command: __substrateLineFor(options.file, argv, options.cwd),
95
+ cwd: options.cwd ?? (typeof realm?.cwd === 'function' ? realm.cwd() : undefined),
96
+ env: environmentOf(options.envPairs) ?? (realm?.env ? { ...realm.env } : undefined),
97
+ input: input === undefined ? undefined : Buffer.from(input).toString('utf8'),
98
+ onStdout: stdio[1]?.type === 'inherit' ? inheritedWriter(1) : undefined,
99
+ onStderr: stdio[2]?.type === 'inherit' ? inheritedWriter(2) : undefined,
100
+ });
101
+ } catch {
102
+ return nothing(UV_ENOSYS);
103
+ }
104
+
105
+ // A program the shell has no command for is absent, as it is on a machine
106
+ // that does not carry that binary; a path that is there and is not a program
107
+ // is the shell's 126 and Node's EACCES. Only a caller that named a program
108
+ // can say so: a `-c` line is the shell's own, and its 127 is the line's.
109
+ const named = __substrateShellLine(options.file, argv) === null;
110
+ if (named && answer.status === 127 && /command not found|No such file or directory/u.test(answer.stderr)) {
111
+ return nothing(UV_ENOENT);
112
+ }
113
+ if (named && answer.status === 126 && /Permission denied|not executable/u.test(answer.stderr)) {
114
+ return nothing(UV_EACCES);
115
+ }
116
+
117
+ // Past `maxBuffer` the child is reported as having failed, and the bytes it
118
+ // had already produced come back whole: libuv reads in blocks and hands
119
+ // over what it read, which is why Node's own test says "we can have buffers
120
+ // larger than maxBuffer".
121
+ const limit = typeof options.maxBuffer === 'number' && options.maxBuffer >= 0 ? options.maxBuffer : Infinity;
122
+ const stdout = Buffer.from(answer.stdout, 'utf8');
123
+ const stderr = Buffer.from(answer.stderr, 'utf8');
124
+ const overflowed = stdout.length > limit || stderr.length > limit;
125
+ const output: Array<Uint8Array | null> = [null];
126
+ for (let index = 1; index < Math.max(3, stdio.length); index += 1) {
127
+ const bytes = index === 1 ? stdout : index === 2 ? stderr : null;
128
+ const kind = stdio[index]?.type;
129
+ output.push(bytes === null || kind === 'ignore' || kind === 'inherit' ? null : bytes);
130
+ }
131
+
132
+ return {
133
+ pid,
134
+ output,
135
+ status: answer.status,
136
+ signal: answer.signal,
137
+ ...(overflowed ? { error: UV_ENOBUFS } : {}),
138
+ };
139
+ }
140
+
141
+ export default { spawn };