@socketsecurity/lib 6.0.9 → 6.0.10

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 (335) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +8 -9
  3. package/dist/abort/signal.d.ts +1 -1
  4. package/dist/abort/signal.js +1 -1
  5. package/dist/ai/agent-context.d.mts +1 -1
  6. package/dist/ai/agent-context.js +3 -2
  7. package/dist/ai/backends.d.mts +3 -3
  8. package/dist/ai/backends.js +2 -2
  9. package/dist/ai/billing-context.d.mts +74 -0
  10. package/dist/ai/billing-context.js +129 -0
  11. package/dist/ai/credentials.d.mts +39 -5
  12. package/dist/ai/credentials.js +61 -6
  13. package/dist/ai/discover.d.mts +4 -0
  14. package/dist/ai/discover.js +4 -0
  15. package/dist/ai/exec.d.mts +1 -1
  16. package/dist/ai/exec.js +1 -1
  17. package/dist/ai/http.d.mts +8 -8
  18. package/dist/ai/http.js +6 -6
  19. package/dist/ai/profiles.d.mts +9 -10
  20. package/dist/ai/profiles.js +0 -5
  21. package/dist/ai/role.d.mts +58 -0
  22. package/dist/ai/role.js +96 -0
  23. package/dist/ai/route-heuristic.d.mts +177 -0
  24. package/dist/ai/route-heuristic.js +194 -0
  25. package/dist/ai/route.d.mts +10 -9
  26. package/dist/ai/route.js +14 -13
  27. package/dist/ai/spawn.d.mts +2 -1
  28. package/dist/ai/spawn.js +25 -2
  29. package/dist/ai/subagent-status.d.mts +2 -0
  30. package/dist/ai/subagent-status.js +2 -0
  31. package/dist/ai/tier.d.mts +1 -1
  32. package/dist/ai/types.d.mts +9 -2
  33. package/dist/ai/worktree.d.mts +1 -1
  34. package/dist/ai/worktree.js +3 -2
  35. package/dist/argv/parse.d.ts +2 -0
  36. package/dist/argv/parse.js +2 -0
  37. package/dist/bin/_internal.d.ts +1 -1
  38. package/dist/bin/_internal.js +1 -1
  39. package/dist/bin/prim.cjs +446 -300
  40. package/dist/bin/shadow.js +2 -1
  41. package/dist/bin/which.d.ts +28 -3
  42. package/dist/bin/which.js +45 -3
  43. package/dist/cacache/_internal.d.ts +10 -2
  44. package/dist/cacache/_internal.js +6 -10
  45. package/dist/cache/ttl/_internal.d.ts +33 -0
  46. package/dist/cache/ttl/_internal.js +68 -0
  47. package/dist/cache/ttl/browser.d.ts +56 -0
  48. package/dist/cache/ttl/browser.js +257 -0
  49. package/dist/cache/ttl/store.js +10 -33
  50. package/dist/cache/ttl/types.d.ts +46 -3
  51. package/dist/checks/primordials-defaults.d.ts +5 -5
  52. package/dist/checks/primordials-defaults.js +5 -5
  53. package/dist/checks/primordials.d.ts +1 -1
  54. package/dist/checks/primordials.js +25 -17
  55. package/dist/cli/check-primordials.d.ts +6 -1
  56. package/dist/cli/check-primordials.js +14 -5
  57. package/dist/cli/check.js +1 -1
  58. package/dist/cli/socket-lib.d.ts +1 -1
  59. package/dist/cli/socket-lib.js +3 -3
  60. package/dist/colors/socket-palette.d.ts +1 -1
  61. package/dist/compression/brotli.d.ts +6 -2
  62. package/dist/compression/brotli.js +4 -0
  63. package/dist/compression/gzip.d.ts +6 -2
  64. package/dist/compression/gzip.js +6 -1
  65. package/dist/config/layers.d.ts +4 -4
  66. package/dist/config/layers.js +4 -4
  67. package/dist/constants/agents.d.ts +3 -0
  68. package/dist/constants/agents.js +3 -0
  69. package/dist/constants/node.d.ts +14 -0
  70. package/dist/constants/node.js +14 -0
  71. package/dist/constants/package-default-node-range.js +1 -5
  72. package/dist/constants/packages.d.ts +5 -0
  73. package/dist/constants/packages.js +5 -0
  74. package/dist/constants/platform.d.ts +1 -1
  75. package/dist/constants/platform.js +1 -1
  76. package/dist/constants/socket.js +1 -1
  77. package/dist/constants/typescript.d.ts +5 -0
  78. package/dist/constants/typescript.js +5 -0
  79. package/dist/debug/_internal.d.ts +22 -7
  80. package/dist/debug/_internal.js +33 -15
  81. package/dist/debug/namespace.js +11 -8
  82. package/dist/debug/output.d.ts +12 -1
  83. package/dist/debug/output.js +33 -16
  84. package/dist/dlx/binary-resolution.js +7 -4
  85. package/dist/eco/npm/npm/parse-lockfile.js +2 -1
  86. package/dist/eco/npm/vlt/exec.d.ts +1 -1
  87. package/dist/eco/npm/vlt/exec.js +1 -1
  88. package/dist/env/agents.d.ts +6 -0
  89. package/dist/env/agents.js +29 -0
  90. package/dist/env/flags.d.ts +12 -0
  91. package/dist/env/flags.js +23 -0
  92. package/dist/env/github-status.js +2 -2
  93. package/dist/env/providers.d.ts +6 -0
  94. package/dist/env/providers.js +23 -0
  95. package/dist/env/proxy.js +1 -1
  96. package/dist/env/rewire.d.ts +32 -0
  97. package/dist/env/rewire.js +55 -23
  98. package/dist/env/runtimes.d.ts +9 -0
  99. package/dist/env/runtimes.js +53 -0
  100. package/dist/env/socket-cli.d.ts +5 -2
  101. package/dist/env/socket-cli.js +6 -3
  102. package/dist/errors/predicates.d.ts +3 -2
  103. package/dist/errors/predicates.js +5 -3
  104. package/dist/errors/stack.js +2 -1
  105. package/dist/events/exit/_internal.d.ts +1 -23
  106. package/dist/external/@npmcli/package-json.js +179 -88
  107. package/dist/external/@npmcli/promise-spawn.js +2 -2
  108. package/dist/external/@sinclair/typebox/value.js +5 -4
  109. package/dist/external/@socketregistry/yocto-spinner.js +3 -3
  110. package/dist/external/adm-zip.d.ts +82 -0
  111. package/dist/external/adm-zip.js +2 -2
  112. package/dist/external/cacache.d.ts +87 -0
  113. package/dist/external/debug.d.ts +22 -0
  114. package/dist/external/debug.js +11 -4
  115. package/dist/external/del.d.ts +1 -0
  116. package/dist/external/external-pack.d.ts +12 -0
  117. package/dist/external/external-pack.js +41 -34
  118. package/dist/external/fast-glob.d.ts +8 -0
  119. package/dist/external/fast-sort.d.ts +1 -0
  120. package/dist/external/get-east-asian-width.d.ts +5 -0
  121. package/dist/external/get-east-asian-width.js +8 -1
  122. package/dist/external/has-flag.d.ts +1 -0
  123. package/dist/external/inquirer-pack.d.ts +18 -0
  124. package/dist/external/libnpmexec.d.ts +35 -0
  125. package/dist/external/libnpmpack.d.ts +1 -0
  126. package/dist/external/make-fetch-happen.d.ts +13 -0
  127. package/dist/external/normalize-package-data.d.ts +4 -0
  128. package/dist/external/npm-core.d.ts +14 -0
  129. package/dist/external/npm-pack.d.ts +24 -0
  130. package/dist/external/npm-pack.js +1551 -1867
  131. package/dist/external/npm-package-arg.d.ts +4 -0
  132. package/dist/external/p-map.js +8 -1
  133. package/dist/external/pacote.d.ts +15 -0
  134. package/dist/external/pico-pack.d.ts +16 -0
  135. package/dist/external/pico-pack.js +38 -23
  136. package/dist/external/picomatch.d.ts +96 -0
  137. package/dist/external/pony-cause.d.ts +14 -0
  138. package/dist/external/semver.d.ts +60 -0
  139. package/dist/external/semver.js +1459 -4
  140. package/dist/external/shell-quote.d.ts +51 -0
  141. package/dist/external/shell-quote.js +55 -15
  142. package/dist/external/signal-exit.d.ts +1 -0
  143. package/dist/external/spdx-correct.d.ts +4 -0
  144. package/dist/external/spdx-expression-parse.d.ts +4 -0
  145. package/dist/external/spdx-pack.d.ts +10 -0
  146. package/dist/external/std-env.d.ts +284 -0
  147. package/dist/external/std-env.js +323 -0
  148. package/dist/external/streaming-iterables.d.ts +11 -0
  149. package/dist/external/supports-color.d.ts +1 -0
  150. package/dist/external/tar-fs.d.ts +31 -0
  151. package/dist/external/validate-npm-package-name.d.ts +4 -0
  152. package/dist/external/which.d.ts +25 -0
  153. package/dist/external/which.js +2 -2
  154. package/dist/external/yargs-parser.d.ts +2 -0
  155. package/dist/external/yargs-parser.js +11 -3
  156. package/dist/external/yoctocolors-cjs.d.ts +51 -0
  157. package/dist/external-tools/bazel/asset-names.d.ts +1 -1
  158. package/dist/external-tools/bazel/from-download.d.ts +1 -1
  159. package/dist/external-tools/bazel/resolve.d.ts +3 -0
  160. package/dist/external-tools/bazel/resolve.js +3 -0
  161. package/dist/external-tools/cdxgen/asset-names.d.ts +5 -5
  162. package/dist/external-tools/cdxgen/asset-names.js +3 -3
  163. package/dist/external-tools/cdxgen/from-download.d.ts +2 -2
  164. package/dist/external-tools/cdxgen/from-download.js +1 -1
  165. package/dist/external-tools/cdxgen/resolve.d.ts +4 -1
  166. package/dist/external-tools/cdxgen/resolve.js +4 -1
  167. package/dist/external-tools/cdxgen/types.d.ts +1 -1
  168. package/dist/external-tools/from-download.d.ts +2 -2
  169. package/dist/external-tools/from-download.js +1 -1
  170. package/dist/external-tools/janus/asset-names.d.ts +4 -1
  171. package/dist/external-tools/janus/asset-names.js +3 -0
  172. package/dist/external-tools/janus/from-download.d.ts +3 -3
  173. package/dist/external-tools/janus/from-download.js +2 -2
  174. package/dist/external-tools/janus/resolve.d.ts +3 -0
  175. package/dist/external-tools/janus/resolve.js +3 -0
  176. package/dist/external-tools/jre/asset-names.d.ts +3 -1
  177. package/dist/external-tools/jre/asset-names.js +2 -0
  178. package/dist/external-tools/jre/from-download.d.ts +1 -1
  179. package/dist/external-tools/manifest.d.ts +5 -3
  180. package/dist/external-tools/manifest.js +4 -2
  181. package/dist/external-tools/opengrep/asset-names.d.ts +1 -1
  182. package/dist/external-tools/opengrep/resolve.d.ts +3 -0
  183. package/dist/external-tools/opengrep/resolve.js +3 -0
  184. package/dist/external-tools/python/asset-names.d.ts +3 -1
  185. package/dist/external-tools/python/asset-names.js +7 -3
  186. package/dist/external-tools/python/pin.js +3 -1
  187. package/dist/external-tools/python/resolve.d.ts +3 -0
  188. package/dist/external-tools/python/resolve.js +3 -0
  189. package/dist/external-tools/sbt/resolve.d.ts +3 -0
  190. package/dist/external-tools/sbt/resolve.js +3 -0
  191. package/dist/external-tools/skillspector/from-uv.d.ts +1 -1
  192. package/dist/external-tools/synp/resolve.d.ts +3 -0
  193. package/dist/external-tools/synp/resolve.js +3 -0
  194. package/dist/external-tools/trivy/asset-names.d.ts +1 -1
  195. package/dist/external-tools/trivy/resolve.d.ts +3 -0
  196. package/dist/external-tools/trivy/resolve.js +3 -0
  197. package/dist/external-tools/trufflehog/asset-names.d.ts +4 -1
  198. package/dist/external-tools/trufflehog/asset-names.js +3 -0
  199. package/dist/external-tools/trufflehog/from-download.d.ts +1 -1
  200. package/dist/external-tools/trufflehog/resolve.d.ts +3 -0
  201. package/dist/external-tools/trufflehog/resolve.js +3 -0
  202. package/dist/external-tools/uv/asset-names.d.ts +1 -1
  203. package/dist/external-tools/uv/resolve.d.ts +3 -0
  204. package/dist/external-tools/uv/resolve.js +3 -0
  205. package/dist/fleet/repo-config.d.ts +8 -6
  206. package/dist/fleet/repo-config.js +8 -6
  207. package/dist/fs/_internal.d.ts +1 -1
  208. package/dist/fs/_internal.js +1 -1
  209. package/dist/fs/access.d.ts +2 -0
  210. package/dist/fs/access.js +2 -0
  211. package/dist/fs/allowed-dirs-cache.js +5 -3
  212. package/dist/fs/find.js +1 -2
  213. package/dist/fs/inspect.d.ts +2 -2
  214. package/dist/fs/read-file.js +3 -4
  215. package/dist/fs/safe.js +1 -1
  216. package/dist/git/_internal.js +5 -1
  217. package/dist/github/commit.d.ts +92 -0
  218. package/dist/github/commit.js +113 -0
  219. package/dist/github/ghsa.js +1 -1
  220. package/dist/github/refs-graphql.js +1 -1
  221. package/dist/github/request.js +1 -1
  222. package/dist/github/token.d.ts +5 -2
  223. package/dist/github/token.js +6 -4
  224. package/dist/github/workflow-runs.d.ts +107 -0
  225. package/dist/github/workflow-runs.js +98 -0
  226. package/dist/http-request/_internal.d.ts +1 -1
  227. package/dist/http-request/browser.d.ts +6 -0
  228. package/dist/http-request/browser.js +3 -2
  229. package/dist/http-request/download.js +2 -0
  230. package/dist/http-request/headers.d.ts +1 -1
  231. package/dist/http-request/headers.js +1 -1
  232. package/dist/http-request/request-attempt.js +6 -3
  233. package/dist/http-request/request-types.d.ts +10 -1
  234. package/dist/http-request/request.js +2 -2
  235. package/dist/http-request/user-agent.d.ts +23 -2
  236. package/dist/http-request/user-agent.js +48 -6
  237. package/dist/integrity.d.ts +3 -1
  238. package/dist/integrity.js +3 -1
  239. package/dist/json/format.js +4 -1
  240. package/dist/logger/_internal.d.ts +13 -15
  241. package/dist/logger/_internal.js +21 -21
  242. package/dist/logger/colors.d.ts +9 -3
  243. package/dist/logger/colors.js +6 -13
  244. package/dist/logger/console-methods.js +2 -2
  245. package/dist/logger/console.d.ts +1 -0
  246. package/dist/logger/console.js +9 -9
  247. package/dist/logger/node.js +2 -1
  248. package/dist/native-messaging/install.js +1 -1
  249. package/dist/native-messaging/rate-limit.d.ts +4 -1
  250. package/dist/native-messaging/rate-limit.js +4 -1
  251. package/dist/node/events.d.ts +3 -0
  252. package/dist/node/events.js +3 -0
  253. package/dist/node/fs.d.ts +1 -1
  254. package/dist/node/timers-promises.d.ts +3 -0
  255. package/dist/node/timers-promises.js +3 -0
  256. package/dist/node/url.d.ts +3 -0
  257. package/dist/node/url.js +3 -0
  258. package/dist/npm/meta-cache.d.ts +183 -0
  259. package/dist/npm/meta-cache.js +318 -0
  260. package/dist/npm/meta-slice.d.ts +27 -0
  261. package/dist/npm/meta-slice.js +68 -0
  262. package/dist/npm/meta-types.d.ts +282 -0
  263. package/dist/npm/meta-types.js +2 -0
  264. package/dist/npm/meta.d.ts +125 -0
  265. package/dist/npm/meta.js +347 -0
  266. package/dist/npm/registry.d.ts +212 -0
  267. package/dist/npm/registry.js +284 -0
  268. package/dist/objects/getters.d.ts +1 -1
  269. package/dist/objects/getters.js +1 -1
  270. package/dist/packages/manifest.js +6 -7
  271. package/dist/packages/metadata-extensions.js +2 -4
  272. package/dist/packages/provenance.d.ts +8 -0
  273. package/dist/packages/provenance.js +8 -0
  274. package/dist/packages/tarball.js +1 -2
  275. package/dist/packages/validation.d.ts +0 -10
  276. package/dist/packages/validation.js +0 -14
  277. package/dist/paths/exts.d.ts +30 -0
  278. package/dist/paths/exts.js +30 -0
  279. package/dist/paths/filenames.d.ts +6 -0
  280. package/dist/paths/filenames.js +6 -0
  281. package/dist/paths/globs.d.ts +6 -0
  282. package/dist/paths/globs.js +6 -0
  283. package/dist/paths/resolve.js +19 -14
  284. package/dist/paths/socket.d.ts +8 -8
  285. package/dist/paths/socket.js +8 -8
  286. package/dist/perf/report.js +4 -2
  287. package/dist/pkg-ext/data.js +0 -2
  288. package/dist/primordials/globals.d.ts +1 -1
  289. package/dist/primordials/globals.js +1 -1
  290. package/dist/primordials/headers.d.ts +13 -1
  291. package/dist/primordials/headers.js +13 -1
  292. package/dist/primordials/process.d.ts +1 -1
  293. package/dist/primordials/process.js +1 -1
  294. package/dist/primordials/url.d.ts +18 -0
  295. package/dist/primordials/url.js +18 -0
  296. package/dist/process/spawn/child.js +3 -5
  297. package/dist/promises/_internal.d.ts +1 -1
  298. package/dist/promises/_internal.js +1 -2
  299. package/dist/promises/options.js +3 -3
  300. package/dist/releases/socket-btm-binary-naming.js +12 -1
  301. package/dist/secrets/_internal.d.ts +1 -1
  302. package/dist/secrets/_internal.js +1 -1
  303. package/dist/secrets/find.d.ts +2 -2
  304. package/dist/secrets/find.js +2 -2
  305. package/dist/secrets/keychain.d.ts +10 -1
  306. package/dist/secrets/keychain.js +10 -1
  307. package/dist/secrets/socket-api-token.d.ts +1 -1
  308. package/dist/secrets/socket-api-token.js +1 -1
  309. package/dist/secrets/types.d.ts +1 -1
  310. package/dist/smol/http.d.ts +2 -0
  311. package/dist/smol/http.js +2 -0
  312. package/dist/smol/https.d.ts +2 -0
  313. package/dist/smol/https.js +2 -0
  314. package/dist/sorts/_internal.d.ts +2 -3
  315. package/dist/sorts/_internal.js +1 -3
  316. package/dist/spinner/format.js +2 -4
  317. package/dist/stdio/footer.js +8 -7
  318. package/dist/stdio/prompts.d.ts +8 -15
  319. package/dist/stdio/prompts.js +18 -29
  320. package/dist/strings/predicates.d.ts +2 -2
  321. package/dist/strings/search.js +1 -1
  322. package/dist/strings/types.d.ts +4 -0
  323. package/dist/strings/width.d.ts +1 -0
  324. package/dist/strings/width.js +17 -8
  325. package/dist/themes/context.d.ts +13 -0
  326. package/dist/themes/context.js +23 -8
  327. package/dist/versions/_internal.d.ts +43 -13
  328. package/dist/versions/_internal.js +27 -15
  329. package/dist/versions/compare.d.ts +16 -10
  330. package/dist/versions/compare.js +36 -16
  331. package/dist/versions/parse.js +1 -1
  332. package/dist/versions/range.js +3 -2
  333. package/dist/words/pluralize.js +4 -1
  334. package/llms.txt +63 -750
  335. package/package.json +200 -35
