@socketsecurity/lib 6.0.3 → 6.0.5

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 (542) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/_virtual/_rolldown/runtime.js +45 -0
  3. package/dist/abort/signal.js +53 -59
  4. package/dist/ai/discover.js +110 -110
  5. package/dist/ai/profiles.js +94 -65
  6. package/dist/ai/spawn.js +172 -194
  7. package/dist/ai/types.js +1 -17
  8. package/dist/ai/worktree.js +160 -183
  9. package/dist/ansi/constants.js +16 -38
  10. package/dist/ansi/strip.js +44 -41
  11. package/dist/archives/_internal.js +64 -73
  12. package/dist/archives/detect.js +30 -43
  13. package/dist/archives/extract.js +43 -50
  14. package/dist/archives/tar.js +197 -228
  15. package/dist/archives/types.js +1 -17
  16. package/dist/archives/zip.js +85 -121
  17. package/dist/argv/flag-predicates.js +203 -101
  18. package/dist/argv/flag-types.js +96 -113
  19. package/dist/argv/parse-args-string.d.ts +16 -14
  20. package/dist/argv/parse-args-string.js +42 -39
  21. package/dist/argv/parse.js +145 -163
  22. package/dist/arrays/_internal.js +65 -48
  23. package/dist/arrays/chunk.js +51 -40
  24. package/dist/arrays/join.js +87 -35
  25. package/dist/arrays/predicates.js +46 -28
  26. package/dist/arrays/unique.js +45 -31
  27. package/dist/bin/_internal.js +34 -42
  28. package/dist/bin/check-primordials.js +175 -233
  29. package/dist/bin/check.js +51 -72
  30. package/dist/bin/exec.js +70 -74
  31. package/dist/bin/find.js +151 -134
  32. package/dist/bin/resolve.js +180 -246
  33. package/dist/bin/shadow.js +24 -33
  34. package/dist/bin/socket-lib.js +51 -73
  35. package/dist/bin/types.js +1 -17
  36. package/dist/bin/which.js +211 -146
  37. package/dist/cacache/_internal.js +25 -40
  38. package/dist/cacache/clear.js +79 -72
  39. package/dist/cacache/read.js +48 -46
  40. package/dist/cacache/tmp.js +29 -36
  41. package/dist/cacache/types.js +1 -17
  42. package/dist/cacache/write.js +43 -48
  43. package/dist/cache/ttl/store.js +232 -288
  44. package/dist/cache/ttl/types.js +1 -17
  45. package/dist/checks/primordials-defaults.js +83 -89
  46. package/dist/checks/primordials.js +225 -277
  47. package/dist/colors/convert.js +45 -37
  48. package/dist/colors/palette.js +88 -45
  49. package/dist/colors/socket-palette.js +74 -84
  50. package/dist/colors/types.js +1 -17
  51. package/dist/compression/_internal.js +57 -72
  52. package/dist/compression/brotli.js +94 -127
  53. package/dist/compression/gzip.js +95 -121
  54. package/dist/compression/types.js +1 -17
  55. package/dist/constants/agents.js +61 -113
  56. package/dist/constants/encoding.js +19 -42
  57. package/dist/constants/github.js +12 -30
  58. package/dist/constants/licenses.js +48 -63
  59. package/dist/constants/lifecycle-script-names.js +31 -45
  60. package/dist/constants/maintained-node-versions.js +22 -37
  61. package/dist/constants/node.js +226 -167
  62. package/dist/constants/package-default-node-range.js +16 -41
  63. package/dist/constants/package-default-socket-categories.js +12 -30
  64. package/dist/constants/packages.js +77 -126
  65. package/dist/constants/platform.js +27 -49
  66. package/dist/constants/sentinels.js +23 -48
  67. package/dist/constants/socket.js +42 -87
  68. package/dist/constants/testing.js +15 -34
  69. package/dist/constants/time.js +16 -36
  70. package/dist/constants/typescript.js +32 -52
  71. package/dist/cover/code.js +111 -142
  72. package/dist/cover/formatters.js +118 -101
  73. package/dist/cover/type.js +50 -76
  74. package/dist/cover/types.js +1 -17
  75. package/dist/crypto/hash.js +54 -46
  76. package/dist/debug/_internal.js +62 -71
  77. package/dist/debug/caller-info.js +53 -64
  78. package/dist/debug/namespace.js +80 -90
  79. package/dist/debug/output.js +172 -188
  80. package/dist/debug/types.js +1 -17
  81. package/dist/dlx/_internal.js +24 -43
  82. package/dist/dlx/arborist.js +162 -160
  83. package/dist/dlx/binary-cache.js +228 -200
  84. package/dist/dlx/binary-download.js +172 -211
  85. package/dist/dlx/binary-resolution.js +165 -157
  86. package/dist/dlx/binary-types.js +1 -17
  87. package/dist/dlx/binary.js +149 -189
  88. package/dist/dlx/cache.js +45 -30
  89. package/dist/dlx/detect.js +245 -159
  90. package/dist/dlx/dir.js +67 -51
  91. package/dist/dlx/firewall.js +62 -100
  92. package/dist/dlx/lockfile.js +122 -127
  93. package/dist/dlx/manifest.js +264 -274
  94. package/dist/dlx/package.js +241 -244
  95. package/dist/dlx/packages.js +99 -96
  96. package/dist/dlx/paths.js +73 -59
  97. package/dist/dlx/spec.js +52 -60
  98. package/dist/dlx/types.js +1 -17
  99. package/dist/eco/cargo/lockfile-format.js +19 -36
  100. package/dist/eco/cargo/manifest-format.js +17 -35
  101. package/dist/eco/cargo/parse-lockfile.js +210 -237
  102. package/dist/eco/manifest/analyze-lockfile.js +46 -63
  103. package/dist/eco/manifest/detect-format.js +66 -90
  104. package/dist/eco/manifest/find-packages.js +39 -64
  105. package/dist/eco/manifest/get-package-versions.js +27 -48
  106. package/dist/eco/manifest/get-package.js +21 -40
  107. package/dist/eco/manifest/manifest-error.js +14 -35
  108. package/dist/eco/manifest/parse-lockfile.js +40 -86
  109. package/dist/eco/manifest/parse-manifest.js +26 -43
  110. package/dist/eco/manifest/parse.js +26 -47
  111. package/dist/eco/manifest/types.js +1 -17
  112. package/dist/eco/npm/bun/exec.js +23 -32
  113. package/dist/eco/npm/manifest-format.js +21 -35
  114. package/dist/eco/npm/npm/exec.js +51 -61
  115. package/dist/eco/npm/npm/extract-package-name-from-path.js +28 -50
  116. package/dist/eco/npm/npm/flags.js +80 -52
  117. package/dist/eco/npm/npm/lockfile-format.js +21 -40
  118. package/dist/eco/npm/npm/parse-git-url.js +26 -40
  119. package/dist/eco/npm/npm/parse-lockfile.js +184 -210
  120. package/dist/eco/npm/parse-package-json.js +71 -102
  121. package/dist/eco/npm/pnpm/detect-pnpm-version.js +22 -43
  122. package/dist/eco/npm/pnpm/exec.js +51 -62
  123. package/dist/eco/npm/pnpm/flags.js +75 -68
  124. package/dist/eco/npm/pnpm/lockfile-format.js +19 -36
  125. package/dist/eco/npm/pnpm/parse-lockfile.js +235 -259
  126. package/dist/eco/npm/pnpm/parse-pnpm-package-id-v5.js +37 -47
  127. package/dist/eco/npm/pnpm/parse-pnpm-package-id-v6-v9.js +36 -49
  128. package/dist/eco/npm/script.js +82 -90
  129. package/dist/eco/npm/vlt/exec.js +24 -32
  130. package/dist/eco/npm/yarnpkg/yarn/exec.js +60 -59
  131. package/dist/eco/npm/yarnpkg/yarn/lockfile-format.js +20 -36
  132. package/dist/eco/npm/yarnpkg/yarn/parse-lockfile.js +194 -242
  133. package/dist/eco/npm/yarnpkg/yarn/parse-yarn-descriptor.js +37 -61
  134. package/dist/eco/purl.js +50 -60
  135. package/dist/eco/types.js +1 -17
  136. package/dist/effects/pulse-frames.js +64 -65
  137. package/dist/effects/shimmer-keyframes.js +71 -52
  138. package/dist/effects/shimmer-terminal.js +81 -50
  139. package/dist/effects/shimmer.js +290 -153
  140. package/dist/env/boolean.js +42 -43
  141. package/dist/env/case-insensitive.js +54 -39
  142. package/dist/env/ci.js +29 -31
  143. package/dist/env/debug.js +28 -31
  144. package/dist/env/github.js +144 -59
  145. package/dist/env/home.js +38 -31
  146. package/dist/env/locale.js +59 -39
  147. package/dist/env/node-auth-token.js +28 -31
  148. package/dist/env/node-env.js +28 -31
  149. package/dist/env/npm.js +94 -47
  150. package/dist/env/number.js +50 -51
  151. package/dist/env/package-manager.js +95 -83
  152. package/dist/env/path.js +28 -31
  153. package/dist/env/pre-commit.js +30 -32
  154. package/dist/env/proxy.js +121 -122
  155. package/dist/env/rewire.js +204 -96
  156. package/dist/env/shell.js +28 -31
  157. package/dist/env/socket-cli.js +233 -81
  158. package/dist/env/socket.js +521 -156
  159. package/dist/env/string.js +43 -44
  160. package/dist/env/temp-dir.js +59 -39
  161. package/dist/env/term.js +28 -31
  162. package/dist/env/test.js +65 -43
  163. package/dist/env/types.js +1 -17
  164. package/dist/env/windows.js +78 -43
  165. package/dist/env/xdg.js +62 -39
  166. package/dist/errors/message.js +40 -46
  167. package/dist/errors/predicates.js +61 -49
  168. package/dist/errors/stack.js +24 -36
  169. package/dist/events/exit/_internal.js +86 -103
  170. package/dist/events/exit/handler.js +48 -55
  171. package/dist/events/exit/intercept.js +49 -70
  172. package/dist/events/exit/lifecycle.js +92 -101
  173. package/dist/events/exit/signals.js +25 -31
  174. package/dist/events/exit/types.js +1 -17
  175. package/dist/events/warning/handler.js +43 -40
  176. package/dist/events/warning/suppress.js +111 -90
  177. package/dist/external/@npmcli/package-json/lib/read-package.js +132 -153
  178. package/dist/external/@npmcli/package-json/lib/sort.js +73 -105
  179. package/dist/external/@npmcli/package-json.js +12705 -15140
  180. package/dist/external/@npmcli/promise-spawn.js +451 -472
  181. package/dist/external/@sinclair/typebox/value.js +7443 -9002
  182. package/dist/external/@sinclair/typebox.js +7516 -7885
  183. package/dist/external/@socketregistry/is-unicode-supported.js +31 -39
  184. package/dist/external/@socketregistry/packageurl-js.js +6127 -7369
  185. package/dist/external/@socketregistry/yocto-spinner.js +394 -455
  186. package/dist/external/@yarnpkg/extensions.js +435 -1022
  187. package/dist/external/adm-zip.js +2313 -2673
  188. package/dist/external/debug.js +700 -687
  189. package/dist/external/external-pack.js +2658 -3171
  190. package/dist/external/fast-sort.js +124 -138
  191. package/dist/external/get-east-asian-width.js +70 -64
  192. package/dist/external/libnpmexec.js +28 -31
  193. package/dist/external/npm-pack.js +43617 -50137
  194. package/dist/external/p-map.js +198 -222
  195. package/dist/external/pico-pack.js +6735 -7304
  196. package/dist/external/pony-cause.js +143 -139
  197. package/dist/external/shell-quote.js +226 -0
  198. package/dist/external/spdx-pack.js +1283 -1403
  199. package/dist/external/streaming-iterables.js +835 -1052
  200. package/dist/external/tar-fs.js +2769 -3048
  201. package/dist/external/which.js +267 -251
  202. package/dist/external/yargs-parser.js +851 -1074
  203. package/dist/external-tools/bazel/asset-names.js +98 -90
  204. package/dist/external-tools/bazel/from-download.js +52 -46
  205. package/dist/external-tools/bazel/from-path.js +27 -38
  206. package/dist/external-tools/bazel/read-bazel-version-file.js +35 -57
  207. package/dist/external-tools/bazel/resolve-asset-url.js +24 -39
  208. package/dist/external-tools/bazel/resolve-bazel-version.js +34 -56
  209. package/dist/external-tools/bazel/resolve.js +44 -58
  210. package/dist/external-tools/bazel/types.js +1 -17
  211. package/dist/external-tools/cdxgen/asset-names.js +59 -66
  212. package/dist/external-tools/cdxgen/from-download.js +52 -80
  213. package/dist/external-tools/cdxgen/from-path.js +19 -37
  214. package/dist/external-tools/cdxgen/from-vfs.js +22 -43
  215. package/dist/external-tools/cdxgen/resolve.js +48 -63
  216. package/dist/external-tools/cdxgen/types.js +1 -17
  217. package/dist/external-tools/from-download.js +107 -67
  218. package/dist/external-tools/janus/asset-names.js +44 -51
  219. package/dist/external-tools/janus/from-download.js +45 -70
  220. package/dist/external-tools/janus/from-path.js +19 -37
  221. package/dist/external-tools/janus/from-vfs.js +22 -43
  222. package/dist/external-tools/janus/resolve.js +45 -63
  223. package/dist/external-tools/janus/types.js +1 -17
  224. package/dist/external-tools/jre/asset-names.js +109 -82
  225. package/dist/external-tools/jre/detect-platform-arch.js +25 -49
  226. package/dist/external-tools/jre/from-download.js +71 -67
  227. package/dist/external-tools/jre/from-java-home.js +27 -54
  228. package/dist/external-tools/jre/from-path.js +27 -49
  229. package/dist/external-tools/jre/from-vfs.js +39 -60
  230. package/dist/external-tools/jre/resolve.js +55 -68
  231. package/dist/external-tools/jre/types.js +1 -17
  232. package/dist/external-tools/manifest.js +130 -150
  233. package/dist/external-tools/opengrep/asset-names.js +60 -72
  234. package/dist/external-tools/opengrep/from-download.js +58 -80
  235. package/dist/external-tools/opengrep/from-path.js +19 -37
  236. package/dist/external-tools/opengrep/from-vfs.js +23 -43
  237. package/dist/external-tools/opengrep/resolve.js +43 -63
  238. package/dist/external-tools/opengrep/types.js +1 -17
  239. package/dist/external-tools/sbt/asset-names.js +21 -30
  240. package/dist/external-tools/sbt/from-download.js +50 -61
  241. package/dist/external-tools/sbt/from-path.js +23 -38
  242. package/dist/external-tools/sbt/from-vfs.js +30 -44
  243. package/dist/external-tools/sbt/resolve.js +45 -63
  244. package/dist/external-tools/sbt/types.js +1 -17
  245. package/dist/external-tools/synp/asset-names.js +11 -29
  246. package/dist/external-tools/synp/from-download.js +24 -41
  247. package/dist/external-tools/synp/from-path.js +19 -37
  248. package/dist/external-tools/synp/from-vfs.js +22 -43
  249. package/dist/external-tools/synp/resolve.js +43 -62
  250. package/dist/external-tools/synp/types.js +1 -17
  251. package/dist/external-tools/trivy/asset-names.js +51 -62
  252. package/dist/external-tools/trivy/from-download.js +42 -64
  253. package/dist/external-tools/trivy/from-path.js +19 -37
  254. package/dist/external-tools/trivy/from-vfs.js +22 -43
  255. package/dist/external-tools/trivy/resolve.js +43 -63
  256. package/dist/external-tools/trivy/types.js +1 -17
  257. package/dist/external-tools/trufflehog/asset-names.js +54 -66
  258. package/dist/external-tools/trufflehog/from-download.js +44 -62
  259. package/dist/external-tools/trufflehog/from-path.js +21 -37
  260. package/dist/external-tools/trufflehog/from-vfs.js +26 -43
  261. package/dist/external-tools/trufflehog/resolve.js +43 -63
  262. package/dist/external-tools/trufflehog/types.js +1 -17
  263. package/dist/external-tools/uv/asset-names.js +64 -74
  264. package/dist/external-tools/uv/from-download.js +44 -65
  265. package/dist/external-tools/uv/from-path.js +19 -37
  266. package/dist/external-tools/uv/from-vfs.js +22 -43
  267. package/dist/external-tools/uv/resolve.js +42 -63
  268. package/dist/external-tools/uv/types.js +1 -17
  269. package/dist/fs/_internal.js +40 -42
  270. package/dist/fs/access.js +57 -54
  271. package/dist/fs/encoding.js +80 -97
  272. package/dist/fs/find-up.js +126 -125
  273. package/dist/fs/inspect.js +168 -99
  274. package/dist/fs/path-cache.js +31 -32
  275. package/dist/fs/read-dir.js +102 -79
  276. package/dist/fs/read-file.js +177 -118
  277. package/dist/fs/read-json-cache.js +150 -134
  278. package/dist/fs/read-json.js +172 -187
  279. package/dist/fs/resolve-module.js +35 -58
  280. package/dist/fs/safe.js +278 -169
  281. package/dist/fs/types.js +1 -17
  282. package/dist/fs/unique.js +52 -48
  283. package/dist/fs/validate.js +56 -40
  284. package/dist/fs/write-json.js +109 -75
  285. package/dist/git/_internal.js +251 -216
  286. package/dist/git/changed.js +191 -74
  287. package/dist/git/repo.js +118 -104
  288. package/dist/git/staged.js +172 -62
  289. package/dist/git/types.js +1 -17
  290. package/dist/git/unstaged.js +175 -62
  291. package/dist/github/constants.js +25 -33
  292. package/dist/github/errors.js +46 -38
  293. package/dist/github/fetch.js +137 -82
  294. package/dist/github/ghsa.js +217 -151
  295. package/dist/github/refs-cache.js +54 -43
  296. package/dist/github/refs-graphql.js +97 -89
  297. package/dist/github/refs-rest.js +70 -101
  298. package/dist/github/refs.js +105 -64
  299. package/dist/github/token.js +96 -48
  300. package/dist/github/types.js +1 -17
  301. package/dist/globs/_internal.js +73 -82
  302. package/dist/globs/defaults.js +40 -59
  303. package/dist/globs/match.js +93 -77
  304. package/dist/globs/matcher.js +104 -92
  305. package/dist/globs/stream.js +43 -55
  306. package/dist/globs/types.js +1 -17
  307. package/dist/http-request/_internal.js +11 -38
  308. package/dist/http-request/browser-fetch.js +19 -29
  309. package/dist/http-request/browser.js +188 -206
  310. package/dist/http-request/checksums.js +101 -65
  311. package/dist/http-request/download-types.js +1 -17
  312. package/dist/http-request/download.js +195 -196
  313. package/dist/http-request/errors.js +39 -47
  314. package/dist/http-request/headers.js +95 -80
  315. package/dist/http-request/http-request.js +10 -35
  316. package/dist/http-request/node.js +71 -97
  317. package/dist/http-request/request-attempt.js +232 -285
  318. package/dist/http-request/request-types.js +1 -17
  319. package/dist/http-request/request.js +106 -108
  320. package/dist/http-request/response-reader.js +47 -51
  321. package/dist/http-request/response-types.js +22 -38
  322. package/dist/http-request/user-agent.js +73 -55
  323. package/dist/integrity.js +105 -106
  324. package/dist/ipc/_internal.js +34 -48
  325. package/dist/ipc/directory.js +55 -63
  326. package/dist/ipc/paths.js +52 -45
  327. package/dist/ipc/types.js +1 -17
  328. package/dist/ipc/write.js +81 -74
  329. package/dist/ipc-cli/get.js +29 -56
  330. package/dist/ipc-cli/types.js +1 -17
  331. package/dist/json/edit.js +182 -242
  332. package/dist/json/format.js +202 -103
  333. package/dist/json/parse.js +206 -109
  334. package/dist/json/types.js +1 -17
  335. package/dist/links/create.js +93 -60
  336. package/dist/links/types.js +1 -17
  337. package/dist/logger/_internal.js +109 -73
  338. package/dist/logger/browser.js +45 -56
  339. package/dist/logger/colors.js +31 -49
  340. package/dist/logger/console.js +89 -112
  341. package/dist/logger/default.js +19 -33
  342. package/dist/logger/logger.js +5 -29
  343. package/dist/logger/node.js +793 -854
  344. package/dist/logger/symbols-builder.js +54 -56
  345. package/dist/logger/symbols.js +135 -118
  346. package/dist/logger/types.js +1 -17
  347. package/dist/memo/_internal.js +39 -49
  348. package/dist/memo/async.js +133 -117
  349. package/dist/memo/clear.js +25 -34
  350. package/dist/memo/decorator.js +43 -37
  351. package/dist/memo/memoize.js +97 -88
  352. package/dist/memo/once.js +42 -41
  353. package/dist/memo/types.js +1 -17
  354. package/dist/memo/weak.js +45 -41
  355. package/dist/node/async-hooks.js +9 -30
  356. package/dist/node/child-process.js +9 -30
  357. package/dist/node/crypto.js +9 -30
  358. package/dist/node/events.js +9 -30
  359. package/dist/node/fs-promises.js +9 -30
  360. package/dist/node/fs.js +9 -30
  361. package/dist/node/http.js +9 -30
  362. package/dist/node/https.js +9 -30
  363. package/dist/node/module.js +20 -34
  364. package/dist/node/os.js +9 -30
  365. package/dist/node/path.js +9 -30
  366. package/dist/node/timers-promises.js +9 -30
  367. package/dist/node/url.js +9 -30
  368. package/dist/node/util.js +9 -30
  369. package/dist/objects/getters.js +185 -126
  370. package/dist/objects/inspect.js +85 -52
  371. package/dist/objects/mutate.js +96 -76
  372. package/dist/objects/predicates.js +112 -59
  373. package/dist/objects/sort.js +120 -76
  374. package/dist/objects/types.js +1 -17
  375. package/dist/packages/edit-class.js +198 -265
  376. package/dist/packages/edit.js +79 -86
  377. package/dist/packages/exports.js +146 -157
  378. package/dist/packages/isolation.js +159 -209
  379. package/dist/packages/licenses.js +207 -189
  380. package/dist/packages/manifest.js +134 -172
  381. package/dist/packages/normalize.js +91 -102
  382. package/dist/packages/operations.d.ts +2 -0
  383. package/dist/packages/operations.js +283 -254
  384. package/dist/packages/provenance.js +195 -245
  385. package/dist/packages/specs.js +94 -84
  386. package/dist/packages/types.js +1 -17
  387. package/dist/packages/validation.js +49 -50
  388. package/dist/paths/_internal.js +82 -86
  389. package/dist/paths/conversion.js +112 -65
  390. package/dist/paths/dirnames.js +17 -42
  391. package/dist/paths/exts.js +23 -54
  392. package/dist/paths/filenames.js +21 -50
  393. package/dist/paths/globs.js +15 -38
  394. package/dist/paths/normalize.js +215 -236
  395. package/dist/paths/packages.js +34 -49
  396. package/dist/paths/predicates.js +184 -106
  397. package/dist/paths/resolve.js +146 -128
  398. package/dist/paths/rewire.js +108 -72
  399. package/dist/paths/socket.js +252 -132
  400. package/dist/paths/walk.js +55 -60
  401. package/dist/perf/_internal.js +10 -28
  402. package/dist/perf/enabled.js +21 -30
  403. package/dist/perf/metrics.js +81 -67
  404. package/dist/perf/report.js +79 -80
  405. package/dist/perf/timer.js +180 -126
  406. package/dist/perf/types.js +1 -17
  407. package/dist/pkg-ext/data.js +29 -82
  408. package/dist/pkg-ext/types.js +1 -17
  409. package/dist/primordials/array.js +120 -198
  410. package/dist/primordials/buffer.js +28 -51
  411. package/dist/primordials/date.js +26 -51
  412. package/dist/primordials/error.js +33 -59
  413. package/dist/primordials/function.js +21 -41
  414. package/dist/primordials/globals.js +25 -48
  415. package/dist/primordials/json.js +14 -30
  416. package/dist/primordials/map-set.js +88 -152
  417. package/dist/primordials/math.js +59 -116
  418. package/dist/primordials/number.js +41 -76
  419. package/dist/primordials/object.js +56 -116
  420. package/dist/primordials/promise.js +28 -52
  421. package/dist/primordials/reflect.js +24 -52
  422. package/dist/primordials/regexp.js +25 -47
  423. package/dist/primordials/string.js +114 -167
  424. package/dist/primordials/symbol.js +40 -72
  425. package/dist/primordials/uncurry.js +38 -55
  426. package/dist/primordials/url.js +27 -66
  427. package/dist/process/_internal.js +7 -32
  428. package/dist/process/abort.js +29 -35
  429. package/dist/process/lock-instance.js +26 -30
  430. package/dist/process/lock-manager.js +279 -307
  431. package/dist/process/lock-types.js +1 -17
  432. package/dist/process/spawn/_internal.js +43 -55
  433. package/dist/process/spawn/child.js +172 -211
  434. package/dist/process/spawn/errors.js +116 -113
  435. package/dist/process/spawn/stdio.js +51 -35
  436. package/dist/process/spawn/types.js +1 -17
  437. package/dist/process/transient.js +49 -66
  438. package/dist/promises/_internal.js +31 -34
  439. package/dist/promises/iterate.js +238 -102
  440. package/dist/promises/options.js +123 -101
  441. package/dist/promises/queue.js +115 -136
  442. package/dist/promises/resolvers.js +77 -46
  443. package/dist/promises/retry.js +156 -101
  444. package/dist/promises/types.js +1 -17
  445. package/dist/regexps/escape.js +32 -30
  446. package/dist/regexps/hex.js +16 -33
  447. package/dist/regexps/spec.js +53 -81
  448. package/dist/releases/github-archives.js +127 -118
  449. package/dist/releases/github-asset-url.js +162 -146
  450. package/dist/releases/github-assets.js +37 -49
  451. package/dist/releases/github-auth.js +32 -48
  452. package/dist/releases/github-downloads.js +118 -138
  453. package/dist/releases/github-listing.js +175 -145
  454. package/dist/releases/github-retry-config.js +41 -47
  455. package/dist/releases/github-types.js +1 -17
  456. package/dist/releases/socket-btm.js +273 -192
  457. package/dist/schema/parse.js +35 -36
  458. package/dist/schema/types.js +1 -17
  459. package/dist/schema/validate.js +118 -99
  460. package/dist/sea/detect.js +57 -52
  461. package/dist/secrets/_internal.js +86 -67
  462. package/dist/secrets/find.js +96 -77
  463. package/dist/secrets/keychain.js +315 -309
  464. package/dist/secrets/linux.js +133 -135
  465. package/dist/secrets/macos.js +151 -147
  466. package/dist/secrets/rc.js +182 -181
  467. package/dist/secrets/socket-api-token.js +28 -43
  468. package/dist/secrets/types.js +1 -17
  469. package/dist/secrets/windows.js +184 -242
  470. package/dist/shadow/skip.js +51 -70
  471. package/dist/shadow/types.js +1 -17
  472. package/dist/shell/parse.d.ts +26 -0
  473. package/dist/shell/parse.js +35 -0
  474. package/dist/shell/quote.d.ts +19 -0
  475. package/dist/shell/quote.js +30 -0
  476. package/dist/smol/detect.js +67 -43
  477. package/dist/smol/http.js +33 -37
  478. package/dist/smol/https.js +31 -37
  479. package/dist/smol/manifest.js +33 -37
  480. package/dist/smol/path.js +33 -37
  481. package/dist/smol/primordial.js +35 -37
  482. package/dist/smol/purl.js +34 -37
  483. package/dist/smol/versions.js +31 -37
  484. package/dist/smol/vfs.js +46 -38
  485. package/dist/sorts/_internal.js +14 -40
  486. package/dist/sorts/natural.js +57 -64
  487. package/dist/sorts/semver.js +33 -43
  488. package/dist/sorts/strings.js +24 -30
  489. package/dist/sorts/types.js +1 -17
  490. package/dist/spinner/default.js +72 -63
  491. package/dist/spinner/format.js +86 -71
  492. package/dist/spinner/spinner.js +749 -797
  493. package/dist/spinner/types.js +1 -17
  494. package/dist/spinner/with.js +193 -137
  495. package/dist/ssri/convert.js +64 -47
  496. package/dist/ssri/parse.js +38 -37
  497. package/dist/ssri/validate.js +51 -34
  498. package/dist/stdio/_internal.js +50 -46
  499. package/dist/stdio/clear.js +208 -86
  500. package/dist/stdio/divider.js +170 -97
  501. package/dist/stdio/footer.js +116 -110
  502. package/dist/stdio/header.js +117 -90
  503. package/dist/stdio/progress.js +189 -218
  504. package/dist/stdio/prompts.js +244 -168
  505. package/dist/stdio/stderr.js +173 -78
  506. package/dist/stdio/stdout.js +177 -94
  507. package/dist/streams/parallel.js +58 -50
  508. package/dist/streams/transform.js +36 -45
  509. package/dist/strings/format.js +145 -63
  510. package/dist/strings/predicates.js +56 -34
  511. package/dist/strings/search.js +52 -42
  512. package/dist/strings/transform.js +113 -72
  513. package/dist/strings/types.js +1 -17
  514. package/dist/strings/width.js +89 -82
  515. package/dist/tables/bordered.js +81 -81
  516. package/dist/tables/padding.js +36 -46
  517. package/dist/tables/simple.js +62 -70
  518. package/dist/tables/types.js +1 -17
  519. package/dist/temporal/instant.js +72 -81
  520. package/dist/temporal/now.js +40 -31
  521. package/dist/temporal/slots.js +42 -36
  522. package/dist/temporal/system.js +36 -36
  523. package/dist/temporal/temporal.js +11 -41
  524. package/dist/themes/context.js +131 -69
  525. package/dist/themes/resolve.js +207 -132
  526. package/dist/themes/themes.js +225 -194
  527. package/dist/themes/types.js +1 -17
  528. package/dist/url/parse.js +48 -51
  529. package/dist/url/predicates.js +24 -31
  530. package/dist/url/search-params.js +133 -101
  531. package/dist/url/types.js +1 -17
  532. package/dist/versions/_internal.js +31 -33
  533. package/dist/versions/compare.js +80 -58
  534. package/dist/versions/modify.js +41 -39
  535. package/dist/versions/parse.js +88 -64
  536. package/dist/versions/range.js +58 -41
  537. package/dist/versions/types.js +1 -17
  538. package/dist/words/article.js +22 -30
  539. package/dist/words/capitalize.js +25 -34
  540. package/dist/words/pluralize.js +23 -31
  541. package/dist/words/types.js +1 -17
  542. package/package.json +17 -5
