@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,1003 @@
1
+ 'use strict';
2
+
3
+ const {
4
+ ArrayFrom,
5
+ ArrayPrototypePush,
6
+ ArrayPrototypeSlice,
7
+ ArrayPrototypeSort,
8
+ Error,
9
+ ErrorCaptureStackTrace,
10
+ FunctionPrototypeCall,
11
+ NumberParseInt,
12
+ ObjectDefineProperties,
13
+ ObjectDefineProperty,
14
+ ObjectFreeze,
15
+ ObjectGetOwnPropertyDescriptor,
16
+ ObjectGetOwnPropertyDescriptors,
17
+ ObjectGetPrototypeOf,
18
+ ObjectPrototypeHasOwnProperty,
19
+ ObjectSetPrototypeOf,
20
+ ObjectValues,
21
+ Promise,
22
+ ReflectApply,
23
+ ReflectConstruct,
24
+ RegExpPrototypeExec,
25
+ RegExpPrototypeGetDotAll,
26
+ RegExpPrototypeGetGlobal,
27
+ RegExpPrototypeGetHasIndices,
28
+ RegExpPrototypeGetIgnoreCase,
29
+ RegExpPrototypeGetMultiline,
30
+ RegExpPrototypeGetSource,
31
+ RegExpPrototypeGetSticky,
32
+ RegExpPrototypeGetUnicode,
33
+ SafeMap,
34
+ SafeSet,
35
+ SafeWeakMap,
36
+ SafeWeakRef,
37
+ StringPrototypeIncludes,
38
+ StringPrototypeReplace,
39
+ StringPrototypeSlice,
40
+ StringPrototypeToLowerCase,
41
+ StringPrototypeToUpperCase,
42
+ Symbol,
43
+ SymbolFor,
44
+ SymbolPrototypeGetDescription,
45
+ SymbolReplace,
46
+ SymbolSplit,
47
+ } = primordials;
48
+
49
+ const {
50
+ codes: {
51
+ ERR_NO_CRYPTO,
52
+ ERR_NO_TYPESCRIPT,
53
+ ERR_UNKNOWN_SIGNAL,
54
+ },
55
+ isErrorStackTraceLimitWritable,
56
+ overrideStackTrace,
57
+ uvErrmapGet,
58
+ } = require('internal/errors');
59
+ const { signals } = internalBinding('constants').os;
60
+ const {
61
+ guessHandleType: _guessHandleType,
62
+ defineLazyProperties,
63
+ privateSymbols: {
64
+ arrow_message_private_symbol,
65
+ decorated_private_symbol,
66
+ },
67
+ sleep: _sleep,
68
+ } = internalBinding('util');
69
+ const { isNativeError, isPromise } = internalBinding('types');
70
+ const { getOptionValue } = require('internal/options');
71
+ const assert = require('internal/assert');
72
+ const { encodings } = internalBinding('string_decoder');
73
+
74
+ const noCrypto = !process.versions.openssl;
75
+ const noTypeScript = !process.versions.amaro;
76
+
77
+ const isWindows = process.platform === 'win32';
78
+ const isMacOS = process.platform === 'darwin';
79
+
80
+ const experimentalWarnings = new SafeSet();
81
+
82
+ const colorRegExp = /\u001b\[\d\d?m/g; // eslint-disable-line no-control-regex
83
+
84
+ let uvBinding;
85
+
86
+ function lazyUv() {
87
+ uvBinding ??= internalBinding('uv');
88
+ return uvBinding;
89
+ }
90
+
91
+ function removeColors(str) {
92
+ return StringPrototypeReplace(str, colorRegExp, '');
93
+ }
94
+
95
+ function isError(e) {
96
+ // An error could be an instance of Error while not being a native error
97
+ // or could be from a different realm and not be instance of Error but still
98
+ // be a native error.
99
+ return isNativeError(e) || e instanceof Error;
100
+ }
101
+
102
+ // Keep a list of deprecation codes that have been warned on so we only warn on
103
+ // each one once.
104
+ const codesWarned = new SafeSet();
105
+
106
+ let validateString;
107
+
108
+ function getDeprecationWarningEmitter(
109
+ code, msg, deprecated, useEmitSync,
110
+ shouldEmitWarning = () => true,
111
+ ) {
112
+ let warned = false;
113
+ return function(arg) {
114
+ if (!warned && shouldEmitWarning(arg)) {
115
+ warned = true;
116
+ if (code === 'ExperimentalWarning') {
117
+ process.emitWarning(msg, code, deprecated);
118
+ } else if (code !== undefined) {
119
+ if (!codesWarned.has(code)) {
120
+ const emitWarning = useEmitSync ?
121
+ require('internal/process/warning').emitWarningSync :
122
+ process.emitWarning;
123
+ emitWarning(msg, 'DeprecationWarning', code, deprecated);
124
+ codesWarned.add(code);
125
+ }
126
+ } else {
127
+ process.emitWarning(msg, 'DeprecationWarning', deprecated);
128
+ }
129
+ }
130
+ };
131
+ }
132
+
133
+ function isPendingDeprecation() {
134
+ return getOptionValue('--pending-deprecation') &&
135
+ !getOptionValue('--no-deprecation');
136
+ }
137
+
138
+ // Internal deprecator for pending --pending-deprecation. This can be invoked
139
+ // at snapshot building time as the warning permission is only queried at
140
+ // run time.
141
+ function pendingDeprecate(fn, msg, code) {
142
+ const emitDeprecationWarning = getDeprecationWarningEmitter(
143
+ code, msg, deprecated, false, isPendingDeprecation,
144
+ );
145
+ function deprecated(...args) {
146
+ emitDeprecationWarning();
147
+ return ReflectApply(fn, this, args);
148
+ }
149
+
150
+ ObjectDefineProperty(deprecated, 'length', {
151
+ __proto__: null,
152
+ ...ObjectGetOwnPropertyDescriptor(fn, 'length'),
153
+ });
154
+
155
+ return deprecated;
156
+ }
157
+
158
+ // Mark that a method should not be used.
159
+ // Returns a modified function which warns once by default.
160
+ // If --no-deprecation is set, then it is a no-op.
161
+ function deprecate(fn, msg, code, useEmitSync) {
162
+ // Lazy-load to avoid a circular dependency.
163
+ if (validateString === undefined)
164
+ ({ validateString } = require('internal/validators'));
165
+
166
+ if (code !== undefined)
167
+ validateString(code, 'code');
168
+
169
+ const emitDeprecationWarning = getDeprecationWarningEmitter(
170
+ code, msg, deprecated, useEmitSync,
171
+ );
172
+
173
+ function deprecated(...args) {
174
+ // TODO(joyeecheung): use getOptionValue('--no-deprecation') instead.
175
+ if (!process.noDeprecation) {
176
+ emitDeprecationWarning();
177
+ }
178
+ if (new.target) {
179
+ return ReflectConstruct(fn, args, new.target);
180
+ }
181
+ return ReflectApply(fn, this, args);
182
+ }
183
+
184
+ // The wrapper will keep the same prototype as fn to maintain prototype chain
185
+ ObjectSetPrototypeOf(deprecated, fn);
186
+ if (fn.prototype) {
187
+ // Setting this (rather than using Object.setPrototype, as above) ensures
188
+ // that calling the unwrapped constructor gives an instanceof the wrapped
189
+ // constructor.
190
+ deprecated.prototype = fn.prototype;
191
+ }
192
+
193
+ ObjectDefineProperty(deprecated, 'length', {
194
+ __proto__: null,
195
+ ...ObjectGetOwnPropertyDescriptor(fn, 'length'),
196
+ });
197
+
198
+ return deprecated;
199
+ }
200
+
201
+ function decorateErrorStack(err) {
202
+ if (!(isError(err) && err.stack) || err[decorated_private_symbol])
203
+ return;
204
+
205
+ const arrow = err[arrow_message_private_symbol];
206
+
207
+ if (arrow) {
208
+ err.stack = arrow + err.stack;
209
+ err[decorated_private_symbol] = true;
210
+ }
211
+ }
212
+
213
+ function assertCrypto() {
214
+ if (noCrypto)
215
+ throw new ERR_NO_CRYPTO();
216
+ }
217
+
218
+ function assertTypeScript() {
219
+ if (noTypeScript)
220
+ throw new ERR_NO_TYPESCRIPT();
221
+ }
222
+
223
+ /**
224
+ * Move the "slow cases" to a separate function to make sure this function gets
225
+ * inlined properly. That prioritizes the common case.
226
+ * @param {unknown} enc
227
+ * @returns {string | undefined} Returns undefined if there is no match.
228
+ */
229
+ function normalizeEncoding(enc) {
230
+ if (enc == null || enc === 'utf8' || enc === 'utf-8') return 'utf8';
231
+ return slowCases(enc);
232
+ }
233
+
234
+ function slowCases(enc) {
235
+ switch (enc.length) {
236
+ case 4:
237
+ if (enc === 'UTF8') return 'utf8';
238
+ if (enc === 'ucs2' || enc === 'UCS2') return 'utf16le';
239
+ enc = StringPrototypeToLowerCase(enc);
240
+ if (enc === 'utf8') return 'utf8';
241
+ if (enc === 'ucs2') return 'utf16le';
242
+ break;
243
+ case 3:
244
+ if (enc === 'hex' || enc === 'HEX' ||
245
+ StringPrototypeToLowerCase(enc) === 'hex')
246
+ return 'hex';
247
+ break;
248
+ case 5:
249
+ if (enc === 'ascii') return 'ascii';
250
+ if (enc === 'ucs-2') return 'utf16le';
251
+ if (enc === 'UTF-8') return 'utf8';
252
+ if (enc === 'ASCII') return 'ascii';
253
+ if (enc === 'UCS-2') return 'utf16le';
254
+ enc = StringPrototypeToLowerCase(enc);
255
+ if (enc === 'utf-8') return 'utf8';
256
+ if (enc === 'ascii') return 'ascii';
257
+ if (enc === 'ucs-2') return 'utf16le';
258
+ break;
259
+ case 6:
260
+ if (enc === 'base64') return 'base64';
261
+ if (enc === 'latin1' || enc === 'binary') return 'latin1';
262
+ if (enc === 'BASE64') return 'base64';
263
+ if (enc === 'LATIN1' || enc === 'BINARY') return 'latin1';
264
+ enc = StringPrototypeToLowerCase(enc);
265
+ if (enc === 'base64') return 'base64';
266
+ if (enc === 'latin1' || enc === 'binary') return 'latin1';
267
+ break;
268
+ case 7:
269
+ if (enc === 'utf16le' || enc === 'UTF16LE' ||
270
+ StringPrototypeToLowerCase(enc) === 'utf16le')
271
+ return 'utf16le';
272
+ break;
273
+ case 8:
274
+ if (enc === 'utf-16le' || enc === 'UTF-16LE' ||
275
+ StringPrototypeToLowerCase(enc) === 'utf-16le')
276
+ return 'utf16le';
277
+ break;
278
+ case 9:
279
+ if (enc === 'base64url' || enc === 'BASE64URL' ||
280
+ StringPrototypeToLowerCase(enc) === 'base64url')
281
+ return 'base64url';
282
+ break;
283
+ default:
284
+ if (enc === '') return 'utf8';
285
+ }
286
+ }
287
+
288
+ /**
289
+ * @param {string} feature Feature name used in the warning message
290
+ * @param {string} messagePrefix Prefix of the warning message
291
+ * @param {string} code See documentation of process.emitWarning
292
+ * @param {string} ctor See documentation of process.emitWarning
293
+ */
294
+ function emitExperimentalWarning(feature, messagePrefix, code, ctor) {
295
+ if (experimentalWarnings.has(feature)) return;
296
+ experimentalWarnings.add(feature);
297
+ let msg = `${feature} is an experimental feature and might change at any time`;
298
+ if (messagePrefix) {
299
+ msg = messagePrefix + msg;
300
+ }
301
+ process.emitWarning(msg, 'ExperimentalWarning', code, ctor);
302
+ }
303
+
304
+ function filterDuplicateStrings(items, low) {
305
+ const map = new SafeMap();
306
+ for (let i = 0; i < items.length; i++) {
307
+ const item = items[i];
308
+ const key = StringPrototypeToLowerCase(item);
309
+ if (low) {
310
+ map.set(key, key);
311
+ } else {
312
+ map.set(key, item);
313
+ }
314
+ }
315
+ return ArrayPrototypeSort(ArrayFrom(map.values()));
316
+ }
317
+
318
+ function cachedResult(fn) {
319
+ let result;
320
+ return () => {
321
+ if (result === undefined)
322
+ result = fn();
323
+ return ArrayPrototypeSlice(result);
324
+ };
325
+ }
326
+
327
+ // Useful for Wrapping an ES6 Class with a constructor Function that
328
+ // does not require the new keyword. For instance:
329
+ // class A { constructor(x) {this.x = x;}}
330
+ // const B = createClassWrapper(A);
331
+ // B() instanceof A // true
332
+ // B() instanceof B // true
333
+ function createClassWrapper(type) {
334
+ function fn(...args) {
335
+ return ReflectConstruct(type, args, new.target || type);
336
+ }
337
+ // Mask the wrapper function name and length values
338
+ ObjectDefineProperties(fn, {
339
+ name: { __proto__: null, value: type.name },
340
+ length: { __proto__: null, value: type.length },
341
+ });
342
+ ObjectSetPrototypeOf(fn, type);
343
+ fn.prototype = type.prototype;
344
+ return fn;
345
+ }
346
+
347
+ let signalsToNamesMapping;
348
+ function getSignalsToNamesMapping() {
349
+ if (signalsToNamesMapping !== undefined)
350
+ return signalsToNamesMapping;
351
+
352
+ signalsToNamesMapping = { __proto__: null };
353
+ for (const key in signals) {
354
+ signalsToNamesMapping[signals[key]] = key;
355
+ }
356
+
357
+ return signalsToNamesMapping;
358
+ }
359
+
360
+ function convertToValidSignal(signal) {
361
+ if (typeof signal === 'number' && getSignalsToNamesMapping()[signal])
362
+ return signal;
363
+
364
+ if (typeof signal === 'string') {
365
+ const signalName = signals[StringPrototypeToUpperCase(signal)];
366
+ if (signalName) return signalName;
367
+ }
368
+
369
+ throw new ERR_UNKNOWN_SIGNAL(signal);
370
+ }
371
+
372
+ function getConstructorOf(obj) {
373
+ while (obj) {
374
+ const descriptor = ObjectGetOwnPropertyDescriptor(obj, 'constructor');
375
+ if (descriptor !== undefined &&
376
+ typeof descriptor.value === 'function' &&
377
+ descriptor.value.name !== '') {
378
+ return descriptor.value;
379
+ }
380
+
381
+ obj = ObjectGetPrototypeOf(obj);
382
+ }
383
+
384
+ return null;
385
+ }
386
+
387
+ let cachedURL;
388
+ let cachedCWD;
389
+
390
+ /**
391
+ * Get the current working directory while accounting for the possibility that it has been deleted.
392
+ * `process.cwd()` can fail if the parent directory is deleted while the process runs.
393
+ * @returns {URL} The current working directory or the volume root if it cannot be determined.
394
+ */
395
+ function getCWDURL() {
396
+ const { sep } = require('path');
397
+ const { pathToFileURL } = require('internal/url');
398
+
399
+ let cwd;
400
+
401
+ try {
402
+ // The implementation of `process.cwd()` already uses proper cache when it can.
403
+ // It's a relatively cheap call performance-wise for the most common use case.
404
+ cwd = process.cwd();
405
+ } catch {
406
+ cachedURL ??= pathToFileURL(sep);
407
+ }
408
+
409
+ if (cwd != null && cwd !== cachedCWD) {
410
+ cachedURL = pathToFileURL(cwd + sep);
411
+ cachedCWD = cwd;
412
+ }
413
+
414
+ return cachedURL;
415
+ }
416
+
417
+ function getSystemErrorMessage(err) {
418
+ return lazyUv().getErrorMessage(err);
419
+ }
420
+
421
+ function getSystemErrorName(err) {
422
+ const entry = uvErrmapGet(err);
423
+ return entry ? entry[0] : `Unknown system error ${err}`;
424
+ }
425
+
426
+ function getSystemErrorMap() {
427
+ return lazyUv().getErrorMap();
428
+ }
429
+
430
+ const kCustomPromisifiedSymbol = SymbolFor('nodejs.util.promisify.custom');
431
+ const kCustomPromisifyArgsSymbol = Symbol('customPromisifyArgs');
432
+
433
+ let validateFunction;
434
+
435
+ function promisify(original) {
436
+ // Lazy-load to avoid a circular dependency.
437
+ if (validateFunction === undefined)
438
+ ({ validateFunction } = require('internal/validators'));
439
+
440
+ validateFunction(original, 'original');
441
+
442
+ if (original[kCustomPromisifiedSymbol]) {
443
+ const fn = original[kCustomPromisifiedSymbol];
444
+
445
+ validateFunction(fn, 'util.promisify.custom');
446
+
447
+ return ObjectDefineProperty(fn, kCustomPromisifiedSymbol, {
448
+ __proto__: null,
449
+ value: fn, enumerable: false, writable: false, configurable: true,
450
+ });
451
+ }
452
+
453
+ // Names to create an object from in case the callback receives multiple
454
+ // arguments, e.g. ['bytesRead', 'buffer'] for fs.read.
455
+ const argumentNames = original[kCustomPromisifyArgsSymbol];
456
+
457
+ function fn(...args) {
458
+ return new Promise((resolve, reject) => {
459
+ ArrayPrototypePush(args, (err, ...values) => {
460
+ if (err) {
461
+ return reject(err);
462
+ }
463
+ if (argumentNames !== undefined && values.length > 1) {
464
+ const obj = {};
465
+ for (let i = 0; i < argumentNames.length; i++)
466
+ obj[argumentNames[i]] = values[i];
467
+ resolve(obj);
468
+ } else {
469
+ resolve(values[0]);
470
+ }
471
+ });
472
+ if (isPromise(ReflectApply(original, this, args))) {
473
+ process.emitWarning('Calling promisify on a function that returns a Promise is likely a mistake.',
474
+ 'DeprecationWarning', 'DEP0174');
475
+ }
476
+ });
477
+ }
478
+
479
+ ObjectSetPrototypeOf(fn, ObjectGetPrototypeOf(original));
480
+
481
+ ObjectDefineProperty(fn, kCustomPromisifiedSymbol, {
482
+ __proto__: null,
483
+ value: fn, enumerable: false, writable: false, configurable: true,
484
+ });
485
+
486
+ const descriptors = ObjectGetOwnPropertyDescriptors(original);
487
+ const propertiesValues = ObjectValues(descriptors);
488
+ for (let i = 0; i < propertiesValues.length; i++) {
489
+ // We want to use null-prototype objects to not rely on globally mutable
490
+ // %Object.prototype%.
491
+ ObjectSetPrototypeOf(propertiesValues[i], null);
492
+ }
493
+ return ObjectDefineProperties(fn, descriptors);
494
+ }
495
+
496
+ promisify.custom = kCustomPromisifiedSymbol;
497
+
498
+ // The built-in Array#join is slower in v8 6.0
499
+ function join(output, separator) {
500
+ let str = '';
501
+ if (output.length !== 0) {
502
+ const lastIndex = output.length - 1;
503
+ for (let i = 0; i < lastIndex; i++) {
504
+ // It is faster not to use a template string here
505
+ str += output[i];
506
+ str += separator;
507
+ }
508
+ str += output[lastIndex];
509
+ }
510
+ return str;
511
+ }
512
+
513
+ // As of V8 6.6, depending on the size of the array, this is anywhere
514
+ // between 1.5-10x faster than the two-arg version of Array#splice()
515
+ function spliceOne(list, index) {
516
+ for (; index + 1 < list.length; index++)
517
+ list[index] = list[index + 1];
518
+ list.pop();
519
+ }
520
+
521
+ const kNodeModulesRE = /^(?:.*)[\\/]node_modules[\\/]/;
522
+
523
+ function isUnderNodeModules(filename) {
524
+ return filename && (RegExpPrototypeExec(kNodeModulesRE, filename) !== null);
525
+ }
526
+
527
+ let getStructuredStackImpl;
528
+
529
+ function lazyGetStructuredStack() {
530
+ if (getStructuredStackImpl === undefined) {
531
+ // Lazy-load to avoid a circular dependency.
532
+ const { runInNewContext } = require('vm');
533
+ // Use `runInNewContext()` to get something tamper-proof and
534
+ // side-effect-free. Since this is currently only used for a deprecated API
535
+ // and module mocking, the perf implications should be okay.
536
+ getStructuredStackImpl = runInNewContext(`(function() {
537
+ try { Error.stackTraceLimit = Infinity; } catch {}
538
+ return function structuredStack() {
539
+ const e = new Error();
540
+ overrideStackTrace.set(e, (err, trace) => trace);
541
+ return e.stack;
542
+ };
543
+ })()`, { overrideStackTrace }, { filename: 'structured-stack' });
544
+ }
545
+
546
+ return getStructuredStackImpl;
547
+ }
548
+
549
+ function getStructuredStack() {
550
+ const getStructuredStackImpl = lazyGetStructuredStack();
551
+
552
+ return getStructuredStackImpl();
553
+ }
554
+
555
+ function once(callback, { preserveReturnValue = false } = kEmptyObject) {
556
+ let called = false;
557
+ let returnValue;
558
+ return function(...args) {
559
+ if (called) return returnValue;
560
+ called = true;
561
+ const result = ReflectApply(callback, this, args);
562
+ returnValue = preserveReturnValue ? result : undefined;
563
+ return result;
564
+ };
565
+ }
566
+
567
+ let validateUint32;
568
+
569
+ function sleep(msec) {
570
+ // Lazy-load to avoid a circular dependency.
571
+ if (validateUint32 === undefined)
572
+ ({ validateUint32 } = require('internal/validators'));
573
+
574
+ validateUint32(msec, 'msec');
575
+ _sleep(msec);
576
+ }
577
+
578
+ // https://heycam.github.io/webidl/#define-the-operations
579
+ function defineOperation(target, name, method) {
580
+ ObjectDefineProperty(target, name, {
581
+ __proto__: null,
582
+ writable: true,
583
+ enumerable: true,
584
+ configurable: true,
585
+ value: method,
586
+ });
587
+ }
588
+
589
+ // https://heycam.github.io/webidl/#es-interfaces
590
+ function exposeInterface(target, name, interfaceObject) {
591
+ ObjectDefineProperty(target, name, {
592
+ __proto__: null,
593
+ writable: true,
594
+ enumerable: false,
595
+ configurable: true,
596
+ value: interfaceObject,
597
+ });
598
+ }
599
+
600
+ // https://heycam.github.io/webidl/#es-namespaces
601
+ function exposeNamespace(target, name, namespaceObject) {
602
+ ObjectDefineProperty(target, name, {
603
+ __proto__: null,
604
+ writable: true,
605
+ enumerable: false,
606
+ configurable: true,
607
+ value: namespaceObject,
608
+ });
609
+ }
610
+
611
+ function exposeGetterAndSetter(target, name, getter, setter = undefined) {
612
+ ObjectDefineProperty(target, name, {
613
+ __proto__: null,
614
+ enumerable: false,
615
+ configurable: true,
616
+ get: getter,
617
+ set: setter,
618
+ });
619
+ }
620
+
621
+ function defineReplaceableLazyAttribute(target, id, keys, writable = true, check) {
622
+ let mod;
623
+ for (let i = 0; i < keys.length; i++) {
624
+ const key = keys[i];
625
+ let value;
626
+ let setterCalled = false;
627
+
628
+ function get() {
629
+ if (check !== undefined) {
630
+ FunctionPrototypeCall(check, this);
631
+ }
632
+ if (setterCalled) {
633
+ return value;
634
+ }
635
+ mod ??= require(id);
636
+ value ??= mod[key];
637
+ return value;
638
+ }
639
+
640
+ ObjectDefineProperty(get, 'name', {
641
+ __proto__: null,
642
+ value: `get ${key}`,
643
+ });
644
+
645
+ function set(val) {
646
+ setterCalled = true;
647
+ value = val;
648
+ }
649
+ ObjectDefineProperty(set, 'name', {
650
+ __proto__: null,
651
+ value: `set ${key}`,
652
+ });
653
+
654
+ ObjectDefineProperty(target, key, {
655
+ __proto__: null,
656
+ enumerable: true,
657
+ configurable: true,
658
+ get,
659
+ set: writable ? set : undefined,
660
+ });
661
+ }
662
+ }
663
+
664
+ function exposeLazyInterfaces(target, id, keys) {
665
+ defineLazyProperties(target, id, keys, false);
666
+ }
667
+
668
+ let _DOMException;
669
+ const lazyDOMExceptionClass = () => {
670
+ _DOMException ??= internalBinding('messaging').DOMException;
671
+ return _DOMException;
672
+ };
673
+
674
+ const lazyDOMException = (message, name) => {
675
+ _DOMException ??= internalBinding('messaging').DOMException;
676
+ if (isErrorStackTraceLimitWritable()) {
677
+ const limit = Error.stackTraceLimit;
678
+ Error.stackTraceLimit = 0;
679
+ const ex = new _DOMException(message, name);
680
+ Error.stackTraceLimit = limit;
681
+ ErrorCaptureStackTrace(ex, lazyDOMException);
682
+ return ex;
683
+ }
684
+ return new _DOMException(message, name);
685
+
686
+ };
687
+
688
+ const kEnumerableProperty = { __proto__: null };
689
+ kEnumerableProperty.enumerable = true;
690
+ ObjectFreeze(kEnumerableProperty);
691
+
692
+ const kEmptyObject = ObjectFreeze({ __proto__: null });
693
+
694
+ function filterOwnProperties(source, keys) {
695
+ const filtered = { __proto__: null };
696
+ for (let i = 0; i < keys.length; i++) {
697
+ const key = keys[i];
698
+ if (ObjectPrototypeHasOwnProperty(source, key)) {
699
+ filtered[key] = source[key];
700
+ }
701
+ }
702
+
703
+ return filtered;
704
+ }
705
+
706
+ /**
707
+ * Mimics `obj[key] = value` but ignoring potential prototype inheritance.
708
+ * @param {any} obj
709
+ * @param {string} key
710
+ * @param {any} value
711
+ * @returns {any}
712
+ */
713
+ function setOwnProperty(obj, key, value) {
714
+ return ObjectDefineProperty(obj, key, {
715
+ __proto__: null,
716
+ configurable: true,
717
+ enumerable: true,
718
+ value,
719
+ writable: true,
720
+ });
721
+ }
722
+
723
+ let internalGlobal;
724
+ function getInternalGlobal() {
725
+ if (internalGlobal == null) {
726
+ // Lazy-load to avoid a circular dependency.
727
+ const { runInNewContext } = require('vm');
728
+ internalGlobal = runInNewContext('this', undefined, { contextName: 'internal' });
729
+ }
730
+ return internalGlobal;
731
+ }
732
+
733
+ function SideEffectFreeRegExpPrototypeExec(regex, string) {
734
+ const { RegExp: RegExpFromAnotherRealm } = getInternalGlobal();
735
+ return FunctionPrototypeCall(RegExpFromAnotherRealm.prototype.exec, regex, string);
736
+ }
737
+
738
+ const crossRealmRegexes = new SafeWeakMap();
739
+ function getCrossRealmRegex(regex) {
740
+ const cached = crossRealmRegexes.get(regex);
741
+ if (cached) return cached;
742
+
743
+ let flagString = '';
744
+ if (RegExpPrototypeGetHasIndices(regex)) flagString += 'd';
745
+ if (RegExpPrototypeGetGlobal(regex)) flagString += 'g';
746
+ if (RegExpPrototypeGetIgnoreCase(regex)) flagString += 'i';
747
+ if (RegExpPrototypeGetMultiline(regex)) flagString += 'm';
748
+ if (RegExpPrototypeGetDotAll(regex)) flagString += 's';
749
+ if (RegExpPrototypeGetUnicode(regex)) flagString += 'u';
750
+ if (RegExpPrototypeGetSticky(regex)) flagString += 'y';
751
+
752
+ const { RegExp: RegExpFromAnotherRealm } = getInternalGlobal();
753
+ const crossRealmRegex = new RegExpFromAnotherRealm(RegExpPrototypeGetSource(regex), flagString);
754
+ crossRealmRegexes.set(regex, crossRealmRegex);
755
+ return crossRealmRegex;
756
+ }
757
+
758
+ function SideEffectFreeRegExpPrototypeSymbolReplace(regex, string, replacement) {
759
+ return getCrossRealmRegex(regex)[SymbolReplace](string, replacement);
760
+ }
761
+
762
+ function SideEffectFreeRegExpPrototypeSymbolSplit(regex, string, limit = undefined) {
763
+ return getCrossRealmRegex(regex)[SymbolSplit](string, limit);
764
+ }
765
+
766
+ /**
767
+ * Helper function to lazy-load an initialize-once value.
768
+ * @template T Return value of initializer
769
+ * @param {()=>T} initializer Initializer of the lazily loaded value.
770
+ * @returns {()=>T}
771
+ */
772
+ function getLazy(initializer) {
773
+ let value;
774
+ let initialized = false;
775
+ return function() {
776
+ if (initialized === false) {
777
+ value = initializer();
778
+ initialized = true;
779
+ }
780
+ return value;
781
+ };
782
+ }
783
+
784
+ // Setup user-facing NODE_V8_COVERAGE environment variable that writes
785
+ // ScriptCoverage objects to a specified directory.
786
+ function setupCoverageHooks(dir) {
787
+ const cwd = require('internal/process/execution').tryGetCwd();
788
+ const { resolve } = require('path');
789
+ const coverageDirectory = resolve(cwd, dir);
790
+ const { sourceMapCacheToObject } =
791
+ require('internal/source_map/source_map_cache');
792
+
793
+ if (process.features.inspector) {
794
+ internalBinding('profiler').setCoverageDirectory(coverageDirectory);
795
+ internalBinding('profiler').setSourceMapCacheGetter(sourceMapCacheToObject);
796
+ } else {
797
+ process.emitWarning('The inspector is disabled, ' +
798
+ 'coverage could not be collected',
799
+ 'Warning');
800
+ return '';
801
+ }
802
+ return coverageDirectory;
803
+ }
804
+
805
+ // Returns the number of ones in the binary representation of the decimal
806
+ // number.
807
+ function countBinaryOnes(n) {
808
+ // Count the number of bits set in parallel, which is faster than looping
809
+ n = n - ((n >>> 1) & 0x55555555);
810
+ n = (n & 0x33333333) + ((n >>> 2) & 0x33333333);
811
+ return ((n + (n >>> 4) & 0xF0F0F0F) * 0x1010101) >>> 24;
812
+ }
813
+
814
+ function getCIDR(address, netmask, family) {
815
+ let ones = 0;
816
+ let split = '.';
817
+ let range = 10;
818
+ let groupLength = 8;
819
+ let hasZeros = false;
820
+ let lastPos = 0;
821
+
822
+ if (family === 'IPv6') {
823
+ split = ':';
824
+ range = 16;
825
+ groupLength = 16;
826
+ }
827
+
828
+ for (let i = 0; i < netmask.length; i++) {
829
+ if (netmask[i] !== split) {
830
+ if (i + 1 < netmask.length) {
831
+ continue;
832
+ }
833
+ i++;
834
+ }
835
+ const part = StringPrototypeSlice(netmask, lastPos, i);
836
+ lastPos = i + 1;
837
+ if (part !== '') {
838
+ if (hasZeros) {
839
+ if (part !== '0') {
840
+ return null;
841
+ }
842
+ } else {
843
+ const binary = NumberParseInt(part, range);
844
+ const binaryOnes = countBinaryOnes(binary);
845
+ ones += binaryOnes;
846
+ if (binaryOnes !== groupLength) {
847
+ if (StringPrototypeIncludes(binary.toString(2), '01')) {
848
+ return null;
849
+ }
850
+ hasZeros = true;
851
+ }
852
+ }
853
+ }
854
+ }
855
+
856
+ return `${address}/${ones}`;
857
+ }
858
+
859
+ const handleTypes = ['TCP', 'TTY', 'UDP', 'FILE', 'PIPE', 'UNKNOWN'];
860
+ function guessHandleType(fd) {
861
+ const type = _guessHandleType(fd);
862
+ return handleTypes[type];
863
+ }
864
+
865
+ class WeakReference {
866
+ #weak = null;
867
+ // eslint-disable-next-line no-unused-private-class-members
868
+ #strong = null;
869
+ #refCount = 0;
870
+ constructor(object) {
871
+ this.#weak = new SafeWeakRef(object);
872
+ }
873
+
874
+ incRef() {
875
+ this.#refCount++;
876
+ if (this.#refCount === 1) {
877
+ const derefed = this.#weak.deref();
878
+ if (derefed !== undefined) {
879
+ this.#strong = derefed;
880
+ }
881
+ }
882
+ return this.#refCount;
883
+ }
884
+
885
+ decRef() {
886
+ this.#refCount--;
887
+ if (this.#refCount === 0) {
888
+ this.#strong = null;
889
+ }
890
+ return this.#refCount;
891
+ }
892
+
893
+ get() {
894
+ return this.#weak.deref();
895
+ }
896
+ }
897
+
898
+ const encodingsMap = { __proto__: null };
899
+ for (let i = 0; i < encodings.length; ++i)
900
+ encodingsMap[encodings[i]] = i;
901
+
902
+ /**
903
+ * Reassigns the .name property of a function.
904
+ * Should be used when function can't be initially defined with desired name
905
+ * or when desired name should include `#`, `[`, `]`, etc.
906
+ * @param {string | symbol} name
907
+ * @param {Function} fn
908
+ * @param {object} [descriptor]
909
+ * @returns {Function} the same function, renamed
910
+ */
911
+ function assignFunctionName(name, fn, descriptor = kEmptyObject) {
912
+ if (typeof name !== 'string') {
913
+ const symbolDescription = SymbolPrototypeGetDescription(name);
914
+ assert(symbolDescription !== undefined, 'Attempted to name function after descriptionless Symbol');
915
+ name = `[${symbolDescription}]`;
916
+ }
917
+ return ObjectDefineProperty(fn, 'name', {
918
+ __proto__: null,
919
+ writable: false,
920
+ enumerable: false,
921
+ configurable: true,
922
+ ...ObjectGetOwnPropertyDescriptor(fn, 'name'),
923
+ ...descriptor,
924
+ value: name,
925
+ });
926
+ }
927
+
928
+ module.exports = {
929
+ getLazy,
930
+ assertCrypto,
931
+ assertTypeScript,
932
+ assignFunctionName,
933
+ cachedResult,
934
+ convertToValidSignal,
935
+ createClassWrapper,
936
+ decorateErrorStack,
937
+ defineOperation,
938
+ defineLazyProperties,
939
+ defineReplaceableLazyAttribute,
940
+ deprecate,
941
+ emitExperimentalWarning,
942
+ encodingsMap,
943
+ exposeInterface,
944
+ exposeLazyInterfaces,
945
+ exposeNamespace,
946
+ exposeGetterAndSetter,
947
+ filterDuplicateStrings,
948
+ filterOwnProperties,
949
+ getConstructorOf,
950
+ getCIDR,
951
+ getCWDURL,
952
+ getInternalGlobal,
953
+ getStructuredStack,
954
+ getSystemErrorMap,
955
+ getSystemErrorName,
956
+ getSystemErrorMessage,
957
+ guessHandleType,
958
+ isError,
959
+ isUnderNodeModules,
960
+ isMacOS,
961
+ isWindows,
962
+ join,
963
+ lazyDOMException,
964
+ lazyDOMExceptionClass,
965
+ normalizeEncoding,
966
+ once,
967
+ promisify,
968
+ SideEffectFreeRegExpPrototypeExec,
969
+ SideEffectFreeRegExpPrototypeSymbolReplace,
970
+ SideEffectFreeRegExpPrototypeSymbolSplit,
971
+ sleep,
972
+ spliceOne,
973
+ setupCoverageHooks,
974
+ removeColors,
975
+
976
+ // Define Symbol.dispose and Symbol.asyncDispose
977
+ // Until these are defined by the environment.
978
+ // TODO(MoLow): Remove this polyfill once Symbol.dispose and Symbol.asyncDispose are available in primordials.
979
+ // eslint-disable-next-line node-core/prefer-primordials
980
+ SymbolDispose: Symbol.dispose || SymbolFor('nodejs.dispose'),
981
+ // eslint-disable-next-line node-core/prefer-primordials
982
+ SymbolAsyncDispose: Symbol.asyncDispose || SymbolFor('nodejs.asyncDispose'),
983
+
984
+ // Symbol used to customize promisify conversion
985
+ customPromisifyArgs: kCustomPromisifyArgsSymbol,
986
+
987
+ // Symbol used to provide a custom inspect function for an object as an
988
+ // alternative to using 'inspect'
989
+ customInspectSymbol: SymbolFor('nodejs.util.inspect.custom'),
990
+
991
+ // Used by the buffer module to capture an internal reference to the
992
+ // default isEncoding implementation, just in case userland overrides it.
993
+ kIsEncodingSymbol: Symbol('kIsEncodingSymbol'),
994
+ kVmBreakFirstLineSymbol: Symbol('kVmBreakFirstLineSymbol'),
995
+
996
+ kEmptyObject,
997
+ kEnumerableProperty,
998
+ setOwnProperty,
999
+ pendingDeprecate,
1000
+ WeakReference,
1001
+ isPendingDeprecation,
1002
+ getDeprecationWarningEmitter,
1003
+ };