@socketsecurity/cli-with-sentry 1.16.1 → 1.17.1
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 +18 -0
- package/LICENSE +87 -0
- package/README.md +13 -13
- package/bin/cli.js +9 -9
- package/dist/.config/tsconfig.dts.tsbuildinfo +1 -1
- package/dist/cli.js +2114 -4292
- package/dist/cli.js.map +1 -1
- package/dist/constants.js +71 -87
- package/dist/constants.js.map +1 -1
- package/dist/env-helpers.js +63 -0
- package/dist/env-helpers.js.map +1 -0
- package/dist/instrument-with-sentry.js +7 -7
- package/dist/instrument-with-sentry.js.map +1 -1
- package/dist/manifest-scripts/dotnet-tool/Microsoft.Build.Locator.dll +0 -0
- package/dist/manifest-scripts/dotnet-tool/socket-facts-dotnet.deps.json +2 -2
- package/dist/manifest-scripts/dotnet-tool/socket-facts-dotnet.dll +0 -0
- package/dist/manifest-scripts/maven-extension/coana-maven-extension.jar +0 -0
- package/dist/runtime-constants.js +345 -0
- package/dist/runtime-constants.js.map +1 -0
- package/dist/shadow-npm-bin2.js +9 -13
- package/dist/shadow-npm-bin2.js.map +1 -1
- package/dist/shadow-npm-inject.js +10 -15
- package/dist/shadow-npm-inject.js.map +1 -1
- package/dist/shadow-npx-bin.js.map +1 -1
- package/dist/shadow-pnpm-bin2.js +21 -25
- package/dist/shadow-pnpm-bin2.js.map +1 -1
- package/dist/shadow-yarn-bin.js +4 -6
- package/dist/shadow-yarn-bin.js.map +1 -1
- package/dist/socket-completion.bash +0 -0
- package/dist/spawn-sync.js +47 -0
- package/dist/spawn-sync.js.map +1 -0
- package/dist/spinner.js +182 -0
- package/dist/spinner.js.map +1 -0
- package/dist/types/commands/fix/generated-socket-facts.d.mts +5 -2
- package/dist/types/commands/fix/handle-fix.d.mts +1 -1
- package/dist/types/commands/fix/types.d.mts +1 -1
- package/dist/types/commands/manifest/bazel/process.d.mts +2 -2
- package/dist/types/commands/manifest/convert-dotnet-to-facts.d.mts +3 -6
- package/dist/types/commands/manifest/discover-manifest-roots.d.mts +10 -11
- package/dist/types/commands/manifest/generate-recursive-manifests.d.mts +16 -30
- package/dist/types/commands/manifest/generate_auto_manifest.d.mts +6 -11
- package/dist/types/commands/manifest/load-build.d.mts +3 -11
- package/dist/types/commands/manifest/run-manifest-facts.d.mts +88 -29
- package/dist/types/commands/manifest/scripts/build-tool.d.mts +2 -0
- package/dist/types/commands/optimize/add-overrides.d.mts +2 -2
- package/dist/types/commands/optimize/get-dependency-entries.d.mts +1 -1
- package/dist/types/commands/optimize/get-overrides-by-agent.d.mts +16 -7
- package/dist/types/commands/optimize/update-lockfile.d.mts +2 -2
- package/dist/types/commands/optimize/update-manifest-by-agent.d.mts +4 -2
- package/dist/types/commands/package/fetch-purls-shallow-score.d.mts +2 -2
- package/dist/types/commands/scan/fetch-supported-scan-file-names.d.mts +1 -1
- package/dist/types/commands/scan/generate-report.d.mts +1 -1
- package/dist/types/commands/scan/handle-create-new-scan.d.mts +5 -1
- package/dist/types/commands/scan/output-create-new-scan.d.mts +1 -1
- package/dist/types/commands/scan/output-diff-scan.d.mts +4 -2
- package/dist/types/commands/scan/perform-reachability-analysis.d.mts +4 -5
- package/dist/types/commands/scan/run-dynamic-sbom-inference.d.mts +7 -15
- package/dist/types/constants/runtime.d.mts +417 -0
- package/dist/types/constants.d.mts +9 -10
- package/dist/types/paths/coana.d.mts +5 -0
- package/dist/types/paths/uv.d.mts +2 -0
- package/dist/types/sea/adapters/cdxgen-worker.d.mts +1 -0
- package/dist/types/sea/adapters/synp-worker.d.mts +1 -0
- package/dist/types/sea/build/cdxgen-fixture.d.mts +4 -0
- package/dist/types/sea/build/smoke-test.d.mts +2 -0
- package/dist/types/sea/build-sea.d.mts +4 -2
- package/dist/types/sea/download-bytes.d.mts +0 -1
- package/dist/types/sea/paths/archive.d.mts +3 -0
- package/dist/types/sea/paths/coana-cache.d.mts +1 -0
- package/dist/types/sea/paths/native-tools.d.mts +13 -0
- package/dist/types/sea/pnpm-lock.d.mts +22 -0
- package/dist/types/sea/rollup-workers.d.mts +1 -0
- package/dist/types/sea/runtime.d.mts +4 -3
- package/dist/types/sea/vfs-digest.d.mts +2 -0
- package/dist/types/shadow/common.d.mts +1 -1
- package/dist/types/shadow/npm/arborist-helpers.d.mts +1 -1
- package/dist/types/shadow/npm/bin.d.mts +1 -1
- package/dist/types/shadow/npm/install.d.mts +3 -3
- package/dist/types/shadow/npm-base.d.mts +1 -1
- package/dist/types/shadow/npx/bin.d.mts +1 -1
- package/dist/types/shadow/pnpm/bin.d.mts +1 -1
- package/dist/types/shadow/yarn/bin.d.mts +1 -1
- package/dist/types/test/mocks/socket-auth.d.mts +40 -39
- package/dist/types/utils/agent.d.mts +6 -1
- package/dist/types/utils/alert/artifact.d.mts +1 -1
- package/dist/types/utils/alerts-map.d.mts +1 -1
- package/dist/types/utils/api.d.mts +1 -1
- package/dist/types/utils/arrays.d.mts +6 -0
- package/dist/types/utils/bin.d.mts +26 -0
- package/dist/types/utils/{coana-release.d.mts → coana/release.d.mts} +5 -3
- package/dist/types/utils/debug.d.mts +23 -49
- package/dist/types/utils/dlx.d.mts +1 -1
- package/dist/types/utils/ecosystem.d.mts +1 -9
- package/dist/types/utils/env.d.mts +24 -0
- package/dist/types/utils/errors.d.mts +2 -2
- package/dist/types/utils/escape-regexp.d.mts +6 -0
- package/dist/types/utils/fs.d.mts +33 -0
- package/dist/types/utils/github.d.mts +1 -1
- package/dist/types/utils/globs.d.mts +1 -0
- package/dist/types/utils/logger.d.mts +51 -0
- package/dist/types/utils/objects.d.mts +11 -0
- package/dist/types/utils/package-environment.d.mts +3 -3
- package/dist/types/utils/packages.d.mts +65 -0
- package/dist/types/utils/path.d.mts +3 -0
- package/dist/types/utils/promises.d.mts +23 -0
- package/dist/types/utils/prompts.d.mts +25 -0
- package/dist/types/utils/purl.d.mts +4 -1
- package/dist/types/utils/socket-package-alert.d.mts +1 -1
- package/dist/types/utils/socket-url.d.mts +1 -1
- package/dist/types/utils/sorts.d.mts +1 -0
- package/dist/types/utils/spawn-sync.d.mts +3 -0
- package/dist/types/utils/spawn.d.mts +67 -0
- package/dist/types/utils/spec.d.mts +1 -1
- package/dist/types/utils/spinner.d.mts +46 -0
- package/dist/types/utils/streams.d.mts +3 -0
- package/dist/types/utils/strings.d.mts +6 -0
- package/dist/types/utils/url.d.mts +2 -0
- package/dist/types/utils/words.d.mts +1 -0
- package/dist/utils.js +4475 -803
- package/dist/utils.js.map +1 -1
- package/dist/vendor.js +39737 -41318
- package/external/blessed-contrib/lib/widget/charts/line.js +172 -149
- package/package.json +41 -37
- package/shadow-bin/npm +0 -0
- package/shadow-bin/npx +0 -0
- package/shadow-bin/pnpm +0 -0
- package/shadow-bin/yarn +0 -0
- package/dist/types/commands/manifest/convert-gradle-to-facts.d.mts +0 -19
- package/dist/types/commands/manifest/convert-maven-to-facts.d.mts +0 -19
- package/dist/types/commands/manifest/convert-sbt-to-facts.d.mts +0 -22
- package/dist/types/commands/manifest/enumerate-workspaces.d.mts +0 -22
- package/dist/types/commands/manifest/expand-env-var-refs.d.mts +0 -9
- package/dist/types/sea/archive-paths.d.mts +0 -6
- 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 -1379
- 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
|
@@ -1,422 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { isArray: ArrayIsArray } = Array
|
|
4
|
-
const {
|
|
5
|
-
defineProperties: ObjectDefineProperties,
|
|
6
|
-
freeze: ObjectFreeze,
|
|
7
|
-
fromEntries: ObjectFromEntries,
|
|
8
|
-
getOwnPropertyDescriptors: ObjectGetOwnPropertyDescriptors,
|
|
9
|
-
getOwnPropertyNames: ObjectGetOwnPropertyNames,
|
|
10
|
-
hasOwn: ObjectHasOwn,
|
|
11
|
-
keys: ObjectKeys,
|
|
12
|
-
setPrototypeOf: ObjectSetPrototypeOf
|
|
13
|
-
} = Object
|
|
14
|
-
const { __defineGetter__ } = Object.prototype
|
|
15
|
-
const { ownKeys: ReflectOwnKeys } = Reflect
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Create a lazy getter function that memoizes its result.
|
|
19
|
-
* @param {string | symbol} name - The property name for the getter.
|
|
20
|
-
* @param {Function} getter - The function to compute the value.
|
|
21
|
-
* @param {{initialized?: Set<string | symbol>}} [stats] - Statistics tracking object.
|
|
22
|
-
* @returns {Function} The lazy getter function.
|
|
23
|
-
*/
|
|
24
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
25
|
-
function createLazyGetter(name, getter, stats) {
|
|
26
|
-
const UNDEFINED_TOKEN = /*@__PURE__*/ require('./constants/undefined-token')
|
|
27
|
-
let lazyValue = UNDEFINED_TOKEN
|
|
28
|
-
// Dynamically name the getter without using Object.defineProperty.
|
|
29
|
-
const { [name]: lazyGetter } = {
|
|
30
|
-
[name]() {
|
|
31
|
-
if (lazyValue === UNDEFINED_TOKEN) {
|
|
32
|
-
stats?.initialized?.add(name)
|
|
33
|
-
lazyValue = getter()
|
|
34
|
-
}
|
|
35
|
-
return lazyValue
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return lazyGetter
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Create a frozen constants object with lazy getters and internal properties.
|
|
43
|
-
* @param {Object} props - Properties to include in the constants object.
|
|
44
|
-
* @param {Object} [options_] - Configuration options.
|
|
45
|
-
* @param {Object} [options_.getters] - Lazy getter definitions.
|
|
46
|
-
* @param {Object} [options_.internals] - Internal properties.
|
|
47
|
-
* @param {Object} [options_.mixin] - Properties to mix in.
|
|
48
|
-
* @returns {Object} The frozen constants object.
|
|
49
|
-
*/
|
|
50
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
51
|
-
function createConstantsObject(props, options_) {
|
|
52
|
-
const options = { __proto__: null, ...options_ }
|
|
53
|
-
const attributes = ObjectFreeze({
|
|
54
|
-
__proto__: null,
|
|
55
|
-
getters: options.getters
|
|
56
|
-
? ObjectFreeze(
|
|
57
|
-
ObjectSetPrototypeOf(toSortedObject(options.getters), null)
|
|
58
|
-
)
|
|
59
|
-
: undefined,
|
|
60
|
-
internals: options.internals
|
|
61
|
-
? ObjectFreeze(
|
|
62
|
-
ObjectSetPrototypeOf(toSortedObject(options.internals), null)
|
|
63
|
-
)
|
|
64
|
-
: undefined,
|
|
65
|
-
mixin: options.mixin
|
|
66
|
-
? ObjectFreeze(
|
|
67
|
-
ObjectDefineProperties(
|
|
68
|
-
{ __proto__: null },
|
|
69
|
-
ObjectGetOwnPropertyDescriptors(options.mixin)
|
|
70
|
-
)
|
|
71
|
-
)
|
|
72
|
-
: undefined,
|
|
73
|
-
props: props
|
|
74
|
-
? ObjectFreeze(ObjectSetPrototypeOf(toSortedObject(props), null))
|
|
75
|
-
: undefined
|
|
76
|
-
})
|
|
77
|
-
const kInternalsSymbol = /*@__PURE__*/ require('./constants/k-internals-symbol')
|
|
78
|
-
const lazyGetterStats = ObjectFreeze({
|
|
79
|
-
__proto__: null,
|
|
80
|
-
initialized: new Set()
|
|
81
|
-
})
|
|
82
|
-
const object = defineLazyGetters(
|
|
83
|
-
{
|
|
84
|
-
__proto__: null,
|
|
85
|
-
[kInternalsSymbol]: ObjectFreeze({
|
|
86
|
-
__proto__: null,
|
|
87
|
-
get attributes() {
|
|
88
|
-
return attributes
|
|
89
|
-
},
|
|
90
|
-
get lazyGetterStats() {
|
|
91
|
-
return lazyGetterStats
|
|
92
|
-
},
|
|
93
|
-
...attributes.internals
|
|
94
|
-
}),
|
|
95
|
-
kInternalsSymbol,
|
|
96
|
-
...attributes.props
|
|
97
|
-
},
|
|
98
|
-
attributes.getters,
|
|
99
|
-
lazyGetterStats
|
|
100
|
-
)
|
|
101
|
-
if (attributes.mixin) {
|
|
102
|
-
ObjectDefineProperties(
|
|
103
|
-
object,
|
|
104
|
-
toSortedObjectFromEntries(
|
|
105
|
-
objectEntries(ObjectGetOwnPropertyDescriptors(attributes.mixin)).filter(
|
|
106
|
-
p => !ObjectHasOwn(object, p[0])
|
|
107
|
-
)
|
|
108
|
-
)
|
|
109
|
-
)
|
|
110
|
-
}
|
|
111
|
-
return ObjectFreeze(object)
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Define a getter property on an object.
|
|
116
|
-
* @param {Object} object - The object to define the getter on.
|
|
117
|
-
* @param {string | symbol} propKey - The property key.
|
|
118
|
-
* @param {Function} getter - The getter function.
|
|
119
|
-
* @returns {Object} The object with the getter defined.
|
|
120
|
-
*/
|
|
121
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
122
|
-
function defineGetter(object, propKey, getter) {
|
|
123
|
-
__defineGetter__.call(object, propKey, getter)
|
|
124
|
-
return object
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Define a lazy getter property on an object.
|
|
129
|
-
* @param {Object} object - The object to define the lazy getter on.
|
|
130
|
-
* @param {string | symbol} propKey - The property key.
|
|
131
|
-
* @param {Function} getter - The getter function.
|
|
132
|
-
* @param {{initialized?: Set<string | symbol>}} [stats] - Statistics tracking object.
|
|
133
|
-
* @returns {Object} The object with the lazy getter defined.
|
|
134
|
-
*/
|
|
135
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
136
|
-
function defineLazyGetter(object, propKey, getter, stats) {
|
|
137
|
-
return defineGetter(object, propKey, createLazyGetter(propKey, getter, stats))
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Define multiple lazy getter properties on an object.
|
|
142
|
-
* @param {Object} object - The object to define the lazy getters on.
|
|
143
|
-
* @param {Object | null} getterDefObj - Object mapping property keys to getter functions.
|
|
144
|
-
* @param {{initialized?: Set<string | symbol>}} [stats] - Statistics tracking object.
|
|
145
|
-
* @returns {Object} The object with the lazy getters defined.
|
|
146
|
-
*/
|
|
147
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
148
|
-
function defineLazyGetters(object, getterDefObj, stats) {
|
|
149
|
-
if (getterDefObj !== null && typeof getterDefObj === 'object') {
|
|
150
|
-
const keys = ReflectOwnKeys(getterDefObj)
|
|
151
|
-
for (let i = 0, { length } = keys; i < length; i += 1) {
|
|
152
|
-
const key = keys[i]
|
|
153
|
-
defineLazyGetter(
|
|
154
|
-
object,
|
|
155
|
-
key,
|
|
156
|
-
createLazyGetter(key, getterDefObj[key], stats)
|
|
157
|
-
)
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
return object
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
let _localeCompare
|
|
164
|
-
/**
|
|
165
|
-
* Compare two entry arrays by their keys for sorting.
|
|
166
|
-
* @param {[any, any]} a - First entry tuple.
|
|
167
|
-
* @param {[any, any]} b - Second entry tuple.
|
|
168
|
-
* @returns {number} Comparison result for sorting.
|
|
169
|
-
* @private
|
|
170
|
-
*/
|
|
171
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
172
|
-
function entryKeyComparator(a, b) {
|
|
173
|
-
if (_localeCompare === undefined) {
|
|
174
|
-
const sorts = /*@__PURE__*/ require('./sorts')
|
|
175
|
-
_localeCompare = sorts.localeCompare
|
|
176
|
-
}
|
|
177
|
-
const keyA = a[0]
|
|
178
|
-
const keyB = b[0]
|
|
179
|
-
const strKeyA = typeof keyA === 'string' ? keyA : String(keyA)
|
|
180
|
-
const strKeyB = typeof keyB === 'string' ? keyB : String(keyB)
|
|
181
|
-
return _localeCompare(strKeyA, strKeyB)
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Get the enumerable own property keys of an object.
|
|
186
|
-
* @param {any} obj - The object to get keys from.
|
|
187
|
-
* @returns {string[]} Array of property keys, or empty array if not an object.
|
|
188
|
-
*/
|
|
189
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
190
|
-
function getKeys(obj) {
|
|
191
|
-
return isObject(obj) ? ObjectKeys(obj) : []
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Get an own property value from an object safely.
|
|
196
|
-
* @param {any} obj - The object to get the property from.
|
|
197
|
-
* @param {string | symbol} propKey - The property key.
|
|
198
|
-
* @returns {any} The property value or undefined.
|
|
199
|
-
*/
|
|
200
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
201
|
-
function getOwn(obj, propKey) {
|
|
202
|
-
if (obj === null || obj === undefined) {
|
|
203
|
-
return undefined
|
|
204
|
-
}
|
|
205
|
-
return ObjectHasOwn(obj, propKey) ? obj[propKey] : undefined
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Get all own property values from an object.
|
|
210
|
-
* @param {any} obj - The object to get values from.
|
|
211
|
-
* @returns {any[]} Array of property values.
|
|
212
|
-
*/
|
|
213
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
214
|
-
function getOwnPropertyValues(obj) {
|
|
215
|
-
if (obj === null || obj === undefined) {
|
|
216
|
-
return []
|
|
217
|
-
}
|
|
218
|
-
const keys = ObjectGetOwnPropertyNames(obj)
|
|
219
|
-
const { length } = keys
|
|
220
|
-
const values = Array(length)
|
|
221
|
-
for (let i = 0; i < length; i += 1) {
|
|
222
|
-
values[i] = obj[keys[i]]
|
|
223
|
-
}
|
|
224
|
-
return values
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Check if an object has any enumerable own properties.
|
|
229
|
-
* @param {any} obj - The object to check.
|
|
230
|
-
* @returns {boolean} True if the object has at least one own property.
|
|
231
|
-
*/
|
|
232
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
233
|
-
function hasKeys(obj) {
|
|
234
|
-
if (obj === null || obj === undefined) {
|
|
235
|
-
return false
|
|
236
|
-
}
|
|
237
|
-
for (const key in obj) {
|
|
238
|
-
if (ObjectHasOwn(obj, key)) {
|
|
239
|
-
return true
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
return false
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* Check if an object has an own property.
|
|
247
|
-
* @param {any} obj - The object to check.
|
|
248
|
-
* @param {string | symbol} propKey - The property key.
|
|
249
|
-
* @returns {boolean} True if the object has the own property.
|
|
250
|
-
*/
|
|
251
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
252
|
-
function hasOwn(obj, propKey) {
|
|
253
|
-
if (obj === null || obj === undefined) {
|
|
254
|
-
return false
|
|
255
|
-
}
|
|
256
|
-
return ObjectHasOwn(obj, propKey)
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Check if a value is an object (including arrays).
|
|
261
|
-
* @param {any} value - The value to check.
|
|
262
|
-
* @returns {boolean} True if the value is an object.
|
|
263
|
-
*/
|
|
264
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
265
|
-
function isObject(value) {
|
|
266
|
-
return value !== null && typeof value === 'object'
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
* Check if a value is a plain object (not an array).
|
|
271
|
-
* @param {any} value - The value to check.
|
|
272
|
-
* @returns {boolean} True if the value is a plain object.
|
|
273
|
-
*/
|
|
274
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
275
|
-
function isObjectObject(value) {
|
|
276
|
-
return value !== null && typeof value === 'object' && !ArrayIsArray(value)
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* Get all own property entries (key-value pairs) from an object.
|
|
281
|
-
* @param {any} obj - The object to get entries from.
|
|
282
|
-
* @returns {Array<[string | symbol, any]>} Array of [key, value] tuples.
|
|
283
|
-
*/
|
|
284
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
285
|
-
function objectEntries(obj) {
|
|
286
|
-
if (obj === null || obj === undefined) {
|
|
287
|
-
return []
|
|
288
|
-
}
|
|
289
|
-
const keys = ReflectOwnKeys(obj)
|
|
290
|
-
const { length } = keys
|
|
291
|
-
const entries = Array(length)
|
|
292
|
-
for (let i = 0; i < length; i += 1) {
|
|
293
|
-
const key = keys[i]
|
|
294
|
-
entries[i] = [key, obj[key]]
|
|
295
|
-
}
|
|
296
|
-
return entries
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
* Deep merge source object into target object.
|
|
301
|
-
* @param {any} target - The target object to merge into.
|
|
302
|
-
* @param {any} source - The source object to merge from.
|
|
303
|
-
* @returns {any} The modified target object.
|
|
304
|
-
*/
|
|
305
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
306
|
-
function merge(target, source) {
|
|
307
|
-
if (!isObject(target) || !isObject(source)) {
|
|
308
|
-
return target
|
|
309
|
-
}
|
|
310
|
-
const LOOP_SENTINEL = /*@__PURE__*/ require('./constants/loop-sentinel')
|
|
311
|
-
const queue = [[target, source]]
|
|
312
|
-
let pos = 0
|
|
313
|
-
let { length: queueLength } = queue
|
|
314
|
-
while (pos < queueLength) {
|
|
315
|
-
if (pos === LOOP_SENTINEL) {
|
|
316
|
-
throw new Error('Detected infinite loop in object crawl of merge')
|
|
317
|
-
}
|
|
318
|
-
const { 0: currentTarget, 1: currentSource } = queue[pos++]
|
|
319
|
-
const isSourceArray = ArrayIsArray(currentSource)
|
|
320
|
-
if (ArrayIsArray(currentTarget)) {
|
|
321
|
-
if (isSourceArray) {
|
|
322
|
-
const seen = new Set(currentTarget)
|
|
323
|
-
for (let i = 0, { length } = currentSource; i < length; i += 1) {
|
|
324
|
-
const item = currentSource[i]
|
|
325
|
-
if (!seen.has(item)) {
|
|
326
|
-
currentTarget.push(item)
|
|
327
|
-
seen.add(item)
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
continue
|
|
332
|
-
}
|
|
333
|
-
if (isSourceArray) {
|
|
334
|
-
continue
|
|
335
|
-
}
|
|
336
|
-
const keys = ReflectOwnKeys(currentSource)
|
|
337
|
-
for (let i = 0, { length } = keys; i < length; i += 1) {
|
|
338
|
-
const key = keys[i]
|
|
339
|
-
const srcVal = currentSource[key]
|
|
340
|
-
const targetVal = currentTarget[key]
|
|
341
|
-
if (ArrayIsArray(srcVal)) {
|
|
342
|
-
if (ArrayIsArray(targetVal)) {
|
|
343
|
-
const seen = new Set(targetVal)
|
|
344
|
-
for (let i = 0, { length } = srcVal; i < length; i += 1) {
|
|
345
|
-
const item = srcVal[i]
|
|
346
|
-
if (!seen.has(item)) {
|
|
347
|
-
targetVal.push(item)
|
|
348
|
-
seen.add(item)
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
} else {
|
|
352
|
-
currentTarget[key] = srcVal
|
|
353
|
-
}
|
|
354
|
-
} else if (isObject(srcVal)) {
|
|
355
|
-
if (isObject(targetVal) && !ArrayIsArray(targetVal)) {
|
|
356
|
-
queue[queueLength++] = [targetVal, srcVal]
|
|
357
|
-
} else {
|
|
358
|
-
currentTarget[key] = srcVal
|
|
359
|
-
}
|
|
360
|
-
} else {
|
|
361
|
-
currentTarget[key] = srcVal
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
return target
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
/**
|
|
369
|
-
* Convert an object to a new object with sorted keys.
|
|
370
|
-
* @param {Object} obj - The object to sort.
|
|
371
|
-
* @returns {Object} A new object with keys in sorted order.
|
|
372
|
-
*/
|
|
373
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
374
|
-
function toSortedObject(obj) {
|
|
375
|
-
return toSortedObjectFromEntries(objectEntries(obj))
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
/**
|
|
379
|
-
* Create an object from entries with sorted keys.
|
|
380
|
-
* @param {Iterable<[string | symbol, any]>} entries - The entries to create an object from.
|
|
381
|
-
* @returns {Object} A new object with keys in sorted order.
|
|
382
|
-
*/
|
|
383
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
384
|
-
function toSortedObjectFromEntries(entries) {
|
|
385
|
-
const otherEntries = []
|
|
386
|
-
const symbolEntries = []
|
|
387
|
-
// Use for-of to work with entries iterators.
|
|
388
|
-
for (const entry of entries) {
|
|
389
|
-
if (typeof entry[0] === 'symbol') {
|
|
390
|
-
symbolEntries.push(entry)
|
|
391
|
-
} else {
|
|
392
|
-
otherEntries.push(entry)
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
if (!otherEntries.length && !symbolEntries.length) {
|
|
396
|
-
return []
|
|
397
|
-
}
|
|
398
|
-
return ObjectFromEntries([
|
|
399
|
-
// The String constructor is safe to use with symbols.
|
|
400
|
-
...symbolEntries.sort(entryKeyComparator),
|
|
401
|
-
...otherEntries.sort(entryKeyComparator)
|
|
402
|
-
])
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
module.exports = {
|
|
406
|
-
createConstantsObject,
|
|
407
|
-
createLazyGetter,
|
|
408
|
-
defineGetter,
|
|
409
|
-
defineLazyGetter,
|
|
410
|
-
defineLazyGetters,
|
|
411
|
-
getKeys,
|
|
412
|
-
getOwn,
|
|
413
|
-
getOwnPropertyValues,
|
|
414
|
-
hasKeys,
|
|
415
|
-
hasOwn,
|
|
416
|
-
isObject,
|
|
417
|
-
isObjectObject,
|
|
418
|
-
merge,
|
|
419
|
-
objectEntries,
|
|
420
|
-
toSortedObject,
|
|
421
|
-
toSortedObjectFromEntries
|
|
422
|
-
}
|