@proteinjs/reflection-build 2.0.2 → 2.1.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 +24 -0
- package/dist/src/ReflectionDoctor.d.ts +6 -1
- package/dist/src/ReflectionDoctor.js +53 -51
- package/dist/src/ReflectionDoctor.js.map +1 -1
- package/dist/src/codegen/CanonicalSourceGraph.d.ts +22 -0
- package/dist/src/codegen/CanonicalSourceGraph.js +60 -0
- package/dist/src/codegen/CanonicalSourceGraph.js.map +1 -0
- package/dist/src/codegen/writeGeneratedIndex.d.ts +12 -3
- package/dist/src/codegen/writeGeneratedIndex.js +21 -13
- package/dist/src/codegen/writeGeneratedIndex.js.map +1 -1
- package/dist/src/parser/PackageSourceFiles.d.ts +30 -0
- package/dist/src/parser/PackageSourceFiles.js +151 -0
- package/dist/src/parser/PackageSourceFiles.js.map +1 -0
- package/dist/src/parser/SharedQualifiedNames.d.ts +43 -0
- package/dist/src/parser/SharedQualifiedNames.js +81 -0
- package/dist/src/parser/SharedQualifiedNames.js.map +1 -0
- package/dist/src/parser/createGraphBuilder.d.ts +6 -1
- package/dist/src/parser/createGraphBuilder.js +16 -31
- package/dist/src/parser/createGraphBuilder.js.map +1 -1
- package/dist/src/parser/createSourceGraph.d.ts +6 -1
- package/dist/src/parser/createSourceGraph.js +23 -38
- package/dist/src/parser/createSourceGraph.js.map +1 -1
- package/dist/test/Class.test.js +1 -1
- package/dist/test/Class.test.js.map +1 -1
- package/dist/test/ExamplePackageFixture.d.ts +47 -0
- package/dist/test/ExamplePackageFixture.js +207 -0
- package/dist/test/ExamplePackageFixture.js.map +1 -0
- package/dist/test/GraphEmitRelativePaths.test.js +1 -1
- package/dist/test/GraphEmitRelativePaths.test.js.map +1 -1
- package/dist/test/PackageSourceFiles.test.d.ts +1 -0
- package/dist/test/PackageSourceFiles.test.js +57 -0
- package/dist/test/PackageSourceFiles.test.js.map +1 -0
- package/dist/test/ReflectionDoctor.test.js +55 -18
- package/dist/test/ReflectionDoctor.test.js.map +1 -1
- package/dist/test/ReproducibleGeneratedIndex.test.d.ts +1 -0
- package/dist/test/ReproducibleGeneratedIndex.test.js +224 -0
- package/dist/test/ReproducibleGeneratedIndex.test.js.map +1 -0
- package/dist/test/SharedQualifiedNames.test.d.ts +1 -0
- package/dist/test/SharedQualifiedNames.test.js +186 -0
- package/dist/test/SharedQualifiedNames.test.js.map +1 -0
- package/dist/test/examples/reproducible/index.d.ts +4 -0
- package/dist/test/examples/reproducible/index.js +21 -0
- package/dist/test/examples/reproducible/index.js.map +1 -0
- package/dist/test/examples/reproducible/src/alpha/Alpha.d.ts +10 -0
- package/dist/test/examples/reproducible/src/alpha/Alpha.js +18 -0
- package/dist/test/examples/reproducible/src/alpha/Alpha.js.map +1 -0
- package/dist/test/examples/reproducible/src/alpha/Defaults.d.ts +2 -0
- package/dist/test/examples/reproducible/src/alpha/Defaults.js +6 -0
- package/dist/test/examples/reproducible/src/alpha/Defaults.js.map +1 -0
- package/dist/test/examples/reproducible/src/beta/Beta.d.ts +5 -0
- package/dist/test/examples/reproducible/src/beta/Beta.js +12 -0
- package/dist/test/examples/reproducible/src/beta/Beta.js.map +1 -0
- package/dist/test/examples/reproducible/src/beta/deep/Gamma.d.ts +4 -0
- package/dist/test/examples/reproducible/src/beta/deep/Gamma.js +11 -0
- package/dist/test/examples/reproducible/src/beta/deep/Gamma.js.map +1 -0
- package/dist/test/examples/reproducible/src/zeta/Defaults.d.ts +2 -0
- package/dist/test/examples/reproducible/src/zeta/Defaults.js +6 -0
- package/dist/test/examples/reproducible/src/zeta/Defaults.js.map +1 -0
- package/dist/test/examples/reproducible/src/zeta/Zeta.d.ts +7 -0
- package/dist/test/examples/reproducible/src/zeta/Zeta.js +18 -0
- package/dist/test/examples/reproducible/src/zeta/Zeta.js.map +1 -0
- package/dist/test/examples/shared-name/index.d.ts +1 -0
- package/dist/test/examples/shared-name/index.js +18 -0
- package/dist/test/examples/shared-name/index.js.map +1 -0
- package/dist/test/examples/shared-name/src/alpha/Widget.d.ts +4 -0
- package/dist/test/examples/shared-name/src/alpha/Widget.js +3 -0
- package/dist/test/examples/shared-name/src/alpha/Widget.js.map +1 -0
- package/dist/test/examples/shared-name/src/beta/Widget.d.ts +3 -0
- package/dist/test/examples/shared-name/src/beta/Widget.js +13 -0
- package/dist/test/examples/shared-name/src/beta/Widget.js.map +1 -0
- package/dist/test/examples/shared-name/src/gamma/Gear.d.ts +7 -0
- package/dist/test/examples/shared-name/src/gamma/Gear.js +5 -0
- package/dist/test/examples/shared-name/src/gamma/Gear.js.map +1 -0
- package/dist/test/examples/shared-name-pruned/index.d.ts +1 -0
- package/dist/test/examples/shared-name-pruned/index.js +18 -0
- package/dist/test/examples/shared-name-pruned/index.js.map +1 -0
- package/dist/test/examples/shared-name-pruned/src/alpha/Limits.d.ts +3 -0
- package/dist/test/examples/shared-name-pruned/src/alpha/Limits.js +6 -0
- package/dist/test/examples/shared-name-pruned/src/alpha/Limits.js.map +1 -0
- package/dist/test/examples/shared-name-pruned/src/alpha/Shape.d.ts +3 -0
- package/dist/test/examples/shared-name-pruned/src/alpha/Shape.js +3 -0
- package/dist/test/examples/shared-name-pruned/src/alpha/Shape.js.map +1 -0
- package/dist/test/examples/shared-name-pruned/src/alpha/Tile.d.ts +7 -0
- package/dist/test/examples/shared-name-pruned/src/alpha/Tile.js +11 -0
- package/dist/test/examples/shared-name-pruned/src/alpha/Tile.js.map +1 -0
- package/dist/test/examples/shared-name-pruned/src/beta/Limits.d.ts +3 -0
- package/dist/test/examples/shared-name-pruned/src/beta/Limits.js +6 -0
- package/dist/test/examples/shared-name-pruned/src/beta/Limits.js.map +1 -0
- package/dist/test/examples/shared-name-pruned/src/beta/Shape.d.ts +3 -0
- package/dist/test/examples/shared-name-pruned/src/beta/Shape.js +3 -0
- package/dist/test/examples/shared-name-pruned/src/beta/Shape.js.map +1 -0
- package/dist/test/examples/source-repository/a/generated/index.js +28 -28
- package/dist/test/examples/source-repository/a/generated/index.js.map +1 -1
- package/dist/test/examples/source-repository/a/src/ExtendsForeignType.d.ts +1 -1
- package/dist/test/examples/source-repository/a/src/ExtendsForeignType.js +5 -5
- package/dist/test/examples/source-repository/a/src/ExtendsForeignType.js.map +1 -1
- package/dist/test/examples/source-repository/b/generated/index.js +3 -3
- package/dist/test/examples/source-repository/b/generated/index.js.map +1 -1
- package/package.json +5 -5
- package/src/ReflectionDoctor.ts +37 -17
- package/src/codegen/CanonicalSourceGraph.ts +50 -0
- package/src/codegen/writeGeneratedIndex.ts +35 -9
- package/src/parser/PackageSourceFiles.ts +66 -0
- package/src/parser/SharedQualifiedNames.ts +76 -0
- package/src/parser/createGraphBuilder.ts +25 -10
- package/src/parser/createSourceGraph.ts +14 -16
- package/test/Class.test.ts +1 -1
- package/test/ExamplePackageFixture.ts +142 -0
- package/test/GraphEmitRelativePaths.test.ts +1 -1
- package/test/PackageSourceFiles.test.ts +42 -0
- package/test/ReflectionDoctor.test.ts +50 -12
- package/test/ReproducibleGeneratedIndex.test.ts +114 -0
- package/test/SharedQualifiedNames.test.ts +89 -0
- package/test/examples/reproducible/index.ts +4 -0
- package/test/examples/reproducible/src/alpha/Alpha.ts +13 -0
- package/test/examples/reproducible/src/alpha/Defaults.ts +4 -0
- package/test/examples/reproducible/src/beta/Beta.ts +7 -0
- package/test/examples/reproducible/src/beta/deep/Gamma.ts +5 -0
- package/test/examples/reproducible/src/zeta/Defaults.ts +4 -0
- package/test/examples/reproducible/src/zeta/Zeta.ts +9 -0
- package/test/examples/shared-name/index.ts +1 -0
- package/test/examples/shared-name/src/alpha/Widget.ts +6 -0
- package/test/examples/shared-name/src/beta/Widget.ts +5 -0
- package/test/examples/shared-name/src/gamma/Gear.ts +9 -0
- package/test/examples/shared-name-pruned/index.ts +1 -0
- package/test/examples/shared-name-pruned/src/alpha/Limits.ts +2 -0
- package/test/examples/shared-name-pruned/src/alpha/Shape.ts +3 -0
- package/test/examples/shared-name-pruned/src/alpha/Tile.ts +9 -0
- package/test/examples/shared-name-pruned/src/beta/Limits.ts +2 -0
- package/test/examples/shared-name-pruned/src/beta/Shape.ts +4 -0
- package/test/examples/source-repository/a/dist/codegen/CanonicalSourceGraph.d.ts +22 -0
- package/test/examples/source-repository/a/dist/codegen/CanonicalSourceGraph.js +60 -0
- package/test/examples/source-repository/a/dist/codegen/CanonicalSourceGraph.js.map +1 -0
- package/test/examples/source-repository/a/dist/codegen/writeGeneratedIndex.d.ts +12 -3
- package/test/examples/source-repository/a/dist/codegen/writeGeneratedIndex.js +21 -13
- package/test/examples/source-repository/a/dist/codegen/writeGeneratedIndex.js.map +1 -1
- package/test/examples/source-repository/a/dist/generated/index.js +28 -28
- package/test/examples/source-repository/a/dist/generated/index.js.map +1 -1
- package/test/examples/source-repository/a/dist/parser/PackageSourceFiles.d.ts +30 -0
- package/test/examples/source-repository/a/dist/parser/PackageSourceFiles.js +151 -0
- package/test/examples/source-repository/a/dist/parser/PackageSourceFiles.js.map +1 -0
- package/test/examples/source-repository/a/dist/parser/SharedQualifiedNames.d.ts +43 -0
- package/test/examples/source-repository/a/dist/parser/SharedQualifiedNames.js +81 -0
- package/test/examples/source-repository/a/dist/parser/SharedQualifiedNames.js.map +1 -0
- package/test/examples/source-repository/a/dist/parser/createGraphBuilder.d.ts +6 -1
- package/test/examples/source-repository/a/dist/parser/createGraphBuilder.js +16 -31
- package/test/examples/source-repository/a/dist/parser/createGraphBuilder.js.map +1 -1
- package/test/examples/source-repository/a/dist/parser/createSourceGraph.d.ts +6 -1
- package/test/examples/source-repository/a/dist/parser/createSourceGraph.js +23 -38
- package/test/examples/source-repository/a/dist/parser/createSourceGraph.js.map +1 -1
- package/test/examples/source-repository/a/dist/src/ExtendsForeignType.d.ts +1 -1
- package/test/examples/source-repository/a/dist/src/ExtendsForeignType.js +5 -5
- package/test/examples/source-repository/a/dist/src/ExtendsForeignType.js.map +1 -1
- package/test/examples/source-repository/a/generated/index.ts +44 -44
- package/test/examples/source-repository/a/node_modules/.package-lock.json +13 -13
- package/test/examples/source-repository/a/node_modules/@proteinjs/util/CHANGELOG.md +8 -0
- package/test/examples/source-repository/a/node_modules/@proteinjs/util/LICENSE +21 -0
- package/test/examples/source-repository/a/node_modules/@proteinjs/util/package.json +3 -2
- package/test/examples/source-repository/a/node_modules/@proteinjs/util/tsconfig.json +1 -0
- package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/CHANGELOG.md +63 -0
- package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/LICENSE +21 -0
- package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/dist/index.d.ts +1 -0
- package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/dist/index.js +1 -0
- package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/dist/index.js.map +1 -1
- package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/dist/src/ArgsMap.js +7 -4
- package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/dist/src/ArgsMap.js.map +1 -1
- package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/dist/src/Fs.js +16 -12
- package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/dist/src/Fs.js.map +1 -1
- package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/dist/src/PackageUtil.d.ts +59 -13
- package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/dist/src/PackageUtil.js +119 -80
- package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/dist/src/PackageUtil.js.map +1 -1
- package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/dist/src/WorkspaceDeclaration.d.ts +91 -0
- package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/dist/src/WorkspaceDeclaration.js +608 -0
- package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/dist/src/WorkspaceDeclaration.js.map +1 -0
- package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/dist/src/promisifiedFs.d.ts +0 -1
- package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/index.ts +1 -0
- package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/package.json +4 -3
- package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/src/ArgsMap.ts +7 -4
- package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/src/Fs.ts +12 -9
- package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/src/PackageUtil.ts +92 -38
- package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/src/WorkspaceDeclaration.ts +340 -0
- package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/test/ArgsMap.test.ts +35 -0
- package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/test/Fs.getFilePathsMatchingGlob.test.ts +70 -0
- package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/test/PackageUtil.getLocalPackageMap.test.ts +107 -0
- package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/test/PackageUtil.pathKeyedIdentity.test.ts +169 -0
- package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/test/WorkspaceDeclaration.test.ts +174 -0
- package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/tsconfig.json +1 -0
- package/test/examples/source-repository/a/package-lock.json +16 -16
- package/test/examples/source-repository/a/package.json +3 -3
- package/test/examples/source-repository/a/src/ExtendsForeignType.ts +1 -1
- package/test/examples/source-repository/b/dist/codegen/CanonicalSourceGraph.d.ts +22 -0
- package/test/examples/source-repository/b/dist/codegen/CanonicalSourceGraph.js +60 -0
- package/test/examples/source-repository/b/dist/codegen/CanonicalSourceGraph.js.map +1 -0
- package/test/examples/source-repository/b/dist/codegen/writeGeneratedIndex.d.ts +12 -3
- package/test/examples/source-repository/b/dist/codegen/writeGeneratedIndex.js +21 -13
- package/test/examples/source-repository/b/dist/codegen/writeGeneratedIndex.js.map +1 -1
- package/test/examples/source-repository/b/dist/generated/index.js +3 -3
- package/test/examples/source-repository/b/dist/generated/index.js.map +1 -1
- package/test/examples/source-repository/b/dist/parser/PackageSourceFiles.d.ts +30 -0
- package/test/examples/source-repository/b/dist/parser/PackageSourceFiles.js +151 -0
- package/test/examples/source-repository/b/dist/parser/PackageSourceFiles.js.map +1 -0
- package/test/examples/source-repository/b/dist/parser/SharedQualifiedNames.d.ts +43 -0
- package/test/examples/source-repository/b/dist/parser/SharedQualifiedNames.js +81 -0
- package/test/examples/source-repository/b/dist/parser/SharedQualifiedNames.js.map +1 -0
- package/test/examples/source-repository/b/dist/parser/createGraphBuilder.d.ts +6 -1
- package/test/examples/source-repository/b/dist/parser/createGraphBuilder.js +16 -31
- package/test/examples/source-repository/b/dist/parser/createGraphBuilder.js.map +1 -1
- package/test/examples/source-repository/b/dist/parser/createSourceGraph.d.ts +6 -1
- package/test/examples/source-repository/b/dist/parser/createSourceGraph.js +23 -38
- package/test/examples/source-repository/b/dist/parser/createSourceGraph.js.map +1 -1
- package/test/examples/source-repository/b/generated/index.ts +6 -6
- package/test/examples/source-repository/b/node_modules/.package-lock.json +10 -10
- package/test/examples/source-repository/b/node_modules/@proteinjs/util/CHANGELOG.md +8 -0
- package/test/examples/source-repository/b/node_modules/@proteinjs/util/LICENSE +21 -0
- package/test/examples/source-repository/b/node_modules/@proteinjs/util/package.json +3 -2
- package/test/examples/source-repository/b/node_modules/@proteinjs/util/tsconfig.json +1 -0
- package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/CHANGELOG.md +63 -0
- package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/LICENSE +21 -0
- package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/dist/index.d.ts +1 -0
- package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/dist/index.js +1 -0
- package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/dist/index.js.map +1 -1
- package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/dist/src/ArgsMap.js +7 -4
- package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/dist/src/ArgsMap.js.map +1 -1
- package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/dist/src/Fs.js +16 -12
- package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/dist/src/Fs.js.map +1 -1
- package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/dist/src/PackageUtil.d.ts +59 -13
- package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/dist/src/PackageUtil.js +119 -80
- package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/dist/src/PackageUtil.js.map +1 -1
- package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/dist/src/WorkspaceDeclaration.d.ts +91 -0
- package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/dist/src/WorkspaceDeclaration.js +608 -0
- package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/dist/src/WorkspaceDeclaration.js.map +1 -0
- package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/dist/src/promisifiedFs.d.ts +0 -1
- package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/index.ts +1 -0
- package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/package.json +4 -3
- package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/src/ArgsMap.ts +7 -4
- package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/src/Fs.ts +12 -9
- package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/src/PackageUtil.ts +92 -38
- package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/src/WorkspaceDeclaration.ts +340 -0
- package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/test/ArgsMap.test.ts +35 -0
- package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/test/Fs.getFilePathsMatchingGlob.test.ts +70 -0
- package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/test/PackageUtil.getLocalPackageMap.test.ts +107 -0
- package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/test/PackageUtil.pathKeyedIdentity.test.ts +169 -0
- package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/test/WorkspaceDeclaration.test.ts +174 -0
- package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/tsconfig.json +1 -0
- package/test/examples/source-repository/b/package-lock.json +13 -13
- package/test/examples/source-repository/b/package.json +3 -3
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Graph } from '@dagrejs/graphlib';
|
|
2
|
+
/** A qualified name that two or more source files declare. */
|
|
3
|
+
export interface SharedQualifiedName {
|
|
4
|
+
qualifiedName: string;
|
|
5
|
+
/** Every file that declares it: package-relative, `/`-separated, in the order the sources parse. */
|
|
6
|
+
filePaths: string[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* One qualified name, one declaring file, for every name that reaches the generated index.
|
|
10
|
+
*
|
|
11
|
+
* The source graph holds ONE node per qualified name. When two files export the same name, the
|
|
12
|
+
* declaration parsed last takes the node (its value, its `filePath`, and so the class or value
|
|
13
|
+
* the source link hands `objects()`), while the parent edges of both stay on it. The other
|
|
14
|
+
* declaration leaves no trace, so the emitted graph cannot show the collision. This class records
|
|
15
|
+
* every file that declares each name while the graph is built, and names the collisions that are
|
|
16
|
+
* left in a graph.
|
|
17
|
+
*
|
|
18
|
+
* The rule applies to the graph AFTER `removeNonLoadables`, never before. Types, consts and
|
|
19
|
+
* functions exported under one name by two files are ordinary TypeScript: while none of them is
|
|
20
|
+
* Loadable, the prune drops the name and it never reaches the index. A name that survives the
|
|
21
|
+
* prune is an authoring error the graph cannot represent, and the build refuses it rather than
|
|
22
|
+
* ship the last file's declaration.
|
|
23
|
+
*
|
|
24
|
+
* Order: files are kept in the order they are recorded, which is the parse order —
|
|
25
|
+
* `PackageSourceFiles.list()` order, package-relative path by code unit — and names in the order
|
|
26
|
+
* their first declaration was recorded. Both are the same on every machine.
|
|
27
|
+
*/
|
|
28
|
+
export declare class SharedQualifiedNames {
|
|
29
|
+
private readonly filePathsByName;
|
|
30
|
+
/**
|
|
31
|
+
* The build's refusal: one error naming the package and, for each shared name, every file that
|
|
32
|
+
* declares it. Returns without effect when `sharedNames` is empty.
|
|
33
|
+
*/
|
|
34
|
+
static refuse(packageName: string, sharedNames: SharedQualifiedName[]): void;
|
|
35
|
+
/** The names left in `prunedGraph` that two or more files declare. */
|
|
36
|
+
in(prunedGraph: Graph): SharedQualifiedName[];
|
|
37
|
+
/**
|
|
38
|
+
* Records that the package-relative `filePath` declares `qualifiedName`. The graph builder calls
|
|
39
|
+
* this for every declaration it sets on the graph; a file that declares a name twice (a const
|
|
40
|
+
* and a type of one name, say) counts once.
|
|
41
|
+
*/
|
|
42
|
+
record(qualifiedName: string, filePath: string): void;
|
|
43
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SharedQualifiedNames = void 0;
|
|
13
|
+
/**
|
|
14
|
+
* One qualified name, one declaring file, for every name that reaches the generated index.
|
|
15
|
+
*
|
|
16
|
+
* The source graph holds ONE node per qualified name. When two files export the same name, the
|
|
17
|
+
* declaration parsed last takes the node (its value, its `filePath`, and so the class or value
|
|
18
|
+
* the source link hands `objects()`), while the parent edges of both stay on it. The other
|
|
19
|
+
* declaration leaves no trace, so the emitted graph cannot show the collision. This class records
|
|
20
|
+
* every file that declares each name while the graph is built, and names the collisions that are
|
|
21
|
+
* left in a graph.
|
|
22
|
+
*
|
|
23
|
+
* The rule applies to the graph AFTER `removeNonLoadables`, never before. Types, consts and
|
|
24
|
+
* functions exported under one name by two files are ordinary TypeScript: while none of them is
|
|
25
|
+
* Loadable, the prune drops the name and it never reaches the index. A name that survives the
|
|
26
|
+
* prune is an authoring error the graph cannot represent, and the build refuses it rather than
|
|
27
|
+
* ship the last file's declaration.
|
|
28
|
+
*
|
|
29
|
+
* Order: files are kept in the order they are recorded, which is the parse order —
|
|
30
|
+
* `PackageSourceFiles.list()` order, package-relative path by code unit — and names in the order
|
|
31
|
+
* their first declaration was recorded. Both are the same on every machine.
|
|
32
|
+
*/
|
|
33
|
+
var SharedQualifiedNames = /** @class */ (function () {
|
|
34
|
+
function SharedQualifiedNames() {
|
|
35
|
+
this.filePathsByName = new Map();
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The build's refusal: one error naming the package and, for each shared name, every file that
|
|
39
|
+
* declares it. Returns without effect when `sharedNames` is empty.
|
|
40
|
+
*/
|
|
41
|
+
SharedQualifiedNames.refuse = function (packageName, sharedNames) {
|
|
42
|
+
if (sharedNames.length === 0) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
throw new Error(__spreadArray([
|
|
46
|
+
"reflection-build refused ".concat(packageName, ": a name that reaches the generated index is declared in more than one file."),
|
|
47
|
+
'The index holds one declaration per qualified name, so the file parsed last would replace the others without a trace.',
|
|
48
|
+
'Give each declaration its own name (no index was written):'
|
|
49
|
+
], sharedNames.map(function (_a) {
|
|
50
|
+
var qualifiedName = _a.qualifiedName, filePaths = _a.filePaths;
|
|
51
|
+
return " ".concat(qualifiedName, ": ").concat(filePaths.join(', '));
|
|
52
|
+
}), true).join('\n'));
|
|
53
|
+
};
|
|
54
|
+
/** The names left in `prunedGraph` that two or more files declare. */
|
|
55
|
+
SharedQualifiedNames.prototype.in = function (prunedGraph) {
|
|
56
|
+
var shared = [];
|
|
57
|
+
this.filePathsByName.forEach(function (filePaths, qualifiedName) {
|
|
58
|
+
if (filePaths.length > 1 && prunedGraph.hasNode(qualifiedName)) {
|
|
59
|
+
shared.push({ qualifiedName: qualifiedName, filePaths: __spreadArray([], filePaths, true) });
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
return shared;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Records that the package-relative `filePath` declares `qualifiedName`. The graph builder calls
|
|
66
|
+
* this for every declaration it sets on the graph; a file that declares a name twice (a const
|
|
67
|
+
* and a type of one name, say) counts once.
|
|
68
|
+
*/
|
|
69
|
+
SharedQualifiedNames.prototype.record = function (qualifiedName, filePath) {
|
|
70
|
+
var filePaths = this.filePathsByName.get(qualifiedName);
|
|
71
|
+
if (!filePaths) {
|
|
72
|
+
this.filePathsByName.set(qualifiedName, [filePath]);
|
|
73
|
+
}
|
|
74
|
+
else if (!filePaths.includes(filePath)) {
|
|
75
|
+
filePaths.push(filePath);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
return SharedQualifiedNames;
|
|
79
|
+
}());
|
|
80
|
+
exports.SharedQualifiedNames = SharedQualifiedNames;
|
|
81
|
+
//# sourceMappingURL=SharedQualifiedNames.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SharedQualifiedNames.js","sourceRoot":"","sources":["../../../../../../src/parser/SharedQualifiedNames.ts"],"names":[],"mappings":";;;;;;;;;;;;AASA;;;;;;;;;;;;;;;;;;;GAmBG;AACH;IAAA;QACmB,oBAAe,GAAG,IAAI,GAAG,EAAoB,CAAC;IA6CjE,CAAC;IA3CC;;;OAGG;IACI,2BAAM,GAAb,UAAc,WAAmB,EAAE,WAAkC;QACnE,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE;YAC5B,OAAO;SACR;QAED,MAAM,IAAI,KAAK,CACb;YACE,mCAA4B,WAAW,iFAA8E;YACrH,uHAAuH;YACvH,4DAA4D;WACzD,WAAW,CAAC,GAAG,CAAC,UAAC,EAA4B;gBAA1B,aAAa,mBAAA,EAAE,SAAS,eAAA;YAAO,OAAA,YAAK,aAAa,eAAK,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAE;QAA7C,CAA6C,CAAC,QACnG,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;IACJ,CAAC;IAED,sEAAsE;IACtE,iCAAE,GAAF,UAAG,WAAkB;QACnB,IAAM,MAAM,GAA0B,EAAE,CAAC;QACzC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,UAAC,SAAS,EAAE,aAAa;YACpD,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,WAAW,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;gBAC9D,MAAM,CAAC,IAAI,CAAC,EAAE,aAAa,eAAA,EAAE,SAAS,oBAAM,SAAS,OAAC,EAAE,CAAC,CAAC;aAC3D;QACH,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACH,qCAAM,GAAN,UAAO,aAAqB,EAAE,QAAgB;QAC5C,IAAM,SAAS,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QAC1D,IAAI,CAAC,SAAS,EAAE;YACd,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;SACrD;aAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;YACxC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SAC1B;IACH,CAAC;IACH,2BAAC;AAAD,CAAC,AA9CD,IA8CC;AA9CY,oDAAoB"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import * as graphlib from '@dagrejs/graphlib';
|
|
2
2
|
import { File } from '../../modules/typescript-parser';
|
|
3
|
-
|
|
3
|
+
import { SharedQualifiedNames } from './SharedQualifiedNames';
|
|
4
|
+
/**
|
|
5
|
+
* @param sharedNames records the file of every declaration set on the graph: the graph keeps one
|
|
6
|
+
* node per qualified name, so it cannot show a name two files declare
|
|
7
|
+
*/
|
|
8
|
+
export declare function createGraphBuilder(graph: graphlib.Graph, packageJson: any, packageJsonDir: string, sharedNames: SharedQualifiedNames): (parsedFile: File) => Promise<void>;
|
|
@@ -1,27 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -60,7 +37,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
60
37
|
};
|
|
61
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
39
|
exports.createGraphBuilder = void 0;
|
|
63
|
-
var path = __importStar(require("path"));
|
|
64
40
|
var typescript_parser_1 = require("../../modules/typescript-parser");
|
|
65
41
|
var reflection_1 = require("@proteinjs/reflection");
|
|
66
42
|
var util_1 = require("@proteinjs/util");
|
|
@@ -69,15 +45,24 @@ var PackageNameFinder_1 = require("./types/PackageNameFinder");
|
|
|
69
45
|
var createTypeAliasDeclaration_1 = require("./types/createTypeAliasDeclaration");
|
|
70
46
|
var createClassDeclaration_1 = require("./types/createClassDeclaration");
|
|
71
47
|
var createInterfaceDeclaration_1 = require("./types/createInterfaceDeclaration");
|
|
72
|
-
|
|
48
|
+
var PackageSourceFiles_1 = require("./PackageSourceFiles");
|
|
49
|
+
/**
|
|
50
|
+
* @param sharedNames records the file of every declaration set on the graph: the graph keeps one
|
|
51
|
+
* node per qualified name, so it cannot show a name two files declare
|
|
52
|
+
*/
|
|
53
|
+
function createGraphBuilder(graph, packageJson, packageJsonDir, sharedNames) {
|
|
73
54
|
var _this = this;
|
|
74
55
|
var packageName = packageJson.name;
|
|
75
56
|
return function (parsedFile) { return __awaiter(_this, void 0, void 0, function () {
|
|
76
|
-
var filePath, _i, _a, declaration, packageNameFinder, variableDeclaration, typeAliasDeclaration, classDeclaration, _b, _c, parentInterface, _d, _e, parentClass, interfaceDeclaration, _f, _g, parentInterface;
|
|
57
|
+
var filePath, setDeclaration, _i, _a, declaration, packageNameFinder, variableDeclaration, typeAliasDeclaration, classDeclaration, _b, _c, parentInterface, _d, _e, parentClass, interfaceDeclaration, _f, _g, parentInterface;
|
|
77
58
|
return __generator(this, function (_h) {
|
|
78
59
|
switch (_h.label) {
|
|
79
60
|
case 0:
|
|
80
|
-
filePath =
|
|
61
|
+
filePath = PackageSourceFiles_1.PackageSourceFiles.relativePath(packageJsonDir, parsedFile.filePath);
|
|
62
|
+
setDeclaration = function (qualifiedName, value) {
|
|
63
|
+
graph.setNode(qualifiedName, value);
|
|
64
|
+
sharedNames.record(qualifiedName, filePath);
|
|
65
|
+
};
|
|
81
66
|
_i = 0, _a = parsedFile.declarations;
|
|
82
67
|
_h.label = 1;
|
|
83
68
|
case 1:
|
|
@@ -94,7 +79,7 @@ function createGraphBuilder(graph, packageJson, packageJsonDir) {
|
|
|
94
79
|
return [4 /*yield*/, (0, createVariableDeclaration_1.createVariableDeclaration)(declaration, packageNameFinder, filePath)];
|
|
95
80
|
case 2:
|
|
96
81
|
variableDeclaration = _h.sent();
|
|
97
|
-
|
|
82
|
+
setDeclaration(variableDeclaration.qualifiedName, Object.assign(variableDeclaration, { sourceType: reflection_1.SourceType.variable }));
|
|
98
83
|
addTypeAliasDeclaration(variableDeclaration.type, variableDeclaration.qualifiedName, reflection_1.SourceRelationship.hasType, graph);
|
|
99
84
|
return [3 /*break*/, 9];
|
|
100
85
|
case 3:
|
|
@@ -102,7 +87,7 @@ function createGraphBuilder(graph, packageJson, packageJsonDir) {
|
|
|
102
87
|
return [4 /*yield*/, (0, createTypeAliasDeclaration_1.createTypeAliasDeclaration)(declaration, packageNameFinder, filePath)];
|
|
103
88
|
case 4:
|
|
104
89
|
typeAliasDeclaration = _h.sent();
|
|
105
|
-
|
|
90
|
+
setDeclaration(typeAliasDeclaration.qualifiedName, Object.assign(typeAliasDeclaration, { sourceType: reflection_1.SourceType.typeAlias }));
|
|
106
91
|
addTypeAliasDeclaration(typeAliasDeclaration, typeAliasDeclaration.qualifiedName, reflection_1.SourceRelationship.extendsType, graph);
|
|
107
92
|
return [3 /*break*/, 9];
|
|
108
93
|
case 5:
|
|
@@ -110,7 +95,7 @@ function createGraphBuilder(graph, packageJson, packageJsonDir) {
|
|
|
110
95
|
return [4 /*yield*/, (0, createClassDeclaration_1.createClassDeclaration)(declaration, packageNameFinder, filePath)];
|
|
111
96
|
case 6:
|
|
112
97
|
classDeclaration = _h.sent();
|
|
113
|
-
|
|
98
|
+
setDeclaration(classDeclaration.qualifiedName, Object.assign(classDeclaration, { sourceType: reflection_1.SourceType.class }));
|
|
114
99
|
for (_b = 0, _c = classDeclaration.directParentInterfaces; _b < _c.length; _b++) {
|
|
115
100
|
parentInterface = _c[_b];
|
|
116
101
|
if (parentInterface.packageName.startsWith('/')) {
|
|
@@ -137,7 +122,7 @@ function createGraphBuilder(graph, packageJson, packageJsonDir) {
|
|
|
137
122
|
return [4 /*yield*/, (0, createInterfaceDeclaration_1.createInterfaceDeclaration)(declaration, packageNameFinder, filePath)];
|
|
138
123
|
case 8:
|
|
139
124
|
interfaceDeclaration = _h.sent();
|
|
140
|
-
|
|
125
|
+
setDeclaration(interfaceDeclaration.qualifiedName, Object.assign(interfaceDeclaration, { sourceType: reflection_1.SourceType.interface }));
|
|
141
126
|
for (_f = 0, _g = interfaceDeclaration.directParents; _f < _g.length; _f++) {
|
|
142
127
|
parentInterface = _g[_f];
|
|
143
128
|
if (parentInterface.packageName.startsWith('/')) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createGraphBuilder.js","sourceRoot":"","sources":["../../../../../../src/parser/createGraphBuilder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createGraphBuilder.js","sourceRoot":"","sources":["../../../../../../src/parser/createGraphBuilder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,qEAMyC;AACzC,oDAA6F;AAC7F,wCAA+C;AAC/C,+EAA8E;AAC9E,+DAA8D;AAC9D,iFAAgF;AAChF,yEAAwE;AACxE,iFAAgF;AAChF,2DAA0D;AAG1D;;;GAGG;AACH,SAAgB,kBAAkB,CAChC,KAAqB,EACrB,WAAgB,EAChB,cAAsB,EACtB,WAAiC;IAJnC,iBA4HC;IAtHC,IAAM,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC;IACrC,OAAO,UAAO,UAAgB;;;;;oBAKtB,QAAQ,GAAG,uCAAkB,CAAC,YAAY,CAAC,cAAc,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;oBAChF,cAAc,GAAG,UAAC,aAAqB,EAAE,KAAa;wBAC1D,KAAK,CAAC,OAAO,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;wBACpC,WAAW,CAAC,MAAM,CAAC,aAAa,EAAE,QAAQ,CAAC,CA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IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE;YAC5C,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;SACzC;QAED,KAAK,CAAC,OAAO,CAAC,mBAAmB,EAAE,UAAU,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC;KAClF;AACH,CAAC"}
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import * as graphlib from '@dagrejs/graphlib';
|
|
2
|
-
|
|
2
|
+
import { SharedQualifiedNames } from './SharedQualifiedNames';
|
|
3
|
+
/**
|
|
4
|
+
* @param sharedNames receives the file of every declaration the graph holds a node for; the
|
|
5
|
+
* build reads the names two files declare from it after the prune
|
|
6
|
+
*/
|
|
7
|
+
export declare function createSourceGraph(dir: string, excludedDirs?: string[], sourceRootsRel?: string | string[], sharedNames?: SharedQualifiedNames): Promise<graphlib.Graph>;
|
|
@@ -58,71 +58,56 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
58
58
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
59
|
}
|
|
60
60
|
};
|
|
61
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
62
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
63
|
-
if (ar || !(i in from)) {
|
|
64
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
65
|
-
ar[i] = from[i];
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
69
|
-
};
|
|
70
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
71
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
72
|
-
};
|
|
73
61
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
74
62
|
exports.createSourceGraph = void 0;
|
|
75
63
|
var graphlib = __importStar(require("@dagrejs/graphlib"));
|
|
76
|
-
var globby_1 = __importDefault(require("globby"));
|
|
77
64
|
var path = __importStar(require("path"));
|
|
78
65
|
var typescript_parser_1 = require("../../modules/typescript-parser");
|
|
79
66
|
var util_node_1 = require("@proteinjs/util-node");
|
|
80
67
|
var createGraphBuilder_1 = require("./createGraphBuilder");
|
|
81
|
-
|
|
68
|
+
var PackageSourceFiles_1 = require("./PackageSourceFiles");
|
|
69
|
+
var SharedQualifiedNames_1 = require("./SharedQualifiedNames");
|
|
70
|
+
/**
|
|
71
|
+
* @param sharedNames receives the file of every declaration the graph holds a node for; the
|
|
72
|
+
* build reads the names two files declare from it after the prune
|
|
73
|
+
*/
|
|
74
|
+
function createSourceGraph(dir, excludedDirs, sourceRootsRel, sharedNames) {
|
|
82
75
|
if (excludedDirs === void 0) { excludedDirs = []; }
|
|
83
76
|
if (sourceRootsRel === void 0) { sourceRootsRel = 'src'; }
|
|
77
|
+
if (sharedNames === void 0) { sharedNames = new SharedQualifiedNames_1.SharedQualifiedNames(); }
|
|
84
78
|
return __awaiter(this, void 0, void 0, function () {
|
|
85
|
-
var packageJsonPath, packageJson, roots,
|
|
86
|
-
return __generator(this, function (
|
|
87
|
-
switch (
|
|
79
|
+
var packageJsonPath, packageJson, roots, sourceFilePaths, graph, addSourceFile, parser, _i, sourceFilePaths_1, sourceFilePath, sourceFile;
|
|
80
|
+
return __generator(this, function (_a) {
|
|
81
|
+
switch (_a.label) {
|
|
88
82
|
case 0:
|
|
89
83
|
packageJsonPath = path.join(dir, 'package.json');
|
|
90
84
|
return [4 /*yield*/, util_node_1.promisifiedFs.exists(packageJsonPath)];
|
|
91
85
|
case 1:
|
|
92
|
-
if (!(
|
|
86
|
+
if (!(_a.sent())) {
|
|
93
87
|
throw new Error("Unable to find package.json in dir: ".concat(dir));
|
|
94
88
|
}
|
|
95
89
|
packageJson = require(packageJsonPath);
|
|
96
90
|
roots = Array.isArray(sourceRootsRel) ? sourceRootsRel : [sourceRootsRel];
|
|
97
|
-
|
|
98
|
-
for (_i = 0, roots_1 = roots; _i < roots_1.length; _i++) {
|
|
99
|
-
rel = roots_1[_i];
|
|
100
|
-
root = path.join(dir, rel);
|
|
101
|
-
patterns.push(path.join(root, '**/*.ts'));
|
|
102
|
-
patterns.push(path.join(root, '**/*.tsx'));
|
|
103
|
-
}
|
|
104
|
-
excludePatterns = __spreadArray(['!**/node_modules/**', '!**/generated/**'], excludedDirs.map(function (d) { return "!".concat(d); }), true);
|
|
105
|
-
return [4 /*yield*/, (0, globby_1.default)(__spreadArray(__spreadArray([], patterns, true), excludePatterns, true))];
|
|
91
|
+
return [4 /*yield*/, new PackageSourceFiles_1.PackageSourceFiles(dir, roots, excludedDirs).list()];
|
|
106
92
|
case 2:
|
|
107
|
-
sourceFilePaths =
|
|
108
|
-
uniqueFilePaths = Array.from(new Set(sourceFilePaths));
|
|
93
|
+
sourceFilePaths = _a.sent();
|
|
109
94
|
graph = new graphlib.Graph();
|
|
110
|
-
addSourceFile = (0, createGraphBuilder_1.createGraphBuilder)(graph, packageJson, dir);
|
|
95
|
+
addSourceFile = (0, createGraphBuilder_1.createGraphBuilder)(graph, packageJson, dir, sharedNames);
|
|
111
96
|
parser = new typescript_parser_1.TypescriptParser();
|
|
112
|
-
|
|
113
|
-
|
|
97
|
+
_i = 0, sourceFilePaths_1 = sourceFilePaths;
|
|
98
|
+
_a.label = 3;
|
|
114
99
|
case 3:
|
|
115
|
-
if (!(
|
|
116
|
-
sourceFilePath =
|
|
100
|
+
if (!(_i < sourceFilePaths_1.length)) return [3 /*break*/, 7];
|
|
101
|
+
sourceFilePath = sourceFilePaths_1[_i];
|
|
117
102
|
return [4 /*yield*/, parser.parseFile(sourceFilePath, path.dirname(sourceFilePath))];
|
|
118
103
|
case 4:
|
|
119
|
-
sourceFile =
|
|
104
|
+
sourceFile = _a.sent();
|
|
120
105
|
return [4 /*yield*/, addSourceFile(sourceFile)];
|
|
121
106
|
case 5:
|
|
122
|
-
|
|
123
|
-
|
|
107
|
+
_a.sent();
|
|
108
|
+
_a.label = 6;
|
|
124
109
|
case 6:
|
|
125
|
-
|
|
110
|
+
_i++;
|
|
126
111
|
return [3 /*break*/, 3];
|
|
127
112
|
case 7: return [2 /*return*/, graph];
|
|
128
113
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSourceGraph.js","sourceRoot":"","sources":["../../../../../../src/parser/createSourceGraph.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createSourceGraph.js","sourceRoot":"","sources":["../../../../../../src/parser/createSourceGraph.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAA8C;AAC9C,yCAA6B;AAC7B,qEAAmE;AACnE,kDAAqD;AACrD,2DAA0D;AAC1D,2DAA0D;AAC1D,+DAA8D;AAE9D;;;GAGG;AACH,SAAsB,iBAAiB,CACrC,GAAW,EACX,YAA2B,EAC3B,cAAyC,EACzC,WAA8D;IAF9D,6BAAA,EAAA,iBAA2B;IAC3B,+BAAA,EAAA,sBAAyC;IACzC,4BAAA,EAAA,kBAAwC,2CAAoB,EAAE;;;;;;oBAExD,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;oBACjD,qBAAM,yBAAa,CAAC,MAAM,CAAC,eAAe,CAAC,EAAA;;oBAAjD,IAAI,CAAC,CAAC,SAA2C,CAAC,EAAE;wBAClD,MAAM,IAAI,KAAK,CAAC,8CAAuC,GAAG,CAAE,CAAC,CAAC;qBAC/D;oBAEK,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;oBACvC,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC;oBACxD,qBAAM,IAAI,uCAAkB,CAAC,GAAG,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC,IAAI,EAAE,EAAA;;oBAA/E,eAAe,GAAG,SAA6D;oBAE/E,KAAK,GAAG,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;oBAC7B,aAAa,GAAG,IAAA,uCAAkB,EAAC,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,WAAW,CAAC,CAAC;oBACzE,MAAM,GAAG,IAAI,oCAAgB,EAAE,CAAC;0BAKM,EAAf,mCAAe;;;yBAAf,CAAA,6BAAe,CAAA;oBAAjC,cAAc;oBACJ,qBAAM,MAAM,CAAC,SAAS,CAAC,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,EAAA;;oBAAjF,UAAU,GAAG,SAAoE;oBACvF,qBAAM,aAAa,CAAC,UAAU,CAAC,EAAA;;oBAA/B,SAA+B,CAAC;;;oBAFL,IAAe,CAAA;;wBAK5C,sBAAO,KAAK,EAAC;;;;CACd;AA5BD,8CA4BC"}
|
|
@@ -31,7 +31,7 @@ export declare class ImplementsExtendsLoadableForeignInterface implements Extend
|
|
|
31
31
|
export interface ExtendsNotLoadableForeignInterface extends NotLoadableForeignInterface {
|
|
32
32
|
b: number;
|
|
33
33
|
}
|
|
34
|
-
export declare class
|
|
34
|
+
export declare class ImplementsExtendsNotLoadableForeignInterface implements ExtendsNotLoadableForeignInterface {
|
|
35
35
|
z: number;
|
|
36
36
|
b: number;
|
|
37
37
|
}
|
|
@@ -15,7 +15,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.ImplementsExtendsNotLoadableForeignAbstractClass = exports.ExtendsNotLoadableForeignAbstractClass = exports.ImplementsExtendsLoadableForeignAbstractClass = exports.ExtendsLoadableForeignAbstractClass = exports.
|
|
18
|
+
exports.ImplementsExtendsNotLoadableForeignAbstractClass = exports.ExtendsNotLoadableForeignAbstractClass = exports.ImplementsExtendsLoadableForeignAbstractClass = exports.ExtendsLoadableForeignAbstractClass = exports.ImplementsExtendsNotLoadableForeignInterface = exports.ImplementsExtendsLoadableForeignInterface = exports.ImplementsNotLoadableForeignAbstractClass = exports.ImplementsLoadableForeignAbstractClass = exports.ImplementsNotLoadableForeignInterface = exports.ImplementsLoadableForeignInterface = exports.implementsExtendsNotLoadableForeignType = exports.implementsExtendsLoadableForeignType = exports.implementsNotLoadableForeignType = exports.implementsLoadableForeignType = void 0;
|
|
19
19
|
var reflection_build_test_b_1 = require("@proteinjs/reflection-build-test-b");
|
|
20
20
|
// variable <- type alias
|
|
21
21
|
exports.implementsLoadableForeignType = { z: 1 };
|
|
@@ -66,14 +66,14 @@ var ImplementsExtendsLoadableForeignInterface = /** @class */ (function () {
|
|
|
66
66
|
return ImplementsExtendsLoadableForeignInterface;
|
|
67
67
|
}());
|
|
68
68
|
exports.ImplementsExtendsLoadableForeignInterface = ImplementsExtendsLoadableForeignInterface;
|
|
69
|
-
var
|
|
70
|
-
function
|
|
69
|
+
var ImplementsExtendsNotLoadableForeignInterface = /** @class */ (function () {
|
|
70
|
+
function ImplementsExtendsNotLoadableForeignInterface() {
|
|
71
71
|
this.z = 1;
|
|
72
72
|
this.b = 2;
|
|
73
73
|
}
|
|
74
|
-
return
|
|
74
|
+
return ImplementsExtendsNotLoadableForeignInterface;
|
|
75
75
|
}());
|
|
76
|
-
exports.
|
|
76
|
+
exports.ImplementsExtendsNotLoadableForeignInterface = ImplementsExtendsNotLoadableForeignInterface;
|
|
77
77
|
// class <- abstract class <- abstract class
|
|
78
78
|
var ExtendsLoadableForeignAbstractClass = /** @class */ (function (_super) {
|
|
79
79
|
__extends(ExtendsLoadableForeignAbstractClass, _super);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExtendsForeignType.js","sourceRoot":"","sources":["../../src/ExtendsForeignType.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,8EAO4C;AAE5C,yBAAyB;AAEZ,QAAA,6BAA6B,GAAw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