ts-morph-extensions 2.24.0-alpha.3
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/README.md +49 -0
- package/dist/dto/decorator.d.ts +8 -0
- package/dist/dto/decorator.d.ts.map +1 -0
- package/dist/dto/decorator.js +36 -0
- package/dist/dto/decorator.js.map +1 -0
- package/dist/dto/graph.d.ts +20 -0
- package/dist/dto/graph.d.ts.map +1 -0
- package/dist/dto/graph.js +66 -0
- package/dist/dto/graph.js.map +1 -0
- package/dist/dto/identifier.d.ts +9 -0
- package/dist/dto/identifier.d.ts.map +1 -0
- package/dist/dto/identifier.js +23 -0
- package/dist/dto/identifier.js.map +1 -0
- package/dist/dto/parameter.d.ts +10 -0
- package/dist/dto/parameter.d.ts.map +1 -0
- package/dist/dto/parameter.js +19 -0
- package/dist/dto/parameter.js.map +1 -0
- package/dist/dto/provider.d.ts +28 -0
- package/dist/dto/provider.d.ts.map +1 -0
- package/dist/dto/provider.js +62 -0
- package/dist/dto/provider.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +15 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +28 -0
- package/dist/logger.js.map +1 -0
- package/dist/project/projectRegistry.d.ts +26 -0
- package/dist/project/projectRegistry.d.ts.map +1 -0
- package/dist/project/projectRegistry.js +130 -0
- package/dist/project/projectRegistry.js.map +1 -0
- package/dist/tsConfig/relativeToAbsolutePathConverter.d.ts +7 -0
- package/dist/tsConfig/relativeToAbsolutePathConverter.d.ts.map +1 -0
- package/dist/tsConfig/relativeToAbsolutePathConverter.js +72 -0
- package/dist/tsConfig/relativeToAbsolutePathConverter.js.map +1 -0
- package/dist/tsConfig/tsconfigParser.d.ts +35 -0
- package/dist/tsConfig/tsconfigParser.d.ts.map +1 -0
- package/dist/tsConfig/tsconfigParser.js +156 -0
- package/dist/tsConfig/tsconfigParser.js.map +1 -0
- package/dist/utils/dedupeSet.d.ts +5 -0
- package/dist/utils/dedupeSet.d.ts.map +1 -0
- package/dist/utils/dedupeSet.js +17 -0
- package/dist/utils/dedupeSet.js.map +1 -0
- package/dist/utils/fileSystem.d.ts +12 -0
- package/dist/utils/fileSystem.d.ts.map +1 -0
- package/dist/utils/fileSystem.js +73 -0
- package/dist/utils/fileSystem.js.map +1 -0
- package/dist/utils/objects.d.ts +2 -0
- package/dist/utils/objects.d.ts.map +1 -0
- package/dist/utils/objects.js +7 -0
- package/dist/utils/objects.js.map +1 -0
- package/dist/utils/ts/assertions.d.ts +3 -0
- package/dist/utils/ts/assertions.d.ts.map +1 -0
- package/dist/utils/ts/assertions.js +9 -0
- package/dist/utils/ts/assertions.js.map +1 -0
- package/dist/utils/ts/decorators.d.ts +8 -0
- package/dist/utils/ts/decorators.d.ts.map +1 -0
- package/dist/utils/ts/decorators.js +42 -0
- package/dist/utils/ts/decorators.js.map +1 -0
- package/dist/utils/ts/identifier.d.ts +3 -0
- package/dist/utils/ts/identifier.d.ts.map +1 -0
- package/dist/utils/ts/identifier.js +14 -0
- package/dist/utils/ts/identifier.js.map +1 -0
- package/dist/utils/ts/providers.d.ts +6 -0
- package/dist/utils/ts/providers.d.ts.map +1 -0
- package/dist/utils/ts/providers.js +29 -0
- package/dist/utils/ts/providers.js.map +1 -0
- package/package.json +25 -0
package/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# ts-morph-extensions
|
|
2
|
+
Extensions and utilities for analyzing and traversing ASTs with ts-morph, specifically for Obsidian dependency injection patterns.
|
|
3
|
+
|
|
4
|
+
## Overview
|
|
5
|
+
This package provides utilities for analyzing Obsidian-specific code patterns (Graphs, Providers, decorators) and a simple interface for managing ts-morph projects with automatic TypeScript configuration discovery and caching.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
### ProjectRegistry
|
|
9
|
+
Manages ts-morph `Project` instances with automatic tsconfig.json discovery and caching.
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { ProjectRegistry } from 'ts-morph-extensions';
|
|
13
|
+
|
|
14
|
+
// Create a project registry (no dependencies needed!)
|
|
15
|
+
const projectRegistry = new ProjectRegistry();
|
|
16
|
+
|
|
17
|
+
// Get a project for a specific file path
|
|
18
|
+
const project = projectRegistry.get('/path/to/your/file.ts');
|
|
19
|
+
|
|
20
|
+
// Get a source file directly (convenience method)
|
|
21
|
+
const sourceFile = projectRegistry.getSourceFileOrThrow('/path/to/your/file.ts');
|
|
22
|
+
|
|
23
|
+
// Also accepts file:// URIs (automatically normalized)
|
|
24
|
+
const projectFromUri = projectRegistry.get('file:///path/to/your/file.ts');
|
|
25
|
+
const sourceFileFromUri = projectRegistry.getSourceFileOrThrow('file:///path/to/your/file.ts');
|
|
26
|
+
|
|
27
|
+
// Optional: provide a custom logger and other options
|
|
28
|
+
const projectRegistryWithOptions = new ProjectRegistry({
|
|
29
|
+
logger: myCustomLogger, // Useful for debugging
|
|
30
|
+
overrideTsConfigPath: '/path/to/custom/tsconfig.json' // Useful for testing
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Features
|
|
35
|
+
- **Automatic tsconfig discovery**: Finds the closest tsconfig.json for any file
|
|
36
|
+
- **Project caching**: Reuses projects for files in the same TypeScript configuration
|
|
37
|
+
- **Flexible configuration**: Support for `extends`, composite projects, and path mappings
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
```bash
|
|
41
|
+
npm install ts-morph-extensions ts-morph
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Dependencies
|
|
45
|
+
- `ts-morph` (peer dependency): For TypeScript project management
|
|
46
|
+
- `jsonc-parser`: For parsing JSON with comments (tsconfig.json files)
|
|
47
|
+
|
|
48
|
+
## License
|
|
49
|
+
ISC
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Decorator as TsMorphDecorator, Node } from 'ts-morph';
|
|
2
|
+
export declare class Decorator {
|
|
3
|
+
private decorator;
|
|
4
|
+
constructor(decorator: TsMorphDecorator);
|
|
5
|
+
get name(): string;
|
|
6
|
+
getArgument(index: number, name?: string): Node | undefined;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorator.d.ts","sourceRoot":"","sources":["../../src/dto/decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,IAAI,gBAAgB,EAC7B,IAAI,EAKL,MAAM,UAAU,CAAC;AAElB,qBAAa,SAAS;IACR,OAAO,CAAC,SAAS;gBAAT,SAAS,EAAE,gBAAgB;IAE/C,IAAW,IAAI,WAEd;IAEM,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;CAwBnE"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Decorator = void 0;
|
|
4
|
+
const ts_morph_1 = require("ts-morph");
|
|
5
|
+
class Decorator {
|
|
6
|
+
constructor(decorator) {
|
|
7
|
+
this.decorator = decorator;
|
|
8
|
+
}
|
|
9
|
+
get name() {
|
|
10
|
+
return this.decorator.getExpression().getText();
|
|
11
|
+
}
|
|
12
|
+
getArgument(index, name) {
|
|
13
|
+
const decoratorExpr = this.decorator.getExpression();
|
|
14
|
+
if (!decoratorExpr.isKind(ts_morph_1.SyntaxKind.CallExpression))
|
|
15
|
+
return undefined;
|
|
16
|
+
const args = decoratorExpr.getArguments();
|
|
17
|
+
if (index >= args.length)
|
|
18
|
+
return undefined;
|
|
19
|
+
const arg = args[index];
|
|
20
|
+
if (!name)
|
|
21
|
+
return arg;
|
|
22
|
+
// If name is provided, expect an object literal
|
|
23
|
+
if (!arg.isKind(ts_morph_1.SyntaxKind.ObjectLiteralExpression))
|
|
24
|
+
return undefined;
|
|
25
|
+
// Find the property with the given name
|
|
26
|
+
const property = arg
|
|
27
|
+
.getProperties()
|
|
28
|
+
.find(prop => prop.isKind(ts_morph_1.SyntaxKind.PropertyAssignment) &&
|
|
29
|
+
prop.getName() === name);
|
|
30
|
+
if (!property?.isKind(ts_morph_1.SyntaxKind.PropertyAssignment))
|
|
31
|
+
return undefined;
|
|
32
|
+
return property.getInitializer();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.Decorator = Decorator;
|
|
36
|
+
//# sourceMappingURL=decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorator.js","sourceRoot":"","sources":["../../src/dto/decorator.ts"],"names":[],"mappings":";;;AAAA,uCAOkB;AAElB,MAAa,SAAS;IACpB,YAAoB,SAA2B;QAA3B,cAAS,GAAT,SAAS,CAAkB;IAAI,CAAC;IAEpD,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,CAAC,OAAO,EAAE,CAAC;IAClD,CAAC;IAEM,WAAW,CAAC,KAAa,EAAE,IAAa;QAC7C,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,CAAC;QACrD,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,qBAAU,CAAC,cAAc,CAAC;YAAE,OAAO,SAAS,CAAC;QAEvE,MAAM,IAAI,GAAI,aAAgC,CAAC,YAAY,EAAE,CAAC;QAC9D,IAAI,KAAK,IAAI,IAAI,CAAC,MAAM;YAAE,OAAO,SAAS,CAAC;QAE3C,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI;YAAE,OAAO,GAAG,CAAC;QAEtB,gDAAgD;QAChD,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,qBAAU,CAAC,uBAAuB,CAAC;YAAE,OAAO,SAAS,CAAC;QAEtE,wCAAwC;QACxC,MAAM,QAAQ,GAAI,GAA+B;aAC9C,aAAa,EAAE;aACf,IAAI,CAAC,IAAI,CAAC,EAAE,CACX,IAAI,CAAC,MAAM,CAAC,qBAAU,CAAC,kBAAkB,CAAC;YACzC,IAA2B,CAAC,OAAO,EAAE,KAAK,IAAI,CAChD,CAAC;QAEJ,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,qBAAU,CAAC,kBAAkB,CAAC;YAAE,OAAO,SAAS,CAAC;QACvE,OAAQ,QAA+B,CAAC,cAAc,EAAE,CAAC;IAC3D,CAAC;CACF;AA/BD,8BA+BC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Provider } from "../index";
|
|
2
|
+
import { ClassDeclaration } from "ts-morph";
|
|
3
|
+
import { DedupeSet } from "../utils/dedupeSet";
|
|
4
|
+
export declare class Graph {
|
|
5
|
+
private node;
|
|
6
|
+
constructor(node: ClassDeclaration);
|
|
7
|
+
get name(): string | undefined;
|
|
8
|
+
resolveProvider(name: string): Provider | undefined;
|
|
9
|
+
hasProvider(name: string): boolean;
|
|
10
|
+
requireProvider(name: string): Provider;
|
|
11
|
+
private resolveProviderFromSubgraphs;
|
|
12
|
+
findProvider(name: string): Provider | undefined;
|
|
13
|
+
getProviders(): Provider[];
|
|
14
|
+
getSubgraphs(): Graph[];
|
|
15
|
+
private getGraphFromSubgraph;
|
|
16
|
+
private getSubgraphsFromDecorator;
|
|
17
|
+
resolveProviders(dedupeSet?: DedupeSet<string>): Provider[];
|
|
18
|
+
private getBaseGraph;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=graph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/dto/graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoD,QAAQ,EAAE,MAAM,UAAU,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAgC,MAAM,UAAU,CAAC;AAE1E,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,qBAAa,KAAK;IACH,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,gBAAgB;IAE3C,IAAW,IAAI,IAAI,MAAM,GAAG,SAAS,CAEpC;IAEM,eAAe,CAAC,IAAI,EAAE,MAAM;IAM5B,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIlC,eAAe,CAAC,IAAI,EAAE,MAAM;IAInC,OAAO,CAAC,4BAA4B;IAO7B,YAAY,CAAC,IAAI,EAAE,MAAM;IAIzB,YAAY;IAKZ,YAAY,IAAI,KAAK,EAAE;IAM9B,OAAO,CAAC,oBAAoB;IAK5B,OAAO,CAAC,yBAAyB;IAM1B,gBAAgB,CAAC,SAAS,oBAAkB,GAAG,QAAQ,EAAE;IAOhE,OAAO,CAAC,YAAY;CAGrB"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Graph = void 0;
|
|
4
|
+
const index_1 = require("../index");
|
|
5
|
+
const ts_morph_1 = require("ts-morph");
|
|
6
|
+
const objects_1 = require("../utils/objects");
|
|
7
|
+
const dedupeSet_1 = require("../utils/dedupeSet");
|
|
8
|
+
class Graph {
|
|
9
|
+
constructor(node) {
|
|
10
|
+
this.node = node;
|
|
11
|
+
}
|
|
12
|
+
get name() {
|
|
13
|
+
return this.node.getName();
|
|
14
|
+
}
|
|
15
|
+
resolveProvider(name) {
|
|
16
|
+
return this.hasProvider(name) ?
|
|
17
|
+
this.requireProvider(name) :
|
|
18
|
+
this.resolveProviderFromSubgraphs(name);
|
|
19
|
+
}
|
|
20
|
+
hasProvider(name) {
|
|
21
|
+
return this.findProvider(name) !== undefined;
|
|
22
|
+
}
|
|
23
|
+
requireProvider(name) {
|
|
24
|
+
return this.findProvider(name);
|
|
25
|
+
}
|
|
26
|
+
resolveProviderFromSubgraphs(name) {
|
|
27
|
+
for (const subgraph of this.getSubgraphs()) {
|
|
28
|
+
const provider = subgraph.resolveProvider(name);
|
|
29
|
+
if (provider)
|
|
30
|
+
return provider;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
findProvider(name) {
|
|
34
|
+
return this.getProviders().find(provider => provider.name === name);
|
|
35
|
+
}
|
|
36
|
+
getProviders() {
|
|
37
|
+
const providers = (0, index_1.getDecoratedMethods)(this.node, ['Provides', 'provides']);
|
|
38
|
+
return providers.map(method => new index_1.Provider(method));
|
|
39
|
+
}
|
|
40
|
+
getSubgraphs() {
|
|
41
|
+
return this.getSubgraphsFromDecorator()
|
|
42
|
+
.map(graph => this.getGraphFromSubgraph(graph))
|
|
43
|
+
.filter(objects_1.isDefined);
|
|
44
|
+
}
|
|
45
|
+
getGraphFromSubgraph(graph) {
|
|
46
|
+
const declaration = (0, index_1.getDefinition)(graph, ts_morph_1.SyntaxKind.ClassDeclaration);
|
|
47
|
+
return declaration && new Graph(declaration);
|
|
48
|
+
}
|
|
49
|
+
getSubgraphsFromDecorator() {
|
|
50
|
+
const graphDecorator = (0, index_1.getDecorator)(this.node, ['Graph', 'graph']);
|
|
51
|
+
const subgraphsArg = graphDecorator?.getArgument(0, 'subgraphs');
|
|
52
|
+
return ts_morph_1.Node.isArrayLiteralExpression(subgraphsArg) ? subgraphsArg.getElements() : [];
|
|
53
|
+
}
|
|
54
|
+
resolveProviders(dedupeSet = new dedupeSet_1.DedupeSet()) {
|
|
55
|
+
const ownProviders = this.getProviders().filter(provider => dedupeSet.dedupe(provider.name));
|
|
56
|
+
const subgraphProviders = this.getSubgraphs().flatMap(subgraph => subgraph.resolveProviders(dedupeSet));
|
|
57
|
+
const baseGraphProviders = this.getBaseGraph()?.getProviders().filter(provider => dedupeSet.dedupe(provider.name)) || [];
|
|
58
|
+
return [...ownProviders, ...baseGraphProviders, ...subgraphProviders];
|
|
59
|
+
}
|
|
60
|
+
getBaseGraph() {
|
|
61
|
+
if (this.node.getBaseClass())
|
|
62
|
+
return new Graph(this.node.getBaseClass());
|
|
63
|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QAAQ,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC;QACxG,MAAM,kBAAkB,GAAG,IAAI,CAAC,YAAY,EAAE,EAAE,YAAY,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;QACzH,OAAO,CAAC,GAAG,YAAY,EAAE,GAAG,kBAAkB,EAAE,GAAG,iBAAiB,CAAC,CAAC;IACxE,CAAC;IAEO,YAAY;QAClB,IAAI,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;YAAE,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAsB,CAAC,CAAC;IAC/F,CAAC;CACF;AAhED,sBAgEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identifier.d.ts","sourceRoot":"","sources":["../../src/dto/identifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAmC,MAAM,UAAU,CAAC;AAIjE,qBAAa,UAAU;IACrB,OAAO,CAAC,IAAI,CAAoB;gBAEnB,IAAI,EAAE,IAAI;IAKhB,UAAU,IAAI,OAAO;IAMrB,MAAM,IAAI,OAAO;IAIjB,oBAAoB,IAAI,OAAO;CAGvC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Identifier = void 0;
|
|
4
|
+
const ts_morph_1 = require("ts-morph");
|
|
5
|
+
const decorators_1 = require("../utils/ts/decorators");
|
|
6
|
+
const assertions_1 = require("../utils/ts/assertions");
|
|
7
|
+
class Identifier {
|
|
8
|
+
constructor(node) {
|
|
9
|
+
(0, assertions_1.assertIdentifier)(node);
|
|
10
|
+
this.node = node;
|
|
11
|
+
}
|
|
12
|
+
isInjected() {
|
|
13
|
+
return this.node.findReferencesAsNodes().some(reference => (0, decorators_1.hasParentWithDecorator)(reference, ['Provides', 'provides']));
|
|
14
|
+
}
|
|
15
|
+
isHook() {
|
|
16
|
+
return /^use[A-Z][a-zA-Z]*$/.test(this.node.getText());
|
|
17
|
+
}
|
|
18
|
+
isProviderDependency() {
|
|
19
|
+
return ts_morph_1.Node.isParameterDeclaration(this.node.getParent()) && (0, decorators_1.hasParentWithDecorator)(this.node, ['Provides', 'provides']);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.Identifier = Identifier;
|
|
23
|
+
//# sourceMappingURL=identifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identifier.js","sourceRoot":"","sources":["../../src/dto/identifier.ts"],"names":[],"mappings":";;;AAAA,uCAAiE;AACjE,uDAAgE;AAChE,uDAA0D;AAE1D,MAAa,UAAU;IAGrB,YAAa,IAAU;QACrB,IAAA,6BAAgB,EAAC,IAAI,CAAC,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAEM,UAAU;QACf,OAAO,IAAI,CAAC,IAAI,CAAC,qBAAqB,EAAE,CAAC,IAAI,CAC3C,SAAS,CAAC,EAAE,CAAC,IAAA,mCAAsB,EAAC,SAAS,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC,CACzE,CAAC;IACJ,CAAC;IAEM,MAAM;QACX,OAAO,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IACzD,CAAC;IAEM,oBAAoB;QACzB,OAAO,eAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,IAAI,IAAA,mCAAsB,EAAC,IAAI,CAAC,IAAI,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;IAC3H,CAAC;CACF;AArBD,gCAqBC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ParameterDeclaration } from "ts-morph";
|
|
2
|
+
import { Provider } from "./provider";
|
|
3
|
+
export declare class Parameter {
|
|
4
|
+
readonly node: ParameterDeclaration;
|
|
5
|
+
constructor(node: ParameterDeclaration);
|
|
6
|
+
get name(): string;
|
|
7
|
+
isNotProvided(by: Provider[]): boolean;
|
|
8
|
+
isProvided(by: Provider[]): boolean;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=parameter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parameter.d.ts","sourceRoot":"","sources":["../../src/dto/parameter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,qBAAa,SAAS;aACQ,IAAI,EAAE,oBAAoB;gBAA1B,IAAI,EAAE,oBAAoB;IAEtD,IAAW,IAAI,WAEd;IAEM,aAAa,CAAC,EAAE,EAAE,QAAQ,EAAE,GAAG,OAAO;IAItC,UAAU,CAAC,EAAE,EAAE,QAAQ,EAAE,GAAG,OAAO;CAG3C"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Parameter = void 0;
|
|
4
|
+
class Parameter {
|
|
5
|
+
constructor(node) {
|
|
6
|
+
this.node = node;
|
|
7
|
+
}
|
|
8
|
+
get name() {
|
|
9
|
+
return this.node.getName();
|
|
10
|
+
}
|
|
11
|
+
isNotProvided(by) {
|
|
12
|
+
return !this.isProvided(by);
|
|
13
|
+
}
|
|
14
|
+
isProvided(by) {
|
|
15
|
+
return by.some(resolved => resolved.name === this.name);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.Parameter = Parameter;
|
|
19
|
+
//# sourceMappingURL=parameter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parameter.js","sourceRoot":"","sources":["../../src/dto/parameter.ts"],"names":[],"mappings":";;;AAGA,MAAa,SAAS;IACpB,YAA4B,IAA0B;QAA1B,SAAI,GAAJ,IAAI,CAAsB;IAAI,CAAC;IAE3D,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;IAEM,aAAa,CAAC,EAAc;QACjC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC;IAEM,UAAU,CAAC,EAAc;QAC9B,OAAO,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1D,CAAC;CACF;AAdD,8BAcC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { MethodDeclaration } from "ts-morph";
|
|
2
|
+
import { Parameter } from "./parameter";
|
|
3
|
+
export declare class Provider {
|
|
4
|
+
private node;
|
|
5
|
+
constructor(node: MethodDeclaration);
|
|
6
|
+
get name(): string;
|
|
7
|
+
get type(): string;
|
|
8
|
+
get kind(): "class" | "function" | (string & {});
|
|
9
|
+
get uri(): import("@ts-morph/common").StandardizedFilePath;
|
|
10
|
+
private get sourceFile();
|
|
11
|
+
get definition(): {
|
|
12
|
+
uri: import("@ts-morph/common").StandardizedFilePath;
|
|
13
|
+
range: {
|
|
14
|
+
start: {
|
|
15
|
+
line: number;
|
|
16
|
+
character: number;
|
|
17
|
+
};
|
|
18
|
+
end: {
|
|
19
|
+
line: number;
|
|
20
|
+
character: number;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
get dependencies(): Parameter[];
|
|
25
|
+
private get range();
|
|
26
|
+
hasParameter(name: string): boolean;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/dto/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,qBAAa,QAAQ;IACN,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,iBAAiB;IAE5C,IAAW,IAAI,WAEd;IAED,IAAW,IAAI,WAKd;IAED,IAAW,IAAI,IAAI,OAAO,GAAG,UAAU,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAItD;IAED,IAAW,GAAG,oDAEb;IAED,OAAO,KAAK,UAAU,GAErB;IAED,IAAW,UAAU;;;;;;;;;;;;MAepB;IAED,IAAW,YAAY,gBAEtB;IAED,OAAO,KAAK,KAAK,GAKhB;IAEM,YAAY,CAAC,IAAI,EAAE,MAAM;CAGjC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Provider = void 0;
|
|
4
|
+
const parameter_1 = require("./parameter");
|
|
5
|
+
class Provider {
|
|
6
|
+
constructor(node) {
|
|
7
|
+
this.node = node;
|
|
8
|
+
}
|
|
9
|
+
get name() {
|
|
10
|
+
return this.node.getName().replace(/^_/, '');
|
|
11
|
+
}
|
|
12
|
+
get type() {
|
|
13
|
+
const returnType = this.node.getReturnType();
|
|
14
|
+
if (returnType.getCallSignatures().length > 0)
|
|
15
|
+
return returnType.getText();
|
|
16
|
+
const symbol = returnType.getSymbol();
|
|
17
|
+
return symbol ? symbol.getName() : returnType.getText();
|
|
18
|
+
}
|
|
19
|
+
get kind() {
|
|
20
|
+
if (this.node.getReturnType().isClassOrInterface())
|
|
21
|
+
return "class";
|
|
22
|
+
if (this.node.getReturnType().getCallSignatures().length > 0)
|
|
23
|
+
return "function";
|
|
24
|
+
return this.node.getReturnType().getText();
|
|
25
|
+
}
|
|
26
|
+
get uri() {
|
|
27
|
+
return this.sourceFile.getFilePath();
|
|
28
|
+
}
|
|
29
|
+
get sourceFile() {
|
|
30
|
+
return this.node.getSourceFile();
|
|
31
|
+
}
|
|
32
|
+
get definition() {
|
|
33
|
+
const range = this.range;
|
|
34
|
+
return {
|
|
35
|
+
uri: this.uri,
|
|
36
|
+
range: {
|
|
37
|
+
start: {
|
|
38
|
+
line: range.start.line,
|
|
39
|
+
character: range.start.column - 1
|
|
40
|
+
},
|
|
41
|
+
end: {
|
|
42
|
+
line: range.end.line,
|
|
43
|
+
character: range.end.column
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
get dependencies() {
|
|
49
|
+
return this.node.getParameters().map(param => new parameter_1.Parameter(param));
|
|
50
|
+
}
|
|
51
|
+
get range() {
|
|
52
|
+
return {
|
|
53
|
+
start: this.sourceFile.getLineAndColumnAtPos(this.node.getStart()),
|
|
54
|
+
end: this.sourceFile.getLineAndColumnAtPos(this.node.getEnd())
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
hasParameter(name) {
|
|
58
|
+
return this.node.getParameters().some(param => param.getName() === name);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.Provider = Provider;
|
|
62
|
+
//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/dto/provider.ts"],"names":[],"mappings":";;;AACA,2CAAwC;AAExC,MAAa,QAAQ;IACnB,YAAqB,IAAuB;QAAvB,SAAI,GAAJ,IAAI,CAAmB;IAAI,CAAC;IAEjD,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAC/C,CAAC;IAED,IAAW,IAAI;QACb,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;QAC7C,IAAI,UAAU,CAAC,iBAAiB,EAAE,CAAC,MAAM,GAAG,CA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S,CAAC,KAAK,CAAC,CAAC,CAAC;IACtE,CAAC;IAED,IAAY,KAAK;QACf,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClE,GAAG,EAAE,IAAI,CAAC,UAAU,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;SAC/D,CAAC;IACJ,CAAC;IAEM,YAAY,CAAC,IAAY;QAC9B,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,IAAI,CAAC,CAAC;IAC3E,CAAC;CACF;AA3DD,4BA2DC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { ProjectRegistry } from './project/projectRegistry';
|
|
2
|
+
export { TsConfigParser } from './tsConfig/tsconfigParser';
|
|
3
|
+
export { Decorator } from './dto/decorator';
|
|
4
|
+
export { Provider } from './dto/provider';
|
|
5
|
+
export { Identifier } from './dto/identifier';
|
|
6
|
+
export { Graph } from './dto/graph';
|
|
7
|
+
export { Parameter } from './dto/parameter';
|
|
8
|
+
export { hasDecorator, getDecorator, hasParentWithDecorator, hasGraphDecorator, getDecoratedMethods } from './utils/ts/decorators';
|
|
9
|
+
export { getDefinition } from './utils/ts/identifier';
|
|
10
|
+
export { getHookDeclaration, getHookDecarationFromTypedProvider, getAncestorProvider } from './utils/ts/providers';
|
|
11
|
+
export { setLogger } from './logger';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,sBAAsB,EACtB,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EACL,kBAAkB,EAClB,kCAAkC,EAClC,mBAAmB,EACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setLogger = exports.getAncestorProvider = exports.getHookDecarationFromTypedProvider = exports.getHookDeclaration = exports.getDefinition = exports.getDecoratedMethods = exports.hasGraphDecorator = exports.hasParentWithDecorator = exports.getDecorator = exports.hasDecorator = exports.Parameter = exports.Graph = exports.Identifier = exports.Provider = exports.Decorator = exports.TsConfigParser = exports.ProjectRegistry = void 0;
|
|
4
|
+
var projectRegistry_1 = require("./project/projectRegistry");
|
|
5
|
+
Object.defineProperty(exports, "ProjectRegistry", { enumerable: true, get: function () { return projectRegistry_1.ProjectRegistry; } });
|
|
6
|
+
var tsconfigParser_1 = require("./tsConfig/tsconfigParser");
|
|
7
|
+
Object.defineProperty(exports, "TsConfigParser", { enumerable: true, get: function () { return tsconfigParser_1.TsConfigParser; } });
|
|
8
|
+
var decorator_1 = require("./dto/decorator");
|
|
9
|
+
Object.defineProperty(exports, "Decorator", { enumerable: true, get: function () { return decorator_1.Decorator; } });
|
|
10
|
+
var provider_1 = require("./dto/provider");
|
|
11
|
+
Object.defineProperty(exports, "Provider", { enumerable: true, get: function () { return provider_1.Provider; } });
|
|
12
|
+
var identifier_1 = require("./dto/identifier");
|
|
13
|
+
Object.defineProperty(exports, "Identifier", { enumerable: true, get: function () { return identifier_1.Identifier; } });
|
|
14
|
+
var graph_1 = require("./dto/graph");
|
|
15
|
+
Object.defineProperty(exports, "Graph", { enumerable: true, get: function () { return graph_1.Graph; } });
|
|
16
|
+
var parameter_1 = require("./dto/parameter");
|
|
17
|
+
Object.defineProperty(exports, "Parameter", { enumerable: true, get: function () { return parameter_1.Parameter; } });
|
|
18
|
+
var decorators_1 = require("./utils/ts/decorators");
|
|
19
|
+
Object.defineProperty(exports, "hasDecorator", { enumerable: true, get: function () { return decorators_1.hasDecorator; } });
|
|
20
|
+
Object.defineProperty(exports, "getDecorator", { enumerable: true, get: function () { return decorators_1.getDecorator; } });
|
|
21
|
+
Object.defineProperty(exports, "hasParentWithDecorator", { enumerable: true, get: function () { return decorators_1.hasParentWithDecorator; } });
|
|
22
|
+
Object.defineProperty(exports, "hasGraphDecorator", { enumerable: true, get: function () { return decorators_1.hasGraphDecorator; } });
|
|
23
|
+
Object.defineProperty(exports, "getDecoratedMethods", { enumerable: true, get: function () { return decorators_1.getDecoratedMethods; } });
|
|
24
|
+
var identifier_2 = require("./utils/ts/identifier");
|
|
25
|
+
Object.defineProperty(exports, "getDefinition", { enumerable: true, get: function () { return identifier_2.getDefinition; } });
|
|
26
|
+
var providers_1 = require("./utils/ts/providers");
|
|
27
|
+
Object.defineProperty(exports, "getHookDeclaration", { enumerable: true, get: function () { return providers_1.getHookDeclaration; } });
|
|
28
|
+
Object.defineProperty(exports, "getHookDecarationFromTypedProvider", { enumerable: true, get: function () { return providers_1.getHookDecarationFromTypedProvider; } });
|
|
29
|
+
Object.defineProperty(exports, "getAncestorProvider", { enumerable: true, get: function () { return providers_1.getAncestorProvider; } });
|
|
30
|
+
var logger_1 = require("./logger");
|
|
31
|
+
Object.defineProperty(exports, "setLogger", { enumerable: true, get: function () { return logger_1.setLogger; } });
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6DAA4D;AAAnD,kHAAA,eAAe,OAAA;AACxB,4DAA2D;AAAlD,gHAAA,cAAc,OAAA;AACvB,6CAA4C;AAAnC,sGAAA,SAAS,OAAA;AAClB,2CAA0C;AAAjC,oGAAA,QAAQ,OAAA;AACjB,+CAA8C;AAArC,wGAAA,UAAU,OAAA;AACnB,qCAAoC;AAA3B,8FAAA,KAAK,OAAA;AACd,6CAA4C;AAAnC,sGAAA,SAAS,OAAA;AAClB,oDAM+B;AAL7B,0GAAA,YAAY,OAAA;AACZ,0GAAA,YAAY,OAAA;AACZ,oHAAA,sBAAsB,OAAA;AACtB,+GAAA,iBAAiB,OAAA;AACjB,iHAAA,mBAAmB,OAAA;AAErB,oDAAsD;AAA7C,2GAAA,aAAa,OAAA;AACtB,kDAI8B;AAH5B,+GAAA,kBAAkB,OAAA;AAClB,+HAAA,kCAAkC,OAAA;AAClC,gHAAA,mBAAmB,OAAA;AAErB,mCAAqC;AAA5B,mGAAA,SAAS,OAAA"}
|
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface Logger {
|
|
2
|
+
info(message: string): void;
|
|
3
|
+
error(message: string, error?: Error): void;
|
|
4
|
+
warn(message: string): void;
|
|
5
|
+
debug(message: string): void;
|
|
6
|
+
}
|
|
7
|
+
export declare class NoOpLogger implements Logger {
|
|
8
|
+
info(_message: string): void;
|
|
9
|
+
error(_message: string, _error?: Error): void;
|
|
10
|
+
warn(_message: string): void;
|
|
11
|
+
debug(_message: string): void;
|
|
12
|
+
}
|
|
13
|
+
export declare function setLogger($logger: Logger): void;
|
|
14
|
+
export declare function getLogger(): any;
|
|
15
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM;IACrB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IAC5C,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,qBAAa,UAAW,YAAW,MAAM;IACvC,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAI5B,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK,GAAG,IAAI;IAI7C,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAI5B,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;CAG9B;AAGD,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,QAExC;AAED,wBAAgB,SAAS,QAExB"}
|
package/dist/logger.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NoOpLogger = void 0;
|
|
4
|
+
exports.setLogger = setLogger;
|
|
5
|
+
exports.getLogger = getLogger;
|
|
6
|
+
class NoOpLogger {
|
|
7
|
+
info(_message) {
|
|
8
|
+
// No-op
|
|
9
|
+
}
|
|
10
|
+
error(_message, _error) {
|
|
11
|
+
// No-op
|
|
12
|
+
}
|
|
13
|
+
warn(_message) {
|
|
14
|
+
// No-op
|
|
15
|
+
}
|
|
16
|
+
debug(_message) {
|
|
17
|
+
// No-op
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.NoOpLogger = NoOpLogger;
|
|
21
|
+
const logger = new NoOpLogger();
|
|
22
|
+
function setLogger($logger) {
|
|
23
|
+
global['tsMorphExtensionsLogger'] = $logger;
|
|
24
|
+
}
|
|
25
|
+
function getLogger() {
|
|
26
|
+
return global['tsMorphExtensionsLogger'] || logger;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";;;AA0BA,8BAEC;AAED,8BAEC;AAzBD,MAAa,UAAU;IACrB,IAAI,CAAC,QAAgB;QACnB,QAAQ;IACV,CAAC;IAED,KAAK,CAAC,QAAgB,EAAE,MAAc;QACpC,QAAQ;IACV,CAAC;IAED,IAAI,CAAC,QAAgB;QACnB,QAAQ;IACV,CAAC;IAED,KAAK,CAAC,QAAgB;QACpB,QAAQ;IACV,CAAC;CACF;AAhBD,gCAgBC;AAED,MAAM,MAAM,GAAW,IAAI,UAAU,EAAE,CAAC;AACxC,SAAgB,SAAS,CAAC,OAAe;IACtC,MAAc,CAAC,yBAAyB,CAAC,GAAG,OAAO,CAAC;AACvD,CAAC;AAED,SAAgB,SAAS;IACvB,OAAQ,MAAc,CAAC,yBAAyB,CAAC,IAAI,MAAM,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Project } from "ts-morph";
|
|
2
|
+
import { Logger } from "../logger";
|
|
3
|
+
import { TsConfigParser } from "../tsConfig/tsconfigParser";
|
|
4
|
+
type Options = {
|
|
5
|
+
overrideTsConfigPath?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare class ProjectRegistry {
|
|
8
|
+
private readonly logger;
|
|
9
|
+
private readonly tsconfigParser;
|
|
10
|
+
private readonly options?;
|
|
11
|
+
private readonly projects;
|
|
12
|
+
private readonly tempFiles;
|
|
13
|
+
constructor(logger?: Logger, tsconfigParser?: TsConfigParser, options?: Options | undefined);
|
|
14
|
+
get(filePathOrUri: string): Project;
|
|
15
|
+
getSourceFile(filePathOrUri: string): import("ts-morph").SourceFile | undefined;
|
|
16
|
+
getSourceFileOrThrow(filePathOrUri: string): import("ts-morph").SourceFile;
|
|
17
|
+
private normalizeFilePath;
|
|
18
|
+
private ensureProject;
|
|
19
|
+
private saveConfigToTempFile;
|
|
20
|
+
private resolveTsConfigPath;
|
|
21
|
+
private findClosestTsConfig;
|
|
22
|
+
dispose(): void;
|
|
23
|
+
private clearTempTsConfigFiles;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=projectRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projectRegistry.d.ts","sourceRoot":"","sources":["../../src/project/projectRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGnC,OAAO,EAAE,MAAM,EAAc,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAY,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAItE,KAAK,OAAO,GAAG;IACb,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B,CAAC;AAEF,qBAAa,eAAe;IAKxB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;IAN3B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAmC;IAC5D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA0B;gBAGjC,MAAM,GAAE,MAAyB,EACjC,cAAc,GAAE,cAAqC,EACrD,OAAO,CAAC,EAAE,OAAO,YAAA;IAG7B,GAAG,CAAC,aAAa,EAAE,MAAM;IAOzB,aAAa,CAAC,aAAa,EAAE,MAAM;IAMnC,oBAAoB,CAAC,aAAa,EAAE,MAAM;IAMjD,OAAO,CAAC,iBAAiB;IAIzB,OAAO,CAAC,aAAa;IAUrB,OAAO,CAAC,oBAAoB;IAc5B,OAAO,CAAC,mBAAmB;IAK3B,OAAO,CAAC,mBAAmB;IAYpB,OAAO;IAQd,OAAO,CAAC,sBAAsB;CAU/B"}
|