@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,412 @@
1
+ 'use strict';
2
+
3
+ const {
4
+ ArrayPrototypeForEach,
5
+ ArrayPrototypeIncludes,
6
+ ArrayPrototypeMap,
7
+ ArrayPrototypePush,
8
+ ArrayPrototypePushApply,
9
+ ArrayPrototypeShift,
10
+ ArrayPrototypeSlice,
11
+ ArrayPrototypeUnshiftApply,
12
+ ObjectEntries,
13
+ ObjectPrototypeHasOwnProperty: ObjectHasOwn,
14
+ StringPrototypeCharAt,
15
+ StringPrototypeIndexOf,
16
+ StringPrototypeSlice,
17
+ StringPrototypeStartsWith,
18
+ } = primordials;
19
+
20
+ const {
21
+ validateArray,
22
+ validateBoolean,
23
+ validateBooleanArray,
24
+ validateObject,
25
+ validateString,
26
+ validateStringArray,
27
+ validateUnion,
28
+ } = require('internal/validators');
29
+
30
+ const {
31
+ findLongOptionForShort,
32
+ isLoneLongOption,
33
+ isLoneShortOption,
34
+ isLongOptionAndValue,
35
+ isOptionValue,
36
+ isOptionLikeValue,
37
+ isShortOptionAndValue,
38
+ isShortOptionGroup,
39
+ useDefaultValueOption,
40
+ objectGetOwn,
41
+ optionsGetOwn,
42
+ } = require('internal/util/parse_args/utils');
43
+
44
+ const {
45
+ codes: {
46
+ ERR_INVALID_ARG_VALUE,
47
+ ERR_PARSE_ARGS_INVALID_OPTION_VALUE,
48
+ ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL,
49
+ ERR_PARSE_ARGS_UNKNOWN_OPTION,
50
+ },
51
+ } = require('internal/errors');
52
+
53
+ const {
54
+ kEmptyObject,
55
+ } = require('internal/util');
56
+
57
+
58
+ function getMainArgs() {
59
+ // Work out where to slice process.argv for user supplied arguments.
60
+
61
+ // Check node options for scenarios where user CLI args follow executable.
62
+ const execArgv = process.execArgv;
63
+ if (ArrayPrototypeIncludes(execArgv, '-e') ||
64
+ ArrayPrototypeIncludes(execArgv, '--eval') ||
65
+ ArrayPrototypeIncludes(execArgv, '-p') ||
66
+ ArrayPrototypeIncludes(execArgv, '--print')) {
67
+ return ArrayPrototypeSlice(process.argv, 1);
68
+ }
69
+
70
+ // Normally first two arguments are executable and script, then CLI arguments
71
+ return ArrayPrototypeSlice(process.argv, 2);
72
+ }
73
+
74
+ /**
75
+ * In strict mode, throw for possible usage errors like --foo --bar
76
+ * @param {object} token - from tokens as available from parseArgs
77
+ */
78
+ function checkOptionLikeValue(token) {
79
+ if (!token.inlineValue && isOptionLikeValue(token.value)) {
80
+ // Only show short example if user used short option.
81
+ const example = StringPrototypeStartsWith(token.rawName, '--') ?
82
+ `'${token.rawName}=-XYZ'` :
83
+ `'--${token.name}=-XYZ' or '${token.rawName}-XYZ'`;
84
+ const errorMessage = `Option '${token.rawName}' argument is ambiguous.
85
+ Did you forget to specify the option argument for '${token.rawName}'?
86
+ To specify an option argument starting with a dash use ${example}.`;
87
+ throw new ERR_PARSE_ARGS_INVALID_OPTION_VALUE(errorMessage);
88
+ }
89
+ }
90
+
91
+ /**
92
+ * In strict mode, throw for usage errors.
93
+ * @param {object} config - from config passed to parseArgs
94
+ * @param {object} token - from tokens as available from parseArgs
95
+ */
96
+ function checkOptionUsage(config, token) {
97
+ let tokenName = token.name;
98
+ if (!ObjectHasOwn(config.options, tokenName)) {
99
+ // Check for negated boolean option.
100
+ if (config.allowNegative && StringPrototypeStartsWith(tokenName, 'no-')) {
101
+ tokenName = StringPrototypeSlice(tokenName, 3);
102
+ if (!ObjectHasOwn(config.options, tokenName) || optionsGetOwn(config.options, tokenName, 'type') !== 'boolean') {
103
+ throw new ERR_PARSE_ARGS_UNKNOWN_OPTION(
104
+ token.rawName, config.allowPositionals);
105
+ }
106
+ } else {
107
+ throw new ERR_PARSE_ARGS_UNKNOWN_OPTION(
108
+ token.rawName, config.allowPositionals);
109
+ }
110
+ }
111
+
112
+ const short = optionsGetOwn(config.options, tokenName, 'short');
113
+ const shortAndLong = `${short ? `-${short}, ` : ''}--${tokenName}`;
114
+ const type = optionsGetOwn(config.options, tokenName, 'type');
115
+ if (type === 'string' && typeof token.value !== 'string') {
116
+ throw new ERR_PARSE_ARGS_INVALID_OPTION_VALUE(`Option '${shortAndLong} <value>' argument missing`);
117
+ }
118
+ // (Idiomatic test for undefined||null, expecting undefined.)
119
+ if (type === 'boolean' && token.value != null) {
120
+ throw new ERR_PARSE_ARGS_INVALID_OPTION_VALUE(`Option '${shortAndLong}' does not take an argument`);
121
+ }
122
+ }
123
+
124
+
125
+ /**
126
+ * Store the option value in `values`.
127
+ * @param {object} token - from tokens as available from parseArgs
128
+ * @param {object} options - option configs, from parseArgs({ options })
129
+ * @param {object} values - option values returned in `values` by parseArgs
130
+ * @param {boolean} allowNegative - allow negative optinons if true
131
+ */
132
+ function storeOption(token, options, values, allowNegative) {
133
+ let longOption = token.name;
134
+ let optionValue = token.value;
135
+ if (longOption === '__proto__') {
136
+ return; // No. Just no.
137
+ }
138
+
139
+ if (allowNegative && StringPrototypeStartsWith(longOption, 'no-') && optionValue === undefined) {
140
+ // Boolean option negation: --no-foo
141
+ longOption = StringPrototypeSlice(longOption, 3);
142
+ token.name = longOption;
143
+ optionValue = false;
144
+ }
145
+
146
+ // We store based on the option value rather than option type,
147
+ // preserving the users intent for author to deal with.
148
+ const newValue = optionValue ?? true;
149
+ if (optionsGetOwn(options, longOption, 'multiple')) {
150
+ // Always store value in array, including for boolean.
151
+ // values[longOption] starts out not present,
152
+ // first value is added as new array [newValue],
153
+ // subsequent values are pushed to existing array.
154
+ // (note: values has null prototype, so simpler usage)
155
+ if (values[longOption]) {
156
+ ArrayPrototypePush(values[longOption], newValue);
157
+ } else {
158
+ values[longOption] = [newValue];
159
+ }
160
+ } else {
161
+ values[longOption] = newValue;
162
+ }
163
+ }
164
+
165
+ /**
166
+ * Store the default option value in `values`.
167
+ * @param {string} longOption - long option name e.g. 'foo'
168
+ * @param {string
169
+ * | boolean
170
+ * | string[]
171
+ * | boolean[]} optionValue - default value from option config
172
+ * @param {object} values - option values returned in `values` by parseArgs
173
+ */
174
+ function storeDefaultOption(longOption, optionValue, values) {
175
+ if (longOption === '__proto__') {
176
+ return; // No. Just no.
177
+ }
178
+
179
+ values[longOption] = optionValue;
180
+ }
181
+
182
+ /**
183
+ * Process args and turn into identified tokens:
184
+ * - option (along with value, if any)
185
+ * - positional
186
+ * - option-terminator
187
+ * @param {string[]} args - from parseArgs({ args }) or mainArgs
188
+ * @param {object} options - option configs, from parseArgs({ options })
189
+ */
190
+ function argsToTokens(args, options) {
191
+ const tokens = [];
192
+ let index = -1;
193
+ let groupCount = 0;
194
+
195
+ const remainingArgs = ArrayPrototypeSlice(args);
196
+ while (remainingArgs.length > 0) {
197
+ const arg = ArrayPrototypeShift(remainingArgs);
198
+ const nextArg = remainingArgs[0];
199
+ if (groupCount > 0)
200
+ groupCount--;
201
+ else
202
+ index++;
203
+
204
+ // Check if `arg` is an options terminator.
205
+ // Guideline 10 in https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html
206
+ if (arg === '--') {
207
+ // Everything after a bare '--' is considered a positional argument.
208
+ ArrayPrototypePush(tokens, { kind: 'option-terminator', index });
209
+ ArrayPrototypePushApply(
210
+ tokens, ArrayPrototypeMap(remainingArgs, (arg) => {
211
+ return { kind: 'positional', index: ++index, value: arg };
212
+ }),
213
+ );
214
+ break; // Finished processing args, leave while loop.
215
+ }
216
+
217
+ if (isLoneShortOption(arg)) {
218
+ // e.g. '-f'
219
+ const shortOption = StringPrototypeCharAt(arg, 1);
220
+ const longOption = findLongOptionForShort(shortOption, options);
221
+ let value;
222
+ let inlineValue;
223
+ if (optionsGetOwn(options, longOption, 'type') === 'string' &&
224
+ isOptionValue(nextArg)) {
225
+ // e.g. '-f', 'bar'
226
+ value = ArrayPrototypeShift(remainingArgs);
227
+ inlineValue = false;
228
+ }
229
+ ArrayPrototypePush(
230
+ tokens,
231
+ { kind: 'option', name: longOption, rawName: arg,
232
+ index, value, inlineValue });
233
+ if (value != null) ++index;
234
+ continue;
235
+ }
236
+
237
+ if (isShortOptionGroup(arg, options)) {
238
+ // Expand -fXzy to -f -X -z -y
239
+ const expanded = [];
240
+ for (let index = 1; index < arg.length; index++) {
241
+ const shortOption = StringPrototypeCharAt(arg, index);
242
+ const longOption = findLongOptionForShort(shortOption, options);
243
+ if (optionsGetOwn(options, longOption, 'type') !== 'string' ||
244
+ index === arg.length - 1) {
245
+ // Boolean option, or last short in group. Well formed.
246
+ ArrayPrototypePush(expanded, `-${shortOption}`);
247
+ } else {
248
+ // String option in middle. Yuck.
249
+ // Expand -abfFILE to -a -b -fFILE
250
+ ArrayPrototypePush(expanded, `-${StringPrototypeSlice(arg, index)}`);
251
+ break; // finished short group
252
+ }
253
+ }
254
+ ArrayPrototypeUnshiftApply(remainingArgs, expanded);
255
+ groupCount = expanded.length;
256
+ continue;
257
+ }
258
+
259
+ if (isShortOptionAndValue(arg, options)) {
260
+ // e.g. -fFILE
261
+ const shortOption = StringPrototypeCharAt(arg, 1);
262
+ const longOption = findLongOptionForShort(shortOption, options);
263
+ const value = StringPrototypeSlice(arg, 2);
264
+ ArrayPrototypePush(
265
+ tokens,
266
+ { kind: 'option', name: longOption, rawName: `-${shortOption}`,
267
+ index, value, inlineValue: true });
268
+ continue;
269
+ }
270
+
271
+ if (isLoneLongOption(arg)) {
272
+ // e.g. '--foo'
273
+ const longOption = StringPrototypeSlice(arg, 2);
274
+ let value;
275
+ let inlineValue;
276
+ if (optionsGetOwn(options, longOption, 'type') === 'string' &&
277
+ isOptionValue(nextArg)) {
278
+ // e.g. '--foo', 'bar'
279
+ value = ArrayPrototypeShift(remainingArgs);
280
+ inlineValue = false;
281
+ }
282
+ ArrayPrototypePush(
283
+ tokens,
284
+ { kind: 'option', name: longOption, rawName: arg,
285
+ index, value, inlineValue });
286
+ if (value != null) ++index;
287
+ continue;
288
+ }
289
+
290
+ if (isLongOptionAndValue(arg)) {
291
+ // e.g. --foo=bar
292
+ const equalIndex = StringPrototypeIndexOf(arg, '=');
293
+ const longOption = StringPrototypeSlice(arg, 2, equalIndex);
294
+ const value = StringPrototypeSlice(arg, equalIndex + 1);
295
+ ArrayPrototypePush(
296
+ tokens,
297
+ { kind: 'option', name: longOption, rawName: `--${longOption}`,
298
+ index, value, inlineValue: true });
299
+ continue;
300
+ }
301
+
302
+ ArrayPrototypePush(tokens, { kind: 'positional', index, value: arg });
303
+ }
304
+ return tokens;
305
+ }
306
+
307
+ const parseArgs = (config = kEmptyObject) => {
308
+ const args = objectGetOwn(config, 'args') ?? getMainArgs();
309
+ const strict = objectGetOwn(config, 'strict') ?? true;
310
+ const allowPositionals = objectGetOwn(config, 'allowPositionals') ?? !strict;
311
+ const returnTokens = objectGetOwn(config, 'tokens') ?? false;
312
+ const allowNegative = objectGetOwn(config, 'allowNegative') ?? false;
313
+ const options = objectGetOwn(config, 'options') ?? { __proto__: null };
314
+ // Bundle these up for passing to strict-mode checks.
315
+ const parseConfig = { args, strict, options, allowPositionals, allowNegative };
316
+
317
+ // Validate input configuration.
318
+ validateArray(args, 'args');
319
+ validateBoolean(strict, 'strict');
320
+ validateBoolean(allowPositionals, 'allowPositionals');
321
+ validateBoolean(returnTokens, 'tokens');
322
+ validateBoolean(allowNegative, 'allowNegative');
323
+ validateObject(options, 'options');
324
+ ArrayPrototypeForEach(
325
+ ObjectEntries(options),
326
+ ({ 0: longOption, 1: optionConfig }) => {
327
+ validateObject(optionConfig, `options.${longOption}`);
328
+
329
+ // type is required
330
+ const optionType = objectGetOwn(optionConfig, 'type');
331
+ validateUnion(optionType, `options.${longOption}.type`, ['string', 'boolean']);
332
+
333
+ if (ObjectHasOwn(optionConfig, 'short')) {
334
+ const shortOption = optionConfig.short;
335
+ validateString(shortOption, `options.${longOption}.short`);
336
+ if (shortOption.length !== 1) {
337
+ throw new ERR_INVALID_ARG_VALUE(
338
+ `options.${longOption}.short`,
339
+ shortOption,
340
+ 'must be a single character',
341
+ );
342
+ }
343
+ }
344
+
345
+ const multipleOption = objectGetOwn(optionConfig, 'multiple');
346
+ if (ObjectHasOwn(optionConfig, 'multiple')) {
347
+ validateBoolean(multipleOption, `options.${longOption}.multiple`);
348
+ }
349
+
350
+ const defaultValue = objectGetOwn(optionConfig, 'default');
351
+ if (defaultValue !== undefined) {
352
+ let validator;
353
+ switch (optionType) {
354
+ case 'string':
355
+ validator = multipleOption ? validateStringArray : validateString;
356
+ break;
357
+
358
+ case 'boolean':
359
+ validator = multipleOption ? validateBooleanArray : validateBoolean;
360
+ break;
361
+ }
362
+ validator(defaultValue, `options.${longOption}.default`);
363
+ }
364
+ },
365
+ );
366
+
367
+ // Phase 1: identify tokens
368
+ const tokens = argsToTokens(args, options);
369
+
370
+ // Phase 2: process tokens into parsed option values and positionals
371
+ const result = {
372
+ values: { __proto__: null },
373
+ positionals: [],
374
+ };
375
+ if (returnTokens) {
376
+ result.tokens = tokens;
377
+ }
378
+ ArrayPrototypeForEach(tokens, (token) => {
379
+ if (token.kind === 'option') {
380
+ if (strict) {
381
+ checkOptionUsage(parseConfig, token);
382
+ checkOptionLikeValue(token);
383
+ }
384
+ storeOption(token, options, result.values, parseConfig.allowNegative);
385
+ } else if (token.kind === 'positional') {
386
+ if (!allowPositionals) {
387
+ throw new ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL(token.value);
388
+ }
389
+ ArrayPrototypePush(result.positionals, token.value);
390
+ }
391
+ });
392
+
393
+ // Phase 3: fill in default values for missing args
394
+ ArrayPrototypeForEach(ObjectEntries(options), ({ 0: longOption,
395
+ 1: optionConfig }) => {
396
+ const mustSetDefault = useDefaultValueOption(longOption,
397
+ optionConfig,
398
+ result.values);
399
+ if (mustSetDefault) {
400
+ storeDefaultOption(longOption,
401
+ objectGetOwn(optionConfig, 'default'),
402
+ result.values);
403
+ }
404
+ });
405
+
406
+
407
+ return result;
408
+ };
409
+
410
+ module.exports = {
411
+ parseArgs,
412
+ };
@@ -0,0 +1,197 @@
1
+ 'use strict';
2
+
3
+ const {
4
+ ArrayPrototypeFind,
5
+ ObjectEntries,
6
+ ObjectPrototypeHasOwnProperty: ObjectHasOwn,
7
+ StringPrototypeCharAt,
8
+ StringPrototypeIncludes,
9
+ StringPrototypeStartsWith,
10
+ } = primordials;
11
+
12
+ const {
13
+ validateObject,
14
+ } = require('internal/validators');
15
+
16
+ // These are internal utilities to make the parsing logic easier to read, and
17
+ // add lots of detail for the curious. They are in a separate file to allow
18
+ // unit testing, although that is not essential (this could be rolled into
19
+ // main file and just tested implicitly via API).
20
+ //
21
+ // These routines are for internal use, not for export to client.
22
+
23
+ /**
24
+ * Return the named property, but only if it is an own property.
25
+ */
26
+ function objectGetOwn(obj, prop) {
27
+ if (ObjectHasOwn(obj, prop))
28
+ return obj[prop];
29
+ }
30
+
31
+ /**
32
+ * Return the named options property, but only if it is an own property.
33
+ */
34
+ function optionsGetOwn(options, longOption, prop) {
35
+ if (ObjectHasOwn(options, longOption))
36
+ return objectGetOwn(options[longOption], prop);
37
+ }
38
+
39
+ /**
40
+ * Determines if the argument may be used as an option value.
41
+ * @example
42
+ * isOptionValue('V') // returns true
43
+ * isOptionValue('-v') // returns true (greedy)
44
+ * isOptionValue('--foo') // returns true (greedy)
45
+ * isOptionValue(undefined) // returns false
46
+ */
47
+ function isOptionValue(value) {
48
+ if (value == null) return false;
49
+
50
+ // Open Group Utility Conventions are that an option-argument
51
+ // is the argument after the option, and may start with a dash.
52
+ return true; // greedy!
53
+ }
54
+
55
+ /**
56
+ * Detect whether there is possible confusion and user may have omitted
57
+ * the option argument, like `--port --verbose` when `port` of type:string.
58
+ * In strict mode we throw errors if value is option-like.
59
+ */
60
+ function isOptionLikeValue(value) {
61
+ if (value == null) return false;
62
+
63
+ return value.length > 1 && StringPrototypeCharAt(value, 0) === '-';
64
+ }
65
+
66
+ /**
67
+ * Determines if `arg` is just a short option.
68
+ * @example '-f'
69
+ */
70
+ function isLoneShortOption(arg) {
71
+ return arg.length === 2 &&
72
+ StringPrototypeCharAt(arg, 0) === '-' &&
73
+ StringPrototypeCharAt(arg, 1) !== '-';
74
+ }
75
+
76
+ /**
77
+ * Determines if `arg` is a lone long option.
78
+ * @example
79
+ * isLoneLongOption('a') // returns false
80
+ * isLoneLongOption('-a') // returns false
81
+ * isLoneLongOption('--foo') // returns true
82
+ * isLoneLongOption('--foo=bar') // returns false
83
+ */
84
+ function isLoneLongOption(arg) {
85
+ return arg.length > 2 &&
86
+ StringPrototypeStartsWith(arg, '--') &&
87
+ !StringPrototypeIncludes(arg, '=', 3);
88
+ }
89
+
90
+ /**
91
+ * Determines if `arg` is a long option and value in the same argument.
92
+ * @example
93
+ * isLongOptionAndValue('--foo') // returns false
94
+ * isLongOptionAndValue('--foo=bar') // returns true
95
+ */
96
+ function isLongOptionAndValue(arg) {
97
+ return arg.length > 2 &&
98
+ StringPrototypeStartsWith(arg, '--') &&
99
+ StringPrototypeIncludes(arg, '=', 3);
100
+ }
101
+
102
+ /**
103
+ * Determines if `arg` is a short option group.
104
+ *
105
+ * See Guideline 5 of the [Open Group Utility Conventions](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html).
106
+ * One or more options without option-arguments, followed by at most one
107
+ * option that takes an option-argument, should be accepted when grouped
108
+ * behind one '-' delimiter.
109
+ * @example
110
+ * isShortOptionGroup('-a', {}) // returns false
111
+ * isShortOptionGroup('-ab', {}) // returns true
112
+ * // -fb is an option and a value, not a short option group
113
+ * isShortOptionGroup('-fb', {
114
+ * options: { f: { type: 'string' } }
115
+ * }) // returns false
116
+ * isShortOptionGroup('-bf', {
117
+ * options: { f: { type: 'string' } }
118
+ * }) // returns true
119
+ * // -bfb is an edge case, return true and caller sorts it out
120
+ * isShortOptionGroup('-bfb', {
121
+ * options: { f: { type: 'string' } }
122
+ * }) // returns true
123
+ */
124
+ function isShortOptionGroup(arg, options) {
125
+ if (arg.length <= 2) return false;
126
+ if (StringPrototypeCharAt(arg, 0) !== '-') return false;
127
+ if (StringPrototypeCharAt(arg, 1) === '-') return false;
128
+
129
+ const firstShort = StringPrototypeCharAt(arg, 1);
130
+ const longOption = findLongOptionForShort(firstShort, options);
131
+ return optionsGetOwn(options, longOption, 'type') !== 'string';
132
+ }
133
+
134
+ /**
135
+ * Determine if arg is a short string option followed by its value.
136
+ * @example
137
+ * isShortOptionAndValue('-a', {}); // returns false
138
+ * isShortOptionAndValue('-ab', {}); // returns false
139
+ * isShortOptionAndValue('-fFILE', {
140
+ * options: { foo: { short: 'f', type: 'string' }}
141
+ * }) // returns true
142
+ */
143
+ function isShortOptionAndValue(arg, options) {
144
+ validateObject(options, 'options');
145
+
146
+ if (arg.length <= 2) return false;
147
+ if (StringPrototypeCharAt(arg, 0) !== '-') return false;
148
+ if (StringPrototypeCharAt(arg, 1) === '-') return false;
149
+
150
+ const shortOption = StringPrototypeCharAt(arg, 1);
151
+ const longOption = findLongOptionForShort(shortOption, options);
152
+ return optionsGetOwn(options, longOption, 'type') === 'string';
153
+ }
154
+
155
+ /**
156
+ * Find the long option associated with a short option. Looks for a configured
157
+ * `short` and returns the short option itself if a long option is not found.
158
+ * @example
159
+ * findLongOptionForShort('a', {}) // returns 'a'
160
+ * findLongOptionForShort('b', {
161
+ * options: { bar: { short: 'b' } }
162
+ * }) // returns 'bar'
163
+ */
164
+ function findLongOptionForShort(shortOption, options) {
165
+ validateObject(options, 'options');
166
+ const longOptionEntry = ArrayPrototypeFind(
167
+ ObjectEntries(options),
168
+ ({ 1: optionConfig }) => objectGetOwn(optionConfig, 'short') === shortOption,
169
+ );
170
+ return longOptionEntry?.[0] ?? shortOption;
171
+ }
172
+
173
+ /**
174
+ * Check if the given option includes a default value
175
+ * and that option has not been set by the input args.
176
+ * @param {string} longOption - long option name e.g. 'foo'
177
+ * @param {object} optionConfig - the option configuration properties
178
+ * @param {object} values - option values returned in `values` by parseArgs
179
+ */
180
+ function useDefaultValueOption(longOption, optionConfig, values) {
181
+ return objectGetOwn(optionConfig, 'default') !== undefined &&
182
+ values[longOption] === undefined;
183
+ }
184
+
185
+ module.exports = {
186
+ findLongOptionForShort,
187
+ isLoneLongOption,
188
+ isLoneShortOption,
189
+ isLongOptionAndValue,
190
+ isOptionValue,
191
+ isOptionLikeValue,
192
+ isShortOptionAndValue,
193
+ isShortOptionGroup,
194
+ useDefaultValueOption,
195
+ objectGetOwn,
196
+ optionsGetOwn,
197
+ };