package/dist/smol/http.js CHANGED
@@ -23,6 +23,8 @@ let smolHttpProbed = false;
23
23
  /**
24
24
  * Returns `node:smol-http` when running on the smol Node binary, otherwise
25
25
  * `undefined`. Result is cached across calls.
26
+ *
27
+ * @unused No internal or Socket consumers (exercised only by its unit tests).
26
28
  */
27
29
  function getSmolHttp() {
28
30
  if (!smolHttpProbed) {
@@ -55,5 +55,7 @@ export interface SmolHttpsBinding {
55
55
  /**
56
56
  * Returns `node:smol-https` when running on the smol Node binary, otherwise
57
57
  * `undefined`. Result is cached across calls.
58
+ *
59
+ * @unused No internal or Socket consumers (exercised only by its unit tests).
58
60
  */
59
61
  export declare function getSmolHttps(): SmolHttpsBinding | undefined;
@@ -21,6 +21,8 @@ let smolHttpsProbed = false;
21
21
  /**
22
22
  * Returns `node:smol-https` when running on the smol Node binary, otherwise
23
23
  * `undefined`. Result is cached across calls.
24
+ *
25
+ * @unused No internal or Socket consumers (exercised only by its unit tests).
24
26
  */
25
27
  function getSmolHttps() {
26
28
  if (!smolHttpsProbed) {
@@ -3,6 +3,5 @@
3
3
  * fast-sort + semver, and the cached Intl.Collator instances. Used by the
4
4
  * locale / natural / semver comparison entrypoints.
5
5
  */
6
- import type * as fastSortType from '../external/fast-sort';
7
- export { getSemver } from '../versions/_internal';
8
- export declare function getFastSort(): typeof fastSortType;
6
+ import type { default as FastSort } from '../external/fast-sort';
7
+ export declare function getFastSort(): typeof FastSort;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with rolldown */
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_versions__internal = require('../versions/_internal.js');
5
4
 
6
5
  //#region src/sorts/_internal.ts
7
6
  let fastSort;
@@ -11,5 +10,4 @@ function getFastSort() {
11
10
  }
12
11
 
13
12
  //#endregion
14
- exports.getFastSort = getFastSort;
15
- exports.getSemver = require_versions__internal.getSemver;
13
+ exports.getFastSort = getFastSort;
@@ -1,10 +1,8 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with rolldown */
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_runtime = require('../_virtual/_rolldown/runtime.js');
5
4
  const require_primordials_math = require('../primordials/math.js');
6
- let src_external_yoctocolors_cjs = require("../external/yoctocolors-cjs");
7
- src_external_yoctocolors_cjs = require_runtime.__toESM(src_external_yoctocolors_cjs);
5
+ const require_logger_colors = require('../logger/colors.js');
8
6
 
9
7
  //#region src/spinner/format.ts
10
8
  /**
@@ -86,7 +84,7 @@ function renderProgressBar(percentage, width = 20) {
86
84
  const filled = require_primordials_math.MathMax(0, Math.min(width, Math.round(percentage / 100 * width)));
87
85
  const empty = require_primordials_math.MathMax(0, width - filled);
88
86
  const bar = "█".repeat(filled) + "░".repeat(empty);
89
- return src_external_yoctocolors_cjs.default.cyan(bar);
87
+ return require_logger_colors.getYoctocolors().cyan(bar);
90
88
  }
91
89
 
92
90
  //#endregion
@@ -1,14 +1,11 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with rolldown */
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_runtime = require('../_virtual/_rolldown/runtime.js');
5
4
  const require_primordials_array = require('../primordials/array.js');
6
5
  const require_primordials_date = require('../primordials/date.js');
7
6
  const require_logger_symbols = require('../logger/symbols.js');
8
7
  const require_strings_format = require('../strings/format.js');
9
8
  const require_logger_default = require('../logger/default.js');
10
- let src_external_yoctocolors_cjs = require("../external/yoctocolors-cjs");
11
- src_external_yoctocolors_cjs = require_runtime.__toESM(src_external_yoctocolors_cjs);
12
9
 
13
10
  //#region src/stdio/footer.ts
14
11
  /**
@@ -44,16 +41,17 @@ function createFooter(message, options) {
44
41
  __proto__: null,
45
42
  ...options
46
43
  };
44
+ const colors = require("../external/yoctocolors-cjs");
47
45
  const border = require_strings_format.repeatString(borderChar, width);
48
46
  const lines = [];
49
- if (message) require_primordials_array.ArrayPrototypePush(lines, (color && src_external_yoctocolors_cjs.default[color] ? src_external_yoctocolors_cjs.default[color] : (s) => s)(message));
47
+ if (message) require_primordials_array.ArrayPrototypePush(lines, (color && colors[color] ? colors[color] : (s) => s)(message));
50
48
  if (showTimestamp) {
51
49
  const timestamp = new require_primordials_date.DateCtor().toISOString();
52
- require_primordials_array.ArrayPrototypePush(lines, src_external_yoctocolors_cjs.default.gray(`Completed at: ${timestamp}`));
50
+ require_primordials_array.ArrayPrototypePush(lines, colors.gray(`Completed at: ${timestamp}`));
53
51
  }
54
52
  if (showDuration && startTime) {
55
53
  const seconds = ((require_primordials_date.DateNow() - startTime) / 1e3).toFixed(2);
56
- require_primordials_array.ArrayPrototypePush(lines, src_external_yoctocolors_cjs.default.gray(`Duration: ${seconds}s`));
54
+ require_primordials_array.ArrayPrototypePush(lines, colors.gray(`Duration: ${seconds}s`));
57
55
  }
58
56
  require_primordials_array.ArrayPrototypePush(lines, border);
59
57
  return lines.join("\n");
@@ -114,7 +112,10 @@ function createSummaryFooter(stats, options) {
114
112
  function printFooter(message) {
115
113
  const border = require_strings_format.repeatString("─", 55);
116
114
  logger.log(border);
117
- if (message) logger.log(src_external_yoctocolors_cjs.default.green(message));
115
+ if (message) {
116
+ const colors = require("../external/yoctocolors-cjs");
117
+ logger.log(colors.green(message));
118
+ }
118
119
  }
119
120
 
120
121
  //#endregion
@@ -2,17 +2,10 @@
2
2
  * @file User prompt utilities for interactive scripts. Provides inquirer.js
3
3
  * integration with spinner support, context handling, and theming.
4
4
  */
5
- import checkboxRaw from '../external/@inquirer/checkbox';
6
- import confirmRaw from '../external/@inquirer/confirm';
7
- import inputRaw from '../external/@inquirer/input';
8
- import passwordRaw from '../external/@inquirer/password';
9
5
  import type { Remap } from '../objects/types';
10
6
  import type { SpinnerInstance } from '../spinner/types';
11
7
  import type { ThemeName } from '../themes/themes';
12
8
  import type { Theme } from '../themes/types';
13
- declare const searchRaw: any;
14
- declare const selectRaw: any;
15
- declare const ActualSeparator: any;
16
9
  /**
17
10
  * Choice option for select and search prompts.
18
11
  *
@@ -135,7 +128,7 @@ export declare function createInquirerTheme(theme: Theme | ThemeName | unknown):
135
128
  *
136
129
  * @returns Separator instance
137
130
  */
138
- export declare function createSeparator(text?: string): InstanceType<typeof ActualSeparator>;
131
+ export declare function createSeparator(text?: string): Separator;
139
132
  /**
140
133
  * Check if value is a Socket Theme object.
141
134
  *
@@ -183,7 +176,7 @@ export declare function wrapPrompt<T = unknown>(inquirerPrompt: (...args: unknow
183
176
  * ],
184
177
  * })
185
178
  */
186
- export declare const checkbox: typeof checkboxRaw;
179
+ export declare const checkbox: (...args: unknown[]) => Promise<unknown>;
187
180
  /**
188
181
  * Prompt for a yes/no confirmation. Wrapped with spinner handling and abort
189
182
  * signal support.
@@ -192,7 +185,7 @@ export declare const checkbox: typeof checkboxRaw;
192
185
  * const answer = await confirm({ message: 'Continue?' })
193
186
  * if (answer) { // user confirmed }
194
187
  */
195
- export declare const confirm: typeof confirmRaw;
188
+ export declare const confirm: (...args: unknown[]) => Promise<unknown>;
196
189
  /**
197
190
  * Prompt for text input. Wrapped with spinner handling and abort signal
198
191
  * support. Result is automatically trimmed.
@@ -200,7 +193,7 @@ export declare const confirm: typeof confirmRaw;
200
193
  * @example
201
194
  * const name = await input({ message: 'Enter your name:' })
202
195
  */
203
- export declare const input: typeof inputRaw;
196
+ export declare const input: (...args: unknown[]) => Promise<unknown>;
204
197
  /**
205
198
  * Prompt for password input (hidden characters). Wrapped with spinner handling
206
199
  * and abort signal support.
@@ -208,7 +201,7 @@ export declare const input: typeof inputRaw;
208
201
  * @example
209
202
  * const token = await password({ message: 'Enter API token:' })
210
203
  */
211
- export declare const password: typeof passwordRaw;
204
+ export declare const password: (...args: unknown[]) => Promise<unknown>;
212
205
  /**
213
206
  * Prompt with searchable/filterable choices. Wrapped with spinner handling and
214
207
  * abort signal support.
@@ -219,7 +212,7 @@ export declare const password: typeof passwordRaw;
219
212
  * source: async input => fetchPackages(input),
220
213
  * })
221
214
  */
222
- export declare const search: typeof searchRaw;
215
+ export declare const search: (...args: unknown[]) => Promise<unknown>;
223
216
  /**
224
217
  * Prompt to select from a list of choices. Wrapped with spinner handling and
225
218
  * abort signal support.
@@ -233,5 +226,5 @@ export declare const search: typeof searchRaw;
233
226
  * ],
234
227
  * })
235
228
  */
236
- export declare const select: typeof selectRaw;
237
- export { ActualSeparator as Separator };
229
+ export declare const select: (...args: unknown[]) => Promise<unknown>;
230
+ export declare const Separator: typeof SeparatorType;
@@ -1,37 +1,18 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with rolldown */
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_runtime = require('../_virtual/_rolldown/runtime.js');
5
4
  const require_process_abort = require('../process/abort.js');
6
5
  const require_themes_themes = require('../themes/themes.js');
7
6
  const require_themes_context = require('../themes/context.js');
8
7
  const require_logger_colors = require('../logger/colors.js');
9
8
  const require_themes_resolve = require('../themes/resolve.js');
10
9
  const require_spinner_default = require('../spinner/default.js');
11
- let src_external__inquirer_checkbox = require("../external/@inquirer/checkbox");
12
- src_external__inquirer_checkbox = require_runtime.__toESM(src_external__inquirer_checkbox);
13
- let src_external__inquirer_confirm = require("../external/@inquirer/confirm");
14
- src_external__inquirer_confirm = require_runtime.__toESM(src_external__inquirer_confirm);
15
- let src_external__inquirer_input = require("../external/@inquirer/input");
16
- src_external__inquirer_input = require_runtime.__toESM(src_external__inquirer_input);
17
- let src_external__inquirer_password = require("../external/@inquirer/password");
18
- src_external__inquirer_password = require_runtime.__toESM(src_external__inquirer_password);
19
- let src_external__inquirer_search = require("../external/@inquirer/search");
20
- src_external__inquirer_search = require_runtime.__toESM(src_external__inquirer_search);
21
- let src_external__inquirer_select = require("../external/@inquirer/select");
22
- src_external__inquirer_select = require_runtime.__toESM(src_external__inquirer_select);
23
10
 
24
11
  //#region src/stdio/prompts.ts
25
12
  /**
26
13
  * @file User prompt utilities for interactive scripts. Provides inquirer.js
27
14
  * integration with spinner support, context handling, and theming.
28
15
  */
29
- const abortSignal = require_process_abort.getAbortSignal();
30
- const spinner = require_spinner_default.getDefaultSpinner();
31
- const searchRaw = src_external__inquirer_search.default;
32
- const selectModule = src_external__inquirer_select;
33
- const selectRaw = selectModule.default;
34
- const ActualSeparator = selectModule.Separator;
35
16
  /**
36
17
  * Convert Socket theme to @inquirer theme format. Maps our theme colors to
37
18
  * inquirer's style functions. Handles theme names, Theme objects, and passes
@@ -102,7 +83,7 @@ function createInquirerTheme(theme) {
102
83
  * @returns Separator instance
103
84
  */
104
85
  function createSeparator(text) {
105
- return new ActualSeparator(text);
86
+ return new (require("../external/@inquirer/select")).Separator(text);
106
87
  }
107
88
  /**
108
89
  * Check if value is a Socket Theme object.
@@ -144,8 +125,8 @@ function wrapPrompt(inquirerPrompt) {
144
125
  return async (...args) => {
145
126
  const origContext = args.length > 1 ? args[1] : void 0;
146
127
  const { spinner: contextSpinner, ...contextWithoutSpinner } = origContext ?? {};
147
- const spinnerInstance = contextSpinner !== void 0 ? contextSpinner : spinner;
148
- const signal = abortSignal;
128
+ const spinnerInstance = contextSpinner !== void 0 ? contextSpinner : require_spinner_default.getDefaultSpinner();
129
+ const signal = require_process_abort.getAbortSignal();
149
130
  const config = args[0];
150
131
  if (config && typeof config === "object") if (!config["theme"]) config["theme"] = createInquirerTheme(require_themes_context.getTheme());
151
132
  else config["theme"] = createInquirerTheme(config["theme"]);
@@ -180,7 +161,7 @@ function wrapPrompt(inquirerPrompt) {
180
161
  * ],
181
162
  * })
182
163
  */
183
- const checkbox = wrapPrompt(src_external__inquirer_checkbox.default);
164
+ const checkbox = wrapPrompt((...args) => require("../external/@inquirer/checkbox").default(...args));
184
165
  /**
185
166
  * Prompt for a yes/no confirmation. Wrapped with spinner handling and abort
186
167
  * signal support.
@@ -189,7 +170,7 @@ const checkbox = wrapPrompt(src_external__inquirer_checkbox.default);
189
170
  * const answer = await confirm({ message: 'Continue?' })
190
171
  * if (answer) { // user confirmed }
191
172
  */
192
- const confirm = wrapPrompt(src_external__inquirer_confirm.default);
173
+ const confirm = wrapPrompt((...args) => require("../external/@inquirer/confirm").default(...args));
193
174
  /**
194
175
  * Prompt for text input. Wrapped with spinner handling and abort signal
195
176
  * support. Result is automatically trimmed.
@@ -197,7 +178,7 @@ const confirm = wrapPrompt(src_external__inquirer_confirm.default);
197
178
  * @example
198
179
  * const name = await input({ message: 'Enter your name:' })
199
180
  */
200
- const input = wrapPrompt(src_external__inquirer_input.default);
181
+ const input = wrapPrompt((...args) => require("../external/@inquirer/input").default(...args));
201
182
  /**
202
183
  * Prompt for password input (hidden characters). Wrapped with spinner handling
203
184
  * and abort signal support.
@@ -205,7 +186,7 @@ const input = wrapPrompt(src_external__inquirer_input.default);
205
186
  * @example
206
187
  * const token = await password({ message: 'Enter API token:' })
207
188
  */
208
- const password = wrapPrompt(src_external__inquirer_password.default);
189
+ const password = wrapPrompt((...args) => require("../external/@inquirer/password").default(...args));
209
190
  /**
210
191
  * Prompt with searchable/filterable choices. Wrapped with spinner handling and
211
192
  * abort signal support.
@@ -216,7 +197,7 @@ const password = wrapPrompt(src_external__inquirer_password.default);
216
197
  * source: async input => fetchPackages(input),
217
198
  * })
218
199
  */
219
- const search = wrapPrompt(searchRaw);
200
+ const search = wrapPrompt((...args) => require("../external/@inquirer/search").default(...args));
220
201
  /**
221
202
  * Prompt to select from a list of choices. Wrapped with spinner handling and
222
203
  * abort signal support.
@@ -230,10 +211,18 @@ const search = wrapPrompt(searchRaw);
230
211
  * ],
231
212
  * })
232
213
  */
233
- const select = wrapPrompt(selectRaw);
214
+ const select = wrapPrompt((...args) => require("../external/@inquirer/select").default(...args));
215
+ const Separator = new Proxy(function() {}, {
216
+ construct(_target, args) {
217
+ return Reflect.construct(require("../external/@inquirer/select").Separator, args);
218
+ },
219
+ get(_target, prop, receiver) {
220
+ return Reflect.get(require("../external/@inquirer/select").Separator, prop, receiver);
221
+ }
222
+ });
234
223
 
235
224
  //#endregion
236
- exports.Separator = ActualSeparator;
225
+ exports.Separator = Separator;
237
226
  exports.checkbox = checkbox;
238
227
  exports.confirm = confirm;
239
228
  exports.createInquirerTheme = createInquirerTheme;
@@ -3,7 +3,7 @@
3
3
  * TypeScript type guards so callers can narrow `unknown` → `string` (or
4
4
  * `BlankString` / non-empty string) without an extra cast.
5
5
  */
6
- import type { BlankString, EmptyString } from './types';
6
+ import type { BlankString, NonEmptyString } from './types';
7
7
  /**
8
8
  * Check if a value is a blank string (empty or only whitespace).
9
9
  *
@@ -49,4 +49,4 @@ export declare function isBlankString(value: unknown): value is BlankString;
49
49
  *
50
50
  * @returns `true` if the value is a non-empty string, `false` otherwise
51
51
  */
52
- export declare function isNonEmptyString(value: unknown): value is Exclude<string, EmptyString>;
52
+ export declare function isNonEmptyString(value: unknown): value is NonEmptyString;
@@ -43,7 +43,7 @@ function search(str, regexp, options) {
43
43
  ...options
44
44
  };
45
45
  const { length } = str;
46
- if (fromIndex >= length) return -1;
46
+ if (fromIndex > length) return -1;
47
47
  if (fromIndex === 0) return require_primordials_string.StringPrototypeSearch(str, regexp);
48
48
  const offset = fromIndex < 0 ? require_primordials_math.MathMax(length + fromIndex, 0) : fromIndex;
49
49
  const result = require_primordials_string.StringPrototypeSlice(str, offset).search(regexp);
@@ -10,6 +10,10 @@ declare const EmptyStringBrand: unique symbol;
10
10
  export type EmptyString = string & {
11
11
  [EmptyStringBrand]: true;
12
12
  };
13
+ declare const NonEmptyStringBrand: unique symbol;
14
+ export type NonEmptyString = string & {
15
+ [NonEmptyStringBrand]: true;
16
+ };
13
17
  export interface ApplyLinePrefixOptions {
14
18
  /**
15
19
  * The prefix to add to each line.
@@ -14,6 +14,7 @@
14
14
  */
15
15
  import type { eastAsianWidth as eastAsianWidthType } from '../external/get-east-asian-width';
16
16
  export declare function getEastAsianWidth(): typeof eastAsianWidthType;
17
+ export declare function getSegmenter(): Intl.Segmenter;
17
18
  /**
18
19
  * Get the visual width of a string in terminal columns.
19
20
  *
@@ -26,7 +26,11 @@ function getEastAsianWidth() {
26
26
  if (cachedEastAsianWidth === void 0) cachedEastAsianWidth = (/* @__PURE__ */ require("../external/get-east-asian-width")).eastAsianWidth;
27
27
  return cachedEastAsianWidth;
28
28
  }
29
- const segmenter = new require_primordials_intl.IntlSegmenter();
29
+ let segmenter;
30
+ function getSegmenter() {
31
+ if (segmenter === void 0) segmenter = new require_primordials_intl.IntlSegmenter();
32
+ return segmenter;
33
+ }
30
34
  let zeroWidthClusterRegex;
31
35
  let leadingNonPrintingRegex;
32
36
  let emojiRegex;
@@ -73,7 +77,7 @@ function stringWidth(text) {
73
77
  let width = 0;
74
78
  const eastAsianWidthOptions = { ambiguousAsWide: false };
75
79
  const eastAsianWidth = getEastAsianWidth();
76
- for (const { segment } of segmenter.segment(plainText)) {
80
+ for (const { segment } of getSegmenter().segment(plainText)) {
77
81
  if (require_primordials_regexp.RegExpPrototypeTest(zeroWidthClusterRegex, segment)) continue;
78
82
  if (require_primordials_regexp.RegExpPrototypeTest(emojiRegex, segment)) {
79
83
  width += 2;
@@ -83,13 +87,17 @@ function stringWidth(text) {
83
87
  if (codePoint === void 0) continue;
84
88
  /* c8 ignore next - External eastAsianWidth call */
85
89
  width += eastAsianWidth(codePoint, eastAsianWidthOptions);
86
- if (segment.length > 1) for (const char of segment.slice(1)) {
87
- const charCode = require_primordials_string.StringPrototypeCharCodeAt(char, 0);
88
- if (charCode >= 65280 && charCode <= 65519) {
89
- const trailingCodePoint = require_primordials_string.StringPrototypeCodePointAt(char, 0);
90
- if (trailingCodePoint !== void 0)
90
+ if (segment.length > 1) {
91
+ const trailingChars = segment.slice(1);
92
+ for (let i = 0, { length } = trailingChars; i < length; i += 1) {
93
+ const char = trailingChars[i];
94
+ const charCode = require_primordials_string.StringPrototypeCharCodeAt(char, 0);
95
+ if (charCode >= 65280 && charCode <= 65519) {
96
+ const trailingCodePoint = require_primordials_string.StringPrototypeCodePointAt(char, 0);
97
+ if (trailingCodePoint !== void 0)
91
98
  /* c8 ignore next - External eastAsianWidth call */
92
- width += eastAsianWidth(trailingCodePoint, eastAsianWidthOptions);
99
+ width += eastAsianWidth(trailingCodePoint, eastAsianWidthOptions);
100
+ }
93
101
  }
94
102
  }
95
103
  }
@@ -98,4 +106,5 @@ function stringWidth(text) {
98
106
 
99
107
  //#endregion
100
108
  exports.getEastAsianWidth = getEastAsianWidth;
109
+ exports.getSegmenter = getSegmenter;
101
110
  exports.stringWidth = stringWidth;
@@ -2,6 +2,7 @@
2
2
  * @file Elegant theme context management. Async-aware theming with automatic
3
3
  * context isolation via AsyncLocalStorage.
4
4
  */
5
+ import type { AsyncLocalStorage } from 'node:async_hooks';
5
6
  import type { Theme } from './types';
6
7
  import type { ThemeName } from './themes';
7
8
  import { getNodeAsyncHooks } from '../node/async-hooks';
@@ -35,6 +36,18 @@ export declare const getAsyncHooks: typeof getNodeAsyncHooks;
35
36
  * @returns Current theme
36
37
  */
37
38
  export declare function getTheme(): Theme;
39
+ /**
40
+ * Get the process-scoped AsyncLocalStorage used for theme context isolation.
41
+ *
42
+ * Constructed LAZILY (memoized) rather than at module-eval: an
43
+ * AsyncLocalStorage holds a live native handle, and constructing it at import
44
+ * time pins that handle into every module transitively importing this leaf —
45
+ * aborting V8 --build-snapshot serialization. Deferring to first use keeps the
46
+ * single-store semantics while leaving module import snapshot-safe.
47
+ *
48
+ * @private
49
+ */
50
+ export declare function getThemeStorage(): AsyncLocalStorage<Theme>;
38
51
  /**
39
52
  * Subscribe to theme change events.
40
53
  *
@@ -22,11 +22,7 @@ function emitThemeChange(theme) {
22
22
  * @private
23
23
  */
24
24
  const getAsyncHooks = require_node_async_hooks.getNodeAsyncHooks;
25
- /**
26
- * AsyncLocalStorage for theme context isolation.
27
- */
28
- const { AsyncLocalStorage } = getAsyncHooks();
29
- const themeStorage = new AsyncLocalStorage();
25
+ let themeStorage;
30
26
  /**
31
27
  * Fallback theme for global context.
32
28
  */
@@ -47,7 +43,25 @@ const listeners = new require_primordials_map_set.SetCtor();
47
43
  * @returns Current theme
48
44
  */
49
45
  function getTheme() {
50
- return themeStorage.getStore() ?? fallbackTheme;
46
+ return getThemeStorage().getStore() ?? fallbackTheme;
47
+ }
48
+ /**
49
+ * Get the process-scoped AsyncLocalStorage used for theme context isolation.
50
+ *
51
+ * Constructed LAZILY (memoized) rather than at module-eval: an
52
+ * AsyncLocalStorage holds a live native handle, and constructing it at import
53
+ * time pins that handle into every module transitively importing this leaf —
54
+ * aborting V8 --build-snapshot serialization. Deferring to first use keeps the
55
+ * single-store semantics while leaving module import snapshot-safe.
56
+ *
57
+ * @private
58
+ */
59
+ function getThemeStorage() {
60
+ if (themeStorage === void 0) {
61
+ const { AsyncLocalStorage } = getAsyncHooks();
62
+ themeStorage = new AsyncLocalStorage();
63
+ }
64
+ return themeStorage;
51
65
  }
52
66
  /**
53
67
  * Subscribe to theme change events.
@@ -106,7 +120,7 @@ function setTheme(theme) {
106
120
  */
107
121
  async function withTheme(theme, fn) {
108
122
  const resolvedTheme = typeof theme === "string" ? require_themes_themes.THEMES[theme] ?? fallbackTheme : theme;
109
- return await themeStorage.run(resolvedTheme, async () => {
123
+ return await getThemeStorage().run(resolvedTheme, async () => {
110
124
  emitThemeChange(resolvedTheme);
111
125
  return await fn();
112
126
  });
@@ -131,7 +145,7 @@ async function withTheme(theme, fn) {
131
145
  */
132
146
  function withThemeSync(theme, fn) {
133
147
  const resolvedTheme = typeof theme === "string" ? require_themes_themes.THEMES[theme] ?? fallbackTheme : theme;
134
- return themeStorage.run(resolvedTheme, () => {
148
+ return getThemeStorage().run(resolvedTheme, () => {
135
149
  emitThemeChange(resolvedTheme);
136
150
  return fn();
137
151
  });
@@ -141,6 +155,7 @@ function withThemeSync(theme, fn) {
141
155
  exports.emitThemeChange = emitThemeChange;
142
156
  exports.getAsyncHooks = getAsyncHooks;
143
157
  exports.getTheme = getTheme;
158
+ exports.getThemeStorage = getThemeStorage;
144
159
  exports.onThemeChange = onThemeChange;
145
160
  exports.setTheme = setTheme;
146
161
  exports.withTheme = withTheme;
@@ -1,24 +1,54 @@
1
1
  /**
2
- * @file Private internals for `versions/*` modules — eagerly picks the right
3
- * implementation at module load. On socket-btm's smol Node binary, prefers
2
+ * @file Private internals for `versions/*` modules — lazily picks the right
3
+ * implementation at FIRST USE. On socket-btm's smol Node binary, prefers
4
4
  * `node:smol-versions` (C++-accelerated via
5
5
  * `internalBinding('smol_versions_native')`); on stock Node, falls through to
6
6
  * the vendored JS `semver`. Both expose a strict-superset surface for the ops
7
- * `versions/*` calls, so leaves can forward to `impl.<op>` directly without
8
- * per-call branching. `getMajorVersion`-style helpers need the parsed object
9
- * shape (`{major, minor, patch}`) which only `semver.parse` exposes — those
10
- * leaves use `getSemver()` directly instead of going through `impl`.
7
+ * `versions/*` calls, so leaves can forward to `getImpl().<op>` directly
8
+ * without per-call branching. `getMajorVersion`-style helpers need the parsed
9
+ * object shape (`{major, minor, patch}`) which only `semver.parse` exposes —
10
+ * those leaves use `getSemver()` directly instead of going through the impl.
11
+ * Snapshot safety: the vendored `semver` resolves through the npm-pack
12
+ * bundle, whose module-eval constructs a live native `[Foreign]` handle
13
+ * (cacache/pacote/make-fetch-happen). Requiring it at module load pins that
14
+ * handle and aborts `node --build-snapshot`. So both the `require` and the
15
+ * smol-vs-semver pick are deferred to first call and memoized.
11
16
  */
12
- import type * as semverType from '../external/semver';
17
+ import type { coerce, compare, diff, eq, gt, gte, inc, lt, lte, maxSatisfying, minSatisfying, parse, rsort, satisfies, sort, valid } from '../external/semver';
13
18
  import type { SmolVersionsBinding } from '../smol/versions';
14
19
  /**
15
- * The vendored `semver` JS implementation. Always available — used directly by
16
- * the leaves that need the parsed `{major, minor, patch}` shape (which
17
- * smol-versions doesn't expose).
20
+ * The surface of the vendored `semver` module the `versions/*` leaves call.
21
+ * Built from named imports (vs. `import * as`) so the used surface stays
22
+ * explicit and greppable.
18
23
  */
19
- export declare function getSemver(): typeof semverType;
24
+ export interface Semver {
25
+ coerce: typeof coerce;
26
+ compare: typeof compare;
27
+ diff: typeof diff;
28
+ eq: typeof eq;
29
+ gt: typeof gt;
30
+ gte: typeof gte;
31
+ inc: typeof inc;
32
+ lt: typeof lt;
33
+ lte: typeof lte;
34
+ maxSatisfying: typeof maxSatisfying;
35
+ minSatisfying: typeof minSatisfying;
36
+ parse: typeof parse;
37
+ rsort: typeof rsort;
38
+ satisfies: typeof satisfies;
39
+ sort: typeof sort;
40
+ valid: typeof valid;
41
+ }
20
42
  /**
21
43
  * Resolved version implementation: smol-versions on the smol Node binary,
22
- * otherwise the vendored `semver`. Bound once at module load.
44
+ * otherwise the vendored `semver`. Resolved once on first call and memoized —
45
+ * deferred from module load so importing a `versions/*` leaf is handle-free.
46
+ */
47
+ export declare function getImpl(): SmolVersionsBinding | Semver;
48
+ /**
49
+ * The vendored `semver` JS implementation. Always available — used directly by
50
+ * the leaves that need the parsed `{major, minor, patch}` shape (which
51
+ * smol-versions doesn't expose). Required lazily on first call so importing a
52
+ * `versions/*` leaf does not pull in the native-handle-bearing npm-pack bundle.
23
53
  */
24
- export declare const impl: SmolVersionsBinding | typeof semverType;
54
+ export declare function getSemver(): Semver;
@@ -5,31 +5,43 @@ const require_smol_versions = require('../smol/versions.js');
5
5
 
6
6
  //#region src/versions/_internal.ts
7
7
  /**
8
- * @file Private internals for `versions/*` modules — eagerly picks the right
9
- * implementation at module load. On socket-btm's smol Node binary, prefers
8
+ * @file Private internals for `versions/*` modules — lazily picks the right
9
+ * implementation at FIRST USE. On socket-btm's smol Node binary, prefers
10
10
  * `node:smol-versions` (C++-accelerated via
11
11
  * `internalBinding('smol_versions_native')`); on stock Node, falls through to
12
12
  * the vendored JS `semver`. Both expose a strict-superset surface for the ops
13
- * `versions/*` calls, so leaves can forward to `impl.<op>` directly without
14
- * per-call branching. `getMajorVersion`-style helpers need the parsed object
15
- * shape (`{major, minor, patch}`) which only `semver.parse` exposes — those
16
- * leaves use `getSemver()` directly instead of going through `impl`.
13
+ * `versions/*` calls, so leaves can forward to `getImpl().<op>` directly
14
+ * without per-call branching. `getMajorVersion`-style helpers need the parsed
15
+ * object shape (`{major, minor, patch}`) which only `semver.parse` exposes —
16
+ * those leaves use `getSemver()` directly instead of going through the impl.
17
+ * Snapshot safety: the vendored `semver` resolves through the npm-pack
18
+ * bundle, whose module-eval constructs a live native `[Foreign]` handle
19
+ * (cacache/pacote/make-fetch-happen). Requiring it at module load pins that
20
+ * handle and aborts `node --build-snapshot`. So both the `require` and the
21
+ * smol-vs-semver pick are deferred to first call and memoized.
17
22
  */
18
- const semver = require("../external/semver");
23
+ let impl;
24
+ /**
25
+ * Resolved version implementation: smol-versions on the smol Node binary,
26
+ * otherwise the vendored `semver`. Resolved once on first call and memoized —
27
+ * deferred from module load so importing a `versions/*` leaf is handle-free.
28
+ */
29
+ function getImpl() {
30
+ if (impl === void 0) impl = require_smol_versions.getSmolVersions() ?? getSemver();
31
+ return impl;
32
+ }
33
+ let semver;
19
34
  /**
20
35
  * The vendored `semver` JS implementation. Always available — used directly by
21
36
  * the leaves that need the parsed `{major, minor, patch}` shape (which
22
- * smol-versions doesn't expose).
37
+ * smol-versions doesn't expose). Required lazily on first call so importing a
38
+ * `versions/*` leaf does not pull in the native-handle-bearing npm-pack bundle.
23
39
  */
24
40
  function getSemver() {
41
+ if (semver === void 0) semver = require("../external/semver");
25
42
  return semver;
26
43
  }
27
- /**
28
- * Resolved version implementation: smol-versions on the smol Node binary,
29
- * otherwise the vendored `semver`. Bound once at module load.
30
- */
31
- const impl = require_smol_versions.getSmolVersions() ?? semver;
32
44
 
33
45
  //#endregion
34
- exports.getSemver = getSemver;
35
- exports.impl = impl;
46
+ exports.getImpl = getImpl;
47
+ exports.getSemver = getSemver;