@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,654 @@
1
+ /* eslint jsdoc/require-jsdoc: "error" */
2
+
3
+ 'use strict';
4
+
5
+ const {
6
+ ArrayIsArray,
7
+ ArrayPrototypeIncludes,
8
+ ArrayPrototypeJoin,
9
+ ArrayPrototypeMap,
10
+ NumberIsFinite,
11
+ NumberIsInteger,
12
+ NumberIsNaN,
13
+ NumberMAX_SAFE_INTEGER,
14
+ NumberMIN_SAFE_INTEGER,
15
+ NumberParseInt,
16
+ ObjectPrototypeHasOwnProperty,
17
+ RegExpPrototypeExec,
18
+ String,
19
+ StringPrototypeToUpperCase,
20
+ StringPrototypeTrim,
21
+ } = primordials;
22
+
23
+ const {
24
+ codes: {
25
+ ERR_INVALID_ARG_TYPE: { HideStackFramesError: ERR_INVALID_ARG_TYPE },
26
+ ERR_INVALID_ARG_VALUE: { HideStackFramesError: ERR_INVALID_ARG_VALUE },
27
+ ERR_INVALID_THIS: { HideStackFramesError: ERR_INVALID_THIS },
28
+ ERR_OUT_OF_RANGE: { HideStackFramesError: ERR_OUT_OF_RANGE },
29
+ ERR_SOCKET_BAD_PORT: { HideStackFramesError: ERR_SOCKET_BAD_PORT },
30
+ ERR_UNKNOWN_SIGNAL: { HideStackFramesError: ERR_UNKNOWN_SIGNAL },
31
+ },
32
+ hideStackFrames,
33
+ } = require('internal/errors');
34
+ const { normalizeEncoding } = require('internal/util');
35
+ const {
36
+ isAsyncFunction,
37
+ isArrayBufferView,
38
+ } = require('internal/util/types');
39
+ const { signals } = internalBinding('constants').os;
40
+
41
+ /**
42
+ * @param {*} value
43
+ * @returns {boolean}
44
+ */
45
+ function isInt32(value) {
46
+ return value === (value | 0);
47
+ }
48
+
49
+ /**
50
+ * @param {*} value
51
+ * @returns {boolean}
52
+ */
53
+ function isUint32(value) {
54
+ return value === (value >>> 0);
55
+ }
56
+
57
+ const octalReg = /^[0-7]+$/;
58
+ const modeDesc = 'must be a 32-bit unsigned integer or an octal string';
59
+
60
+ /**
61
+ * Parse and validate values that will be converted into mode_t (the S_*
62
+ * constants). Only valid numbers and octal strings are allowed. They could be
63
+ * converted to 32-bit unsigned integers or non-negative signed integers in the
64
+ * C++ land, but any value higher than 0o777 will result in platform-specific
65
+ * behaviors.
66
+ * @param {*} value Values to be validated
67
+ * @param {string} name Name of the argument
68
+ * @param {number} [def] If specified, will be returned for invalid values
69
+ * @returns {number}
70
+ */
71
+ function parseFileMode(value, name, def) {
72
+ value ??= def;
73
+ if (typeof value === 'string') {
74
+ if (RegExpPrototypeExec(octalReg, value) === null) {
75
+ throw new ERR_INVALID_ARG_VALUE(name, value, modeDesc);
76
+ }
77
+ value = NumberParseInt(value, 8);
78
+ }
79
+
80
+ validateUint32(value, name);
81
+ return value;
82
+ }
83
+
84
+ /**
85
+ * @callback validateInteger
86
+ * @param {*} value
87
+ * @param {string} name
88
+ * @param {number} [min]
89
+ * @param {number} [max]
90
+ * @returns {asserts value is number}
91
+ */
92
+
93
+ /** @type {validateInteger} */
94
+ const validateInteger = hideStackFrames(
95
+ (value, name, min = NumberMIN_SAFE_INTEGER, max = NumberMAX_SAFE_INTEGER) => {
96
+ if (typeof value !== 'number')
97
+ throw new ERR_INVALID_ARG_TYPE(name, 'number', value);
98
+ if (!NumberIsInteger(value))
99
+ throw new ERR_OUT_OF_RANGE(name, 'an integer', value);
100
+ if (value < min || value > max)
101
+ throw new ERR_OUT_OF_RANGE(name, `>= ${min} && <= ${max}`, value);
102
+ },
103
+ );
104
+
105
+ /**
106
+ * @callback validateInt32
107
+ * @param {*} value
108
+ * @param {string} name
109
+ * @param {number} [min]
110
+ * @param {number} [max]
111
+ * @returns {asserts value is number}
112
+ */
113
+
114
+ /** @type {validateInt32} */
115
+ const validateInt32 = hideStackFrames(
116
+ (value, name, min = -2147483648, max = 2147483647) => {
117
+ // The defaults for min and max correspond to the limits of 32-bit integers.
118
+ if (typeof value !== 'number') {
119
+ throw new ERR_INVALID_ARG_TYPE(name, 'number', value);
120
+ }
121
+ if (!NumberIsInteger(value)) {
122
+ throw new ERR_OUT_OF_RANGE(name, 'an integer', value);
123
+ }
124
+ if (value < min || value > max) {
125
+ throw new ERR_OUT_OF_RANGE(name, `>= ${min} && <= ${max}`, value);
126
+ }
127
+ },
128
+ );
129
+
130
+ /**
131
+ * @callback validateUint32
132
+ * @param {*} value
133
+ * @param {string} name
134
+ * @param {boolean} [positive=false]
135
+ * @returns {asserts value is number}
136
+ */
137
+
138
+ /** @type {validateUint32} */
139
+ const validateUint32 = hideStackFrames((value, name, positive = false) => {
140
+ if (typeof value !== 'number') {
141
+ throw new ERR_INVALID_ARG_TYPE(name, 'number', value);
142
+ }
143
+ if (!NumberIsInteger(value)) {
144
+ throw new ERR_OUT_OF_RANGE(name, 'an integer', value);
145
+ }
146
+ const min = positive ? 1 : 0;
147
+ // 2 ** 32 === 4294967296
148
+ const max = 4_294_967_295;
149
+ if (value < min || value > max) {
150
+ throw new ERR_OUT_OF_RANGE(name, `>= ${min} && <= ${max}`, value);
151
+ }
152
+ });
153
+
154
+ /**
155
+ * @callback validateString
156
+ * @param {*} value
157
+ * @param {string} name
158
+ * @returns {asserts value is string}
159
+ */
160
+
161
+ /** @type {validateString} */
162
+ const validateString = hideStackFrames((value, name) => {
163
+ if (typeof value !== 'string')
164
+ throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
165
+ });
166
+
167
+ /**
168
+ * @callback validateNumber
169
+ * @param {*} value
170
+ * @param {string} name
171
+ * @param {number} [min]
172
+ * @param {number} [max]
173
+ * @returns {asserts value is number}
174
+ */
175
+
176
+ /** @type {validateNumber} */
177
+ const validateNumber = hideStackFrames((value, name, min = undefined, max) => {
178
+ if (typeof value !== 'number')
179
+ throw new ERR_INVALID_ARG_TYPE(name, 'number', value);
180
+
181
+ if ((min != null && value < min) || (max != null && value > max) ||
182
+ ((min != null || max != null) && NumberIsNaN(value))) {
183
+ throw new ERR_OUT_OF_RANGE(
184
+ name,
185
+ `${min != null ? `>= ${min}` : ''}${min != null && max != null ? ' && ' : ''}${max != null ? `<= ${max}` : ''}`,
186
+ value);
187
+ }
188
+ });
189
+
190
+ /**
191
+ * @callback validateOneOf
192
+ * @template T
193
+ * @param {T} value
194
+ * @param {string} name
195
+ * @param {T[]} oneOf
196
+ */
197
+
198
+ /** @type {validateOneOf} */
199
+ const validateOneOf = hideStackFrames((value, name, oneOf) => {
200
+ if (!ArrayPrototypeIncludes(oneOf, value)) {
201
+ const allowed = ArrayPrototypeJoin(
202
+ ArrayPrototypeMap(oneOf, (v) =>
203
+ (typeof v === 'string' ? `'${v}'` : String(v))),
204
+ ', ');
205
+ const reason = 'must be one of: ' + allowed;
206
+ throw new ERR_INVALID_ARG_VALUE(name, value, reason);
207
+ }
208
+ });
209
+
210
+ /**
211
+ * @callback validateBoolean
212
+ * @param {*} value
213
+ * @param {string} name
214
+ * @returns {asserts value is boolean}
215
+ */
216
+
217
+ /** @type {validateBoolean} */
218
+ const validateBoolean = hideStackFrames((value, name) => {
219
+ if (typeof value !== 'boolean')
220
+ throw new ERR_INVALID_ARG_TYPE(name, 'boolean', value);
221
+ });
222
+
223
+ const kValidateObjectNone = 0;
224
+ const kValidateObjectAllowNullable = 1 << 0;
225
+ const kValidateObjectAllowArray = 1 << 1;
226
+ const kValidateObjectAllowFunction = 1 << 2;
227
+ const kValidateObjectAllowObjects = kValidateObjectAllowArray |
228
+ kValidateObjectAllowFunction;
229
+ const kValidateObjectAllowObjectsAndNull = kValidateObjectAllowNullable |
230
+ kValidateObjectAllowArray |
231
+ kValidateObjectAllowFunction;
232
+
233
+ /**
234
+ * @callback validateObject
235
+ * @param {*} value
236
+ * @param {string} name
237
+ * @param {number} [options]
238
+ */
239
+
240
+ /** @type {validateObject} */
241
+ const validateObject = hideStackFrames(
242
+ (value, name, options = kValidateObjectNone) => {
243
+ if (options === kValidateObjectNone) {
244
+ if (value === null || ArrayIsArray(value)) {
245
+ throw new ERR_INVALID_ARG_TYPE(name, 'Object', value);
246
+ }
247
+
248
+ if (typeof value !== 'object') {
249
+ throw new ERR_INVALID_ARG_TYPE(name, 'Object', value);
250
+ }
251
+ } else {
252
+ const throwOnNullable = (kValidateObjectAllowNullable & options) === 0;
253
+
254
+ if (throwOnNullable && value === null) {
255
+ throw new ERR_INVALID_ARG_TYPE(name, 'Object', value);
256
+ }
257
+
258
+ const throwOnArray = (kValidateObjectAllowArray & options) === 0;
259
+
260
+ if (throwOnArray && ArrayIsArray(value)) {
261
+ throw new ERR_INVALID_ARG_TYPE(name, 'Object', value);
262
+ }
263
+
264
+ const throwOnFunction = (kValidateObjectAllowFunction & options) === 0;
265
+ const typeofValue = typeof value;
266
+
267
+ if (typeofValue !== 'object' && (throwOnFunction || typeofValue !== 'function')) {
268
+ throw new ERR_INVALID_ARG_TYPE(name, 'Object', value);
269
+ }
270
+ }
271
+ });
272
+
273
+ /**
274
+ * @callback validateDictionary - We are using the Web IDL Standard definition
275
+ * of "dictionary" here, which means any value
276
+ * whose Type is either Undefined, Null, or
277
+ * Object (which includes functions).
278
+ * @param {*} value
279
+ * @param {string} name
280
+ * @see https://webidl.spec.whatwg.org/#es-dictionary
281
+ * @see https://tc39.es/ecma262/#table-typeof-operator-results
282
+ */
283
+
284
+ /** @type {validateDictionary} */
285
+ const validateDictionary = hideStackFrames(
286
+ (value, name) => {
287
+ if (value != null && typeof value !== 'object' && typeof value !== 'function') {
288
+ throw new ERR_INVALID_ARG_TYPE(name, 'a dictionary', value);
289
+ }
290
+ });
291
+
292
+ /**
293
+ * @callback validateArray
294
+ * @param {*} value
295
+ * @param {string} name
296
+ * @param {number} [minLength]
297
+ * @returns {asserts value is any[]}
298
+ */
299
+
300
+ /** @type {validateArray} */
301
+ const validateArray = hideStackFrames((value, name, minLength = 0) => {
302
+ if (!ArrayIsArray(value)) {
303
+ throw new ERR_INVALID_ARG_TYPE(name, 'Array', value);
304
+ }
305
+ if (value.length < minLength) {
306
+ const reason = `must be longer than ${minLength}`;
307
+ throw new ERR_INVALID_ARG_VALUE(name, value, reason);
308
+ }
309
+ });
310
+
311
+ /**
312
+ * @callback validateStringArray
313
+ * @param {*} value
314
+ * @param {string} name
315
+ * @returns {asserts value is string[]}
316
+ */
317
+
318
+ /** @type {validateStringArray} */
319
+ const validateStringArray = hideStackFrames((value, name) => {
320
+ validateArray(value, name);
321
+ for (let i = 0; i < value.length; ++i) {
322
+ // Don't use validateString here for performance reasons, as
323
+ // we would generate intermediate strings for the name.
324
+ if (typeof value[i] !== 'string') {
325
+ throw new ERR_INVALID_ARG_TYPE(`${name}[${i}]`, 'string', value[i]);
326
+ }
327
+ }
328
+ });
329
+
330
+ /**
331
+ * @callback validateBooleanArray
332
+ * @param {*} value
333
+ * @param {string} name
334
+ * @returns {asserts value is boolean[]}
335
+ */
336
+
337
+ /** @type {validateBooleanArray} */
338
+ const validateBooleanArray = hideStackFrames((value, name) => {
339
+ validateArray(value, name);
340
+ for (let i = 0; i < value.length; ++i) {
341
+ // Don't use validateBoolean here for performance reasons, as
342
+ // we would generate intermediate strings for the name.
343
+ if (value[i] !== true && value[i] !== false) {
344
+ throw new ERR_INVALID_ARG_TYPE(`${name}[${i}]`, 'boolean', value[i]);
345
+ }
346
+ }
347
+ });
348
+
349
+ /**
350
+ * @callback validateAbortSignalArray
351
+ * @param {*} value
352
+ * @param {string} name
353
+ * @returns {asserts value is AbortSignal[]}
354
+ */
355
+
356
+ /** @type {validateAbortSignalArray} */
357
+ function validateAbortSignalArray(value, name) {
358
+ validateArray(value, name);
359
+ for (let i = 0; i < value.length; i++) {
360
+ const signal = value[i];
361
+ const indexedName = `${name}[${i}]`;
362
+ if (signal == null) {
363
+ throw new ERR_INVALID_ARG_TYPE(indexedName, 'AbortSignal', signal);
364
+ }
365
+ validateAbortSignal(signal, indexedName);
366
+ }
367
+ }
368
+
369
+ /**
370
+ * @param {*} signal
371
+ * @param {string} [name='signal']
372
+ * @returns {asserts signal is keyof signals}
373
+ */
374
+ const validateSignalName = hideStackFrames((signal, name = 'signal') => {
375
+ validateString(signal, name);
376
+
377
+ if (signals[signal] === undefined) {
378
+ if (signals[StringPrototypeToUpperCase(signal)] !== undefined) {
379
+ throw new ERR_UNKNOWN_SIGNAL(signal +
380
+ ' (signals must use all capital letters)');
381
+ }
382
+
383
+ throw new ERR_UNKNOWN_SIGNAL(signal);
384
+ }
385
+ });
386
+
387
+ /**
388
+ * @callback validateBuffer
389
+ * @param {*} buffer
390
+ * @param {string} [name='buffer']
391
+ * @returns {asserts buffer is ArrayBufferView}
392
+ */
393
+
394
+ /** @type {validateBuffer} */
395
+ const validateBuffer = hideStackFrames((buffer, name = 'buffer') => {
396
+ if (!isArrayBufferView(buffer)) {
397
+ throw new ERR_INVALID_ARG_TYPE(name,
398
+ ['Buffer', 'TypedArray', 'DataView'],
399
+ buffer);
400
+ }
401
+ });
402
+
403
+ /**
404
+ * @param {string} data
405
+ * @param {string} encoding
406
+ */
407
+ const validateEncoding = hideStackFrames((data, encoding) => {
408
+ const normalizedEncoding = normalizeEncoding(encoding);
409
+ const length = data.length;
410
+
411
+ if (normalizedEncoding === 'hex' && length % 2 !== 0) {
412
+ throw new ERR_INVALID_ARG_VALUE('encoding', encoding,
413
+ `is invalid for data of length ${length}`);
414
+ }
415
+ });
416
+
417
+ /**
418
+ * Check that the port number is not NaN when coerced to a number,
419
+ * is an integer and that it falls within the legal range of port numbers.
420
+ * @param {*} port
421
+ * @param {string} [name='Port']
422
+ * @param {boolean} [allowZero=true]
423
+ * @returns {number}
424
+ */
425
+ const validatePort = hideStackFrames((port, name = 'Port', allowZero = true) => {
426
+ if ((typeof port !== 'number' && typeof port !== 'string') ||
427
+ (typeof port === 'string' && StringPrototypeTrim(port).length === 0) ||
428
+ +port !== (+port >>> 0) ||
429
+ port > 0xFFFF ||
430
+ (port === 0 && !allowZero)) {
431
+ throw new ERR_SOCKET_BAD_PORT(name, port, allowZero);
432
+ }
433
+ return port | 0;
434
+ });
435
+
436
+ /**
437
+ * @callback validateAbortSignal
438
+ * @param {*} signal
439
+ * @param {string} name
440
+ */
441
+
442
+ /** @type {validateAbortSignal} */
443
+ const validateAbortSignal = hideStackFrames((signal, name) => {
444
+ if (signal !== undefined &&
445
+ (signal === null ||
446
+ typeof signal !== 'object' ||
447
+ !('aborted' in signal))) {
448
+ throw new ERR_INVALID_ARG_TYPE(name, 'AbortSignal', signal);
449
+ }
450
+ });
451
+
452
+ /**
453
+ * @callback validateFunction
454
+ * @param {*} value
455
+ * @param {string} name
456
+ * @returns {asserts value is Function}
457
+ */
458
+
459
+ /** @type {validateFunction} */
460
+ const validateFunction = hideStackFrames((value, name) => {
461
+ if (typeof value !== 'function')
462
+ throw new ERR_INVALID_ARG_TYPE(name, 'Function', value);
463
+ });
464
+
465
+ /**
466
+ * @callback validatePlainFunction
467
+ * @param {*} value
468
+ * @param {string} name
469
+ * @returns {asserts value is Function}
470
+ */
471
+
472
+ /** @type {validatePlainFunction} */
473
+ const validatePlainFunction = hideStackFrames((value, name) => {
474
+ if (typeof value !== 'function' || isAsyncFunction(value))
475
+ throw new ERR_INVALID_ARG_TYPE(name, 'Function', value);
476
+ });
477
+
478
+ /**
479
+ * @callback validateUndefined
480
+ * @param {*} value
481
+ * @param {string} name
482
+ * @returns {asserts value is undefined}
483
+ */
484
+
485
+ /** @type {validateUndefined} */
486
+ const validateUndefined = hideStackFrames((value, name) => {
487
+ if (value !== undefined)
488
+ throw new ERR_INVALID_ARG_TYPE(name, 'undefined', value);
489
+ });
490
+
491
+ /**
492
+ * @template T
493
+ * @param {T} value
494
+ * @param {string} name
495
+ * @param {T[]} union
496
+ */
497
+ function validateUnion(value, name, union) {
498
+ if (!ArrayPrototypeIncludes(union, value)) {
499
+ throw new ERR_INVALID_ARG_TYPE(name, `('${ArrayPrototypeJoin(union, '|')}')`, value);
500
+ }
501
+ }
502
+
503
+ /*
504
+ The rules for the Link header field are described here:
505
+ https://www.rfc-editor.org/rfc/rfc8288.html#section-3
506
+
507
+ This regex validates any string surrounded by angle brackets
508
+ (not necessarily a valid URI reference) followed by zero or more
509
+ link-params separated by semicolons.
510
+ */
511
+ const linkValueRegExp = /^(?:<[^>]*>)(?:\s*;\s*[^;"\s]+(?:=(")?[^;"\s]*\1)?)*$/;
512
+
513
+ /**
514
+ * @param {any} value
515
+ * @param {string} name
516
+ */
517
+ const validateLinkHeaderFormat = hideStackFrames((value, name) => {
518
+ if (
519
+ typeof value === 'undefined' ||
520
+ !RegExpPrototypeExec(linkValueRegExp, value)
521
+ ) {
522
+ throw new ERR_INVALID_ARG_VALUE(
523
+ name,
524
+ value,
525
+ 'must be an array or string of format "</styles.css>; rel=preload; as=style"',
526
+ );
527
+ }
528
+ });
529
+
530
+ /**
531
+ * Validate provided `this` object by checking that it has specific own property
532
+ * @param {any} object
533
+ * @param {string|symbol} fieldKey
534
+ * @param {string} className
535
+ */
536
+ const validateThisInternalField = hideStackFrames((object, fieldKey, className) => {
537
+ if (typeof object !== 'object' || object === null || !ObjectPrototypeHasOwnProperty(object, fieldKey)) {
538
+ throw new ERR_INVALID_THIS(className);
539
+ }
540
+ });
541
+
542
+ /**
543
+ * @param {any} hints
544
+ * @return {string}
545
+ */
546
+ const validateLinkHeaderValue = hideStackFrames((hints) => {
547
+ if (typeof hints === 'string') {
548
+ validateLinkHeaderFormat.withoutStackTrace(hints, 'hints');
549
+ return hints;
550
+ } else if (ArrayIsArray(hints)) {
551
+ const hintsLength = hints.length;
552
+ let result = '';
553
+
554
+ if (hintsLength === 0) {
555
+ return result;
556
+ }
557
+
558
+ for (let i = 0; i < hintsLength; i++) {
559
+ const link = hints[i];
560
+ validateLinkHeaderFormat.withoutStackTrace(link, 'hints');
561
+ result += link;
562
+
563
+ if (i !== hintsLength - 1) {
564
+ result += ', ';
565
+ }
566
+ }
567
+
568
+ return result;
569
+ }
570
+
571
+ throw new ERR_INVALID_ARG_VALUE(
572
+ 'hints',
573
+ hints,
574
+ 'must be an array or string of format "</styles.css>; rel=preload; as=style"',
575
+ );
576
+ });
577
+
578
+ // 1. Returns false for undefined and NaN
579
+ // 2. Returns true for finite numbers
580
+ // 3. Throws ERR_INVALID_ARG_TYPE for non-numbers
581
+ // 4. Throws ERR_OUT_OF_RANGE for infinite numbers
582
+ const validateFiniteNumber = hideStackFrames((number, name) => {
583
+ // Common case
584
+ if (number === undefined) {
585
+ return false;
586
+ }
587
+
588
+ if (NumberIsFinite(number)) {
589
+ return true; // Is a valid number
590
+ }
591
+
592
+ if (NumberIsNaN(number)) {
593
+ return false;
594
+ }
595
+
596
+ validateNumber(number, name);
597
+
598
+ // Infinite numbers
599
+ throw new ERR_OUT_OF_RANGE(name, 'a finite number', number);
600
+ });
601
+
602
+ // 1. Returns def for number when it's undefined or NaN
603
+ // 2. Returns number for finite numbers >= lower and <= upper
604
+ // 3. Throws ERR_INVALID_ARG_TYPE for non-numbers
605
+ // 4. Throws ERR_OUT_OF_RANGE for infinite numbers or numbers > upper or < lower
606
+ const checkRangesOrGetDefault = hideStackFrames(
607
+ (number, name, lower, upper, def) => {
608
+ if (!validateFiniteNumber(number, name)) {
609
+ return def;
610
+ }
611
+ if (number < lower || number > upper) {
612
+ throw new ERR_OUT_OF_RANGE(name, `>= ${lower} and <= ${upper}`, number);
613
+ }
614
+ return number;
615
+ },
616
+ );
617
+
618
+ module.exports = {
619
+ isInt32,
620
+ isUint32,
621
+ parseFileMode,
622
+ validateArray,
623
+ validateStringArray,
624
+ validateBooleanArray,
625
+ validateAbortSignalArray,
626
+ validateBoolean,
627
+ validateBuffer,
628
+ validateDictionary,
629
+ validateEncoding,
630
+ validateFunction,
631
+ validateInt32,
632
+ validateInteger,
633
+ validateNumber,
634
+ validateObject,
635
+ kValidateObjectNone,
636
+ kValidateObjectAllowNullable,
637
+ kValidateObjectAllowArray,
638
+ kValidateObjectAllowFunction,
639
+ kValidateObjectAllowObjects,
640
+ kValidateObjectAllowObjectsAndNull,
641
+ validateOneOf,
642
+ validatePlainFunction,
643
+ validatePort,
644
+ validateSignalName,
645
+ validateString,
646
+ validateUint32,
647
+ validateUndefined,
648
+ validateUnion,
649
+ validateAbortSignal,
650
+ validateLinkHeaderValue,
651
+ validateThisInternalField,
652
+ validateFiniteNumber,
653
+ checkRangesOrGetDefault,
654
+ };