@@ -1,1061 +1,844 @@
1
1
  "use strict";
2
2
  /**
3
3
  * Bundled from streaming-iterables
4
- * This is a zero-dependency bundle created by esbuild.
4
+ * This is a zero-dependency bundle created by rolldown.
5
5
  */
6
- "use strict";
7
- var __defProp = Object.defineProperty;
8
- var __getOwnPropNames = Object.getOwnPropertyNames;
9
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
10
- var __commonJS = (cb, mod) => function __require() {
11
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
- };
6
+ 'use strict';
13
7
 
14
- // node_modules/.pnpm/streaming-iterables@8.0.1/node_modules/streaming-iterables/dist/index.js
15
- var require_dist = __commonJS({
16
- "node_modules/.pnpm/streaming-iterables@8.0.1/node_modules/streaming-iterables/dist/index.js"(exports2, module2) {
17
- (function(global, factory) {
18
- typeof exports2 === "object" && typeof module2 !== "undefined" ? factory(exports2) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.streamingIterables = {}));
19
- })(exports2, (function(exports3) {
20
- "use strict";
21
- async function* _batch(size, iterable) {
22
- let dataBatch = [];
23
- for await (const data of iterable) {
24
- dataBatch.push(data);
25
- if (dataBatch.length === size) {
26
- yield dataBatch;
27
- dataBatch = [];
28
- }
29
- }
30
- if (dataBatch.length > 0) {
31
- yield dataBatch;
32
- }
33
- }
34
- __name(_batch, "_batch");
35
- function* _syncBatch(size, iterable) {
36
- let dataBatch = [];
37
- for (const data of iterable) {
38
- dataBatch.push(data);
39
- if (dataBatch.length === size) {
40
- yield dataBatch;
41
- dataBatch = [];
42
- }
43
- }
44
- if (dataBatch.length > 0) {
45
- yield dataBatch;
46
- }
47
- }
48
- __name(_syncBatch, "_syncBatch");
49
- function batch(size, iterable) {
50
- if (iterable === void 0) {
51
- return (curriedIterable) => batch(size, curriedIterable);
52
- }
53
- if (iterable[Symbol.asyncIterator]) {
54
- return _batch(size, iterable);
55
- }
56
- return _syncBatch(size, iterable);
57
- }
58
- __name(batch, "batch");
59
- const TIMEOUT = Symbol("TIMEOUT");
60
- const createTimer = /* @__PURE__ */ __name((duration) => {
61
- let timeoutId;
62
- return [
63
- new Promise((resolve) => {
64
- timeoutId = setTimeout(() => resolve(TIMEOUT), duration);
65
- }),
66
- () => {
67
- clearTimeout(timeoutId);
68
- }
69
- ];
70
- }, "createTimer");
71
- async function* _batchWithTimeout(size, timeout, iterable) {
72
- const iterator = iterable[Symbol.asyncIterator]();
73
- let pendingData;
74
- let batchData = [];
75
- let timer;
76
- let clearTimer;
77
- const startTimer = /* @__PURE__ */ __name(() => {
78
- deleteTimer();
79
- [timer, clearTimer] = createTimer(timeout);
80
- }, "startTimer");
81
- const deleteTimer = /* @__PURE__ */ __name(() => {
82
- if (clearTimer) {
83
- clearTimer();
84
- }
85
- timer = void 0;
86
- }, "deleteTimer");
87
- pendingData = iterator.next();
88
- while (true) {
89
- const res = await (timer ? Promise.race([pendingData, timer]) : pendingData);
90
- if (res === TIMEOUT || res.done) {
91
- if (batchData.length) {
92
- yield batchData;
93
- batchData = [];
94
- }
95
- deleteTimer();
96
- if (res !== TIMEOUT) {
97
- break;
98
- }
99
- continue;
100
- }
101
- pendingData = iterator.next();
102
- batchData.push(res.value);
103
- if (batchData.length === 1) {
104
- startTimer();
105
- }
106
- if (batchData.length === size) {
107
- yield batchData;
108
- batchData = [];
109
- deleteTimer();
110
- continue;
111
- }
112
- }
113
- }
114
- __name(_batchWithTimeout, "_batchWithTimeout");
115
- function batchWithTimeout(size, timeout, iterable) {
116
- if (iterable === void 0) {
117
- return (curriedIterable) => batchWithTimeout(size, timeout, curriedIterable);
118
- }
119
- if (iterable[Symbol.asyncIterator] && timeout !== Infinity) {
120
- return _batchWithTimeout(size, timeout, iterable);
121
- }
122
- return batch(size, iterable);
123
- }
124
- __name(batchWithTimeout, "batchWithTimeout");
125
- function getIterator(iterable) {
126
- if (typeof iterable.next === "function") {
127
- return iterable;
128
- }
129
- if (typeof iterable[Symbol.iterator] === "function") {
130
- return iterable[Symbol.iterator]();
131
- }
132
- if (typeof iterable[Symbol.asyncIterator] === "function") {
133
- return iterable[Symbol.asyncIterator]();
134
- }
135
- throw new TypeError('"values" does not to conform to any of the iterator or iterable protocols');
136
- }
137
- __name(getIterator, "getIterator");
138
- function defer() {
139
- let reject;
140
- let resolve;
141
- const promise = new Promise((resolveFunc, rejectFunc) => {
142
- resolve = resolveFunc;
143
- reject = rejectFunc;
144
- });
145
- return {
146
- promise,
147
- reject,
148
- resolve
149
- };
150
- }
151
- __name(defer, "defer");
152
- function _buffer(size, iterable) {
153
- const iterator = getIterator(iterable);
154
- const resultQueue = [];
155
- const readQueue = [];
156
- let reading = false;
157
- let ended = false;
158
- function fulfillReadQueue() {
159
- while (readQueue.length > 0 && resultQueue.length > 0) {
160
- const readDeferred = readQueue.shift();
161
- const { error, value } = resultQueue.shift();
162
- if (error) {
163
- readDeferred.reject(error);
164
- } else {
165
- readDeferred.resolve({ done: false, value });
166
- }
167
- }
168
- while (readQueue.length > 0 && ended) {
169
- const { resolve } = readQueue.shift();
170
- resolve({ done: true, value: void 0 });
171
- }
172
- }
173
- __name(fulfillReadQueue, "fulfillReadQueue");
174
- async function fillQueue() {
175
- if (ended) {
176
- return;
177
- }
178
- if (reading) {
179
- return;
180
- }
181
- if (resultQueue.length >= size) {
182
- return;
183
- }
184
- reading = true;
185
- try {
186
- const { done, value } = await iterator.next();
187
- if (done) {
188
- ended = true;
189
- } else {
190
- resultQueue.push({ value });
191
- }
192
- } catch (error) {
193
- ended = true;
194
- resultQueue.push({ error });
195
- }
196
- fulfillReadQueue();
197
- reading = false;
198
- fillQueue();
199
- }
200
- __name(fillQueue, "fillQueue");
201
- async function next() {
202
- if (resultQueue.length > 0) {
203
- const { error, value } = resultQueue.shift();
204
- if (error) {
205
- throw error;
206
- }
207
- fillQueue();
208
- return { done: false, value };
209
- }
210
- if (ended) {
211
- return { done: true, value: void 0 };
212
- }
213
- const deferred = defer();
214
- readQueue.push(deferred);
215
- fillQueue();
216
- return deferred.promise;
217
- }
218
- __name(next, "next");
219
- const asyncIterableIterator = {
220
- next,
221
- [Symbol.asyncIterator]: () => asyncIterableIterator
222
- };
223
- return asyncIterableIterator;
224
- }
225
- __name(_buffer, "_buffer");
226
- function* syncBuffer(size, iterable) {
227
- const valueQueue = [];
228
- let e;
229
- try {
230
- for (const value of iterable) {
231
- valueQueue.push(value);
232
- if (valueQueue.length <= size) {
233
- continue;
234
- }
235
- yield valueQueue.shift();
236
- }
237
- } catch (error) {
238
- e = error;
239
- }
240
- for (const value of valueQueue) {
241
- yield value;
242
- }
243
- if (e) {
244
- throw e;
245
- }
246
- }
247
- __name(syncBuffer, "syncBuffer");
248
- function buffer(size, iterable) {
249
- if (iterable === void 0) {
250
- return (curriedIterable) => buffer(size, curriedIterable);
251
- }
252
- if (size === 0) {
253
- return iterable;
254
- }
255
- if (iterable[Symbol.asyncIterator]) {
256
- return _buffer(size, iterable);
257
- }
258
- return syncBuffer(size, iterable);
259
- }
260
- __name(buffer, "buffer");
261
- async function _collect(iterable) {
262
- const values = [];
263
- for await (const value of iterable) {
264
- values.push(value);
265
- }
266
- return values;
267
- }
268
- __name(_collect, "_collect");
269
- function collect(iterable) {
270
- if (iterable[Symbol.asyncIterator]) {
271
- return _collect(iterable);
272
- }
273
- return Array.from(iterable);
274
- }
275
- __name(collect, "collect");
276
- async function* _concat(iterables) {
277
- for await (const iterable of iterables) {
278
- yield* iterable;
279
- }
280
- }
281
- __name(_concat, "_concat");
282
- function* _syncConcat(iterables) {
283
- for (const iterable of iterables) {
284
- yield* iterable;
285
- }
286
- }
287
- __name(_syncConcat, "_syncConcat");
288
- function concat(...iterables) {
289
- const hasAnyAsync = iterables.find((itr) => itr[Symbol.asyncIterator] !== void 0);
290
- if (hasAnyAsync) {
291
- return _concat(iterables);
292
- } else {
293
- return _syncConcat(iterables);
294
- }
295
- }
296
- __name(concat, "concat");
297
- async function _consume(iterable) {
298
- for await (const _val of iterable) {
299
- }
300
- }
301
- __name(_consume, "_consume");
302
- function consume(iterable) {
303
- if (iterable[Symbol.asyncIterator]) {
304
- return _consume(iterable);
305
- }
306
- for (const _val of iterable) {
307
- }
308
- }
309
- __name(consume, "consume");
310
- async function* _drop(count, iterable) {
311
- let skipped = 0;
312
- for await (const val of iterable) {
313
- if (skipped < count) {
314
- skipped++;
315
- continue;
316
- }
317
- yield await val;
318
- }
319
- }
320
- __name(_drop, "_drop");
321
- function* _syncDrop(count, iterable) {
322
- let skipped = 0;
323
- for (const val of iterable) {
324
- if (skipped < count) {
325
- skipped++;
326
- continue;
327
- }
328
- yield val;
329
- }
330
- }
331
- __name(_syncDrop, "_syncDrop");
332
- function drop(count, iterable) {
333
- if (iterable === void 0) {
334
- return (curriedIterable) => drop(count, curriedIterable);
335
- }
336
- if (iterable[Symbol.asyncIterator]) {
337
- return _drop(count, iterable);
338
- }
339
- return _syncDrop(count, iterable);
340
- }
341
- __name(drop, "drop");
342
- async function* _filter(filterFunc, iterable) {
343
- for await (const data of iterable) {
344
- if (await filterFunc(data)) {
345
- yield data;
346
- }
347
- }
348
- }
349
- __name(_filter, "_filter");
350
- function filter(filterFunc, iterable) {
351
- if (iterable === void 0) {
352
- return (curriedIterable) => _filter(filterFunc, curriedIterable);
353
- }
354
- return _filter(filterFunc, iterable);
355
- }
356
- __name(filter, "filter");
357
- async function* flatten(iterable) {
358
- for await (const maybeItr of iterable) {
359
- if (maybeItr && typeof maybeItr !== "string" && (maybeItr[Symbol.iterator] || maybeItr[Symbol.asyncIterator])) {
360
- yield* flatten(maybeItr);
361
- } else {
362
- yield maybeItr;
363
- }
364
- }
365
- }
366
- __name(flatten, "flatten");
367
- async function* _map(func, iterable) {
368
- for await (const val of iterable) {
369
- yield await func(val);
370
- }
371
- }
372
- __name(_map, "_map");
373
- function map(func, iterable) {
374
- if (iterable === void 0) {
375
- return (curriedIterable) => _map(func, curriedIterable);
376
- }
377
- return _map(func, iterable);
378
- }
379
- __name(map, "map");
380
- function flatMap(func, iterable) {
381
- if (iterable === void 0) {
382
- return (curriedIterable) => flatMap(func, curriedIterable);
383
- }
384
- return filter((i) => i !== void 0 && i !== null, flatten(map(func, iterable)));
385
- }
386
- __name(flatMap, "flatMap");
387
- function _flatTransform(concurrency, func, iterable) {
388
- const iterator = getIterator(iterable);
389
- const resultQueue = [];
390
- const readQueue = [];
391
- let ended = false;
392
- let reading = false;
393
- let inflightCount = 0;
394
- let lastError = null;
395
- function fulfillReadQueue() {
396
- while (readQueue.length > 0 && resultQueue.length > 0) {
397
- const { resolve } = readQueue.shift();
398
- const value = resultQueue.shift();
399
- resolve({ done: false, value });
400
- }
401
- while (readQueue.length > 0 && inflightCount === 0 && ended) {
402
- const { resolve, reject } = readQueue.shift();
403
- if (lastError) {
404
- reject(lastError);
405
- lastError = null;
406
- } else {
407
- resolve({ done: true, value: void 0 });
408
- }
409
- }
410
- }
411
- __name(fulfillReadQueue, "fulfillReadQueue");
412
- async function fillQueue() {
413
- if (ended) {
414
- fulfillReadQueue();
415
- return;
416
- }
417
- if (reading) {
418
- return;
419
- }
420
- if (inflightCount + resultQueue.length >= concurrency) {
421
- return;
422
- }
423
- reading = true;
424
- inflightCount++;
425
- try {
426
- const { done, value } = await iterator.next();
427
- if (done) {
428
- ended = true;
429
- inflightCount--;
430
- fulfillReadQueue();
431
- } else {
432
- mapAndQueue(value);
433
- }
434
- } catch (error) {
435
- ended = true;
436
- inflightCount--;
437
- lastError = error;
438
- fulfillReadQueue();
439
- }
440
- reading = false;
441
- fillQueue();
442
- }
443
- __name(fillQueue, "fillQueue");
444
- async function mapAndQueue(itrValue) {
445
- try {
446
- const value = await func(itrValue);
447
- if (value && value[Symbol.asyncIterator]) {
448
- for await (const asyncVal of value) {
449
- resultQueue.push(asyncVal);
450
- }
451
- } else {
452
- resultQueue.push(value);
453
- }
454
- } catch (error) {
455
- ended = true;
456
- lastError = error;
457
- }
458
- inflightCount--;
459
- fulfillReadQueue();
460
- fillQueue();
461
- }
462
- __name(mapAndQueue, "mapAndQueue");
463
- async function next() {
464
- if (resultQueue.length === 0) {
465
- const deferred = defer();
466
- readQueue.push(deferred);
467
- fillQueue();
468
- return deferred.promise;
469
- }
470
- const value = resultQueue.shift();
471
- fillQueue();
472
- return { done: false, value };
473
- }
474
- __name(next, "next");
475
- const asyncIterableIterator = {
476
- next,
477
- [Symbol.asyncIterator]: () => asyncIterableIterator
478
- };
479
- return asyncIterableIterator;
480
- }
481
- __name(_flatTransform, "_flatTransform");
482
- function flatTransform(concurrency, func, iterable) {
483
- if (func === void 0) {
484
- return (curriedFunc, curriedIterable) => curriedIterable ? flatTransform(concurrency, curriedFunc, curriedIterable) : flatTransform(concurrency, curriedFunc);
485
- }
486
- if (iterable === void 0) {
487
- return (curriedIterable) => flatTransform(concurrency, func, curriedIterable);
488
- }
489
- return filter((i) => i !== void 0 && i !== null, flatten(_flatTransform(concurrency, func, iterable)));
490
- }
491
- __name(flatTransform, "flatTransform");
492
- async function onceReadable(stream) {
493
- return new Promise((resolve) => {
494
- stream.once("readable", () => {
495
- resolve();
496
- });
497
- });
498
- }
499
- __name(onceReadable, "onceReadable");
500
- async function* _fromStream(stream) {
501
- while (true) {
502
- const data = stream.read();
503
- if (data !== null) {
504
- yield data;
505
- continue;
506
- }
507
- if (stream._readableState.ended) {
508
- break;
509
- }
510
- await onceReadable(stream);
511
- }
512
- }
513
- __name(_fromStream, "_fromStream");
514
- function fromStream(stream) {
515
- if (typeof stream[Symbol.asyncIterator] === "function") {
516
- return stream;
517
- }
518
- return _fromStream(stream);
519
- }
520
- __name(fromStream, "fromStream");
521
- async function* merge(...iterables) {
522
- const sources = new Set(iterables.map(getIterator));
523
- while (sources.size > 0) {
524
- for (const iterator of sources) {
525
- const nextVal = await iterator.next();
526
- if (nextVal.done) {
527
- sources.delete(iterator);
528
- } else {
529
- yield nextVal.value;
530
- }
531
- }
532
- }
533
- }
534
- __name(merge, "merge");
535
- function pipeline(firstFn, ...fns) {
536
- let previousFn = firstFn();
537
- for (const func of fns) {
538
- previousFn = func(previousFn);
539
- }
540
- return previousFn;
541
- }
542
- __name(pipeline, "pipeline");
543
- async function* _parallelMap(concurrency, func, iterable) {
544
- let transformError = null;
545
- const wrapFunc = /* @__PURE__ */ __name((value) => ({
546
- value: func(value)
547
- }), "wrapFunc");
548
- const stopOnError = /* @__PURE__ */ __name(async function* (source) {
549
- for await (const value of source) {
550
- if (transformError) {
551
- return;
552
- }
553
- yield value;
554
- }
555
- }, "stopOnError");
556
- const output = pipeline(() => iterable, buffer(1), stopOnError, map(wrapFunc), buffer(concurrency - 1));
557
- const itr = getIterator(output);
558
- while (true) {
559
- const { value, done } = await itr.next();
560
- if (done) {
561
- break;
562
- }
563
- try {
564
- const val = await value.value;
565
- if (!transformError) {
566
- yield val;
567
- }
568
- } catch (error) {
569
- transformError = error;
570
- }
571
- }
572
- if (transformError) {
573
- throw transformError;
574
- }
575
- }
576
- __name(_parallelMap, "_parallelMap");
577
- function parallelMap2(concurrency, func, iterable) {
578
- if (func === void 0) {
579
- return (curriedFunc, curriedIterable) => parallelMap2(concurrency, curriedFunc, curriedIterable);
580
- }
581
- if (iterable === void 0) {
582
- return (curriedIterable) => parallelMap2(concurrency, func, curriedIterable);
583
- }
584
- if (concurrency === 1) {
585
- return map(func, iterable);
586
- }
587
- return _parallelMap(concurrency, func, iterable);
588
- }
589
- __name(parallelMap2, "parallelMap");
590
- function parallelFlatMap(concurrency, func, iterable) {
591
- if (func === void 0) {
592
- return (curriedFunc, curriedIterable) => curriedIterable ? parallelFlatMap(concurrency, curriedFunc, curriedIterable) : parallelFlatMap(concurrency, curriedFunc);
593
- }
594
- if (iterable === void 0) {
595
- return (curriedIterable) => parallelFlatMap(concurrency, func, curriedIterable);
596
- }
597
- return filter((i) => i !== void 0 && i !== null, flatten(parallelMap2(concurrency, func, iterable)));
598
- }
599
- __name(parallelFlatMap, "parallelFlatMap");
600
- async function* parallelMerge(...iterables) {
601
- const inputs = iterables.map(getIterator);
602
- const concurrentWork = /* @__PURE__ */ new Set();
603
- const values = /* @__PURE__ */ new Map();
604
- let lastError = null;
605
- let errCb = null;
606
- let valueCb = null;
607
- const notifyError = /* @__PURE__ */ __name((err) => {
608
- lastError = err;
609
- if (errCb) {
610
- errCb(err);
611
- }
612
- }, "notifyError");
613
- const notifyDone = /* @__PURE__ */ __name((value) => {
614
- if (valueCb) {
615
- valueCb(value);
616
- }
617
- }, "notifyDone");
618
- const waitForQueue = /* @__PURE__ */ __name(() => new Promise((resolve, reject) => {
619
- if (lastError) {
620
- reject(lastError);
621
- }
622
- if (values.size > 0) {
623
- return resolve();
624
- }
625
- valueCb = resolve;
626
- errCb = reject;
627
- }), "waitForQueue");
628
- const queueNext = /* @__PURE__ */ __name((input) => {
629
- const nextVal = Promise.resolve(input.next()).then(async ({ done, value }) => {
630
- if (!done) {
631
- values.set(input, value);
632
- }
633
- concurrentWork.delete(nextVal);
634
- });
635
- concurrentWork.add(nextVal);
636
- nextVal.then(notifyDone, notifyError);
637
- }, "queueNext");
638
- for (const input of inputs) {
639
- queueNext(input);
640
- }
641
- while (true) {
642
- if (concurrentWork.size === 0 && values.size === 0) {
643
- return;
644
- }
645
- await waitForQueue();
646
- for (const [input, value] of values) {
647
- values.delete(input);
648
- yield value;
649
- queueNext(input);
650
- }
651
- }
652
- }
653
- __name(parallelMerge, "parallelMerge");
654
- async function _reduce(func, start, iterable) {
655
- let value = start;
656
- for await (const nextItem of iterable) {
657
- value = await func(value, nextItem);
658
- }
659
- return value;
660
- }
661
- __name(_reduce, "_reduce");
662
- function reduce(func, start, iterable) {
663
- if (start === void 0) {
664
- return (curriedStart, curriedIterable) => curriedIterable ? _reduce(func, curriedStart, curriedIterable) : reduce(func, curriedStart);
665
- }
666
- if (iterable === void 0) {
667
- return (curriedIterable) => reduce(func, start, curriedIterable);
668
- }
669
- return _reduce(func, start, iterable);
670
- }
671
- __name(reduce, "reduce");
672
- async function* _take(count, iterable) {
673
- let taken = 0;
674
- for await (const val of iterable) {
675
- yield await val;
676
- taken++;
677
- if (taken >= count) {
678
- break;
679
- }
680
- }
681
- }
682
- __name(_take, "_take");
683
- function* _syncTake(count, iterable) {
684
- let taken = 0;
685
- for (const val of iterable) {
686
- yield val;
687
- taken++;
688
- if (taken >= count) {
689
- break;
690
- }
691
- }
692
- }
693
- __name(_syncTake, "_syncTake");
694
- function take(count, iterable) {
695
- if (iterable === void 0) {
696
- return (curriedIterable) => take(count, curriedIterable);
697
- }
698
- if (iterable[Symbol.asyncIterator]) {
699
- return _take(count, iterable);
700
- }
701
- return _syncTake(count, iterable);
702
- }
703
- __name(take, "take");
704
- async function* _takeLast(count, iterable) {
705
- const buffer2 = [];
706
- for await (const res of iterable) {
707
- buffer2.push(res);
708
- if (buffer2.length > count) {
709
- buffer2.shift();
710
- }
711
- }
712
- while (buffer2.length) {
713
- yield await buffer2.shift();
714
- }
715
- }
716
- __name(_takeLast, "_takeLast");
717
- function* _syncTakeLast(count, iterable) {
718
- const buffer2 = [];
719
- for (const res of iterable) {
720
- buffer2.push(res);
721
- if (buffer2.length > count) {
722
- buffer2.shift();
723
- }
724
- }
725
- while (buffer2.length) {
726
- yield buffer2.shift();
727
- }
728
- }
729
- __name(_syncTakeLast, "_syncTakeLast");
730
- function takeLast(count, iterable) {
731
- if (iterable === void 0) {
732
- return (curriedIterable) => takeLast(count, curriedIterable);
733
- }
734
- if (iterable[Symbol.asyncIterator]) {
735
- return _takeLast(count, iterable);
736
- }
737
- return _syncTakeLast(count, iterable);
738
- }
739
- __name(takeLast, "takeLast");
740
- async function* _takeWhile(predicate, iterable) {
741
- for await (const data of iterable) {
742
- if (!await predicate(data)) {
743
- return;
744
- }
745
- yield data;
746
- }
747
- }
748
- __name(_takeWhile, "_takeWhile");
749
- function takeWhile(predicate, iterable) {
750
- if (iterable === void 0) {
751
- return (curriedIterable) => _takeWhile(predicate, curriedIterable);
752
- }
753
- return _takeWhile(predicate, iterable);
754
- }
755
- __name(takeWhile, "takeWhile");
756
- async function* _asyncTap(func, iterable) {
757
- for await (const val of iterable) {
758
- await func(val);
759
- yield val;
760
- }
761
- }
762
- __name(_asyncTap, "_asyncTap");
763
- function tap(func, iterable) {
764
- if (iterable === void 0) {
765
- return (curriedIterable) => _asyncTap(func, curriedIterable);
766
- }
767
- return _asyncTap(func, iterable);
768
- }
769
- __name(tap, "tap");
770
- const sleep = /* @__PURE__ */ __name((ms) => new Promise((resolve) => setTimeout(resolve, ms)), "sleep");
771
- function _throttle(limit, interval, iterable) {
772
- if (!Number.isFinite(limit)) {
773
- throw new TypeError("Expected `limit` to be a finite number");
774
- }
775
- if (limit <= 0) {
776
- throw new TypeError("Expected `limit` to be greater than 0");
777
- }
778
- if (!Number.isFinite(interval)) {
779
- throw new TypeError("Expected `interval` to be a finite number");
780
- }
781
- return (/* @__PURE__ */ __name((async function* __throttle() {
782
- let sent = 0;
783
- let time2;
784
- for await (const val of iterable) {
785
- if (sent < limit) {
786
- if (typeof time2 === "undefined") {
787
- time2 = Date.now();
788
- }
789
- sent++;
790
- yield val;
791
- continue;
792
- }
793
- const elapsedMs = Date.now() - (time2 || 0);
794
- const waitFor = interval - elapsedMs;
795
- if (waitFor > 0) {
796
- await sleep(waitFor);
797
- }
798
- time2 = Date.now();
799
- sent = 1;
800
- yield val;
801
- }
802
- }), "__throttle"))();
803
- }
804
- __name(_throttle, "_throttle");
805
- function throttle(limit, interval, iterable) {
806
- if (iterable === void 0) {
807
- return (curriedIterable) => _throttle(limit, interval, curriedIterable);
808
- }
809
- return _throttle(limit, interval, iterable);
810
- }
811
- __name(throttle, "throttle");
812
- function addTime(a, b) {
813
- let seconds = a[0] + b[0];
814
- let nanoseconds = a[1] + b[1];
815
- if (nanoseconds >= 1e9) {
816
- const remainder = nanoseconds % 1e9;
817
- seconds += (nanoseconds - remainder) / 1e9;
818
- nanoseconds = remainder;
819
- }
820
- return [seconds, nanoseconds];
821
- }
822
- __name(addTime, "addTime");
823
- async function* _asyncTime(config, iterable) {
824
- const itr = iterable[Symbol.asyncIterator]();
825
- let total = [0, 0];
826
- while (true) {
827
- const start = process.hrtime();
828
- const { value, done } = await itr.next();
829
- const delta = process.hrtime(start);
830
- total = addTime(total, delta);
831
- if (config.progress) {
832
- config.progress(delta, total);
833
- }
834
- if (done) {
835
- if (config.total) {
836
- config.total(total);
837
- }
838
- return value;
839
- }
840
- yield value;
841
- }
842
- }
843
- __name(_asyncTime, "_asyncTime");
844
- function* _syncTime(config, iterable) {
845
- const itr = iterable[Symbol.iterator]();
846
- let total = [0, 0];
847
- while (true) {
848
- const start = process.hrtime();
849
- const { value, done } = itr.next();
850
- const delta = process.hrtime(start);
851
- total = addTime(total, delta);
852
- if (config.progress) {
853
- config.progress(delta, total);
854
- }
855
- if (done) {
856
- if (config.total) {
857
- config.total(total);
858
- }
859
- return value;
860
- }
861
- yield value;
862
- }
863
- }
864
- __name(_syncTime, "_syncTime");
865
- function time(config = {}, iterable) {
866
- if (iterable === void 0) {
867
- return (curriedIterable) => time(config, curriedIterable);
868
- }
869
- if (iterable[Symbol.asyncIterator] !== void 0) {
870
- return _asyncTime(config, iterable);
871
- } else {
872
- return _syncTime(config, iterable);
873
- }
874
- }
875
- __name(time, "time");
876
- function _transform(concurrency, func, iterable) {
877
- const iterator = getIterator(iterable);
878
- const resultQueue = [];
879
- const readQueue = [];
880
- let ended = false;
881
- let reading = false;
882
- let inflightCount = 0;
883
- let lastError = null;
884
- function fulfillReadQueue() {
885
- while (readQueue.length > 0 && resultQueue.length > 0) {
886
- const { resolve } = readQueue.shift();
887
- const value = resultQueue.shift();
888
- resolve({ done: false, value });
889
- }
890
- while (readQueue.length > 0 && inflightCount === 0 && ended) {
891
- const { resolve, reject } = readQueue.shift();
892
- if (lastError) {
893
- reject(lastError);
894
- lastError = null;
895
- } else {
896
- resolve({ done: true, value: void 0 });
897
- }
898
- }
899
- }
900
- __name(fulfillReadQueue, "fulfillReadQueue");
901
- async function fillQueue() {
902
- if (ended) {
903
- fulfillReadQueue();
904
- return;
905
- }
906
- if (reading) {
907
- return;
908
- }
909
- if (inflightCount + resultQueue.length >= concurrency) {
910
- return;
911
- }
912
- reading = true;
913
- inflightCount++;
914
- try {
915
- const { done, value } = await iterator.next();
916
- if (done) {
917
- ended = true;
918
- inflightCount--;
919
- fulfillReadQueue();
920
- } else {
921
- mapAndQueue(value);
922
- }
923
- } catch (error) {
924
- ended = true;
925
- inflightCount--;
926
- lastError = error;
927
- fulfillReadQueue();
928
- }
929
- reading = false;
930
- fillQueue();
931
- }
932
- __name(fillQueue, "fillQueue");
933
- async function mapAndQueue(itrValue) {
934
- try {
935
- const value = await func(itrValue);
936
- resultQueue.push(value);
937
- } catch (error) {
938
- ended = true;
939
- lastError = error;
940
- }
941
- inflightCount--;
942
- fulfillReadQueue();
943
- fillQueue();
944
- }
945
- __name(mapAndQueue, "mapAndQueue");
946
- async function next() {
947
- if (resultQueue.length === 0) {
948
- const deferred = defer();
949
- readQueue.push(deferred);
950
- fillQueue();
951
- return deferred.promise;
952
- }
953
- const value = resultQueue.shift();
954
- fillQueue();
955
- return { done: false, value };
956
- }
957
- __name(next, "next");
958
- const asyncIterableIterator = {
959
- next,
960
- [Symbol.asyncIterator]: () => asyncIterableIterator
961
- };
962
- return asyncIterableIterator;
963
- }
964
- __name(_transform, "_transform");
965
- function transform2(concurrency, func, iterable) {
966
- if (func === void 0) {
967
- return (curriedFunc, curriedIterable) => curriedIterable ? transform2(concurrency, curriedFunc, curriedIterable) : transform2(concurrency, curriedFunc);
968
- }
969
- if (iterable === void 0) {
970
- return (curriedIterable) => transform2(concurrency, func, curriedIterable);
971
- }
972
- return _transform(concurrency, func, iterable);
973
- }
974
- __name(transform2, "transform");
975
- async function _writeToStream(stream, iterable) {
976
- let lastError = null;
977
- let errCb = null;
978
- let drainCb = null;
979
- const notifyError = /* @__PURE__ */ __name((err) => {
980
- lastError = err;
981
- if (errCb) {
982
- errCb(err);
983
- }
984
- }, "notifyError");
985
- const notifyDrain = /* @__PURE__ */ __name(() => {
986
- if (drainCb) {
987
- drainCb();
988
- }
989
- }, "notifyDrain");
990
- const cleanup = /* @__PURE__ */ __name(() => {
991
- stream.removeListener("error", notifyError);
992
- stream.removeListener("drain", notifyDrain);
993
- }, "cleanup");
994
- stream.once("error", notifyError);
995
- const waitForDrain = /* @__PURE__ */ __name(() => new Promise((resolve, reject) => {
996
- if (lastError) {
997
- return reject(lastError);
998
- }
999
- stream.once("drain", notifyDrain);
1000
- drainCb = resolve;
1001
- errCb = reject;
1002
- }), "waitForDrain");
1003
- for await (const value of iterable) {
1004
- if (stream.write(value) === false) {
1005
- await waitForDrain();
1006
- }
1007
- if (lastError) {
1008
- break;
1009
- }
1010
- }
1011
- cleanup();
1012
- if (lastError) {
1013
- throw lastError;
1014
- }
1015
- }
1016
- __name(_writeToStream, "_writeToStream");
1017
- function writeToStream(stream, iterable) {
1018
- if (iterable === void 0) {
1019
- return (curriedIterable) => _writeToStream(stream, curriedIterable);
1020
- }
1021
- return _writeToStream(stream, iterable);
1022
- }
1023
- __name(writeToStream, "writeToStream");
1024
- exports3.batch = batch;
1025
- exports3.batchWithTimeout = batchWithTimeout;
1026
- exports3.buffer = buffer;
1027
- exports3.collect = collect;
1028
- exports3.concat = concat;
1029
- exports3.consume = consume;
1030
- exports3.drop = drop;
1031
- exports3.filter = filter;
1032
- exports3.flatMap = flatMap;
1033
- exports3.flatTransform = flatTransform;
1034
- exports3.flatten = flatten;
1035
- exports3.fromStream = fromStream;
1036
- exports3.getIterator = getIterator;
1037
- exports3.map = map;
1038
- exports3.merge = merge;
1039
- exports3.parallelFlatMap = parallelFlatMap;
1040
- exports3.parallelMap = parallelMap2;
1041
- exports3.parallelMerge = parallelMerge;
1042
- exports3.pipeline = pipeline;
1043
- exports3.reduce = reduce;
1044
- exports3.take = take;
1045
- exports3.takeLast = takeLast;
1046
- exports3.takeWhile = takeWhile;
1047
- exports3.tap = tap;
1048
- exports3.throttle = throttle;
1049
- exports3.time = time;
1050
- exports3.transform = transform2;
1051
- exports3.writeToStream = writeToStream;
1052
- }));
1053
- }
8
+ //#region \0rolldown/runtime.js
9
+ var __defProp = Object.defineProperty;
10
+ var __name = (target, value) => __defProp(target, "name", {
11
+ value,
12
+ configurable: true
1054
13
  });
