@socketsecurity/lib 0.0.0 → 1.0.0
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 +270 -0
- package/LICENSE +21 -0
- package/README.md +80 -2
- package/data/extensions.json +28 -0
- package/dist/abort.d.ts +11 -0
- package/dist/abort.js +62 -0
- package/dist/abort.js.map +7 -0
- package/dist/agent.d.ts +102 -0
- package/dist/agent.js +288 -0
- package/dist/agent.js.map +7 -0
- package/dist/ansi.d.ts +29 -0
- package/dist/ansi.js +62 -0
- package/dist/ansi.js.map +7 -0
- package/dist/argv/flags.d.ts +199 -0
- package/dist/argv/flags.js +284 -0
- package/dist/argv/flags.js.map +7 -0
- package/dist/argv/parse.d.ts +76 -0
- package/dist/argv/parse.js +173 -0
- package/dist/argv/parse.js.map +7 -0
- package/dist/arrays.d.ts +29 -0
- package/dist/arrays.js +87 -0
- package/dist/arrays.js.map +7 -0
- package/dist/bin.d.ts +50 -0
- package/dist/bin.js +405 -0
- package/dist/bin.js.map +7 -0
- package/dist/cacache.d.ts +86 -0
- package/dist/cacache.js +140 -0
- package/dist/cacache.js.map +7 -0
- package/dist/cache-with-ttl.d.ts +133 -0
- package/dist/cache-with-ttl.js +225 -0
- package/dist/cache-with-ttl.js.map +7 -0
- package/dist/constants/agents.d.ts +37 -0
- package/dist/constants/agents.js +128 -0
- package/dist/constants/agents.js.map +7 -0
- package/dist/constants/core.d.ts +22 -0
- package/dist/constants/core.js +59 -0
- package/dist/constants/core.js.map +7 -0
- package/dist/constants/encoding.d.ts +13 -0
- package/dist/constants/encoding.js +50 -0
- package/dist/constants/encoding.js.map +7 -0
- package/dist/constants/github.d.ts +7 -0
- package/dist/constants/github.js +32 -0
- package/dist/constants/github.js.map +7 -0
- package/dist/constants/licenses.d.ts +8 -0
- package/dist/constants/licenses.js +68 -0
- package/dist/constants/licenses.js.map +7 -0
- package/dist/constants/node.d.ts +29 -0
- package/dist/constants/node.js +173 -0
- package/dist/constants/node.js.map +7 -0
- package/dist/constants/packages.d.ts +19 -0
- package/dist/constants/packages.js +130 -0
- package/dist/constants/packages.js.map +7 -0
- package/dist/constants/paths.d.ts +51 -0
- package/dist/constants/paths.js +152 -0
- package/dist/constants/paths.js.map +7 -0
- package/dist/constants/platform.d.ts +6 -0
- package/dist/constants/platform.js +43 -0
- package/dist/constants/platform.js.map +7 -0
- package/dist/constants/process.d.ts +7 -0
- package/dist/constants/process.js +54 -0
- package/dist/constants/process.js.map +7 -0
- package/dist/constants/socket.d.ts +29 -0
- package/dist/constants/socket.js +83 -0
- package/dist/constants/socket.js.map +7 -0
- package/dist/constants/testing.d.ts +9 -0
- package/dist/constants/testing.js +38 -0
- package/dist/constants/testing.js.map +7 -0
- package/dist/constants/time.d.ts +11 -0
- package/dist/constants/time.js +41 -0
- package/dist/constants/time.js.map +7 -0
- package/dist/constants/typescript.d.ts +6 -0
- package/dist/constants/typescript.js +56 -0
- package/dist/constants/typescript.js.map +7 -0
- package/dist/cover/code.d.ts +8 -0
- package/dist/cover/code.js +137 -0
- package/dist/cover/code.js.map +7 -0
- package/dist/cover/formatters.d.ts +9 -0
- package/dist/cover/formatters.js +103 -0
- package/dist/cover/formatters.js.map +7 -0
- package/dist/cover/type.d.ts +7 -0
- package/dist/cover/type.js +65 -0
- package/dist/cover/type.js.map +7 -0
- package/dist/cover/types.d.ts +70 -0
- package/dist/cover/types.js +17 -0
- package/dist/cover/types.js.map +7 -0
- package/dist/debug.d.ts +99 -0
- package/dist/debug.js +345 -0
- package/dist/debug.js.map +7 -0
- package/dist/dlx-binary.d.ts +49 -0
- package/dist/dlx-binary.js +261 -0
- package/dist/dlx-binary.js.map +7 -0
- package/dist/dlx.d.ts +64 -0
- package/dist/dlx.js +168 -0
- package/dist/dlx.js.map +7 -0
- package/dist/download-lock.d.ts +48 -0
- package/dist/download-lock.js +139 -0
- package/dist/download-lock.js.map +7 -0
- package/dist/effects/pulse-frames.d.ts +23 -0
- package/dist/effects/pulse-frames.js +66 -0
- package/dist/effects/pulse-frames.js.map +7 -0
- package/dist/effects/text-shimmer.d.ts +37 -0
- package/dist/effects/text-shimmer.js +175 -0
- package/dist/effects/text-shimmer.js.map +7 -0
- package/dist/effects/types.d.ts +41 -0
- package/dist/effects/types.js +17 -0
- package/dist/effects/types.js.map +7 -0
- package/dist/effects/ultra.d.ts +16 -0
- package/dist/effects/ultra.js +63 -0
- package/dist/effects/ultra.js.map +7 -0
- package/dist/env/appdata.d.ts +1 -0
- package/dist/env/appdata.js +30 -0
- package/dist/env/appdata.js.map +7 -0
- package/dist/env/ci.d.ts +1 -0
- package/dist/env/ci.js +31 -0
- package/dist/env/ci.js.map +7 -0
- package/dist/env/comspec.d.ts +1 -0
- package/dist/env/comspec.js +30 -0
- package/dist/env/comspec.js.map +7 -0
- package/dist/env/debug.d.ts +1 -0
- package/dist/env/debug.js +30 -0
- package/dist/env/debug.js.map +7 -0
- package/dist/env/getters.d.ts +40 -0
- package/dist/env/getters.js +283 -0
- package/dist/env/getters.js.map +7 -0
- package/dist/env/github-api-url.d.ts +1 -0
- package/dist/env/github-api-url.js +30 -0
- package/dist/env/github-api-url.js.map +7 -0
- package/dist/env/github-base-ref.d.ts +1 -0
- package/dist/env/github-base-ref.js +30 -0
- package/dist/env/github-base-ref.js.map +7 -0
- package/dist/env/github-ref-name.d.ts +1 -0
- package/dist/env/github-ref-name.js +30 -0
- package/dist/env/github-ref-name.js.map +7 -0
- package/dist/env/github-ref-type.d.ts +1 -0
- package/dist/env/github-ref-type.js +30 -0
- package/dist/env/github-ref-type.js.map +7 -0
- package/dist/env/github-repository.d.ts +1 -0
- package/dist/env/github-repository.js +30 -0
- package/dist/env/github-repository.js.map +7 -0
- package/dist/env/github-server-url.d.ts +1 -0
- package/dist/env/github-server-url.js +30 -0
- package/dist/env/github-server-url.js.map +7 -0
- package/dist/env/github-token.d.ts +1 -0
- package/dist/env/github-token.js +30 -0
- package/dist/env/github-token.js.map +7 -0
- package/dist/env/helpers.d.ts +6 -0
- package/dist/env/helpers.js +49 -0
- package/dist/env/helpers.js.map +7 -0
- package/dist/env/home.d.ts +1 -0
- package/dist/env/home.js +30 -0
- package/dist/env/home.js.map +7 -0
- package/dist/env/jest-worker-id.d.ts +1 -0
- package/dist/env/jest-worker-id.js +30 -0
- package/dist/env/jest-worker-id.js.map +7 -0
- package/dist/env/lang.d.ts +1 -0
- package/dist/env/lang.js +30 -0
- package/dist/env/lang.js.map +7 -0
- package/dist/env/lc-all.d.ts +1 -0
- package/dist/env/lc-all.js +30 -0
- package/dist/env/lc-all.js.map +7 -0
- package/dist/env/lc-messages.d.ts +1 -0
- package/dist/env/lc-messages.js +30 -0
- package/dist/env/lc-messages.js.map +7 -0
- package/dist/env/localappdata.d.ts +1 -0
- package/dist/env/localappdata.js +30 -0
- package/dist/env/localappdata.js.map +7 -0
- package/dist/env/node-auth-token.d.ts +1 -0
- package/dist/env/node-auth-token.js +30 -0
- package/dist/env/node-auth-token.js.map +7 -0
- package/dist/env/node-env.d.ts +1 -0
- package/dist/env/node-env.js +30 -0
- package/dist/env/node-env.js.map +7 -0
- package/dist/env/npm-config-registry.d.ts +1 -0
- package/dist/env/npm-config-registry.js +30 -0
- package/dist/env/npm-config-registry.js.map +7 -0
- package/dist/env/npm-config-user-agent.d.ts +1 -0
- package/dist/env/npm-config-user-agent.js +30 -0
- package/dist/env/npm-config-user-agent.js.map +7 -0
- package/dist/env/npm-lifecycle-event.d.ts +1 -0
- package/dist/env/npm-lifecycle-event.js +30 -0
- package/dist/env/npm-lifecycle-event.js.map +7 -0
- package/dist/env/npm-registry.d.ts +1 -0
- package/dist/env/npm-registry.js +30 -0
- package/dist/env/npm-registry.js.map +7 -0
- package/dist/env/npm-token.d.ts +1 -0
- package/dist/env/npm-token.js +30 -0
- package/dist/env/npm-token.js.map +7 -0
- package/dist/env/path.d.ts +1 -0
- package/dist/env/path.js +30 -0
- package/dist/env/path.js.map +7 -0
- package/dist/env/pre-commit.d.ts +1 -0
- package/dist/env/pre-commit.js +31 -0
- package/dist/env/pre-commit.js.map +7 -0
- package/dist/env/shell.d.ts +1 -0
- package/dist/env/shell.js +30 -0
- package/dist/env/shell.js.map +7 -0
- package/dist/env/socket-accept-risks.d.ts +1 -0
- package/dist/env/socket-accept-risks.js +31 -0
- package/dist/env/socket-accept-risks.js.map +7 -0
- package/dist/env/socket-api-base-url.d.ts +1 -0
- package/dist/env/socket-api-base-url.js +30 -0
- package/dist/env/socket-api-base-url.js.map +7 -0
- package/dist/env/socket-api-proxy.d.ts +1 -0
- package/dist/env/socket-api-proxy.js +30 -0
- package/dist/env/socket-api-proxy.js.map +7 -0
- package/dist/env/socket-api-timeout.d.ts +1 -0
- package/dist/env/socket-api-timeout.js +31 -0
- package/dist/env/socket-api-timeout.js.map +7 -0
- package/dist/env/socket-api-token.d.ts +1 -0
- package/dist/env/socket-api-token.js +30 -0
- package/dist/env/socket-api-token.js.map +7 -0
- package/dist/env/socket-cacache-dir.d.ts +1 -0
- package/dist/env/socket-cacache-dir.js +30 -0
- package/dist/env/socket-cacache-dir.js.map +7 -0
- package/dist/env/socket-cli-accept-risks.d.ts +1 -0
- package/dist/env/socket-cli-accept-risks.js +33 -0
- package/dist/env/socket-cli-accept-risks.js.map +7 -0
- package/dist/env/socket-cli-api-base-url.d.ts +1 -0
- package/dist/env/socket-cli-api-base-url.js +30 -0
- package/dist/env/socket-cli-api-base-url.js.map +7 -0
- package/dist/env/socket-cli-api-proxy.d.ts +1 -0
- package/dist/env/socket-cli-api-proxy.js +30 -0
- package/dist/env/socket-cli-api-proxy.js.map +7 -0
- package/dist/env/socket-cli-api-timeout.d.ts +1 -0
- package/dist/env/socket-cli-api-timeout.js +31 -0
- package/dist/env/socket-cli-api-timeout.js.map +7 -0
- package/dist/env/socket-cli-api-token.d.ts +1 -0
- package/dist/env/socket-cli-api-token.js +30 -0
- package/dist/env/socket-cli-api-token.js.map +7 -0
- package/dist/env/socket-cli-config.d.ts +1 -0
- package/dist/env/socket-cli-config.js +30 -0
- package/dist/env/socket-cli-config.js.map +7 -0
- package/dist/env/socket-cli-fix.d.ts +1 -0
- package/dist/env/socket-cli-fix.js +30 -0
- package/dist/env/socket-cli-fix.js.map +7 -0
- package/dist/env/socket-cli-no-api-token.d.ts +1 -0
- package/dist/env/socket-cli-no-api-token.js +33 -0
- package/dist/env/socket-cli-no-api-token.js.map +7 -0
- package/dist/env/socket-cli-optimize.d.ts +1 -0
- package/dist/env/socket-cli-optimize.js +31 -0
- package/dist/env/socket-cli-optimize.js.map +7 -0
- package/dist/env/socket-cli-org-slug.d.ts +1 -0
- package/dist/env/socket-cli-org-slug.js +30 -0
- package/dist/env/socket-cli-org-slug.js.map +7 -0
- package/dist/env/socket-cli-shadow-accept-risks.d.ts +1 -0
- package/dist/env/socket-cli-shadow-accept-risks.js +33 -0
- package/dist/env/socket-cli-shadow-accept-risks.js.map +7 -0
- package/dist/env/socket-cli-shadow-api-token.d.ts +1 -0
- package/dist/env/socket-cli-shadow-api-token.js +30 -0
- package/dist/env/socket-cli-shadow-api-token.js.map +7 -0
- package/dist/env/socket-cli-shadow-bin.d.ts +1 -0
- package/dist/env/socket-cli-shadow-bin.js +30 -0
- package/dist/env/socket-cli-shadow-bin.js.map +7 -0
- package/dist/env/socket-cli-shadow-progress.d.ts +1 -0
- package/dist/env/socket-cli-shadow-progress.js +33 -0
- package/dist/env/socket-cli-shadow-progress.js.map +7 -0
- package/dist/env/socket-cli-shadow-silent.d.ts +1 -0
- package/dist/env/socket-cli-shadow-silent.js +33 -0
- package/dist/env/socket-cli-shadow-silent.js.map +7 -0
- package/dist/env/socket-cli-view-all-risks.d.ts +1 -0
- package/dist/env/socket-cli-view-all-risks.js +33 -0
- package/dist/env/socket-cli-view-all-risks.js.map +7 -0
- package/dist/env/socket-config.d.ts +1 -0
- package/dist/env/socket-config.js +30 -0
- package/dist/env/socket-config.js.map +7 -0
- package/dist/env/socket-debug.d.ts +1 -0
- package/dist/env/socket-debug.js +30 -0
- package/dist/env/socket-debug.js.map +7 -0
- package/dist/env/socket-home.d.ts +1 -0
- package/dist/env/socket-home.js +30 -0
- package/dist/env/socket-home.js.map +7 -0
- package/dist/env/socket-no-api-token.d.ts +1 -0
- package/dist/env/socket-no-api-token.js +31 -0
- package/dist/env/socket-no-api-token.js.map +7 -0
- package/dist/env/socket-npm-registry.d.ts +1 -0
- package/dist/env/socket-npm-registry.js +30 -0
- package/dist/env/socket-npm-registry.js.map +7 -0
- package/dist/env/socket-org-slug.d.ts +1 -0
- package/dist/env/socket-org-slug.js +30 -0
- package/dist/env/socket-org-slug.js.map +7 -0
- package/dist/env/socket-registry-url.d.ts +1 -0
- package/dist/env/socket-registry-url.js +30 -0
- package/dist/env/socket-registry-url.js.map +7 -0
- package/dist/env/socket-view-all-risks.d.ts +1 -0
- package/dist/env/socket-view-all-risks.js +31 -0
- package/dist/env/socket-view-all-risks.js.map +7 -0
- package/dist/env/temp.d.ts +1 -0
- package/dist/env/temp.js +30 -0
- package/dist/env/temp.js.map +7 -0
- package/dist/env/term.d.ts +1 -0
- package/dist/env/term.js +30 -0
- package/dist/env/term.js.map +7 -0
- package/dist/env/tmp.d.ts +1 -0
- package/dist/env/tmp.js +30 -0
- package/dist/env/tmp.js.map +7 -0
- package/dist/env/tmpdir.d.ts +1 -0
- package/dist/env/tmpdir.js +30 -0
- package/dist/env/tmpdir.js.map +7 -0
- package/dist/env/userprofile.d.ts +1 -0
- package/dist/env/userprofile.js +30 -0
- package/dist/env/userprofile.js.map +7 -0
- package/dist/env/vitest.d.ts +1 -0
- package/dist/env/vitest.js +31 -0
- package/dist/env/vitest.js.map +7 -0
- package/dist/env/xdg-cache-home.d.ts +1 -0
- package/dist/env/xdg-cache-home.js +30 -0
- package/dist/env/xdg-cache-home.js.map +7 -0
- package/dist/env/xdg-config-home.d.ts +1 -0
- package/dist/env/xdg-config-home.js +30 -0
- package/dist/env/xdg-config-home.js.map +7 -0
- package/dist/env/xdg-data-home.d.ts +1 -0
- package/dist/env/xdg-data-home.js +30 -0
- package/dist/env/xdg-data-home.js.map +7 -0
- package/dist/env.d.ts +15 -0
- package/dist/env.js +63 -0
- package/dist/env.js.map +7 -0
- package/dist/external/@inquirer/checkbox.js +4 -0
- package/dist/external/@inquirer/confirm.js +22 -0
- package/dist/external/@inquirer/core.js +4 -0
- package/dist/external/@inquirer/input.js +1 -0
- package/dist/external/@inquirer/password.js +1 -0
- package/dist/external/@inquirer/prompts.js +4 -0
- package/dist/external/@inquirer/search.js +1 -0
- package/dist/external/@inquirer/select.js +25 -0
- package/dist/external/@npmcli/package-json/index.js +1 -0
- package/dist/external/@npmcli/package-json/lib/read-package.js +1 -0
- package/dist/external/@npmcli/package-json/lib/sort.js +1 -0
- package/dist/external/@npmcli/promise-spawn.js +5 -0
- package/dist/external/@socketregistry/is-unicode-supported.d.ts +2 -0
- package/dist/external/@socketregistry/is-unicode-supported.js +5 -0
- package/dist/external/@socketregistry/packageurl-js.js +34 -0
- package/dist/external/@socketregistry/yocto-spinner.d.ts +12 -0
- package/dist/external/@socketregistry/yocto-spinner.js +8 -0
- package/dist/external/@yarnpkg/extensions.d.ts +5 -0
- package/dist/external/@yarnpkg/extensions.js +5 -0
- package/dist/external/cacache.d.ts +93 -0
- package/dist/external/cacache.js +32 -0
- package/dist/external/debug.d.ts +25 -0
- package/dist/external/debug.js +9 -0
- package/dist/external/del.d.ts +1 -0
- package/dist/external/del.js +54 -0
- package/dist/external/fast-glob.js +54 -0
- package/dist/external/fast-sort.d.ts +4 -0
- package/dist/external/fast-sort.js +5 -0
- package/dist/external/get-east-asian-width.d.ts +5 -0
- package/dist/external/get-east-asian-width.js +5 -0
- package/dist/external/libnpmpack.d.ts +3 -0
- package/dist/external/libnpmpack.js +225 -0
- package/dist/external/make-fetch-happen.d.ts +16 -0
- package/dist/external/make-fetch-happen.js +69 -0
- package/dist/external/normalize-package-data.js +6 -0
- package/dist/external/npm-package-arg.js +6 -0
- package/dist/external/pacote.d.ts +19 -0
- package/dist/external/pacote.js +105 -0
- package/dist/external/picomatch.js +5 -0
- package/dist/external/semver.d.ts +3 -0
- package/dist/external/semver.js +5 -0
- package/dist/external/spdx-correct.js +5 -0
- package/dist/external/spdx-expression-parse.js +5 -0
- package/dist/external/streaming-iterables.js +5 -0
- package/dist/external/validate-npm-package-name.js +5 -0
- package/dist/external/which.js +5 -0
- package/dist/external/yargs-parser.d.ts +3 -0
- package/dist/external/yargs-parser.js +26 -0
- package/dist/external/yoctocolors-cjs.d.ts +38 -0
- package/dist/external/yoctocolors-cjs.js +5 -0
- package/dist/external/zod.d.ts +1 -0
- package/dist/external/zod.js +27 -0
- package/dist/fs.d.ts +184 -0
- package/dist/fs.js +610 -0
- package/dist/fs.js.map +7 -0
- package/dist/functions.d.ts +27 -0
- package/dist/functions.js +70 -0
- package/dist/functions.js.map +7 -0
- package/dist/git.d.ts +93 -0
- package/dist/git.js +321 -0
- package/dist/git.js.map +7 -0
- package/dist/github.d.ts +121 -0
- package/dist/github.js +203 -0
- package/dist/github.js.map +7 -0
- package/dist/globs.d.ts +46 -0
- package/dist/globs.js +154 -0
- package/dist/globs.js.map +7 -0
- package/dist/http-request.d.ts +53 -0
- package/dist/http-request.js +315 -0
- package/dist/http-request.js.map +7 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +64 -0
- package/dist/index.js.map +7 -0
- package/dist/ipc.d.ts +366 -0
- package/dist/ipc.js +234 -0
- package/dist/ipc.js.map +7 -0
- package/dist/json.d.ts +23 -0
- package/dist/json.js +75 -0
- package/dist/json.js.map +7 -0
- package/dist/logger.d.ts +183 -0
- package/dist/logger.js +653 -0
- package/dist/logger.js.map +7 -0
- package/dist/maintained-node-versions.d.ts +7 -0
- package/dist/maintained-node-versions.js +37 -0
- package/dist/maintained-node-versions.js.map +7 -0
- package/dist/memoization.d.ts +142 -0
- package/dist/memoization.js +212 -0
- package/dist/memoization.js.map +7 -0
- package/dist/objects.d.ts +146 -0
- package/dist/objects.js +321 -0
- package/dist/objects.js.map +7 -0
- package/dist/packages/editable.d.ts +107 -0
- package/dist/packages/editable.js +358 -0
- package/dist/packages/editable.js.map +7 -0
- package/dist/packages/exports.d.ts +30 -0
- package/dist/packages/exports.js +164 -0
- package/dist/packages/exports.js.map +7 -0
- package/dist/packages/isolation.d.ts +22 -0
- package/dist/packages/isolation.js +197 -0
- package/dist/packages/isolation.js.map +7 -0
- package/dist/packages/licenses.d.ts +68 -0
- package/dist/packages/licenses.js +216 -0
- package/dist/packages/licenses.js.map +7 -0
- package/dist/packages/manifest.d.ts +16 -0
- package/dist/packages/manifest.js +192 -0
- package/dist/packages/manifest.js.map +7 -0
- package/dist/packages/normalize.d.ts +21 -0
- package/dist/packages/normalize.js +122 -0
- package/dist/packages/normalize.js.map +7 -0
- package/dist/packages/operations.d.ts +54 -0
- package/dist/packages/operations.js +306 -0
- package/dist/packages/operations.js.map +7 -0
- package/dist/packages/paths.d.ts +10 -0
- package/dist/packages/paths.js +55 -0
- package/dist/packages/paths.js.map +7 -0
- package/dist/packages/provenance.d.ts +10 -0
- package/dist/packages/provenance.js +180 -0
- package/dist/packages/provenance.js.map +7 -0
- package/dist/packages/registry.d.ts +8 -0
- package/dist/packages/registry.js +30 -0
- package/dist/packages/registry.js.map +7 -0
- package/dist/packages/specs.d.ts +28 -0
- package/dist/packages/specs.js +85 -0
- package/dist/packages/specs.js.map +7 -0
- package/dist/packages/validation.d.ts +15 -0
- package/dist/packages/validation.js +53 -0
- package/dist/packages/validation.js.map +7 -0
- package/dist/packages.d.ts +154 -0
- package/dist/packages.js +131 -0
- package/dist/packages.js.map +7 -0
- package/dist/path.d.ts +74 -0
- package/dist/path.js +442 -0
- package/dist/path.js.map +7 -0
- package/dist/paths.d.ts +42 -0
- package/dist/paths.js +145 -0
- package/dist/paths.js.map +7 -0
- package/dist/performance.d.ts +178 -0
- package/dist/performance.js +219 -0
- package/dist/performance.js.map +7 -0
- package/dist/promise-queue.d.ts +35 -0
- package/dist/promise-queue.js +111 -0
- package/dist/promise-queue.js.map +7 -0
- package/dist/promises.d.ts +67 -0
- package/dist/promises.js +268 -0
- package/dist/promises.js.map +7 -0
- package/dist/prompts.d.ts +27 -0
- package/dist/prompts.js +60 -0
- package/dist/prompts.js.map +7 -0
- package/dist/regexps.d.ts +13 -0
- package/dist/regexps.js +32 -0
- package/dist/regexps.js.map +7 -0
- package/dist/sea.d.ts +10 -0
- package/dist/sea.js +46 -0
- package/dist/sea.js.map +7 -0
- package/dist/shadow.d.ts +17 -0
- package/dist/shadow.js +60 -0
- package/dist/shadow.js.map +7 -0
- package/dist/signal-exit.d.ts +23 -0
- package/dist/signal-exit.js +250 -0
- package/dist/signal-exit.js.map +7 -0
- package/dist/sorts.d.ts +28 -0
- package/dist/sorts.js +96 -0
- package/dist/sorts.js.map +7 -0
- package/dist/spawn.d.ts +207 -0
- package/dist/spawn.js +201 -0
- package/dist/spawn.js.map +7 -0
- package/dist/spinner.d.ts +208 -0
- package/dist/spinner.js +729 -0
- package/dist/spinner.js.map +7 -0
- package/dist/ssri.d.ts +95 -0
- package/dist/ssri.js +73 -0
- package/dist/ssri.js.map +7 -0
- package/dist/stdio/clear.d.ts +40 -0
- package/dist/stdio/clear.js +84 -0
- package/dist/stdio/clear.js.map +7 -0
- package/dist/stdio/divider.d.ts +48 -0
- package/dist/stdio/divider.js +81 -0
- package/dist/stdio/divider.js.map +7 -0
- package/dist/stdio/footer.d.ts +25 -0
- package/dist/stdio/footer.js +96 -0
- package/dist/stdio/footer.js.map +7 -0
- package/dist/stdio/header.d.ts +25 -0
- package/dist/stdio/header.js +102 -0
- package/dist/stdio/header.js.map +7 -0
- package/dist/stdio/mask.d.ts +72 -0
- package/dist/stdio/mask.js +187 -0
- package/dist/stdio/mask.js.map +7 -0
- package/dist/stdio/progress.d.ts +51 -0
- package/dist/stdio/progress.js +171 -0
- package/dist/stdio/progress.js.map +7 -0
- package/dist/stdio/prompts.d.ts +46 -0
- package/dist/stdio/prompts.js +90 -0
- package/dist/stdio/prompts.js.map +7 -0
- package/dist/stdio/stderr.d.ts +48 -0
- package/dist/stdio/stderr.js +91 -0
- package/dist/stdio/stderr.js.map +7 -0
- package/dist/stdio/stdout.d.ts +48 -0
- package/dist/stdio/stdout.js +105 -0
- package/dist/stdio/stdout.js.map +7 -0
- package/dist/streams.d.ts +20 -0
- package/dist/streams.js +80 -0
- package/dist/streams.js.map +7 -0
- package/dist/strings.d.ts +139 -0
- package/dist/strings.js +253 -0
- package/dist/strings.js.map +7 -0
- package/dist/suppress-warnings.d.ts +66 -0
- package/dist/suppress-warnings.js +100 -0
- package/dist/suppress-warnings.js.map +7 -0
- package/dist/tables.d.ts +69 -0
- package/dist/tables.js +130 -0
- package/dist/tables.js.map +7 -0
- package/dist/temporary-executor.d.ts +9 -0
- package/dist/temporary-executor.js +54 -0
- package/dist/temporary-executor.js.map +7 -0
- package/dist/types.d.ts +65 -0
- package/dist/types.js +74 -0
- package/dist/types.js.map +7 -0
- package/dist/url.d.ts +60 -0
- package/dist/url.js +144 -0
- package/dist/url.js.map +7 -0
- package/dist/utils/get-ipc.d.ts +16 -0
- package/dist/utils/get-ipc.js +60 -0
- package/dist/utils/get-ipc.js.map +7 -0
- package/dist/validation/json-parser.d.ts +10 -0
- package/dist/validation/json-parser.js +129 -0
- package/dist/validation/json-parser.js.map +7 -0
- package/dist/validation/types.d.ts +40 -0
- package/dist/validation/types.js +17 -0
- package/dist/validation/types.js.map +7 -0
- package/dist/versions.d.ts +87 -0
- package/dist/versions.js +155 -0
- package/dist/versions.js.map +7 -0
- package/dist/words.d.ts +22 -0
- package/dist/words.js +52 -0
- package/dist/words.js.map +7 -0
- package/dist/zod.d.ts +5 -0
- package/dist/zod.js +29 -0
- package/dist/zod.js.map +7 -0
- package/package.json +856 -7
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Stream processing utilities with streaming-iterables integration.
|
|
3
|
+
* Provides async stream handling and transformation functions.
|
|
4
|
+
*/
|
|
5
|
+
import type { IterationOptions } from './promises';
|
|
6
|
+
/**
|
|
7
|
+
* Execute a function for each item in an iterable in parallel.
|
|
8
|
+
*/
|
|
9
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
10
|
+
export declare function parallelEach<T>(iterable: Iterable<T> | AsyncIterable<T>, func: (item: T) => Promise<unknown>, options?: number | IterationOptions): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Map over an iterable in parallel with concurrency control.
|
|
13
|
+
*/
|
|
14
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
15
|
+
export declare function parallelMap<T, U>(iterable: Iterable<T> | AsyncIterable<T>, func: (item: T) => Promise<U>, options?: number | IterationOptions): AsyncIterable<U>;
|
|
16
|
+
/**
|
|
17
|
+
* Transform an iterable with a function.
|
|
18
|
+
*/
|
|
19
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
20
|
+
export declare function transform<T, U>(iterable: Iterable<T> | AsyncIterable<T>, func: (item: T) => Promise<U>, options?: number | IterationOptions): AsyncIterable<U>;
|
package/dist/streams.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/* Socket Lib - Built with esbuild */
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var streams_exports = {};
|
|
20
|
+
__export(streams_exports, {
|
|
21
|
+
parallelEach: () => parallelEach,
|
|
22
|
+
parallelMap: () => parallelMap,
|
|
23
|
+
transform: () => transform
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(streams_exports);
|
|
26
|
+
var import_promises = require("./promises");
|
|
27
|
+
let _streamingIterables;
|
|
28
|
+
// @__NO_SIDE_EFFECTS__
|
|
29
|
+
function getStreamingIterables() {
|
|
30
|
+
if (_streamingIterables === void 0) {
|
|
31
|
+
_streamingIterables = require("../external/streaming-iterables");
|
|
32
|
+
}
|
|
33
|
+
return _streamingIterables;
|
|
34
|
+
}
|
|
35
|
+
// @__NO_SIDE_EFFECTS__
|
|
36
|
+
async function parallelEach(iterable, func, options) {
|
|
37
|
+
for await (const _ of /* @__PURE__ */ parallelMap(iterable, func, options)) {
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// @__NO_SIDE_EFFECTS__
|
|
41
|
+
function parallelMap(iterable, func, options) {
|
|
42
|
+
const streamingIterables = /* @__PURE__ */ getStreamingIterables();
|
|
43
|
+
const opts = (0, import_promises.normalizeIterationOptions)(options);
|
|
44
|
+
const result = streamingIterables?.parallelMap(
|
|
45
|
+
opts.concurrency,
|
|
46
|
+
async (item) => {
|
|
47
|
+
const result2 = await (0, import_promises.pRetry)((...args) => func(args[0]), {
|
|
48
|
+
...opts.retries,
|
|
49
|
+
args: [item]
|
|
50
|
+
});
|
|
51
|
+
return result2;
|
|
52
|
+
},
|
|
53
|
+
iterable
|
|
54
|
+
);
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
// @__NO_SIDE_EFFECTS__
|
|
58
|
+
function transform(iterable, func, options) {
|
|
59
|
+
const streamingIterables = /* @__PURE__ */ getStreamingIterables();
|
|
60
|
+
const opts = (0, import_promises.normalizeIterationOptions)(options);
|
|
61
|
+
const result = streamingIterables?.transform(
|
|
62
|
+
opts.concurrency,
|
|
63
|
+
async (item) => {
|
|
64
|
+
const result2 = await (0, import_promises.pRetry)((...args) => func(args[0]), {
|
|
65
|
+
...opts.retries,
|
|
66
|
+
args: [item]
|
|
67
|
+
});
|
|
68
|
+
return result2;
|
|
69
|
+
},
|
|
70
|
+
iterable
|
|
71
|
+
);
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
75
|
+
0 && (module.exports = {
|
|
76
|
+
parallelEach,
|
|
77
|
+
parallelMap,
|
|
78
|
+
transform
|
|
79
|
+
});
|
|
80
|
+
//# sourceMappingURL=streams.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/streams.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * @fileoverview Stream processing utilities with streaming-iterables integration.\n * Provides async stream handling and transformation functions.\n */\n\nimport type { IterationOptions } from './promises'\nimport { normalizeIterationOptions, pRetry } from './promises'\n\nlet _streamingIterables:\n | {\n parallelMap: <T, U>(\n concurrency: number,\n mapper: (item: T) => Promise<U>,\n iterable: Iterable<T> | AsyncIterable<T>,\n ) => AsyncIterable<U>\n transform: <T, U>(\n concurrency: number,\n mapper: (item: T) => Promise<U>,\n iterable: Iterable<T> | AsyncIterable<T>,\n ) => AsyncIterable<U>\n }\n | undefined\n/**\n * Get the streaming-iterables module.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getStreamingIterables() {\n if (_streamingIterables === undefined) {\n _streamingIterables = /*@__PURE__*/ require('../external/streaming-iterables')\n }\n return _streamingIterables\n}\n\n/**\n * Execute a function for each item in an iterable in parallel.\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport async function parallelEach<T>(\n iterable: Iterable<T> | AsyncIterable<T>,\n func: (item: T) => Promise<unknown>,\n options?: number | IterationOptions,\n): Promise<void> {\n for await (const _ of parallelMap(iterable, func, options)) {\n /* empty block */\n }\n}\n\n/**\n * Map over an iterable in parallel with concurrency control.\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function parallelMap<T, U>(\n iterable: Iterable<T> | AsyncIterable<T>,\n func: (item: T) => Promise<U>,\n options?: number | IterationOptions,\n): AsyncIterable<U> {\n const streamingIterables = getStreamingIterables()\n const opts = normalizeIterationOptions(options)\n const result = streamingIterables?.parallelMap(\n opts.concurrency,\n async (item: T) => {\n const result = await pRetry((...args: unknown[]) => func(args[0] as T), {\n ...opts.retries,\n args: [item],\n })\n return result as U\n },\n iterable,\n )\n return result as AsyncIterable<U>\n}\n\n/**\n * Transform an iterable with a function.\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function transform<T, U>(\n iterable: Iterable<T> | AsyncIterable<T>,\n func: (item: T) => Promise<U>,\n options?: number | IterationOptions,\n): AsyncIterable<U> {\n const streamingIterables = getStreamingIterables()\n const opts = normalizeIterationOptions(options)\n const result = streamingIterables?.transform(\n opts.concurrency,\n async (item: T) => {\n const result = await pRetry((...args: unknown[]) => func(args[0] as T), {\n ...opts.retries,\n args: [item],\n })\n return result as U\n },\n iterable,\n )\n return result as AsyncIterable<U>\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,sBAAkD;AAElD,IAAI;AAAA;AAmBJ,SAAS,wBAAwB;AAC/B,MAAI,wBAAwB,QAAW;AACrC,0BAAoC,QAAQ,iCAAiC;AAAA,EAC/E;AACA,SAAO;AACT;AAAA;AAMA,eAAsB,aACpB,UACA,MACA,SACe;AACf,mBAAiB,KAAK,4BAAY,UAAU,MAAM,OAAO,GAAG;AAAA,EAE5D;AACF;AAAA;AAMO,SAAS,YACd,UACA,MACA,SACkB;AAClB,QAAM,qBAAqB,sCAAsB;AACjD,QAAM,WAAO,2CAA0B,OAAO;AAC9C,QAAM,SAAS,oBAAoB;AAAA,IACjC,KAAK;AAAA,IACL,OAAO,SAAY;AACjB,YAAMA,UAAS,UAAM,wBAAO,IAAI,SAAoB,KAAK,KAAK,CAAC,CAAM,GAAG;AAAA,QACtE,GAAG,KAAK;AAAA,QACR,MAAM,CAAC,IAAI;AAAA,MACb,CAAC;AACD,aAAOA;AAAA,IACT;AAAA,IACA;AAAA,EACF;AACA,SAAO;AACT;AAAA;AAMO,SAAS,UACd,UACA,MACA,SACkB;AAClB,QAAM,qBAAqB,sCAAsB;AACjD,QAAM,WAAO,2CAA0B,OAAO;AAC9C,QAAM,SAAS,oBAAoB;AAAA,IACjC,KAAK;AAAA,IACL,OAAO,SAAY;AACjB,YAAMA,UAAS,UAAM,wBAAO,IAAI,SAAoB,KAAK,KAAK,CAAC,CAAM,GAAG;AAAA,QACtE,GAAG,KAAK;AAAA,QACR,MAAM,CAAC,IAAI;AAAA,MACb,CAAC;AACD,aAAOA;AAAA,IACT;AAAA,IACA;AAAA,EACF;AACA,SAAO;AACT;",
|
|
6
|
+
"names": ["result"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview String manipulation utilities including ANSI code handling.
|
|
3
|
+
* Provides string processing, prefix application, and terminal output utilities.
|
|
4
|
+
*/
|
|
5
|
+
import { ansiRegex, stripAnsi } from './ansi';
|
|
6
|
+
// Import get-east-asian-width from external wrapper.
|
|
7
|
+
// This library implements Unicode Standard Annex #11 (East Asian Width).
|
|
8
|
+
// https://www.unicode.org/reports/tr11/
|
|
9
|
+
// Re-export ANSI utilities for backward compatibility.
|
|
10
|
+
export { ansiRegex, stripAnsi };
|
|
11
|
+
// Type definitions
|
|
12
|
+
declare const BlankStringBrand: unique symbol;
|
|
13
|
+
export type BlankString = string & {
|
|
14
|
+
[BlankStringBrand]: true;
|
|
15
|
+
};
|
|
16
|
+
declare const EmptyStringBrand: unique symbol;
|
|
17
|
+
export type EmptyString = string & {
|
|
18
|
+
[EmptyStringBrand]: true;
|
|
19
|
+
};
|
|
20
|
+
// IMPORTANT: Do not use destructuring here - use direct assignment instead.
|
|
21
|
+
// tsgo has a bug that incorrectly transpiles destructured exports, resulting in
|
|
22
|
+
// `exports.SomeName = void 0;` which causes runtime errors.
|
|
23
|
+
// See: https://github.com/SocketDev/socket-packageurl-js/issues/3
|
|
24
|
+
export declare const fromCharCode: (...codes: number[]) => string;
|
|
25
|
+
export interface ApplyLinePrefixOptions {
|
|
26
|
+
prefix?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Apply a prefix to each line of a string.
|
|
30
|
+
*/
|
|
31
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
32
|
+
export declare function applyLinePrefix(str: string, options?: ApplyLinePrefixOptions | undefined): string;
|
|
33
|
+
/**
|
|
34
|
+
* Convert a camelCase string to kebab-case.
|
|
35
|
+
*/
|
|
36
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
37
|
+
export declare function camelToKebab(str: string): string;
|
|
38
|
+
export interface IndentStringOptions {
|
|
39
|
+
count?: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Indent each line of a string with spaces.
|
|
43
|
+
*/
|
|
44
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
45
|
+
export declare function indentString(str: string, options?: IndentStringOptions | undefined): string;
|
|
46
|
+
/**
|
|
47
|
+
* Check if a value is a blank string (empty or only whitespace).
|
|
48
|
+
*/
|
|
49
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
50
|
+
export declare function isBlankString(value: unknown): value is BlankString;
|
|
51
|
+
/**
|
|
52
|
+
* Check if a value is a non-empty string.
|
|
53
|
+
*/
|
|
54
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
55
|
+
export declare function isNonEmptyString(value: unknown): value is Exclude<string, EmptyString>;
|
|
56
|
+
export interface SearchOptions {
|
|
57
|
+
fromIndex?: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Search for a regular expression in a string starting from an index.
|
|
61
|
+
*/
|
|
62
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
63
|
+
export declare function search(str: string, regexp: RegExp, options?: SearchOptions | undefined): number;
|
|
64
|
+
/**
|
|
65
|
+
* Strip the Byte Order Mark (BOM) from the beginning of a string.
|
|
66
|
+
*/
|
|
67
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
68
|
+
export declare function stripBom(str: string): string;
|
|
69
|
+
/**
|
|
70
|
+
* Get the visual width of a string in terminal columns.
|
|
71
|
+
* Strips ANSI escape codes and accounts for wide characters.
|
|
72
|
+
*
|
|
73
|
+
* Based on string-width:
|
|
74
|
+
* https://socket.dev/npm/package/string-width/overview/7.2.0
|
|
75
|
+
* MIT License
|
|
76
|
+
* Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
77
|
+
*
|
|
78
|
+
* Terminal emulators display characters in a grid of cells (columns).
|
|
79
|
+
* Most ASCII characters take 1 column, but some characters (especially
|
|
80
|
+
* emoji and CJK characters) take 2 columns.
|
|
81
|
+
*
|
|
82
|
+
* This function calculates how many columns a string will occupy when
|
|
83
|
+
* displayed in a terminal, which is crucial for:
|
|
84
|
+
* - Aligning text properly
|
|
85
|
+
* - Preventing text from jumping when characters change
|
|
86
|
+
* - Calculating padding/spacing
|
|
87
|
+
*
|
|
88
|
+
* Logic:
|
|
89
|
+
* - Segment graphemes to match how terminals render clusters.
|
|
90
|
+
* - Width rules:
|
|
91
|
+
* 1. Skip non-printing clusters (Default_Ignorable, Control, pure Mark, lone Surrogates).
|
|
92
|
+
* 2. RGI emoji clusters (\p{RGI_Emoji}) are double-width.
|
|
93
|
+
* 3. Otherwise use East Asian Width of the cluster's first visible code point.
|
|
94
|
+
* 4. Add widths for trailing Halfwidth/Fullwidth Forms within the same cluster.
|
|
95
|
+
*
|
|
96
|
+
* East Asian Width categories (Unicode Standard Annex #11):
|
|
97
|
+
* - F (Fullwidth): 2 columns - e.g., fullwidth Latin letters (A, B)
|
|
98
|
+
* - W (Wide): 2 columns - e.g., CJK ideographs (漢字), emoji (⚡, 😀)
|
|
99
|
+
* - H (Halfwidth): 1 column - e.g., halfwidth Katakana (ア, イ)
|
|
100
|
+
* - Na (Narrow): 1 column - e.g., ASCII (a-z, 0-9)
|
|
101
|
+
* - A (Ambiguous): Context-dependent, we treat as 1 column
|
|
102
|
+
* - N (Neutral): 1 column - e.g., most symbols (✦, ✧, ⋆)
|
|
103
|
+
*
|
|
104
|
+
* Why this matters for Socket spinners:
|
|
105
|
+
* - Lightning bolt (⚡) takes 2 columns
|
|
106
|
+
* - Stars (✦, ✧, ⋆) take 1 column
|
|
107
|
+
* - Without compensation, text jumps when frames change
|
|
108
|
+
* - We use this to calculate padding for consistent alignment
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* stringWidth('hello') // => 5 (5 ASCII chars = 5 columns)
|
|
112
|
+
* stringWidth('⚡') // => 2 (lightning bolt is wide)
|
|
113
|
+
* stringWidth('✦') // => 1 (star is narrow)
|
|
114
|
+
* stringWidth('\x1b[31mred\x1b[0m') // => 3 (ANSI codes stripped, 'red' = 3)
|
|
115
|
+
*
|
|
116
|
+
* @throws {TypeError} When input is not a string.
|
|
117
|
+
*/
|
|
118
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
119
|
+
export declare function stringWidth(text: string): number;
|
|
120
|
+
/**
|
|
121
|
+
* Convert a string to kebab-case (handles camelCase and snake_case).
|
|
122
|
+
*/
|
|
123
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
124
|
+
export declare function toKebabCase(str: string): string;
|
|
125
|
+
/**
|
|
126
|
+
* Trim newlines from the beginning and end of a string.
|
|
127
|
+
*/
|
|
128
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
129
|
+
export declare function trimNewlines(str: string): string;
|
|
130
|
+
/**
|
|
131
|
+
* Repeat a string n times.
|
|
132
|
+
*/
|
|
133
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
134
|
+
export declare function repeatString(str: string, count: number): string;
|
|
135
|
+
/**
|
|
136
|
+
* Center text within a given width.
|
|
137
|
+
*/
|
|
138
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
139
|
+
export declare function centerText(text: string, width: number): string;
|
package/dist/strings.js
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/* Socket Lib - Built with esbuild */
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var strings_exports = {};
|
|
20
|
+
__export(strings_exports, {
|
|
21
|
+
ansiRegex: () => import_ansi.ansiRegex,
|
|
22
|
+
applyLinePrefix: () => applyLinePrefix,
|
|
23
|
+
camelToKebab: () => camelToKebab,
|
|
24
|
+
centerText: () => centerText,
|
|
25
|
+
fromCharCode: () => fromCharCode,
|
|
26
|
+
indentString: () => indentString,
|
|
27
|
+
isBlankString: () => isBlankString,
|
|
28
|
+
isNonEmptyString: () => isNonEmptyString,
|
|
29
|
+
repeatString: () => repeatString,
|
|
30
|
+
search: () => search,
|
|
31
|
+
stringWidth: () => stringWidth,
|
|
32
|
+
stripAnsi: () => import_ansi.stripAnsi,
|
|
33
|
+
stripBom: () => stripBom,
|
|
34
|
+
toKebabCase: () => toKebabCase,
|
|
35
|
+
trimNewlines: () => trimNewlines
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(strings_exports);
|
|
38
|
+
var import_ansi = require("./ansi");
|
|
39
|
+
var import_get_east_asian_width = require("./external/get-east-asian-width");
|
|
40
|
+
const fromCharCode = String.fromCharCode;
|
|
41
|
+
// @__NO_SIDE_EFFECTS__
|
|
42
|
+
function applyLinePrefix(str, options) {
|
|
43
|
+
const { prefix = "" } = {
|
|
44
|
+
__proto__: null,
|
|
45
|
+
...options
|
|
46
|
+
};
|
|
47
|
+
return prefix.length ? `${prefix}${str.includes("\n") ? str.replace(/\n/g, `
|
|
48
|
+
${prefix}`) : str}` : str;
|
|
49
|
+
}
|
|
50
|
+
// @__NO_SIDE_EFFECTS__
|
|
51
|
+
function camelToKebab(str) {
|
|
52
|
+
const { length } = str;
|
|
53
|
+
if (!length) {
|
|
54
|
+
return "";
|
|
55
|
+
}
|
|
56
|
+
let result = "";
|
|
57
|
+
let i = 0;
|
|
58
|
+
while (i < length) {
|
|
59
|
+
const char = str[i];
|
|
60
|
+
if (!char) {
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
const charCode = char.charCodeAt(0);
|
|
64
|
+
const isUpperCase = charCode >= 65 && charCode <= 90;
|
|
65
|
+
if (isUpperCase) {
|
|
66
|
+
if (result.length > 0) {
|
|
67
|
+
result += "-";
|
|
68
|
+
}
|
|
69
|
+
while (i < length) {
|
|
70
|
+
const currChar = str[i];
|
|
71
|
+
if (!currChar) {
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
const currCharCode = currChar.charCodeAt(0);
|
|
75
|
+
const isCurrUpper = currCharCode >= 65 && currCharCode <= 90;
|
|
76
|
+
if (isCurrUpper) {
|
|
77
|
+
result += fromCharCode(
|
|
78
|
+
currCharCode + 32
|
|
79
|
+
/*'a'-'A'*/
|
|
80
|
+
);
|
|
81
|
+
i += 1;
|
|
82
|
+
} else {
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
} else {
|
|
87
|
+
result += char;
|
|
88
|
+
i += 1;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
93
|
+
// @__NO_SIDE_EFFECTS__
|
|
94
|
+
function indentString(str, options) {
|
|
95
|
+
const { count = 1 } = { __proto__: null, ...options };
|
|
96
|
+
return str.replace(/^(?!\s*$)/gm, " ".repeat(count));
|
|
97
|
+
}
|
|
98
|
+
// @__NO_SIDE_EFFECTS__
|
|
99
|
+
function isBlankString(value) {
|
|
100
|
+
return typeof value === "string" && (!value.length || /^\s+$/.test(value));
|
|
101
|
+
}
|
|
102
|
+
// @__NO_SIDE_EFFECTS__
|
|
103
|
+
function isNonEmptyString(value) {
|
|
104
|
+
return typeof value === "string" && value.length > 0;
|
|
105
|
+
}
|
|
106
|
+
// @__NO_SIDE_EFFECTS__
|
|
107
|
+
function search(str, regexp, options) {
|
|
108
|
+
const { fromIndex = 0 } = { __proto__: null, ...options };
|
|
109
|
+
const { length } = str;
|
|
110
|
+
if (fromIndex >= length) {
|
|
111
|
+
return -1;
|
|
112
|
+
}
|
|
113
|
+
if (fromIndex === 0) {
|
|
114
|
+
return str.search(regexp);
|
|
115
|
+
}
|
|
116
|
+
const offset = fromIndex < 0 ? Math.max(length + fromIndex, 0) : fromIndex;
|
|
117
|
+
const result = str.slice(offset).search(regexp);
|
|
118
|
+
return result === -1 ? -1 : result + offset;
|
|
119
|
+
}
|
|
120
|
+
// @__NO_SIDE_EFFECTS__
|
|
121
|
+
function stripBom(str) {
|
|
122
|
+
return str.length > 0 && str.charCodeAt(0) === 65279 ? str.slice(1) : str;
|
|
123
|
+
}
|
|
124
|
+
const segmenter = new Intl.Segmenter();
|
|
125
|
+
let zeroWidthClusterRegex;
|
|
126
|
+
let leadingNonPrintingRegex;
|
|
127
|
+
let emojiRegex;
|
|
128
|
+
try {
|
|
129
|
+
zeroWidthClusterRegex = new RegExp("^(?:\\p{Default_Ignorable_Code_Point}|\\p{Control}|\\p{Mark}|\\p{Surrogate})+$", "v");
|
|
130
|
+
leadingNonPrintingRegex = new RegExp("^[\\p{Default_Ignorable_Code_Point}\\p{Control}\\p{Format}\\p{Mark}\\p{Surrogate}]+", "v");
|
|
131
|
+
emojiRegex = new RegExp("^\\p{RGI_Emoji}$", "v");
|
|
132
|
+
} catch {
|
|
133
|
+
zeroWidthClusterRegex = new RegExp("^(?:\\p{Default_Ignorable_Code_Point}|\\p{Control}|\\p{Mark})+$", "u");
|
|
134
|
+
leadingNonPrintingRegex = /^[\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Mark}]+/u;
|
|
135
|
+
emojiRegex = new RegExp("^\\p{Extended_Pictographic}$", "u");
|
|
136
|
+
}
|
|
137
|
+
// @__NO_SIDE_EFFECTS__
|
|
138
|
+
function stringWidth(text) {
|
|
139
|
+
if (typeof text !== "string" || !text.length) {
|
|
140
|
+
return 0;
|
|
141
|
+
}
|
|
142
|
+
const plainText = (0, import_ansi.stripAnsi)(text);
|
|
143
|
+
if (!plainText.length) {
|
|
144
|
+
return 0;
|
|
145
|
+
}
|
|
146
|
+
let width = 0;
|
|
147
|
+
const eastAsianWidthOptions = { ambiguousAsWide: false };
|
|
148
|
+
for (const { segment } of segmenter.segment(plainText)) {
|
|
149
|
+
if (zeroWidthClusterRegex.test(segment)) {
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
if (emojiRegex.test(segment)) {
|
|
153
|
+
width += 2;
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
const baseSegment = segment.replace(leadingNonPrintingRegex, "");
|
|
157
|
+
const codePoint = baseSegment.codePointAt(0);
|
|
158
|
+
if (codePoint === void 0) {
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
width += (0, import_get_east_asian_width.eastAsianWidth)(codePoint, eastAsianWidthOptions);
|
|
162
|
+
if (segment.length > 1) {
|
|
163
|
+
for (const char of segment.slice(1)) {
|
|
164
|
+
const charCode = char.charCodeAt(0);
|
|
165
|
+
if (charCode >= 65280 && charCode <= 65519) {
|
|
166
|
+
const trailingCodePoint = char.codePointAt(0);
|
|
167
|
+
if (trailingCodePoint !== void 0) {
|
|
168
|
+
width += (0, import_get_east_asian_width.eastAsianWidth)(trailingCodePoint, eastAsianWidthOptions);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return width;
|
|
175
|
+
}
|
|
176
|
+
// @__NO_SIDE_EFFECTS__
|
|
177
|
+
function toKebabCase(str) {
|
|
178
|
+
if (!str.length) {
|
|
179
|
+
return str;
|
|
180
|
+
}
|
|
181
|
+
return str.replace(/([a-z]+[0-9]*)([A-Z])/g, "$1-$2").replace(/_/g, "-").toLowerCase();
|
|
182
|
+
}
|
|
183
|
+
// @__NO_SIDE_EFFECTS__
|
|
184
|
+
function trimNewlines(str) {
|
|
185
|
+
const { length } = str;
|
|
186
|
+
if (length === 0) {
|
|
187
|
+
return str;
|
|
188
|
+
}
|
|
189
|
+
const first = str.charCodeAt(0);
|
|
190
|
+
const noFirstNewline = first !== 13 && first !== 10;
|
|
191
|
+
if (length === 1) {
|
|
192
|
+
return noFirstNewline ? str : "";
|
|
193
|
+
}
|
|
194
|
+
const last = str.charCodeAt(length - 1);
|
|
195
|
+
const noLastNewline = last !== 13 && last !== 10;
|
|
196
|
+
if (noFirstNewline && noLastNewline) {
|
|
197
|
+
return str;
|
|
198
|
+
}
|
|
199
|
+
let start = 0;
|
|
200
|
+
let end = length;
|
|
201
|
+
while (start < end) {
|
|
202
|
+
const code = str.charCodeAt(start);
|
|
203
|
+
if (code !== 13 && code !== 10) {
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
start += 1;
|
|
207
|
+
}
|
|
208
|
+
while (end > start) {
|
|
209
|
+
const code = str.charCodeAt(end - 1);
|
|
210
|
+
if (code !== 13 && code !== 10) {
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
end -= 1;
|
|
214
|
+
}
|
|
215
|
+
return start === 0 && end === length ? str : str.slice(start, end);
|
|
216
|
+
}
|
|
217
|
+
// @__NO_SIDE_EFFECTS__
|
|
218
|
+
function repeatString(str, count) {
|
|
219
|
+
if (count <= 0) {
|
|
220
|
+
return "";
|
|
221
|
+
}
|
|
222
|
+
return str.repeat(count);
|
|
223
|
+
}
|
|
224
|
+
// @__NO_SIDE_EFFECTS__
|
|
225
|
+
function centerText(text, width) {
|
|
226
|
+
const textLength = (0, import_ansi.stripAnsi)(text).length;
|
|
227
|
+
if (textLength >= width) {
|
|
228
|
+
return text;
|
|
229
|
+
}
|
|
230
|
+
const padding = width - textLength;
|
|
231
|
+
const leftPad = Math.floor(padding / 2);
|
|
232
|
+
const rightPad = padding - leftPad;
|
|
233
|
+
return " ".repeat(leftPad) + text + " ".repeat(rightPad);
|
|
234
|
+
}
|
|
235
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
236
|
+
0 && (module.exports = {
|
|
237
|
+
ansiRegex,
|
|
238
|
+
applyLinePrefix,
|
|
239
|
+
camelToKebab,
|
|
240
|
+
centerText,
|
|
241
|
+
fromCharCode,
|
|
242
|
+
indentString,
|
|
243
|
+
isBlankString,
|
|
244
|
+
isNonEmptyString,
|
|
245
|
+
repeatString,
|
|
246
|
+
search,
|
|
247
|
+
stringWidth,
|
|
248
|
+
stripAnsi,
|
|
249
|
+
stripBom,
|
|
250
|
+
toKebabCase,
|
|
251
|
+
trimNewlines
|
|
252
|
+
});
|
|
253
|
+
//# sourceMappingURL=strings.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/strings.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * @fileoverview String manipulation utilities including ANSI code handling.\n * Provides string processing, prefix application, and terminal output utilities.\n */\n\nimport { ansiRegex, stripAnsi } from './ansi'\nimport { eastAsianWidth } from './external/get-east-asian-width'\n// Import get-east-asian-width from external wrapper.\n// This library implements Unicode Standard Annex #11 (East Asian Width).\n// https://www.unicode.org/reports/tr11/\n\n// Re-export ANSI utilities for backward compatibility.\nexport { ansiRegex, stripAnsi }\n\n// Type definitions\ndeclare const BlankStringBrand: unique symbol\nexport type BlankString = string & { [BlankStringBrand]: true }\ndeclare const EmptyStringBrand: unique symbol\nexport type EmptyString = string & { [EmptyStringBrand]: true }\n\n// IMPORTANT: Do not use destructuring here - use direct assignment instead.\n// tsgo has a bug that incorrectly transpiles destructured exports, resulting in\n// `exports.SomeName = void 0;` which causes runtime errors.\n// See: https://github.com/SocketDev/socket-packageurl-js/issues/3\nexport const fromCharCode = String.fromCharCode\n\nexport interface ApplyLinePrefixOptions {\n prefix?: string\n}\n\n/**\n * Apply a prefix to each line of a string.\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function applyLinePrefix(\n str: string,\n options?: ApplyLinePrefixOptions | undefined,\n): string {\n const { prefix = '' } = {\n __proto__: null,\n ...options,\n } as ApplyLinePrefixOptions\n return prefix.length\n ? `${prefix}${str.includes('\\n') ? str.replace(/\\n/g, `\\n${prefix}`) : str}`\n : str\n}\n\n/**\n * Convert a camelCase string to kebab-case.\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function camelToKebab(str: string): string {\n const { length } = str\n if (!length) {\n return ''\n }\n let result = ''\n let i = 0\n while (i < length) {\n const char = str[i]\n if (!char) {\n break\n }\n const charCode = char.charCodeAt(0)\n // Check if current character is uppercase letter.\n // A = 65, Z = 90\n const isUpperCase = charCode >= 65 /*'A'*/ && charCode <= 90 /*'Z'*/\n if (isUpperCase) {\n // Add dash before uppercase sequence (except at start).\n if (result.length > 0) {\n result += '-'\n }\n // Collect all consecutive uppercase letters.\n while (i < length) {\n const currChar = str[i]\n if (!currChar) {\n break\n }\n const currCharCode = currChar.charCodeAt(0)\n const isCurrUpper =\n currCharCode >= 65 /*'A'*/ && currCharCode <= 90 /*'Z'*/\n if (isCurrUpper) {\n // Convert uppercase to lowercase: subtract 32 (A=65 -> a=97, diff=32)\n result += fromCharCode(currCharCode + 32 /*'a'-'A'*/)\n i += 1\n } else {\n // Stop when we hit non-uppercase.\n break\n }\n }\n } else {\n // Handle lowercase letters, digits, and other characters.\n result += char\n i += 1\n }\n }\n return result\n}\n\nexport interface IndentStringOptions {\n count?: number\n}\n\n/**\n * Indent each line of a string with spaces.\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function indentString(\n str: string,\n options?: IndentStringOptions | undefined,\n): string {\n const { count = 1 } = { __proto__: null, ...options } as IndentStringOptions\n return str.replace(/^(?!\\s*$)/gm, ' '.repeat(count))\n}\n\n/**\n * Check if a value is a blank string (empty or only whitespace).\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function isBlankString(value: unknown): value is BlankString {\n return typeof value === 'string' && (!value.length || /^\\s+$/.test(value))\n}\n\n/**\n * Check if a value is a non-empty string.\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function isNonEmptyString(\n value: unknown,\n): value is Exclude<string, EmptyString> {\n return typeof value === 'string' && value.length > 0\n}\n\nexport interface SearchOptions {\n fromIndex?: number\n}\n\n/**\n * Search for a regular expression in a string starting from an index.\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function search(\n str: string,\n regexp: RegExp,\n options?: SearchOptions | undefined,\n): number {\n const { fromIndex = 0 } = { __proto__: null, ...options } as SearchOptions\n const { length } = str\n if (fromIndex >= length) {\n return -1\n }\n if (fromIndex === 0) {\n return str.search(regexp)\n }\n const offset = fromIndex < 0 ? Math.max(length + fromIndex, 0) : fromIndex\n const result = str.slice(offset).search(regexp)\n return result === -1 ? -1 : result + offset\n}\n\n/**\n * Strip the Byte Order Mark (BOM) from the beginning of a string.\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function stripBom(str: string): string {\n // In JavaScript, string data is stored as UTF-16, so BOM is 0xFEFF.\n // https://tc39.es/ecma262/#sec-unicode-format-control-characters\n return str.length > 0 && str.charCodeAt(0) === 0xfe_ff ? str.slice(1) : str\n}\n\n// Initialize Intl.Segmenter for proper grapheme cluster segmentation.\n// Hoisted outside stringWidth() for reuse across multiple calls.\n//\n// A grapheme cluster is what a user perceives as a single character, but may\n// be composed of multiple Unicode code points.\n//\n// Why this matters:\n// - '\uD83D\uDC4D' (thumbs up) is 1 code point but appears as 1 character \u2192 1 grapheme\n// - '\uD83D\uDC4D\uD83C\uDFFD' (thumbs up + skin tone) is 2 code points but appears as 1 character \u2192 1 grapheme\n// - '\uD83D\uDC68\u200D\uD83D\uDC69\u200D\uD83D\uDC67\u200D\uD83D\uDC66' (family) is 7 code points (4 people + 3 ZWJ) but appears as 1 character \u2192 1 grapheme\n// - '\u00E9' can be 1 code point (U+00E9) OR 2 code points (e + \u0301) but appears as 1 character \u2192 1 grapheme\n//\n// Without Intl.Segmenter, simple iteration treats each code point separately,\n// leading to incorrect width calculations for complex sequences.\n//\n// Intl.Segmenter is available in:\n// - Node.js 16.0.0+ (our minimum is 18.0.0, so always available)\n// - All modern browsers\n//\n// Performance: Creating this once and reusing it is more efficient than\n// creating a new Intl.Segmenter instance on every stringWidth() call.\nconst segmenter = new Intl.Segmenter()\n\n// Feature-detect Unicode property escapes support and create regex patterns.\n// Hoisted outside stringWidth() for reuse across multiple calls.\n//\n// Unicode property escapes in regex allow matching characters by their Unicode properties.\n// The 'v' flag (ES2024, Node 20+) provides the most accurate Unicode support including:\n// - \\p{RGI_Emoji} - Matches only emoji recommended for general interchange\n// - Full support for Unicode sets and properties\n//\n// The 'u' flag (ES2015, Node 18+) provides basic Unicode support but:\n// - No \\p{RGI_Emoji} property (must use broader \\p{Extended_Pictographic})\n// - No \\p{Surrogate} property (must omit from patterns)\n// - Less accurate for complex emoji sequences\n//\n// We feature-detect by attempting to create a regex with 'v' flag.\n// If it throws, we fall back to 'u' flag with adjusted patterns.\n//\n// This ensures:\n// - Best accuracy on Node 20+ (our test matrix: 20, 22, 24)\n// - Backward compatibility with Node 18 (our minimum version)\n// - No runtime errors from unsupported regex features\n//\n// Performance: Creating these once and reusing them is more efficient than\n// creating new regex instances on every stringWidth() call.\nlet zeroWidthClusterRegex: RegExp\nlet leadingNonPrintingRegex: RegExp\nlet emojiRegex: RegExp\n\ntry {\n // Try 'v' flag first (Node 20+) for most accurate Unicode property support.\n //\n // ZERO-WIDTH CLUSTER PATTERN:\n // Matches entire clusters that should be invisible (width = 0):\n // - \\p{Default_Ignorable_Code_Point} - Characters like Zero Width Space (U+200B)\n // - \\p{Control} - ASCII control chars (0x00-0x1F, 0x7F-0x9F) like \\t, \\n\n // - \\p{Mark} - Combining marks that modify previous character (accents, diacritics)\n // - \\p{Surrogate} - Lone surrogate halves (invalid UTF-16, should not appear)\n zeroWidthClusterRegex =\n /^(?:\\p{Default_Ignorable_Code_Point}|\\p{Control}|\\p{Mark}|\\p{Surrogate})+$/v\n\n // LEADING NON-PRINTING PATTERN:\n // Matches non-printing characters at the start of a cluster.\n // Used to find the \"base\" visible character in a cluster.\n // - \\p{Format} - Formatting characters like Right-to-Left marks\n // Example: In a cluster starting with format chars, we skip them to find the base character.\n leadingNonPrintingRegex =\n /^[\\p{Default_Ignorable_Code_Point}\\p{Control}\\p{Format}\\p{Mark}\\p{Surrogate}]+/v\n\n // RGI EMOJI PATTERN:\n // \\p{RGI_Emoji} matches emoji in the \"Recommended for General Interchange\" set.\n // This is the most accurate way to detect emoji that should render as double-width.\n //\n // RGI emoji include:\n // - Basic emoji: \uD83D\uDC4D, \uD83D\uDE00, \u26A1\n // - Emoji with modifiers: \uD83D\uDC4D\uD83C\uDFFD (thumbs up + medium skin tone)\n // - ZWJ sequences: \uD83D\uDC68\u200D\uD83D\uDC69\u200D\uD83D\uDC67\u200D\uD83D\uDC66 (family: man, woman, girl, boy)\n // - Keycap sequences: 1\uFE0F\u20E3 (digit + variation selector + combining enclosing keycap)\n //\n // Why RGI? The Unicode Consortium recommends this subset for interchange because:\n // - They have consistent rendering across platforms\n // - They're widely supported\n // - They follow a standardized format\n //\n // Non-RGI emoji might be symbols that look like emoji but render as 1 column.\n emojiRegex = /^\\p{RGI_Emoji}$/v\n} catch {\n // Fall back to 'u' flag (Node 18+) with slightly less accurate patterns.\n //\n // KEY DIFFERENCES from 'v' flag patterns:\n // 1. No \\p{Surrogate} property - omitted from patterns\n // 2. No \\p{RGI_Emoji} property - use \\p{Extended_Pictographic} instead\n //\n // \\p{Extended_Pictographic} is broader than \\p{RGI_Emoji}:\n // - Includes emoji-like symbols that might render as 1 column\n // - Less precise but better than nothing\n // - Defined in Unicode Technical Standard #51\n //\n // The patterns are otherwise identical, just with \\p{Surrogate} removed\n // and \\p{RGI_Emoji} replaced with \\p{Extended_Pictographic}.\n zeroWidthClusterRegex =\n /^(?:\\p{Default_Ignorable_Code_Point}|\\p{Control}|\\p{Mark})+$/u\n leadingNonPrintingRegex =\n /^[\\p{Default_Ignorable_Code_Point}\\p{Control}\\p{Format}\\p{Mark}]+/u\n emojiRegex = /^\\p{Extended_Pictographic}$/u\n}\n\n/**\n * Get the visual width of a string in terminal columns.\n * Strips ANSI escape codes and accounts for wide characters.\n *\n * Based on string-width:\n * https://socket.dev/npm/package/string-width/overview/7.2.0\n * MIT License\n * Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)\n *\n * Terminal emulators display characters in a grid of cells (columns).\n * Most ASCII characters take 1 column, but some characters (especially\n * emoji and CJK characters) take 2 columns.\n *\n * This function calculates how many columns a string will occupy when\n * displayed in a terminal, which is crucial for:\n * - Aligning text properly\n * - Preventing text from jumping when characters change\n * - Calculating padding/spacing\n *\n * Logic:\n * - Segment graphemes to match how terminals render clusters.\n * - Width rules:\n * 1. Skip non-printing clusters (Default_Ignorable, Control, pure Mark, lone Surrogates).\n * 2. RGI emoji clusters (\\p{RGI_Emoji}) are double-width.\n * 3. Otherwise use East Asian Width of the cluster's first visible code point.\n * 4. Add widths for trailing Halfwidth/Fullwidth Forms within the same cluster.\n *\n * East Asian Width categories (Unicode Standard Annex #11):\n * - F (Fullwidth): 2 columns - e.g., fullwidth Latin letters (\uFF21, \uFF22)\n * - W (Wide): 2 columns - e.g., CJK ideographs (\u6F22\u5B57), emoji (\u26A1, \uD83D\uDE00)\n * - H (Halfwidth): 1 column - e.g., halfwidth Katakana (\uFF71, \uFF72)\n * - Na (Narrow): 1 column - e.g., ASCII (a-z, 0-9)\n * - A (Ambiguous): Context-dependent, we treat as 1 column\n * - N (Neutral): 1 column - e.g., most symbols (\u2726, \u2727, \u22C6)\n *\n * Why this matters for Socket spinners:\n * - Lightning bolt (\u26A1) takes 2 columns\n * - Stars (\u2726, \u2727, \u22C6) take 1 column\n * - Without compensation, text jumps when frames change\n * - We use this to calculate padding for consistent alignment\n *\n * @example\n * stringWidth('hello') // => 5 (5 ASCII chars = 5 columns)\n * stringWidth('\u26A1') // => 2 (lightning bolt is wide)\n * stringWidth('\u2726') // => 1 (star is narrow)\n * stringWidth('\\x1b[31mred\\x1b[0m') // => 3 (ANSI codes stripped, 'red' = 3)\n *\n * @throws {TypeError} When input is not a string.\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function stringWidth(text: string): number {\n if (typeof text !== 'string' || !text.length) {\n return 0\n }\n\n // Strip ANSI escape codes first (colors, bold, italic, etc.).\n // These are invisible and don't contribute to visual width.\n // Example: '\\x1b[31mred\\x1b[0m' becomes 'red'.\n const plainText = stripAnsi(text)\n\n if (!plainText.length) {\n return 0\n }\n\n // KEY IMPROVEMENT #1: Proper Grapheme Cluster Segmentation\n //\n // Use the hoisted Intl.Segmenter instance (defined outside this function).\n // See comments above for detailed explanation of grapheme cluster segmentation.\n\n // KEY IMPROVEMENT #2: Feature Detection for Unicode Property Escapes\n //\n // Use the hoisted regex patterns (defined outside this function).\n // See comments above for detailed explanation of feature detection and fallback patterns.\n\n let width = 0\n\n // Configure East Asian Width calculation.\n // ambiguousAsWide: false - treat ambiguous-width characters as narrow (1 column).\n //\n // Ambiguous width characters (category 'A') include:\n // - Greek letters: \u03B1, \u03B2, \u03B3\n // - Cyrillic letters: \u0410, \u0411, \u0412\n // - Box drawing characters: \u2500, \u2502, \u250C\n //\n // In East Asian contexts, these are often rendered as wide (2 columns).\n // In Western contexts, they're typically narrow (1 column).\n //\n // We choose narrow (false) because:\n // - Socket's primary audience is Western developers\n // - Most terminal emulators default to narrow for ambiguous characters\n // - Consistent with string-width's default behavior\n const eastAsianWidthOptions = { ambiguousAsWide: false }\n\n // KEY IMPROVEMENT #3: Comprehensive Width Calculation\n //\n // Segment the string into grapheme clusters and calculate width for each.\n // This is the core algorithm that handles all the complexity of Unicode text rendering.\n for (const { segment } of segmenter.segment(plainText)) {\n // STEP 1: Skip zero-width / non-printing clusters\n //\n // These clusters contain only invisible characters that take no space.\n // Examples:\n // - '\\t' (tab) - Control character\n // - '\\n' (newline) - Control character\n // - '\\u200B' (zero-width space) - Default ignorable\n // - Combining marks without base character\n //\n // Why skip? Terminals don't allocate columns for these characters.\n // They're either control codes or modify adjacent characters without adding width.\n if (zeroWidthClusterRegex.test(segment)) {\n continue\n }\n\n // STEP 2: Handle emoji (double-width)\n //\n // RGI emoji are always rendered as double-width (2 columns) in terminals.\n // This is true even for complex sequences:\n // - \uD83D\uDC4D (basic emoji) = 2 columns\n // - \uD83D\uDC4D\uD83C\uDFFD (emoji + skin tone modifier) = 2 columns (not 4!)\n // - \uD83D\uDC68\u200D\uD83D\uDC69\u200D\uD83D\uDC67\u200D\uD83D\uDC66 (family ZWJ sequence) = 2 columns (not 14!)\n //\n // Why double-width? Historical reasons:\n // - Emoji originated in Japanese mobile carriers\n // - They were designed to match CJK character width\n // - Terminal emulators inherited this behavior\n //\n // The key insight: The ENTIRE grapheme cluster is 2 columns, regardless\n // of how many code points it contains. That's why we need Intl.Segmenter!\n if (emojiRegex.test(segment)) {\n width += 2\n continue\n }\n\n // STEP 3: Use East Asian Width for everything else\n //\n // For non-emoji clusters, calculate width based on the first visible character.\n //\n // Why first visible character? In a grapheme cluster like \"\u00E9\" (e + combining acute),\n // the base character 'e' determines the width, and the combining mark modifies it\n // without adding width.\n //\n // Strip leading non-printing characters to find the base character.\n // Example: If a cluster starts with format characters, skip them to find\n // the actual visible character that determines width.\n const baseSegment = segment.replace(leadingNonPrintingRegex, '')\n const codePoint = baseSegment.codePointAt(0)\n\n if (codePoint === undefined) {\n // If no visible character remains after stripping non-printing chars, skip.\n // This shouldn't happen if our zero-width regex is correct, but defensive programming.\n continue\n }\n\n // Calculate width using East Asian Width property.\n // This handles:\n // - Narrow (1 column): ASCII a-z, A-Z, 0-9, most symbols\n // - Wide (2 columns): CJK ideographs (\u6F22, \u5B57), fullwidth forms (\uFF21, \uFF22)\n // - Halfwidth (1 column): Halfwidth Katakana (\uFF71, \uFF72, \uFF73)\n // - Ambiguous (1 column per our config): Greek, Cyrillic, box drawing\n width += eastAsianWidth(codePoint, eastAsianWidthOptions)\n\n // STEP 4: Handle trailing Halfwidth and Fullwidth Forms\n //\n // The Halfwidth and Fullwidth Forms Unicode block (U+FF00-U+FFEF) contains\n // compatibility characters for legacy East Asian encodings.\n //\n // Examples:\n // - \uFF9E (U+FF9E) - Halfwidth Katakana voiced sound mark (dakuten)\n // - \uFF9F (U+FF9F) - Halfwidth Katakana semi-voiced sound mark (handakuten)\n // - \uFF70 (U+FF70) - Halfwidth Katakana-Hiragana prolonged sound mark\n //\n // These can appear as TRAILING characters in a grapheme cluster (not leading).\n // When they do, they add their own width to the cluster.\n //\n // Example: A cluster might be [base character][dakuten]\n // - Base character contributes its width (calculated above)\n // - Dakuten contributes its width (calculated here)\n //\n // Why is this necessary? These forms are spacing characters, not combining marks.\n // They occupy their own column(s) even when following another character.\n //\n // Note: We only check trailing characters (segment.slice(1)).\n // The base character width was already calculated above.\n if (segment.length > 1) {\n for (const char of segment.slice(1)) {\n const charCode = char.charCodeAt(0)\n // Check if character is in Halfwidth and Fullwidth Forms range.\n if (charCode >= 0xff_00 && charCode <= 0xff_ef) {\n const trailingCodePoint = char.codePointAt(0)\n if (trailingCodePoint !== undefined) {\n // Add the East Asian Width of this trailing character.\n // Most halfwidth forms contribute 1 column, fullwidth contribute 2.\n width += eastAsianWidth(trailingCodePoint, eastAsianWidthOptions)\n }\n }\n }\n }\n }\n\n return width\n}\n\n/**\n * Convert a string to kebab-case (handles camelCase and snake_case).\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function toKebabCase(str: string): string {\n if (!str.length) {\n return str\n }\n return (\n str\n // Convert camelCase to kebab-case\n .replace(/([a-z]+[0-9]*)([A-Z])/g, '$1-$2')\n // Convert underscores to hyphens\n .replace(/_/g, '-')\n .toLowerCase()\n )\n}\n\n/**\n * Trim newlines from the beginning and end of a string.\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function trimNewlines(str: string): string {\n const { length } = str\n if (length === 0) {\n return str\n }\n const first = str.charCodeAt(0)\n const noFirstNewline = first !== 13 /*'\\r'*/ && first !== 10 /*'\\n'*/\n if (length === 1) {\n return noFirstNewline ? str : ''\n }\n const last = str.charCodeAt(length - 1)\n const noLastNewline = last !== 13 /*'\\r'*/ && last !== 10 /*'\\n'*/\n if (noFirstNewline && noLastNewline) {\n return str\n }\n let start = 0\n let end = length\n while (start < end) {\n const code = str.charCodeAt(start)\n if (code !== 13 /*'\\r'*/ && code !== 10 /*'\\n'*/) {\n break\n }\n start += 1\n }\n while (end > start) {\n const code = str.charCodeAt(end - 1)\n if (code !== 13 /*'\\r'*/ && code !== 10 /*'\\n'*/) {\n break\n }\n end -= 1\n }\n return start === 0 && end === length ? str : str.slice(start, end)\n}\n\n/**\n * Repeat a string n times.\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function repeatString(str: string, count: number): string {\n if (count <= 0) {\n return ''\n }\n return str.repeat(count)\n}\n\n/**\n * Center text within a given width.\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function centerText(text: string, width: number): string {\n const textLength = stripAnsi(text).length\n if (textLength >= width) {\n return text\n }\n\n const padding = width - textLength\n const leftPad = Math.floor(padding / 2)\n const rightPad = padding - leftPad\n\n return ' '.repeat(leftPad) + text + ' '.repeat(rightPad)\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Suppress MaxListenersExceededWarning messages.
|
|
3
|
+
* This is useful in tests or scripts where multiple listeners are expected.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* import { suppressMaxListenersWarning } from '@socketsecurity/registry/lib/suppress-warnings'
|
|
7
|
+
*
|
|
8
|
+
* suppressMaxListenersWarning()
|
|
9
|
+
*/
|
|
10
|
+
export declare function suppressMaxListenersWarning(): void;
|
|
11
|
+
/**
|
|
12
|
+
* Suppress all process warnings of a specific type.
|
|
13
|
+
*
|
|
14
|
+
* @param warningType - The warning type to suppress (e.g., 'DeprecationWarning', 'ExperimentalWarning')
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* import { suppressWarningType } from '@socketsecurity/registry/lib/suppress-warnings'
|
|
18
|
+
*
|
|
19
|
+
* suppressWarningType('ExperimentalWarning')
|
|
20
|
+
*/
|
|
21
|
+
export declare function suppressWarningType(warningType: string): void;
|
|
22
|
+
/**
|
|
23
|
+
* Set max listeners on an EventTarget (like AbortSignal) to avoid TypeError.
|
|
24
|
+
*
|
|
25
|
+
* By manually setting `kMaxEventTargetListeners` on the target we avoid:
|
|
26
|
+
* TypeError [ERR_INVALID_ARG_TYPE]: The "emitter" argument must be an
|
|
27
|
+
* instance of EventEmitter or EventTarget. Received an instance of
|
|
28
|
+
* AbortSignal
|
|
29
|
+
*
|
|
30
|
+
* in some patch releases of Node 18-23 when calling events.getMaxListeners().
|
|
31
|
+
* See https://github.com/nodejs/node/pull/56807.
|
|
32
|
+
*
|
|
33
|
+
* Instead of calling events.setMaxListeners(n, target) we set the symbol
|
|
34
|
+
* property directly to avoid depending on 'node:events' module.
|
|
35
|
+
*
|
|
36
|
+
* @param target - The EventTarget or AbortSignal to configure
|
|
37
|
+
* @param maxListeners - Maximum number of listeners (defaults to 10, the Node.js default)
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* import { setMaxEventTargetListeners } from '@socketsecurity/registry/lib/suppress-warnings'
|
|
41
|
+
*
|
|
42
|
+
* const controller = new AbortController()
|
|
43
|
+
* setMaxEventTargetListeners(controller.signal)
|
|
44
|
+
*/
|
|
45
|
+
export declare function setMaxEventTargetListeners(target: EventTarget | AbortSignal | undefined, maxListeners?: number): void;
|
|
46
|
+
/**
|
|
47
|
+
* Restore the original process.emitWarning function.
|
|
48
|
+
* Call this to re-enable all warnings after suppressing them.
|
|
49
|
+
*/
|
|
50
|
+
export declare function restoreWarnings(): void;
|
|
51
|
+
/**
|
|
52
|
+
* Suppress warnings temporarily within a callback.
|
|
53
|
+
*
|
|
54
|
+
* @param warningType - The warning type to suppress
|
|
55
|
+
* @param callback - Function to execute with warnings suppressed
|
|
56
|
+
* @returns The result of the callback
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* import { withSuppressedWarnings } from '@socketsecurity/registry/lib/suppress-warnings'
|
|
60
|
+
*
|
|
61
|
+
* const result = await withSuppressedWarnings('ExperimentalWarning', async () => {
|
|
62
|
+
* // Code that triggers experimental warnings
|
|
63
|
+
* return someValue
|
|
64
|
+
* })
|
|
65
|
+
*/
|
|
66
|
+
export declare function withSuppressedWarnings<T>(warningType: string, callback: () => T | Promise<T>): Promise<T>;
|