@socketsecurity/lib 6.0.8 → 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.
- package/CHANGELOG.md +28 -0
- package/README.md +8 -9
- package/dist/abort/signal.d.ts +1 -1
- package/dist/abort/signal.js +1 -1
- package/dist/ai/agent-context.d.mts +1 -1
- package/dist/ai/agent-context.js +3 -2
- package/dist/ai/backends.d.mts +3 -3
- package/dist/ai/backends.js +2 -2
- package/dist/ai/billing-context.d.mts +74 -0
- package/dist/ai/billing-context.js +129 -0
- package/dist/ai/credentials.d.mts +39 -5
- package/dist/ai/credentials.js +61 -6
- package/dist/ai/discover.d.mts +4 -0
- package/dist/ai/discover.js +4 -0
- package/dist/ai/exec.d.mts +1 -1
- package/dist/ai/exec.js +1 -1
- package/dist/ai/http.d.mts +8 -8
- package/dist/ai/http.js +6 -6
- package/dist/ai/profiles.d.mts +9 -10
- package/dist/ai/profiles.js +0 -5
- package/dist/ai/role.d.mts +58 -0
- package/dist/ai/role.js +96 -0
- package/dist/ai/route-heuristic.d.mts +177 -0
- package/dist/ai/route-heuristic.js +194 -0
- package/dist/ai/route.d.mts +31 -17
- package/dist/ai/route.js +35 -19
- package/dist/ai/spawn.d.mts +34 -1
- package/dist/ai/spawn.js +115 -3
- package/dist/ai/subagent-status.d.mts +2 -0
- package/dist/ai/subagent-status.js +2 -0
- package/dist/ai/tier.d.mts +1 -1
- package/dist/ai/types.d.mts +19 -2
- package/dist/ai/worktree.d.mts +1 -1
- package/dist/ai/worktree.js +3 -2
- package/dist/argv/parse.d.ts +2 -0
- package/dist/argv/parse.js +2 -0
- package/dist/bin/_internal.d.ts +1 -1
- package/dist/bin/_internal.js +1 -1
- package/dist/bin/prim.cjs +19253 -13937
- package/dist/bin/resolve.js +1 -1
- package/dist/bin/shadow.js +2 -1
- package/dist/bin/which.d.ts +28 -3
- package/dist/bin/which.js +45 -3
- package/dist/cacache/_internal.d.ts +10 -2
- package/dist/cacache/_internal.js +6 -10
- package/dist/cache/ttl/_internal.d.ts +33 -0
- package/dist/cache/ttl/_internal.js +68 -0
- package/dist/cache/ttl/browser.d.ts +56 -0
- package/dist/cache/ttl/browser.js +257 -0
- package/dist/cache/ttl/store.js +11 -34
- package/dist/cache/ttl/types.d.ts +46 -3
- package/dist/checks/primordials-defaults.d.ts +5 -5
- package/dist/checks/primordials-defaults.js +5 -5
- package/dist/checks/primordials.d.ts +1 -1
- package/dist/checks/primordials.js +25 -17
- package/dist/cli/check-primordials.d.ts +6 -1
- package/dist/cli/check-primordials.js +14 -5
- package/dist/cli/check.js +1 -1
- package/dist/cli/socket-lib.d.ts +1 -1
- package/dist/cli/socket-lib.js +3 -3
- package/dist/colors/socket-palette.d.ts +1 -1
- package/dist/compression/brotli.d.ts +6 -2
- package/dist/compression/brotli.js +5 -1
- package/dist/compression/gzip.d.ts +6 -2
- package/dist/compression/gzip.js +7 -2
- package/dist/config/layers.d.ts +53 -0
- package/dist/config/layers.js +83 -0
- package/dist/constants/agents.d.ts +3 -0
- package/dist/constants/agents.js +3 -0
- package/dist/constants/node.d.ts +14 -0
- package/dist/constants/node.js +14 -0
- package/dist/constants/package-default-node-range.js +1 -5
- package/dist/constants/packages.d.ts +5 -0
- package/dist/constants/packages.js +5 -0
- package/dist/constants/platform.d.ts +1 -1
- package/dist/constants/platform.js +1 -1
- package/dist/constants/socket.js +1 -1
- package/dist/constants/typescript.d.ts +5 -0
- package/dist/constants/typescript.js +5 -0
- package/dist/debug/_internal.d.ts +22 -7
- package/dist/debug/_internal.js +33 -15
- package/dist/debug/caller-info.js +1 -1
- package/dist/debug/namespace.js +11 -8
- package/dist/debug/output.d.ts +12 -1
- package/dist/debug/output.js +33 -16
- package/dist/dlx/binary-cache.js +1 -1
- package/dist/dlx/binary-resolution.js +8 -5
- package/dist/dlx/firewall.js +1 -1
- package/dist/dlx/lockfile.js +1 -1
- package/dist/eco/npm/npm/parse-lockfile.js +3 -2
- package/dist/eco/npm/vlt/exec.d.ts +1 -1
- package/dist/eco/npm/vlt/exec.js +1 -1
- package/dist/eco/npm/yarnpkg/yarn/parse-lockfile.js +1 -1
- package/dist/env/agents.d.ts +6 -0
- package/dist/env/agents.js +29 -0
- package/dist/env/flags.d.ts +12 -0
- package/dist/env/flags.js +23 -0
- package/dist/env/github-status.js +2 -2
- package/dist/env/providers.d.ts +6 -0
- package/dist/env/providers.js +23 -0
- package/dist/env/proxy.js +1 -1
- package/dist/env/rewire.d.ts +37 -3
- package/dist/env/rewire.js +60 -29
- package/dist/env/runtimes.d.ts +9 -0
- package/dist/env/runtimes.js +53 -0
- package/dist/env/socket-cli.d.ts +5 -2
- package/dist/env/socket-cli.js +6 -3
- package/dist/env/xdg.d.ts +17 -0
- package/dist/env/xdg.js +21 -1
- package/dist/errors/predicates.d.ts +3 -2
- package/dist/errors/predicates.js +5 -3
- package/dist/events/exit/_internal.d.ts +1 -23
- package/dist/external/@npmcli/package-json.js +3570 -4905
- package/dist/external/@npmcli/promise-spawn.js +2 -2
- package/dist/external/@sinclair/typebox/value.js +5 -4
- package/dist/external/@socketregistry/yocto-spinner.js +3 -3
- package/dist/external/@yarnpkg/extensions.js +1 -1
- package/dist/external/adm-zip.d.ts +82 -0
- package/dist/external/adm-zip.js +2 -2
- package/dist/external/cacache.d.ts +87 -0
- package/dist/external/debug.d.ts +22 -0
- package/dist/external/debug.js +11 -4
- package/dist/external/del.d.ts +1 -0
- package/dist/external/external-pack.d.ts +12 -0
- package/dist/external/external-pack.js +42 -35
- package/dist/external/fast-glob.d.ts +8 -0
- package/dist/external/fast-sort.d.ts +1 -0
- package/dist/external/get-east-asian-width.d.ts +5 -0
- package/dist/external/get-east-asian-width.js +8 -1
- package/dist/external/has-flag.d.ts +1 -0
- package/dist/external/inquirer-pack.d.ts +18 -0
- package/dist/external/libnpmexec.d.ts +35 -0
- package/dist/external/libnpmpack.d.ts +1 -0
- package/dist/external/make-fetch-happen.d.ts +13 -0
- package/dist/external/normalize-package-data.d.ts +4 -0
- package/dist/external/npm-core.d.ts +14 -0
- package/dist/external/npm-pack.d.ts +24 -0
- package/dist/external/npm-pack.js +28934 -31885
- package/dist/external/npm-package-arg.d.ts +4 -0
- package/dist/external/p-map.js +8 -1
- package/dist/external/pacote.d.ts +15 -0
- package/dist/external/pico-pack.d.ts +16 -0
- package/dist/external/pico-pack.js +38 -23
- package/dist/external/picomatch.d.ts +96 -0
- package/dist/external/pony-cause.d.ts +14 -0
- package/dist/external/semver.d.ts +60 -0
- package/dist/external/semver.js +1459 -4
- package/dist/external/shell-quote.d.ts +51 -0
- package/dist/external/shell-quote.js +55 -15
- package/dist/external/signal-exit.d.ts +1 -0
- package/dist/external/spdx-correct.d.ts +4 -0
- package/dist/external/spdx-expression-parse.d.ts +4 -0
- package/dist/external/spdx-pack.d.ts +10 -0
- package/dist/external/std-env.d.ts +284 -0
- package/dist/external/std-env.js +323 -0
- package/dist/external/streaming-iterables.d.ts +11 -0
- package/dist/external/supports-color.d.ts +1 -0
- package/dist/external/tar-fs.d.ts +31 -0
- package/dist/external/tar-fs.js +63 -16
- package/dist/external/validate-npm-package-name.d.ts +4 -0
- package/dist/external/which.d.ts +25 -0
- package/dist/external/which.js +2 -2
- package/dist/external/yargs-parser.d.ts +2 -0
- package/dist/external/yargs-parser.js +11 -3
- package/dist/external/yoctocolors-cjs.d.ts +51 -0
- package/dist/external-tools/bazel/asset-names.d.ts +1 -1
- package/dist/external-tools/bazel/from-download.d.ts +1 -1
- package/dist/external-tools/bazel/resolve.d.ts +3 -0
- package/dist/external-tools/bazel/resolve.js +3 -0
- package/dist/external-tools/cdxgen/asset-names.d.ts +5 -5
- package/dist/external-tools/cdxgen/asset-names.js +3 -3
- package/dist/external-tools/cdxgen/from-download.d.ts +2 -2
- package/dist/external-tools/cdxgen/from-download.js +1 -1
- package/dist/external-tools/cdxgen/resolve.d.ts +4 -1
- package/dist/external-tools/cdxgen/resolve.js +4 -1
- package/dist/external-tools/cdxgen/types.d.ts +1 -1
- package/dist/external-tools/from-download.d.ts +2 -2
- package/dist/external-tools/from-download.js +1 -1
- package/dist/external-tools/janus/asset-names.d.ts +4 -1
- package/dist/external-tools/janus/asset-names.js +3 -0
- package/dist/external-tools/janus/from-download.d.ts +3 -3
- package/dist/external-tools/janus/from-download.js +2 -2
- package/dist/external-tools/janus/resolve.d.ts +3 -0
- package/dist/external-tools/janus/resolve.js +3 -0
- package/dist/external-tools/jre/asset-names.d.ts +3 -1
- package/dist/external-tools/jre/asset-names.js +2 -0
- package/dist/external-tools/jre/detect-platform-arch.js +1 -1
- package/dist/external-tools/jre/from-download.d.ts +1 -1
- package/dist/external-tools/manifest.d.ts +5 -3
- package/dist/external-tools/manifest.js +5 -3
- package/dist/external-tools/opengrep/asset-names.d.ts +1 -1
- package/dist/external-tools/opengrep/resolve.d.ts +3 -0
- package/dist/external-tools/opengrep/resolve.js +3 -0
- package/dist/external-tools/python/asset-names.d.ts +3 -1
- package/dist/external-tools/python/asset-names.js +8 -4
- package/dist/external-tools/python/pin.js +3 -1
- package/dist/external-tools/python/resolve.d.ts +3 -0
- package/dist/external-tools/python/resolve.js +3 -0
- package/dist/external-tools/python/uv-install.d.ts +89 -0
- package/dist/external-tools/python/uv-install.js +165 -0
- package/dist/external-tools/sbt/resolve.d.ts +3 -0
- package/dist/external-tools/sbt/resolve.js +3 -0
- package/dist/external-tools/skillspector/from-uv.d.ts +30 -0
- package/dist/external-tools/skillspector/from-uv.js +56 -0
- package/dist/external-tools/skillspector/resolve.d.ts +18 -3
- package/dist/external-tools/skillspector/resolve.js +21 -8
- package/dist/external-tools/skillspector/types.d.ts +3 -1
- package/dist/external-tools/synp/resolve.d.ts +3 -0
- package/dist/external-tools/synp/resolve.js +3 -0
- package/dist/external-tools/trivy/asset-names.d.ts +1 -1
- package/dist/external-tools/trivy/resolve.d.ts +3 -0
- package/dist/external-tools/trivy/resolve.js +3 -0
- package/dist/external-tools/trufflehog/asset-names.d.ts +4 -1
- package/dist/external-tools/trufflehog/asset-names.js +3 -0
- package/dist/external-tools/trufflehog/from-download.d.ts +1 -1
- package/dist/external-tools/trufflehog/resolve.d.ts +3 -0
- package/dist/external-tools/trufflehog/resolve.js +3 -0
- package/dist/external-tools/uv/asset-names.d.ts +36 -0
- package/dist/external-tools/uv/asset-names.js +73 -0
- package/dist/external-tools/uv/from-download.d.ts +17 -0
- package/dist/external-tools/uv/from-download.js +50 -0
- package/dist/external-tools/uv/from-path.d.ts +5 -0
- package/dist/external-tools/uv/from-path.js +22 -0
- package/dist/external-tools/uv/from-vfs.d.ts +7 -0
- package/dist/external-tools/uv/from-vfs.js +26 -0
- package/dist/external-tools/uv/resolve.d.ts +28 -0
- package/dist/external-tools/uv/resolve.js +64 -0
- package/dist/external-tools/uv/types.d.ts +24 -0
- package/dist/external-tools/uv/types.js +2 -0
- package/dist/fleet/repo-config.d.ts +55 -0
- package/dist/fleet/repo-config.js +81 -0
- package/dist/fs/_internal.d.ts +1 -1
- package/dist/fs/_internal.js +1 -1
- package/dist/fs/access.d.ts +2 -0
- package/dist/fs/access.js +2 -0
- package/dist/fs/copy.d.ts +88 -0
- package/dist/fs/copy.js +89 -0
- package/dist/fs/find.js +1 -2
- package/dist/fs/inspect.d.ts +2 -2
- package/dist/fs/read-file.js +3 -4
- package/dist/fs/safe.js +2 -2
- package/dist/git/_internal.js +7 -3
- package/dist/github/commit.d.ts +92 -0
- package/dist/github/commit.js +113 -0
- package/dist/github/ghsa.js +1 -1
- package/dist/github/refs-graphql.js +1 -1
- package/dist/github/refs.js +10 -15
- package/dist/github/request.js +1 -1
- package/dist/github/token.d.ts +5 -2
- package/dist/github/token.js +6 -4
- package/dist/github/workflow-runs.d.ts +107 -0
- package/dist/github/workflow-runs.js +98 -0
- package/dist/globs/_internal.js +1 -1
- package/dist/http-request/_internal.d.ts +1 -1
- package/dist/http-request/browser.d.ts +6 -0
- package/dist/http-request/browser.js +4 -3
- package/dist/http-request/checksum-file.js +1 -1
- package/dist/http-request/download.js +2 -0
- package/dist/http-request/headers.d.ts +1 -1
- package/dist/http-request/headers.js +2 -2
- package/dist/http-request/request-attempt.js +6 -3
- package/dist/http-request/request-types.d.ts +10 -1
- package/dist/http-request/request.js +2 -2
- package/dist/http-request/user-agent.d.ts +23 -2
- package/dist/http-request/user-agent.js +48 -6
- package/dist/integrity.d.ts +127 -78
- package/dist/integrity.js +170 -84
- package/dist/json/format.js +4 -1
- package/dist/logger/_internal.d.ts +13 -15
- package/dist/logger/_internal.js +21 -21
- package/dist/logger/colors.d.ts +10 -5
- package/dist/logger/colors.js +7 -14
- package/dist/logger/console-methods.js +2 -2
- package/dist/logger/console.d.ts +1 -0
- package/dist/logger/console.js +9 -9
- package/dist/logger/node.js +2 -1
- package/dist/logger/symbols-builder.js +7 -8
- package/dist/logger/symbols.js +8 -8
- package/dist/native-messaging/install.js +1 -1
- package/dist/native-messaging/rate-limit.d.ts +4 -1
- package/dist/native-messaging/rate-limit.js +4 -1
- package/dist/node/events.d.ts +3 -0
- package/dist/node/events.js +3 -0
- package/dist/node/fs.d.ts +1 -1
- package/dist/node/module.d.ts +73 -2
- package/dist/node/module.js +97 -12
- package/dist/node/timers-promises.d.ts +3 -0
- package/dist/node/timers-promises.js +3 -0
- package/dist/node/url.d.ts +3 -0
- package/dist/node/url.js +3 -0
- package/dist/npm/meta-cache.d.ts +183 -0
- package/dist/npm/meta-cache.js +318 -0
- package/dist/npm/meta-slice.d.ts +27 -0
- package/dist/npm/meta-slice.js +68 -0
- package/dist/npm/meta-types.d.ts +282 -0
- package/dist/npm/meta-types.js +2 -0
- package/dist/npm/meta.d.ts +125 -0
- package/dist/npm/meta.js +347 -0
- package/dist/npm/registry.d.ts +212 -0
- package/dist/npm/registry.js +284 -0
- package/dist/objects/getters.d.ts +1 -1
- package/dist/objects/getters.js +1 -1
- package/dist/objects/predicates.js +1 -1
- package/dist/packages/exports.js +2 -2
- package/dist/packages/isolation.js +1 -1
- package/dist/packages/manifest.d.ts +29 -0
- package/dist/packages/manifest.js +44 -9
- package/dist/packages/metadata-extensions.js +2 -4
- package/dist/packages/normalize.js +1 -1
- package/dist/packages/provenance.d.ts +8 -0
- package/dist/packages/provenance.js +10 -2
- package/dist/packages/specs.js +1 -1
- package/dist/packages/tarball.js +1 -2
- package/dist/packages/validation.d.ts +0 -10
- package/dist/packages/validation.js +0 -14
- package/dist/paths/_internal.d.ts +1 -7
- package/dist/paths/_internal.js +9 -15
- package/dist/paths/conversion.js +1 -1
- package/dist/paths/exts.d.ts +30 -0
- package/dist/paths/exts.js +30 -0
- package/dist/paths/filenames.d.ts +6 -0
- package/dist/paths/filenames.js +6 -0
- package/dist/paths/globs.d.ts +6 -0
- package/dist/paths/globs.js +6 -0
- package/dist/paths/normalize.js +1 -1
- package/dist/paths/predicates.js +2 -1
- package/dist/paths/resolve.js +19 -14
- package/dist/paths/socket.d.ts +81 -30
- package/dist/paths/socket.js +102 -28
- package/dist/perf/metrics.js +1 -1
- package/dist/perf/report.js +5 -3
- package/dist/pkg-ext/data.js +0 -2
- package/dist/primordials/globals.d.ts +1 -1
- package/dist/primordials/globals.js +1 -1
- package/dist/primordials/headers.d.ts +13 -1
- package/dist/primordials/headers.js +13 -1
- package/dist/primordials/process.d.ts +1 -1
- package/dist/primordials/process.js +1 -1
- package/dist/primordials/url.d.ts +18 -0
- package/dist/primordials/url.js +18 -0
- package/dist/process/spawn/child.js +3 -5
- package/dist/promises/_internal.d.ts +1 -1
- package/dist/promises/_internal.js +1 -2
- package/dist/promises/options.js +3 -3
- package/dist/regexps/spec.js +1 -1
- package/dist/releases/socket-btm-binary-naming.js +12 -1
- package/dist/schema/validate.js +1 -1
- package/dist/secrets/_internal.d.ts +1 -1
- package/dist/secrets/_internal.js +1 -1
- package/dist/secrets/broker.d.ts +35 -0
- package/dist/secrets/broker.js +72 -0
- package/dist/secrets/find.d.ts +8 -6
- package/dist/secrets/find.js +17 -3
- package/dist/secrets/keychain.d.ts +10 -1
- package/dist/secrets/keychain.js +10 -1
- package/dist/secrets/rc.js +1 -1
- package/dist/secrets/socket-api-token.d.ts +1 -1
- package/dist/secrets/socket-api-token.js +1 -1
- package/dist/secrets/types.d.ts +1 -1
- package/dist/smol/detect.js +1 -1
- package/dist/smol/http.d.ts +2 -0
- package/dist/smol/http.js +3 -1
- package/dist/smol/https.d.ts +2 -0
- package/dist/smol/https.js +3 -1
- package/dist/smol/manifest.js +1 -1
- package/dist/smol/path.js +1 -1
- package/dist/smol/primordial.js +1 -1
- package/dist/smol/purl.js +1 -1
- package/dist/smol/versions.js +1 -1
- package/dist/smol/vfs.js +1 -1
- package/dist/sorts/_internal.d.ts +2 -4
- package/dist/sorts/_internal.js +1 -7
- package/dist/sorts/semver.js +2 -2
- package/dist/spinner/create-spinner-class.js +1 -1
- package/dist/spinner/format.js +2 -4
- package/dist/stdio/footer.js +8 -7
- package/dist/stdio/progress.js +1 -1
- package/dist/stdio/prompts.d.ts +8 -23
- package/dist/stdio/prompts.js +28 -52
- package/dist/strings/format.js +1 -1
- package/dist/strings/predicates.d.ts +2 -2
- package/dist/strings/search.js +2 -2
- package/dist/strings/types.d.ts +4 -0
- package/dist/strings/width.d.ts +1 -0
- package/dist/strings/width.js +17 -8
- package/dist/themes/context.d.ts +18 -3
- package/dist/themes/context.js +28 -14
- package/dist/versions/_internal.d.ts +43 -13
- package/dist/versions/_internal.js +27 -15
- package/dist/versions/compare.d.ts +16 -10
- package/dist/versions/compare.js +36 -16
- package/dist/versions/parse.js +1 -1
- package/dist/versions/range.js +3 -2
- package/dist/words/pluralize.js +4 -1
- package/llms.txt +63 -0
- package/package.json +271 -40
package/dist/stdio/prompts.js
CHANGED
|
@@ -1,49 +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');
|
|
7
|
+
const require_logger_colors = require('../logger/colors.js');
|
|
8
8
|
const require_themes_resolve = require('../themes/resolve.js');
|
|
9
9
|
const require_spinner_default = require('../spinner/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
|
-
let src_external__inquirer_checkbox = require("../external/@inquirer/checkbox");
|
|
13
|
-
src_external__inquirer_checkbox = require_runtime.__toESM(src_external__inquirer_checkbox);
|
|
14
|
-
let src_external__inquirer_confirm = require("../external/@inquirer/confirm");
|
|
15
|
-
src_external__inquirer_confirm = require_runtime.__toESM(src_external__inquirer_confirm);
|
|
16
|
-
let src_external__inquirer_input = require("../external/@inquirer/input");
|
|
17
|
-
src_external__inquirer_input = require_runtime.__toESM(src_external__inquirer_input);
|
|
18
|
-
let src_external__inquirer_password = require("../external/@inquirer/password");
|
|
19
|
-
src_external__inquirer_password = require_runtime.__toESM(src_external__inquirer_password);
|
|
20
|
-
let src_external__inquirer_search = require("../external/@inquirer/search");
|
|
21
|
-
src_external__inquirer_search = require_runtime.__toESM(src_external__inquirer_search);
|
|
22
|
-
let src_external__inquirer_select = require("../external/@inquirer/select");
|
|
23
|
-
src_external__inquirer_select = require_runtime.__toESM(src_external__inquirer_select);
|
|
24
10
|
|
|
25
11
|
//#region src/stdio/prompts.ts
|
|
26
12
|
/**
|
|
27
13
|
* @file User prompt utilities for interactive scripts. Provides inquirer.js
|
|
28
14
|
* integration with spinner support, context handling, and theming.
|
|
29
15
|
*/
|
|
30
|
-
const abortSignal = require_process_abort.getAbortSignal();
|
|
31
|
-
const spinner = require_spinner_default.getDefaultSpinner();
|
|
32
|
-
const searchRaw = src_external__inquirer_search.default;
|
|
33
|
-
const selectModule = src_external__inquirer_select;
|
|
34
|
-
const selectRaw = selectModule.default;
|
|
35
|
-
const ActualSeparator = selectModule.Separator;
|
|
36
|
-
/**
|
|
37
|
-
* Apply a color to text using yoctocolors. Handles both named colors and RGB
|
|
38
|
-
* tuples.
|
|
39
|
-
*
|
|
40
|
-
* @private
|
|
41
|
-
*/
|
|
42
|
-
function applyColor(text, color) {
|
|
43
|
-
if (typeof color === "string") return src_external_yoctocolors_cjs.default[color](text);
|
|
44
|
-
const { 0: r, 1: g, 2: b } = color;
|
|
45
|
-
return `\u001B[38;2;${r};${g};${b}m${text}\u001B[39m`;
|
|
46
|
-
}
|
|
47
16
|
/**
|
|
48
17
|
* Convert Socket theme to @inquirer theme format. Maps our theme colors to
|
|
49
18
|
* inquirer's style functions. Handles theme names, Theme objects, and passes
|
|
@@ -75,18 +44,18 @@ function createInquirerTheme(theme) {
|
|
|
75
44
|
const primaryColor = socketTheme.colors.primary;
|
|
76
45
|
return {
|
|
77
46
|
style: {
|
|
78
|
-
message: (text) => applyColor(text, promptColor),
|
|
79
|
-
answer: (text) => applyColor(text, primaryColor),
|
|
80
|
-
help: (text) => applyColor(text, textDimColor),
|
|
81
|
-
description: (text) => applyColor(text, textDimColor),
|
|
82
|
-
disabled: (text) => applyColor(text, textDimColor),
|
|
83
|
-
error: (text) => applyColor(text, errorColor),
|
|
84
|
-
highlight: (text) => applyColor(text, primaryColor)
|
|
47
|
+
message: (text) => require_logger_colors.applyColor(text, promptColor),
|
|
48
|
+
answer: (text) => require_logger_colors.applyColor(text, primaryColor),
|
|
49
|
+
help: (text) => require_logger_colors.applyColor(text, textDimColor),
|
|
50
|
+
description: (text) => require_logger_colors.applyColor(text, textDimColor),
|
|
51
|
+
disabled: (text) => require_logger_colors.applyColor(text, textDimColor),
|
|
52
|
+
error: (text) => require_logger_colors.applyColor(text, errorColor),
|
|
53
|
+
highlight: (text) => require_logger_colors.applyColor(text, primaryColor)
|
|
85
54
|
},
|
|
86
55
|
icon: {
|
|
87
|
-
checked: applyColor("✓", successColor),
|
|
56
|
+
checked: require_logger_colors.applyColor("✓", successColor),
|
|
88
57
|
unchecked: " ",
|
|
89
|
-
cursor: applyColor("❯", primaryColor)
|
|
58
|
+
cursor: require_logger_colors.applyColor("❯", primaryColor)
|
|
90
59
|
}
|
|
91
60
|
};
|
|
92
61
|
}
|
|
@@ -114,7 +83,7 @@ function createInquirerTheme(theme) {
|
|
|
114
83
|
* @returns Separator instance
|
|
115
84
|
*/
|
|
116
85
|
function createSeparator(text) {
|
|
117
|
-
return new
|
|
86
|
+
return new (require("../external/@inquirer/select")).Separator(text);
|
|
118
87
|
}
|
|
119
88
|
/**
|
|
120
89
|
* Check if value is a Socket Theme object.
|
|
@@ -156,8 +125,8 @@ function wrapPrompt(inquirerPrompt) {
|
|
|
156
125
|
return async (...args) => {
|
|
157
126
|
const origContext = args.length > 1 ? args[1] : void 0;
|
|
158
127
|
const { spinner: contextSpinner, ...contextWithoutSpinner } = origContext ?? {};
|
|
159
|
-
const spinnerInstance = contextSpinner !== void 0 ? contextSpinner :
|
|
160
|
-
const signal =
|
|
128
|
+
const spinnerInstance = contextSpinner !== void 0 ? contextSpinner : require_spinner_default.getDefaultSpinner();
|
|
129
|
+
const signal = require_process_abort.getAbortSignal();
|
|
161
130
|
const config = args[0];
|
|
162
131
|
if (config && typeof config === "object") if (!config["theme"]) config["theme"] = createInquirerTheme(require_themes_context.getTheme());
|
|
163
132
|
else config["theme"] = createInquirerTheme(config["theme"]);
|
|
@@ -192,7 +161,7 @@ function wrapPrompt(inquirerPrompt) {
|
|
|
192
161
|
* ],
|
|
193
162
|
* })
|
|
194
163
|
*/
|
|
195
|
-
const checkbox = wrapPrompt(
|
|
164
|
+
const checkbox = wrapPrompt((...args) => require("../external/@inquirer/checkbox").default(...args));
|
|
196
165
|
/**
|
|
197
166
|
* Prompt for a yes/no confirmation. Wrapped with spinner handling and abort
|
|
198
167
|
* signal support.
|
|
@@ -201,7 +170,7 @@ const checkbox = wrapPrompt(src_external__inquirer_checkbox.default);
|
|
|
201
170
|
* const answer = await confirm({ message: 'Continue?' })
|
|
202
171
|
* if (answer) { // user confirmed }
|
|
203
172
|
*/
|
|
204
|
-
const confirm = wrapPrompt(
|
|
173
|
+
const confirm = wrapPrompt((...args) => require("../external/@inquirer/confirm").default(...args));
|
|
205
174
|
/**
|
|
206
175
|
* Prompt for text input. Wrapped with spinner handling and abort signal
|
|
207
176
|
* support. Result is automatically trimmed.
|
|
@@ -209,7 +178,7 @@ const confirm = wrapPrompt(src_external__inquirer_confirm.default);
|
|
|
209
178
|
* @example
|
|
210
179
|
* const name = await input({ message: 'Enter your name:' })
|
|
211
180
|
*/
|
|
212
|
-
const input = wrapPrompt(
|
|
181
|
+
const input = wrapPrompt((...args) => require("../external/@inquirer/input").default(...args));
|
|
213
182
|
/**
|
|
214
183
|
* Prompt for password input (hidden characters). Wrapped with spinner handling
|
|
215
184
|
* and abort signal support.
|
|
@@ -217,7 +186,7 @@ const input = wrapPrompt(src_external__inquirer_input.default);
|
|
|
217
186
|
* @example
|
|
218
187
|
* const token = await password({ message: 'Enter API token:' })
|
|
219
188
|
*/
|
|
220
|
-
const password = wrapPrompt(
|
|
189
|
+
const password = wrapPrompt((...args) => require("../external/@inquirer/password").default(...args));
|
|
221
190
|
/**
|
|
222
191
|
* Prompt with searchable/filterable choices. Wrapped with spinner handling and
|
|
223
192
|
* abort signal support.
|
|
@@ -228,7 +197,7 @@ const password = wrapPrompt(src_external__inquirer_password.default);
|
|
|
228
197
|
* source: async input => fetchPackages(input),
|
|
229
198
|
* })
|
|
230
199
|
*/
|
|
231
|
-
const search = wrapPrompt(
|
|
200
|
+
const search = wrapPrompt((...args) => require("../external/@inquirer/search").default(...args));
|
|
232
201
|
/**
|
|
233
202
|
* Prompt to select from a list of choices. Wrapped with spinner handling and
|
|
234
203
|
* abort signal support.
|
|
@@ -242,11 +211,18 @@ const search = wrapPrompt(searchRaw);
|
|
|
242
211
|
* ],
|
|
243
212
|
* })
|
|
244
213
|
*/
|
|
245
|
-
const select = wrapPrompt(
|
|
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
|
+
});
|
|
246
223
|
|
|
247
224
|
//#endregion
|
|
248
|
-
exports.Separator =
|
|
249
|
-
exports.applyColor = applyColor;
|
|
225
|
+
exports.Separator = Separator;
|
|
250
226
|
exports.checkbox = checkbox;
|
|
251
227
|
exports.confirm = confirm;
|
|
252
228
|
exports.createInquirerTheme = createInquirerTheme;
|
package/dist/strings/format.js
CHANGED
|
@@ -1,8 +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_primordials_math = require('../primordials/math.js');
|
|
5
4
|
const require_primordials_string = require('../primordials/string.js');
|
|
5
|
+
const require_primordials_math = require('../primordials/math.js');
|
|
6
6
|
const require_ansi_strip = require('../ansi/strip.js');
|
|
7
7
|
|
|
8
8
|
//#region src/strings/format.ts
|
|
@@ -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,
|
|
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
|
|
52
|
+
export declare function isNonEmptyString(value: unknown): value is NonEmptyString;
|
package/dist/strings/search.js
CHANGED
|
@@ -1,8 +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_primordials_math = require('../primordials/math.js');
|
|
5
4
|
const require_primordials_string = require('../primordials/string.js');
|
|
5
|
+
const require_primordials_math = require('../primordials/math.js');
|
|
6
6
|
|
|
7
7
|
//#region src/strings/search.ts
|
|
8
8
|
/**
|
|
@@ -43,7 +43,7 @@ function search(str, regexp, options) {
|
|
|
43
43
|
...options
|
|
44
44
|
};
|
|
45
45
|
const { length } = str;
|
|
46
|
-
if (fromIndex
|
|
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);
|
package/dist/strings/types.d.ts
CHANGED
|
@@ -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.
|
package/dist/strings/width.d.ts
CHANGED
|
@@ -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
|
*
|
package/dist/strings/width.js
CHANGED
|
@@ -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
|
-
|
|
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
|
|
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)
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
|
|
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
|
-
|
|
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;
|
package/dist/themes/context.d.ts
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
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
|
-
import
|
|
8
|
+
import { getNodeAsyncHooks } from '../node/async-hooks';
|
|
8
9
|
/**
|
|
9
10
|
* Theme change event listener signature.
|
|
10
11
|
*/
|
|
@@ -16,11 +17,13 @@ export type ThemeChangeListener = (theme: Theme) => void;
|
|
|
16
17
|
*/
|
|
17
18
|
export declare function emitThemeChange(theme: Theme): void;
|
|
18
19
|
/**
|
|
19
|
-
* Lazily load the async_hooks module
|
|
20
|
+
* Lazily load the async_hooks module. Aliases the canonical `node/async-hooks`
|
|
21
|
+
* accessor (single owner of the bundler-safe require); kept as an export so
|
|
22
|
+
* this module's surface is unchanged.
|
|
20
23
|
*
|
|
21
24
|
* @private
|
|
22
25
|
*/
|
|
23
|
-
export declare
|
|
26
|
+
export declare const getAsyncHooks: typeof getNodeAsyncHooks;
|
|
24
27
|
/**
|
|
25
28
|
* Get the active theme from context.
|
|
26
29
|
*
|
|
@@ -33,6 +36,18 @@ export declare function getAsyncHooks(): typeof AsyncHooks;
|
|
|
33
36
|
* @returns Current theme
|
|
34
37
|
*/
|
|
35
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>;
|
|
36
51
|
/**
|
|
37
52
|
* Subscribe to theme change events.
|
|
38
53
|
*
|
package/dist/themes/context.js
CHANGED
|
@@ -1,11 +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_node_async_hooks = require('../node/async-hooks.js');
|
|
4
5
|
const require_primordials_map_set = require('../primordials/map-set.js');
|
|
5
6
|
const require_themes_themes = require('./themes.js');
|
|
6
7
|
|
|
7
8
|
//#region src/themes/context.ts
|
|
8
|
-
let asyncHooks;
|
|
9
9
|
/**
|
|
10
10
|
* Emit theme change event to listeners.
|
|
11
11
|
*
|
|
@@ -15,19 +15,14 @@ function emitThemeChange(theme) {
|
|
|
15
15
|
for (const listener of listeners) listener(theme);
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
* Lazily load the async_hooks module
|
|
18
|
+
* Lazily load the async_hooks module. Aliases the canonical `node/async-hooks`
|
|
19
|
+
* accessor (single owner of the bundler-safe require); kept as an export so
|
|
20
|
+
* this module's surface is unchanged.
|
|
19
21
|
*
|
|
20
22
|
* @private
|
|
21
23
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return asyncHooks;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* AsyncLocalStorage for theme context isolation.
|
|
28
|
-
*/
|
|
29
|
-
const { AsyncLocalStorage } = getAsyncHooks();
|
|
30
|
-
const themeStorage = new AsyncLocalStorage();
|
|
24
|
+
const getAsyncHooks = require_node_async_hooks.getNodeAsyncHooks;
|
|
25
|
+
let themeStorage;
|
|
31
26
|
/**
|
|
32
27
|
* Fallback theme for global context.
|
|
33
28
|
*/
|
|
@@ -48,7 +43,25 @@ const listeners = new require_primordials_map_set.SetCtor();
|
|
|
48
43
|
* @returns Current theme
|
|
49
44
|
*/
|
|
50
45
|
function getTheme() {
|
|
51
|
-
return
|
|
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;
|
|
52
65
|
}
|
|
53
66
|
/**
|
|
54
67
|
* Subscribe to theme change events.
|
|
@@ -107,7 +120,7 @@ function setTheme(theme) {
|
|
|
107
120
|
*/
|
|
108
121
|
async function withTheme(theme, fn) {
|
|
109
122
|
const resolvedTheme = typeof theme === "string" ? require_themes_themes.THEMES[theme] ?? fallbackTheme : theme;
|
|
110
|
-
return await
|
|
123
|
+
return await getThemeStorage().run(resolvedTheme, async () => {
|
|
111
124
|
emitThemeChange(resolvedTheme);
|
|
112
125
|
return await fn();
|
|
113
126
|
});
|
|
@@ -132,7 +145,7 @@ async function withTheme(theme, fn) {
|
|
|
132
145
|
*/
|
|
133
146
|
function withThemeSync(theme, fn) {
|
|
134
147
|
const resolvedTheme = typeof theme === "string" ? require_themes_themes.THEMES[theme] ?? fallbackTheme : theme;
|
|
135
|
-
return
|
|
148
|
+
return getThemeStorage().run(resolvedTheme, () => {
|
|
136
149
|
emitThemeChange(resolvedTheme);
|
|
137
150
|
return fn();
|
|
138
151
|
});
|
|
@@ -142,6 +155,7 @@ function withThemeSync(theme, fn) {
|
|
|
142
155
|
exports.emitThemeChange = emitThemeChange;
|
|
143
156
|
exports.getAsyncHooks = getAsyncHooks;
|
|
144
157
|
exports.getTheme = getTheme;
|
|
158
|
+
exports.getThemeStorage = getThemeStorage;
|
|
145
159
|
exports.onThemeChange = onThemeChange;
|
|
146
160
|
exports.setTheme = setTheme;
|
|
147
161
|
exports.withTheme = withTheme;
|
|
@@ -1,24 +1,54 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file Private internals for `versions/*` modules —
|
|
3
|
-
* implementation at
|
|
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 `
|
|
8
|
-
* per-call branching. `getMajorVersion`-style helpers need the parsed
|
|
9
|
-
* shape (`{major, minor, patch}`) which only `semver.parse` exposes —
|
|
10
|
-
* leaves use `getSemver()` directly instead of going through
|
|
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
|
|
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`
|
|
16
|
-
*
|
|
17
|
-
*
|
|
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
|
|
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`.
|
|
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
|
|
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 —
|
|
9
|
-
* implementation at
|
|
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 `
|
|
14
|
-
* per-call branching. `getMajorVersion`-style helpers need the parsed
|
|
15
|
-
* shape (`{major, minor, patch}`) which only `semver.parse` exposes —
|
|
16
|
-
* leaves use `getSemver()` directly instead of going through
|
|
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
|
-
|
|
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.
|
|
35
|
-
exports.
|
|
46
|
+
exports.getImpl = getImpl;
|
|
47
|
+
exports.getSemver = getSemver;
|
|
@@ -14,7 +14,11 @@
|
|
|
14
14
|
* "invalid version" throw into `undefined` for the caller's convenience;
|
|
15
15
|
* all other ops surface whatever the underlying impl returns. The vendored
|
|
16
16
|
* `semver` export has no `neq` helper, so when we fall back to it we route
|
|
17
|
-
* `neq` through `!eq` to match smol's semantics.
|
|
17
|
+
* `neq` through `!eq` to match smol's semantics. Snapshot safety: each
|
|
18
|
+
* export is a thin forwarding function that resolves `getImpl()` at FIRST
|
|
19
|
+
* CALL, not at module-eval. Binding the impl methods at module load
|
|
20
|
+
* (`impl.eq.bind(impl)`) pinned the native-handle-bearing semver/npm-pack
|
|
21
|
+
* bundle into the heap and aborted `node --build-snapshot`.
|
|
18
22
|
*/
|
|
19
23
|
/**
|
|
20
24
|
* Compare two semantic version strings.
|
|
@@ -25,27 +29,29 @@ export declare function compare(a: string, b: string): -1 | 0 | 1 | undefined;
|
|
|
25
29
|
/**
|
|
26
30
|
* Check if a equals b.
|
|
27
31
|
*/
|
|
28
|
-
export declare
|
|
29
|
-
/**
|
|
30
|
-
* Check if a does not equal b.
|
|
31
|
-
*/
|
|
32
|
-
export declare const neq: (a: string, b: string) => boolean;
|
|
32
|
+
export declare function eq(a: string, b: string): boolean;
|
|
33
33
|
/**
|
|
34
34
|
* Check if a is greater than b.
|
|
35
35
|
*/
|
|
36
|
-
export declare
|
|
36
|
+
export declare function gt(a: string, b: string): boolean;
|
|
37
37
|
/**
|
|
38
38
|
* Check if a is greater than or equal to b.
|
|
39
39
|
*/
|
|
40
|
-
export declare
|
|
40
|
+
export declare function gte(a: string, b: string): boolean;
|
|
41
41
|
/**
|
|
42
42
|
* Check if a is less than b.
|
|
43
43
|
*/
|
|
44
|
-
export declare
|
|
44
|
+
export declare function lt(a: string, b: string): boolean;
|
|
45
45
|
/**
|
|
46
46
|
* Check if a is less than or equal to b.
|
|
47
47
|
*/
|
|
48
|
-
export declare
|
|
48
|
+
export declare function lte(a: string, b: string): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Check if a does not equal b. The vendored `semver` export exposes no `neq`
|
|
51
|
+
* helper, so on the fallback path we route through `!eq` to match smol's
|
|
52
|
+
* semantics; smol-versions has a native `.neq` and uses it directly.
|
|
53
|
+
*/
|
|
54
|
+
export declare function neq(a: string, b: string): boolean;
|
|
49
55
|
/**
|
|
50
56
|
* Sort versions in descending order.
|
|
51
57
|
*/
|