14
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
1055
15
 
1056
- // src/external/streaming-iterables.js
1057
- var { parallelMap, transform } = require_dist();
16
+ //#endregion
17
+
18
+ //#region node_modules/.pnpm/streaming-iterables@8.0.1/node_modules/streaming-iterables/dist/index.js
19
+ var require_dist = /* @__PURE__ */ __commonJSMin(((exports, module) => {
20
+ (function(global, factory) {
21
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.streamingIterables = {}));
22
+ })(exports, (function(exports$1) {
23
+ "use strict";
24
+ async function* _batch(size, iterable) {
25
+ let dataBatch = [];
26
+ for await (const data of iterable) {
27
+ dataBatch.push(data);
28
+ if (dataBatch.length === size) {
29
+ yield dataBatch;
30
+ dataBatch = [];
31
+ }
32
+ }
33
+ if (dataBatch.length > 0) yield dataBatch;
34
+ }
35
+ function* _syncBatch(size, iterable) {
36
+ let dataBatch = [];
37
+ for (const data of iterable) {
38
+ dataBatch.push(data);
39
+ if (dataBatch.length === size) {
40
+ yield dataBatch;
41
+ dataBatch = [];
42
+ }
43
+ }
44
+ if (dataBatch.length > 0) yield dataBatch;
45
+ }
46
+ function batch(size, iterable) {
47
+ if (iterable === void 0) return (curriedIterable) => batch(size, curriedIterable);
48
+ if (iterable[Symbol.asyncIterator]) return _batch(size, iterable);
49
+ return _syncBatch(size, iterable);
50
+ }
51
+ const TIMEOUT = Symbol("TIMEOUT");
52
+ const createTimer = (duration) => {
53
+ let timeoutId;
54
+ return [new Promise((resolve) => {
55
+ timeoutId = setTimeout(() => resolve(TIMEOUT), duration);
56
+ }), () => {
57
+ clearTimeout(timeoutId);
58
+ }];
59
+ };
60
+ async function* _batchWithTimeout(size, timeout, iterable) {
61
+ const iterator = iterable[Symbol.asyncIterator]();
62
+ let pendingData;
63
+ let batchData = [];
64
+ let timer;
65
+ let clearTimer;
66
+ const startTimer = () => {
67
+ deleteTimer();
68
+ [timer, clearTimer] = createTimer(timeout);
69
+ };
70
+ const deleteTimer = () => {
71
+ if (clearTimer) clearTimer();
72
+ timer = void 0;
73
+ };
74
+ pendingData = iterator.next();
75
+ while (true) {
76
+ const res = await (timer ? Promise.race([pendingData, timer]) : pendingData);
77
+ if (res === TIMEOUT || res.done) {
78
+ if (batchData.length) {
79
+ yield batchData;
80
+ batchData = [];
81
+ }
82
+ deleteTimer();
83
+ if (res !== TIMEOUT) break;
84
+ continue;
85
+ }
86
+ pendingData = iterator.next();
87
+ batchData.push(res.value);
88
+ if (batchData.length === 1) startTimer();
89
+ if (batchData.length === size) {
90
+ yield batchData;
91
+ batchData = [];
92
+ deleteTimer();
93
+ continue;
94
+ }
95
+ }
96
+ }
97
+ function batchWithTimeout(size, timeout, iterable) {
98
+ if (iterable === void 0) return (curriedIterable) => batchWithTimeout(size, timeout, curriedIterable);
99
+ if (iterable[Symbol.asyncIterator] && timeout !== Infinity) return _batchWithTimeout(size, timeout, iterable);
100
+ return batch(size, iterable);
101
+ }
102
+ function getIterator(iterable) {
103
+ if (typeof iterable.next === "function") return iterable;
104
+ if (typeof iterable[Symbol.iterator] === "function") return iterable[Symbol.iterator]();
105
+ if (typeof iterable[Symbol.asyncIterator] === "function") return iterable[Symbol.asyncIterator]();
106
+ throw new TypeError("\"values\" does not to conform to any of the iterator or iterable protocols");
107
+ }
108
+ function defer() {
109
+ let reject;
110
+ let resolve;
111
+ return {
112
+ promise: new Promise((resolveFunc, rejectFunc) => {
113
+ resolve = resolveFunc;
114
+ reject = rejectFunc;
115
+ }),
116
+ reject,
117
+ resolve
118
+ };
119
+ }
120
+ function _buffer(size, iterable) {
121
+ const iterator = getIterator(iterable);
122
+ const resultQueue = [];
123
+ const readQueue = [];
124
+ let reading = false;
125
+ let ended = false;
126
+ function fulfillReadQueue() {
127
+ while (readQueue.length > 0 && resultQueue.length > 0) {
128
+ const readDeferred = readQueue.shift();
129
+ const { error, value } = resultQueue.shift();
130
+ if (error) readDeferred.reject(error);
131
+ else readDeferred.resolve({
132
+ done: false,
133
+ value
134
+ });
135
+ }
136
+ while (readQueue.length > 0 && ended) {
137
+ const { resolve } = readQueue.shift();
138
+ resolve({
139
+ done: true,
140
+ value: void 0
141
+ });
142
+ }
143
+ }
144
+ async function fillQueue() {
145
+ if (ended) return;
146
+ if (reading) return;
147
+ if (resultQueue.length >= size) return;
148
+ reading = true;
149
+ try {
150
+ const { done, value } = await iterator.next();
151
+ if (done) ended = true;
152
+ else resultQueue.push({ value });
153
+ } catch (error) {
154
+ ended = true;
155
+ resultQueue.push({ error });
156
+ }
157
+ fulfillReadQueue();
158
+ reading = false;
159
+ fillQueue();
160
+ }
161
+ async function next() {
162
+ if (resultQueue.length > 0) {
163
+ const { error, value } = resultQueue.shift();
164
+ if (error) throw error;
165
+ fillQueue();
166
+ return {
167
+ done: false,
168
+ value
169
+ };
170
+ }
171
+ if (ended) return {
172
+ done: true,
173
+ value: void 0
174
+ };
175
+ const deferred = defer();
176
+ readQueue.push(deferred);
177
+ fillQueue();
178
+ return deferred.promise;
179
+ }
180
+ const asyncIterableIterator = {
181
+ next,
182
+ [Symbol.asyncIterator]: () => asyncIterableIterator
183
+ };
184
+ return asyncIterableIterator;
185
+ }
186
+ function* syncBuffer(size, iterable) {
187
+ const valueQueue = [];
188
+ let e;
189
+ try {
190
+ for (const value of iterable) {
191
+ valueQueue.push(value);
192
+ if (valueQueue.length <= size) continue;
193
+ yield valueQueue.shift();
194
+ }
195
+ } catch (error) {
196
+ e = error;
197
+ }
198
+ for (const value of valueQueue) yield value;
199
+ if (e) throw e;
200
+ }
201
+ function buffer(size, iterable) {
202
+ if (iterable === void 0) return (curriedIterable) => buffer(size, curriedIterable);
203
+ if (size === 0) return iterable;
204
+ if (iterable[Symbol.asyncIterator]) return _buffer(size, iterable);
205
+ return syncBuffer(size, iterable);
206
+ }
207
+ async function _collect(iterable) {
208
+ const values = [];
209
+ for await (const value of iterable) values.push(value);
210
+ return values;
211
+ }
212
+ function collect(iterable) {
213
+ if (iterable[Symbol.asyncIterator]) return _collect(iterable);
214
+ return Array.from(iterable);
215
+ }
216
+ async function* _concat(iterables) {
217
+ for await (const iterable of iterables) yield* iterable;
218
+ }
219
+ function* _syncConcat(iterables) {
220
+ for (const iterable of iterables) yield* iterable;
221
+ }
222
+ function concat(...iterables) {
223
+ if (iterables.find((itr) => itr[Symbol.asyncIterator] !== void 0)) return _concat(iterables);
224
+ else return _syncConcat(iterables);
225
+ }
226
+ async function _consume(iterable) {
227
+ for await (const _val of iterable);
228
+ }
229
+ function consume(iterable) {
230
+ if (iterable[Symbol.asyncIterator]) return _consume(iterable);
231
+ for (const _val of iterable);
232
+ }
233
+ async function* _drop(count, iterable) {
234
+ let skipped = 0;
235
+ for await (const val of iterable) {
236
+ if (skipped < count) {
237
+ skipped++;
238
+ continue;
239
+ }
240
+ yield await val;
241
+ }
242
+ }
243
+ function* _syncDrop(count, iterable) {
244
+ let skipped = 0;
245
+ for (const val of iterable) {
246
+ if (skipped < count) {
247
+ skipped++;
248
+ continue;
249
+ }
250
+ yield val;
251
+ }
252
+ }
253
+ function drop(count, iterable) {
254
+ if (iterable === void 0) return (curriedIterable) => drop(count, curriedIterable);
255
+ if (iterable[Symbol.asyncIterator]) return _drop(count, iterable);
256
+ return _syncDrop(count, iterable);
257
+ }
258
+ async function* _filter(filterFunc, iterable) {
259
+ for await (const data of iterable) if (await filterFunc(data)) yield data;
260
+ }
261
+ function filter(filterFunc, iterable) {
262
+ if (iterable === void 0) return (curriedIterable) => _filter(filterFunc, curriedIterable);
263
+ return _filter(filterFunc, iterable);
264
+ }
265
+ /**
266
+ * Returns a new iterator by pulling every item out of `iterable` (and all its sub iterables) and yielding them depth-first. Checks for the iterable interfaces and iterates it if it exists. If the value is a string it is not iterated as that ends up in an infinite loop. Errors from the source `iterable` are raised immediately.
267
+
268
+ *note*: Typescript doesn't have recursive types but you can nest iterables as deep as you like.
269
+
270
+ ```ts
271
+ import { flatten } from 'streaming-iterables'
272
+
273
+ for await (const item of flatten([1, 2, [3, [4, 5], 6])) {
274
+ console.log(item)
275
+ }
276
+ // 1
277
+ // 2
278
+ // 3
279
+ // 4
280
+ // 5
281
+ // 6
282
+ ```
283
+ */
284
+ async function* flatten(iterable) {
285
+ for await (const maybeItr of iterable) if (maybeItr && typeof maybeItr !== "string" && (maybeItr[Symbol.iterator] || maybeItr[Symbol.asyncIterator])) yield* flatten(maybeItr);
286
+ else yield maybeItr;
287
+ }
288
+ async function* _map(func, iterable) {
289
+ for await (const val of iterable) yield await func(val);
290
+ }
291
+ function map(func, iterable) {
292
+ if (iterable === void 0) return (curriedIterable) => _map(func, curriedIterable);
293
+ return _map(func, iterable);
294
+ }
295
+ function flatMap(func, iterable) {
296
+ if (iterable === void 0) return (curriedIterable) => flatMap(func, curriedIterable);
297
+ return filter((i) => i !== void 0 && i !== null, flatten(map(func, iterable)));
298
+ }
299
+ function _flatTransform(concurrency, func, iterable) {
300
+ const iterator = getIterator(iterable);
301
+ const resultQueue = [];
302
+ const readQueue = [];
303
+ let ended = false;
304
+ let reading = false;
305
+ let inflightCount = 0;
306
+ let lastError = null;
307
+ function fulfillReadQueue() {
308
+ while (readQueue.length > 0 && resultQueue.length > 0) {
309
+ const { resolve } = readQueue.shift();
310
+ resolve({
311
+ done: false,
312
+ value: resultQueue.shift()
313
+ });
314
+ }
315
+ while (readQueue.length > 0 && inflightCount === 0 && ended) {
316
+ const { resolve, reject } = readQueue.shift();
317
+ if (lastError) {
318
+ reject(lastError);
319
+ lastError = null;
320
+ } else resolve({
321
+ done: true,
322
+ value: void 0
323
+ });
324
+ }
325
+ }
326
+ async function fillQueue() {
327
+ if (ended) {
328
+ fulfillReadQueue();
329
+ return;
330
+ }
331
+ if (reading) return;
332
+ if (inflightCount + resultQueue.length >= concurrency) return;
333
+ reading = true;
334
+ inflightCount++;
335
+ try {
336
+ const { done, value } = await iterator.next();
337
+ if (done) {
338
+ ended = true;
339
+ inflightCount--;
340
+ fulfillReadQueue();
341
+ } else mapAndQueue(value);
342
+ } catch (error) {
343
+ ended = true;
344
+ inflightCount--;
345
+ lastError = error;
346
+ fulfillReadQueue();
347
+ }
348
+ reading = false;
349
+ fillQueue();
350
+ }
351
+ async function mapAndQueue(itrValue) {
352
+ try {
353
+ const value = await func(itrValue);
354
+ if (value && value[Symbol.asyncIterator]) for await (const asyncVal of value) resultQueue.push(asyncVal);
355
+ else resultQueue.push(value);
356
+ } catch (error) {
357
+ ended = true;
358
+ lastError = error;
359
+ }
360
+ inflightCount--;
361
+ fulfillReadQueue();
362
+ fillQueue();
363
+ }
364
+ async function next() {
365
+ if (resultQueue.length === 0) {
366
+ const deferred = defer();
367
+ readQueue.push(deferred);
368
+ fillQueue();
369
+ return deferred.promise;
370
+ }
371
+ const value = resultQueue.shift();
372
+ fillQueue();
373
+ return {
374
+ done: false,
375
+ value
376
+ };
377
+ }
378
+ const asyncIterableIterator = {
379
+ next,
380
+ [Symbol.asyncIterator]: () => asyncIterableIterator
381
+ };
382
+ return asyncIterableIterator;
383
+ }
384
+ function flatTransform(concurrency, func, iterable) {
385
+ if (func === void 0) return (curriedFunc, curriedIterable) => curriedIterable ? flatTransform(concurrency, curriedFunc, curriedIterable) : flatTransform(concurrency, curriedFunc);
386
+ if (iterable === void 0) return (curriedIterable) => flatTransform(concurrency, func, curriedIterable);
387
+ return filter((i) => i !== void 0 && i !== null, flatten(_flatTransform(concurrency, func, iterable)));
388
+ }
389
+ async function onceReadable(stream) {
390
+ return new Promise((resolve) => {
391
+ stream.once("readable", () => {
392
+ resolve();
393
+ });
394
+ });
395
+ }
396
+ async function* _fromStream(stream) {
397
+ while (true) {
398
+ const data = stream.read();
399
+ if (data !== null) {
400
+ yield data;
401
+ continue;
402
+ }
403
+ if (stream._readableState.ended) break;
404
+ await onceReadable(stream);
405
+ }
406
+ }
407
+ /**
408
+ * Wraps the stream in an async iterator or returns the stream if it already is an async iterator.
409
+
410
+ *note*: Since Node 10, streams already async iterators. This function may be used to ensure compatibility with older versions of Node.
411
+
412
+ ```ts
413
+ import { fromStream } from 'streaming-iterables'
414
+ import { createReadStream } from 'fs'
415
+
416
+ const pokeLog = fromStream(createReadStream('./pokedex-operating-system.log'))
417
+
418
+ for await (const pokeData of pokeLog) {
419
+ console.log(pokeData) // Buffer(...)
420
+ }
421
+ ```
422
+ * @deprecated This method is deprecated since, node 10 is out of LTS. It may be removed in an upcoming major release.
423
+ */
424
+ function fromStream(stream) {
425
+ if (typeof stream[Symbol.asyncIterator] === "function") return stream;
426
+ return _fromStream(stream);
427
+ }
428
+ /**
429
+ * Combine multiple iterators into a single iterable. Reads one item off each iterable in order repeatedly until they are all exhausted. If you care less about order and want them faster see `parallelMerge()`.
430
+ */
431
+ async function* merge(...iterables) {
432
+ const sources = new Set(iterables.map(getIterator));
433
+ while (sources.size > 0) for (const iterator of sources) {
434
+ const nextVal = await iterator.next();
435
+ if (nextVal.done) sources.delete(iterator);
436
+ else yield nextVal.value;
437
+ }
438
+ }
439
+ function pipeline(firstFn, ...fns) {
440
+ let previousFn = firstFn();
441
+ for (const func of fns) previousFn = func(previousFn);
442
+ return previousFn;
443
+ }
444
+ async function* _parallelMap(concurrency, func, iterable) {
445
+ let transformError = null;
446
+ const wrapFunc = (value) => ({ value: func(value) });
447
+ const stopOnError = async function* (source) {
448
+ for await (const value of source) {
449
+ if (transformError) return;
450
+ yield value;
451
+ }
452
+ };
453
+ const itr = getIterator(pipeline(() => iterable, buffer(1), stopOnError, map(wrapFunc), buffer(concurrency - 1)));
454
+ while (true) {
455
+ const { value, done } = await itr.next();
456
+ if (done) break;
457
+ try {
458
+ const val = await value.value;
459
+ if (!transformError) yield val;
460
+ } catch (error) {
461
+ transformError = error;
462
+ }
463
+ }
464
+ if (transformError) throw transformError;
465
+ }
466
+ function parallelMap(concurrency, func, iterable) {
467
+ if (func === void 0) return (curriedFunc, curriedIterable) => parallelMap(concurrency, curriedFunc, curriedIterable);
468
+ if (iterable === void 0) return (curriedIterable) => parallelMap(concurrency, func, curriedIterable);
469
+ if (concurrency === 1) return map(func, iterable);
470
+ return _parallelMap(concurrency, func, iterable);
471
+ }
472
+ function parallelFlatMap(concurrency, func, iterable) {
473
+ if (func === void 0) return (curriedFunc, curriedIterable) => curriedIterable ? parallelFlatMap(concurrency, curriedFunc, curriedIterable) : parallelFlatMap(concurrency, curriedFunc);
474
+ if (iterable === void 0) return (curriedIterable) => parallelFlatMap(concurrency, func, curriedIterable);
475
+ return filter((i) => i !== void 0 && i !== null, flatten(parallelMap(concurrency, func, iterable)));
476
+ }
477
+ /**
478
+ *Combine multiple iterators into a single iterable. Reads one item off of every iterable and yields them as they resolve. This is useful for pulling items out of a collection of iterables as soon as they're available. Errors `iterables` are raised immediately.
479
+
480
+ ```ts
481
+ import { parallelMerge } from 'streaming-iterables'
482
+ import { getPokemon, getTransformer } from 'iterable-pokedex'
483
+
484
+ // pokemon are much faster to load btw
485
+ const heros = parallelMerge(getPokemon(), getTransformer())
486
+ for await (const hero of heros) {
487
+ console.log(hero)
488
+ }
489
+ // charmander
490
+ // bulbasaur
491
+ // megatron
492
+ // pikachu
493
+ // eevee
494
+ // bumblebee
495
+ // jazz
496
+ ```
497
+ */
498
+ async function* parallelMerge(...iterables) {
499
+ const inputs = iterables.map(getIterator);
500
+ const concurrentWork = /* @__PURE__ */ new Set();
501
+ const values = /* @__PURE__ */ new Map();
502
+ let lastError = null;
503
+ let errCb = null;
504
+ let valueCb = null;
505
+ const notifyError = (err) => {
506
+ lastError = err;
507
+ if (errCb) errCb(err);
508
+ };
509
+ const notifyDone = (value) => {
510
+ if (valueCb) valueCb(value);
511
+ };
512
+ const waitForQueue = () => new Promise((resolve, reject) => {
513
+ if (lastError) reject(lastError);
514
+ if (values.size > 0) return resolve();
515
+ valueCb = resolve;
516
+ errCb = reject;
517
+ });
518
+ const queueNext = (input) => {
519
+ const nextVal = Promise.resolve(input.next()).then(async ({ done, value }) => {
520
+ if (!done) values.set(input, value);
521
+ concurrentWork.delete(nextVal);
522
+ });
523
+ concurrentWork.add(nextVal);
524
+ nextVal.then(notifyDone, notifyError);
525
+ };
526
+ for (const input of inputs) queueNext(input);
527
+ while (true) {
528
+ if (concurrentWork.size === 0 && values.size === 0) return;
529
+ await waitForQueue();
530
+ for (const [input, value] of values) {
531
+ values.delete(input);
532
+ yield value;
533
+ queueNext(input);
534
+ }
535
+ }
536
+ }
537
+ async function _reduce(func, start, iterable) {
538
+ let value = start;
539
+ for await (const nextItem of iterable) value = await func(value, nextItem);
540
+ return value;
541
+ }
542
+ function reduce(func, start, iterable) {
543
+ if (start === void 0) return (curriedStart, curriedIterable) => curriedIterable ? _reduce(func, curriedStart, curriedIterable) : reduce(func, curriedStart);
544
+ if (iterable === void 0) return (curriedIterable) => reduce(func, start, curriedIterable);
545
+ return _reduce(func, start, iterable);
546
+ }
547
+ async function* _take(count, iterable) {
548
+ let taken = 0;
549
+ for await (const val of iterable) {
550
+ yield await val;
551
+ taken++;
552
+ if (taken >= count) break;
553
+ }
554
+ }
555
+ function* _syncTake(count, iterable) {
556
+ let taken = 0;
557
+ for (const val of iterable) {
558
+ yield val;
559
+ taken++;
560
+ if (taken >= count) break;
561
+ }
562
+ }
563
+ function take(count, iterable) {
564
+ if (iterable === void 0) return (curriedIterable) => take(count, curriedIterable);
565
+ if (iterable[Symbol.asyncIterator]) return _take(count, iterable);
566
+ return _syncTake(count, iterable);
567
+ }
568
+ async function* _takeLast(count, iterable) {
569
+ const buffer = [];
570
+ for await (const res of iterable) {
571
+ buffer.push(res);
572
+ if (buffer.length > count) buffer.shift();
573
+ }
574
+ while (buffer.length) yield await buffer.shift();
575
+ }
576
+ function* _syncTakeLast(count, iterable) {
577
+ const buffer = [];
578
+ for (const res of iterable) {
579
+ buffer.push(res);
580
+ if (buffer.length > count) buffer.shift();
581
+ }
582
+ while (buffer.length) yield buffer.shift();
583
+ }
584
+ function takeLast(count, iterable) {
585
+ if (iterable === void 0) return (curriedIterable) => takeLast(count, curriedIterable);
586
+ if (iterable[Symbol.asyncIterator]) return _takeLast(count, iterable);
587
+ return _syncTakeLast(count, iterable);
588
+ }
589
+ async function* _takeWhile(predicate, iterable) {
590
+ for await (const data of iterable) {
591
+ if (!await predicate(data)) return;
592
+ yield data;
593
+ }
594
+ }
595
+ function takeWhile(predicate, iterable) {
596
+ if (iterable === void 0) return (curriedIterable) => _takeWhile(predicate, curriedIterable);
597
+ return _takeWhile(predicate, iterable);
598
+ }
599
+ async function* _asyncTap(func, iterable) {
600
+ for await (const val of iterable) {
601
+ await func(val);
602
+ yield val;
603
+ }
604
+ }
605
+ function tap(func, iterable) {
606
+ if (iterable === void 0) return (curriedIterable) => _asyncTap(func, curriedIterable);
607
+ return _asyncTap(func, iterable);
608
+ }
609
+ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
610
+ function _throttle(limit, interval, iterable) {
611
+ if (!Number.isFinite(limit)) throw new TypeError("Expected `limit` to be a finite number");
612
+ if (limit <= 0) throw new TypeError("Expected `limit` to be greater than 0");
613
+ if (!Number.isFinite(interval)) throw new TypeError("Expected `interval` to be a finite number");
614
+ return (async function* __throttle() {
615
+ let sent = 0;
616
+ let time;
617
+ for await (const val of iterable) {
618
+ if (sent < limit) {
619
+ if (typeof time === "undefined") time = Date.now();
620
+ sent++;
621
+ yield val;
622
+ continue;
623
+ }
624
+ const waitFor = interval - (Date.now() - (time || 0));
625
+ if (waitFor > 0) await sleep(waitFor);
626
+ time = Date.now();
627
+ sent = 1;
628
+ yield val;
629
+ }
630
+ })();
631
+ }
632
+ function throttle(limit, interval, iterable) {
633
+ if (iterable === void 0) return (curriedIterable) => _throttle(limit, interval, curriedIterable);
634
+ return _throttle(limit, interval, iterable);
635
+ }
636
+ function addTime(a, b) {
637
+ let seconds = a[0] + b[0];
638
+ let nanoseconds = a[1] + b[1];
639
+ if (nanoseconds >= 1e9) {
640
+ const remainder = nanoseconds % 1e9;
641
+ seconds += (nanoseconds - remainder) / 1e9;
642
+ nanoseconds = remainder;
643
+ }
644
+ return [seconds, nanoseconds];
645
+ }
646
+ async function* _asyncTime(config, iterable) {
647
+ const itr = iterable[Symbol.asyncIterator]();
648
+ let total = [0, 0];
649
+ while (true) {
650
+ const start = process.hrtime();
651
+ const { value, done } = await itr.next();
652
+ const delta = process.hrtime(start);
653
+ total = addTime(total, delta);
654
+ if (config.progress) config.progress(delta, total);
655
+ if (done) {
656
+ if (config.total) config.total(total);
657
+ return value;
658
+ }
659
+ yield value;
660
+ }
661
+ }
662
+ function* _syncTime(config, iterable) {
663
+ const itr = iterable[Symbol.iterator]();
664
+ let total = [0, 0];
665
+ while (true) {
666
+ const start = process.hrtime();
667
+ const { value, done } = itr.next();
668
+ const delta = process.hrtime(start);
669
+ total = addTime(total, delta);
670
+ if (config.progress) config.progress(delta, total);
671
+ if (done) {
672
+ if (config.total) config.total(total);
673
+ return value;
674
+ }
675
+ yield value;
676
+ }
677
+ }
678
+ function time(config = {}, iterable) {
679
+ if (iterable === void 0) return (curriedIterable) => time(config, curriedIterable);
680
+ if (iterable[Symbol.asyncIterator] !== void 0) return _asyncTime(config, iterable);
681
+ else return _syncTime(config, iterable);
682
+ }
683
+ function _transform(concurrency, func, iterable) {
684
+ const iterator = getIterator(iterable);
685
+ const resultQueue = [];
686
+ const readQueue = [];
687
+ let ended = false;
688
+ let reading = false;
689
+ let inflightCount = 0;
690
+ let lastError = null;
691
+ function fulfillReadQueue() {
692
+ while (readQueue.length > 0 && resultQueue.length > 0) {
693
+ const { resolve } = readQueue.shift();
694
+ resolve({
695
+ done: false,
696
+ value: resultQueue.shift()
697
+ });
698
+ }
699
+ while (readQueue.length > 0 && inflightCount === 0 && ended) {
700
+ const { resolve, reject } = readQueue.shift();
701
+ if (lastError) {
702
+ reject(lastError);
703
+ lastError = null;
704
+ } else resolve({
705
+ done: true,
706
+ value: void 0
707
+ });
708
+ }
709
+ }
710
+ async function fillQueue() {
711
+ if (ended) {
712
+ fulfillReadQueue();
713
+ return;
714
+ }
715
+ if (reading) return;
716
+ if (inflightCount + resultQueue.length >= concurrency) return;
717
+ reading = true;
718
+ inflightCount++;
719
+ try {
720
+ const { done, value } = await iterator.next();
721
+ if (done) {
722
+ ended = true;
723
+ inflightCount--;
724
+ fulfillReadQueue();
725
+ } else mapAndQueue(value);
726
+ } catch (error) {
727
+ ended = true;
728
+ inflightCount--;
729
+ lastError = error;
730
+ fulfillReadQueue();
731
+ }
732
+ reading = false;
733
+ fillQueue();
734
+ }
735
+ async function mapAndQueue(itrValue) {
736
+ try {
737
+ const value = await func(itrValue);
738
+ resultQueue.push(value);
739
+ } catch (error) {
740
+ ended = true;
741
+ lastError = error;
742
+ }
743
+ inflightCount--;
744
+ fulfillReadQueue();
745
+ fillQueue();
746
+ }
747
+ async function next() {
748
+ if (resultQueue.length === 0) {
749
+ const deferred = defer();
750
+ readQueue.push(deferred);
751
+ fillQueue();
752
+ return deferred.promise;
753
+ }
754
+ const value = resultQueue.shift();
755
+ fillQueue();
756
+ return {
757
+ done: false,
758
+ value
759
+ };
760
+ }
761
+ const asyncIterableIterator = {
762
+ next,
763
+ [Symbol.asyncIterator]: () => asyncIterableIterator
764
+ };
765
+ return asyncIterableIterator;
766
+ }
767
+ function transform(concurrency, func, iterable) {
768
+ if (func === void 0) return (curriedFunc, curriedIterable) => curriedIterable ? transform(concurrency, curriedFunc, curriedIterable) : transform(concurrency, curriedFunc);
769
+ if (iterable === void 0) return (curriedIterable) => transform(concurrency, func, curriedIterable);
770
+ return _transform(concurrency, func, iterable);
771
+ }
772
+ async function _writeToStream(stream, iterable) {
773
+ let lastError = null;
774
+ let errCb = null;
775
+ let drainCb = null;
776
+ const notifyError = (err) => {
777
+ lastError = err;
778
+ if (errCb) errCb(err);
779
+ };
780
+ const notifyDrain = () => {
781
+ if (drainCb) drainCb();
782
+ };
783
+ const cleanup = () => {
784
+ stream.removeListener("error", notifyError);
785
+ stream.removeListener("drain", notifyDrain);
786
+ };
787
+ stream.once("error", notifyError);
788
+ const waitForDrain = () => new Promise((resolve, reject) => {
789
+ if (lastError) return reject(lastError);
790
+ stream.once("drain", notifyDrain);
791
+ drainCb = resolve;
792
+ errCb = reject;
793
+ });
794
+ for await (const value of iterable) {
795
+ if (stream.write(value) === false) await waitForDrain();
796
+ if (lastError) break;
797
+ }
798
+ cleanup();
799
+ if (lastError) throw lastError;
800
+ }
801
+ function writeToStream(stream, iterable) {
802
+ if (iterable === void 0) return (curriedIterable) => _writeToStream(stream, curriedIterable);
803
+ return _writeToStream(stream, iterable);
804
+ }
805
+ exports$1.batch = batch;
806
+ exports$1.batchWithTimeout = batchWithTimeout;
807
+ exports$1.buffer = buffer;
808
+ exports$1.collect = collect;
809
+ exports$1.concat = concat;
810
+ exports$1.consume = consume;
811
+ exports$1.drop = drop;
812
+ exports$1.filter = filter;
813
+ exports$1.flatMap = flatMap;
814
+ exports$1.flatTransform = flatTransform;
815
+ exports$1.flatten = flatten;
816
+ exports$1.fromStream = fromStream;
817
+ exports$1.getIterator = getIterator;
818
+ exports$1.map = map;
819
+ exports$1.merge = merge;
820
+ exports$1.parallelFlatMap = parallelFlatMap;
821
+ exports$1.parallelMap = parallelMap;
822
+ exports$1.parallelMerge = parallelMerge;
823
+ exports$1.pipeline = pipeline;
824
+ exports$1.reduce = reduce;
825
+ exports$1.take = take;
826
+ exports$1.takeLast = takeLast;
827
+ exports$1.takeWhile = takeWhile;
828
+ exports$1.tap = tap;
829
+ exports$1.throttle = throttle;
830
+ exports$1.time = time;
831
+ exports$1.transform = transform;
832
+ exports$1.writeToStream = writeToStream;
833
+ }));
834
+ }));
835
+
836
+ //#endregion
837
+ //#region src/external/streaming-iterables.js
838
+ const { parallelMap, transform } = require_dist();
1058
839
  module.exports = {
1059
- parallelMap,
1060
- transform
840
+ parallelMap,
841
+ transform
1061
842
  };
843
+
844
+ //#endregion