@socketsecurity/cli-with-sentry 1.1.25 → 2.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 +51 -218
- package/README.md +41 -74
- package/dist/cli.js.bz +0 -0
- package/dist/cli.js.bz.sha256 +1 -0
- package/dist/index.js +2 -0
- package/package.json +31 -274
- package/bin/cli.js +0 -52
- package/bin/npm-cli.js +0 -29
- package/bin/npx-cli.js +0 -29
- package/bin/pnpm-cli.js +0 -29
- package/bin/yarn-cli.js +0 -29
- package/dist/cli.js +0 -14999
- package/dist/cli.js.map +0 -1
- package/dist/constants.js +0 -845
- package/dist/constants.js.map +0 -1
- package/dist/flags.js +0 -212
- package/dist/flags.js.map +0 -1
- package/dist/init.gradle +0 -250
- package/dist/instrument-with-sentry.js +0 -44
- package/dist/instrument-with-sentry.js.map +0 -1
- package/dist/npm-cli.js +0 -30
- package/dist/npm-cli.js.map +0 -1
- package/dist/npx-cli.js +0 -26
- package/dist/npx-cli.js.map +0 -1
- package/dist/pnpm-cli.js +0 -30
- package/dist/pnpm-cli.js.map +0 -1
- package/dist/shadow-npm-bin.js +0 -8
- package/dist/shadow-npm-bin.js.map +0 -1
- package/dist/shadow-npm-bin2.js +0 -102
- package/dist/shadow-npm-bin2.js.map +0 -1
- package/dist/shadow-npm-inject.js +0 -307
- package/dist/shadow-npm-inject.js.map +0 -1
- package/dist/shadow-npx-bin.js +0 -12
- package/dist/shadow-npx-bin.js.map +0 -1
- package/dist/shadow-pnpm-bin.js +0 -8
- package/dist/shadow-pnpm-bin.js.map +0 -1
- package/dist/shadow-pnpm-bin2.js +0 -300
- package/dist/shadow-pnpm-bin2.js.map +0 -1
- package/dist/shadow-yarn-bin.js +0 -96
- package/dist/shadow-yarn-bin.js.map +0 -1
- package/dist/tsconfig.dts.tsbuildinfo +0 -1
- package/dist/types/cli.d.mts +0 -3
- package/dist/types/cli.d.mts.map +0 -1
- package/dist/types/commands/analytics/cmd-analytics.d.mts +0 -10
- package/dist/types/commands/analytics/cmd-analytics.d.mts.map +0 -1
- package/dist/types/commands/analytics/fetch-org-analytics.d.mts +0 -8
- package/dist/types/commands/analytics/fetch-org-analytics.d.mts.map +0 -1
- package/dist/types/commands/analytics/fetch-repo-analytics.d.mts +0 -8
- package/dist/types/commands/analytics/fetch-repo-analytics.d.mts.map +0 -1
- package/dist/types/commands/analytics/handle-analytics.d.mts +0 -10
- package/dist/types/commands/analytics/handle-analytics.d.mts.map +0 -1
- package/dist/types/commands/analytics/output-analytics.d.mts +0 -29
- package/dist/types/commands/analytics/output-analytics.d.mts.map +0 -1
- package/dist/types/commands/audit-log/cmd-audit-log.d.mts +0 -10
- package/dist/types/commands/audit-log/cmd-audit-log.d.mts.map +0 -1
- package/dist/types/commands/audit-log/fetch-audit-log.d.mts +0 -15
- package/dist/types/commands/audit-log/fetch-audit-log.d.mts.map +0 -1
- package/dist/types/commands/audit-log/handle-audit-log.d.mts +0 -9
- package/dist/types/commands/audit-log/handle-audit-log.d.mts.map +0 -1
- package/dist/types/commands/audit-log/output-audit-log.d.mts +0 -22
- package/dist/types/commands/audit-log/output-audit-log.d.mts.map +0 -1
- package/dist/types/commands/ci/cmd-ci.d.mts +0 -9
- package/dist/types/commands/ci/cmd-ci.d.mts.map +0 -1
- package/dist/types/commands/ci/fetch-default-org-slug.d.mts +0 -4
- package/dist/types/commands/ci/fetch-default-org-slug.d.mts.map +0 -1
- package/dist/types/commands/ci/handle-ci.d.mts +0 -2
- package/dist/types/commands/ci/handle-ci.d.mts.map +0 -1
- package/dist/types/commands/config/cmd-config-auto.d.mts +0 -10
- package/dist/types/commands/config/cmd-config-auto.d.mts.map +0 -1
- package/dist/types/commands/config/cmd-config-get.d.mts +0 -9
- package/dist/types/commands/config/cmd-config-get.d.mts.map +0 -1
- package/dist/types/commands/config/cmd-config-list.d.mts +0 -9
- package/dist/types/commands/config/cmd-config-list.d.mts.map +0 -1
- package/dist/types/commands/config/cmd-config-set.d.mts +0 -10
- package/dist/types/commands/config/cmd-config-set.d.mts.map +0 -1
- package/dist/types/commands/config/cmd-config-unset.d.mts +0 -10
- package/dist/types/commands/config/cmd-config-unset.d.mts.map +0 -1
- package/dist/types/commands/config/cmd-config.d.mts +0 -3
- package/dist/types/commands/config/cmd-config.d.mts.map +0 -1
- package/dist/types/commands/config/discover-config-value.d.mts +0 -3
- package/dist/types/commands/config/discover-config-value.d.mts.map +0 -1
- package/dist/types/commands/config/handle-config-auto.d.mts +0 -7
- package/dist/types/commands/config/handle-config-auto.d.mts.map +0 -1
- package/dist/types/commands/config/handle-config-get.d.mts +0 -7
- package/dist/types/commands/config/handle-config-get.d.mts.map +0 -1
- package/dist/types/commands/config/handle-config-set.d.mts +0 -8
- package/dist/types/commands/config/handle-config-set.d.mts.map +0 -1
- package/dist/types/commands/config/handle-config-unset.d.mts +0 -7
- package/dist/types/commands/config/handle-config-unset.d.mts.map +0 -1
- package/dist/types/commands/config/output-config-auto.d.mts +0 -4
- package/dist/types/commands/config/output-config-auto.d.mts.map +0 -1
- package/dist/types/commands/config/output-config-get.d.mts +0 -4
- package/dist/types/commands/config/output-config-get.d.mts.map +0 -1
- package/dist/types/commands/config/output-config-list.d.mts +0 -6
- package/dist/types/commands/config/output-config-list.d.mts.map +0 -1
- package/dist/types/commands/config/output-config-set.d.mts +0 -3
- package/dist/types/commands/config/output-config-set.d.mts.map +0 -1
- package/dist/types/commands/config/output-config-unset.d.mts +0 -3
- package/dist/types/commands/config/output-config-unset.d.mts.map +0 -1
- package/dist/types/commands/fix/cmd-fix.d.mts +0 -10
- package/dist/types/commands/fix/cmd-fix.d.mts.map +0 -1
- package/dist/types/commands/fix/coana-fix.d.mts +0 -6
- package/dist/types/commands/fix/coana-fix.d.mts.map +0 -1
- package/dist/types/commands/fix/env-helpers.d.mts +0 -26
- package/dist/types/commands/fix/env-helpers.d.mts.map +0 -1
- package/dist/types/commands/fix/git.d.mts +0 -13
- package/dist/types/commands/fix/git.d.mts.map +0 -1
- package/dist/types/commands/fix/handle-fix.d.mts +0 -20
- package/dist/types/commands/fix/handle-fix.d.mts.map +0 -1
- package/dist/types/commands/fix/output-fix-result.d.mts +0 -3
- package/dist/types/commands/fix/output-fix-result.d.mts.map +0 -1
- package/dist/types/commands/fix/pull-request.d.mts +0 -31
- package/dist/types/commands/fix/pull-request.d.mts.map +0 -1
- package/dist/types/commands/fix/types.d.mts +0 -21
- package/dist/types/commands/fix/types.d.mts.map +0 -1
- package/dist/types/commands/install/cmd-install-completion.d.mts +0 -9
- package/dist/types/commands/install/cmd-install-completion.d.mts.map +0 -1
- package/dist/types/commands/install/cmd-install.d.mts +0 -3
- package/dist/types/commands/install/cmd-install.d.mts.map +0 -1
- package/dist/types/commands/install/handle-install-completion.d.mts +0 -2
- package/dist/types/commands/install/handle-install-completion.d.mts.map +0 -1
- package/dist/types/commands/install/output-install-completion.d.mts +0 -12
- package/dist/types/commands/install/output-install-completion.d.mts.map +0 -1
- package/dist/types/commands/install/setup-tab-completion.d.mts +0 -13
- package/dist/types/commands/install/setup-tab-completion.d.mts.map +0 -1
- package/dist/types/commands/json/cmd-json.d.mts +0 -9
- package/dist/types/commands/json/cmd-json.d.mts.map +0 -1
- package/dist/types/commands/json/handle-cmd-json.d.mts +0 -2
- package/dist/types/commands/json/handle-cmd-json.d.mts.map +0 -1
- package/dist/types/commands/json/output-cmd-json.d.mts +0 -2
- package/dist/types/commands/json/output-cmd-json.d.mts.map +0 -1
- package/dist/types/commands/login/apply-login.d.mts +0 -2
- package/dist/types/commands/login/apply-login.d.mts.map +0 -1
- package/dist/types/commands/login/attempt-login.d.mts +0 -6
- package/dist/types/commands/login/attempt-login.d.mts.map +0 -1
- package/dist/types/commands/login/cmd-login.d.mts +0 -10
- package/dist/types/commands/login/cmd-login.d.mts.map +0 -1
- package/dist/types/commands/logout/apply-logout.d.mts +0 -2
- package/dist/types/commands/logout/apply-logout.d.mts.map +0 -1
- package/dist/types/commands/logout/attempt-logout.d.mts +0 -2
- package/dist/types/commands/logout/attempt-logout.d.mts.map +0 -1
- package/dist/types/commands/logout/cmd-logout.d.mts +0 -9
- package/dist/types/commands/logout/cmd-logout.d.mts.map +0 -1
- package/dist/types/commands/manifest/cmd-manifest-auto.d.mts +0 -9
- package/dist/types/commands/manifest/cmd-manifest-auto.d.mts.map +0 -1
- package/dist/types/commands/manifest/cmd-manifest-cdxgen.d.mts +0 -9
- package/dist/types/commands/manifest/cmd-manifest-cdxgen.d.mts.map +0 -1
- package/dist/types/commands/manifest/cmd-manifest-conda.d.mts +0 -9
- package/dist/types/commands/manifest/cmd-manifest-conda.d.mts.map +0 -1
- package/dist/types/commands/manifest/cmd-manifest-gradle.d.mts +0 -9
- package/dist/types/commands/manifest/cmd-manifest-gradle.d.mts.map +0 -1
- package/dist/types/commands/manifest/cmd-manifest-kotlin.d.mts +0 -9
- package/dist/types/commands/manifest/cmd-manifest-kotlin.d.mts.map +0 -1
- package/dist/types/commands/manifest/cmd-manifest-scala.d.mts +0 -9
- package/dist/types/commands/manifest/cmd-manifest-scala.d.mts.map +0 -1
- package/dist/types/commands/manifest/cmd-manifest-setup.d.mts +0 -9
- package/dist/types/commands/manifest/cmd-manifest-setup.d.mts.map +0 -1
- package/dist/types/commands/manifest/cmd-manifest.d.mts +0 -9
- package/dist/types/commands/manifest/cmd-manifest.d.mts.map +0 -1
- package/dist/types/commands/manifest/convert-conda-to-requirements.d.mts +0 -8
- package/dist/types/commands/manifest/convert-conda-to-requirements.d.mts.map +0 -1
- package/dist/types/commands/manifest/convert_gradle_to_maven.d.mts +0 -7
- package/dist/types/commands/manifest/convert_gradle_to_maven.d.mts.map +0 -1
- package/dist/types/commands/manifest/convert_sbt_to_maven.d.mts +0 -8
- package/dist/types/commands/manifest/convert_sbt_to_maven.d.mts.map +0 -1
- package/dist/types/commands/manifest/detect-manifest-actions.d.mts +0 -13
- package/dist/types/commands/manifest/detect-manifest-actions.d.mts.map +0 -1
- package/dist/types/commands/manifest/generate_auto_manifest.d.mts +0 -9
- package/dist/types/commands/manifest/generate_auto_manifest.d.mts.map +0 -1
- package/dist/types/commands/manifest/handle-manifest-conda.d.mts +0 -9
- package/dist/types/commands/manifest/handle-manifest-conda.d.mts.map +0 -1
- package/dist/types/commands/manifest/handle-manifest-setup.d.mts +0 -2
- package/dist/types/commands/manifest/handle-manifest-setup.d.mts.map +0 -1
- package/dist/types/commands/manifest/output-manifest-setup.d.mts +0 -3
- package/dist/types/commands/manifest/output-manifest-setup.d.mts.map +0 -1
- package/dist/types/commands/manifest/output-requirements.d.mts +0 -6
- package/dist/types/commands/manifest/output-requirements.d.mts.map +0 -1
- package/dist/types/commands/manifest/run-cdxgen.d.mts +0 -6
- package/dist/types/commands/manifest/run-cdxgen.d.mts.map +0 -1
- package/dist/types/commands/manifest/setup-manifest-config.d.mts +0 -3
- package/dist/types/commands/manifest/setup-manifest-config.d.mts.map +0 -1
- package/dist/types/commands/npm/cmd-npm.d.mts +0 -10
- package/dist/types/commands/npm/cmd-npm.d.mts.map +0 -1
- package/dist/types/commands/npx/cmd-npx.d.mts +0 -9
- package/dist/types/commands/npx/cmd-npx.d.mts.map +0 -1
- package/dist/types/commands/oops/cmd-oops.d.mts +0 -9
- package/dist/types/commands/oops/cmd-oops.d.mts.map +0 -1
- package/dist/types/commands/optimize/add-overrides.d.mts +0 -20
- package/dist/types/commands/optimize/add-overrides.d.mts.map +0 -1
- package/dist/types/commands/optimize/apply-optimization.d.mts +0 -14
- package/dist/types/commands/optimize/apply-optimization.d.mts.map +0 -1
- package/dist/types/commands/optimize/cmd-optimize.d.mts +0 -10
- package/dist/types/commands/optimize/cmd-optimize.d.mts.map +0 -1
- package/dist/types/commands/optimize/deps-includes-by-agent.d.mts +0 -5
- package/dist/types/commands/optimize/deps-includes-by-agent.d.mts.map +0 -1
- package/dist/types/commands/optimize/get-dependency-entries.d.mts +0 -3
- package/dist/types/commands/optimize/get-dependency-entries.d.mts.map +0 -1
- package/dist/types/commands/optimize/get-overrides-by-agent.d.mts +0 -42
- package/dist/types/commands/optimize/get-overrides-by-agent.d.mts.map +0 -1
- package/dist/types/commands/optimize/handle-optimize.d.mts +0 -8
- package/dist/types/commands/optimize/handle-optimize.d.mts.map +0 -1
- package/dist/types/commands/optimize/lockfile-includes-by-agent.d.mts +0 -8
- package/dist/types/commands/optimize/lockfile-includes-by-agent.d.mts.map +0 -1
- package/dist/types/commands/optimize/ls-by-agent.d.mts +0 -13
- package/dist/types/commands/optimize/ls-by-agent.d.mts.map +0 -1
- package/dist/types/commands/optimize/output-optimize-result.d.mts +0 -9
- package/dist/types/commands/optimize/output-optimize-result.d.mts.map +0 -1
- package/dist/types/commands/optimize/shared.d.mts +0 -2
- package/dist/types/commands/optimize/shared.d.mts.map +0 -1
- package/dist/types/commands/optimize/types.d.mts +0 -9
- package/dist/types/commands/optimize/types.d.mts.map +0 -1
- package/dist/types/commands/optimize/update-lockfile.d.mts +0 -11
- package/dist/types/commands/optimize/update-lockfile.d.mts.map +0 -1
- package/dist/types/commands/optimize/update-manifest-by-agent.d.mts +0 -8
- package/dist/types/commands/optimize/update-manifest-by-agent.d.mts.map +0 -1
- package/dist/types/commands/organization/cmd-organization-dependencies.d.mts +0 -10
- package/dist/types/commands/organization/cmd-organization-dependencies.d.mts.map +0 -1
- package/dist/types/commands/organization/cmd-organization-list.d.mts +0 -10
- package/dist/types/commands/organization/cmd-organization-list.d.mts.map +0 -1
- package/dist/types/commands/organization/cmd-organization-policy-license.d.mts +0 -10
- package/dist/types/commands/organization/cmd-organization-policy-license.d.mts.map +0 -1
- package/dist/types/commands/organization/cmd-organization-policy-security.d.mts +0 -10
- package/dist/types/commands/organization/cmd-organization-policy-security.d.mts.map +0 -1
- package/dist/types/commands/organization/cmd-organization-policy.d.mts +0 -3
- package/dist/types/commands/organization/cmd-organization-policy.d.mts.map +0 -1
- package/dist/types/commands/organization/cmd-organization-quota.d.mts +0 -9
- package/dist/types/commands/organization/cmd-organization-quota.d.mts.map +0 -1
- package/dist/types/commands/organization/cmd-organization.d.mts +0 -3
- package/dist/types/commands/organization/cmd-organization.d.mts.map +0 -1
- package/dist/types/commands/organization/fetch-dependencies.d.mts +0 -12
- package/dist/types/commands/organization/fetch-dependencies.d.mts.map +0 -1
- package/dist/types/commands/organization/fetch-license-policy.d.mts +0 -8
- package/dist/types/commands/organization/fetch-license-policy.d.mts.map +0 -1
- package/dist/types/commands/organization/fetch-organization-list.d.mts +0 -20
- package/dist/types/commands/organization/fetch-organization-list.d.mts.map +0 -1
- package/dist/types/commands/organization/fetch-quota.d.mts +0 -8
- package/dist/types/commands/organization/fetch-quota.d.mts.map +0 -1
- package/dist/types/commands/organization/fetch-security-policy.d.mts +0 -8
- package/dist/types/commands/organization/fetch-security-policy.d.mts.map +0 -1
- package/dist/types/commands/organization/handle-dependencies.d.mts +0 -7
- package/dist/types/commands/organization/handle-dependencies.d.mts.map +0 -1
- package/dist/types/commands/organization/handle-license-policy.d.mts +0 -3
- package/dist/types/commands/organization/handle-license-policy.d.mts.map +0 -1
- package/dist/types/commands/organization/handle-organization-list.d.mts +0 -3
- package/dist/types/commands/organization/handle-organization-list.d.mts.map +0 -1
- package/dist/types/commands/organization/handle-quota.d.mts +0 -3
- package/dist/types/commands/organization/handle-quota.d.mts.map +0 -1
- package/dist/types/commands/organization/handle-security-policy.d.mts +0 -3
- package/dist/types/commands/organization/handle-security-policy.d.mts.map +0 -1
- package/dist/types/commands/organization/output-dependencies.d.mts +0 -8
- package/dist/types/commands/organization/output-dependencies.d.mts.map +0 -1
- package/dist/types/commands/organization/output-license-policy.d.mts +0 -4
- package/dist/types/commands/organization/output-license-policy.d.mts.map +0 -1
- package/dist/types/commands/organization/output-organization-list.d.mts +0 -4
- package/dist/types/commands/organization/output-organization-list.d.mts.map +0 -1
- package/dist/types/commands/organization/output-quota.d.mts +0 -4
- package/dist/types/commands/organization/output-quota.d.mts.map +0 -1
- package/dist/types/commands/organization/output-security-policy.d.mts +0 -4
- package/dist/types/commands/organization/output-security-policy.d.mts.map +0 -1
- package/dist/types/commands/package/cmd-package-score.d.mts +0 -10
- package/dist/types/commands/package/cmd-package-score.d.mts.map +0 -1
- package/dist/types/commands/package/cmd-package-shallow.d.mts +0 -17
- package/dist/types/commands/package/cmd-package-shallow.d.mts.map +0 -1
- package/dist/types/commands/package/cmd-package.d.mts +0 -3
- package/dist/types/commands/package/cmd-package.d.mts.map +0 -1
- package/dist/types/commands/package/fetch-purl-deep-score.d.mts +0 -51
- package/dist/types/commands/package/fetch-purl-deep-score.d.mts.map +0 -1
- package/dist/types/commands/package/fetch-purls-shallow-score.d.mts +0 -8
- package/dist/types/commands/package/fetch-purls-shallow-score.d.mts.map +0 -1
- package/dist/types/commands/package/handle-purl-deep-score.d.mts +0 -3
- package/dist/types/commands/package/handle-purl-deep-score.d.mts.map +0 -1
- package/dist/types/commands/package/handle-purls-shallow-score.d.mts +0 -6
- package/dist/types/commands/package/handle-purls-shallow-score.d.mts.map +0 -1
- package/dist/types/commands/package/output-purls-deep-score.d.mts +0 -5
- package/dist/types/commands/package/output-purls-deep-score.d.mts.map +0 -1
- package/dist/types/commands/package/output-purls-shallow-score.d.mts +0 -29
- package/dist/types/commands/package/output-purls-shallow-score.d.mts.map +0 -1
- package/dist/types/commands/package/parse-package-specifiers.d.mts +0 -9
- package/dist/types/commands/package/parse-package-specifiers.d.mts.map +0 -1
- package/dist/types/commands/patch/cmd-patch.d.mts +0 -10
- package/dist/types/commands/patch/cmd-patch.d.mts.map +0 -1
- package/dist/types/commands/patch/handle-patch.d.mts +0 -12
- package/dist/types/commands/patch/handle-patch.d.mts.map +0 -1
- package/dist/types/commands/patch/manifest-schema.d.mts +0 -34
- package/dist/types/commands/patch/manifest-schema.d.mts.map +0 -1
- package/dist/types/commands/patch/output-patch-result.d.mts +0 -5
- package/dist/types/commands/patch/output-patch-result.d.mts.map +0 -1
- package/dist/types/commands/pnpm/cmd-pnpm.d.mts +0 -10
- package/dist/types/commands/pnpm/cmd-pnpm.d.mts.map +0 -1
- package/dist/types/commands/raw-npm/cmd-raw-npm.d.mts +0 -9
- package/dist/types/commands/raw-npm/cmd-raw-npm.d.mts.map +0 -1
- package/dist/types/commands/raw-npm/run-raw-npm.d.mts +0 -2
- package/dist/types/commands/raw-npm/run-raw-npm.d.mts.map +0 -1
- package/dist/types/commands/raw-npx/cmd-raw-npx.d.mts +0 -9
- package/dist/types/commands/raw-npx/cmd-raw-npx.d.mts.map +0 -1
- package/dist/types/commands/raw-npx/run-raw-npx.d.mts +0 -2
- package/dist/types/commands/raw-npx/run-raw-npx.d.mts.map +0 -1
- package/dist/types/commands/repository/cmd-repository-create.d.mts +0 -10
- package/dist/types/commands/repository/cmd-repository-create.d.mts.map +0 -1
- package/dist/types/commands/repository/cmd-repository-del.d.mts +0 -10
- package/dist/types/commands/repository/cmd-repository-del.d.mts.map +0 -1
- package/dist/types/commands/repository/cmd-repository-list.d.mts +0 -10
- package/dist/types/commands/repository/cmd-repository-list.d.mts.map +0 -1
- package/dist/types/commands/repository/cmd-repository-update.d.mts +0 -10
- package/dist/types/commands/repository/cmd-repository-update.d.mts.map +0 -1
- package/dist/types/commands/repository/cmd-repository-view.d.mts +0 -10
- package/dist/types/commands/repository/cmd-repository-view.d.mts.map +0 -1
- package/dist/types/commands/repository/cmd-repository.d.mts +0 -3
- package/dist/types/commands/repository/cmd-repository.d.mts.map +0 -1
- package/dist/types/commands/repository/fetch-create-repo.d.mts +0 -16
- package/dist/types/commands/repository/fetch-create-repo.d.mts.map +0 -1
- package/dist/types/commands/repository/fetch-delete-repo.d.mts +0 -8
- package/dist/types/commands/repository/fetch-delete-repo.d.mts.map +0 -1
- package/dist/types/commands/repository/fetch-list-all-repos.d.mts +0 -10
- package/dist/types/commands/repository/fetch-list-all-repos.d.mts.map +0 -1
- package/dist/types/commands/repository/fetch-list-repos.d.mts +0 -15
- package/dist/types/commands/repository/fetch-list-repos.d.mts.map +0 -1
- package/dist/types/commands/repository/fetch-update-repo.d.mts +0 -16
- package/dist/types/commands/repository/fetch-update-repo.d.mts.map +0 -1
- package/dist/types/commands/repository/fetch-view-repo.d.mts +0 -8
- package/dist/types/commands/repository/fetch-view-repo.d.mts.map +0 -1
- package/dist/types/commands/repository/handle-create-repo.d.mts +0 -10
- package/dist/types/commands/repository/handle-create-repo.d.mts.map +0 -1
- package/dist/types/commands/repository/handle-delete-repo.d.mts +0 -3
- package/dist/types/commands/repository/handle-delete-repo.d.mts.map +0 -1
- package/dist/types/commands/repository/handle-list-repos.d.mts +0 -12
- package/dist/types/commands/repository/handle-list-repos.d.mts.map +0 -1
- package/dist/types/commands/repository/handle-update-repo.d.mts +0 -10
- package/dist/types/commands/repository/handle-update-repo.d.mts.map +0 -1
- package/dist/types/commands/repository/handle-view-repo.d.mts +0 -3
- package/dist/types/commands/repository/handle-view-repo.d.mts.map +0 -1
- package/dist/types/commands/repository/output-create-repo.d.mts +0 -4
- package/dist/types/commands/repository/output-create-repo.d.mts.map +0 -1
- package/dist/types/commands/repository/output-delete-repo.d.mts +0 -4
- package/dist/types/commands/repository/output-delete-repo.d.mts.map +0 -1
- package/dist/types/commands/repository/output-list-repos.d.mts +0 -5
- package/dist/types/commands/repository/output-list-repos.d.mts.map +0 -1
- package/dist/types/commands/repository/output-update-repo.d.mts +0 -4
- package/dist/types/commands/repository/output-update-repo.d.mts.map +0 -1
- package/dist/types/commands/repository/output-view-repo.d.mts +0 -4
- package/dist/types/commands/repository/output-view-repo.d.mts.map +0 -1
- package/dist/types/commands/repository/types.d.mts +0 -2
- package/dist/types/commands/repository/types.d.mts.map +0 -1
- package/dist/types/commands/scan/cmd-scan-create.d.mts +0 -10
- package/dist/types/commands/scan/cmd-scan-create.d.mts.map +0 -1
- package/dist/types/commands/scan/cmd-scan-del.d.mts +0 -10
- package/dist/types/commands/scan/cmd-scan-del.d.mts.map +0 -1
- package/dist/types/commands/scan/cmd-scan-diff.d.mts +0 -10
- package/dist/types/commands/scan/cmd-scan-diff.d.mts.map +0 -1
- package/dist/types/commands/scan/cmd-scan-github.d.mts +0 -10
- package/dist/types/commands/scan/cmd-scan-github.d.mts.map +0 -1
- package/dist/types/commands/scan/cmd-scan-list.d.mts +0 -4
- package/dist/types/commands/scan/cmd-scan-list.d.mts.map +0 -1
- package/dist/types/commands/scan/cmd-scan-metadata.d.mts +0 -4
- package/dist/types/commands/scan/cmd-scan-metadata.d.mts.map +0 -1
- package/dist/types/commands/scan/cmd-scan-reach.d.mts +0 -10
- package/dist/types/commands/scan/cmd-scan-reach.d.mts.map +0 -1
- package/dist/types/commands/scan/cmd-scan-report.d.mts +0 -4
- package/dist/types/commands/scan/cmd-scan-report.d.mts.map +0 -1
- package/dist/types/commands/scan/cmd-scan-setup.d.mts +0 -9
- package/dist/types/commands/scan/cmd-scan-setup.d.mts.map +0 -1
- package/dist/types/commands/scan/cmd-scan-view.d.mts +0 -4
- package/dist/types/commands/scan/cmd-scan-view.d.mts.map +0 -1
- package/dist/types/commands/scan/cmd-scan.d.mts +0 -3
- package/dist/types/commands/scan/cmd-scan.d.mts.map +0 -1
- package/dist/types/commands/scan/create-scan-from-github.d.mts +0 -12
- package/dist/types/commands/scan/create-scan-from-github.d.mts.map +0 -1
- package/dist/types/commands/scan/fetch-create-org-full-scan.d.mts +0 -20
- package/dist/types/commands/scan/fetch-create-org-full-scan.d.mts.map +0 -1
- package/dist/types/commands/scan/fetch-delete-org-full-scan.d.mts +0 -8
- package/dist/types/commands/scan/fetch-delete-org-full-scan.d.mts.map +0 -1
- package/dist/types/commands/scan/fetch-diff-scan.d.mts +0 -8
- package/dist/types/commands/scan/fetch-diff-scan.d.mts.map +0 -1
- package/dist/types/commands/scan/fetch-list-scans.d.mts +0 -18
- package/dist/types/commands/scan/fetch-list-scans.d.mts.map +0 -1
- package/dist/types/commands/scan/fetch-report-data.d.mts +0 -17
- package/dist/types/commands/scan/fetch-report-data.d.mts.map +0 -1
- package/dist/types/commands/scan/fetch-scan-metadata.d.mts +0 -8
- package/dist/types/commands/scan/fetch-scan-metadata.d.mts.map +0 -1
- package/dist/types/commands/scan/fetch-scan.d.mts +0 -4
- package/dist/types/commands/scan/fetch-scan.d.mts.map +0 -1
- package/dist/types/commands/scan/fetch-supported-scan-file-names.d.mts +0 -10
- package/dist/types/commands/scan/fetch-supported-scan-file-names.d.mts.map +0 -1
- package/dist/types/commands/scan/finalize-tier1-scan.d.mts +0 -12
- package/dist/types/commands/scan/finalize-tier1-scan.d.mts.map +0 -1
- package/dist/types/commands/scan/generate-report.d.mts +0 -44
- package/dist/types/commands/scan/generate-report.d.mts.map +0 -1
- package/dist/types/commands/scan/handle-create-github-scan.d.mts +0 -12
- package/dist/types/commands/scan/handle-create-github-scan.d.mts.map +0 -1
- package/dist/types/commands/scan/handle-create-new-scan.d.mts +0 -29
- package/dist/types/commands/scan/handle-create-new-scan.d.mts.map +0 -1
- package/dist/types/commands/scan/handle-delete-scan.d.mts +0 -3
- package/dist/types/commands/scan/handle-delete-scan.d.mts.map +0 -1
- package/dist/types/commands/scan/handle-diff-scan.d.mts +0 -10
- package/dist/types/commands/scan/handle-diff-scan.d.mts.map +0 -1
- package/dist/types/commands/scan/handle-list-scans.d.mts +0 -13
- package/dist/types/commands/scan/handle-list-scans.d.mts.map +0 -1
- package/dist/types/commands/scan/handle-scan-config.d.mts +0 -2
- package/dist/types/commands/scan/handle-scan-config.d.mts.map +0 -1
- package/dist/types/commands/scan/handle-scan-metadata.d.mts +0 -3
- package/dist/types/commands/scan/handle-scan-metadata.d.mts.map +0 -1
- package/dist/types/commands/scan/handle-scan-reach.d.mts +0 -12
- package/dist/types/commands/scan/handle-scan-reach.d.mts.map +0 -1
- package/dist/types/commands/scan/handle-scan-report.d.mts +0 -14
- package/dist/types/commands/scan/handle-scan-report.d.mts.map +0 -1
- package/dist/types/commands/scan/handle-scan-view.d.mts +0 -3
- package/dist/types/commands/scan/handle-scan-view.d.mts.map +0 -1
- package/dist/types/commands/scan/output-create-new-scan.d.mts +0 -10
- package/dist/types/commands/scan/output-create-new-scan.d.mts.map +0 -1
- package/dist/types/commands/scan/output-delete-scan.d.mts +0 -4
- package/dist/types/commands/scan/output-delete-scan.d.mts.map +0 -1
- package/dist/types/commands/scan/output-diff-scan.d.mts +0 -8
- package/dist/types/commands/scan/output-diff-scan.d.mts.map +0 -1
- package/dist/types/commands/scan/output-list-scans.d.mts +0 -4
- package/dist/types/commands/scan/output-list-scans.d.mts.map +0 -1
- package/dist/types/commands/scan/output-scan-config-result.d.mts +0 -3
- package/dist/types/commands/scan/output-scan-config-result.d.mts.map +0 -1
- package/dist/types/commands/scan/output-scan-github.d.mts +0 -3
- package/dist/types/commands/scan/output-scan-github.d.mts.map +0 -1
- package/dist/types/commands/scan/output-scan-metadata.d.mts +0 -4
- package/dist/types/commands/scan/output-scan-metadata.d.mts.map +0 -1
- package/dist/types/commands/scan/output-scan-reach.d.mts +0 -7
- package/dist/types/commands/scan/output-scan-reach.d.mts.map +0 -1
- package/dist/types/commands/scan/output-scan-report.d.mts +0 -22
- package/dist/types/commands/scan/output-scan-report.d.mts.map +0 -1
- package/dist/types/commands/scan/output-scan-view.d.mts +0 -4
- package/dist/types/commands/scan/output-scan-view.d.mts.map +0 -1
- package/dist/types/commands/scan/perform-reachability-analysis.d.mts +0 -27
- package/dist/types/commands/scan/perform-reachability-analysis.d.mts.map +0 -1
- package/dist/types/commands/scan/reachability-flags.d.mts +0 -3
- package/dist/types/commands/scan/reachability-flags.d.mts.map +0 -1
- package/dist/types/commands/scan/setup-scan-config.d.mts +0 -3
- package/dist/types/commands/scan/setup-scan-config.d.mts.map +0 -1
- package/dist/types/commands/scan/stream-scan.d.mts +0 -7
- package/dist/types/commands/scan/stream-scan.d.mts.map +0 -1
- package/dist/types/commands/scan/suggest-org-slug.d.mts +0 -2
- package/dist/types/commands/scan/suggest-org-slug.d.mts.map +0 -1
- package/dist/types/commands/scan/suggest-to-persist-orgslug.d.mts +0 -2
- package/dist/types/commands/scan/suggest-to-persist-orgslug.d.mts.map +0 -1
- package/dist/types/commands/scan/suggest_branch_slug.d.mts +0 -2
- package/dist/types/commands/scan/suggest_branch_slug.d.mts.map +0 -1
- package/dist/types/commands/scan/suggest_target.d.mts +0 -2
- package/dist/types/commands/scan/suggest_target.d.mts.map +0 -1
- package/dist/types/commands/scan/types.d.mts +0 -3
- package/dist/types/commands/scan/types.d.mts.map +0 -1
- package/dist/types/commands/threat-feed/cmd-threat-feed.d.mts +0 -10
- package/dist/types/commands/threat-feed/cmd-threat-feed.d.mts.map +0 -1
- package/dist/types/commands/threat-feed/fetch-threat-feed.d.mts +0 -13
- package/dist/types/commands/threat-feed/fetch-threat-feed.d.mts.map +0 -1
- package/dist/types/commands/threat-feed/handle-threat-feed.d.mts +0 -13
- package/dist/types/commands/threat-feed/handle-threat-feed.d.mts.map +0 -1
- package/dist/types/commands/threat-feed/output-threat-feed.d.mts +0 -4
- package/dist/types/commands/threat-feed/output-threat-feed.d.mts.map +0 -1
- package/dist/types/commands/threat-feed/types.d.mts +0 -15
- package/dist/types/commands/threat-feed/types.d.mts.map +0 -1
- package/dist/types/commands/uninstall/cmd-uninstall-completion.d.mts +0 -8
- package/dist/types/commands/uninstall/cmd-uninstall-completion.d.mts.map +0 -1
- package/dist/types/commands/uninstall/cmd-uninstall.d.mts +0 -3
- package/dist/types/commands/uninstall/cmd-uninstall.d.mts.map +0 -1
- package/dist/types/commands/uninstall/handle-uninstall-completion.d.mts +0 -2
- package/dist/types/commands/uninstall/handle-uninstall-completion.d.mts.map +0 -1
- package/dist/types/commands/uninstall/output-uninstall-completion.d.mts +0 -6
- package/dist/types/commands/uninstall/output-uninstall-completion.d.mts.map +0 -1
- package/dist/types/commands/uninstall/teardown-tab-completion.d.mts +0 -6
- package/dist/types/commands/uninstall/teardown-tab-completion.d.mts.map +0 -1
- package/dist/types/commands/wrapper/add-socket-wrapper.d.mts +0 -2
- package/dist/types/commands/wrapper/add-socket-wrapper.d.mts.map +0 -1
- package/dist/types/commands/wrapper/check-socket-wrapper-setup.d.mts +0 -2
- package/dist/types/commands/wrapper/check-socket-wrapper-setup.d.mts.map +0 -1
- package/dist/types/commands/wrapper/cmd-wrapper.d.mts +0 -9
- package/dist/types/commands/wrapper/cmd-wrapper.d.mts.map +0 -1
- package/dist/types/commands/wrapper/postinstall-wrapper.d.mts +0 -2
- package/dist/types/commands/wrapper/postinstall-wrapper.d.mts.map +0 -1
- package/dist/types/commands/wrapper/remove-socket-wrapper.d.mts +0 -2
- package/dist/types/commands/wrapper/remove-socket-wrapper.d.mts.map +0 -1
- package/dist/types/commands/yarn/cmd-yarn.d.mts +0 -10
- package/dist/types/commands/yarn/cmd-yarn.d.mts.map +0 -1
- package/dist/types/commands.d.mts +0 -203
- package/dist/types/commands.d.mts.map +0 -1
- package/dist/types/constants.d.mts +0 -299
- package/dist/types/constants.d.mts.map +0 -1
- package/dist/types/flags.d.mts +0 -18
- package/dist/types/flags.d.mts.map +0 -1
- package/dist/types/instrument-with-sentry.d.mts +0 -2
- package/dist/types/instrument-with-sentry.d.mts.map +0 -1
- package/dist/types/npm-cli.d.mts +0 -3
- package/dist/types/npm-cli.d.mts.map +0 -1
- package/dist/types/npx-cli.d.mts +0 -3
- package/dist/types/npx-cli.d.mts.map +0 -1
- package/dist/types/pnpm-cli.d.mts +0 -3
- package/dist/types/pnpm-cli.d.mts.map +0 -1
- package/dist/types/sea/bootstrap.d.mts +0 -2
- package/dist/types/sea/bootstrap.d.mts.map +0 -1
- package/dist/types/sea/build-sea.d.mts +0 -27
- package/dist/types/sea/build-sea.d.mts.map +0 -1
- package/dist/types/shadow/common.d.mts +0 -23
- package/dist/types/shadow/common.d.mts.map +0 -1
- package/dist/types/shadow/npm/arborist/index.d.mts +0 -8
- package/dist/types/shadow/npm/arborist/index.d.mts.map +0 -1
- package/dist/types/shadow/npm/arborist/lib/arborist/index.d.mts +0 -35
- package/dist/types/shadow/npm/arborist/lib/arborist/index.d.mts.map +0 -1
- package/dist/types/shadow/npm/arborist/types.d.mts +0 -123
- package/dist/types/shadow/npm/arborist/types.d.mts.map +0 -1
- package/dist/types/shadow/npm/arborist-helpers.d.mts +0 -24
- package/dist/types/shadow/npm/arborist-helpers.d.mts.map +0 -1
- package/dist/types/shadow/npm/bin.d.mts +0 -5
- package/dist/types/shadow/npm/bin.d.mts.map +0 -1
- package/dist/types/shadow/npm/inject.d.mts +0 -2
- package/dist/types/shadow/npm/inject.d.mts.map +0 -1
- package/dist/types/shadow/npm/install.d.mts +0 -13
- package/dist/types/shadow/npm/install.d.mts.map +0 -1
- package/dist/types/shadow/npm/paths.d.mts +0 -6
- package/dist/types/shadow/npm/paths.d.mts.map +0 -1
- package/dist/types/shadow/npm-base.d.mts +0 -11
- package/dist/types/shadow/npm-base.d.mts.map +0 -1
- package/dist/types/shadow/npx/bin.d.mts +0 -5
- package/dist/types/shadow/npx/bin.d.mts.map +0 -1
- package/dist/types/shadow/pnpm/bin.d.mts +0 -10
- package/dist/types/shadow/pnpm/bin.d.mts.map +0 -1
- package/dist/types/shadow/stdio-ipc.d.mts +0 -7
- package/dist/types/shadow/stdio-ipc.d.mts.map +0 -1
- package/dist/types/shadow/yarn/bin.d.mts +0 -10
- package/dist/types/shadow/yarn/bin.d.mts.map +0 -1
- package/dist/types/test/json-output-validation.d.mts +0 -37
- package/dist/types/test/json-output-validation.d.mts.map +0 -1
- package/dist/types/test/mocks/socket-auth.d.mts +0 -88
- package/dist/types/test/mocks/socket-auth.d.mts.map +0 -1
- package/dist/types/types.d.mts +0 -29
- package/dist/types/types.d.mts.map +0 -1
- package/dist/types/utils/agent.d.mts +0 -12
- package/dist/types/utils/agent.d.mts.map +0 -1
- package/dist/types/utils/alert/artifact.d.mts +0 -21
- package/dist/types/utils/alert/artifact.d.mts.map +0 -1
- package/dist/types/utils/alert/fix.d.mts +0 -6
- package/dist/types/utils/alert/fix.d.mts.map +0 -1
- package/dist/types/utils/alert/severity.d.mts +0 -14
- package/dist/types/utils/alert/severity.d.mts.map +0 -1
- package/dist/types/utils/alerts-map.d.mts +0 -27
- package/dist/types/utils/alerts-map.d.mts.map +0 -1
- package/dist/types/utils/api.d.mts +0 -44
- package/dist/types/utils/api.d.mts.map +0 -1
- package/dist/types/utils/check-input.d.mts +0 -9
- package/dist/types/utils/check-input.d.mts.map +0 -1
- package/dist/types/utils/cmd.d.mts +0 -50
- package/dist/types/utils/cmd.d.mts.map +0 -1
- package/dist/types/utils/coana.d.mts +0 -2
- package/dist/types/utils/coana.d.mts.map +0 -1
- package/dist/types/utils/color-or-markdown.d.mts +0 -16
- package/dist/types/utils/color-or-markdown.d.mts.map +0 -1
- package/dist/types/utils/completion.d.mts +0 -11
- package/dist/types/utils/completion.d.mts.map +0 -1
- package/dist/types/utils/config.d.mts +0 -34
- package/dist/types/utils/config.d.mts.map +0 -1
- package/dist/types/utils/cve-to-ghsa.d.mts +0 -6
- package/dist/types/utils/cve-to-ghsa.d.mts.map +0 -1
- package/dist/types/utils/debug.d.mts +0 -45
- package/dist/types/utils/debug.d.mts.map +0 -1
- package/dist/types/utils/determine-org-slug.d.mts +0 -2
- package/dist/types/utils/determine-org-slug.d.mts.map +0 -1
- package/dist/types/utils/dlx-binary.d.mts +0 -58
- package/dist/types/utils/dlx-binary.d.mts.map +0 -1
- package/dist/types/utils/dlx-detection.d.mts +0 -29
- package/dist/types/utils/dlx-detection.d.mts.map +0 -1
- package/dist/types/utils/dlx.d.mts +0 -36
- package/dist/types/utils/dlx.d.mts.map +0 -1
- package/dist/types/utils/ecosystem.d.mts +0 -20
- package/dist/types/utils/ecosystem.d.mts.map +0 -1
- package/dist/types/utils/errors.d.mts +0 -62
- package/dist/types/utils/errors.d.mts.map +0 -1
- package/dist/types/utils/extract-names.d.mts +0 -15
- package/dist/types/utils/extract-names.d.mts.map +0 -1
- package/dist/types/utils/fail-msg-with-badge.d.mts +0 -2
- package/dist/types/utils/fail-msg-with-badge.d.mts.map +0 -1
- package/dist/types/utils/filter-config.d.mts +0 -5
- package/dist/types/utils/filter-config.d.mts.map +0 -1
- package/dist/types/utils/fs.d.mts +0 -8
- package/dist/types/utils/fs.d.mts.map +0 -1
- package/dist/types/utils/get-output-kind.d.mts +0 -3
- package/dist/types/utils/get-output-kind.d.mts.map +0 -1
- package/dist/types/utils/git.d.mts +0 -35
- package/dist/types/utils/git.d.mts.map +0 -1
- package/dist/types/utils/github.d.mts +0 -38
- package/dist/types/utils/github.d.mts.map +0 -1
- package/dist/types/utils/glob.d.mts +0 -15
- package/dist/types/utils/glob.d.mts.map +0 -1
- package/dist/types/utils/lockfile.d.mts +0 -2
- package/dist/types/utils/lockfile.d.mts.map +0 -1
- package/dist/types/utils/map-to-object.d.mts +0 -10
- package/dist/types/utils/map-to-object.d.mts.map +0 -1
- package/dist/types/utils/markdown.d.mts +0 -27
- package/dist/types/utils/markdown.d.mts.map +0 -1
- package/dist/types/utils/meow-with-subcommands.d.mts +0 -83
- package/dist/types/utils/meow-with-subcommands.d.mts.map +0 -1
- package/dist/types/utils/ms-at-home.d.mts +0 -2
- package/dist/types/utils/ms-at-home.d.mts.map +0 -1
- package/dist/types/utils/npm-config.d.mts +0 -14
- package/dist/types/utils/npm-config.d.mts.map +0 -1
- package/dist/types/utils/npm-package-arg.d.mts +0 -8
- package/dist/types/utils/npm-package-arg.d.mts.map +0 -1
- package/dist/types/utils/npm-paths.d.mts +0 -7
- package/dist/types/utils/npm-paths.d.mts.map +0 -1
- package/dist/types/utils/npm-spec.d.mts +0 -57
- package/dist/types/utils/npm-spec.d.mts.map +0 -1
- package/dist/types/utils/objects.d.mts +0 -3
- package/dist/types/utils/objects.d.mts.map +0 -1
- package/dist/types/utils/organization.d.mts +0 -5
- package/dist/types/utils/organization.d.mts.map +0 -1
- package/dist/types/utils/output-formatting.d.mts +0 -20
- package/dist/types/utils/output-formatting.d.mts.map +0 -1
- package/dist/types/utils/package-environment.d.mts +0 -57
- package/dist/types/utils/package-environment.d.mts.map +0 -1
- package/dist/types/utils/path-resolve.d.mts +0 -14
- package/dist/types/utils/path-resolve.d.mts.map +0 -1
- package/dist/types/utils/pnpm-paths.d.mts +0 -5
- package/dist/types/utils/pnpm-paths.d.mts.map +0 -1
- package/dist/types/utils/pnpm.d.mts +0 -11
- package/dist/types/utils/pnpm.d.mts.map +0 -1
- package/dist/types/utils/purl-to-ghsa.d.mts +0 -6
- package/dist/types/utils/purl-to-ghsa.d.mts.map +0 -1
- package/dist/types/utils/purl.d.mts +0 -71
- package/dist/types/utils/purl.d.mts.map +0 -1
- package/dist/types/utils/requirements.d.mts +0 -125
- package/dist/types/utils/requirements.d.mts.map +0 -1
- package/dist/types/utils/sdk.d.mts +0 -17
- package/dist/types/utils/sdk.d.mts.map +0 -1
- package/dist/types/utils/semver.d.mts +0 -7
- package/dist/types/utils/semver.d.mts.map +0 -1
- package/dist/types/utils/serialize-result-json.d.mts +0 -5
- package/dist/types/utils/serialize-result-json.d.mts.map +0 -1
- package/dist/types/utils/shadow-links.d.mts +0 -5
- package/dist/types/utils/shadow-links.d.mts.map +0 -1
- package/dist/types/utils/socket-json.d.mts +0 -59
- package/dist/types/utils/socket-json.d.mts.map +0 -1
- package/dist/types/utils/socket-package-alert.d.mts +0 -80
- package/dist/types/utils/socket-package-alert.d.mts.map +0 -1
- package/dist/types/utils/socket-url.d.mts +0 -8
- package/dist/types/utils/socket-url.d.mts.map +0 -1
- package/dist/types/utils/spec.d.mts +0 -5
- package/dist/types/utils/spec.d.mts.map +0 -1
- package/dist/types/utils/strings.d.mts +0 -14
- package/dist/types/utils/strings.d.mts.map +0 -1
- package/dist/types/utils/terminal-link.d.mts +0 -52
- package/dist/types/utils/terminal-link.d.mts.map +0 -1
- package/dist/types/utils/tildify.d.mts +0 -2
- package/dist/types/utils/tildify.d.mts.map +0 -1
- package/dist/types/utils/translations.d.mts +0 -617
- package/dist/types/utils/translations.d.mts.map +0 -1
- package/dist/types/utils/walk-nested-map.d.mts +0 -7
- package/dist/types/utils/walk-nested-map.d.mts.map +0 -1
- package/dist/types/utils/yarn-paths.d.mts +0 -5
- package/dist/types/utils/yarn-paths.d.mts.map +0 -1
- package/dist/types/utils/yarn-version.d.mts +0 -2
- package/dist/types/utils/yarn-version.d.mts.map +0 -1
- package/dist/types/yarn-cli.d.mts +0 -3
- package/dist/types/yarn-cli.d.mts.map +0 -1
- package/dist/utils.js +0 -6146
- package/dist/utils.js.map +0 -1
- package/dist/vendor.js +0 -162074
- package/dist/yarn-cli.js +0 -30
- package/dist/yarn-cli.js.map +0 -1
- package/external/@socketsecurity/registry/LICENSE +0 -21
- package/external/@socketsecurity/registry/README.md +0 -9
- package/external/@socketsecurity/registry/extensions.json +0 -28
- package/external/@socketsecurity/registry/external/@inquirer/confirm.js +0 -3165
- package/external/@socketsecurity/registry/external/@inquirer/input.js +0 -3202
- package/external/@socketsecurity/registry/external/@inquirer/password.js +0 -3307
- package/external/@socketsecurity/registry/external/@inquirer/search.js +0 -3519
- package/external/@socketsecurity/registry/external/@inquirer/select.js +0 -3655
- package/external/@socketsecurity/registry/external/@npmcli/package-json/index.js +0 -21406
- package/external/@socketsecurity/registry/external/@npmcli/package-json/lib/read-package.js +0 -183
- package/external/@socketsecurity/registry/external/@npmcli/package-json/lib/sort.js +0 -274
- package/external/@socketsecurity/registry/external/@npmcli/promise-spawn.js +0 -704
- package/external/@socketsecurity/registry/external/@socketregistry/is-unicode-supported.js +0 -54
- package/external/@socketsecurity/registry/external/@socketregistry/packageurl-js.js +0 -4516
- package/external/@socketsecurity/registry/external/@socketregistry/yocto-spinner.js +0 -453
- package/external/@socketsecurity/registry/external/@yarnpkg/extensions.js +0 -1406
- package/external/@socketsecurity/registry/external/browserslist.js +0 -20496
- package/external/@socketsecurity/registry/external/cacache.js +0 -16208
- package/external/@socketsecurity/registry/external/debug.js +0 -1163
- package/external/@socketsecurity/registry/external/fast-glob.js +0 -7994
- package/external/@socketsecurity/registry/external/fast-sort.js +0 -181
- package/external/@socketsecurity/registry/external/libnpmpack.js +0 -106271
- package/external/@socketsecurity/registry/external/make-fetch-happen.js +0 -38997
- package/external/@socketsecurity/registry/external/normalize-package-data.js +0 -5343
- package/external/@socketsecurity/registry/external/npm-package-arg.js +0 -5773
- package/external/@socketsecurity/registry/external/pacote.js +0 -74109
- package/external/@socketsecurity/registry/external/picomatch.js +0 -2307
- package/external/@socketsecurity/registry/external/semver.js +0 -2618
- package/external/@socketsecurity/registry/external/signal-exit.js +0 -336
- package/external/@socketsecurity/registry/external/spdx-correct.js +0 -1457
- package/external/@socketsecurity/registry/external/spdx-expression-parse.js +0 -1043
- package/external/@socketsecurity/registry/external/streaming-iterables.js +0 -326
- package/external/@socketsecurity/registry/external/validate-npm-package-name.js +0 -108
- package/external/@socketsecurity/registry/external/which.js +0 -405
- package/external/@socketsecurity/registry/external/yoctocolors-cjs.js +0 -101
- package/external/@socketsecurity/registry/index.js +0 -31
- package/external/@socketsecurity/registry/lib/agent.js +0 -390
- package/external/@socketsecurity/registry/lib/arrays.js +0 -89
- package/external/@socketsecurity/registry/lib/bin.js +0 -650
- package/external/@socketsecurity/registry/lib/constants/abort-controller.js +0 -15
- package/external/@socketsecurity/registry/lib/constants/abort-signal.js +0 -27
- package/external/@socketsecurity/registry/lib/constants/at-latest.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/biome-json.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/bun-lock.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/bun-lockb.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/bun.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ci.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/column-limit.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/copy-left-licenses.js +0 -27
- package/external/@socketsecurity/registry/lib/constants/darwin.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/dot-git-dir.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/dot-package-lock-json.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/dot-socket-dir.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/empty-file.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/empty-value.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/env.js +0 -59
- package/external/@socketsecurity/registry/lib/constants/eslint-config-js.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/esnext.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/exec-path.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-cjs.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-cmd.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-cts.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-dts.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-js.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-json.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-lock.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-lockb.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-md.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-mjs.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-mts.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-ps1.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-yaml.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-yml.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/extensions-json.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/extensions.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/get-ipc.js +0 -10
- package/external/@socketsecurity/registry/lib/constants/gitignore.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/index.js +0 -139
- package/external/@socketsecurity/registry/lib/constants/ipc-handler.js +0 -19
- package/external/@socketsecurity/registry/lib/constants/ipc-object.js +0 -6
- package/external/@socketsecurity/registry/lib/constants/ipc-promise.js +0 -47
- package/external/@socketsecurity/registry/lib/constants/ipc-target.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/k-internals-symbol.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/latest.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/license-glob-recursive.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/license-glob.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/license-original-glob-recursive.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/license-original-glob.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/license-original.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/license.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/lifecycle-script-names.js +0 -18
- package/external/@socketsecurity/registry/lib/constants/loop-sentinel.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/maintained-node-versions.js +0 -47
- package/external/@socketsecurity/registry/lib/constants/manifest-json.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/mit.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/node-auth-token.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/node-debug-flags.js +0 -9
- package/external/@socketsecurity/registry/lib/constants/node-env.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/node-harden-flags.js +0 -29
- package/external/@socketsecurity/registry/lib/constants/node-modules-glob-recursive.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/node-modules.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/node-no-warnings-flags.js +0 -16
- package/external/@socketsecurity/registry/lib/constants/node-version.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/npm-exec-path.js +0 -5
- package/external/@socketsecurity/registry/lib/constants/npm-real-exec-path.js +0 -6
- package/external/@socketsecurity/registry/lib/constants/npm-shrinkwrap-json.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/npm.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/npx.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/overrides.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/package-default-node-range.js +0 -6
- package/external/@socketsecurity/registry/lib/constants/package-default-socket-categories.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/package-default-version.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/package-extensions.js +0 -47
- package/external/@socketsecurity/registry/lib/constants/package-json.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/package-lock-json.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/packument-cache.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/pacote-cache-path.js +0 -9
- package/external/@socketsecurity/registry/lib/constants/pnpm-exec-path.js +0 -5
- package/external/@socketsecurity/registry/lib/constants/pnpm-lock-yaml.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/pnpm.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/pre-commit.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/readme-glob-recursive.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/readme-glob.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/readme-md.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/registry-scope-delimiter.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/registry.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/resolutions.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/socket-github-org.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/socket-ipc-handshake.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/socket-override-scope.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/socket-public-api-token.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/socket-registry-npm-org.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/socket-registry-package-name.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/socket-registry-repo-name.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/socket-registry-scope.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/socket-security-scope.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/spinner.js +0 -4
- package/external/@socketsecurity/registry/lib/constants/supports-node-compile-cache-api.js +0 -8
- package/external/@socketsecurity/registry/lib/constants/supports-node-compile-cache-env-var.js +0 -8
- package/external/@socketsecurity/registry/lib/constants/supports-node-disable-warning-flag.js +0 -8
- package/external/@socketsecurity/registry/lib/constants/supports-node-permission-flag.js +0 -8
- package/external/@socketsecurity/registry/lib/constants/supports-node-require-module.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/supports-node-run.js +0 -8
- package/external/@socketsecurity/registry/lib/constants/supports-process-send.js +0 -5
- package/external/@socketsecurity/registry/lib/constants/ts-libs-available.js +0 -22
- package/external/@socketsecurity/registry/lib/constants/ts-types-available.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/tsconfig-json.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/undefined-token.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/unknown-error.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/unknown-value.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/unlicenced.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/unlicensed.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/utf8.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/vitest.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/vlt-lock-json.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/vlt.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/win32.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/yarn-berry.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/yarn-classic.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/yarn-exec-path.js +0 -5
- package/external/@socketsecurity/registry/lib/constants/yarn-lock.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/yarn.js +0 -3
- package/external/@socketsecurity/registry/lib/debug.js +0 -264
- package/external/@socketsecurity/registry/lib/env.js +0 -62
- package/external/@socketsecurity/registry/lib/fs.js +0 -556
- package/external/@socketsecurity/registry/lib/functions.js +0 -20
- package/external/@socketsecurity/registry/lib/globs.js +0 -145
- package/external/@socketsecurity/registry/lib/json.js +0 -69
- package/external/@socketsecurity/registry/lib/logger.js +0 -534
- package/external/@socketsecurity/registry/lib/objects.js +0 -422
- package/external/@socketsecurity/registry/lib/packages.js +0 -1376
- package/external/@socketsecurity/registry/lib/path.js +0 -231
- package/external/@socketsecurity/registry/lib/promises.js +0 -286
- package/external/@socketsecurity/registry/lib/prompts.js +0 -63
- package/external/@socketsecurity/registry/lib/regexps.js +0 -23
- package/external/@socketsecurity/registry/lib/sorts.js +0 -70
- package/external/@socketsecurity/registry/lib/spawn.js +0 -252
- package/external/@socketsecurity/registry/lib/spinner.js +0 -205
- package/external/@socketsecurity/registry/lib/streams.js +0 -84
- package/external/@socketsecurity/registry/lib/strings.js +0 -235
- package/external/@socketsecurity/registry/lib/url.js +0 -68
- package/external/@socketsecurity/registry/lib/words.js +0 -45
- package/external/@socketsecurity/registry/manifest.json +0 -1875
- package/external/blessed/LICENSE +0 -20
- package/external/blessed/README.md +0 -2421
- package/external/blessed/lib/alias.js +0 -528
- package/external/blessed/lib/blessed.js +0 -34
- package/external/blessed/lib/colors.js +0 -532
- package/external/blessed/lib/events.js +0 -191
- package/external/blessed/lib/gpmclient.js +0 -223
- package/external/blessed/lib/helpers.js +0 -167
- package/external/blessed/lib/keys.js +0 -341
- package/external/blessed/lib/program.js +0 -4297
- package/external/blessed/lib/tput.js +0 -3020
- package/external/blessed/lib/unicode.js +0 -792
- package/external/blessed/lib/widget.js +0 -62
- package/external/blessed/lib/widgets/ansiimage.js +0 -169
- package/external/blessed/lib/widgets/bigtext.js +0 -161
- package/external/blessed/lib/widgets/box.js +0 -36
- package/external/blessed/lib/widgets/button.js +0 -64
- package/external/blessed/lib/widgets/checkbox.js +0 -93
- package/external/blessed/lib/widgets/element.js +0 -2572
- package/external/blessed/lib/widgets/filemanager.js +0 -214
- package/external/blessed/lib/widgets/form.js +0 -269
- package/external/blessed/lib/widgets/image.js +0 -63
- package/external/blessed/lib/widgets/input.js +0 -36
- package/external/blessed/lib/widgets/layout.js +0 -235
- package/external/blessed/lib/widgets/line.js +0 -58
- package/external/blessed/lib/widgets/list.js +0 -601
- package/external/blessed/lib/widgets/listbar.js +0 -413
- package/external/blessed/lib/widgets/listtable.js +0 -254
- package/external/blessed/lib/widgets/loading.js +0 -90
- package/external/blessed/lib/widgets/log.js +0 -85
- package/external/blessed/lib/widgets/message.js +0 -125
- package/external/blessed/lib/widgets/node.js +0 -284
- package/external/blessed/lib/widgets/overlayimage.js +0 -719
- package/external/blessed/lib/widgets/progressbar.js +0 -159
- package/external/blessed/lib/widgets/prompt.js +0 -122
- package/external/blessed/lib/widgets/question.js +0 -118
- package/external/blessed/lib/widgets/radiobutton.js +0 -63
- package/external/blessed/lib/widgets/radioset.js +0 -38
- package/external/blessed/lib/widgets/screen.js +0 -2300
- package/external/blessed/lib/widgets/scrollablebox.js +0 -391
- package/external/blessed/lib/widgets/scrollabletext.js +0 -37
- package/external/blessed/lib/widgets/table.js +0 -356
- package/external/blessed/lib/widgets/terminal.js +0 -414
- package/external/blessed/lib/widgets/text.js +0 -37
- package/external/blessed/lib/widgets/textarea.js +0 -344
- package/external/blessed/lib/widgets/textbox.js +0 -79
- package/external/blessed/lib/widgets/video.js +0 -128
- package/external/blessed/usr/fonts/AUTHORS +0 -1
- package/external/blessed/usr/fonts/LICENSE +0 -94
- package/external/blessed/usr/fonts/README +0 -340
- package/external/blessed/usr/fonts/ter-u14b.json +0 -17826
- package/external/blessed/usr/fonts/ter-u14n.json +0 -17826
- package/external/blessed/usr/linux +0 -0
- package/external/blessed/usr/windows-ansi +0 -0
- package/external/blessed/usr/xterm +0 -0
- package/external/blessed/usr/xterm-256color +0 -0
- package/external/blessed/usr/xterm.termcap +0 -243
- package/external/blessed/usr/xterm.terminfo +0 -1977
- package/external/blessed/vendor/tng.js +0 -1757
- package/external/blessed-contrib/LICENSE.md +0 -21
- package/external/blessed-contrib/lib/layout/grid.js +0 -409
- package/external/blessed-contrib/lib/widget/charts/bar.js +0 -8370
- package/external/blessed-contrib/lib/widget/charts/line.js +0 -17924
- package/external/blessed-contrib/lib/widget/table.js +0 -187
- package/shadow-bin/npm +0 -27
- package/shadow-bin/npx +0 -27
- package/shadow-bin/pnpm +0 -27
- package/shadow-bin/yarn +0 -27
- /package/{translations.json → data/alert-translations.json} +0 -0
- /package/{requirements.json → data/command-api-requirements.json} +0 -0
- /package/{dist → data}/socket-completion.bash +0 -0
|
@@ -1,3655 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true })
|
|
4
|
-
|
|
5
|
-
const require$$0 = require('tty')
|
|
6
|
-
const process$2 = require('process')
|
|
7
|
-
const readline$1 = require('readline')
|
|
8
|
-
const async_hooks = require('async_hooks')
|
|
9
|
-
const require$$0$2 = require('stream')
|
|
10
|
-
const util = require('util')
|
|
11
|
-
const require$$0$1 = require('tty')
|
|
12
|
-
|
|
13
|
-
function _interopNamespaceDefault(e) {
|
|
14
|
-
const n = Object.create(null)
|
|
15
|
-
if (e) {
|
|
16
|
-
Object.keys(e).forEach(function (k) {
|
|
17
|
-
if (k !== 'default') {
|
|
18
|
-
const d = Object.getOwnPropertyDescriptor(e, k)
|
|
19
|
-
Object.defineProperty(
|
|
20
|
-
n,
|
|
21
|
-
k,
|
|
22
|
-
d.get
|
|
23
|
-
? d
|
|
24
|
-
: {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return e[k]
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
)
|
|
31
|
-
}
|
|
32
|
-
})
|
|
33
|
-
}
|
|
34
|
-
n.default = e
|
|
35
|
-
return Object.freeze(n)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const readline__namespace = /*#__PURE__*/ _interopNamespaceDefault(readline$1)
|
|
39
|
-
|
|
40
|
-
const isUpKey = key => key.name === 'up'
|
|
41
|
-
const isDownKey = key => key.name === 'down'
|
|
42
|
-
const isBackspaceKey = key => key.name === 'backspace'
|
|
43
|
-
const isNumberKey = key => '1234567890'.includes(key.name)
|
|
44
|
-
const isEnterKey = key => key.name === 'enter' || key.name === 'return'
|
|
45
|
-
|
|
46
|
-
class AbortPromptError extends Error {
|
|
47
|
-
name = 'AbortPromptError'
|
|
48
|
-
message = 'Prompt was aborted'
|
|
49
|
-
constructor(options) {
|
|
50
|
-
super()
|
|
51
|
-
this.cause = options?.cause
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
class CancelPromptError extends Error {
|
|
55
|
-
name = 'CancelPromptError'
|
|
56
|
-
message = 'Prompt was canceled'
|
|
57
|
-
}
|
|
58
|
-
class ExitPromptError extends Error {
|
|
59
|
-
name = 'ExitPromptError'
|
|
60
|
-
}
|
|
61
|
-
class HookError extends Error {
|
|
62
|
-
name = 'HookError'
|
|
63
|
-
}
|
|
64
|
-
class ValidationError extends Error {
|
|
65
|
-
name = 'ValidationError'
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/* eslint @typescript-eslint/no-explicit-any: ["off"] */
|
|
69
|
-
const hookStorage = new async_hooks.AsyncLocalStorage()
|
|
70
|
-
function createStore(rl) {
|
|
71
|
-
const store = {
|
|
72
|
-
rl,
|
|
73
|
-
hooks: [],
|
|
74
|
-
hooksCleanup: [],
|
|
75
|
-
hooksEffect: [],
|
|
76
|
-
index: 0,
|
|
77
|
-
handleChange() {}
|
|
78
|
-
}
|
|
79
|
-
return store
|
|
80
|
-
}
|
|
81
|
-
// Run callback in with the hook engine setup.
|
|
82
|
-
function withHooks(rl, cb) {
|
|
83
|
-
const store = createStore(rl)
|
|
84
|
-
return hookStorage.run(store, () => {
|
|
85
|
-
function cycle(render) {
|
|
86
|
-
store.handleChange = () => {
|
|
87
|
-
store.index = 0
|
|
88
|
-
render()
|
|
89
|
-
}
|
|
90
|
-
store.handleChange()
|
|
91
|
-
}
|
|
92
|
-
return cb(cycle)
|
|
93
|
-
})
|
|
94
|
-
}
|
|
95
|
-
// Safe getStore utility that'll return the store or throw if undefined.
|
|
96
|
-
function getStore() {
|
|
97
|
-
const store = hookStorage.getStore()
|
|
98
|
-
if (!store) {
|
|
99
|
-
throw new HookError(
|
|
100
|
-
'[Inquirer] Hook functions can only be called from within a prompt'
|
|
101
|
-
)
|
|
102
|
-
}
|
|
103
|
-
return store
|
|
104
|
-
}
|
|
105
|
-
function readline() {
|
|
106
|
-
return getStore().rl
|
|
107
|
-
}
|
|
108
|
-
// Merge state updates happening within the callback function to avoid multiple renders.
|
|
109
|
-
function withUpdates(fn) {
|
|
110
|
-
const wrapped = (...args) => {
|
|
111
|
-
const store = getStore()
|
|
112
|
-
let shouldUpdate = false
|
|
113
|
-
const oldHandleChange = store.handleChange
|
|
114
|
-
store.handleChange = () => {
|
|
115
|
-
shouldUpdate = true
|
|
116
|
-
}
|
|
117
|
-
const returnValue = fn(...args)
|
|
118
|
-
if (shouldUpdate) {
|
|
119
|
-
oldHandleChange()
|
|
120
|
-
}
|
|
121
|
-
store.handleChange = oldHandleChange
|
|
122
|
-
return returnValue
|
|
123
|
-
}
|
|
124
|
-
return async_hooks.AsyncResource.bind(wrapped)
|
|
125
|
-
}
|
|
126
|
-
function withPointer(cb) {
|
|
127
|
-
const store = getStore()
|
|
128
|
-
const { index } = store
|
|
129
|
-
const pointer = {
|
|
130
|
-
get() {
|
|
131
|
-
return store.hooks[index]
|
|
132
|
-
},
|
|
133
|
-
set(value) {
|
|
134
|
-
store.hooks[index] = value
|
|
135
|
-
},
|
|
136
|
-
initialized: index in store.hooks
|
|
137
|
-
}
|
|
138
|
-
const returnValue = cb(pointer)
|
|
139
|
-
store.index++
|
|
140
|
-
return returnValue
|
|
141
|
-
}
|
|
142
|
-
function handleChange() {
|
|
143
|
-
getStore().handleChange()
|
|
144
|
-
}
|
|
145
|
-
const effectScheduler = {
|
|
146
|
-
queue(cb) {
|
|
147
|
-
const store = getStore()
|
|
148
|
-
const { index } = store
|
|
149
|
-
store.hooksEffect.push(() => {
|
|
150
|
-
store.hooksCleanup[index]?.()
|
|
151
|
-
const cleanFn = cb(readline())
|
|
152
|
-
if (cleanFn != null && typeof cleanFn !== 'function') {
|
|
153
|
-
throw new ValidationError(
|
|
154
|
-
'useEffect return value must be a cleanup function or nothing.'
|
|
155
|
-
)
|
|
156
|
-
}
|
|
157
|
-
store.hooksCleanup[index] = cleanFn
|
|
158
|
-
})
|
|
159
|
-
},
|
|
160
|
-
run() {
|
|
161
|
-
const store = getStore()
|
|
162
|
-
withUpdates(() => {
|
|
163
|
-
store.hooksEffect.forEach(effect => {
|
|
164
|
-
effect()
|
|
165
|
-
})
|
|
166
|
-
// Warning: Clean the hooks before exiting the `withUpdates` block.
|
|
167
|
-
// Failure to do so means an updates would hit the same effects again.
|
|
168
|
-
store.hooksEffect.length = 0
|
|
169
|
-
})()
|
|
170
|
-
},
|
|
171
|
-
clearAll() {
|
|
172
|
-
const store = getStore()
|
|
173
|
-
store.hooksCleanup.forEach(cleanFn => {
|
|
174
|
-
cleanFn?.()
|
|
175
|
-
})
|
|
176
|
-
store.hooksEffect.length = 0
|
|
177
|
-
store.hooksCleanup.length = 0
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
function useState(defaultValue) {
|
|
182
|
-
return withPointer(pointer => {
|
|
183
|
-
const setState = async_hooks.AsyncResource.bind(
|
|
184
|
-
function setState(newValue) {
|
|
185
|
-
// Noop if the value is still the same.
|
|
186
|
-
if (pointer.get() !== newValue) {
|
|
187
|
-
pointer.set(newValue)
|
|
188
|
-
// Trigger re-render
|
|
189
|
-
handleChange()
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
)
|
|
193
|
-
if (pointer.initialized) {
|
|
194
|
-
return [pointer.get(), setState]
|
|
195
|
-
}
|
|
196
|
-
const value =
|
|
197
|
-
typeof defaultValue === 'function' ? defaultValue() : defaultValue
|
|
198
|
-
pointer.set(value)
|
|
199
|
-
return [value, setState]
|
|
200
|
-
})
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
function useEffect(cb, depArray) {
|
|
204
|
-
withPointer(pointer => {
|
|
205
|
-
const oldDeps = pointer.get()
|
|
206
|
-
const hasChanged =
|
|
207
|
-
!Array.isArray(oldDeps) ||
|
|
208
|
-
depArray.some((dep, i) => !Object.is(dep, oldDeps[i]))
|
|
209
|
-
if (hasChanged) {
|
|
210
|
-
effectScheduler.queue(cb)
|
|
211
|
-
}
|
|
212
|
-
pointer.set(depArray)
|
|
213
|
-
})
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
let yoctocolorsCjs
|
|
217
|
-
let hasRequiredYoctocolorsCjs
|
|
218
|
-
function requireYoctocolorsCjs() {
|
|
219
|
-
if (hasRequiredYoctocolorsCjs) {
|
|
220
|
-
return yoctocolorsCjs
|
|
221
|
-
}
|
|
222
|
-
hasRequiredYoctocolorsCjs = 1
|
|
223
|
-
const tty = require$$0 // eslint-disable-line unicorn/prefer-module
|
|
224
|
-
|
|
225
|
-
// eslint-disable-next-line no-warning-comments
|
|
226
|
-
// TODO: Use a better method when it's added to Node.js (https://github.com/nodejs/node/pull/40240)
|
|
227
|
-
// Lots of optionals here to support Deno.
|
|
228
|
-
const hasColors = tty?.WriteStream?.prototype?.hasColors?.() ?? false
|
|
229
|
-
const format = (open, close) => {
|
|
230
|
-
if (!hasColors) {
|
|
231
|
-
return input => input
|
|
232
|
-
}
|
|
233
|
-
const openCode = `\u001B[${open}m`
|
|
234
|
-
const closeCode = `\u001B[${close}m`
|
|
235
|
-
return input => {
|
|
236
|
-
const string = input + '' // eslint-disable-line no-implicit-coercion -- This is faster.
|
|
237
|
-
let index = string.indexOf(closeCode)
|
|
238
|
-
if (index === -1) {
|
|
239
|
-
// Note: Intentionally not using string interpolation for performance reasons.
|
|
240
|
-
return openCode + string + closeCode
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
// Handle nested colors.
|
|
244
|
-
|
|
245
|
-
// We could have done this, but it's too slow (as of Node.js 22).
|
|
246
|
-
// return openCode + string.replaceAll(closeCode, openCode) + closeCode;
|
|
247
|
-
|
|
248
|
-
let result = openCode
|
|
249
|
-
let lastIndex = 0
|
|
250
|
-
|
|
251
|
-
// SGR 22 resets both bold (1) and dim (2). When we encounter a nested
|
|
252
|
-
// close for styles that use 22, we need to re-open the outer style.
|
|
253
|
-
const reopenOnNestedClose = close === 22
|
|
254
|
-
const replaceCode = (reopenOnNestedClose ? closeCode : '') + openCode
|
|
255
|
-
while (index !== -1) {
|
|
256
|
-
result += string.slice(lastIndex, index) + replaceCode
|
|
257
|
-
lastIndex = index + closeCode.length
|
|
258
|
-
index = string.indexOf(closeCode, lastIndex)
|
|
259
|
-
}
|
|
260
|
-
result += string.slice(lastIndex) + closeCode
|
|
261
|
-
return result
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
const colors = {}
|
|
265
|
-
colors.reset = format(0, 0)
|
|
266
|
-
colors.bold = format(1, 22)
|
|
267
|
-
colors.dim = format(2, 22)
|
|
268
|
-
colors.italic = format(3, 23)
|
|
269
|
-
colors.underline = format(4, 24)
|
|
270
|
-
colors.overline = format(53, 55)
|
|
271
|
-
colors.inverse = format(7, 27)
|
|
272
|
-
colors.hidden = format(8, 28)
|
|
273
|
-
colors.strikethrough = format(9, 29)
|
|
274
|
-
colors.black = format(30, 39)
|
|
275
|
-
colors.red = format(31, 39)
|
|
276
|
-
colors.green = format(32, 39)
|
|
277
|
-
colors.yellow = format(33, 39)
|
|
278
|
-
colors.blue = format(34, 39)
|
|
279
|
-
colors.magenta = format(35, 39)
|
|
280
|
-
colors.cyan = format(36, 39)
|
|
281
|
-
colors.white = format(37, 39)
|
|
282
|
-
colors.gray = format(90, 39)
|
|
283
|
-
colors.bgBlack = format(40, 49)
|
|
284
|
-
colors.bgRed = format(41, 49)
|
|
285
|
-
colors.bgGreen = format(42, 49)
|
|
286
|
-
colors.bgYellow = format(43, 49)
|
|
287
|
-
colors.bgBlue = format(44, 49)
|
|
288
|
-
colors.bgMagenta = format(45, 49)
|
|
289
|
-
colors.bgCyan = format(46, 49)
|
|
290
|
-
colors.bgWhite = format(47, 49)
|
|
291
|
-
colors.bgGray = format(100, 49)
|
|
292
|
-
colors.redBright = format(91, 39)
|
|
293
|
-
colors.greenBright = format(92, 39)
|
|
294
|
-
colors.yellowBright = format(93, 39)
|
|
295
|
-
colors.blueBright = format(94, 39)
|
|
296
|
-
colors.magentaBright = format(95, 39)
|
|
297
|
-
colors.cyanBright = format(96, 39)
|
|
298
|
-
colors.whiteBright = format(97, 39)
|
|
299
|
-
colors.bgRedBright = format(101, 49)
|
|
300
|
-
colors.bgGreenBright = format(102, 49)
|
|
301
|
-
colors.bgYellowBright = format(103, 49)
|
|
302
|
-
colors.bgBlueBright = format(104, 49)
|
|
303
|
-
colors.bgMagentaBright = format(105, 49)
|
|
304
|
-
colors.bgCyanBright = format(106, 49)
|
|
305
|
-
colors.bgWhiteBright = format(107, 49)
|
|
306
|
-
yoctocolorsCjs = colors // eslint-disable-line unicorn/prefer-module
|
|
307
|
-
return yoctocolorsCjs
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
const yoctocolorsCjsExports = /*@__PURE__*/ requireYoctocolorsCjs()
|
|
311
|
-
|
|
312
|
-
// process.env dot-notation access prints:
|
|
313
|
-
// Property 'TERM' comes from an index signature, so it must be accessed with ['TERM'].ts(4111)
|
|
314
|
-
/* eslint dot-notation: ["off"] */
|
|
315
|
-
// Ported from is-unicode-supported
|
|
316
|
-
function isUnicodeSupported() {
|
|
317
|
-
if (process$2.platform !== 'win32') {
|
|
318
|
-
return process$2.env['TERM'] !== 'linux' // Linux console (kernel)
|
|
319
|
-
}
|
|
320
|
-
return (
|
|
321
|
-
Boolean(process$2.env['WT_SESSION']) ||
|
|
322
|
-
// Windows Terminal
|
|
323
|
-
Boolean(process$2.env['TERMINUS_SUBLIME']) ||
|
|
324
|
-
// Terminus (<0.2.27)
|
|
325
|
-
process$2.env['ConEmuTask'] === '{cmd::Cmder}' ||
|
|
326
|
-
// ConEmu and cmder
|
|
327
|
-
process$2.env['TERM_PROGRAM'] === 'Terminus-Sublime' ||
|
|
328
|
-
process$2.env['TERM_PROGRAM'] === 'vscode' ||
|
|
329
|
-
process$2.env['TERM'] === 'xterm-256color' ||
|
|
330
|
-
process$2.env['TERM'] === 'alacritty' ||
|
|
331
|
-
process$2.env['TERMINAL_EMULATOR'] === 'JetBrains-JediTerm'
|
|
332
|
-
)
|
|
333
|
-
}
|
|
334
|
-
// Ported from figures
|
|
335
|
-
const common = {
|
|
336
|
-
circleQuestionMark: '(?)',
|
|
337
|
-
questionMarkPrefix: '(?)',
|
|
338
|
-
square: '█',
|
|
339
|
-
squareDarkShade: '▓',
|
|
340
|
-
squareMediumShade: '▒',
|
|
341
|
-
squareLightShade: '░',
|
|
342
|
-
squareTop: '▀',
|
|
343
|
-
squareBottom: '▄',
|
|
344
|
-
squareLeft: '▌',
|
|
345
|
-
squareRight: '▐',
|
|
346
|
-
squareCenter: '■',
|
|
347
|
-
bullet: '●',
|
|
348
|
-
dot: '․',
|
|
349
|
-
ellipsis: '…',
|
|
350
|
-
pointerSmall: '›',
|
|
351
|
-
triangleUp: '▲',
|
|
352
|
-
triangleUpSmall: '▴',
|
|
353
|
-
triangleDown: '▼',
|
|
354
|
-
triangleDownSmall: '▾',
|
|
355
|
-
triangleLeftSmall: '◂',
|
|
356
|
-
triangleRightSmall: '▸',
|
|
357
|
-
home: '⌂',
|
|
358
|
-
heart: '♥',
|
|
359
|
-
musicNote: '♪',
|
|
360
|
-
musicNoteBeamed: '♫',
|
|
361
|
-
arrowUp: '↑',
|
|
362
|
-
arrowDown: '↓',
|
|
363
|
-
arrowLeft: '←',
|
|
364
|
-
arrowRight: '→',
|
|
365
|
-
arrowLeftRight: '↔',
|
|
366
|
-
arrowUpDown: '↕',
|
|
367
|
-
almostEqual: '≈',
|
|
368
|
-
notEqual: '≠',
|
|
369
|
-
lessOrEqual: '≤',
|
|
370
|
-
greaterOrEqual: '≥',
|
|
371
|
-
identical: '≡',
|
|
372
|
-
infinity: '∞',
|
|
373
|
-
subscriptZero: '₀',
|
|
374
|
-
subscriptOne: '₁',
|
|
375
|
-
subscriptTwo: '₂',
|
|
376
|
-
subscriptThree: '₃',
|
|
377
|
-
subscriptFour: '₄',
|
|
378
|
-
subscriptFive: '₅',
|
|
379
|
-
subscriptSix: '₆',
|
|
380
|
-
subscriptSeven: '₇',
|
|
381
|
-
subscriptEight: '₈',
|
|
382
|
-
subscriptNine: '₉',
|
|
383
|
-
oneHalf: '½',
|
|
384
|
-
oneThird: '⅓',
|
|
385
|
-
oneQuarter: '¼',
|
|
386
|
-
oneFifth: '⅕',
|
|
387
|
-
oneSixth: '⅙',
|
|
388
|
-
oneEighth: '⅛',
|
|
389
|
-
twoThirds: '⅔',
|
|
390
|
-
twoFifths: '⅖',
|
|
391
|
-
threeQuarters: '¾',
|
|
392
|
-
threeFifths: '⅗',
|
|
393
|
-
threeEighths: '⅜',
|
|
394
|
-
fourFifths: '⅘',
|
|
395
|
-
fiveSixths: '⅚',
|
|
396
|
-
fiveEighths: '⅝',
|
|
397
|
-
sevenEighths: '⅞',
|
|
398
|
-
line: '─',
|
|
399
|
-
lineBold: '━',
|
|
400
|
-
lineDouble: '═',
|
|
401
|
-
lineDashed0: '┄',
|
|
402
|
-
lineDashed1: '┅',
|
|
403
|
-
lineDashed2: '┈',
|
|
404
|
-
lineDashed3: '┉',
|
|
405
|
-
lineDashed4: '╌',
|
|
406
|
-
lineDashed5: '╍',
|
|
407
|
-
lineDashed6: '╴',
|
|
408
|
-
lineDashed7: '╶',
|
|
409
|
-
lineDashed8: '╸',
|
|
410
|
-
lineDashed9: '╺',
|
|
411
|
-
lineDashed10: '╼',
|
|
412
|
-
lineDashed11: '╾',
|
|
413
|
-
lineDashed12: '−',
|
|
414
|
-
lineDashed13: '–',
|
|
415
|
-
lineDashed14: '‐',
|
|
416
|
-
lineDashed15: '⁃',
|
|
417
|
-
lineVertical: '│',
|
|
418
|
-
lineVerticalBold: '┃',
|
|
419
|
-
lineVerticalDouble: '║',
|
|
420
|
-
lineVerticalDashed0: '┆',
|
|
421
|
-
lineVerticalDashed1: '┇',
|
|
422
|
-
lineVerticalDashed2: '┊',
|
|
423
|
-
lineVerticalDashed3: '┋',
|
|
424
|
-
lineVerticalDashed4: '╎',
|
|
425
|
-
lineVerticalDashed5: '╏',
|
|
426
|
-
lineVerticalDashed6: '╵',
|
|
427
|
-
lineVerticalDashed7: '╷',
|
|
428
|
-
lineVerticalDashed8: '╹',
|
|
429
|
-
lineVerticalDashed9: '╻',
|
|
430
|
-
lineVerticalDashed10: '╽',
|
|
431
|
-
lineVerticalDashed11: '╿',
|
|
432
|
-
lineDownLeft: '┐',
|
|
433
|
-
lineDownLeftArc: '╮',
|
|
434
|
-
lineDownBoldLeftBold: '┓',
|
|
435
|
-
lineDownBoldLeft: '┒',
|
|
436
|
-
lineDownLeftBold: '┑',
|
|
437
|
-
lineDownDoubleLeftDouble: '╗',
|
|
438
|
-
lineDownDoubleLeft: '╖',
|
|
439
|
-
lineDownLeftDouble: '╕',
|
|
440
|
-
lineDownRight: '┌',
|
|
441
|
-
lineDownRightArc: '╭',
|
|
442
|
-
lineDownBoldRightBold: '┏',
|
|
443
|
-
lineDownBoldRight: '┎',
|
|
444
|
-
lineDownRightBold: '┍',
|
|
445
|
-
lineDownDoubleRightDouble: '╔',
|
|
446
|
-
lineDownDoubleRight: '╓',
|
|
447
|
-
lineDownRightDouble: '╒',
|
|
448
|
-
lineUpLeft: '┘',
|
|
449
|
-
lineUpLeftArc: '╯',
|
|
450
|
-
lineUpBoldLeftBold: '┛',
|
|
451
|
-
lineUpBoldLeft: '┚',
|
|
452
|
-
lineUpLeftBold: '┙',
|
|
453
|
-
lineUpDoubleLeftDouble: '╝',
|
|
454
|
-
lineUpDoubleLeft: '╜',
|
|
455
|
-
lineUpLeftDouble: '╛',
|
|
456
|
-
lineUpRight: '└',
|
|
457
|
-
lineUpRightArc: '╰',
|
|
458
|
-
lineUpBoldRightBold: '┗',
|
|
459
|
-
lineUpBoldRight: '┖',
|
|
460
|
-
lineUpRightBold: '┕',
|
|
461
|
-
lineUpDoubleRightDouble: '╚',
|
|
462
|
-
lineUpDoubleRight: '╙',
|
|
463
|
-
lineUpRightDouble: '╘',
|
|
464
|
-
lineUpDownLeft: '┤',
|
|
465
|
-
lineUpBoldDownBoldLeftBold: '┫',
|
|
466
|
-
lineUpBoldDownBoldLeft: '┨',
|
|
467
|
-
lineUpDownLeftBold: '┥',
|
|
468
|
-
lineUpBoldDownLeftBold: '┩',
|
|
469
|
-
lineUpDownBoldLeftBold: '┪',
|
|
470
|
-
lineUpDownBoldLeft: '┧',
|
|
471
|
-
lineUpBoldDownLeft: '┦',
|
|
472
|
-
lineUpDoubleDownDoubleLeftDouble: '╣',
|
|
473
|
-
lineUpDoubleDownDoubleLeft: '╢',
|
|
474
|
-
lineUpDownLeftDouble: '╡',
|
|
475
|
-
lineUpDownRight: '├',
|
|
476
|
-
lineUpBoldDownBoldRightBold: '┣',
|
|
477
|
-
lineUpBoldDownBoldRight: '┠',
|
|
478
|
-
lineUpDownRightBold: '┝',
|
|
479
|
-
lineUpBoldDownRightBold: '┡',
|
|
480
|
-
lineUpDownBoldRightBold: '┢',
|
|
481
|
-
lineUpDownBoldRight: '┟',
|
|
482
|
-
lineUpBoldDownRight: '┞',
|
|
483
|
-
lineUpDoubleDownDoubleRightDouble: '╠',
|
|
484
|
-
lineUpDoubleDownDoubleRight: '╟',
|
|
485
|
-
lineUpDownRightDouble: '╞',
|
|
486
|
-
lineDownLeftRight: '┬',
|
|
487
|
-
lineDownBoldLeftBoldRightBold: '┳',
|
|
488
|
-
lineDownLeftBoldRightBold: '┯',
|
|
489
|
-
lineDownBoldLeftRight: '┰',
|
|
490
|
-
lineDownBoldLeftBoldRight: '┱',
|
|
491
|
-
lineDownBoldLeftRightBold: '┲',
|
|
492
|
-
lineDownLeftRightBold: '┮',
|
|
493
|
-
lineDownLeftBoldRight: '┭',
|
|
494
|
-
lineDownDoubleLeftDoubleRightDouble: '╦',
|
|
495
|
-
lineDownDoubleLeftRight: '╥',
|
|
496
|
-
lineDownLeftDoubleRightDouble: '╤',
|
|
497
|
-
lineUpLeftRight: '┴',
|
|
498
|
-
lineUpBoldLeftBoldRightBold: '┻',
|
|
499
|
-
lineUpLeftBoldRightBold: '┷',
|
|
500
|
-
lineUpBoldLeftRight: '┸',
|
|
501
|
-
lineUpBoldLeftBoldRight: '┹',
|
|
502
|
-
lineUpBoldLeftRightBold: '┺',
|
|
503
|
-
lineUpLeftRightBold: '┶',
|
|
504
|
-
lineUpLeftBoldRight: '┵',
|
|
505
|
-
lineUpDoubleLeftDoubleRightDouble: '╩',
|
|
506
|
-
lineUpDoubleLeftRight: '╨',
|
|
507
|
-
lineUpLeftDoubleRightDouble: '╧',
|
|
508
|
-
lineUpDownLeftRight: '┼',
|
|
509
|
-
lineUpBoldDownBoldLeftBoldRightBold: '╋',
|
|
510
|
-
lineUpDownBoldLeftBoldRightBold: '╈',
|
|
511
|
-
lineUpBoldDownLeftBoldRightBold: '╇',
|
|
512
|
-
lineUpBoldDownBoldLeftRightBold: '╊',
|
|
513
|
-
lineUpBoldDownBoldLeftBoldRight: '╉',
|
|
514
|
-
lineUpBoldDownLeftRight: '╀',
|
|
515
|
-
lineUpDownBoldLeftRight: '╁',
|
|
516
|
-
lineUpDownLeftBoldRight: '┽',
|
|
517
|
-
lineUpDownLeftRightBold: '┾',
|
|
518
|
-
lineUpBoldDownBoldLeftRight: '╂',
|
|
519
|
-
lineUpDownLeftBoldRightBold: '┿',
|
|
520
|
-
lineUpBoldDownLeftBoldRight: '╃',
|
|
521
|
-
lineUpBoldDownLeftRightBold: '╄',
|
|
522
|
-
lineUpDownBoldLeftBoldRight: '╅',
|
|
523
|
-
lineUpDownBoldLeftRightBold: '╆',
|
|
524
|
-
lineUpDoubleDownDoubleLeftDoubleRightDouble: '╬',
|
|
525
|
-
lineUpDoubleDownDoubleLeftRight: '╫',
|
|
526
|
-
lineUpDownLeftDoubleRightDouble: '╪',
|
|
527
|
-
lineCross: '╳',
|
|
528
|
-
lineBackslash: '╲',
|
|
529
|
-
lineSlash: '╱'
|
|
530
|
-
}
|
|
531
|
-
const specialMainSymbols = {
|
|
532
|
-
tick: '✔',
|
|
533
|
-
info: 'ℹ',
|
|
534
|
-
warning: '⚠',
|
|
535
|
-
cross: '✘',
|
|
536
|
-
squareSmall: '◻',
|
|
537
|
-
squareSmallFilled: '◼',
|
|
538
|
-
circle: '◯',
|
|
539
|
-
circleFilled: '◉',
|
|
540
|
-
circleDotted: '◌',
|
|
541
|
-
circleDouble: '◎',
|
|
542
|
-
circleCircle: 'ⓞ',
|
|
543
|
-
circleCross: 'ⓧ',
|
|
544
|
-
circlePipe: 'Ⓘ',
|
|
545
|
-
radioOn: '◉',
|
|
546
|
-
radioOff: '◯',
|
|
547
|
-
checkboxOn: '☒',
|
|
548
|
-
checkboxOff: '☐',
|
|
549
|
-
checkboxCircleOn: 'ⓧ',
|
|
550
|
-
checkboxCircleOff: 'Ⓘ',
|
|
551
|
-
pointer: '❯',
|
|
552
|
-
triangleUpOutline: '△',
|
|
553
|
-
triangleLeft: '◀',
|
|
554
|
-
triangleRight: '▶',
|
|
555
|
-
lozenge: '◆',
|
|
556
|
-
lozengeOutline: '◇',
|
|
557
|
-
hamburger: '☰',
|
|
558
|
-
smiley: '㋡',
|
|
559
|
-
mustache: '෴',
|
|
560
|
-
star: '★',
|
|
561
|
-
play: '▶',
|
|
562
|
-
nodejs: '⬢',
|
|
563
|
-
oneSeventh: '⅐',
|
|
564
|
-
oneNinth: '⅑',
|
|
565
|
-
oneTenth: '⅒'
|
|
566
|
-
}
|
|
567
|
-
const specialFallbackSymbols = {
|
|
568
|
-
tick: '√',
|
|
569
|
-
info: 'i',
|
|
570
|
-
warning: '‼',
|
|
571
|
-
cross: '×',
|
|
572
|
-
squareSmall: '□',
|
|
573
|
-
squareSmallFilled: '■',
|
|
574
|
-
circle: '( )',
|
|
575
|
-
circleFilled: '(*)',
|
|
576
|
-
circleDotted: '( )',
|
|
577
|
-
circleDouble: '( )',
|
|
578
|
-
circleCircle: '(○)',
|
|
579
|
-
circleCross: '(×)',
|
|
580
|
-
circlePipe: '(│)',
|
|
581
|
-
radioOn: '(*)',
|
|
582
|
-
radioOff: '( )',
|
|
583
|
-
checkboxOn: '[×]',
|
|
584
|
-
checkboxOff: '[ ]',
|
|
585
|
-
checkboxCircleOn: '(×)',
|
|
586
|
-
checkboxCircleOff: '( )',
|
|
587
|
-
pointer: '>',
|
|
588
|
-
triangleUpOutline: '∆',
|
|
589
|
-
triangleLeft: '◄',
|
|
590
|
-
triangleRight: '►',
|
|
591
|
-
lozenge: '♦',
|
|
592
|
-
lozengeOutline: '◊',
|
|
593
|
-
hamburger: '≡',
|
|
594
|
-
smiley: '☺',
|
|
595
|
-
mustache: '┌─┐',
|
|
596
|
-
star: '✶',
|
|
597
|
-
play: '►',
|
|
598
|
-
nodejs: '♦',
|
|
599
|
-
oneSeventh: '1/7',
|
|
600
|
-
oneNinth: '1/9',
|
|
601
|
-
oneTenth: '1/10'
|
|
602
|
-
}
|
|
603
|
-
const mainSymbols = {
|
|
604
|
-
...common,
|
|
605
|
-
...specialMainSymbols
|
|
606
|
-
}
|
|
607
|
-
const fallbackSymbols = {
|
|
608
|
-
...common,
|
|
609
|
-
...specialFallbackSymbols
|
|
610
|
-
}
|
|
611
|
-
const shouldUseMain = isUnicodeSupported()
|
|
612
|
-
const figures = shouldUseMain ? mainSymbols : fallbackSymbols
|
|
613
|
-
|
|
614
|
-
const defaultTheme = {
|
|
615
|
-
prefix: {
|
|
616
|
-
idle: yoctocolorsCjsExports.blue('?'),
|
|
617
|
-
// TODO: use figure
|
|
618
|
-
done: yoctocolorsCjsExports.green(figures.tick)
|
|
619
|
-
},
|
|
620
|
-
spinner: {
|
|
621
|
-
interval: 80,
|
|
622
|
-
frames: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'].map(frame =>
|
|
623
|
-
yoctocolorsCjsExports.yellow(frame)
|
|
624
|
-
)
|
|
625
|
-
},
|
|
626
|
-
style: {
|
|
627
|
-
answer: yoctocolorsCjsExports.cyan,
|
|
628
|
-
message: yoctocolorsCjsExports.bold,
|
|
629
|
-
error: text => yoctocolorsCjsExports.red(`> ${text}`),
|
|
630
|
-
defaultAnswer: text => yoctocolorsCjsExports.dim(`(${text})`),
|
|
631
|
-
help: yoctocolorsCjsExports.dim,
|
|
632
|
-
highlight: yoctocolorsCjsExports.cyan,
|
|
633
|
-
key: text =>
|
|
634
|
-
yoctocolorsCjsExports.cyan(yoctocolorsCjsExports.bold(`<${text}>`))
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
function isPlainObject(value) {
|
|
639
|
-
if (typeof value !== 'object' || value === null) {
|
|
640
|
-
return false
|
|
641
|
-
}
|
|
642
|
-
let proto = value
|
|
643
|
-
while (Object.getPrototypeOf(proto) !== null) {
|
|
644
|
-
proto = Object.getPrototypeOf(proto)
|
|
645
|
-
}
|
|
646
|
-
return Object.getPrototypeOf(value) === proto
|
|
647
|
-
}
|
|
648
|
-
function deepMerge(...objects) {
|
|
649
|
-
const output = {}
|
|
650
|
-
for (const obj of objects) {
|
|
651
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
652
|
-
const prevValue = output[key]
|
|
653
|
-
output[key] =
|
|
654
|
-
isPlainObject(prevValue) && isPlainObject(value)
|
|
655
|
-
? deepMerge(prevValue, value)
|
|
656
|
-
: value
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
return output
|
|
660
|
-
}
|
|
661
|
-
function makeTheme(...themes) {
|
|
662
|
-
const themesToMerge = [defaultTheme, ...themes.filter(theme => theme != null)]
|
|
663
|
-
return deepMerge(...themesToMerge)
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
function usePrefix({ status = 'idle', theme }) {
|
|
667
|
-
const [showLoader, setShowLoader] = useState(false)
|
|
668
|
-
const [tick, setTick] = useState(0)
|
|
669
|
-
const { prefix, spinner } = makeTheme(theme)
|
|
670
|
-
useEffect(() => {
|
|
671
|
-
if (status === 'loading') {
|
|
672
|
-
let tickInterval
|
|
673
|
-
let inc = -1
|
|
674
|
-
// Delay displaying spinner by 300ms, to avoid flickering
|
|
675
|
-
const delayTimeout = setTimeout(() => {
|
|
676
|
-
setShowLoader(true)
|
|
677
|
-
tickInterval = setInterval(() => {
|
|
678
|
-
inc = inc + 1
|
|
679
|
-
setTick(inc % spinner.frames.length)
|
|
680
|
-
}, spinner.interval)
|
|
681
|
-
}, 300)
|
|
682
|
-
return () => {
|
|
683
|
-
clearTimeout(delayTimeout)
|
|
684
|
-
clearInterval(tickInterval)
|
|
685
|
-
}
|
|
686
|
-
} else {
|
|
687
|
-
setShowLoader(false)
|
|
688
|
-
}
|
|
689
|
-
}, [status])
|
|
690
|
-
if (showLoader) {
|
|
691
|
-
return spinner.frames[tick]
|
|
692
|
-
}
|
|
693
|
-
// There's a delay before we show the loader. So we want to ignore `loading` here, and pass idle instead.
|
|
694
|
-
const iconName = status === 'loading' ? 'idle' : status
|
|
695
|
-
return typeof prefix === 'string'
|
|
696
|
-
? prefix
|
|
697
|
-
: (prefix[iconName] ?? prefix['idle'])
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
function useMemo(fn, dependencies) {
|
|
701
|
-
return withPointer(pointer => {
|
|
702
|
-
const prev = pointer.get()
|
|
703
|
-
if (
|
|
704
|
-
!prev ||
|
|
705
|
-
prev.dependencies.length !== dependencies.length ||
|
|
706
|
-
prev.dependencies.some((dep, i) => dep !== dependencies[i])
|
|
707
|
-
) {
|
|
708
|
-
const value = fn()
|
|
709
|
-
pointer.set({
|
|
710
|
-
value,
|
|
711
|
-
dependencies
|
|
712
|
-
})
|
|
713
|
-
return value
|
|
714
|
-
}
|
|
715
|
-
return prev.value
|
|
716
|
-
})
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
function useRef(val) {
|
|
720
|
-
return useState({
|
|
721
|
-
current: val
|
|
722
|
-
})[0]
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
function useKeypress(userHandler) {
|
|
726
|
-
const signal = useRef(userHandler)
|
|
727
|
-
signal.current = userHandler
|
|
728
|
-
useEffect(rl => {
|
|
729
|
-
let ignore = false
|
|
730
|
-
const handler = withUpdates((_input, event) => {
|
|
731
|
-
if (ignore) {
|
|
732
|
-
return
|
|
733
|
-
}
|
|
734
|
-
void signal.current(event, rl)
|
|
735
|
-
})
|
|
736
|
-
rl.input.on('keypress', handler)
|
|
737
|
-
return () => {
|
|
738
|
-
ignore = true
|
|
739
|
-
rl.input.removeListener('keypress', handler)
|
|
740
|
-
}
|
|
741
|
-
}, [])
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
let cliWidth_1
|
|
745
|
-
let hasRequiredCliWidth
|
|
746
|
-
function requireCliWidth() {
|
|
747
|
-
if (hasRequiredCliWidth) {
|
|
748
|
-
return cliWidth_1
|
|
749
|
-
}
|
|
750
|
-
hasRequiredCliWidth = 1
|
|
751
|
-
cliWidth_1 = cliWidth
|
|
752
|
-
function normalizeOpts(options) {
|
|
753
|
-
const defaultOpts = {
|
|
754
|
-
defaultWidth: 0,
|
|
755
|
-
output: process.stdout,
|
|
756
|
-
tty: require$$0$1
|
|
757
|
-
}
|
|
758
|
-
if (!options) {
|
|
759
|
-
return defaultOpts
|
|
760
|
-
}
|
|
761
|
-
Object.keys(defaultOpts).forEach(function (key) {
|
|
762
|
-
if (!options[key]) {
|
|
763
|
-
options[key] = defaultOpts[key]
|
|
764
|
-
}
|
|
765
|
-
})
|
|
766
|
-
return options
|
|
767
|
-
}
|
|
768
|
-
function cliWidth(options) {
|
|
769
|
-
const opts = normalizeOpts(options)
|
|
770
|
-
if (opts.output.getWindowSize) {
|
|
771
|
-
return opts.output.getWindowSize()[0] || opts.defaultWidth
|
|
772
|
-
}
|
|
773
|
-
if (opts.tty.getWindowSize) {
|
|
774
|
-
return opts.tty.getWindowSize()[1] || opts.defaultWidth
|
|
775
|
-
}
|
|
776
|
-
if (opts.output.columns) {
|
|
777
|
-
return opts.output.columns
|
|
778
|
-
}
|
|
779
|
-
if (process.env.CLI_WIDTH) {
|
|
780
|
-
const width = parseInt(process.env.CLI_WIDTH, 10)
|
|
781
|
-
if (!isNaN(width) && width !== 0) {
|
|
782
|
-
return width
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
|
-
return opts.defaultWidth
|
|
786
|
-
}
|
|
787
|
-
return cliWidth_1
|
|
788
|
-
}
|
|
789
|
-
|
|
790
|
-
const cliWidthExports = requireCliWidth()
|
|
791
|
-
|
|
792
|
-
const stringWidth = { exports: {} }
|
|
793
|
-
|
|
794
|
-
let ansiRegex
|
|
795
|
-
let hasRequiredAnsiRegex
|
|
796
|
-
function requireAnsiRegex() {
|
|
797
|
-
if (hasRequiredAnsiRegex) {
|
|
798
|
-
return ansiRegex
|
|
799
|
-
}
|
|
800
|
-
hasRequiredAnsiRegex = 1
|
|
801
|
-
ansiRegex = ({ onlyFirst = false } = {}) => {
|
|
802
|
-
const pattern = [
|
|
803
|
-
'[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
|
|
804
|
-
'(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'
|
|
805
|
-
].join('|')
|
|
806
|
-
return new RegExp(pattern, onlyFirst ? undefined : 'g')
|
|
807
|
-
}
|
|
808
|
-
return ansiRegex
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
let stripAnsi
|
|
812
|
-
let hasRequiredStripAnsi
|
|
813
|
-
function requireStripAnsi() {
|
|
814
|
-
if (hasRequiredStripAnsi) {
|
|
815
|
-
return stripAnsi
|
|
816
|
-
}
|
|
817
|
-
hasRequiredStripAnsi = 1
|
|
818
|
-
const ansiRegex = requireAnsiRegex()
|
|
819
|
-
stripAnsi = string =>
|
|
820
|
-
typeof string === 'string' ? string.replace(ansiRegex(), '') : string
|
|
821
|
-
return stripAnsi
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
const isFullwidthCodePoint = { exports: {} }
|
|
825
|
-
|
|
826
|
-
/* eslint-disable yoda */
|
|
827
|
-
let hasRequiredIsFullwidthCodePoint
|
|
828
|
-
function requireIsFullwidthCodePoint() {
|
|
829
|
-
if (hasRequiredIsFullwidthCodePoint) {
|
|
830
|
-
return isFullwidthCodePoint.exports
|
|
831
|
-
}
|
|
832
|
-
hasRequiredIsFullwidthCodePoint = 1
|
|
833
|
-
const isFullwidthCodePoint$1 = codePoint => {
|
|
834
|
-
if (Number.isNaN(codePoint)) {
|
|
835
|
-
return false
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
// Code points are derived from:
|
|
839
|
-
// http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt
|
|
840
|
-
if (
|
|
841
|
-
codePoint >= 0x1100 &&
|
|
842
|
-
(codePoint <= 0x115f ||
|
|
843
|
-
// Hangul Jamo
|
|
844
|
-
codePoint === 0x2329 ||
|
|
845
|
-
// LEFT-POINTING ANGLE BRACKET
|
|
846
|
-
codePoint === 0x232a ||
|
|
847
|
-
// RIGHT-POINTING ANGLE BRACKET
|
|
848
|
-
// CJK Radicals Supplement .. Enclosed CJK Letters and Months
|
|
849
|
-
(0x2e80 <= codePoint && codePoint <= 0x3247 && codePoint !== 0x303f) ||
|
|
850
|
-
// Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A
|
|
851
|
-
(0x3250 <= codePoint && codePoint <= 0x4dbf) ||
|
|
852
|
-
// CJK Unified Ideographs .. Yi Radicals
|
|
853
|
-
(0x4e00 <= codePoint && codePoint <= 0xa4c6) ||
|
|
854
|
-
// Hangul Jamo Extended-A
|
|
855
|
-
(0xa960 <= codePoint && codePoint <= 0xa97c) ||
|
|
856
|
-
// Hangul Syllables
|
|
857
|
-
(0xac00 <= codePoint && codePoint <= 0xd7a3) ||
|
|
858
|
-
// CJK Compatibility Ideographs
|
|
859
|
-
(0xf900 <= codePoint && codePoint <= 0xfaff) ||
|
|
860
|
-
// Vertical Forms
|
|
861
|
-
(0xfe10 <= codePoint && codePoint <= 0xfe19) ||
|
|
862
|
-
// CJK Compatibility Forms .. Small Form Variants
|
|
863
|
-
(0xfe30 <= codePoint && codePoint <= 0xfe6b) ||
|
|
864
|
-
// Halfwidth and Fullwidth Forms
|
|
865
|
-
(0xff01 <= codePoint && codePoint <= 0xff60) ||
|
|
866
|
-
(0xffe0 <= codePoint && codePoint <= 0xffe6) ||
|
|
867
|
-
// Kana Supplement
|
|
868
|
-
(0x1b000 <= codePoint && codePoint <= 0x1b001) ||
|
|
869
|
-
// Enclosed Ideographic Supplement
|
|
870
|
-
(0x1f200 <= codePoint && codePoint <= 0x1f251) ||
|
|
871
|
-
// CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane
|
|
872
|
-
(0x20000 <= codePoint && codePoint <= 0x3fffd))
|
|
873
|
-
) {
|
|
874
|
-
return true
|
|
875
|
-
}
|
|
876
|
-
return false
|
|
877
|
-
}
|
|
878
|
-
isFullwidthCodePoint.exports = isFullwidthCodePoint$1
|
|
879
|
-
isFullwidthCodePoint.exports.default = isFullwidthCodePoint$1
|
|
880
|
-
return isFullwidthCodePoint.exports
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
let emojiRegex
|
|
884
|
-
let hasRequiredEmojiRegex
|
|
885
|
-
function requireEmojiRegex() {
|
|
886
|
-
if (hasRequiredEmojiRegex) {
|
|
887
|
-
return emojiRegex
|
|
888
|
-
}
|
|
889
|
-
hasRequiredEmojiRegex = 1
|
|
890
|
-
emojiRegex = function () {
|
|
891
|
-
// https://mths.be/emoji
|
|
892
|
-
return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g
|
|
893
|
-
}
|
|
894
|
-
return emojiRegex
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
let hasRequiredStringWidth
|
|
898
|
-
function requireStringWidth() {
|
|
899
|
-
if (hasRequiredStringWidth) {
|
|
900
|
-
return stringWidth.exports
|
|
901
|
-
}
|
|
902
|
-
hasRequiredStringWidth = 1
|
|
903
|
-
const stripAnsi = requireStripAnsi()
|
|
904
|
-
const isFullwidthCodePoint = requireIsFullwidthCodePoint()
|
|
905
|
-
const emojiRegex = requireEmojiRegex()
|
|
906
|
-
const stringWidth$1 = string => {
|
|
907
|
-
if (typeof string !== 'string' || string.length === 0) {
|
|
908
|
-
return 0
|
|
909
|
-
}
|
|
910
|
-
string = stripAnsi(string)
|
|
911
|
-
if (string.length === 0) {
|
|
912
|
-
return 0
|
|
913
|
-
}
|
|
914
|
-
string = string.replace(emojiRegex(), ' ')
|
|
915
|
-
let width = 0
|
|
916
|
-
for (let i = 0; i < string.length; i++) {
|
|
917
|
-
const code = string.codePointAt(i)
|
|
918
|
-
|
|
919
|
-
// Ignore control characters
|
|
920
|
-
if (code <= 0x1f || (code >= 0x7f && code <= 0x9f)) {
|
|
921
|
-
continue
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
// Ignore combining characters
|
|
925
|
-
if (code >= 0x300 && code <= 0x36f) {
|
|
926
|
-
continue
|
|
927
|
-
}
|
|
928
|
-
|
|
929
|
-
// Surrogates
|
|
930
|
-
if (code > 0xffff) {
|
|
931
|
-
i++
|
|
932
|
-
}
|
|
933
|
-
width += isFullwidthCodePoint(code) ? 2 : 1
|
|
934
|
-
}
|
|
935
|
-
return width
|
|
936
|
-
}
|
|
937
|
-
stringWidth.exports = stringWidth$1
|
|
938
|
-
// TODO: remove this in the next major version
|
|
939
|
-
stringWidth.exports.default = stringWidth$1
|
|
940
|
-
return stringWidth.exports
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
const ansiStyles = { exports: {} }
|
|
944
|
-
|
|
945
|
-
let colorName
|
|
946
|
-
let hasRequiredColorName
|
|
947
|
-
function requireColorName() {
|
|
948
|
-
if (hasRequiredColorName) {
|
|
949
|
-
return colorName
|
|
950
|
-
}
|
|
951
|
-
hasRequiredColorName = 1
|
|
952
|
-
colorName = {
|
|
953
|
-
aliceblue: [240, 248, 255],
|
|
954
|
-
antiquewhite: [250, 235, 215],
|
|
955
|
-
aqua: [0, 255, 255],
|
|
956
|
-
aquamarine: [127, 255, 212],
|
|
957
|
-
azure: [240, 255, 255],
|
|
958
|
-
beige: [245, 245, 220],
|
|
959
|
-
bisque: [255, 228, 196],
|
|
960
|
-
black: [0, 0, 0],
|
|
961
|
-
blanchedalmond: [255, 235, 205],
|
|
962
|
-
blue: [0, 0, 255],
|
|
963
|
-
blueviolet: [138, 43, 226],
|
|
964
|
-
brown: [165, 42, 42],
|
|
965
|
-
burlywood: [222, 184, 135],
|
|
966
|
-
cadetblue: [95, 158, 160],
|
|
967
|
-
chartreuse: [127, 255, 0],
|
|
968
|
-
chocolate: [210, 105, 30],
|
|
969
|
-
coral: [255, 127, 80],
|
|
970
|
-
cornflowerblue: [100, 149, 237],
|
|
971
|
-
cornsilk: [255, 248, 220],
|
|
972
|
-
crimson: [220, 20, 60],
|
|
973
|
-
cyan: [0, 255, 255],
|
|
974
|
-
darkblue: [0, 0, 139],
|
|
975
|
-
darkcyan: [0, 139, 139],
|
|
976
|
-
darkgoldenrod: [184, 134, 11],
|
|
977
|
-
darkgray: [169, 169, 169],
|
|
978
|
-
darkgreen: [0, 100, 0],
|
|
979
|
-
darkgrey: [169, 169, 169],
|
|
980
|
-
darkkhaki: [189, 183, 107],
|
|
981
|
-
darkmagenta: [139, 0, 139],
|
|
982
|
-
darkolivegreen: [85, 107, 47],
|
|
983
|
-
darkorange: [255, 140, 0],
|
|
984
|
-
darkorchid: [153, 50, 204],
|
|
985
|
-
darkred: [139, 0, 0],
|
|
986
|
-
darksalmon: [233, 150, 122],
|
|
987
|
-
darkseagreen: [143, 188, 143],
|
|
988
|
-
darkslateblue: [72, 61, 139],
|
|
989
|
-
darkslategray: [47, 79, 79],
|
|
990
|
-
darkslategrey: [47, 79, 79],
|
|
991
|
-
darkturquoise: [0, 206, 209],
|
|
992
|
-
darkviolet: [148, 0, 211],
|
|
993
|
-
deeppink: [255, 20, 147],
|
|
994
|
-
deepskyblue: [0, 191, 255],
|
|
995
|
-
dimgray: [105, 105, 105],
|
|
996
|
-
dimgrey: [105, 105, 105],
|
|
997
|
-
dodgerblue: [30, 144, 255],
|
|
998
|
-
firebrick: [178, 34, 34],
|
|
999
|
-
floralwhite: [255, 250, 240],
|
|
1000
|
-
forestgreen: [34, 139, 34],
|
|
1001
|
-
fuchsia: [255, 0, 255],
|
|
1002
|
-
gainsboro: [220, 220, 220],
|
|
1003
|
-
ghostwhite: [248, 248, 255],
|
|
1004
|
-
gold: [255, 215, 0],
|
|
1005
|
-
goldenrod: [218, 165, 32],
|
|
1006
|
-
gray: [128, 128, 128],
|
|
1007
|
-
green: [0, 128, 0],
|
|
1008
|
-
greenyellow: [173, 255, 47],
|
|
1009
|
-
grey: [128, 128, 128],
|
|
1010
|
-
honeydew: [240, 255, 240],
|
|
1011
|
-
hotpink: [255, 105, 180],
|
|
1012
|
-
indianred: [205, 92, 92],
|
|
1013
|
-
indigo: [75, 0, 130],
|
|
1014
|
-
ivory: [255, 255, 240],
|
|
1015
|
-
khaki: [240, 230, 140],
|
|
1016
|
-
lavender: [230, 230, 250],
|
|
1017
|
-
lavenderblush: [255, 240, 245],
|
|
1018
|
-
lawngreen: [124, 252, 0],
|
|
1019
|
-
lemonchiffon: [255, 250, 205],
|
|
1020
|
-
lightblue: [173, 216, 230],
|
|
1021
|
-
lightcoral: [240, 128, 128],
|
|
1022
|
-
lightcyan: [224, 255, 255],
|
|
1023
|
-
lightgoldenrodyellow: [250, 250, 210],
|
|
1024
|
-
lightgray: [211, 211, 211],
|
|
1025
|
-
lightgreen: [144, 238, 144],
|
|
1026
|
-
lightgrey: [211, 211, 211],
|
|
1027
|
-
lightpink: [255, 182, 193],
|
|
1028
|
-
lightsalmon: [255, 160, 122],
|
|
1029
|
-
lightseagreen: [32, 178, 170],
|
|
1030
|
-
lightskyblue: [135, 206, 250],
|
|
1031
|
-
lightslategray: [119, 136, 153],
|
|
1032
|
-
lightslategrey: [119, 136, 153],
|
|
1033
|
-
lightsteelblue: [176, 196, 222],
|
|
1034
|
-
lightyellow: [255, 255, 224],
|
|
1035
|
-
lime: [0, 255, 0],
|
|
1036
|
-
limegreen: [50, 205, 50],
|
|
1037
|
-
linen: [250, 240, 230],
|
|
1038
|
-
magenta: [255, 0, 255],
|
|
1039
|
-
maroon: [128, 0, 0],
|
|
1040
|
-
mediumaquamarine: [102, 205, 170],
|
|
1041
|
-
mediumblue: [0, 0, 205],
|
|
1042
|
-
mediumorchid: [186, 85, 211],
|
|
1043
|
-
mediumpurple: [147, 112, 219],
|
|
1044
|
-
mediumseagreen: [60, 179, 113],
|
|
1045
|
-
mediumslateblue: [123, 104, 238],
|
|
1046
|
-
mediumspringgreen: [0, 250, 154],
|
|
1047
|
-
mediumturquoise: [72, 209, 204],
|
|
1048
|
-
mediumvioletred: [199, 21, 133],
|
|
1049
|
-
midnightblue: [25, 25, 112],
|
|
1050
|
-
mintcream: [245, 255, 250],
|
|
1051
|
-
mistyrose: [255, 228, 225],
|
|
1052
|
-
moccasin: [255, 228, 181],
|
|
1053
|
-
navajowhite: [255, 222, 173],
|
|
1054
|
-
navy: [0, 0, 128],
|
|
1055
|
-
oldlace: [253, 245, 230],
|
|
1056
|
-
olive: [128, 128, 0],
|
|
1057
|
-
olivedrab: [107, 142, 35],
|
|
1058
|
-
orange: [255, 165, 0],
|
|
1059
|
-
orangered: [255, 69, 0],
|
|
1060
|
-
orchid: [218, 112, 214],
|
|
1061
|
-
palegoldenrod: [238, 232, 170],
|
|
1062
|
-
palegreen: [152, 251, 152],
|
|
1063
|
-
paleturquoise: [175, 238, 238],
|
|
1064
|
-
palevioletred: [219, 112, 147],
|
|
1065
|
-
papayawhip: [255, 239, 213],
|
|
1066
|
-
peachpuff: [255, 218, 185],
|
|
1067
|
-
peru: [205, 133, 63],
|
|
1068
|
-
pink: [255, 192, 203],
|
|
1069
|
-
plum: [221, 160, 221],
|
|
1070
|
-
powderblue: [176, 224, 230],
|
|
1071
|
-
purple: [128, 0, 128],
|
|
1072
|
-
rebeccapurple: [102, 51, 153],
|
|
1073
|
-
red: [255, 0, 0],
|
|
1074
|
-
rosybrown: [188, 143, 143],
|
|
1075
|
-
royalblue: [65, 105, 225],
|
|
1076
|
-
saddlebrown: [139, 69, 19],
|
|
1077
|
-
salmon: [250, 128, 114],
|
|
1078
|
-
sandybrown: [244, 164, 96],
|
|
1079
|
-
seagreen: [46, 139, 87],
|
|
1080
|
-
seashell: [255, 245, 238],
|
|
1081
|
-
sienna: [160, 82, 45],
|
|
1082
|
-
silver: [192, 192, 192],
|
|
1083
|
-
skyblue: [135, 206, 235],
|
|
1084
|
-
slateblue: [106, 90, 205],
|
|
1085
|
-
slategray: [112, 128, 144],
|
|
1086
|
-
slategrey: [112, 128, 144],
|
|
1087
|
-
snow: [255, 250, 250],
|
|
1088
|
-
springgreen: [0, 255, 127],
|
|
1089
|
-
steelblue: [70, 130, 180],
|
|
1090
|
-
tan: [210, 180, 140],
|
|
1091
|
-
teal: [0, 128, 128],
|
|
1092
|
-
thistle: [216, 191, 216],
|
|
1093
|
-
tomato: [255, 99, 71],
|
|
1094
|
-
turquoise: [64, 224, 208],
|
|
1095
|
-
violet: [238, 130, 238],
|
|
1096
|
-
wheat: [245, 222, 179],
|
|
1097
|
-
white: [255, 255, 255],
|
|
1098
|
-
whitesmoke: [245, 245, 245],
|
|
1099
|
-
yellow: [255, 255, 0],
|
|
1100
|
-
yellowgreen: [154, 205, 50]
|
|
1101
|
-
}
|
|
1102
|
-
return colorName
|
|
1103
|
-
}
|
|
1104
|
-
|
|
1105
|
-
/* MIT license */
|
|
1106
|
-
let conversions
|
|
1107
|
-
let hasRequiredConversions
|
|
1108
|
-
function requireConversions() {
|
|
1109
|
-
if (hasRequiredConversions) {
|
|
1110
|
-
return conversions
|
|
1111
|
-
}
|
|
1112
|
-
hasRequiredConversions = 1
|
|
1113
|
-
/* eslint-disable no-mixed-operators */
|
|
1114
|
-
const cssKeywords = requireColorName()
|
|
1115
|
-
|
|
1116
|
-
// NOTE: conversions should only return primitive values (i.e. arrays, or
|
|
1117
|
-
// values that give correct `typeof` results).
|
|
1118
|
-
// do not use box values types (i.e. Number(), String(), etc.)
|
|
1119
|
-
|
|
1120
|
-
const reverseKeywords = {}
|
|
1121
|
-
for (const key of Object.keys(cssKeywords)) {
|
|
1122
|
-
reverseKeywords[cssKeywords[key]] = key
|
|
1123
|
-
}
|
|
1124
|
-
const convert = {
|
|
1125
|
-
rgb: {
|
|
1126
|
-
channels: 3,
|
|
1127
|
-
labels: 'rgb'
|
|
1128
|
-
},
|
|
1129
|
-
hsl: {
|
|
1130
|
-
channels: 3,
|
|
1131
|
-
labels: 'hsl'
|
|
1132
|
-
},
|
|
1133
|
-
hsv: {
|
|
1134
|
-
channels: 3,
|
|
1135
|
-
labels: 'hsv'
|
|
1136
|
-
},
|
|
1137
|
-
hwb: {
|
|
1138
|
-
channels: 3,
|
|
1139
|
-
labels: 'hwb'
|
|
1140
|
-
},
|
|
1141
|
-
cmyk: {
|
|
1142
|
-
channels: 4,
|
|
1143
|
-
labels: 'cmyk'
|
|
1144
|
-
},
|
|
1145
|
-
xyz: {
|
|
1146
|
-
channels: 3,
|
|
1147
|
-
labels: 'xyz'
|
|
1148
|
-
},
|
|
1149
|
-
lab: {
|
|
1150
|
-
channels: 3,
|
|
1151
|
-
labels: 'lab'
|
|
1152
|
-
},
|
|
1153
|
-
lch: {
|
|
1154
|
-
channels: 3,
|
|
1155
|
-
labels: 'lch'
|
|
1156
|
-
},
|
|
1157
|
-
hex: {
|
|
1158
|
-
channels: 1,
|
|
1159
|
-
labels: ['hex']
|
|
1160
|
-
},
|
|
1161
|
-
keyword: {
|
|
1162
|
-
channels: 1,
|
|
1163
|
-
labels: ['keyword']
|
|
1164
|
-
},
|
|
1165
|
-
ansi16: {
|
|
1166
|
-
channels: 1,
|
|
1167
|
-
labels: ['ansi16']
|
|
1168
|
-
},
|
|
1169
|
-
ansi256: {
|
|
1170
|
-
channels: 1,
|
|
1171
|
-
labels: ['ansi256']
|
|
1172
|
-
},
|
|
1173
|
-
hcg: {
|
|
1174
|
-
channels: 3,
|
|
1175
|
-
labels: ['h', 'c', 'g']
|
|
1176
|
-
},
|
|
1177
|
-
apple: {
|
|
1178
|
-
channels: 3,
|
|
1179
|
-
labels: ['r16', 'g16', 'b16']
|
|
1180
|
-
},
|
|
1181
|
-
gray: {
|
|
1182
|
-
channels: 1,
|
|
1183
|
-
labels: ['gray']
|
|
1184
|
-
}
|
|
1185
|
-
}
|
|
1186
|
-
conversions = convert
|
|
1187
|
-
|
|
1188
|
-
// Hide .channels and .labels properties
|
|
1189
|
-
for (const model of Object.keys(convert)) {
|
|
1190
|
-
if (!('channels' in convert[model])) {
|
|
1191
|
-
throw new Error('missing channels property: ' + model)
|
|
1192
|
-
}
|
|
1193
|
-
if (!('labels' in convert[model])) {
|
|
1194
|
-
throw new Error('missing channel labels property: ' + model)
|
|
1195
|
-
}
|
|
1196
|
-
if (convert[model].labels.length !== convert[model].channels) {
|
|
1197
|
-
throw new Error('channel and label counts mismatch: ' + model)
|
|
1198
|
-
}
|
|
1199
|
-
const { channels, labels } = convert[model]
|
|
1200
|
-
delete convert[model].channels
|
|
1201
|
-
delete convert[model].labels
|
|
1202
|
-
Object.defineProperty(convert[model], 'channels', {
|
|
1203
|
-
value: channels
|
|
1204
|
-
})
|
|
1205
|
-
Object.defineProperty(convert[model], 'labels', {
|
|
1206
|
-
value: labels
|
|
1207
|
-
})
|
|
1208
|
-
}
|
|
1209
|
-
convert.rgb.hsl = function (rgb) {
|
|
1210
|
-
const r = rgb[0] / 255
|
|
1211
|
-
const g = rgb[1] / 255
|
|
1212
|
-
const b = rgb[2] / 255
|
|
1213
|
-
const min = Math.min(r, g, b)
|
|
1214
|
-
const max = Math.max(r, g, b)
|
|
1215
|
-
const delta = max - min
|
|
1216
|
-
let h
|
|
1217
|
-
let s
|
|
1218
|
-
if (max === min) {
|
|
1219
|
-
h = 0
|
|
1220
|
-
} else if (r === max) {
|
|
1221
|
-
h = (g - b) / delta
|
|
1222
|
-
} else if (g === max) {
|
|
1223
|
-
h = 2 + (b - r) / delta
|
|
1224
|
-
} else if (b === max) {
|
|
1225
|
-
h = 4 + (r - g) / delta
|
|
1226
|
-
}
|
|
1227
|
-
h = Math.min(h * 60, 360)
|
|
1228
|
-
if (h < 0) {
|
|
1229
|
-
h += 360
|
|
1230
|
-
}
|
|
1231
|
-
const l = (min + max) / 2
|
|
1232
|
-
if (max === min) {
|
|
1233
|
-
s = 0
|
|
1234
|
-
} else if (l <= 0.5) {
|
|
1235
|
-
s = delta / (max + min)
|
|
1236
|
-
} else {
|
|
1237
|
-
s = delta / (2 - max - min)
|
|
1238
|
-
}
|
|
1239
|
-
return [h, s * 100, l * 100]
|
|
1240
|
-
}
|
|
1241
|
-
convert.rgb.hsv = function (rgb) {
|
|
1242
|
-
let rdif
|
|
1243
|
-
let gdif
|
|
1244
|
-
let bdif
|
|
1245
|
-
let h
|
|
1246
|
-
let s
|
|
1247
|
-
const r = rgb[0] / 255
|
|
1248
|
-
const g = rgb[1] / 255
|
|
1249
|
-
const b = rgb[2] / 255
|
|
1250
|
-
const v = Math.max(r, g, b)
|
|
1251
|
-
const diff = v - Math.min(r, g, b)
|
|
1252
|
-
const diffc = function (c) {
|
|
1253
|
-
return (v - c) / 6 / diff + 1 / 2
|
|
1254
|
-
}
|
|
1255
|
-
if (diff === 0) {
|
|
1256
|
-
h = 0
|
|
1257
|
-
s = 0
|
|
1258
|
-
} else {
|
|
1259
|
-
s = diff / v
|
|
1260
|
-
rdif = diffc(r)
|
|
1261
|
-
gdif = diffc(g)
|
|
1262
|
-
bdif = diffc(b)
|
|
1263
|
-
if (r === v) {
|
|
1264
|
-
h = bdif - gdif
|
|
1265
|
-
} else if (g === v) {
|
|
1266
|
-
h = 1 / 3 + rdif - bdif
|
|
1267
|
-
} else if (b === v) {
|
|
1268
|
-
h = 2 / 3 + gdif - rdif
|
|
1269
|
-
}
|
|
1270
|
-
if (h < 0) {
|
|
1271
|
-
h += 1
|
|
1272
|
-
} else if (h > 1) {
|
|
1273
|
-
h -= 1
|
|
1274
|
-
}
|
|
1275
|
-
}
|
|
1276
|
-
return [h * 360, s * 100, v * 100]
|
|
1277
|
-
}
|
|
1278
|
-
convert.rgb.hwb = function (rgb) {
|
|
1279
|
-
const r = rgb[0]
|
|
1280
|
-
const g = rgb[1]
|
|
1281
|
-
let b = rgb[2]
|
|
1282
|
-
const h = convert.rgb.hsl(rgb)[0]
|
|
1283
|
-
const w = (1 / 255) * Math.min(r, Math.min(g, b))
|
|
1284
|
-
b = 1 - (1 / 255) * Math.max(r, Math.max(g, b))
|
|
1285
|
-
return [h, w * 100, b * 100]
|
|
1286
|
-
}
|
|
1287
|
-
convert.rgb.cmyk = function (rgb) {
|
|
1288
|
-
const r = rgb[0] / 255
|
|
1289
|
-
const g = rgb[1] / 255
|
|
1290
|
-
const b = rgb[2] / 255
|
|
1291
|
-
const k = Math.min(1 - r, 1 - g, 1 - b)
|
|
1292
|
-
const c = (1 - r - k) / (1 - k) || 0
|
|
1293
|
-
const m = (1 - g - k) / (1 - k) || 0
|
|
1294
|
-
const y = (1 - b - k) / (1 - k) || 0
|
|
1295
|
-
return [c * 100, m * 100, y * 100, k * 100]
|
|
1296
|
-
}
|
|
1297
|
-
function comparativeDistance(x, y) {
|
|
1298
|
-
/*
|
|
1299
|
-
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
|
1300
|
-
*/
|
|
1301
|
-
return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2
|
|
1302
|
-
}
|
|
1303
|
-
convert.rgb.keyword = function (rgb) {
|
|
1304
|
-
const reversed = reverseKeywords[rgb]
|
|
1305
|
-
if (reversed) {
|
|
1306
|
-
return reversed
|
|
1307
|
-
}
|
|
1308
|
-
let currentClosestDistance = Infinity
|
|
1309
|
-
let currentClosestKeyword
|
|
1310
|
-
for (const keyword of Object.keys(cssKeywords)) {
|
|
1311
|
-
const value = cssKeywords[keyword]
|
|
1312
|
-
|
|
1313
|
-
// Compute comparative distance
|
|
1314
|
-
const distance = comparativeDistance(rgb, value)
|
|
1315
|
-
|
|
1316
|
-
// Check if its less, if so set as closest
|
|
1317
|
-
if (distance < currentClosestDistance) {
|
|
1318
|
-
currentClosestDistance = distance
|
|
1319
|
-
currentClosestKeyword = keyword
|
|
1320
|
-
}
|
|
1321
|
-
}
|
|
1322
|
-
return currentClosestKeyword
|
|
1323
|
-
}
|
|
1324
|
-
convert.keyword.rgb = function (keyword) {
|
|
1325
|
-
return cssKeywords[keyword]
|
|
1326
|
-
}
|
|
1327
|
-
convert.rgb.xyz = function (rgb) {
|
|
1328
|
-
let r = rgb[0] / 255
|
|
1329
|
-
let g = rgb[1] / 255
|
|
1330
|
-
let b = rgb[2] / 255
|
|
1331
|
-
|
|
1332
|
-
// Assume sRGB
|
|
1333
|
-
r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92
|
|
1334
|
-
g = g > 0.04045 ? ((g + 0.055) / 1.055) ** 2.4 : g / 12.92
|
|
1335
|
-
b = b > 0.04045 ? ((b + 0.055) / 1.055) ** 2.4 : b / 12.92
|
|
1336
|
-
const x = r * 0.4124 + g * 0.3576 + b * 0.1805
|
|
1337
|
-
const y = r * 0.2126 + g * 0.7152 + b * 0.0722
|
|
1338
|
-
const z = r * 0.0193 + g * 0.1192 + b * 0.9505
|
|
1339
|
-
return [x * 100, y * 100, z * 100]
|
|
1340
|
-
}
|
|
1341
|
-
convert.rgb.lab = function (rgb) {
|
|
1342
|
-
const xyz = convert.rgb.xyz(rgb)
|
|
1343
|
-
let x = xyz[0]
|
|
1344
|
-
let y = xyz[1]
|
|
1345
|
-
let z = xyz[2]
|
|
1346
|
-
x /= 95.047
|
|
1347
|
-
y /= 100
|
|
1348
|
-
z /= 108.883
|
|
1349
|
-
x = x > 0.008856 ? x ** (1 / 3) : 7.787 * x + 16 / 116
|
|
1350
|
-
y = y > 0.008856 ? y ** (1 / 3) : 7.787 * y + 16 / 116
|
|
1351
|
-
z = z > 0.008856 ? z ** (1 / 3) : 7.787 * z + 16 / 116
|
|
1352
|
-
const l = 116 * y - 16
|
|
1353
|
-
const a = 500 * (x - y)
|
|
1354
|
-
const b = 200 * (y - z)
|
|
1355
|
-
return [l, a, b]
|
|
1356
|
-
}
|
|
1357
|
-
convert.hsl.rgb = function (hsl) {
|
|
1358
|
-
const h = hsl[0] / 360
|
|
1359
|
-
const s = hsl[1] / 100
|
|
1360
|
-
const l = hsl[2] / 100
|
|
1361
|
-
let t2
|
|
1362
|
-
let t3
|
|
1363
|
-
let val
|
|
1364
|
-
if (s === 0) {
|
|
1365
|
-
val = l * 255
|
|
1366
|
-
return [val, val, val]
|
|
1367
|
-
}
|
|
1368
|
-
if (l < 0.5) {
|
|
1369
|
-
t2 = l * (1 + s)
|
|
1370
|
-
} else {
|
|
1371
|
-
t2 = l + s - l * s
|
|
1372
|
-
}
|
|
1373
|
-
const t1 = 2 * l - t2
|
|
1374
|
-
const rgb = [0, 0, 0]
|
|
1375
|
-
for (let i = 0; i < 3; i++) {
|
|
1376
|
-
t3 = h + (1 / 3) * -(i - 1)
|
|
1377
|
-
if (t3 < 0) {
|
|
1378
|
-
t3++
|
|
1379
|
-
}
|
|
1380
|
-
if (t3 > 1) {
|
|
1381
|
-
t3--
|
|
1382
|
-
}
|
|
1383
|
-
if (6 * t3 < 1) {
|
|
1384
|
-
val = t1 + (t2 - t1) * 6 * t3
|
|
1385
|
-
} else if (2 * t3 < 1) {
|
|
1386
|
-
val = t2
|
|
1387
|
-
} else if (3 * t3 < 2) {
|
|
1388
|
-
val = t1 + (t2 - t1) * (2 / 3 - t3) * 6
|
|
1389
|
-
} else {
|
|
1390
|
-
val = t1
|
|
1391
|
-
}
|
|
1392
|
-
rgb[i] = val * 255
|
|
1393
|
-
}
|
|
1394
|
-
return rgb
|
|
1395
|
-
}
|
|
1396
|
-
convert.hsl.hsv = function (hsl) {
|
|
1397
|
-
const h = hsl[0]
|
|
1398
|
-
let s = hsl[1] / 100
|
|
1399
|
-
let l = hsl[2] / 100
|
|
1400
|
-
let smin = s
|
|
1401
|
-
const lmin = Math.max(l, 0.01)
|
|
1402
|
-
l *= 2
|
|
1403
|
-
s *= l <= 1 ? l : 2 - l
|
|
1404
|
-
smin *= lmin <= 1 ? lmin : 2 - lmin
|
|
1405
|
-
const v = (l + s) / 2
|
|
1406
|
-
const sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s)
|
|
1407
|
-
return [h, sv * 100, v * 100]
|
|
1408
|
-
}
|
|
1409
|
-
convert.hsv.rgb = function (hsv) {
|
|
1410
|
-
const h = hsv[0] / 60
|
|
1411
|
-
const s = hsv[1] / 100
|
|
1412
|
-
let v = hsv[2] / 100
|
|
1413
|
-
const hi = Math.floor(h) % 6
|
|
1414
|
-
const f = h - Math.floor(h)
|
|
1415
|
-
const p = 255 * v * (1 - s)
|
|
1416
|
-
const q = 255 * v * (1 - s * f)
|
|
1417
|
-
const t = 255 * v * (1 - s * (1 - f))
|
|
1418
|
-
v *= 255
|
|
1419
|
-
switch (hi) {
|
|
1420
|
-
case 0:
|
|
1421
|
-
return [v, t, p]
|
|
1422
|
-
case 1:
|
|
1423
|
-
return [q, v, p]
|
|
1424
|
-
case 2:
|
|
1425
|
-
return [p, v, t]
|
|
1426
|
-
case 3:
|
|
1427
|
-
return [p, q, v]
|
|
1428
|
-
case 4:
|
|
1429
|
-
return [t, p, v]
|
|
1430
|
-
case 5:
|
|
1431
|
-
return [v, p, q]
|
|
1432
|
-
}
|
|
1433
|
-
}
|
|
1434
|
-
convert.hsv.hsl = function (hsv) {
|
|
1435
|
-
const h = hsv[0]
|
|
1436
|
-
const s = hsv[1] / 100
|
|
1437
|
-
const v = hsv[2] / 100
|
|
1438
|
-
const vmin = Math.max(v, 0.01)
|
|
1439
|
-
let sl
|
|
1440
|
-
let l
|
|
1441
|
-
l = (2 - s) * v
|
|
1442
|
-
const lmin = (2 - s) * vmin
|
|
1443
|
-
sl = s * vmin
|
|
1444
|
-
sl /= lmin <= 1 ? lmin : 2 - lmin
|
|
1445
|
-
sl = sl || 0
|
|
1446
|
-
l /= 2
|
|
1447
|
-
return [h, sl * 100, l * 100]
|
|
1448
|
-
}
|
|
1449
|
-
|
|
1450
|
-
// http://dev.w3.org/csswg/css-color/#hwb-to-rgb
|
|
1451
|
-
convert.hwb.rgb = function (hwb) {
|
|
1452
|
-
const h = hwb[0] / 360
|
|
1453
|
-
let wh = hwb[1] / 100
|
|
1454
|
-
let bl = hwb[2] / 100
|
|
1455
|
-
const ratio = wh + bl
|
|
1456
|
-
let f
|
|
1457
|
-
|
|
1458
|
-
// Wh + bl cant be > 1
|
|
1459
|
-
if (ratio > 1) {
|
|
1460
|
-
wh /= ratio
|
|
1461
|
-
bl /= ratio
|
|
1462
|
-
}
|
|
1463
|
-
const i = Math.floor(6 * h)
|
|
1464
|
-
const v = 1 - bl
|
|
1465
|
-
f = 6 * h - i
|
|
1466
|
-
if ((i & 0x01) !== 0) {
|
|
1467
|
-
f = 1 - f
|
|
1468
|
-
}
|
|
1469
|
-
const n = wh + f * (v - wh) // Linear interpolation
|
|
1470
|
-
|
|
1471
|
-
let r
|
|
1472
|
-
let g
|
|
1473
|
-
let b
|
|
1474
|
-
/* eslint-disable max-statements-per-line,no-multi-spaces */
|
|
1475
|
-
switch (i) {
|
|
1476
|
-
default:
|
|
1477
|
-
case 6:
|
|
1478
|
-
case 0:
|
|
1479
|
-
r = v
|
|
1480
|
-
g = n
|
|
1481
|
-
b = wh
|
|
1482
|
-
break
|
|
1483
|
-
case 1:
|
|
1484
|
-
r = n
|
|
1485
|
-
g = v
|
|
1486
|
-
b = wh
|
|
1487
|
-
break
|
|
1488
|
-
case 2:
|
|
1489
|
-
r = wh
|
|
1490
|
-
g = v
|
|
1491
|
-
b = n
|
|
1492
|
-
break
|
|
1493
|
-
case 3:
|
|
1494
|
-
r = wh
|
|
1495
|
-
g = n
|
|
1496
|
-
b = v
|
|
1497
|
-
break
|
|
1498
|
-
case 4:
|
|
1499
|
-
r = n
|
|
1500
|
-
g = wh
|
|
1501
|
-
b = v
|
|
1502
|
-
break
|
|
1503
|
-
case 5:
|
|
1504
|
-
r = v
|
|
1505
|
-
g = wh
|
|
1506
|
-
b = n
|
|
1507
|
-
break
|
|
1508
|
-
}
|
|
1509
|
-
/* eslint-enable max-statements-per-line,no-multi-spaces */
|
|
1510
|
-
|
|
1511
|
-
return [r * 255, g * 255, b * 255]
|
|
1512
|
-
}
|
|
1513
|
-
convert.cmyk.rgb = function (cmyk) {
|
|
1514
|
-
const c = cmyk[0] / 100
|
|
1515
|
-
const m = cmyk[1] / 100
|
|
1516
|
-
const y = cmyk[2] / 100
|
|
1517
|
-
const k = cmyk[3] / 100
|
|
1518
|
-
const r = 1 - Math.min(1, c * (1 - k) + k)
|
|
1519
|
-
const g = 1 - Math.min(1, m * (1 - k) + k)
|
|
1520
|
-
const b = 1 - Math.min(1, y * (1 - k) + k)
|
|
1521
|
-
return [r * 255, g * 255, b * 255]
|
|
1522
|
-
}
|
|
1523
|
-
convert.xyz.rgb = function (xyz) {
|
|
1524
|
-
const x = xyz[0] / 100
|
|
1525
|
-
const y = xyz[1] / 100
|
|
1526
|
-
const z = xyz[2] / 100
|
|
1527
|
-
let r
|
|
1528
|
-
let g
|
|
1529
|
-
let b
|
|
1530
|
-
r = x * 3.2406 + y * -1.5372 + z * -0.4986
|
|
1531
|
-
g = x * -0.9689 + y * 1.8758 + z * 0.0415
|
|
1532
|
-
b = x * 0.0557 + y * -0.204 + z * 1.057
|
|
1533
|
-
|
|
1534
|
-
// Assume sRGB
|
|
1535
|
-
r = r > 0.0031308 ? 1.055 * r ** (1.0 / 2.4) - 0.055 : r * 12.92
|
|
1536
|
-
g = g > 0.0031308 ? 1.055 * g ** (1.0 / 2.4) - 0.055 : g * 12.92
|
|
1537
|
-
b = b > 0.0031308 ? 1.055 * b ** (1.0 / 2.4) - 0.055 : b * 12.92
|
|
1538
|
-
r = Math.min(Math.max(0, r), 1)
|
|
1539
|
-
g = Math.min(Math.max(0, g), 1)
|
|
1540
|
-
b = Math.min(Math.max(0, b), 1)
|
|
1541
|
-
return [r * 255, g * 255, b * 255]
|
|
1542
|
-
}
|
|
1543
|
-
convert.xyz.lab = function (xyz) {
|
|
1544
|
-
let x = xyz[0]
|
|
1545
|
-
let y = xyz[1]
|
|
1546
|
-
let z = xyz[2]
|
|
1547
|
-
x /= 95.047
|
|
1548
|
-
y /= 100
|
|
1549
|
-
z /= 108.883
|
|
1550
|
-
x = x > 0.008856 ? x ** (1 / 3) : 7.787 * x + 16 / 116
|
|
1551
|
-
y = y > 0.008856 ? y ** (1 / 3) : 7.787 * y + 16 / 116
|
|
1552
|
-
z = z > 0.008856 ? z ** (1 / 3) : 7.787 * z + 16 / 116
|
|
1553
|
-
const l = 116 * y - 16
|
|
1554
|
-
const a = 500 * (x - y)
|
|
1555
|
-
const b = 200 * (y - z)
|
|
1556
|
-
return [l, a, b]
|
|
1557
|
-
}
|
|
1558
|
-
convert.lab.xyz = function (lab) {
|
|
1559
|
-
const l = lab[0]
|
|
1560
|
-
const a = lab[1]
|
|
1561
|
-
const b = lab[2]
|
|
1562
|
-
let x
|
|
1563
|
-
let y
|
|
1564
|
-
let z
|
|
1565
|
-
y = (l + 16) / 116
|
|
1566
|
-
x = a / 500 + y
|
|
1567
|
-
z = y - b / 200
|
|
1568
|
-
const y2 = y ** 3
|
|
1569
|
-
const x2 = x ** 3
|
|
1570
|
-
const z2 = z ** 3
|
|
1571
|
-
y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787
|
|
1572
|
-
x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787
|
|
1573
|
-
z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787
|
|
1574
|
-
x *= 95.047
|
|
1575
|
-
y *= 100
|
|
1576
|
-
z *= 108.883
|
|
1577
|
-
return [x, y, z]
|
|
1578
|
-
}
|
|
1579
|
-
convert.lab.lch = function (lab) {
|
|
1580
|
-
const l = lab[0]
|
|
1581
|
-
const a = lab[1]
|
|
1582
|
-
const b = lab[2]
|
|
1583
|
-
let h
|
|
1584
|
-
const hr = Math.atan2(b, a)
|
|
1585
|
-
h = (hr * 360) / 2 / Math.PI
|
|
1586
|
-
if (h < 0) {
|
|
1587
|
-
h += 360
|
|
1588
|
-
}
|
|
1589
|
-
const c = Math.sqrt(a * a + b * b)
|
|
1590
|
-
return [l, c, h]
|
|
1591
|
-
}
|
|
1592
|
-
convert.lch.lab = function (lch) {
|
|
1593
|
-
const l = lch[0]
|
|
1594
|
-
const c = lch[1]
|
|
1595
|
-
const h = lch[2]
|
|
1596
|
-
const hr = (h / 360) * 2 * Math.PI
|
|
1597
|
-
const a = c * Math.cos(hr)
|
|
1598
|
-
const b = c * Math.sin(hr)
|
|
1599
|
-
return [l, a, b]
|
|
1600
|
-
}
|
|
1601
|
-
convert.rgb.ansi16 = function (args, saturation = null) {
|
|
1602
|
-
const [r, g, b] = args
|
|
1603
|
-
let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation // Hsv -> ansi16 optimization
|
|
1604
|
-
|
|
1605
|
-
value = Math.round(value / 50)
|
|
1606
|
-
if (value === 0) {
|
|
1607
|
-
return 30
|
|
1608
|
-
}
|
|
1609
|
-
let ansi =
|
|
1610
|
-
30 +
|
|
1611
|
-
((Math.round(b / 255) << 2) |
|
|
1612
|
-
(Math.round(g / 255) << 1) |
|
|
1613
|
-
Math.round(r / 255))
|
|
1614
|
-
if (value === 2) {
|
|
1615
|
-
ansi += 60
|
|
1616
|
-
}
|
|
1617
|
-
return ansi
|
|
1618
|
-
}
|
|
1619
|
-
convert.hsv.ansi16 = function (args) {
|
|
1620
|
-
// Optimization here; we already know the value and don't need to get
|
|
1621
|
-
// it converted for us.
|
|
1622
|
-
return convert.rgb.ansi16(convert.hsv.rgb(args), args[2])
|
|
1623
|
-
}
|
|
1624
|
-
convert.rgb.ansi256 = function (args) {
|
|
1625
|
-
const r = args[0]
|
|
1626
|
-
const g = args[1]
|
|
1627
|
-
const b = args[2]
|
|
1628
|
-
|
|
1629
|
-
// We use the extended greyscale palette here, with the exception of
|
|
1630
|
-
// black and white. normal palette only has 4 greyscale shades.
|
|
1631
|
-
if (r === g && g === b) {
|
|
1632
|
-
if (r < 8) {
|
|
1633
|
-
return 16
|
|
1634
|
-
}
|
|
1635
|
-
if (r > 248) {
|
|
1636
|
-
return 231
|
|
1637
|
-
}
|
|
1638
|
-
return Math.round(((r - 8) / 247) * 24) + 232
|
|
1639
|
-
}
|
|
1640
|
-
const ansi =
|
|
1641
|
-
16 +
|
|
1642
|
-
36 * Math.round((r / 255) * 5) +
|
|
1643
|
-
6 * Math.round((g / 255) * 5) +
|
|
1644
|
-
Math.round((b / 255) * 5)
|
|
1645
|
-
return ansi
|
|
1646
|
-
}
|
|
1647
|
-
convert.ansi16.rgb = function (args) {
|
|
1648
|
-
let color = args % 10
|
|
1649
|
-
|
|
1650
|
-
// Handle greyscale
|
|
1651
|
-
if (color === 0 || color === 7) {
|
|
1652
|
-
if (args > 50) {
|
|
1653
|
-
color += 3.5
|
|
1654
|
-
}
|
|
1655
|
-
color = (color / 10.5) * 255
|
|
1656
|
-
return [color, color, color]
|
|
1657
|
-
}
|
|
1658
|
-
const mult = (~~(args > 50) + 1) * 0.5
|
|
1659
|
-
const r = (color & 1) * mult * 255
|
|
1660
|
-
const g = ((color >> 1) & 1) * mult * 255
|
|
1661
|
-
const b = ((color >> 2) & 1) * mult * 255
|
|
1662
|
-
return [r, g, b]
|
|
1663
|
-
}
|
|
1664
|
-
convert.ansi256.rgb = function (args) {
|
|
1665
|
-
// Handle greyscale
|
|
1666
|
-
if (args >= 232) {
|
|
1667
|
-
const c = (args - 232) * 10 + 8
|
|
1668
|
-
return [c, c, c]
|
|
1669
|
-
}
|
|
1670
|
-
args -= 16
|
|
1671
|
-
let rem
|
|
1672
|
-
const r = (Math.floor(args / 36) / 5) * 255
|
|
1673
|
-
const g = (Math.floor((rem = args % 36) / 6) / 5) * 255
|
|
1674
|
-
const b = ((rem % 6) / 5) * 255
|
|
1675
|
-
return [r, g, b]
|
|
1676
|
-
}
|
|
1677
|
-
convert.rgb.hex = function (args) {
|
|
1678
|
-
const integer =
|
|
1679
|
-
((Math.round(args[0]) & 0xff) << 16) +
|
|
1680
|
-
((Math.round(args[1]) & 0xff) << 8) +
|
|
1681
|
-
(Math.round(args[2]) & 0xff)
|
|
1682
|
-
const string = integer.toString(16).toUpperCase()
|
|
1683
|
-
return '000000'.substring(string.length) + string
|
|
1684
|
-
}
|
|
1685
|
-
convert.hex.rgb = function (args) {
|
|
1686
|
-
const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i)
|
|
1687
|
-
if (!match) {
|
|
1688
|
-
return [0, 0, 0]
|
|
1689
|
-
}
|
|
1690
|
-
let colorString = match[0]
|
|
1691
|
-
if (match[0].length === 3) {
|
|
1692
|
-
colorString = colorString
|
|
1693
|
-
.split('')
|
|
1694
|
-
.map(char => {
|
|
1695
|
-
return char + char
|
|
1696
|
-
})
|
|
1697
|
-
.join('')
|
|
1698
|
-
}
|
|
1699
|
-
const integer = parseInt(colorString, 16)
|
|
1700
|
-
const r = (integer >> 16) & 0xff
|
|
1701
|
-
const g = (integer >> 8) & 0xff
|
|
1702
|
-
const b = integer & 0xff
|
|
1703
|
-
return [r, g, b]
|
|
1704
|
-
}
|
|
1705
|
-
convert.rgb.hcg = function (rgb) {
|
|
1706
|
-
const r = rgb[0] / 255
|
|
1707
|
-
const g = rgb[1] / 255
|
|
1708
|
-
const b = rgb[2] / 255
|
|
1709
|
-
const max = Math.max(Math.max(r, g), b)
|
|
1710
|
-
const min = Math.min(Math.min(r, g), b)
|
|
1711
|
-
const chroma = max - min
|
|
1712
|
-
let grayscale
|
|
1713
|
-
let hue
|
|
1714
|
-
if (chroma < 1) {
|
|
1715
|
-
grayscale = min / (1 - chroma)
|
|
1716
|
-
} else {
|
|
1717
|
-
grayscale = 0
|
|
1718
|
-
}
|
|
1719
|
-
if (chroma <= 0) {
|
|
1720
|
-
hue = 0
|
|
1721
|
-
} else if (max === r) {
|
|
1722
|
-
hue = ((g - b) / chroma) % 6
|
|
1723
|
-
} else if (max === g) {
|
|
1724
|
-
hue = 2 + (b - r) / chroma
|
|
1725
|
-
} else {
|
|
1726
|
-
hue = 4 + (r - g) / chroma
|
|
1727
|
-
}
|
|
1728
|
-
hue /= 6
|
|
1729
|
-
hue %= 1
|
|
1730
|
-
return [hue * 360, chroma * 100, grayscale * 100]
|
|
1731
|
-
}
|
|
1732
|
-
convert.hsl.hcg = function (hsl) {
|
|
1733
|
-
const s = hsl[1] / 100
|
|
1734
|
-
const l = hsl[2] / 100
|
|
1735
|
-
const c = l < 0.5 ? 2.0 * s * l : 2.0 * s * (1.0 - l)
|
|
1736
|
-
let f = 0
|
|
1737
|
-
if (c < 1.0) {
|
|
1738
|
-
f = (l - 0.5 * c) / (1.0 - c)
|
|
1739
|
-
}
|
|
1740
|
-
return [hsl[0], c * 100, f * 100]
|
|
1741
|
-
}
|
|
1742
|
-
convert.hsv.hcg = function (hsv) {
|
|
1743
|
-
const s = hsv[1] / 100
|
|
1744
|
-
const v = hsv[2] / 100
|
|
1745
|
-
const c = s * v
|
|
1746
|
-
let f = 0
|
|
1747
|
-
if (c < 1.0) {
|
|
1748
|
-
f = (v - c) / (1 - c)
|
|
1749
|
-
}
|
|
1750
|
-
return [hsv[0], c * 100, f * 100]
|
|
1751
|
-
}
|
|
1752
|
-
convert.hcg.rgb = function (hcg) {
|
|
1753
|
-
const h = hcg[0] / 360
|
|
1754
|
-
const c = hcg[1] / 100
|
|
1755
|
-
const g = hcg[2] / 100
|
|
1756
|
-
if (c === 0.0) {
|
|
1757
|
-
return [g * 255, g * 255, g * 255]
|
|
1758
|
-
}
|
|
1759
|
-
const pure = [0, 0, 0]
|
|
1760
|
-
const hi = (h % 1) * 6
|
|
1761
|
-
const v = hi % 1
|
|
1762
|
-
const w = 1 - v
|
|
1763
|
-
let mg = 0
|
|
1764
|
-
|
|
1765
|
-
/* eslint-disable max-statements-per-line */
|
|
1766
|
-
switch (Math.floor(hi)) {
|
|
1767
|
-
case 0:
|
|
1768
|
-
pure[0] = 1
|
|
1769
|
-
pure[1] = v
|
|
1770
|
-
pure[2] = 0
|
|
1771
|
-
break
|
|
1772
|
-
case 1:
|
|
1773
|
-
pure[0] = w
|
|
1774
|
-
pure[1] = 1
|
|
1775
|
-
pure[2] = 0
|
|
1776
|
-
break
|
|
1777
|
-
case 2:
|
|
1778
|
-
pure[0] = 0
|
|
1779
|
-
pure[1] = 1
|
|
1780
|
-
pure[2] = v
|
|
1781
|
-
break
|
|
1782
|
-
case 3:
|
|
1783
|
-
pure[0] = 0
|
|
1784
|
-
pure[1] = w
|
|
1785
|
-
pure[2] = 1
|
|
1786
|
-
break
|
|
1787
|
-
case 4:
|
|
1788
|
-
pure[0] = v
|
|
1789
|
-
pure[1] = 0
|
|
1790
|
-
pure[2] = 1
|
|
1791
|
-
break
|
|
1792
|
-
default:
|
|
1793
|
-
pure[0] = 1
|
|
1794
|
-
pure[1] = 0
|
|
1795
|
-
pure[2] = w
|
|
1796
|
-
}
|
|
1797
|
-
/* eslint-enable max-statements-per-line */
|
|
1798
|
-
|
|
1799
|
-
mg = (1.0 - c) * g
|
|
1800
|
-
return [
|
|
1801
|
-
(c * pure[0] + mg) * 255,
|
|
1802
|
-
(c * pure[1] + mg) * 255,
|
|
1803
|
-
(c * pure[2] + mg) * 255
|
|
1804
|
-
]
|
|
1805
|
-
}
|
|
1806
|
-
convert.hcg.hsv = function (hcg) {
|
|
1807
|
-
const c = hcg[1] / 100
|
|
1808
|
-
const g = hcg[2] / 100
|
|
1809
|
-
const v = c + g * (1.0 - c)
|
|
1810
|
-
let f = 0
|
|
1811
|
-
if (v > 0.0) {
|
|
1812
|
-
f = c / v
|
|
1813
|
-
}
|
|
1814
|
-
return [hcg[0], f * 100, v * 100]
|
|
1815
|
-
}
|
|
1816
|
-
convert.hcg.hsl = function (hcg) {
|
|
1817
|
-
const c = hcg[1] / 100
|
|
1818
|
-
const g = hcg[2] / 100
|
|
1819
|
-
const l = g * (1.0 - c) + 0.5 * c
|
|
1820
|
-
let s = 0
|
|
1821
|
-
if (l > 0.0 && l < 0.5) {
|
|
1822
|
-
s = c / (2 * l)
|
|
1823
|
-
} else if (l >= 0.5 && l < 1.0) {
|
|
1824
|
-
s = c / (2 * (1 - l))
|
|
1825
|
-
}
|
|
1826
|
-
return [hcg[0], s * 100, l * 100]
|
|
1827
|
-
}
|
|
1828
|
-
convert.hcg.hwb = function (hcg) {
|
|
1829
|
-
const c = hcg[1] / 100
|
|
1830
|
-
const g = hcg[2] / 100
|
|
1831
|
-
const v = c + g * (1.0 - c)
|
|
1832
|
-
return [hcg[0], (v - c) * 100, (1 - v) * 100]
|
|
1833
|
-
}
|
|
1834
|
-
convert.hwb.hcg = function (hwb) {
|
|
1835
|
-
const w = hwb[1] / 100
|
|
1836
|
-
const b = hwb[2] / 100
|
|
1837
|
-
const v = 1 - b
|
|
1838
|
-
const c = v - w
|
|
1839
|
-
let g = 0
|
|
1840
|
-
if (c < 1) {
|
|
1841
|
-
g = (v - c) / (1 - c)
|
|
1842
|
-
}
|
|
1843
|
-
return [hwb[0], c * 100, g * 100]
|
|
1844
|
-
}
|
|
1845
|
-
convert.apple.rgb = function (apple) {
|
|
1846
|
-
return [
|
|
1847
|
-
(apple[0] / 65535) * 255,
|
|
1848
|
-
(apple[1] / 65535) * 255,
|
|
1849
|
-
(apple[2] / 65535) * 255
|
|
1850
|
-
]
|
|
1851
|
-
}
|
|
1852
|
-
convert.rgb.apple = function (rgb) {
|
|
1853
|
-
return [
|
|
1854
|
-
(rgb[0] / 255) * 65535,
|
|
1855
|
-
(rgb[1] / 255) * 65535,
|
|
1856
|
-
(rgb[2] / 255) * 65535
|
|
1857
|
-
]
|
|
1858
|
-
}
|
|
1859
|
-
convert.gray.rgb = function (args) {
|
|
1860
|
-
return [(args[0] / 100) * 255, (args[0] / 100) * 255, (args[0] / 100) * 255]
|
|
1861
|
-
}
|
|
1862
|
-
convert.gray.hsl = function (args) {
|
|
1863
|
-
return [0, 0, args[0]]
|
|
1864
|
-
}
|
|
1865
|
-
convert.gray.hsv = convert.gray.hsl
|
|
1866
|
-
convert.gray.hwb = function (gray) {
|
|
1867
|
-
return [0, 100, gray[0]]
|
|
1868
|
-
}
|
|
1869
|
-
convert.gray.cmyk = function (gray) {
|
|
1870
|
-
return [0, 0, 0, gray[0]]
|
|
1871
|
-
}
|
|
1872
|
-
convert.gray.lab = function (gray) {
|
|
1873
|
-
return [gray[0], 0, 0]
|
|
1874
|
-
}
|
|
1875
|
-
convert.gray.hex = function (gray) {
|
|
1876
|
-
const val = Math.round((gray[0] / 100) * 255) & 0xff
|
|
1877
|
-
const integer = (val << 16) + (val << 8) + val
|
|
1878
|
-
const string = integer.toString(16).toUpperCase()
|
|
1879
|
-
return '000000'.substring(string.length) + string
|
|
1880
|
-
}
|
|
1881
|
-
convert.rgb.gray = function (rgb) {
|
|
1882
|
-
const val = (rgb[0] + rgb[1] + rgb[2]) / 3
|
|
1883
|
-
return [(val / 255) * 100]
|
|
1884
|
-
}
|
|
1885
|
-
return conversions
|
|
1886
|
-
}
|
|
1887
|
-
|
|
1888
|
-
let route
|
|
1889
|
-
let hasRequiredRoute
|
|
1890
|
-
function requireRoute() {
|
|
1891
|
-
if (hasRequiredRoute) {
|
|
1892
|
-
return route
|
|
1893
|
-
}
|
|
1894
|
-
hasRequiredRoute = 1
|
|
1895
|
-
const conversions = requireConversions()
|
|
1896
|
-
|
|
1897
|
-
/*
|
|
1898
|
-
This function routes a model to all other models.
|
|
1899
|
-
all functions that are routed have a property `.conversion` attached
|
|
1900
|
-
to the returned synthetic function. This property is an array
|
|
1901
|
-
of strings, each with the steps in between the 'from' and 'to'
|
|
1902
|
-
color models (inclusive).
|
|
1903
|
-
conversions that are not possible simply are not included.
|
|
1904
|
-
*/
|
|
1905
|
-
|
|
1906
|
-
function buildGraph() {
|
|
1907
|
-
const graph = {}
|
|
1908
|
-
// https://jsperf.com/object-keys-vs-for-in-with-closure/3
|
|
1909
|
-
const models = Object.keys(conversions)
|
|
1910
|
-
for (let len = models.length, i = 0; i < len; i++) {
|
|
1911
|
-
graph[models[i]] = {
|
|
1912
|
-
// http://jsperf.com/1-vs-infinity
|
|
1913
|
-
// micro-opt, but this is simple.
|
|
1914
|
-
distance: -1,
|
|
1915
|
-
parent: null
|
|
1916
|
-
}
|
|
1917
|
-
}
|
|
1918
|
-
return graph
|
|
1919
|
-
}
|
|
1920
|
-
|
|
1921
|
-
// https://en.wikipedia.org/wiki/Breadth-first_search
|
|
1922
|
-
function deriveBFS(fromModel) {
|
|
1923
|
-
const graph = buildGraph()
|
|
1924
|
-
const queue = [fromModel] // Unshift -> queue -> pop
|
|
1925
|
-
|
|
1926
|
-
graph[fromModel].distance = 0
|
|
1927
|
-
while (queue.length) {
|
|
1928
|
-
const current = queue.pop()
|
|
1929
|
-
const adjacents = Object.keys(conversions[current])
|
|
1930
|
-
for (let len = adjacents.length, i = 0; i < len; i++) {
|
|
1931
|
-
const adjacent = adjacents[i]
|
|
1932
|
-
const node = graph[adjacent]
|
|
1933
|
-
if (node.distance === -1) {
|
|
1934
|
-
node.distance = graph[current].distance + 1
|
|
1935
|
-
node.parent = current
|
|
1936
|
-
queue.unshift(adjacent)
|
|
1937
|
-
}
|
|
1938
|
-
}
|
|
1939
|
-
}
|
|
1940
|
-
return graph
|
|
1941
|
-
}
|
|
1942
|
-
function link(from, to) {
|
|
1943
|
-
return function (args) {
|
|
1944
|
-
return to(from(args))
|
|
1945
|
-
}
|
|
1946
|
-
}
|
|
1947
|
-
function wrapConversion(toModel, graph) {
|
|
1948
|
-
const path = [graph[toModel].parent, toModel]
|
|
1949
|
-
let fn = conversions[graph[toModel].parent][toModel]
|
|
1950
|
-
let cur = graph[toModel].parent
|
|
1951
|
-
while (graph[cur].parent) {
|
|
1952
|
-
path.unshift(graph[cur].parent)
|
|
1953
|
-
fn = link(conversions[graph[cur].parent][cur], fn)
|
|
1954
|
-
cur = graph[cur].parent
|
|
1955
|
-
}
|
|
1956
|
-
fn.conversion = path
|
|
1957
|
-
return fn
|
|
1958
|
-
}
|
|
1959
|
-
route = function (fromModel) {
|
|
1960
|
-
const graph = deriveBFS(fromModel)
|
|
1961
|
-
const conversion = {}
|
|
1962
|
-
const models = Object.keys(graph)
|
|
1963
|
-
for (let len = models.length, i = 0; i < len; i++) {
|
|
1964
|
-
const toModel = models[i]
|
|
1965
|
-
const node = graph[toModel]
|
|
1966
|
-
if (node.parent === null) {
|
|
1967
|
-
// No possible conversion, or this node is the source model.
|
|
1968
|
-
continue
|
|
1969
|
-
}
|
|
1970
|
-
conversion[toModel] = wrapConversion(toModel, graph)
|
|
1971
|
-
}
|
|
1972
|
-
return conversion
|
|
1973
|
-
}
|
|
1974
|
-
return route
|
|
1975
|
-
}
|
|
1976
|
-
|
|
1977
|
-
let colorConvert
|
|
1978
|
-
let hasRequiredColorConvert
|
|
1979
|
-
function requireColorConvert() {
|
|
1980
|
-
if (hasRequiredColorConvert) {
|
|
1981
|
-
return colorConvert
|
|
1982
|
-
}
|
|
1983
|
-
hasRequiredColorConvert = 1
|
|
1984
|
-
const conversions = requireConversions()
|
|
1985
|
-
const route = requireRoute()
|
|
1986
|
-
const convert = {}
|
|
1987
|
-
const models = Object.keys(conversions)
|
|
1988
|
-
function wrapRaw(fn) {
|
|
1989
|
-
const wrappedFn = function (...args) {
|
|
1990
|
-
const arg0 = args[0]
|
|
1991
|
-
if (arg0 === undefined || arg0 === null) {
|
|
1992
|
-
return arg0
|
|
1993
|
-
}
|
|
1994
|
-
if (arg0.length > 1) {
|
|
1995
|
-
args = arg0
|
|
1996
|
-
}
|
|
1997
|
-
return fn(args)
|
|
1998
|
-
}
|
|
1999
|
-
|
|
2000
|
-
// Preserve .conversion property if there is one
|
|
2001
|
-
if ('conversion' in fn) {
|
|
2002
|
-
wrappedFn.conversion = fn.conversion
|
|
2003
|
-
}
|
|
2004
|
-
return wrappedFn
|
|
2005
|
-
}
|
|
2006
|
-
function wrapRounded(fn) {
|
|
2007
|
-
const wrappedFn = function (...args) {
|
|
2008
|
-
const arg0 = args[0]
|
|
2009
|
-
if (arg0 === undefined || arg0 === null) {
|
|
2010
|
-
return arg0
|
|
2011
|
-
}
|
|
2012
|
-
if (arg0.length > 1) {
|
|
2013
|
-
args = arg0
|
|
2014
|
-
}
|
|
2015
|
-
const result = fn(args)
|
|
2016
|
-
|
|
2017
|
-
// We're assuming the result is an array here.
|
|
2018
|
-
// see notice in conversions.js; don't use box types
|
|
2019
|
-
// in conversion functions.
|
|
2020
|
-
if (typeof result === 'object') {
|
|
2021
|
-
for (let len = result.length, i = 0; i < len; i++) {
|
|
2022
|
-
result[i] = Math.round(result[i])
|
|
2023
|
-
}
|
|
2024
|
-
}
|
|
2025
|
-
return result
|
|
2026
|
-
}
|
|
2027
|
-
|
|
2028
|
-
// Preserve .conversion property if there is one
|
|
2029
|
-
if ('conversion' in fn) {
|
|
2030
|
-
wrappedFn.conversion = fn.conversion
|
|
2031
|
-
}
|
|
2032
|
-
return wrappedFn
|
|
2033
|
-
}
|
|
2034
|
-
models.forEach(fromModel => {
|
|
2035
|
-
convert[fromModel] = {}
|
|
2036
|
-
Object.defineProperty(convert[fromModel], 'channels', {
|
|
2037
|
-
value: conversions[fromModel].channels
|
|
2038
|
-
})
|
|
2039
|
-
Object.defineProperty(convert[fromModel], 'labels', {
|
|
2040
|
-
value: conversions[fromModel].labels
|
|
2041
|
-
})
|
|
2042
|
-
const routes = route(fromModel)
|
|
2043
|
-
const routeModels = Object.keys(routes)
|
|
2044
|
-
routeModels.forEach(toModel => {
|
|
2045
|
-
const fn = routes[toModel]
|
|
2046
|
-
convert[fromModel][toModel] = wrapRounded(fn)
|
|
2047
|
-
convert[fromModel][toModel].raw = wrapRaw(fn)
|
|
2048
|
-
})
|
|
2049
|
-
})
|
|
2050
|
-
colorConvert = convert
|
|
2051
|
-
return colorConvert
|
|
2052
|
-
}
|
|
2053
|
-
|
|
2054
|
-
ansiStyles.exports
|
|
2055
|
-
let hasRequiredAnsiStyles
|
|
2056
|
-
function requireAnsiStyles() {
|
|
2057
|
-
if (hasRequiredAnsiStyles) {
|
|
2058
|
-
return ansiStyles.exports
|
|
2059
|
-
}
|
|
2060
|
-
hasRequiredAnsiStyles = 1
|
|
2061
|
-
;(function (module) {
|
|
2062
|
-
const wrapAnsi16 =
|
|
2063
|
-
(fn, offset) =>
|
|
2064
|
-
(...args) => {
|
|
2065
|
-
const code = fn(...args)
|
|
2066
|
-
return `\u001B[${code + offset}m`
|
|
2067
|
-
}
|
|
2068
|
-
const wrapAnsi256 =
|
|
2069
|
-
(fn, offset) =>
|
|
2070
|
-
(...args) => {
|
|
2071
|
-
const code = fn(...args)
|
|
2072
|
-
return `\u001B[${38 + offset};5;${code}m`
|
|
2073
|
-
}
|
|
2074
|
-
const wrapAnsi16m =
|
|
2075
|
-
(fn, offset) =>
|
|
2076
|
-
(...args) => {
|
|
2077
|
-
const rgb = fn(...args)
|
|
2078
|
-
return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`
|
|
2079
|
-
}
|
|
2080
|
-
const ansi2ansi = n => n
|
|
2081
|
-
const rgb2rgb = (r, g, b) => [r, g, b]
|
|
2082
|
-
const setLazyProperty = (object, property, get) => {
|
|
2083
|
-
Object.defineProperty(object, property, {
|
|
2084
|
-
get: () => {
|
|
2085
|
-
const value = get()
|
|
2086
|
-
Object.defineProperty(object, property, {
|
|
2087
|
-
value,
|
|
2088
|
-
enumerable: true,
|
|
2089
|
-
configurable: true
|
|
2090
|
-
})
|
|
2091
|
-
return value
|
|
2092
|
-
},
|
|
2093
|
-
enumerable: true,
|
|
2094
|
-
configurable: true
|
|
2095
|
-
})
|
|
2096
|
-
}
|
|
2097
|
-
|
|
2098
|
-
/** @type {typeof import('color-convert')} */
|
|
2099
|
-
let colorConvert
|
|
2100
|
-
const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
|
|
2101
|
-
if (colorConvert === undefined) {
|
|
2102
|
-
colorConvert = requireColorConvert()
|
|
2103
|
-
}
|
|
2104
|
-
const offset = isBackground ? 10 : 0
|
|
2105
|
-
const styles = {}
|
|
2106
|
-
for (const [sourceSpace, suite] of Object.entries(colorConvert)) {
|
|
2107
|
-
const name = sourceSpace === 'ansi16' ? 'ansi' : sourceSpace
|
|
2108
|
-
if (sourceSpace === targetSpace) {
|
|
2109
|
-
styles[name] = wrap(identity, offset)
|
|
2110
|
-
} else if (typeof suite === 'object') {
|
|
2111
|
-
styles[name] = wrap(suite[targetSpace], offset)
|
|
2112
|
-
}
|
|
2113
|
-
}
|
|
2114
|
-
return styles
|
|
2115
|
-
}
|
|
2116
|
-
function assembleStyles() {
|
|
2117
|
-
const codes = new Map()
|
|
2118
|
-
const styles = {
|
|
2119
|
-
modifier: {
|
|
2120
|
-
reset: [0, 0],
|
|
2121
|
-
// 21 isn't widely supported and 22 does the same thing
|
|
2122
|
-
bold: [1, 22],
|
|
2123
|
-
dim: [2, 22],
|
|
2124
|
-
italic: [3, 23],
|
|
2125
|
-
underline: [4, 24],
|
|
2126
|
-
inverse: [7, 27],
|
|
2127
|
-
hidden: [8, 28],
|
|
2128
|
-
strikethrough: [9, 29]
|
|
2129
|
-
},
|
|
2130
|
-
color: {
|
|
2131
|
-
black: [30, 39],
|
|
2132
|
-
red: [31, 39],
|
|
2133
|
-
green: [32, 39],
|
|
2134
|
-
yellow: [33, 39],
|
|
2135
|
-
blue: [34, 39],
|
|
2136
|
-
magenta: [35, 39],
|
|
2137
|
-
cyan: [36, 39],
|
|
2138
|
-
white: [37, 39],
|
|
2139
|
-
// Bright color
|
|
2140
|
-
blackBright: [90, 39],
|
|
2141
|
-
redBright: [91, 39],
|
|
2142
|
-
greenBright: [92, 39],
|
|
2143
|
-
yellowBright: [93, 39],
|
|
2144
|
-
blueBright: [94, 39],
|
|
2145
|
-
magentaBright: [95, 39],
|
|
2146
|
-
cyanBright: [96, 39],
|
|
2147
|
-
whiteBright: [97, 39]
|
|
2148
|
-
},
|
|
2149
|
-
bgColor: {
|
|
2150
|
-
bgBlack: [40, 49],
|
|
2151
|
-
bgRed: [41, 49],
|
|
2152
|
-
bgGreen: [42, 49],
|
|
2153
|
-
bgYellow: [43, 49],
|
|
2154
|
-
bgBlue: [44, 49],
|
|
2155
|
-
bgMagenta: [45, 49],
|
|
2156
|
-
bgCyan: [46, 49],
|
|
2157
|
-
bgWhite: [47, 49],
|
|
2158
|
-
// Bright color
|
|
2159
|
-
bgBlackBright: [100, 49],
|
|
2160
|
-
bgRedBright: [101, 49],
|
|
2161
|
-
bgGreenBright: [102, 49],
|
|
2162
|
-
bgYellowBright: [103, 49],
|
|
2163
|
-
bgBlueBright: [104, 49],
|
|
2164
|
-
bgMagentaBright: [105, 49],
|
|
2165
|
-
bgCyanBright: [106, 49],
|
|
2166
|
-
bgWhiteBright: [107, 49]
|
|
2167
|
-
}
|
|
2168
|
-
}
|
|
2169
|
-
|
|
2170
|
-
// Alias bright black as gray (and grey)
|
|
2171
|
-
styles.color.gray = styles.color.blackBright
|
|
2172
|
-
styles.bgColor.bgGray = styles.bgColor.bgBlackBright
|
|
2173
|
-
styles.color.grey = styles.color.blackBright
|
|
2174
|
-
styles.bgColor.bgGrey = styles.bgColor.bgBlackBright
|
|
2175
|
-
for (const [groupName, group] of Object.entries(styles)) {
|
|
2176
|
-
for (const [styleName, style] of Object.entries(group)) {
|
|
2177
|
-
styles[styleName] = {
|
|
2178
|
-
open: `\u001B[${style[0]}m`,
|
|
2179
|
-
close: `\u001B[${style[1]}m`
|
|
2180
|
-
}
|
|
2181
|
-
group[styleName] = styles[styleName]
|
|
2182
|
-
codes.set(style[0], style[1])
|
|
2183
|
-
}
|
|
2184
|
-
Object.defineProperty(styles, groupName, {
|
|
2185
|
-
value: group,
|
|
2186
|
-
enumerable: false
|
|
2187
|
-
})
|
|
2188
|
-
}
|
|
2189
|
-
Object.defineProperty(styles, 'codes', {
|
|
2190
|
-
value: codes,
|
|
2191
|
-
enumerable: false
|
|
2192
|
-
})
|
|
2193
|
-
styles.color.close = '\u001B[39m'
|
|
2194
|
-
styles.bgColor.close = '\u001B[49m'
|
|
2195
|
-
setLazyProperty(styles.color, 'ansi', () =>
|
|
2196
|
-
makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, false)
|
|
2197
|
-
)
|
|
2198
|
-
setLazyProperty(styles.color, 'ansi256', () =>
|
|
2199
|
-
makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, false)
|
|
2200
|
-
)
|
|
2201
|
-
setLazyProperty(styles.color, 'ansi16m', () =>
|
|
2202
|
-
makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, false)
|
|
2203
|
-
)
|
|
2204
|
-
setLazyProperty(styles.bgColor, 'ansi', () =>
|
|
2205
|
-
makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, true)
|
|
2206
|
-
)
|
|
2207
|
-
setLazyProperty(styles.bgColor, 'ansi256', () =>
|
|
2208
|
-
makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, true)
|
|
2209
|
-
)
|
|
2210
|
-
setLazyProperty(styles.bgColor, 'ansi16m', () =>
|
|
2211
|
-
makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, true)
|
|
2212
|
-
)
|
|
2213
|
-
return styles
|
|
2214
|
-
}
|
|
2215
|
-
|
|
2216
|
-
// Make the export immutable
|
|
2217
|
-
Object.defineProperty(module, 'exports', {
|
|
2218
|
-
enumerable: true,
|
|
2219
|
-
get: assembleStyles
|
|
2220
|
-
})
|
|
2221
|
-
})(ansiStyles)
|
|
2222
|
-
return ansiStyles.exports
|
|
2223
|
-
}
|
|
2224
|
-
|
|
2225
|
-
let wrapAnsi_1
|
|
2226
|
-
let hasRequiredWrapAnsi
|
|
2227
|
-
function requireWrapAnsi() {
|
|
2228
|
-
if (hasRequiredWrapAnsi) {
|
|
2229
|
-
return wrapAnsi_1
|
|
2230
|
-
}
|
|
2231
|
-
hasRequiredWrapAnsi = 1
|
|
2232
|
-
const stringWidth = requireStringWidth()
|
|
2233
|
-
const stripAnsi = requireStripAnsi()
|
|
2234
|
-
const ansiStyles = requireAnsiStyles()
|
|
2235
|
-
const ESCAPES = new Set(['\u001B', '\u009B'])
|
|
2236
|
-
const END_CODE = 39
|
|
2237
|
-
const wrapAnsi = code => `${ESCAPES.values().next().value}[${code}m`
|
|
2238
|
-
|
|
2239
|
-
// Calculate the length of words split on ' ', ignoring
|
|
2240
|
-
// the extra characters added by ansi escape codes
|
|
2241
|
-
const wordLengths = string =>
|
|
2242
|
-
string.split(' ').map(character => stringWidth(character))
|
|
2243
|
-
|
|
2244
|
-
// Wrap a long word across multiple rows
|
|
2245
|
-
// Ansi escape codes do not count towards length
|
|
2246
|
-
const wrapWord = (rows, word, columns) => {
|
|
2247
|
-
const characters = [...word]
|
|
2248
|
-
let isInsideEscape = false
|
|
2249
|
-
let visible = stringWidth(stripAnsi(rows[rows.length - 1]))
|
|
2250
|
-
for (const [index, character] of characters.entries()) {
|
|
2251
|
-
const characterLength = stringWidth(character)
|
|
2252
|
-
if (visible + characterLength <= columns) {
|
|
2253
|
-
rows[rows.length - 1] += character
|
|
2254
|
-
} else {
|
|
2255
|
-
rows.push(character)
|
|
2256
|
-
visible = 0
|
|
2257
|
-
}
|
|
2258
|
-
if (ESCAPES.has(character)) {
|
|
2259
|
-
isInsideEscape = true
|
|
2260
|
-
} else if (isInsideEscape && character === 'm') {
|
|
2261
|
-
isInsideEscape = false
|
|
2262
|
-
continue
|
|
2263
|
-
}
|
|
2264
|
-
if (isInsideEscape) {
|
|
2265
|
-
continue
|
|
2266
|
-
}
|
|
2267
|
-
visible += characterLength
|
|
2268
|
-
if (visible === columns && index < characters.length - 1) {
|
|
2269
|
-
rows.push('')
|
|
2270
|
-
visible = 0
|
|
2271
|
-
}
|
|
2272
|
-
}
|
|
2273
|
-
|
|
2274
|
-
// It's possible that the last row we copy over is only
|
|
2275
|
-
// ansi escape characters, handle this edge-case
|
|
2276
|
-
if (!visible && rows[rows.length - 1].length > 0 && rows.length > 1) {
|
|
2277
|
-
rows[rows.length - 2] += rows.pop()
|
|
2278
|
-
}
|
|
2279
|
-
}
|
|
2280
|
-
|
|
2281
|
-
// Trims spaces from a string ignoring invisible sequences
|
|
2282
|
-
const stringVisibleTrimSpacesRight = str => {
|
|
2283
|
-
const words = str.split(' ')
|
|
2284
|
-
let last = words.length
|
|
2285
|
-
while (last > 0) {
|
|
2286
|
-
if (stringWidth(words[last - 1]) > 0) {
|
|
2287
|
-
break
|
|
2288
|
-
}
|
|
2289
|
-
last--
|
|
2290
|
-
}
|
|
2291
|
-
if (last === words.length) {
|
|
2292
|
-
return str
|
|
2293
|
-
}
|
|
2294
|
-
return words.slice(0, last).join(' ') + words.slice(last).join('')
|
|
2295
|
-
}
|
|
2296
|
-
|
|
2297
|
-
// The wrap-ansi module can be invoked in either 'hard' or 'soft' wrap mode
|
|
2298
|
-
//
|
|
2299
|
-
// 'hard' will never allow a string to take up more than columns characters
|
|
2300
|
-
//
|
|
2301
|
-
// 'soft' allows long words to expand past the column length
|
|
2302
|
-
const exec = (string, columns, options = {}) => {
|
|
2303
|
-
if (options.trim !== false && string.trim() === '') {
|
|
2304
|
-
return ''
|
|
2305
|
-
}
|
|
2306
|
-
let pre = ''
|
|
2307
|
-
let ret = ''
|
|
2308
|
-
let escapeCode
|
|
2309
|
-
const lengths = wordLengths(string)
|
|
2310
|
-
let rows = ['']
|
|
2311
|
-
for (const [index, word] of string.split(' ').entries()) {
|
|
2312
|
-
if (options.trim !== false) {
|
|
2313
|
-
rows[rows.length - 1] = rows[rows.length - 1].trimLeft()
|
|
2314
|
-
}
|
|
2315
|
-
let rowLength = stringWidth(rows[rows.length - 1])
|
|
2316
|
-
if (index !== 0) {
|
|
2317
|
-
if (
|
|
2318
|
-
rowLength >= columns &&
|
|
2319
|
-
(options.wordWrap === false || options.trim === false)
|
|
2320
|
-
) {
|
|
2321
|
-
// If we start with a new word but the current row length equals the length of the columns, add a new row
|
|
2322
|
-
rows.push('')
|
|
2323
|
-
rowLength = 0
|
|
2324
|
-
}
|
|
2325
|
-
if (rowLength > 0 || options.trim === false) {
|
|
2326
|
-
rows[rows.length - 1] += ' '
|
|
2327
|
-
rowLength++
|
|
2328
|
-
}
|
|
2329
|
-
}
|
|
2330
|
-
|
|
2331
|
-
// In 'hard' wrap mode, the length of a line is never allowed to extend past 'columns'
|
|
2332
|
-
if (options.hard && lengths[index] > columns) {
|
|
2333
|
-
const remainingColumns = columns - rowLength
|
|
2334
|
-
const breaksStartingThisLine =
|
|
2335
|
-
1 + Math.floor((lengths[index] - remainingColumns - 1) / columns)
|
|
2336
|
-
const breaksStartingNextLine = Math.floor(
|
|
2337
|
-
(lengths[index] - 1) / columns
|
|
2338
|
-
)
|
|
2339
|
-
if (breaksStartingNextLine < breaksStartingThisLine) {
|
|
2340
|
-
rows.push('')
|
|
2341
|
-
}
|
|
2342
|
-
wrapWord(rows, word, columns)
|
|
2343
|
-
continue
|
|
2344
|
-
}
|
|
2345
|
-
if (
|
|
2346
|
-
rowLength + lengths[index] > columns &&
|
|
2347
|
-
rowLength > 0 &&
|
|
2348
|
-
lengths[index] > 0
|
|
2349
|
-
) {
|
|
2350
|
-
if (options.wordWrap === false && rowLength < columns) {
|
|
2351
|
-
wrapWord(rows, word, columns)
|
|
2352
|
-
continue
|
|
2353
|
-
}
|
|
2354
|
-
rows.push('')
|
|
2355
|
-
}
|
|
2356
|
-
if (rowLength + lengths[index] > columns && options.wordWrap === false) {
|
|
2357
|
-
wrapWord(rows, word, columns)
|
|
2358
|
-
continue
|
|
2359
|
-
}
|
|
2360
|
-
rows[rows.length - 1] += word
|
|
2361
|
-
}
|
|
2362
|
-
if (options.trim !== false) {
|
|
2363
|
-
rows = rows.map(stringVisibleTrimSpacesRight)
|
|
2364
|
-
}
|
|
2365
|
-
pre = rows.join('\n')
|
|
2366
|
-
for (const [index, character] of [...pre].entries()) {
|
|
2367
|
-
ret += character
|
|
2368
|
-
if (ESCAPES.has(character)) {
|
|
2369
|
-
const code = parseFloat(/\d[^m]*/.exec(pre.slice(index, index + 4)))
|
|
2370
|
-
escapeCode = code === END_CODE ? null : code
|
|
2371
|
-
}
|
|
2372
|
-
const code = ansiStyles.codes.get(Number(escapeCode))
|
|
2373
|
-
if (escapeCode && code) {
|
|
2374
|
-
if (pre[index + 1] === '\n') {
|
|
2375
|
-
ret += wrapAnsi(code)
|
|
2376
|
-
} else if (character === '\n') {
|
|
2377
|
-
ret += wrapAnsi(escapeCode)
|
|
2378
|
-
}
|
|
2379
|
-
}
|
|
2380
|
-
}
|
|
2381
|
-
return ret
|
|
2382
|
-
}
|
|
2383
|
-
|
|
2384
|
-
// For each newline, invoke the method separately
|
|
2385
|
-
wrapAnsi_1 = (string, columns, options) => {
|
|
2386
|
-
return String(string)
|
|
2387
|
-
.normalize()
|
|
2388
|
-
.replace(/\r\n/g, '\n')
|
|
2389
|
-
.split('\n')
|
|
2390
|
-
.map(line => exec(line, columns, options))
|
|
2391
|
-
.join('\n')
|
|
2392
|
-
}
|
|
2393
|
-
return wrapAnsi_1
|
|
2394
|
-
}
|
|
2395
|
-
|
|
2396
|
-
const wrapAnsiExports = requireWrapAnsi()
|
|
2397
|
-
|
|
2398
|
-
/**
|
|
2399
|
-
* Force line returns at specific width. This function is ANSI code friendly and it'll
|
|
2400
|
-
* ignore invisible codes during width calculation.
|
|
2401
|
-
* @param {string} content
|
|
2402
|
-
* @param {number} width
|
|
2403
|
-
* @return {string}
|
|
2404
|
-
*/
|
|
2405
|
-
function breakLines(content, width) {
|
|
2406
|
-
return content
|
|
2407
|
-
.split('\n')
|
|
2408
|
-
.flatMap(line =>
|
|
2409
|
-
wrapAnsiExports(line, width, {
|
|
2410
|
-
trim: false,
|
|
2411
|
-
hard: true
|
|
2412
|
-
})
|
|
2413
|
-
.split('\n')
|
|
2414
|
-
.map(str => str.trimEnd())
|
|
2415
|
-
)
|
|
2416
|
-
.join('\n')
|
|
2417
|
-
}
|
|
2418
|
-
/**
|
|
2419
|
-
* Returns the width of the active readline, or 80 as default value.
|
|
2420
|
-
* @returns {number}
|
|
2421
|
-
*/
|
|
2422
|
-
function readlineWidth() {
|
|
2423
|
-
return cliWidthExports({
|
|
2424
|
-
defaultWidth: 80,
|
|
2425
|
-
output: readline().output
|
|
2426
|
-
})
|
|
2427
|
-
}
|
|
2428
|
-
|
|
2429
|
-
function usePointerPosition({ active, renderedItems, pageSize, loop }) {
|
|
2430
|
-
const state = useRef({
|
|
2431
|
-
lastPointer: active,
|
|
2432
|
-
lastActive: undefined
|
|
2433
|
-
})
|
|
2434
|
-
const { lastPointer, lastActive } = state.current
|
|
2435
|
-
const middle = Math.floor(pageSize / 2)
|
|
2436
|
-
const renderedLength = renderedItems.reduce(
|
|
2437
|
-
(acc, item) => acc + item.length,
|
|
2438
|
-
0
|
|
2439
|
-
)
|
|
2440
|
-
const defaultPointerPosition = renderedItems
|
|
2441
|
-
.slice(0, active)
|
|
2442
|
-
.reduce((acc, item) => acc + item.length, 0)
|
|
2443
|
-
let pointer = defaultPointerPosition
|
|
2444
|
-
if (renderedLength > pageSize) {
|
|
2445
|
-
if (loop) {
|
|
2446
|
-
/**
|
|
2447
|
-
* Creates the next position for the pointer considering an infinitely
|
|
2448
|
-
* looping list of items to be rendered on the page.
|
|
2449
|
-
*
|
|
2450
|
-
* The goal is to progressively move the cursor to the middle position as the user move down, and then keep
|
|
2451
|
-
* the cursor there. When the user move up, maintain the cursor position.
|
|
2452
|
-
*/
|
|
2453
|
-
// By default, keep the cursor position as-is.
|
|
2454
|
-
pointer = lastPointer
|
|
2455
|
-
if (
|
|
2456
|
-
// First render, skip this logic.
|
|
2457
|
-
lastActive != null &&
|
|
2458
|
-
// Only move the pointer down when the user moves down.
|
|
2459
|
-
lastActive < active &&
|
|
2460
|
-
// Check user didn't move up across page boundary.
|
|
2461
|
-
active - lastActive < pageSize
|
|
2462
|
-
) {
|
|
2463
|
-
pointer = Math.min(
|
|
2464
|
-
// Furthest allowed position for the pointer is the middle of the list
|
|
2465
|
-
middle,
|
|
2466
|
-
Math.abs(active - lastActive) === 1
|
|
2467
|
-
? Math.min(
|
|
2468
|
-
// Move the pointer at most the height of the last active item.
|
|
2469
|
-
lastPointer + (renderedItems[lastActive]?.length ?? 0),
|
|
2470
|
-
// If the user moved by one item, move the pointer to the natural position of the active item as
|
|
2471
|
-
// long as it doesn't move the cursor up.
|
|
2472
|
-
Math.max(defaultPointerPosition, lastPointer)
|
|
2473
|
-
)
|
|
2474
|
-
: // Otherwise, move the pointer down by the difference between the active and last active item.
|
|
2475
|
-
lastPointer + active - lastActive
|
|
2476
|
-
)
|
|
2477
|
-
}
|
|
2478
|
-
} else {
|
|
2479
|
-
/**
|
|
2480
|
-
* Creates the next position for the pointer considering a finite list of
|
|
2481
|
-
* items to be rendered on a page.
|
|
2482
|
-
*
|
|
2483
|
-
* The goal is to keep the pointer in the middle of the page whenever possible, until
|
|
2484
|
-
* we reach the bounds of the list (top or bottom). In which case, the cursor moves progressively
|
|
2485
|
-
* to the bottom or top of the list.
|
|
2486
|
-
*/
|
|
2487
|
-
const spaceUnderActive = renderedItems
|
|
2488
|
-
.slice(active)
|
|
2489
|
-
.reduce((acc, item) => acc + item.length, 0)
|
|
2490
|
-
pointer =
|
|
2491
|
-
spaceUnderActive < pageSize - middle
|
|
2492
|
-
? // If the active item is near the end of the list, progressively move the cursor towards the end.
|
|
2493
|
-
pageSize - spaceUnderActive
|
|
2494
|
-
: // Otherwise, progressively move the pointer to the middle of the list.
|
|
2495
|
-
Math.min(defaultPointerPosition, middle)
|
|
2496
|
-
}
|
|
2497
|
-
}
|
|
2498
|
-
// Save state for the next render
|
|
2499
|
-
state.current.lastPointer = pointer
|
|
2500
|
-
state.current.lastActive = active
|
|
2501
|
-
return pointer
|
|
2502
|
-
}
|
|
2503
|
-
function usePagination({ items, active, renderItem, pageSize, loop = true }) {
|
|
2504
|
-
const width = readlineWidth()
|
|
2505
|
-
const bound = num => ((num % items.length) + items.length) % items.length
|
|
2506
|
-
const renderedItems = items.map((item, index) => {
|
|
2507
|
-
if (item == null) {
|
|
2508
|
-
return []
|
|
2509
|
-
}
|
|
2510
|
-
return breakLines(
|
|
2511
|
-
renderItem({
|
|
2512
|
-
item,
|
|
2513
|
-
index,
|
|
2514
|
-
isActive: index === active
|
|
2515
|
-
}),
|
|
2516
|
-
width
|
|
2517
|
-
).split('\n')
|
|
2518
|
-
})
|
|
2519
|
-
const renderedLength = renderedItems.reduce(
|
|
2520
|
-
(acc, item) => acc + item.length,
|
|
2521
|
-
0
|
|
2522
|
-
)
|
|
2523
|
-
const renderItemAtIndex = index => renderedItems[index] ?? []
|
|
2524
|
-
const pointer = usePointerPosition({
|
|
2525
|
-
active,
|
|
2526
|
-
renderedItems,
|
|
2527
|
-
pageSize,
|
|
2528
|
-
loop
|
|
2529
|
-
})
|
|
2530
|
-
// Render the active item to decide the position.
|
|
2531
|
-
// If the active item fits under the pointer, we render it there.
|
|
2532
|
-
// Otherwise, we need to render it to fit at the bottom of the page; moving the pointer up.
|
|
2533
|
-
const activeItem = renderItemAtIndex(active).slice(0, pageSize)
|
|
2534
|
-
const activeItemPosition =
|
|
2535
|
-
pointer + activeItem.length <= pageSize
|
|
2536
|
-
? pointer
|
|
2537
|
-
: pageSize - activeItem.length
|
|
2538
|
-
// Create an array of lines for the page, and add the lines of the active item into the page
|
|
2539
|
-
const pageBuffer = Array.from({
|
|
2540
|
-
length: pageSize
|
|
2541
|
-
})
|
|
2542
|
-
pageBuffer.splice(activeItemPosition, activeItem.length, ...activeItem)
|
|
2543
|
-
// Store to prevent rendering the same item twice
|
|
2544
|
-
const itemVisited = new Set([active])
|
|
2545
|
-
// Fill the page under the active item
|
|
2546
|
-
let bufferPointer = activeItemPosition + activeItem.length
|
|
2547
|
-
let itemPointer = bound(active + 1)
|
|
2548
|
-
while (
|
|
2549
|
-
bufferPointer < pageSize &&
|
|
2550
|
-
!itemVisited.has(itemPointer) &&
|
|
2551
|
-
(loop && renderedLength > pageSize
|
|
2552
|
-
? itemPointer !== active
|
|
2553
|
-
: itemPointer > active)
|
|
2554
|
-
) {
|
|
2555
|
-
const lines = renderItemAtIndex(itemPointer)
|
|
2556
|
-
const linesToAdd = lines.slice(0, pageSize - bufferPointer)
|
|
2557
|
-
pageBuffer.splice(bufferPointer, linesToAdd.length, ...linesToAdd)
|
|
2558
|
-
// Move pointers for next iteration
|
|
2559
|
-
itemVisited.add(itemPointer)
|
|
2560
|
-
bufferPointer += linesToAdd.length
|
|
2561
|
-
itemPointer = bound(itemPointer + 1)
|
|
2562
|
-
}
|
|
2563
|
-
// Fill the page over the active item
|
|
2564
|
-
bufferPointer = activeItemPosition - 1
|
|
2565
|
-
itemPointer = bound(active - 1)
|
|
2566
|
-
while (
|
|
2567
|
-
bufferPointer >= 0 &&
|
|
2568
|
-
!itemVisited.has(itemPointer) &&
|
|
2569
|
-
(loop && renderedLength > pageSize
|
|
2570
|
-
? itemPointer !== active
|
|
2571
|
-
: itemPointer < active)
|
|
2572
|
-
) {
|
|
2573
|
-
const lines = renderItemAtIndex(itemPointer)
|
|
2574
|
-
const linesToAdd = lines.slice(
|
|
2575
|
-
Math.max(0, lines.length - bufferPointer - 1)
|
|
2576
|
-
)
|
|
2577
|
-
pageBuffer.splice(
|
|
2578
|
-
bufferPointer - linesToAdd.length + 1,
|
|
2579
|
-
linesToAdd.length,
|
|
2580
|
-
...linesToAdd
|
|
2581
|
-
)
|
|
2582
|
-
// Move pointers for next iteration
|
|
2583
|
-
itemVisited.add(itemPointer)
|
|
2584
|
-
bufferPointer -= linesToAdd.length
|
|
2585
|
-
itemPointer = bound(itemPointer - 1)
|
|
2586
|
-
}
|
|
2587
|
-
return pageBuffer.filter(line => typeof line === 'string').join('\n')
|
|
2588
|
-
}
|
|
2589
|
-
|
|
2590
|
-
let lib
|
|
2591
|
-
let hasRequiredLib
|
|
2592
|
-
function requireLib() {
|
|
2593
|
-
if (hasRequiredLib) {
|
|
2594
|
-
return lib
|
|
2595
|
-
}
|
|
2596
|
-
hasRequiredLib = 1
|
|
2597
|
-
const Stream = require$$0$2
|
|
2598
|
-
class MuteStream extends Stream {
|
|
2599
|
-
#isTTY = null
|
|
2600
|
-
constructor(opts = {}) {
|
|
2601
|
-
super(opts)
|
|
2602
|
-
this.writable = this.readable = true
|
|
2603
|
-
this.muted = false
|
|
2604
|
-
this.on('pipe', this._onpipe)
|
|
2605
|
-
this.replace = opts.replace
|
|
2606
|
-
|
|
2607
|
-
// For readline-type situations
|
|
2608
|
-
// This much at the start of a line being redrawn after a ctrl char
|
|
2609
|
-
// is seen (such as backspace) won't be redrawn as the replacement
|
|
2610
|
-
this._prompt = opts.prompt || null
|
|
2611
|
-
this._hadControl = false
|
|
2612
|
-
}
|
|
2613
|
-
#destSrc(key, def) {
|
|
2614
|
-
if (this._dest) {
|
|
2615
|
-
return this._dest[key]
|
|
2616
|
-
}
|
|
2617
|
-
if (this._src) {
|
|
2618
|
-
return this._src[key]
|
|
2619
|
-
}
|
|
2620
|
-
return def
|
|
2621
|
-
}
|
|
2622
|
-
#proxy(method, ...args) {
|
|
2623
|
-
if (typeof this._dest?.[method] === 'function') {
|
|
2624
|
-
this._dest[method](...args)
|
|
2625
|
-
}
|
|
2626
|
-
if (typeof this._src?.[method] === 'function') {
|
|
2627
|
-
this._src[method](...args)
|
|
2628
|
-
}
|
|
2629
|
-
}
|
|
2630
|
-
get isTTY() {
|
|
2631
|
-
if (this.#isTTY !== null) {
|
|
2632
|
-
return this.#isTTY
|
|
2633
|
-
}
|
|
2634
|
-
return this.#destSrc('isTTY', false)
|
|
2635
|
-
}
|
|
2636
|
-
|
|
2637
|
-
// basically just get replace the getter/setter with a regular value
|
|
2638
|
-
set isTTY(val) {
|
|
2639
|
-
this.#isTTY = val
|
|
2640
|
-
}
|
|
2641
|
-
get rows() {
|
|
2642
|
-
return this.#destSrc('rows')
|
|
2643
|
-
}
|
|
2644
|
-
get columns() {
|
|
2645
|
-
return this.#destSrc('columns')
|
|
2646
|
-
}
|
|
2647
|
-
mute() {
|
|
2648
|
-
this.muted = true
|
|
2649
|
-
}
|
|
2650
|
-
unmute() {
|
|
2651
|
-
this.muted = false
|
|
2652
|
-
}
|
|
2653
|
-
_onpipe(src) {
|
|
2654
|
-
this._src = src
|
|
2655
|
-
}
|
|
2656
|
-
pipe(dest, options) {
|
|
2657
|
-
this._dest = dest
|
|
2658
|
-
return super.pipe(dest, options)
|
|
2659
|
-
}
|
|
2660
|
-
pause() {
|
|
2661
|
-
if (this._src) {
|
|
2662
|
-
return this._src.pause()
|
|
2663
|
-
}
|
|
2664
|
-
}
|
|
2665
|
-
resume() {
|
|
2666
|
-
if (this._src) {
|
|
2667
|
-
return this._src.resume()
|
|
2668
|
-
}
|
|
2669
|
-
}
|
|
2670
|
-
write(c) {
|
|
2671
|
-
if (this.muted) {
|
|
2672
|
-
if (!this.replace) {
|
|
2673
|
-
return true
|
|
2674
|
-
}
|
|
2675
|
-
// eslint-disable-next-line no-control-regex
|
|
2676
|
-
if (c.match(/^\u001b/)) {
|
|
2677
|
-
if (c.indexOf(this._prompt) === 0) {
|
|
2678
|
-
c = c.slice(this._prompt.length)
|
|
2679
|
-
c = c.replace(/./g, this.replace)
|
|
2680
|
-
c = this._prompt + c
|
|
2681
|
-
}
|
|
2682
|
-
this._hadControl = true
|
|
2683
|
-
return this.emit('data', c)
|
|
2684
|
-
} else {
|
|
2685
|
-
if (
|
|
2686
|
-
this._prompt &&
|
|
2687
|
-
this._hadControl &&
|
|
2688
|
-
c.indexOf(this._prompt) === 0
|
|
2689
|
-
) {
|
|
2690
|
-
this._hadControl = false
|
|
2691
|
-
this.emit('data', this._prompt)
|
|
2692
|
-
c = c.slice(this._prompt.length)
|
|
2693
|
-
}
|
|
2694
|
-
c = c.toString().replace(/./g, this.replace)
|
|
2695
|
-
}
|
|
2696
|
-
}
|
|
2697
|
-
this.emit('data', c)
|
|
2698
|
-
}
|
|
2699
|
-
end(c) {
|
|
2700
|
-
if (this.muted) {
|
|
2701
|
-
if (c && this.replace) {
|
|
2702
|
-
c = c.toString().replace(/./g, this.replace)
|
|
2703
|
-
} else {
|
|
2704
|
-
c = null
|
|
2705
|
-
}
|
|
2706
|
-
}
|
|
2707
|
-
if (c) {
|
|
2708
|
-
this.emit('data', c)
|
|
2709
|
-
}
|
|
2710
|
-
this.emit('end')
|
|
2711
|
-
}
|
|
2712
|
-
destroy(...args) {
|
|
2713
|
-
return this.#proxy('destroy', ...args)
|
|
2714
|
-
}
|
|
2715
|
-
destroySoon(...args) {
|
|
2716
|
-
return this.#proxy('destroySoon', ...args)
|
|
2717
|
-
}
|
|
2718
|
-
close(...args) {
|
|
2719
|
-
return this.#proxy('close', ...args)
|
|
2720
|
-
}
|
|
2721
|
-
}
|
|
2722
|
-
lib = MuteStream
|
|
2723
|
-
return lib
|
|
2724
|
-
}
|
|
2725
|
-
|
|
2726
|
-
const libExports = requireLib()
|
|
2727
|
-
|
|
2728
|
-
/**
|
|
2729
|
-
* This is not the set of all possible signals.
|
|
2730
|
-
*
|
|
2731
|
-
* It IS, however, the set of all signals that trigger
|
|
2732
|
-
* an exit on either Linux or BSD systems. Linux is a
|
|
2733
|
-
* superset of the signal names supported on BSD, and
|
|
2734
|
-
* the unknown signals just fail to register, so we can
|
|
2735
|
-
* catch that easily enough.
|
|
2736
|
-
*
|
|
2737
|
-
* Windows signals are a different set, since there are
|
|
2738
|
-
* signals that terminate Windows processes, but don't
|
|
2739
|
-
* terminate (or don't even exist) on Posix systems.
|
|
2740
|
-
*
|
|
2741
|
-
* Don't bother with SIGKILL. It's uncatchable, which
|
|
2742
|
-
* means that we can't fire any callbacks anyway.
|
|
2743
|
-
*
|
|
2744
|
-
* If a user does happen to register a handler on a non-
|
|
2745
|
-
* fatal signal like SIGWINCH or something, and then
|
|
2746
|
-
* exit, it'll end up firing `process.emit('exit')`, so
|
|
2747
|
-
* the handler will be fired anyway.
|
|
2748
|
-
*
|
|
2749
|
-
* SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised
|
|
2750
|
-
* artificially, inherently leave the process in a
|
|
2751
|
-
* state from which it is not safe to try and enter JS
|
|
2752
|
-
* listeners.
|
|
2753
|
-
*/
|
|
2754
|
-
const signals = []
|
|
2755
|
-
signals.push('SIGHUP', 'SIGINT', 'SIGTERM')
|
|
2756
|
-
if (process.platform !== 'win32') {
|
|
2757
|
-
signals.push(
|
|
2758
|
-
'SIGALRM',
|
|
2759
|
-
'SIGABRT',
|
|
2760
|
-
'SIGVTALRM',
|
|
2761
|
-
'SIGXCPU',
|
|
2762
|
-
'SIGXFSZ',
|
|
2763
|
-
'SIGUSR2',
|
|
2764
|
-
'SIGTRAP',
|
|
2765
|
-
'SIGSYS',
|
|
2766
|
-
'SIGQUIT',
|
|
2767
|
-
'SIGIOT'
|
|
2768
|
-
// should detect profiler and enable/disable accordingly.
|
|
2769
|
-
// see #21
|
|
2770
|
-
// 'SIGPROF'
|
|
2771
|
-
)
|
|
2772
|
-
}
|
|
2773
|
-
if (process.platform === 'linux') {
|
|
2774
|
-
signals.push('SIGIO', 'SIGPOLL', 'SIGPWR', 'SIGSTKFLT')
|
|
2775
|
-
}
|
|
2776
|
-
|
|
2777
|
-
// Note: since nyc uses this module to output coverage, any lines
|
|
2778
|
-
// that are in the direct sync flow of nyc's outputCoverage are
|
|
2779
|
-
// ignored, since we can never get coverage for them.
|
|
2780
|
-
// grab a reference to node's real process object right away
|
|
2781
|
-
const processOk = process =>
|
|
2782
|
-
!!process &&
|
|
2783
|
-
typeof process === 'object' &&
|
|
2784
|
-
typeof process.removeListener === 'function' &&
|
|
2785
|
-
typeof process.emit === 'function' &&
|
|
2786
|
-
typeof process.reallyExit === 'function' &&
|
|
2787
|
-
typeof process.listeners === 'function' &&
|
|
2788
|
-
typeof process.kill === 'function' &&
|
|
2789
|
-
typeof process.pid === 'number' &&
|
|
2790
|
-
typeof process.on === 'function'
|
|
2791
|
-
const kExitEmitter = Symbol.for('signal-exit emitter')
|
|
2792
|
-
const global = globalThis
|
|
2793
|
-
const ObjectDefineProperty = Object.defineProperty.bind(Object)
|
|
2794
|
-
// teeny special purpose ee
|
|
2795
|
-
class Emitter {
|
|
2796
|
-
emitted = {
|
|
2797
|
-
afterExit: false,
|
|
2798
|
-
exit: false
|
|
2799
|
-
}
|
|
2800
|
-
listeners = {
|
|
2801
|
-
afterExit: [],
|
|
2802
|
-
exit: []
|
|
2803
|
-
}
|
|
2804
|
-
count = 0
|
|
2805
|
-
id = Math.random()
|
|
2806
|
-
constructor() {
|
|
2807
|
-
if (global[kExitEmitter]) {
|
|
2808
|
-
return global[kExitEmitter]
|
|
2809
|
-
}
|
|
2810
|
-
ObjectDefineProperty(global, kExitEmitter, {
|
|
2811
|
-
value: this,
|
|
2812
|
-
writable: false,
|
|
2813
|
-
enumerable: false,
|
|
2814
|
-
configurable: false
|
|
2815
|
-
})
|
|
2816
|
-
}
|
|
2817
|
-
on(ev, fn) {
|
|
2818
|
-
this.listeners[ev].push(fn)
|
|
2819
|
-
}
|
|
2820
|
-
removeListener(ev, fn) {
|
|
2821
|
-
const list = this.listeners[ev]
|
|
2822
|
-
const i = list.indexOf(fn)
|
|
2823
|
-
/* c8 ignore start */
|
|
2824
|
-
if (i === -1) {
|
|
2825
|
-
return
|
|
2826
|
-
}
|
|
2827
|
-
/* c8 ignore stop */
|
|
2828
|
-
if (i === 0 && list.length === 1) {
|
|
2829
|
-
list.length = 0
|
|
2830
|
-
} else {
|
|
2831
|
-
list.splice(i, 1)
|
|
2832
|
-
}
|
|
2833
|
-
}
|
|
2834
|
-
emit(ev, code, signal) {
|
|
2835
|
-
if (this.emitted[ev]) {
|
|
2836
|
-
return false
|
|
2837
|
-
}
|
|
2838
|
-
this.emitted[ev] = true
|
|
2839
|
-
let ret = false
|
|
2840
|
-
for (const fn of this.listeners[ev]) {
|
|
2841
|
-
ret = fn(code, signal) === true || ret
|
|
2842
|
-
}
|
|
2843
|
-
if (ev === 'exit') {
|
|
2844
|
-
ret = this.emit('afterExit', code, signal) || ret
|
|
2845
|
-
}
|
|
2846
|
-
return ret
|
|
2847
|
-
}
|
|
2848
|
-
}
|
|
2849
|
-
class SignalExitBase {}
|
|
2850
|
-
const signalExitWrap = handler => {
|
|
2851
|
-
return {
|
|
2852
|
-
onExit(cb, opts) {
|
|
2853
|
-
return handler.onExit(cb, opts)
|
|
2854
|
-
},
|
|
2855
|
-
load() {
|
|
2856
|
-
return handler.load()
|
|
2857
|
-
},
|
|
2858
|
-
unload() {
|
|
2859
|
-
return handler.unload()
|
|
2860
|
-
}
|
|
2861
|
-
}
|
|
2862
|
-
}
|
|
2863
|
-
class SignalExitFallback extends SignalExitBase {
|
|
2864
|
-
onExit() {
|
|
2865
|
-
return () => {}
|
|
2866
|
-
}
|
|
2867
|
-
load() {}
|
|
2868
|
-
unload() {}
|
|
2869
|
-
}
|
|
2870
|
-
class SignalExit extends SignalExitBase {
|
|
2871
|
-
// "SIGHUP" throws an `ENOSYS` error on Windows,
|
|
2872
|
-
// so use a supported signal instead
|
|
2873
|
-
/* c8 ignore start */
|
|
2874
|
-
#hupSig = process$1.platform === 'win32' ? 'SIGINT' : 'SIGHUP'
|
|
2875
|
-
/* c8 ignore stop */
|
|
2876
|
-
#emitter = new Emitter()
|
|
2877
|
-
#process
|
|
2878
|
-
#originalProcessEmit
|
|
2879
|
-
#originalProcessReallyExit
|
|
2880
|
-
#sigListeners = {}
|
|
2881
|
-
#loaded = false
|
|
2882
|
-
constructor(process) {
|
|
2883
|
-
super()
|
|
2884
|
-
this.#process = process
|
|
2885
|
-
// { <signal>: <listener fn>, ... }
|
|
2886
|
-
this.#sigListeners = {}
|
|
2887
|
-
for (const sig of signals) {
|
|
2888
|
-
this.#sigListeners[sig] = () => {
|
|
2889
|
-
// If there are no other listeners, an exit is coming!
|
|
2890
|
-
// Simplest way: remove us and then re-send the signal.
|
|
2891
|
-
// We know that this will kill the process, so we can
|
|
2892
|
-
// safely emit now.
|
|
2893
|
-
const listeners = this.#process.listeners(sig)
|
|
2894
|
-
let { count } = this.#emitter
|
|
2895
|
-
// This is a workaround for the fact that signal-exit v3 and signal
|
|
2896
|
-
// exit v4 are not aware of each other, and each will attempt to let
|
|
2897
|
-
// the other handle it, so neither of them do. To correct this, we
|
|
2898
|
-
// detect if we're the only handler *except* for previous versions
|
|
2899
|
-
// of signal-exit, and increment by the count of listeners it has
|
|
2900
|
-
// created.
|
|
2901
|
-
/* c8 ignore start */
|
|
2902
|
-
const p = process
|
|
2903
|
-
if (
|
|
2904
|
-
typeof p.__signal_exit_emitter__ === 'object' &&
|
|
2905
|
-
typeof p.__signal_exit_emitter__.count === 'number'
|
|
2906
|
-
) {
|
|
2907
|
-
count += p.__signal_exit_emitter__.count
|
|
2908
|
-
}
|
|
2909
|
-
/* c8 ignore stop */
|
|
2910
|
-
if (listeners.length === count) {
|
|
2911
|
-
this.unload()
|
|
2912
|
-
const ret = this.#emitter.emit('exit', null, sig)
|
|
2913
|
-
/* c8 ignore start */
|
|
2914
|
-
const s = sig === 'SIGHUP' ? this.#hupSig : sig
|
|
2915
|
-
if (!ret) {
|
|
2916
|
-
process.kill(process.pid, s)
|
|
2917
|
-
}
|
|
2918
|
-
/* c8 ignore stop */
|
|
2919
|
-
}
|
|
2920
|
-
}
|
|
2921
|
-
}
|
|
2922
|
-
this.#originalProcessReallyExit = process.reallyExit
|
|
2923
|
-
this.#originalProcessEmit = process.emit
|
|
2924
|
-
}
|
|
2925
|
-
onExit(cb, opts) {
|
|
2926
|
-
/* c8 ignore start */
|
|
2927
|
-
if (!processOk(this.#process)) {
|
|
2928
|
-
return () => {}
|
|
2929
|
-
}
|
|
2930
|
-
/* c8 ignore stop */
|
|
2931
|
-
if (this.#loaded === false) {
|
|
2932
|
-
this.load()
|
|
2933
|
-
}
|
|
2934
|
-
const ev = opts?.alwaysLast ? 'afterExit' : 'exit'
|
|
2935
|
-
this.#emitter.on(ev, cb)
|
|
2936
|
-
return () => {
|
|
2937
|
-
this.#emitter.removeListener(ev, cb)
|
|
2938
|
-
if (
|
|
2939
|
-
this.#emitter.listeners['exit'].length === 0 &&
|
|
2940
|
-
this.#emitter.listeners['afterExit'].length === 0
|
|
2941
|
-
) {
|
|
2942
|
-
this.unload()
|
|
2943
|
-
}
|
|
2944
|
-
}
|
|
2945
|
-
}
|
|
2946
|
-
load() {
|
|
2947
|
-
if (this.#loaded) {
|
|
2948
|
-
return
|
|
2949
|
-
}
|
|
2950
|
-
this.#loaded = true
|
|
2951
|
-
// This is the number of onSignalExit's that are in play.
|
|
2952
|
-
// It's important so that we can count the correct number of
|
|
2953
|
-
// listeners on signals, and don't wait for the other one to
|
|
2954
|
-
// handle it instead of us.
|
|
2955
|
-
this.#emitter.count += 1
|
|
2956
|
-
for (const sig of signals) {
|
|
2957
|
-
try {
|
|
2958
|
-
const fn = this.#sigListeners[sig]
|
|
2959
|
-
if (fn) {
|
|
2960
|
-
this.#process.on(sig, fn)
|
|
2961
|
-
}
|
|
2962
|
-
} catch (_) {}
|
|
2963
|
-
}
|
|
2964
|
-
this.#process.emit = (ev, ...a) => {
|
|
2965
|
-
return this.#processEmit(ev, ...a)
|
|
2966
|
-
}
|
|
2967
|
-
this.#process.reallyExit = code => {
|
|
2968
|
-
return this.#processReallyExit(code)
|
|
2969
|
-
}
|
|
2970
|
-
}
|
|
2971
|
-
unload() {
|
|
2972
|
-
if (!this.#loaded) {
|
|
2973
|
-
return
|
|
2974
|
-
}
|
|
2975
|
-
this.#loaded = false
|
|
2976
|
-
signals.forEach(sig => {
|
|
2977
|
-
const listener = this.#sigListeners[sig]
|
|
2978
|
-
/* c8 ignore start */
|
|
2979
|
-
if (!listener) {
|
|
2980
|
-
throw new Error('Listener not defined for signal: ' + sig)
|
|
2981
|
-
}
|
|
2982
|
-
/* c8 ignore stop */
|
|
2983
|
-
try {
|
|
2984
|
-
this.#process.removeListener(sig, listener)
|
|
2985
|
-
/* c8 ignore start */
|
|
2986
|
-
} catch (_) {}
|
|
2987
|
-
/* c8 ignore stop */
|
|
2988
|
-
})
|
|
2989
|
-
this.#process.emit = this.#originalProcessEmit
|
|
2990
|
-
this.#process.reallyExit = this.#originalProcessReallyExit
|
|
2991
|
-
this.#emitter.count -= 1
|
|
2992
|
-
}
|
|
2993
|
-
#processReallyExit(code) {
|
|
2994
|
-
/* c8 ignore start */
|
|
2995
|
-
if (!processOk(this.#process)) {
|
|
2996
|
-
return 0
|
|
2997
|
-
}
|
|
2998
|
-
this.#process.exitCode = code || 0
|
|
2999
|
-
/* c8 ignore stop */
|
|
3000
|
-
this.#emitter.emit('exit', this.#process.exitCode, null)
|
|
3001
|
-
return this.#originalProcessReallyExit.call(
|
|
3002
|
-
this.#process,
|
|
3003
|
-
this.#process.exitCode
|
|
3004
|
-
)
|
|
3005
|
-
}
|
|
3006
|
-
#processEmit(ev, ...args) {
|
|
3007
|
-
const og = this.#originalProcessEmit
|
|
3008
|
-
if (ev === 'exit' && processOk(this.#process)) {
|
|
3009
|
-
if (typeof args[0] === 'number') {
|
|
3010
|
-
this.#process.exitCode = args[0]
|
|
3011
|
-
/* c8 ignore start */
|
|
3012
|
-
}
|
|
3013
|
-
/* c8 ignore start */
|
|
3014
|
-
const ret = og.call(this.#process, ev, ...args)
|
|
3015
|
-
/* c8 ignore start */
|
|
3016
|
-
this.#emitter.emit('exit', this.#process.exitCode, null)
|
|
3017
|
-
/* c8 ignore stop */
|
|
3018
|
-
return ret
|
|
3019
|
-
} else {
|
|
3020
|
-
return og.call(this.#process, ev, ...args)
|
|
3021
|
-
}
|
|
3022
|
-
}
|
|
3023
|
-
}
|
|
3024
|
-
const process$1 = globalThis.process
|
|
3025
|
-
// wrap so that we call the method on the actual handler, without
|
|
3026
|
-
// exporting it directly.
|
|
3027
|
-
const {
|
|
3028
|
-
/**
|
|
3029
|
-
* Called when the process is exiting, whether via signal, explicit
|
|
3030
|
-
* exit, or running out of stuff to do.
|
|
3031
|
-
*
|
|
3032
|
-
* If the global process object is not suitable for instrumentation,
|
|
3033
|
-
* then this will be a no-op.
|
|
3034
|
-
*
|
|
3035
|
-
* Returns a function that may be used to unload signal-exit.
|
|
3036
|
-
*/
|
|
3037
|
-
onExit
|
|
3038
|
-
} = signalExitWrap(
|
|
3039
|
-
processOk(process$1) ? new SignalExit(process$1) : new SignalExitFallback()
|
|
3040
|
-
)
|
|
3041
|
-
|
|
3042
|
-
const ESC = '\u001B['
|
|
3043
|
-
/** Move cursor to first column */
|
|
3044
|
-
const cursorLeft = ESC + 'G'
|
|
3045
|
-
/** Show the cursor */
|
|
3046
|
-
const cursorShow = ESC + '?25h'
|
|
3047
|
-
/** Move cursor up by count rows */
|
|
3048
|
-
const cursorUp = (rows = 1) => (rows > 0 ? `${ESC}${rows}A` : '')
|
|
3049
|
-
/** Move cursor down by count rows */
|
|
3050
|
-
const cursorDown = (rows = 1) => (rows > 0 ? `${ESC}${rows}B` : '')
|
|
3051
|
-
/** Move cursor to position (x, y) */
|
|
3052
|
-
const cursorTo = (x, y) => {
|
|
3053
|
-
return `${ESC}${x + 1}G`
|
|
3054
|
-
}
|
|
3055
|
-
const eraseLine = ESC + '2K'
|
|
3056
|
-
/** Erase the specified number of lines above the cursor */
|
|
3057
|
-
const eraseLines = lines =>
|
|
3058
|
-
lines > 0
|
|
3059
|
-
? (eraseLine + cursorUp(1)).repeat(lines - 1) + eraseLine + cursorLeft
|
|
3060
|
-
: ''
|
|
3061
|
-
|
|
3062
|
-
const height = content => content.split('\n').length
|
|
3063
|
-
const lastLine = content => content.split('\n').pop() ?? ''
|
|
3064
|
-
class ScreenManager {
|
|
3065
|
-
// These variables are keeping information to allow correct prompt re-rendering
|
|
3066
|
-
height = 0
|
|
3067
|
-
extraLinesUnderPrompt = 0
|
|
3068
|
-
cursorPos
|
|
3069
|
-
rl
|
|
3070
|
-
constructor(rl) {
|
|
3071
|
-
this.rl = rl
|
|
3072
|
-
this.cursorPos = rl.getCursorPos()
|
|
3073
|
-
}
|
|
3074
|
-
write(content) {
|
|
3075
|
-
this.rl.output.unmute()
|
|
3076
|
-
this.rl.output.write(content)
|
|
3077
|
-
this.rl.output.mute()
|
|
3078
|
-
}
|
|
3079
|
-
render(content, bottomContent = '') {
|
|
3080
|
-
// Write message to screen and setPrompt to control backspace
|
|
3081
|
-
const promptLine = lastLine(content)
|
|
3082
|
-
const rawPromptLine = util.stripVTControlCharacters(promptLine)
|
|
3083
|
-
// Remove the rl.line from our prompt. We can't rely on the content of
|
|
3084
|
-
// rl.line (mainly because of the password prompt), so just rely on it's
|
|
3085
|
-
// length.
|
|
3086
|
-
let prompt = rawPromptLine
|
|
3087
|
-
if (this.rl.line.length > 0) {
|
|
3088
|
-
prompt = prompt.slice(0, -this.rl.line.length)
|
|
3089
|
-
}
|
|
3090
|
-
this.rl.setPrompt(prompt)
|
|
3091
|
-
// SetPrompt will change cursor position, now we can get correct value
|
|
3092
|
-
this.cursorPos = this.rl.getCursorPos()
|
|
3093
|
-
const width = readlineWidth()
|
|
3094
|
-
content = breakLines(content, width)
|
|
3095
|
-
bottomContent = breakLines(bottomContent, width)
|
|
3096
|
-
// Manually insert an extra line if we're at the end of the line.
|
|
3097
|
-
// This prevent the cursor from appearing at the beginning of the
|
|
3098
|
-
// current line.
|
|
3099
|
-
if (rawPromptLine.length % width === 0) {
|
|
3100
|
-
content += '\n'
|
|
3101
|
-
}
|
|
3102
|
-
let output = content + (bottomContent ? '\n' + bottomContent : '')
|
|
3103
|
-
/**
|
|
3104
|
-
* Re-adjust the cursor at the correct position.
|
|
3105
|
-
*/
|
|
3106
|
-
// We need to consider parts of the prompt under the cursor as part of the bottom
|
|
3107
|
-
// content in order to correctly cleanup and re-render.
|
|
3108
|
-
const promptLineUpDiff =
|
|
3109
|
-
Math.floor(rawPromptLine.length / width) - this.cursorPos.rows
|
|
3110
|
-
const bottomContentHeight =
|
|
3111
|
-
promptLineUpDiff + (bottomContent ? height(bottomContent) : 0)
|
|
3112
|
-
// Return cursor to the input position (on top of the bottomContent)
|
|
3113
|
-
if (bottomContentHeight > 0) {
|
|
3114
|
-
output += cursorUp(bottomContentHeight)
|
|
3115
|
-
}
|
|
3116
|
-
// Return cursor to the initial left offset.
|
|
3117
|
-
output += cursorTo(this.cursorPos.cols)
|
|
3118
|
-
/**
|
|
3119
|
-
* Render and store state for future re-rendering
|
|
3120
|
-
*/
|
|
3121
|
-
this.write(
|
|
3122
|
-
cursorDown(this.extraLinesUnderPrompt) + eraseLines(this.height) + output
|
|
3123
|
-
)
|
|
3124
|
-
this.extraLinesUnderPrompt = bottomContentHeight
|
|
3125
|
-
this.height = height(output)
|
|
3126
|
-
}
|
|
3127
|
-
checkCursorPos() {
|
|
3128
|
-
const cursorPos = this.rl.getCursorPos()
|
|
3129
|
-
if (cursorPos.cols !== this.cursorPos.cols) {
|
|
3130
|
-
this.write(cursorTo(cursorPos.cols))
|
|
3131
|
-
this.cursorPos = cursorPos
|
|
3132
|
-
}
|
|
3133
|
-
}
|
|
3134
|
-
done({ clearContent }) {
|
|
3135
|
-
this.rl.setPrompt('')
|
|
3136
|
-
let output = cursorDown(this.extraLinesUnderPrompt)
|
|
3137
|
-
output += clearContent ? eraseLines(this.height) : '\n'
|
|
3138
|
-
output += cursorShow
|
|
3139
|
-
this.write(output)
|
|
3140
|
-
this.rl.close()
|
|
3141
|
-
}
|
|
3142
|
-
}
|
|
3143
|
-
|
|
3144
|
-
// TODO: Remove this class once Node 22 becomes the minimum supported version.
|
|
3145
|
-
class PromisePolyfill extends Promise {
|
|
3146
|
-
// Available starting from Node 22
|
|
3147
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers
|
|
3148
|
-
static withResolver() {
|
|
3149
|
-
let resolve
|
|
3150
|
-
let reject
|
|
3151
|
-
const promise = new Promise((res, rej) => {
|
|
3152
|
-
resolve = res
|
|
3153
|
-
reject = rej
|
|
3154
|
-
})
|
|
3155
|
-
return {
|
|
3156
|
-
promise,
|
|
3157
|
-
resolve: resolve,
|
|
3158
|
-
reject: reject
|
|
3159
|
-
}
|
|
3160
|
-
}
|
|
3161
|
-
}
|
|
3162
|
-
|
|
3163
|
-
function getCallSites() {
|
|
3164
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
3165
|
-
const _prepareStackTrace = Error.prepareStackTrace
|
|
3166
|
-
let result = []
|
|
3167
|
-
try {
|
|
3168
|
-
Error.prepareStackTrace = (_, callSites) => {
|
|
3169
|
-
const callSitesWithoutCurrent = callSites.slice(1)
|
|
3170
|
-
result = callSitesWithoutCurrent
|
|
3171
|
-
return callSitesWithoutCurrent
|
|
3172
|
-
}
|
|
3173
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
3174
|
-
new Error().stack
|
|
3175
|
-
} catch {
|
|
3176
|
-
// An error will occur if the Node flag --frozen-intrinsics is used.
|
|
3177
|
-
// https://nodejs.org/api/cli.html#--frozen-intrinsics
|
|
3178
|
-
return result
|
|
3179
|
-
}
|
|
3180
|
-
Error.prepareStackTrace = _prepareStackTrace
|
|
3181
|
-
return result
|
|
3182
|
-
}
|
|
3183
|
-
function createPrompt(view) {
|
|
3184
|
-
const callSites = getCallSites()
|
|
3185
|
-
const prompt = (config, context = {}) => {
|
|
3186
|
-
// Default `input` to stdin
|
|
3187
|
-
const { input = process.stdin, signal } = context
|
|
3188
|
-
const cleanups = new Set()
|
|
3189
|
-
// Add mute capabilities to the output
|
|
3190
|
-
const output = new libExports()
|
|
3191
|
-
output.pipe(context.output ?? process.stdout)
|
|
3192
|
-
const rl = readline__namespace.createInterface({
|
|
3193
|
-
terminal: true,
|
|
3194
|
-
input,
|
|
3195
|
-
output
|
|
3196
|
-
})
|
|
3197
|
-
const screen = new ScreenManager(rl)
|
|
3198
|
-
const { promise, resolve, reject } = PromisePolyfill.withResolver()
|
|
3199
|
-
const cancel = () => reject(new CancelPromptError())
|
|
3200
|
-
if (signal) {
|
|
3201
|
-
const abort = () =>
|
|
3202
|
-
reject(
|
|
3203
|
-
new AbortPromptError({
|
|
3204
|
-
cause: signal.reason
|
|
3205
|
-
})
|
|
3206
|
-
)
|
|
3207
|
-
if (signal.aborted) {
|
|
3208
|
-
abort()
|
|
3209
|
-
return Object.assign(promise, {
|
|
3210
|
-
cancel
|
|
3211
|
-
})
|
|
3212
|
-
}
|
|
3213
|
-
signal.addEventListener('abort', abort)
|
|
3214
|
-
cleanups.add(() => signal.removeEventListener('abort', abort))
|
|
3215
|
-
}
|
|
3216
|
-
cleanups.add(
|
|
3217
|
-
onExit((code, signal) => {
|
|
3218
|
-
reject(
|
|
3219
|
-
new ExitPromptError(
|
|
3220
|
-
`User force closed the prompt with ${code} ${signal}`
|
|
3221
|
-
)
|
|
3222
|
-
)
|
|
3223
|
-
})
|
|
3224
|
-
)
|
|
3225
|
-
// SIGINT must be explicitly handled by the prompt so the ExitPromptError can be handled.
|
|
3226
|
-
// Otherwise, the prompt will stop and in some scenarios never resolve.
|
|
3227
|
-
// Ref issue #1741
|
|
3228
|
-
const sigint = () =>
|
|
3229
|
-
reject(new ExitPromptError(`User force closed the prompt with SIGINT`))
|
|
3230
|
-
rl.on('SIGINT', sigint)
|
|
3231
|
-
cleanups.add(() => rl.removeListener('SIGINT', sigint))
|
|
3232
|
-
// Re-renders only happen when the state change; but the readline cursor could change position
|
|
3233
|
-
// and that also requires a re-render (and a manual one because we mute the streams).
|
|
3234
|
-
// We set the listener after the initial workLoop to avoid a double render if render triggered
|
|
3235
|
-
// by a state change sets the cursor to the right position.
|
|
3236
|
-
const checkCursorPos = () => screen.checkCursorPos()
|
|
3237
|
-
rl.input.on('keypress', checkCursorPos)
|
|
3238
|
-
cleanups.add(() => rl.input.removeListener('keypress', checkCursorPos))
|
|
3239
|
-
return withHooks(rl, cycle => {
|
|
3240
|
-
// The close event triggers immediately when the user press ctrl+c. SignalExit on the other hand
|
|
3241
|
-
// triggers after the process is done (which happens after timeouts are done triggering.)
|
|
3242
|
-
// We triggers the hooks cleanup phase on rl `close` so active timeouts can be cleared.
|
|
3243
|
-
const hooksCleanup = async_hooks.AsyncResource.bind(() =>
|
|
3244
|
-
effectScheduler.clearAll()
|
|
3245
|
-
)
|
|
3246
|
-
rl.on('close', hooksCleanup)
|
|
3247
|
-
cleanups.add(() => rl.removeListener('close', hooksCleanup))
|
|
3248
|
-
cycle(() => {
|
|
3249
|
-
try {
|
|
3250
|
-
const nextView = view(config, value => {
|
|
3251
|
-
setImmediate(() => resolve(value))
|
|
3252
|
-
})
|
|
3253
|
-
// Typescript won't allow this, but not all users rely on typescript.
|
|
3254
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
3255
|
-
if (nextView === undefined) {
|
|
3256
|
-
const callerFilename = callSites[1]?.getFileName()
|
|
3257
|
-
throw new Error(
|
|
3258
|
-
`Prompt functions must return a string.\n at ${callerFilename}`
|
|
3259
|
-
)
|
|
3260
|
-
}
|
|
3261
|
-
const [content, bottomContent] =
|
|
3262
|
-
typeof nextView === 'string' ? [nextView] : nextView
|
|
3263
|
-
screen.render(content, bottomContent)
|
|
3264
|
-
effectScheduler.run()
|
|
3265
|
-
} catch (error) {
|
|
3266
|
-
reject(error)
|
|
3267
|
-
}
|
|
3268
|
-
})
|
|
3269
|
-
return Object.assign(
|
|
3270
|
-
promise
|
|
3271
|
-
.then(
|
|
3272
|
-
answer => {
|
|
3273
|
-
effectScheduler.clearAll()
|
|
3274
|
-
return answer
|
|
3275
|
-
},
|
|
3276
|
-
error => {
|
|
3277
|
-
effectScheduler.clearAll()
|
|
3278
|
-
throw error
|
|
3279
|
-
}
|
|
3280
|
-
)
|
|
3281
|
-
// Wait for the promise to settle, then cleanup.
|
|
3282
|
-
.finally(() => {
|
|
3283
|
-
cleanups.forEach(cleanup => cleanup())
|
|
3284
|
-
screen.done({
|
|
3285
|
-
clearContent: Boolean(context.clearPromptOnDone)
|
|
3286
|
-
})
|
|
3287
|
-
output.end()
|
|
3288
|
-
})
|
|
3289
|
-
// Once cleanup is done, let the expose promise resolve/reject to the internal one.
|
|
3290
|
-
.then(() => promise),
|
|
3291
|
-
{
|
|
3292
|
-
cancel
|
|
3293
|
-
}
|
|
3294
|
-
)
|
|
3295
|
-
})
|
|
3296
|
-
}
|
|
3297
|
-
return prompt
|
|
3298
|
-
}
|
|
3299
|
-
|
|
3300
|
-
/**
|
|
3301
|
-
* Separator object
|
|
3302
|
-
* Used to space/separate choices group
|
|
3303
|
-
*/
|
|
3304
|
-
class Separator {
|
|
3305
|
-
separator = yoctocolorsCjsExports.dim(
|
|
3306
|
-
Array.from({
|
|
3307
|
-
length: 15
|
|
3308
|
-
}).join(figures.line)
|
|
3309
|
-
)
|
|
3310
|
-
type = 'separator'
|
|
3311
|
-
constructor(separator) {
|
|
3312
|
-
if (separator) {
|
|
3313
|
-
this.separator = separator
|
|
3314
|
-
}
|
|
3315
|
-
}
|
|
3316
|
-
static isSeparator(choice) {
|
|
3317
|
-
return Boolean(
|
|
3318
|
-
choice &&
|
|
3319
|
-
typeof choice === 'object' &&
|
|
3320
|
-
'type' in choice &&
|
|
3321
|
-
choice.type === 'separator'
|
|
3322
|
-
)
|
|
3323
|
-
}
|
|
3324
|
-
}
|
|
3325
|
-
|
|
3326
|
-
const ansiEscapes = { exports: {} }
|
|
3327
|
-
|
|
3328
|
-
let hasRequiredAnsiEscapes
|
|
3329
|
-
function requireAnsiEscapes() {
|
|
3330
|
-
if (hasRequiredAnsiEscapes) {
|
|
3331
|
-
return ansiEscapes.exports
|
|
3332
|
-
}
|
|
3333
|
-
hasRequiredAnsiEscapes = 1
|
|
3334
|
-
;(function (module) {
|
|
3335
|
-
const ansiEscapes = module.exports
|
|
3336
|
-
// TODO: remove this in the next major version
|
|
3337
|
-
module.exports.default = ansiEscapes
|
|
3338
|
-
const ESC = '\u001B['
|
|
3339
|
-
const OSC = '\u001B]'
|
|
3340
|
-
const BEL = '\u0007'
|
|
3341
|
-
const SEP = ';'
|
|
3342
|
-
const isTerminalApp = process.env.TERM_PROGRAM === 'Apple_Terminal'
|
|
3343
|
-
ansiEscapes.cursorTo = (x, y) => {
|
|
3344
|
-
if (typeof x !== 'number') {
|
|
3345
|
-
throw new TypeError('The `x` argument is required')
|
|
3346
|
-
}
|
|
3347
|
-
if (typeof y !== 'number') {
|
|
3348
|
-
return ESC + (x + 1) + 'G'
|
|
3349
|
-
}
|
|
3350
|
-
return ESC + (y + 1) + ';' + (x + 1) + 'H'
|
|
3351
|
-
}
|
|
3352
|
-
ansiEscapes.cursorMove = (x, y) => {
|
|
3353
|
-
if (typeof x !== 'number') {
|
|
3354
|
-
throw new TypeError('The `x` argument is required')
|
|
3355
|
-
}
|
|
3356
|
-
let ret = ''
|
|
3357
|
-
if (x < 0) {
|
|
3358
|
-
ret += ESC + -x + 'D'
|
|
3359
|
-
} else if (x > 0) {
|
|
3360
|
-
ret += ESC + x + 'C'
|
|
3361
|
-
}
|
|
3362
|
-
if (y < 0) {
|
|
3363
|
-
ret += ESC + -y + 'A'
|
|
3364
|
-
} else if (y > 0) {
|
|
3365
|
-
ret += ESC + y + 'B'
|
|
3366
|
-
}
|
|
3367
|
-
return ret
|
|
3368
|
-
}
|
|
3369
|
-
ansiEscapes.cursorUp = (count = 1) => ESC + count + 'A'
|
|
3370
|
-
ansiEscapes.cursorDown = (count = 1) => ESC + count + 'B'
|
|
3371
|
-
ansiEscapes.cursorForward = (count = 1) => ESC + count + 'C'
|
|
3372
|
-
ansiEscapes.cursorBackward = (count = 1) => ESC + count + 'D'
|
|
3373
|
-
ansiEscapes.cursorLeft = ESC + 'G'
|
|
3374
|
-
ansiEscapes.cursorSavePosition = isTerminalApp ? '\u001B7' : ESC + 's'
|
|
3375
|
-
ansiEscapes.cursorRestorePosition = isTerminalApp ? '\u001B8' : ESC + 'u'
|
|
3376
|
-
ansiEscapes.cursorGetPosition = ESC + '6n'
|
|
3377
|
-
ansiEscapes.cursorNextLine = ESC + 'E'
|
|
3378
|
-
ansiEscapes.cursorPrevLine = ESC + 'F'
|
|
3379
|
-
ansiEscapes.cursorHide = ESC + '?25l'
|
|
3380
|
-
ansiEscapes.cursorShow = ESC + '?25h'
|
|
3381
|
-
ansiEscapes.eraseLines = count => {
|
|
3382
|
-
let clear = ''
|
|
3383
|
-
for (let i = 0; i < count; i++) {
|
|
3384
|
-
clear +=
|
|
3385
|
-
ansiEscapes.eraseLine + (i < count - 1 ? ansiEscapes.cursorUp() : '')
|
|
3386
|
-
}
|
|
3387
|
-
if (count) {
|
|
3388
|
-
clear += ansiEscapes.cursorLeft
|
|
3389
|
-
}
|
|
3390
|
-
return clear
|
|
3391
|
-
}
|
|
3392
|
-
ansiEscapes.eraseEndLine = ESC + 'K'
|
|
3393
|
-
ansiEscapes.eraseStartLine = ESC + '1K'
|
|
3394
|
-
ansiEscapes.eraseLine = ESC + '2K'
|
|
3395
|
-
ansiEscapes.eraseDown = ESC + 'J'
|
|
3396
|
-
ansiEscapes.eraseUp = ESC + '1J'
|
|
3397
|
-
ansiEscapes.eraseScreen = ESC + '2J'
|
|
3398
|
-
ansiEscapes.scrollUp = ESC + 'S'
|
|
3399
|
-
ansiEscapes.scrollDown = ESC + 'T'
|
|
3400
|
-
ansiEscapes.clearScreen = '\u001Bc'
|
|
3401
|
-
ansiEscapes.clearTerminal =
|
|
3402
|
-
process.platform === 'win32'
|
|
3403
|
-
? `${ansiEscapes.eraseScreen}${ESC}0f`
|
|
3404
|
-
: // 1. Erases the screen (Only done in case `2` is not supported)
|
|
3405
|
-
// 2. Erases the whole screen including scrollback buffer
|
|
3406
|
-
// 3. Moves cursor to the top-left position
|
|
3407
|
-
// More info: https://www.real-world-systems.com/docs/ANSIcode.html
|
|
3408
|
-
`${ansiEscapes.eraseScreen}${ESC}3J${ESC}H`
|
|
3409
|
-
ansiEscapes.beep = BEL
|
|
3410
|
-
ansiEscapes.link = (text, url) => {
|
|
3411
|
-
return [OSC, '8', SEP, SEP, url, BEL, text, OSC, '8', SEP, SEP, BEL].join(
|
|
3412
|
-
''
|
|
3413
|
-
)
|
|
3414
|
-
}
|
|
3415
|
-
ansiEscapes.image = (buffer, options = {}) => {
|
|
3416
|
-
let ret = `${OSC}1337;File=inline=1`
|
|
3417
|
-
if (options.width) {
|
|
3418
|
-
ret += `;width=${options.width}`
|
|
3419
|
-
}
|
|
3420
|
-
if (options.height) {
|
|
3421
|
-
ret += `;height=${options.height}`
|
|
3422
|
-
}
|
|
3423
|
-
if (options.preserveAspectRatio === false) {
|
|
3424
|
-
ret += ';preserveAspectRatio=0'
|
|
3425
|
-
}
|
|
3426
|
-
return ret + ':' + buffer.toString('base64') + BEL
|
|
3427
|
-
}
|
|
3428
|
-
ansiEscapes.iTerm = {
|
|
3429
|
-
setCwd: (cwd = process.cwd()) => `${OSC}50;CurrentDir=${cwd}${BEL}`,
|
|
3430
|
-
annotation: (message, options = {}) => {
|
|
3431
|
-
let ret = `${OSC}1337;`
|
|
3432
|
-
const hasX = typeof options.x !== 'undefined'
|
|
3433
|
-
const hasY = typeof options.y !== 'undefined'
|
|
3434
|
-
if (
|
|
3435
|
-
(hasX || hasY) &&
|
|
3436
|
-
!(hasX && hasY && typeof options.length !== 'undefined')
|
|
3437
|
-
) {
|
|
3438
|
-
throw new Error(
|
|
3439
|
-
'`x`, `y` and `length` must be defined when `x` or `y` is defined'
|
|
3440
|
-
)
|
|
3441
|
-
}
|
|
3442
|
-
message = message.replace(/\|/g, '')
|
|
3443
|
-
ret += options.isHidden ? 'AddHiddenAnnotation=' : 'AddAnnotation='
|
|
3444
|
-
if (options.length > 0) {
|
|
3445
|
-
ret += (
|
|
3446
|
-
hasX
|
|
3447
|
-
? [message, options.length, options.x, options.y]
|
|
3448
|
-
: [options.length, message]
|
|
3449
|
-
).join('|')
|
|
3450
|
-
} else {
|
|
3451
|
-
ret += message
|
|
3452
|
-
}
|
|
3453
|
-
return ret + BEL
|
|
3454
|
-
}
|
|
3455
|
-
}
|
|
3456
|
-
})(ansiEscapes)
|
|
3457
|
-
return ansiEscapes.exports
|
|
3458
|
-
}
|
|
3459
|
-
|
|
3460
|
-
const ansiEscapesExports = requireAnsiEscapes()
|
|
3461
|
-
|
|
3462
|
-
const selectTheme = {
|
|
3463
|
-
icon: {
|
|
3464
|
-
cursor: figures.pointer
|
|
3465
|
-
},
|
|
3466
|
-
style: {
|
|
3467
|
-
disabled: text => yoctocolorsCjsExports.dim(`- ${text}`),
|
|
3468
|
-
description: text => yoctocolorsCjsExports.cyan(text)
|
|
3469
|
-
},
|
|
3470
|
-
helpMode: 'auto',
|
|
3471
|
-
indexMode: 'hidden'
|
|
3472
|
-
}
|
|
3473
|
-
function isSelectable(item) {
|
|
3474
|
-
return !Separator.isSeparator(item) && !item.disabled
|
|
3475
|
-
}
|
|
3476
|
-
function normalizeChoices(choices) {
|
|
3477
|
-
return choices.map(choice => {
|
|
3478
|
-
if (Separator.isSeparator(choice)) {
|
|
3479
|
-
return choice
|
|
3480
|
-
}
|
|
3481
|
-
if (typeof choice === 'string') {
|
|
3482
|
-
return {
|
|
3483
|
-
value: choice,
|
|
3484
|
-
name: choice,
|
|
3485
|
-
short: choice,
|
|
3486
|
-
disabled: false
|
|
3487
|
-
}
|
|
3488
|
-
}
|
|
3489
|
-
const name = choice.name ?? String(choice.value)
|
|
3490
|
-
const normalizedChoice = {
|
|
3491
|
-
value: choice.value,
|
|
3492
|
-
name,
|
|
3493
|
-
short: choice.short ?? name,
|
|
3494
|
-
disabled: choice.disabled ?? false
|
|
3495
|
-
}
|
|
3496
|
-
if (choice.description) {
|
|
3497
|
-
normalizedChoice.description = choice.description
|
|
3498
|
-
}
|
|
3499
|
-
return normalizedChoice
|
|
3500
|
-
})
|
|
3501
|
-
}
|
|
3502
|
-
const index = createPrompt((config, done) => {
|
|
3503
|
-
const { loop = true, pageSize = 7 } = config
|
|
3504
|
-
const firstRender = useRef(true)
|
|
3505
|
-
const theme = makeTheme(selectTheme, config.theme)
|
|
3506
|
-
const [status, setStatus] = useState('idle')
|
|
3507
|
-
const prefix = usePrefix({
|
|
3508
|
-
status,
|
|
3509
|
-
theme
|
|
3510
|
-
})
|
|
3511
|
-
const searchTimeoutRef = useRef()
|
|
3512
|
-
const items = useMemo(
|
|
3513
|
-
() => normalizeChoices(config.choices),
|
|
3514
|
-
[config.choices]
|
|
3515
|
-
)
|
|
3516
|
-
const bounds = useMemo(() => {
|
|
3517
|
-
const first = items.findIndex(isSelectable)
|
|
3518
|
-
const last = items.findLastIndex(isSelectable)
|
|
3519
|
-
if (first === -1) {
|
|
3520
|
-
throw new ValidationError(
|
|
3521
|
-
'[select prompt] No selectable choices. All choices are disabled.'
|
|
3522
|
-
)
|
|
3523
|
-
}
|
|
3524
|
-
return {
|
|
3525
|
-
first,
|
|
3526
|
-
last
|
|
3527
|
-
}
|
|
3528
|
-
}, [items])
|
|
3529
|
-
const defaultItemIndex = useMemo(() => {
|
|
3530
|
-
if (!('default' in config)) {
|
|
3531
|
-
return -1
|
|
3532
|
-
}
|
|
3533
|
-
return items.findIndex(
|
|
3534
|
-
item => isSelectable(item) && item.value === config.default
|
|
3535
|
-
)
|
|
3536
|
-
}, [config.default, items])
|
|
3537
|
-
const [active, setActive] = useState(
|
|
3538
|
-
defaultItemIndex === -1 ? bounds.first : defaultItemIndex
|
|
3539
|
-
)
|
|
3540
|
-
// Safe to assume the cursor position always point to a Choice.
|
|
3541
|
-
const selectedChoice = items[active]
|
|
3542
|
-
useKeypress((key, rl) => {
|
|
3543
|
-
clearTimeout(searchTimeoutRef.current)
|
|
3544
|
-
if (isEnterKey(key)) {
|
|
3545
|
-
setStatus('done')
|
|
3546
|
-
done(selectedChoice.value)
|
|
3547
|
-
} else if (isUpKey(key) || isDownKey(key)) {
|
|
3548
|
-
rl.clearLine(0)
|
|
3549
|
-
if (
|
|
3550
|
-
loop ||
|
|
3551
|
-
(isUpKey(key) && active !== bounds.first) ||
|
|
3552
|
-
(isDownKey(key) && active !== bounds.last)
|
|
3553
|
-
) {
|
|
3554
|
-
const offset = isUpKey(key) ? -1 : 1
|
|
3555
|
-
let next = active
|
|
3556
|
-
do {
|
|
3557
|
-
next = (next + offset + items.length) % items.length
|
|
3558
|
-
} while (!isSelectable(items[next]))
|
|
3559
|
-
setActive(next)
|
|
3560
|
-
}
|
|
3561
|
-
} else if (isNumberKey(key) && !Number.isNaN(Number(rl.line))) {
|
|
3562
|
-
const selectedIndex = Number(rl.line) - 1
|
|
3563
|
-
// Find the nth item (ignoring separators)
|
|
3564
|
-
let selectableIndex = -1
|
|
3565
|
-
const position = items.findIndex(item => {
|
|
3566
|
-
if (Separator.isSeparator(item)) {
|
|
3567
|
-
return false
|
|
3568
|
-
}
|
|
3569
|
-
selectableIndex++
|
|
3570
|
-
return selectableIndex === selectedIndex
|
|
3571
|
-
})
|
|
3572
|
-
const item = items[position]
|
|
3573
|
-
if (item != null && isSelectable(item)) {
|
|
3574
|
-
setActive(position)
|
|
3575
|
-
}
|
|
3576
|
-
searchTimeoutRef.current = setTimeout(() => {
|
|
3577
|
-
rl.clearLine(0)
|
|
3578
|
-
}, 700)
|
|
3579
|
-
} else if (isBackspaceKey(key)) {
|
|
3580
|
-
rl.clearLine(0)
|
|
3581
|
-
} else {
|
|
3582
|
-
// Default to search
|
|
3583
|
-
const searchTerm = rl.line.toLowerCase()
|
|
3584
|
-
const matchIndex = items.findIndex(item => {
|
|
3585
|
-
if (Separator.isSeparator(item) || !isSelectable(item)) {
|
|
3586
|
-
return false
|
|
3587
|
-
}
|
|
3588
|
-
return item.name.toLowerCase().startsWith(searchTerm)
|
|
3589
|
-
})
|
|
3590
|
-
if (matchIndex !== -1) {
|
|
3591
|
-
setActive(matchIndex)
|
|
3592
|
-
}
|
|
3593
|
-
searchTimeoutRef.current = setTimeout(() => {
|
|
3594
|
-
rl.clearLine(0)
|
|
3595
|
-
}, 700)
|
|
3596
|
-
}
|
|
3597
|
-
})
|
|
3598
|
-
useEffect(
|
|
3599
|
-
() => () => {
|
|
3600
|
-
clearTimeout(searchTimeoutRef.current)
|
|
3601
|
-
},
|
|
3602
|
-
[]
|
|
3603
|
-
)
|
|
3604
|
-
const message = theme.style.message(config.message, status)
|
|
3605
|
-
let helpTipTop = ''
|
|
3606
|
-
let helpTipBottom = ''
|
|
3607
|
-
if (
|
|
3608
|
-
theme.helpMode === 'always' ||
|
|
3609
|
-
(theme.helpMode === 'auto' && firstRender.current)
|
|
3610
|
-
) {
|
|
3611
|
-
firstRender.current = false
|
|
3612
|
-
if (items.length > pageSize) {
|
|
3613
|
-
helpTipBottom = `\n${theme.style.help(`(${config.instructions?.pager ?? 'Use arrow keys to reveal more choices'})`)}`
|
|
3614
|
-
} else {
|
|
3615
|
-
helpTipTop = theme.style.help(
|
|
3616
|
-
`(${config.instructions?.navigation ?? 'Use arrow keys'})`
|
|
3617
|
-
)
|
|
3618
|
-
}
|
|
3619
|
-
}
|
|
3620
|
-
let separatorCount = 0
|
|
3621
|
-
const page = usePagination({
|
|
3622
|
-
items,
|
|
3623
|
-
active,
|
|
3624
|
-
renderItem({ item, isActive, index }) {
|
|
3625
|
-
if (Separator.isSeparator(item)) {
|
|
3626
|
-
separatorCount++
|
|
3627
|
-
return ` ${item.separator}`
|
|
3628
|
-
}
|
|
3629
|
-
const indexLabel =
|
|
3630
|
-
theme.indexMode === 'number' ? `${index + 1 - separatorCount}. ` : ''
|
|
3631
|
-
if (item.disabled) {
|
|
3632
|
-
const disabledLabel =
|
|
3633
|
-
typeof item.disabled === 'string' ? item.disabled : '(disabled)'
|
|
3634
|
-
return theme.style.disabled(
|
|
3635
|
-
`${indexLabel}${item.name} ${disabledLabel}`
|
|
3636
|
-
)
|
|
3637
|
-
}
|
|
3638
|
-
const color = isActive ? theme.style.highlight : x => x
|
|
3639
|
-
const cursor = isActive ? theme.icon.cursor : ` `
|
|
3640
|
-
return color(`${cursor} ${indexLabel}${item.name}`)
|
|
3641
|
-
},
|
|
3642
|
-
pageSize,
|
|
3643
|
-
loop
|
|
3644
|
-
})
|
|
3645
|
-
if (status === 'done') {
|
|
3646
|
-
return `${prefix} ${message} ${theme.style.answer(selectedChoice.short)}`
|
|
3647
|
-
}
|
|
3648
|
-
const choiceDescription = selectedChoice.description
|
|
3649
|
-
? `\n${theme.style.description(selectedChoice.description)}`
|
|
3650
|
-
: ``
|
|
3651
|
-
return `${[prefix, message, helpTipTop].filter(Boolean).join(' ')}\n${page}${helpTipBottom}${choiceDescription}${ansiEscapesExports.cursorHide}`
|
|
3652
|
-
})
|
|
3653
|
-
|
|
3654
|
-
exports.Separator = Separator
|
|
3655
|
-
exports.default = index
|