packtory 0.0.8 → 0.0.9
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/artifacts/artifacts-builder.d.ts +7 -5
- package/artifacts/artifacts-builder.d.ts.map +1 -1
- package/artifacts/artifacts-builder.js +47 -18
- package/artifacts/artifacts-builder.js.map +1 -1
- package/bundle-emitter/emitter.d.ts +12 -2
- package/bundle-emitter/emitter.d.ts.map +1 -1
- package/bundle-emitter/emitter.js +11 -6
- package/bundle-emitter/emitter.js.map +1 -1
- package/bundle-emitter/extract-package-tarball.js +1 -2
- package/bundle-emitter/extract-package-tarball.js.map +1 -1
- package/bundle-emitter/publish-settings-bridge.js +133 -0
- package/bundle-emitter/publish-settings-bridge.js.map +1 -0
- package/bundle-emitter/registry-client.d.ts +13 -6
- package/bundle-emitter/registry-client.d.ts.map +1 -1
- package/bundle-emitter/registry-client.js +217 -45
- package/bundle-emitter/registry-client.js.map +1 -1
- package/bundle-emitter/repository-coherence.js +54 -0
- package/bundle-emitter/repository-coherence.js.map +1 -0
- package/bundle-emitter/repository-url-normalizer.js +38 -0
- package/bundle-emitter/repository-url-normalizer.js.map +1 -0
- package/checks/check-runner.js +3 -9
- package/checks/check-runner.js.map +1 -1
- package/checks/rule.js +13 -0
- package/checks/rule.js.map +1 -0
- package/checks/rules/max-bundle-size.js +44 -0
- package/checks/rules/max-bundle-size.js.map +1 -0
- package/checks/rules/no-dev-dependency-imports.js +37 -0
- package/checks/rules/no-dev-dependency-imports.js.map +1 -0
- package/checks/rules/no-duplicated-files.js +102 -27
- package/checks/rules/no-duplicated-files.js.map +1 -1
- package/checks/rules/no-side-effects.js +51 -0
- package/checks/rules/no-side-effects.js.map +1 -0
- package/checks/rules/no-unused-bundle-dependencies.js +33 -0
- package/checks/rules/no-unused-bundle-dependencies.js.map +1 -0
- package/checks/rules/registry.js +17 -0
- package/checks/rules/registry.js.map +1 -0
- package/checks/rules/required-files.js +41 -0
- package/checks/rules/required-files.js.map +1 -0
- package/checks/rules/unique-target-paths.js +34 -0
- package/checks/rules/unique-target-paths.js.map +1 -0
- package/common/clock.d.ts +7 -0
- package/common/clock.d.ts.map +1 -0
- package/common/clock.js +11 -0
- package/common/clock.js.map +1 -0
- package/common/code-files.js +5 -0
- package/common/code-files.js.map +1 -0
- package/config/additional-package-json-attributes-schema.js +7 -0
- package/config/additional-package-json-attributes-schema.js.map +1 -0
- package/config/automatic-versioning-settings.js +7 -0
- package/config/automatic-versioning-settings.js.map +1 -0
- package/config/checks-schema.d.ts +74 -0
- package/config/checks-schema.d.ts.map +1 -0
- package/config/checks-schema.js +27 -0
- package/config/checks-schema.js.map +1 -0
- package/config/common-package-settings-schemas.js +20 -0
- package/config/common-package-settings-schemas.js.map +1 -0
- package/config/config.d.ts +16 -704
- package/config/config.d.ts.map +1 -1
- package/config/config.js +3 -71
- package/config/config.js.map +1 -1
- package/config/dead-code-elimination-settings.d.ts +6 -0
- package/config/dead-code-elimination-settings.d.ts.map +1 -0
- package/config/dead-code-elimination-settings.js +5 -0
- package/config/dead-code-elimination-settings.js.map +1 -0
- package/config/dependency-policy.d.ts +6 -0
- package/config/dependency-policy.d.ts.map +1 -0
- package/config/dependency-policy.js +6 -0
- package/config/dependency-policy.js.map +1 -0
- package/config/main-package-json-schema.js +14 -0
- package/config/main-package-json-schema.js.map +1 -0
- package/config/manual-versioning-settings.js +7 -0
- package/config/manual-versioning-settings.js.map +1 -0
- package/config/optional-package-settings-schema.js +15 -0
- package/config/optional-package-settings-schema.js.map +1 -0
- package/config/package-config.d.ts +49 -0
- package/config/package-config.d.ts.map +1 -0
- package/config/package-config.js +7 -0
- package/config/package-config.js.map +1 -0
- package/config/package-interface.d.ts +34 -0
- package/config/package-interface.d.ts.map +1 -0
- package/config/package-interface.js +26 -0
- package/config/package-interface.js.map +1 -0
- package/config/package-json.d.ts +11 -10
- package/config/package-json.d.ts.map +1 -1
- package/config/package-json.js +11 -19
- package/config/package-json.js.map +1 -1
- package/config/package-schemas.js +10 -0
- package/config/package-schemas.js.map +1 -0
- package/config/packtory-config-schema.js +7 -0
- package/config/packtory-config-schema.js.map +1 -0
- package/config/packtory-config-without-registry-schema.js +32 -0
- package/config/packtory-config-without-registry-schema.js.map +1 -0
- package/config/per-package-settings-schema.js +22 -0
- package/config/per-package-settings-schema.js.map +1 -0
- package/config/publish-settings.d.ts +22 -0
- package/config/publish-settings.d.ts.map +1 -0
- package/config/publish-settings.js +26 -0
- package/config/publish-settings.js.map +1 -0
- package/config/publish-settings.report.js +17 -0
- package/config/publish-settings.report.js.map +1 -0
- package/config/registry-settings.d.ts +83 -1
- package/config/registry-settings.d.ts.map +1 -1
- package/config/registry-settings.js +35 -1
- package/config/registry-settings.js.map +1 -1
- package/config/registry-settings.report.js +41 -0
- package/config/registry-settings.report.js.map +1 -0
- package/config/root.d.ts +7 -0
- package/config/root.d.ts.map +1 -0
- package/config/{entry-point.js → root.js} +2 -2
- package/config/root.js.map +1 -0
- package/config/sbom-settings.js +5 -0
- package/config/sbom-settings.js.map +1 -0
- package/config/validation.d.ts +2 -2
- package/config/validation.d.ts.map +1 -1
- package/config/validation.js +155 -37
- package/config/validation.js.map +1 -1
- package/config/versioning-settings.d.ts.map +1 -1
- package/config/versioning-settings.js +2 -9
- package/config/versioning-settings.js.map +1 -1
- package/dead-code-eliminator/analyzed-bundle.d.ts +27 -0
- package/dead-code-eliminator/analyzed-bundle.d.ts.map +1 -0
- package/dead-code-eliminator/analyzed-bundle.js +8 -0
- package/dead-code-eliminator/analyzed-bundle.js.map +1 -0
- package/dead-code-eliminator/cross-bundle/cross-bundle-seeds.js +126 -0
- package/dead-code-eliminator/cross-bundle/cross-bundle-seeds.js.map +1 -0
- package/dead-code-eliminator/elimination-emitter.js +53 -0
- package/dead-code-eliminator/elimination-emitter.js.map +1 -0
- package/dead-code-eliminator/eliminator.js +141 -0
- package/dead-code-eliminator/eliminator.js.map +1 -0
- package/dead-code-eliminator/load-bundle.js +52 -0
- package/dead-code-eliminator/load-bundle.js.map +1 -0
- package/dead-code-eliminator/reachability/binding-extractor.js +88 -0
- package/dead-code-eliminator/reachability/binding-extractor.js.map +1 -0
- package/dead-code-eliminator/reachability/impure-statements.js +12 -0
- package/dead-code-eliminator/reachability/impure-statements.js.map +1 -0
- package/dead-code-eliminator/reachability/reachability.js +141 -0
- package/dead-code-eliminator/reachability/reachability.js.map +1 -0
- package/dead-code-eliminator/side-effect-classifier.js +289 -0
- package/dead-code-eliminator/side-effect-classifier.js.map +1 -0
- package/dead-code-eliminator/side-effects-field.js +25 -0
- package/dead-code-eliminator/side-effects-field.js.map +1 -0
- package/dead-code-eliminator/transform/atom-translator.js +13 -0
- package/dead-code-eliminator/transform/atom-translator.js.map +1 -0
- package/dead-code-eliminator/transform/declaration-remover.js +92 -0
- package/dead-code-eliminator/transform/declaration-remover.js.map +1 -0
- package/dead-code-eliminator/transform/line-index.js +27 -0
- package/dead-code-eliminator/transform/line-index.js.map +1 -0
- package/dead-code-eliminator/transform/source-map-composer.js +68 -0
- package/dead-code-eliminator/transform/source-map-composer.js.map +1 -0
- package/dependency-scanner/dependency-graph.d.ts +1 -1
- package/dependency-scanner/dependency-graph.d.ts.map +1 -1
- package/dependency-scanner/dependency-graph.js +5 -7
- package/dependency-scanner/dependency-graph.js.map +1 -1
- package/dependency-scanner/external-dependencies.js +2 -2
- package/dependency-scanner/external-dependencies.js.map +1 -1
- package/dependency-scanner/scanner.d.ts +7 -7
- package/dependency-scanner/scanner.d.ts.map +1 -1
- package/dependency-scanner/scanner.js +9 -14
- package/dependency-scanner/scanner.js.map +1 -1
- package/dependency-scanner/source-file-references.js +3 -48
- package/dependency-scanner/source-file-references.js.map +1 -1
- package/dependency-scanner/source-map-file-locator.d.ts.map +1 -1
- package/dependency-scanner/source-map-file-locator.js +10 -3
- package/dependency-scanner/source-map-file-locator.js.map +1 -1
- package/dependency-scanner/typescript-file-host.d.ts +2 -0
- package/dependency-scanner/typescript-file-host.d.ts.map +1 -1
- package/dependency-scanner/typescript-file-host.js +99 -32
- package/dependency-scanner/typescript-file-host.js.map +1 -1
- package/dependency-scanner/typescript-project-analyzer.d.ts +4 -5
- package/dependency-scanner/typescript-project-analyzer.d.ts.map +1 -1
- package/dependency-scanner/typescript-project-analyzer.js +5 -17
- package/dependency-scanner/typescript-project-analyzer.js.map +1 -1
- package/directed-graph/graph.d.ts +1 -1
- package/directed-graph/graph.d.ts.map +1 -1
- package/directed-graph/graph.js +132 -97
- package/directed-graph/graph.js.map +1 -1
- package/file-manager/compare.js +11 -9
- package/file-manager/compare.js.map +1 -1
- package/file-manager/file-manager.d.ts +1 -1
- package/file-manager/file-manager.d.ts.map +1 -1
- package/file-manager/file-manager.js +7 -1
- package/file-manager/file-manager.js.map +1 -1
- package/file-manager/permissions.js +20 -6
- package/file-manager/permissions.js.map +1 -1
- package/linker/linked-bundle.d.ts +5 -3
- package/linker/linked-bundle.d.ts.map +1 -1
- package/linker/linker.d.ts.map +1 -1
- package/linker/linker.js +8 -7
- package/linker/linker.js.map +1 -1
- package/linker/resource-graph.js +5 -8
- package/linker/resource-graph.js.map +1 -1
- package/linker/source-modifier/import-paths.js +1 -12
- package/linker/source-modifier/import-paths.js.map +1 -1
- package/linker/substitute-bundles.js +55 -48
- package/linker/substitute-bundles.js.map +1 -1
- package/linker/substituted-resource-graph.js +5 -8
- package/linker/substituted-resource-graph.js.map +1 -1
- package/npm-oidc-id-token-resolver.js +56 -0
- package/npm-oidc-id-token-resolver.js.map +1 -0
- package/package-surface/modules.js +307 -0
- package/package-surface/modules.js.map +1 -0
- package/package-surface/public-module-usage.js +37 -0
- package/package-surface/public-module-usage.js.map +1 -0
- package/package-surface/surface.d.ts +14 -0
- package/package-surface/surface.d.ts.map +1 -0
- package/package-surface/surface.js +16 -0
- package/package-surface/surface.js.map +1 -0
- package/package.json +13 -9
- package/packages/package-processor.composition.js +127 -0
- package/packages/package-processor.composition.js.map +1 -0
- package/packages/packtory/packtory.entry-point.d.ts +10 -5
- package/packages/packtory/packtory.entry-point.d.ts.map +1 -1
- package/packages/packtory/packtory.entry-point.js +7 -43
- package/packages/packtory/packtory.entry-point.js.map +1 -1
- package/packtory/map-config.d.ts +7 -16
- package/packtory/map-config.d.ts.map +1 -1
- package/packtory/map-config.js +5 -60
- package/packtory/map-config.js.map +1 -1
- package/packtory/normalize-paths.js +2 -2
- package/packtory/normalize-paths.js.map +1 -1
- package/packtory/package-processor-build.js +75 -0
- package/packtory/package-processor-build.js.map +1 -0
- package/packtory/package-processor-publish.d.ts +29 -0
- package/packtory/package-processor-publish.d.ts.map +1 -0
- package/packtory/package-processor-publish.js +134 -0
- package/packtory/package-processor-publish.js.map +1 -0
- package/packtory/package-processor.d.ts +17 -21
- package/packtory/package-processor.d.ts.map +1 -1
- package/packtory/package-processor.js +6 -81
- package/packtory/package-processor.js.map +1 -1
- package/packtory/packtory-publish.js +66 -0
- package/packtory/packtory-publish.js.map +1 -0
- package/packtory/packtory-resolve.js +77 -0
- package/packtory/packtory-resolve.js.map +1 -0
- package/packtory/packtory-results.d.ts +47 -0
- package/packtory/packtory-results.d.ts.map +1 -0
- package/packtory/packtory-results.js +16 -0
- package/packtory/packtory-results.js.map +1 -0
- package/packtory/packtory.d.ts +16 -37
- package/packtory/packtory.d.ts.map +1 -1
- package/packtory/packtory.js +33 -114
- package/packtory/packtory.js.map +1 -1
- package/packtory/prepare-package-options.d.ts +28 -0
- package/packtory/prepare-package-options.d.ts.map +1 -0
- package/packtory/prepare-package-options.js +122 -0
- package/packtory/prepare-package-options.js.map +1 -0
- package/packtory/report-attachment.js +25 -0
- package/packtory/report-attachment.js.map +1 -0
- package/packtory/resolved-package.d.ts +17 -0
- package/packtory/resolved-package.d.ts.map +1 -0
- package/packtory/resolved-package.js +35 -0
- package/packtory/resolved-package.js.map +1 -0
- package/packtory/scheduler.d.ts.map +1 -1
- package/packtory/scheduler.js +17 -15
- package/packtory/scheduler.js.map +1 -1
- package/progress/progress-broadcaster.d.ts +128 -5
- package/progress/progress-broadcaster.d.ts.map +1 -1
- package/progress/progress-broadcaster.js +37 -8
- package/progress/progress-broadcaster.js.map +1 -1
- package/report/artifact-entry-merger.js +22 -0
- package/report/artifact-entry-merger.js.map +1 -0
- package/report/config-redactor.js +27 -0
- package/report/config-redactor.js.map +1 -0
- package/report/decorators.js +68 -0
- package/report/decorators.js.map +1 -0
- package/report/inspectors.js +74 -0
- package/report/inspectors.js.map +1 -0
- package/report/report-aggregator.d.ts +61 -0
- package/report/report-aggregator.d.ts.map +1 -0
- package/report/report-aggregator.js +187 -0
- package/report/report-aggregator.js.map +1 -0
- package/resource-resolver/content.js +14 -0
- package/resource-resolver/content.js.map +1 -1
- package/resource-resolver/resolved-bundle.d.ts +4 -2
- package/resource-resolver/resolved-bundle.d.ts.map +1 -1
- package/resource-resolver/resource-resolve-options.d.ts +12 -5
- package/resource-resolver/resource-resolve-options.d.ts.map +1 -1
- package/resource-resolver/resource-resolve-options.js +14 -0
- package/resource-resolver/resource-resolve-options.js.map +1 -0
- package/resource-resolver/resource-resolver.d.ts +1 -1
- package/resource-resolver/resource-resolver.d.ts.map +1 -1
- package/resource-resolver/resource-resolver.js +37 -22
- package/resource-resolver/resource-resolver.js.map +1 -1
- package/sbom/extract-license.js +12 -0
- package/sbom/extract-license.js.map +1 -0
- package/sbom/license-resolver.d.ts +14 -0
- package/sbom/license-resolver.d.ts.map +1 -0
- package/sbom/license-resolver.js +22 -0
- package/sbom/license-resolver.js.map +1 -0
- package/sbom/sbom-builder.js +68 -0
- package/sbom/sbom-builder.js.map +1 -0
- package/sbom/sbom-file.d.ts +19 -0
- package/sbom/sbom-file.d.ts.map +1 -0
- package/sbom/sbom-file.js +57 -0
- package/sbom/sbom-file.js.map +1 -0
- package/sbom/sbom-serializer.d.ts +6 -0
- package/sbom/sbom-serializer.d.ts.map +1 -0
- package/sbom/sbom-serializer.js +11 -0
- package/sbom/sbom-serializer.js.map +1 -0
- package/sbom/tool-version.js +44 -0
- package/sbom/tool-version.js.map +1 -0
- package/tar/extract-tar.js +28 -3
- package/tar/extract-tar.js.map +1 -1
- package/tar/tarball-builder.d.ts.map +1 -1
- package/tar/tarball-builder.js +10 -7
- package/tar/tarball-builder.js.map +1 -1
- package/version-manager/manager.d.ts +5 -1
- package/version-manager/manager.d.ts.map +1 -1
- package/version-manager/manager.js +9 -1
- package/version-manager/manager.js.map +1 -1
- package/version-manager/manifest/builder.js +52 -6
- package/version-manager/manifest/builder.js.map +1 -1
- package/version-manager/manifest/serialize.js +31 -39
- package/version-manager/manifest/serialize.js.map +1 -1
- package/version-manager/manifest/sort-values.js +17 -0
- package/version-manager/manifest/sort-values.js.map +1 -0
- package/version-manager/specifier-classifier.js +35 -0
- package/version-manager/specifier-classifier.js.map +1 -0
- package/version-manager/specifier-errors.js +44 -0
- package/version-manager/specifier-errors.js.map +1 -0
- package/version-manager/versioned-bundle-dependencies.js +112 -0
- package/version-manager/versioned-bundle-dependencies.js.map +1 -0
- package/version-manager/versioned-bundle-imports.d.ts +5 -0
- package/version-manager/versioned-bundle-imports.d.ts.map +1 -0
- package/version-manager/versioned-bundle-imports.js +75 -0
- package/version-manager/versioned-bundle-imports.js.map +1 -0
- package/version-manager/versioned-bundle.d.ts +16 -8
- package/version-manager/versioned-bundle.d.ts.map +1 -1
- package/version-manager/versioned-bundle.js +48 -62
- package/version-manager/versioned-bundle.js.map +1 -1
- package/config/entry-point.d.ts +0 -7
- package/config/entry-point.d.ts.map +0 -1
- package/config/entry-point.js.map +0 -1
- package/file-manager/sort.js +0 -13
- package/file-manager/sort.js.map +0 -1
- package/list/unique-list.js +0 -5
- package/list/unique-list.js.map +0 -1
- package/version-manager/manifest/builder.d.ts +0 -5
- package/version-manager/manifest/builder.d.ts.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { unique } from 'remeda';
|
|
2
2
|
export function mergeExternalDependencies(dependenciesA, dependenciesB) {
|
|
3
3
|
const mergedDependencies = new Map(dependenciesA.entries());
|
|
4
4
|
for (const dependencyB of dependenciesB.values()) {
|
|
@@ -9,7 +9,7 @@ export function mergeExternalDependencies(dependenciesA, dependenciesB) {
|
|
|
9
9
|
else {
|
|
10
10
|
mergedDependencies.set(dependencyA.name, {
|
|
11
11
|
name: dependencyA.name,
|
|
12
|
-
referencedFrom:
|
|
12
|
+
referencedFrom: unique([...dependencyA.referencedFrom, ...dependencyB.referencedFrom])
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external-dependencies.js","sourceRoot":"","sources":["../../../../source/dependency-scanner/external-dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"external-dependencies.js","sourceRoot":"","sources":["../../../../source/dependency-scanner/external-dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAShC,MAAM,UAAU,yBAAyB,CACrC,aAAmC,EACnC,aAAmC;IAEnC,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAA6B,aAAa,CAAC,OAAO,EAAE,CAAC,CAAC;IAExF,KAAK,MAAM,WAAW,IAAI,aAAa,CAAC,MAAM,EAAE,EAAE,CAAC;QAC/C,MAAM,WAAW,GAAG,kBAAkB,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAE7D,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC5B,kBAAkB,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QAC1D,CAAC;aAAM,CAAC;YACJ,kBAAkB,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE;gBACrC,IAAI,EAAE,WAAW,CAAC,IAAI;gBACtB,cAAc,EAAE,MAAM,CAAC,CAAC,GAAG,WAAW,CAAC,cAAc,EAAE,GAAG,WAAW,CAAC,cAAc,CAAC,CAAC;aACzF,CAAC,CAAC;QACP,CAAC;IACL,CAAC;IAED,OAAO,kBAAkB,CAAC;AAC9B,CAAC"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
+
import type { MainPackageJson } from '../config/package-json.ts';
|
|
1
2
|
import type { SourceMapFileLocator } from './source-map-file-locator.ts';
|
|
2
|
-
import type {
|
|
3
|
+
import type { TypescriptProjectAnalyzer } from './typescript-project-analyzer.ts';
|
|
3
4
|
import { type DependencyGraph } from './dependency-graph.ts';
|
|
4
|
-
type
|
|
5
|
-
readonly
|
|
6
|
-
readonly
|
|
7
|
-
readonly resolveDeclarationFiles
|
|
8
|
-
readonly failOnCompileErrors?: boolean;
|
|
5
|
+
type ScanOptionsInput = {
|
|
6
|
+
readonly mainPackageJson: MainPackageJson;
|
|
7
|
+
readonly includeSourceMapFiles?: boolean;
|
|
8
|
+
readonly resolveDeclarationFiles?: boolean;
|
|
9
9
|
};
|
|
10
10
|
export type DependencyScannerDependencies = {
|
|
11
11
|
readonly sourceMapFileLocator: SourceMapFileLocator;
|
|
12
12
|
readonly typescriptProjectAnalyzer: TypescriptProjectAnalyzer;
|
|
13
13
|
};
|
|
14
14
|
export type DependencyScanner = {
|
|
15
|
-
scan: (entryPointFile: string, folder: string, options
|
|
15
|
+
scan: (entryPointFile: string, folder: string, options: ScanOptionsInput) => Promise<DependencyGraph>;
|
|
16
16
|
};
|
|
17
17
|
export declare function createDependencyScanner(dependencyScannerDependencies: Readonly<DependencyScannerDependencies>): DependencyScanner;
|
|
18
18
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scanner.d.ts","sourceRoot":"","sources":["../../../../source/dependency-scanner/scanner.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"scanner.d.ts","sourceRoot":"","sources":["../../../../source/dependency-scanner/scanner.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,KAAK,EAAE,yBAAyB,EAAqB,MAAM,kCAAkC,CAAC;AACrG,OAAO,EAAuD,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAQlH,KAAK,gBAAgB,GAAG;IACpB,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;IAC1C,QAAQ,CAAC,qBAAqB,CAAC,EAAE,OAAO,CAAC;IACzC,QAAQ,CAAC,uBAAuB,CAAC,EAAE,OAAO,CAAC;CAC9C,CAAC;AAmCF,MAAM,MAAM,6BAA6B,GAAG;IACxC,QAAQ,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;IACpD,QAAQ,CAAC,yBAAyB,EAAE,yBAAyB,CAAC;CACjE,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC5B,IAAI,EAAE,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;CACzG,CAAC;AAEF,wBAAgB,uBAAuB,CACnC,6BAA6B,EAAE,QAAQ,CAAC,6BAA6B,CAAC,GACvE,iBAAiB,CAgEnB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Maybe } from 'true-myth/maybe';
|
|
2
|
-
import {
|
|
2
|
+
import { unique } from 'remeda';
|
|
3
3
|
import { createDependencyGraph } from "./dependency-graph.js";
|
|
4
4
|
function isNodeModulesPath(filePath) {
|
|
5
5
|
return filePath.includes('/node_modules/');
|
|
@@ -8,16 +8,13 @@ function isLocalPath(filePath) {
|
|
|
8
8
|
return !isNodeModulesPath(filePath);
|
|
9
9
|
}
|
|
10
10
|
function extractModuleName(nodeModulePath) {
|
|
11
|
-
const
|
|
11
|
+
const prefix = '/node_modules/';
|
|
12
|
+
const pattern = /\/node_modules\/(?:[^@]+?|(?:@.+?\/.+?))\//;
|
|
12
13
|
const result = pattern.exec(nodeModulePath);
|
|
13
14
|
if (result === null) {
|
|
14
15
|
throw new Error(`Couldn’t find node_modules package name for '${nodeModulePath}'`);
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
-
if (moduleName === undefined) {
|
|
18
|
-
throw new Error(`Couldn’t extract module name from path ${nodeModulePath}`);
|
|
19
|
-
}
|
|
20
|
-
return moduleName;
|
|
17
|
+
return result[0].slice(prefix.length, -1);
|
|
21
18
|
}
|
|
22
19
|
function determineLocalDependencies(dependencies) {
|
|
23
20
|
return dependencies.filter(isLocalPath);
|
|
@@ -25,7 +22,7 @@ function determineLocalDependencies(dependencies) {
|
|
|
25
22
|
function determineExternalDependencies(dependencies) {
|
|
26
23
|
const modulePaths = dependencies.filter(isNodeModulesPath);
|
|
27
24
|
const moduleNames = modulePaths.map(extractModuleName);
|
|
28
|
-
const uniqueModuleNames =
|
|
25
|
+
const uniqueModuleNames = unique(moduleNames);
|
|
29
26
|
return uniqueModuleNames;
|
|
30
27
|
}
|
|
31
28
|
export function createDependencyScanner(dependencyScannerDependencies) {
|
|
@@ -56,19 +53,17 @@ export function createDependencyScanner(dependencyScannerDependencies) {
|
|
|
56
53
|
}
|
|
57
54
|
}
|
|
58
55
|
return {
|
|
59
|
-
async scan(entryPointFile, folder, options
|
|
60
|
-
const { resolveDeclarationFiles = false, includeSourceMapFiles = false,
|
|
56
|
+
async scan(entryPointFile, folder, options) {
|
|
57
|
+
const { resolveDeclarationFiles = false, includeSourceMapFiles = false, mainPackageJson } = options;
|
|
61
58
|
const scanOptions = {
|
|
62
59
|
includeSourceMapFiles,
|
|
63
60
|
resolveDeclarationFiles,
|
|
64
|
-
|
|
65
|
-
failOnCompileErrors
|
|
61
|
+
mainPackageJson
|
|
66
62
|
};
|
|
67
63
|
const graph = createDependencyGraph();
|
|
68
64
|
const project = typescriptProjectAnalyzer.analyzeProject(folder, {
|
|
69
65
|
resolveDeclarationFiles: scanOptions.resolveDeclarationFiles,
|
|
70
|
-
|
|
71
|
-
moduleResolution: scanOptions.moduleResolution
|
|
66
|
+
mainPackageJson: scanOptions.mainPackageJson
|
|
72
67
|
});
|
|
73
68
|
await scanDependenciesOfSourceFile(project, entryPointFile, graph, scanOptions);
|
|
74
69
|
return graph;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scanner.js","sourceRoot":"","sources":["../../../../source/dependency-scanner/scanner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"scanner.js","sourceRoot":"","sources":["../../../../source/dependency-scanner/scanner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,OAAO,EAAE,qBAAqB,EAAsD,MAAM,uBAAuB,CAAC;AAclH,SAAS,iBAAiB,CAAC,QAAgB;IACvC,OAAO,QAAQ,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,WAAW,CAAC,QAAgB;IACjC,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;AACxC,CAAC;AAED,SAAS,iBAAiB,CAAC,cAAsB;IAC7C,MAAM,MAAM,GAAG,gBAAgB,CAAC;IAChC,MAAM,OAAO,GAAG,4CAA4C,CAAC;IAE7D,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAE5C,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,gDAAgD,cAAc,GAAG,CAAC,CAAC;IACvF,CAAC;IAED,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;AAC9C,CAAC;AAED,SAAS,0BAA0B,CAAC,YAA+B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,UAAU,EAAE,CAAC;YAClC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;gBAC7B,MAAM,4BAA4B,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;YAC5E,CAAC;YACD,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,cAAc,EAAE,UAAU,CAAC,EAAE,CAAC;gBACnD,KAAK,CAAC,OAAO,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;YAC9C,CAAC;QACL,CAAC;IACL,CAAC;IAED,OAAO;QACH,KAAK,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO;YACtC,MAAM,EAAE,uBAAuB,GAAG,KAAK,EAAE,qBAAqB,GAAG,KAAK,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;YACpG,MAAM,WAAW,GAAG;gBAChB,qBAAqB;gBACrB,uBAAuB;gBACvB,eAAe;aAClB,CAAC;YAEF,MAAM,KAAK,GAAG,qBAAqB,EAAE,CAAC;YACtC,MAAM,OAAO,GAAG,yBAAyB,CAAC,cAAc,CAAC,MAAM,EAAE;gBAC7D,uBAAuB,EAAE,WAAW,CAAC,uBAAuB;gBAC5D,eAAe,EAAE,WAAW,CAAC,eAAe;aAC/C,CAAC,CAAC;YAEH,MAAM,4BAA4B,CAAC,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;YAEhF,OAAO,KAAK,CAAC;QACjB,CAAC;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -1,45 +1,6 @@
|
|
|
1
1
|
import { isBuiltin } from 'node:module';
|
|
2
|
-
import {
|
|
3
|
-
import { ts
|
|
4
|
-
function getReferencedSourceFileFromSymbol(symbol) {
|
|
5
|
-
if (symbol === undefined) {
|
|
6
|
-
return Maybe.nothing();
|
|
7
|
-
}
|
|
8
|
-
const declarations = symbol.getDeclarations();
|
|
9
|
-
return first(declarations)
|
|
10
|
-
.andThen((firstDeclaration) => {
|
|
11
|
-
return firstDeclaration;
|
|
12
|
-
})
|
|
13
|
-
.andThen((firstDeclaration) => {
|
|
14
|
-
if (firstDeclaration.getKind() !== SyntaxKind.SourceFile) {
|
|
15
|
-
return Maybe.nothing();
|
|
16
|
-
}
|
|
17
|
-
if (!ASTNode.isSourceFile(firstDeclaration)) {
|
|
18
|
-
return Maybe.nothing();
|
|
19
|
-
}
|
|
20
|
-
return Maybe.just(firstDeclaration);
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
function getSourceFileFromSymbol(literal, parent, grandParent) {
|
|
24
|
-
if (ASTNode.isImportTypeNode(grandParent)) {
|
|
25
|
-
return getReferencedSourceFileFromSymbol(grandParent.getSymbol());
|
|
26
|
-
}
|
|
27
|
-
if (ASTNode.isCallExpression(parent)) {
|
|
28
|
-
return getReferencedSourceFileFromSymbol(literal.getSymbol());
|
|
29
|
-
}
|
|
30
|
-
return Maybe.nothing();
|
|
31
|
-
}
|
|
32
|
-
function getSourceFileForLiteral(literal) {
|
|
33
|
-
const parent = literal.getParentOrThrow();
|
|
34
|
-
const grandParent = parent.getParent();
|
|
35
|
-
if (ASTNode.isImportDeclaration(parent) || ASTNode.isExportDeclaration(parent)) {
|
|
36
|
-
return parent.getModuleSpecifierSourceFile();
|
|
37
|
-
}
|
|
38
|
-
if (ASTNode.isImportEqualsDeclaration(grandParent)) {
|
|
39
|
-
return grandParent.getExternalModuleReferenceSourceFile();
|
|
40
|
-
}
|
|
41
|
-
return getSourceFileFromSymbol(literal, parent, grandParent).unwrapOr(undefined);
|
|
42
|
-
}
|
|
2
|
+
import { isDefined } from 'remeda';
|
|
3
|
+
import { ts } from 'ts-morph';
|
|
43
4
|
export function resolveSourceFileForLiteral(literal, containingSourceFile) {
|
|
44
5
|
const project = containingSourceFile.getProject();
|
|
45
6
|
const result = ts.resolveModuleName(literal.getLiteralValue(), containingSourceFile.getFilePath(), project.getCompilerOptions(), project.getModuleResolutionHost());
|
|
@@ -49,17 +10,11 @@ export function resolveSourceFileForLiteral(literal, containingSourceFile) {
|
|
|
49
10
|
}
|
|
50
11
|
return undefined;
|
|
51
12
|
}
|
|
52
|
-
function isDefined(value) {
|
|
53
|
-
return value !== undefined;
|
|
54
|
-
}
|
|
55
13
|
export function getReferencedSourceFiles(sourceFile) {
|
|
56
14
|
const importStringLiterals = sourceFile.getImportStringLiterals();
|
|
57
15
|
return importStringLiterals
|
|
58
16
|
.map((literal) => {
|
|
59
|
-
|
|
60
|
-
if (referencedSourceFile === undefined) {
|
|
61
|
-
referencedSourceFile = resolveSourceFileForLiteral(literal, sourceFile);
|
|
62
|
-
}
|
|
17
|
+
const referencedSourceFile = resolveSourceFileForLiteral(literal, sourceFile);
|
|
63
18
|
if (referencedSourceFile === undefined) {
|
|
64
19
|
const importValue = literal.getLiteralValue();
|
|
65
20
|
if (isBuiltin(importValue)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-file-references.js","sourceRoot":"","sources":["../../../../source/dependency-scanner/source-file-references.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"source-file-references.js","sourceRoot":"","sources":["../../../../source/dependency-scanner/source-file-references.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,EAAE,EAAuC,MAAM,UAAU,CAAC;AAEnE,MAAM,UAAU,2BAA2B,CACvC,OAAsB,EACtB,oBAA0C;IAE1C,MAAM,OAAO,GAAG,oBAAoB,CAAC,UAAU,EAAE,CAAC;IAClD,MAAM,MAAM,GAAG,EAAE,CAAC,iBAAiB,CAC/B,OAAO,CAAC,eAAe,EAAE,EACzB,oBAAoB,CAAC,WAAW,EAAE,EAClC,OAAO,CAAC,kBAAkB,EAAE,EAC5B,OAAO,CAAC,uBAAuB,EAAE,CACpC,CAAC;IAEF,IAAI,MAAM,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;QACtC,MAAM,gBAAgB,GAAG,MAAM,CAAC,cAAc,CAAC,gBAAgB,CAAC;QAChE,OAAO,OAAO,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;IACnD,CAAC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,UAAgC;IACrE,MAAM,oBAAoB,GAAG,UAAU,CAAC,uBAAuB,EAAE,CAAC;IAClE,OAAO,oBAAoB;SACtB,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;QACb,MAAM,oBAAoB,GAAG,2BAA2B,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QAE9E,IAAI,oBAAoB,KAAK,SAAS,EAAE,CAAC;YACrC,MAAM,WAAW,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;YAE9C,IAAI,SAAS,CAAC,WAAW,CAAC,EAAE,CAAC;gBACzB,OAAO,SAAS,CAAC;YACrB,CAAC;YAED,MAAM,OAAO,GAAG,6BAA6B,WAAW,cAAc,UAAU,CAAC,WAAW,EAAE,GAAG,CAAC;YAElG,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;QAC7B,CAAC;QAED,OAAO,oBAAoB,CAAC;IAChC,CAAC,CAAC;SACD,MAAM,CAAC,SAAS,CAAC,CAAC;AAC3B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-map-file-locator.d.ts","sourceRoot":"","sources":["../../../../source/dependency-scanner/source-map-file-locator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAEnE,MAAM,MAAM,gCAAgC,GAAG;IAC3C,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IAC/B,MAAM,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;CAC1D,CAAC;
|
|
1
|
+
{"version":3,"file":"source-map-file-locator.d.ts","sourceRoot":"","sources":["../../../../source/dependency-scanner/source-map-file-locator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAEnE,MAAM,MAAM,gCAAgC,GAAG;IAC3C,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IAC/B,MAAM,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;CAC1D,CAAC;AAaF,wBAAgB,0BAA0B,CACtC,YAAY,EAAE,QAAQ,CAAC,gCAAgC,CAAC,GACzD,oBAAoB,CAqBtB"}
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { Maybe } from 'true-myth';
|
|
3
|
-
|
|
3
|
+
function getSourceMappingUrl(fileContent) {
|
|
4
|
+
for (const line of fileContent.split('\n')) {
|
|
5
|
+
if (line.startsWith('//# sourceMappingURL=')) {
|
|
6
|
+
const sourceMappingUrl = line.slice('//# sourceMappingURL='.length);
|
|
7
|
+
return sourceMappingUrl === '' ? undefined : sourceMappingUrl;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
4
12
|
export function createSourceMapFileLocator(dependencies) {
|
|
5
13
|
const { fileManager } = dependencies;
|
|
6
14
|
return {
|
|
7
15
|
async locate(sourceFile) {
|
|
8
16
|
const fileContent = await fileManager.readFile(sourceFile);
|
|
9
|
-
const
|
|
10
|
-
const sourceMappingUrl = result?.groups?.url;
|
|
17
|
+
const sourceMappingUrl = getSourceMappingUrl(fileContent);
|
|
11
18
|
if (sourceMappingUrl !== undefined) {
|
|
12
19
|
const folder = path.dirname(sourceFile);
|
|
13
20
|
const sourceMappingFile = path.join(folder, sourceMappingUrl);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-map-file-locator.js","sourceRoot":"","sources":["../../../../source/dependency-scanner/source-map-file-locator.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAWlC,MAAM,uBAAuB,GAAG,
|
|
1
|
+
{"version":3,"file":"source-map-file-locator.js","sourceRoot":"","sources":["../../../../source/dependency-scanner/source-map-file-locator.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAWlC,SAAS,mBAAmB,CAAC,WAAmB;IAC5C,KAAK,MAAM,IAAI,IAAI,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACzC,IAAI,IAAI,CAAC,UAAU,CAAC,uBAAuB,CAAC,EAAE,CAAC;YAC3C,MAAM,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC;YACpE,OAAO,gBAAgB,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC;QAClE,CAAC;IACL,CAAC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,0BAA0B,CACtC,YAAwD;IAExD,MAAM,EAAE,WAAW,EAAE,GAAG,YAAY,CAAC;IAErC,OAAO;QACH,KAAK,CAAC,MAAM,CAAC,UAAU;YACnB,MAAM,WAAW,GAAG,MAAM,WAAW,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;YAC3D,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,WAAW,CAAC,CAAC;YAE1D,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;gBACjC,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;gBACxC,MAAM,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;gBAC9D,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,WAAW,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;gBAE7E,IAAI,UAAU,EAAE,CAAC;oBACb,OAAO,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;gBACzC,CAAC;YACL,CAAC;YAED,OAAO,KAAK,CAAC,OAAO,EAAE,CAAC;QAC3B,CAAC;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { FileSystemHost } from 'ts-morph';
|
|
2
|
+
import type { MainPackageJson } from '../config/package-json.ts';
|
|
2
3
|
export type FileSystemAdaptersDependencies = {
|
|
3
4
|
fileSystemHost: FileSystemHost;
|
|
4
5
|
};
|
|
5
6
|
export type FileSystemAdapters = {
|
|
6
7
|
fileSystemHostWithoutFilter: FileSystemHost;
|
|
7
8
|
fileSystemHostFilteringDeclarationFiles: FileSystemHost;
|
|
9
|
+
withVirtualPackageJson: (fileSystemHost: FileSystemHost, folder: string, mainPackageJson: MainPackageJson) => FileSystemHost;
|
|
8
10
|
};
|
|
9
11
|
export declare function createFileSystemAdapters(dependencies: FileSystemAdaptersDependencies): FileSystemAdapters;
|
|
10
12
|
//# sourceMappingURL=typescript-file-host.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript-file-host.d.ts","sourceRoot":"","sources":["../../../../source/dependency-scanner/typescript-file-host.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"typescript-file-host.d.ts","sourceRoot":"","sources":["../../../../source/dependency-scanner/typescript-file-host.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAejE,MAAM,MAAM,8BAA8B,GAAG;IACzC,cAAc,EAAE,cAAc,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC7B,2BAA2B,EAAE,cAAc,CAAC;IAC5C,uCAAuC,EAAE,cAAc,CAAC;IACxD,sBAAsB,EAAE,CACpB,cAAc,EAAE,cAAc,EAC9B,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,eAAe,KAC/B,cAAc,CAAC;CACvB,CAAC;AA4FF,wBAAgB,wBAAwB,CAAC,YAAY,EAAE,8BAA8B,GAAG,kBAAkB,CAmDzG"}
|
|
@@ -1,49 +1,116 @@
|
|
|
1
|
-
|
|
1
|
+
import path from 'node:path';
|
|
2
2
|
function isDeclarationFile(filePath) {
|
|
3
3
|
const lowerCasedFilePath = filePath.toLowerCase();
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
return false;
|
|
4
|
+
return (lowerCasedFilePath.endsWith('.d.ts') ||
|
|
5
|
+
lowerCasedFilePath.endsWith('.d.cts') ||
|
|
6
|
+
lowerCasedFilePath.endsWith('.d.mts'));
|
|
10
7
|
}
|
|
11
8
|
function isTypesRootFolder(directoryPath) {
|
|
12
9
|
return directoryPath.endsWith('/node_modules/@types') || directoryPath.includes('/node_modules/@types/');
|
|
13
10
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
11
|
+
const syncMethodNames = {
|
|
12
|
+
fileExists: 'fileExistsSync',
|
|
13
|
+
directoryExists: 'directoryExistsSync',
|
|
14
|
+
readFile: 'readFileSync'
|
|
15
|
+
};
|
|
16
|
+
function bindRequiredMethod(object, methodName, expectedResultDescription, validateResult) {
|
|
17
|
+
const method = Reflect.get(object, methodName);
|
|
18
|
+
if (typeof method !== 'function') {
|
|
19
|
+
throw new TypeError(`Expected ${methodName} to be a function`);
|
|
20
|
+
}
|
|
21
|
+
return (filePath) => {
|
|
22
|
+
const result = Reflect.apply(method, object, [filePath]);
|
|
23
|
+
if (!validateResult(result)) {
|
|
24
|
+
throw new TypeError(`Expected ${methodName} to return ${expectedResultDescription}`);
|
|
27
25
|
}
|
|
28
|
-
|
|
29
|
-
return fileSystemHost.fileExistsSync(filePath);
|
|
26
|
+
return result;
|
|
30
27
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
}
|
|
29
|
+
function isBoolean(value) {
|
|
30
|
+
return typeof value === 'boolean';
|
|
31
|
+
}
|
|
32
|
+
function isString(value) {
|
|
33
|
+
return typeof value === 'string';
|
|
34
|
+
}
|
|
35
|
+
const packageJsonIndentationSpaces = 2;
|
|
36
|
+
function serializeMainPackageJson(mainPackageJson) {
|
|
37
|
+
return JSON.stringify(mainPackageJson, null, packageJsonIndentationSpaces);
|
|
38
|
+
}
|
|
39
|
+
function createVirtualPackageJsonHost(fileSystemHost, folder, mainPackageJson) {
|
|
40
|
+
const packageJsonPath = path.resolve(folder, 'package.json');
|
|
41
|
+
const serializedPackageJson = serializeMainPackageJson(mainPackageJson);
|
|
42
|
+
const fileExistsSync = bindRequiredMethod(fileSystemHost, syncMethodNames.fileExists, 'a boolean', isBoolean);
|
|
43
|
+
const readFileSync = bindRequiredMethod(fileSystemHost, syncMethodNames.readFile, 'a string', isString);
|
|
44
|
+
const virtualFileSystemHost = {
|
|
45
|
+
...fileSystemHost,
|
|
46
|
+
fileExists: async (filePath) => {
|
|
47
|
+
if (path.resolve(filePath) === packageJsonPath) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
return fileSystemHost.fileExists(filePath);
|
|
51
|
+
},
|
|
52
|
+
[syncMethodNames.fileExists]: (filePath) => {
|
|
53
|
+
if (path.resolve(filePath) === packageJsonPath) {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
// eslint-disable-next-line node/no-sync -- the ts-morph host interface requires this synchronous method
|
|
57
|
+
return fileExistsSync(filePath);
|
|
58
|
+
},
|
|
59
|
+
readFile: async (filePath, encoding) => {
|
|
60
|
+
if (path.resolve(filePath) === packageJsonPath) {
|
|
61
|
+
return serializedPackageJson;
|
|
62
|
+
}
|
|
63
|
+
return fileSystemHost.readFile(filePath, encoding);
|
|
64
|
+
},
|
|
65
|
+
[syncMethodNames.readFile]: (filePath) => {
|
|
66
|
+
if (path.resolve(filePath) === packageJsonPath) {
|
|
67
|
+
return serializedPackageJson;
|
|
68
|
+
}
|
|
69
|
+
// eslint-disable-next-line node/no-sync -- the ts-morph host interface requires this synchronous method
|
|
70
|
+
return readFileSync(filePath);
|
|
34
71
|
}
|
|
35
|
-
return fileSystemHost.directoryExists(directoryPath);
|
|
36
72
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
73
|
+
Object.setPrototypeOf(virtualFileSystemHost, fileSystemHost);
|
|
74
|
+
return virtualFileSystemHost;
|
|
75
|
+
}
|
|
76
|
+
export function createFileSystemAdapters(dependencies) {
|
|
77
|
+
const { fileSystemHost } = dependencies;
|
|
78
|
+
const fileExistsSync = bindRequiredMethod(fileSystemHost, syncMethodNames.fileExists, 'a boolean', isBoolean);
|
|
79
|
+
const directoryExistsSync = bindRequiredMethod(fileSystemHost, syncMethodNames.directoryExists, 'a boolean', isBoolean);
|
|
80
|
+
const fileSystemHostFilteringDeclarationFiles = {
|
|
81
|
+
...fileSystemHost,
|
|
82
|
+
fileExists: async (filePath) => {
|
|
83
|
+
if (isDeclarationFile(filePath)) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
return fileSystemHost.fileExists(filePath);
|
|
87
|
+
},
|
|
88
|
+
[syncMethodNames.fileExists]: (filePath) => {
|
|
89
|
+
if (isDeclarationFile(filePath)) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
// eslint-disable-next-line node/no-sync -- the ts-morph host interface requires this synchronous method
|
|
93
|
+
return fileExistsSync(filePath);
|
|
94
|
+
},
|
|
95
|
+
directoryExists: async (directoryPath) => {
|
|
96
|
+
if (isTypesRootFolder(directoryPath)) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
return fileSystemHost.directoryExists(directoryPath);
|
|
100
|
+
},
|
|
101
|
+
[syncMethodNames.directoryExists]: (directoryPath) => {
|
|
102
|
+
if (isTypesRootFolder(directoryPath)) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
// eslint-disable-next-line node/no-sync -- the ts-morph host interface requires this synchronous method
|
|
106
|
+
return directoryExistsSync(directoryPath);
|
|
40
107
|
}
|
|
41
|
-
// eslint-disable-next-line node/no-sync -- we need to provide this method to match the expected interface
|
|
42
|
-
return fileSystemHost.directoryExistsSync(directoryPath);
|
|
43
108
|
};
|
|
109
|
+
Object.setPrototypeOf(fileSystemHostFilteringDeclarationFiles, fileSystemHost);
|
|
44
110
|
return {
|
|
45
111
|
fileSystemHostWithoutFilter: fileSystemHost,
|
|
46
|
-
fileSystemHostFilteringDeclarationFiles
|
|
112
|
+
fileSystemHostFilteringDeclarationFiles,
|
|
113
|
+
withVirtualPackageJson: createVirtualPackageJsonHost
|
|
47
114
|
};
|
|
48
115
|
}
|
|
49
116
|
//# sourceMappingURL=typescript-file-host.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript-file-host.js","sourceRoot":"","sources":["../../../../source/dependency-scanner/typescript-file-host.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"typescript-file-host.js","sourceRoot":"","sources":["../../../../source/dependency-scanner/typescript-file-host.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,SAAS,iBAAiB,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,OAAO,KAAK,CAAC;YACjB,CAAC;YAED,wGAAwG;YACxG,OAAO,cAAc,CAAC,QAAQ,CAAC,CAAC;QACpC,CAAC;QACD,eAAe,EAAE,KAAK,EAAE,aAAqB,EAAoB,EAAE;YAC/D,IAAI,iBAAiB,CAAC,aAAa,CAAC,EAAE,CAAC;gBACnC,OAAO,KAAK,CAAC;YACjB,CAAC;YAED,OAAO,cAAc,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;QACzD,CAAC;QACD,CAAC,eAAe,CAAC,eAAe,CAAC,EAAE,CAAC,aAAqB,EAAW,EAAE;YAClE,IAAI,iBAAiB,CAAC,aAAa,CAAC,EAAE,CAAC;gBACnC,OAAO,KAAK,CAAC;YACjB,CAAC;YAED,wGAAwG;YACxG,OAAO,mBAAmB,CAAC,aAAa,CAAC,CAAC;QAC9C,CAAC;KACJ,CAAC;IACF,MAAM,CAAC,cAAc,CAAC,uCAAuC,EAAE,cAAc,CAAC,CAAC;IAE/E,OAAO;QACH,2BAA2B,EAAE,cAAc;QAC3C,uCAAuC;QACvC,sBAAsB,EAAE,4BAA4B;KACvD,CAAC;AACN,CAAC"}
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { type Project as _Project, type SourceFile } from 'ts-morph';
|
|
2
|
+
import type { MainPackageJson } from '../config/package-json.ts';
|
|
2
3
|
import type { FileSystemAdapters } from './typescript-file-host.ts';
|
|
3
|
-
export type ModuleResolution = 'common-js' | 'module';
|
|
4
4
|
export type TypescriptProjectAnalyzerDependencies = {
|
|
5
5
|
readonly Project: typeof _Project;
|
|
6
6
|
readonly fileSystemAdapters: FileSystemAdapters;
|
|
7
7
|
getReferencedSourceFiles: (sourceFile: Readonly<SourceFile>) => readonly Readonly<SourceFile>[];
|
|
8
8
|
};
|
|
9
|
-
|
|
10
|
-
readonly moduleResolution: ModuleResolution;
|
|
11
|
-
readonly failOnCompileErrors: boolean;
|
|
9
|
+
type AnalyzationOptions = {
|
|
12
10
|
readonly resolveDeclarationFiles: boolean;
|
|
11
|
+
readonly mainPackageJson: MainPackageJson;
|
|
13
12
|
};
|
|
14
13
|
export type TypescriptProject = {
|
|
15
14
|
getReferencedSourceFilePaths: (containingSourceFilePath: string) => readonly string[];
|
|
16
|
-
getSourceFile: (filePath: string) => SourceFile;
|
|
17
15
|
getProject: () => _Project;
|
|
18
16
|
};
|
|
19
17
|
export type TypescriptProjectAnalyzer = {
|
|
@@ -21,4 +19,5 @@ export type TypescriptProjectAnalyzer = {
|
|
|
21
19
|
};
|
|
22
20
|
export declare function getSourcePathFromSourceFile(sourceFile: Readonly<SourceFile>): string;
|
|
23
21
|
export declare function createTypescriptProjectAnalyzer(dependencies: TypescriptProjectAnalyzerDependencies): TypescriptProjectAnalyzer;
|
|
22
|
+
export {};
|
|
24
23
|
//# sourceMappingURL=typescript-project-analyzer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript-project-analyzer.d.ts","sourceRoot":"","sources":["../../../../source/dependency-scanner/typescript-project-analyzer.ts"],"names":[],"mappings":"AACA,OAAO,EAEH,KAAK,OAAO,IAAI,QAAQ,EACxB,KAAK,UAAU,EAGlB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"typescript-project-analyzer.d.ts","sourceRoot":"","sources":["../../../../source/dependency-scanner/typescript-project-analyzer.ts"],"names":[],"mappings":"AACA,OAAO,EAEH,KAAK,OAAO,IAAI,QAAQ,EACxB,KAAK,UAAU,EAGlB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,MAAM,MAAM,qCAAqC,GAAG;IAChD,QAAQ,CAAC,OAAO,EAAE,OAAO,QAAQ,CAAC;IAClC,QAAQ,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;IAChD,wBAAwB,EAAE,CAAC,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,KAAK,SAAS,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;CACnG,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACtB,QAAQ,CAAC,uBAAuB,EAAE,OAAO,CAAC;IAC1C,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC5B,4BAA4B,EAAE,CAAC,wBAAwB,EAAE,MAAM,KAAK,SAAS,MAAM,EAAE,CAAC;IACtF,UAAU,EAAE,MAAM,QAAQ,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACpC,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,KAAK,iBAAiB,CAAC;CACtF,CAAC;AAEF,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,MAAM,CAIpF;AAyBD,wBAAgB,+BAA+B,CAC3C,YAAY,EAAE,qCAAqC,GACpD,yBAAyB,CAwC3B"}
|
|
@@ -5,7 +5,7 @@ export function getSourcePathFromSourceFile(sourceFile) {
|
|
|
5
5
|
return filePath;
|
|
6
6
|
}
|
|
7
7
|
function analyzationOptionsToCompilerOptions(options) {
|
|
8
|
-
const {
|
|
8
|
+
const { resolveDeclarationFiles } = options;
|
|
9
9
|
const compilerOptions = {
|
|
10
10
|
moduleResolution: ModuleResolutionKind.Node16,
|
|
11
11
|
esModuleInterop: true,
|
|
@@ -14,7 +14,8 @@ function analyzationOptionsToCompilerOptions(options) {
|
|
|
14
14
|
allowJs: true,
|
|
15
15
|
noLib: true,
|
|
16
16
|
skipLibCheck: true,
|
|
17
|
-
module:
|
|
17
|
+
module: ModuleKind.Node16,
|
|
18
|
+
resolvePackageJsonImports: true
|
|
18
19
|
};
|
|
19
20
|
if (!resolveDeclarationFiles) {
|
|
20
21
|
compilerOptions.types = [];
|
|
@@ -28,19 +29,13 @@ export function createTypescriptProjectAnalyzer(dependencies) {
|
|
|
28
29
|
analyzeProject(folder, options) {
|
|
29
30
|
const project = new Project({
|
|
30
31
|
compilerOptions: analyzationOptionsToCompilerOptions(options),
|
|
31
|
-
fileSystem: options.resolveDeclarationFiles
|
|
32
|
+
fileSystem: fileSystemAdapters.withVirtualPackageJson(options.resolveDeclarationFiles
|
|
32
33
|
? fileSystemAdapters.fileSystemHostWithoutFilter
|
|
33
|
-
: fileSystemAdapters.fileSystemHostFilteringDeclarationFiles
|
|
34
|
+
: fileSystemAdapters.fileSystemHostFilteringDeclarationFiles, folder, options.mainPackageJson)
|
|
34
35
|
});
|
|
35
36
|
const fileExtension = options.resolveDeclarationFiles ? '.d.ts' : '.js';
|
|
36
37
|
const filesPattern = path.join(folder, `**/*${fileExtension}`);
|
|
37
38
|
project.addSourceFilesAtPaths([filesPattern]);
|
|
38
|
-
if (options.failOnCompileErrors) {
|
|
39
|
-
const diagnostics = project.getPreEmitDiagnostics();
|
|
40
|
-
if (diagnostics.length > 0) {
|
|
41
|
-
throw new Error('Failed to analyze source files');
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
39
|
return {
|
|
45
40
|
getReferencedSourceFilePaths(containingSourceFilePath) {
|
|
46
41
|
const currentSourceFile = project.getSourceFile(containingSourceFilePath);
|
|
@@ -50,13 +45,6 @@ export function createTypescriptProjectAnalyzer(dependencies) {
|
|
|
50
45
|
const referencedSourceFilePaths = getReferencedSourceFiles(currentSourceFile).map(getSourcePathFromSourceFile);
|
|
51
46
|
return referencedSourceFilePaths;
|
|
52
47
|
},
|
|
53
|
-
getSourceFile(filePath) {
|
|
54
|
-
const sourceFile = project.getSourceFile(filePath);
|
|
55
|
-
if (sourceFile === undefined) {
|
|
56
|
-
throw new Error(`Failed to find source file for "${filePath}"`);
|
|
57
|
-
}
|
|
58
|
-
return sourceFile;
|
|
59
|
-
},
|
|
60
48
|
getProject() {
|
|
61
49
|
return project;
|
|
62
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript-project-analyzer.js","sourceRoot":"","sources":["../../../../source/dependency-scanner/typescript-project-analyzer.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACH,UAAU,EAGV,oBAAoB,EAEvB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"typescript-project-analyzer.js","sourceRoot":"","sources":["../../../../source/dependency-scanner/typescript-project-analyzer.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACH,UAAU,EAGV,oBAAoB,EAEvB,MAAM,UAAU,CAAC;AAwBlB,MAAM,UAAU,2BAA2B,CAAC,UAAgC;IACxE,MAAM,QAAQ,GAAG,UAAU,CAAC,WAAW,EAAE,CAAC;IAE1C,OAAO,QAAQ,CAAC;AACpB,CAAC;AAED,SAAS,mCAAmC,CAAC,OAA2B;IACpE,MAAM,EAAE,uBAAuB,EAAE,GAAG,OAAO,CAAC;IAE5C,MAAM,eAAe,GAAoB;QACrC,gBAAgB,EAAE,oBAAoB,CAAC,MAAM;QAC7C,eAAe,EAAE,IAAI;QACrB,oBAAoB,EAAE,CAAC;QACvB,MAAM,EAAE,IAAI;QACZ,OAAO,EAAE,IAAI;QACb,KAAK,EAAE,IAAI;QACX,YAAY,EAAE,IAAI;QAClB,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,yBAAyB,EAAE,IAAI;KAClC,CAAC;IAEF,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAC3B,eAAe,CAAC,KAAK,GAAG,EAAE,CAAC;QAC3B,eAAe,CAAC,SAAS,GAAG,EAAE,CAAC;IACnC,CAAC;IAED,OAAO,eAAe,CAAC;AAC3B,CAAC;AAED,MAAM,UAAU,+BAA+B,CAC3C,YAAmD;IAEnD,MAAM,EAAE,kBAAkB,EAAE,OAAO,EAAE,wBAAwB,EAAE,GAAG,YAAY,CAAC;IAE/E,OAAO;QACH,cAAc,CAAC,MAAM,EAAE,OAAO;YAC1B,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC;gBACxB,eAAe,EAAE,mCAAmC,CAAC,OAAO,CAAC;gBAC7D,UAAU,EAAE,kBAAkB,CAAC,sBAAsB,CACjD,OAAO,CAAC,uBAAuB;oBAC3B,CAAC,CAAC,kBAAkB,CAAC,2BAA2B;oBAChD,CAAC,CAAC,kBAAkB,CAAC,uCAAuC,EAChE,MAAM,EACN,OAAO,CAAC,eAAe,CAC1B;aACJ,CAAC,CAAC;YAEH,MAAM,aAAa,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;YACxE,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,aAAa,EAAE,CAAC,CAAC;YAC/D,OAAO,CAAC,qBAAqB,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;YAE9C,OAAO;gBACH,4BAA4B,CAAC,wBAAwB;oBACjD,MAAM,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC,wBAAwB,CAAC,CAAC;oBAE1E,IAAI,iBAAiB,KAAK,SAAS,EAAE,CAAC;wBAClC,OAAO,EAAE,CAAC;oBACd,CAAC;oBAED,MAAM,yBAAyB,GAC3B,wBAAwB,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;oBAEjF,OAAO,yBAAyB,CAAC;gBACrC,CAAC;gBAED,UAAU;oBACN,OAAO,OAAO,CAAC;gBACnB,CAAC;aACJ,CAAC;QACN,CAAC;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -5,7 +5,7 @@ type GraphNode<TId extends GraphNodeId, TData> = {
|
|
|
5
5
|
readonly adjacentNodeIds: Set<TId>;
|
|
6
6
|
readonly incomingEdges: number;
|
|
7
7
|
};
|
|
8
|
-
|
|
8
|
+
type GraphEdge<TId extends GraphNodeId> = {
|
|
9
9
|
readonly from: TId;
|
|
10
10
|
readonly to: TId;
|
|
11
11
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../../../source/directed-graph/graph.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../../../source/directed-graph/graph.ts"],"names":[],"mappings":"AACA,KAAK,WAAW,GAAG,MAAM,GAAG,MAAM,CAAC;AAEnC,KAAK,SAAS,CAAC,GAAG,SAAS,WAAW,EAAE,KAAK,IAAI;IAC7C,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC;IACjB,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,eAAe,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IACnC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAClC,CAAC;AAEF,KAAK,SAAS,CAAC,GAAG,SAAS,WAAW,IAAI;IACtC,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC;IACnB,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC;CACpB,CAAC;AAEF,KAAK,OAAO,CAAC,GAAG,SAAS,WAAW,EAAE,KAAK,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,SAAS,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,KAAK,IAAI,CAAC;AAE/F,MAAM,MAAM,aAAa,CAAC,GAAG,SAAS,WAAW,EAAE,KAAK,IAAI;IACxD,OAAO,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,KAAK,IAAI,CAAC;IACxC,OAAO,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC;IAClD,UAAU,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC;IACrD,OAAO,EAAE,CAAC,EAAE,EAAE,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