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