@runtyped/type-compiler 1.0.20-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +4 -0
- package/compiler-debug.ts +38 -0
- package/deepkit-compiler-debug.js +5 -0
- package/deepkit-type-install.js +5 -0
- package/dist/cjs/compiler-debug.d.ts +1 -0
- package/dist/cjs/compiler-debug.js +28 -0
- package/dist/cjs/compiler-debug.js.map +1 -0
- package/dist/cjs/index.d.ts +7 -0
- package/dist/cjs/index.js +36 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/install-transformer.d.ts +7 -0
- package/dist/cjs/install-transformer.js +77 -0
- package/dist/cjs/install-transformer.js.map +1 -0
- package/dist/cjs/src/compiler.d.ts +313 -0
- package/dist/cjs/src/compiler.js +2506 -0
- package/dist/cjs/src/compiler.js.map +1 -0
- package/dist/cjs/src/config.d.ts +83 -0
- package/dist/cjs/src/config.js +248 -0
- package/dist/cjs/src/config.js.map +1 -0
- package/dist/cjs/src/debug.d.ts +9 -0
- package/dist/cjs/src/debug.js +26 -0
- package/dist/cjs/src/debug.js.map +1 -0
- package/dist/cjs/src/loader.d.ts +18 -0
- package/dist/cjs/src/loader.js +55 -0
- package/dist/cjs/src/loader.js.map +1 -0
- package/dist/cjs/src/plugin.d.ts +14 -0
- package/dist/cjs/src/plugin.js +46 -0
- package/dist/cjs/src/plugin.js.map +1 -0
- package/dist/cjs/src/reflection-ast.d.ts +46 -0
- package/dist/cjs/src/reflection-ast.js +335 -0
- package/dist/cjs/src/reflection-ast.js.map +1 -0
- package/dist/cjs/src/resolver.d.ts +27 -0
- package/dist/cjs/src/resolver.js +88 -0
- package/dist/cjs/src/resolver.js.map +1 -0
- package/dist/cjs/src/ts-types.d.ts +17 -0
- package/dist/cjs/src/ts-types.js +6 -0
- package/dist/cjs/src/ts-types.js.map +1 -0
- package/dist/esm/compiler-debug.d.ts +1 -0
- package/dist/esm/compiler-debug.js +26 -0
- package/dist/esm/compiler-debug.js.map +1 -0
- package/dist/esm/index.d.ts +7 -0
- package/dist/esm/index.js +19 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/install-transformer.d.ts +7 -0
- package/dist/esm/install-transformer.js +75 -0
- package/dist/esm/install-transformer.js.map +1 -0
- package/dist/esm/src/compiler.d.ts +313 -0
- package/dist/esm/src/compiler.js +2463 -0
- package/dist/esm/src/compiler.js.map +1 -0
- package/dist/esm/src/config.d.ts +83 -0
- package/dist/esm/src/config.js +238 -0
- package/dist/esm/src/config.js.map +1 -0
- package/dist/esm/src/debug.d.ts +9 -0
- package/dist/esm/src/debug.js +21 -0
- package/dist/esm/src/debug.js.map +1 -0
- package/dist/esm/src/loader.d.ts +18 -0
- package/dist/esm/src/loader.js +48 -0
- package/dist/esm/src/loader.js.map +1 -0
- package/dist/esm/src/plugin.d.ts +14 -0
- package/dist/esm/src/plugin.js +40 -0
- package/dist/esm/src/plugin.js.map +1 -0
- package/dist/esm/src/reflection-ast.d.ts +46 -0
- package/dist/esm/src/reflection-ast.js +284 -0
- package/dist/esm/src/reflection-ast.js.map +1 -0
- package/dist/esm/src/resolver.d.ts +27 -0
- package/dist/esm/src/resolver.js +80 -0
- package/dist/esm/src/resolver.js.map +1 -0
- package/dist/esm/src/ts-types.d.ts +17 -0
- package/dist/esm/src/ts-types.js +5 -0
- package/dist/esm/src/ts-types.js.map +1 -0
- package/index.ts +22 -0
- package/install-transformer.ts +84 -0
- package/package.json +59 -0
- package/src/compiler.ts +3003 -0
- package/src/config.ts +331 -0
- package/src/debug.ts +22 -0
- package/src/loader.ts +58 -0
- package/src/plugin.ts +58 -0
- package/src/reflection-ast.ts +335 -0
- package/src/resolver.ts +113 -0
- package/src/ts-types.ts +28 -0
- package/tsconfig.esm.json +16 -0
- package/tsconfig.json +27 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DeepkitLoader = void 0;
|
|
7
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
8
|
+
const compiler_js_1 = require("./compiler.js");
|
|
9
|
+
class DeepkitLoader {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.options = {
|
|
12
|
+
allowJs: true,
|
|
13
|
+
declaration: false,
|
|
14
|
+
};
|
|
15
|
+
this.host = typescript_1.default.createCompilerHost(this.options);
|
|
16
|
+
this.program = typescript_1.default.createProgram([], this.options, this.host);
|
|
17
|
+
this.printer = typescript_1.default.createPrinter({ newLine: typescript_1.default.NewLineKind.LineFeed });
|
|
18
|
+
this.cache = new compiler_js_1.Cache;
|
|
19
|
+
this.knownFiles = {};
|
|
20
|
+
this.sourceFiles = {};
|
|
21
|
+
const originReadFile = this.host.readFile;
|
|
22
|
+
this.host.readFile = (fileName) => {
|
|
23
|
+
if (this.knownFiles[fileName])
|
|
24
|
+
return this.knownFiles[fileName];
|
|
25
|
+
return originReadFile.call(this.host, fileName);
|
|
26
|
+
};
|
|
27
|
+
//the program should not write any files
|
|
28
|
+
this.host.writeFile = () => {
|
|
29
|
+
};
|
|
30
|
+
const originalGetSourceFile = this.host.getSourceFile;
|
|
31
|
+
this.host.getSourceFile = (fileName, languageVersion, onError, shouldCreateNewSourceFile) => {
|
|
32
|
+
if (this.sourceFiles[fileName])
|
|
33
|
+
return this.sourceFiles[fileName];
|
|
34
|
+
return originalGetSourceFile.call(this.host, fileName, languageVersion, onError, shouldCreateNewSourceFile);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
transform(source, path) {
|
|
38
|
+
this.knownFiles[path] = source;
|
|
39
|
+
const sourceFile = typescript_1.default.createSourceFile(path, source, typescript_1.default.ScriptTarget.ESNext, true, path.endsWith('.tsx') ? typescript_1.default.ScriptKind.TSX : typescript_1.default.ScriptKind.TS);
|
|
40
|
+
let newSource = source;
|
|
41
|
+
typescript_1.default.transform(sourceFile, [
|
|
42
|
+
(context) => {
|
|
43
|
+
const transformer = new compiler_js_1.ReflectionTransformer(context, this.cache).forHost(this.host).withReflection({ reflection: 'default' });
|
|
44
|
+
return (node) => {
|
|
45
|
+
const sourceFile = transformer.transformSourceFile(node);
|
|
46
|
+
newSource = this.printer.printNode(typescript_1.default.EmitHint.SourceFile, sourceFile, sourceFile);
|
|
47
|
+
return sourceFile;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
], this.options);
|
|
51
|
+
return newSource;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.DeepkitLoader = DeepkitLoader;
|
|
55
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../../src/loader.ts"],"names":[],"mappings":";;;;;;AACA,4DAA4B;AAC5B,+CAA6D;AAE7D,MAAa,aAAa;IAgBtB;QAfU,YAAO,GAAoB;YACjC,OAAO,EAAE,IAAI;YACb,WAAW,EAAE,KAAK;SACrB,CAAC;QAEQ,SAAI,GAAG,oBAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAE3C,YAAO,GAAG,oBAAE,CAAC,aAAa,CAAC,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAExD,YAAO,GAAG,oBAAE,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,oBAAE,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC;QACjE,UAAK,GAAG,IAAI,mBAAK,CAAC;QAElB,eAAU,GAA+B,EAAE,CAAC;QAC5C,gBAAW,GAAmC,EAAE,CAAC;QAGvD,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;QAC1C,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,CAAC,Q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M,WAAW,GAAG,IAAI,mCAAqB,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,cAAc,CAAC,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC,CAAC;gBAChI,OAAO,CAAC,IAAgB,EAAc,EAAE;oBACpC,MAAM,UAAU,GAAG,WAAW,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;oBAEzD,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,oBAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;oBACnF,OAAO,UAAU,CAAC;gBACtB,CAAC,CAAC;YACN,CAAC;SACJ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAEjB,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ;AArDD,sCAqDC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
export interface Options {
|
|
3
|
+
include?: string;
|
|
4
|
+
exclude?: string;
|
|
5
|
+
tsConfig?: string;
|
|
6
|
+
transformers?: ts.CustomTransformers;
|
|
7
|
+
compilerOptions?: ts.CompilerOptions;
|
|
8
|
+
readFile?: (path: string) => string | undefined;
|
|
9
|
+
}
|
|
10
|
+
export type Transform = (code: string, fileName: string) => {
|
|
11
|
+
code: string;
|
|
12
|
+
map?: string;
|
|
13
|
+
} | undefined;
|
|
14
|
+
export declare function deepkitType(options?: Options): Transform;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.deepkitType = deepkitType;
|
|
7
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
8
|
+
const process_1 = require("process");
|
|
9
|
+
const pluginutils_1 = require("@rollup/pluginutils");
|
|
10
|
+
const compiler_js_1 = require("./compiler.js");
|
|
11
|
+
function deepkitType(options = {}) {
|
|
12
|
+
const filter = (0, pluginutils_1.createFilter)(options.include ?? ['**/*.tsx', '**/*.ts'], options.exclude ?? 'node_modules/**');
|
|
13
|
+
const transformers = options.transformers || {
|
|
14
|
+
before: [compiler_js_1.transformer],
|
|
15
|
+
after: [compiler_js_1.declarationTransformer],
|
|
16
|
+
};
|
|
17
|
+
const configFilePath = options.tsConfig || (0, process_1.cwd)() + '/tsconfig.json';
|
|
18
|
+
const tsConfig = typescript_1.default.readConfigFile(configFilePath, options.readFile || typescript_1.default.sys.readFile);
|
|
19
|
+
if (tsConfig.error) {
|
|
20
|
+
throw new Error(typescript_1.default.formatDiagnostic(tsConfig.error, {
|
|
21
|
+
getCanonicalFileName: (fileName) => fileName,
|
|
22
|
+
getCurrentDirectory: typescript_1.default.sys.getCurrentDirectory,
|
|
23
|
+
getNewLine: () => typescript_1.default.sys.newLine,
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
const compilerOptions = Object.assign({
|
|
27
|
+
'target': typescript_1.default.ScriptTarget.ESNext,
|
|
28
|
+
'module': typescript_1.default.ModuleKind.ESNext,
|
|
29
|
+
configFilePath,
|
|
30
|
+
}, tsConfig.config, options.compilerOptions || {});
|
|
31
|
+
return function transform(code, fileName) {
|
|
32
|
+
if (!filter(fileName))
|
|
33
|
+
return;
|
|
34
|
+
const transformed = typescript_1.default.transpileModule(code, {
|
|
35
|
+
compilerOptions,
|
|
36
|
+
fileName,
|
|
37
|
+
//@ts-ignore
|
|
38
|
+
transformers
|
|
39
|
+
});
|
|
40
|
+
return {
|
|
41
|
+
code: transformed.outputText,
|
|
42
|
+
map: transformed.sourceMapText,
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{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OAAO,CAAC,eAAe,IAAI,EAAE,CAAC,CAAC;IAEnD,OAAO,SAAS,SAAS,CAAC,IAAY,EAAE,QAAgB;QACpD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;YAAE,OAAO;QAE9B,MAAM,WAAW,GAAG,oBAAE,CAAC,eAAe,CAAC,IAAI,EAAE;YACzC,eAAe;YACf,QAAQ;YACR,YAAY;YACZ,YAAY;SACf,CAAC,CAAC;QAEH,OAAO;YACH,IAAI,EAAE,WAAW,CAAC,UAAU;YAC5B,GAAG,EAAE,WAAW,CAAC,aAAa;SACjC,CAAC;IACN,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import ts, { __String, ArrowFunction, BinaryExpression, EntityName, Expression, Identifier, ImportDeclaration, JSDoc, JSDocImportTag, ModifierLike, Node, NodeArray, NodeFactory, PrivateIdentifier, PropertyAccessExpression, PropertyName, QualifiedName, StringLiteral, SymbolTable } from 'typescript';
|
|
2
|
+
import { SourceFile } from './ts-types.js';
|
|
3
|
+
export type PackExpression = Expression | string | number | boolean | bigint;
|
|
4
|
+
export declare function getIdentifierName(node: Identifier | PrivateIdentifier | StringLiteral | __String): string;
|
|
5
|
+
export declare function getEscapedText(node: Identifier | PrivateIdentifier | StringLiteral | __String): string;
|
|
6
|
+
export declare function findSourceFile(node: Node): SourceFile | undefined;
|
|
7
|
+
export declare function joinQualifiedName(name: EntityName): string;
|
|
8
|
+
export declare function getCommentOfNode(sourceFile: SourceFile, node: Node): string | undefined;
|
|
9
|
+
export declare function parseJSDocAttributeFromText(comment: string, attribute: string): string | undefined;
|
|
10
|
+
export declare function extractJSDocAttribute(sourceFile: SourceFile, node: Node | undefined, attribute: string): string | undefined;
|
|
11
|
+
export declare function getPropertyName(f: NodeFactory, node?: PropertyName): string | symbol | number | ArrowFunction;
|
|
12
|
+
export declare function getNameAsString(node?: PropertyName | QualifiedName): string;
|
|
13
|
+
export declare function hasModifier(node: Node & {
|
|
14
|
+
modifiers?: NodeArray<ModifierLike>;
|
|
15
|
+
}, modifier: ts.SyntaxKind): boolean;
|
|
16
|
+
export declare class NodeConverter {
|
|
17
|
+
protected f: NodeFactory;
|
|
18
|
+
constructor(f: NodeFactory);
|
|
19
|
+
toExpression<T extends PackExpression | PackExpression[]>(node?: T): Expression;
|
|
20
|
+
}
|
|
21
|
+
export declare function isNodeWithLocals(node: Node): node is (Node & {
|
|
22
|
+
locals: SymbolTable | undefined;
|
|
23
|
+
});
|
|
24
|
+
export declare function getGlobalsOfSourceFile(file: SourceFile): SymbolTable | void;
|
|
25
|
+
/**
|
|
26
|
+
* For imports that can removed (like a class import only used as type only, like `p: Model[]`) we have
|
|
27
|
+
* to modify the import so TS does not remove it.
|
|
28
|
+
*/
|
|
29
|
+
export declare function ensureImportIsEmitted(importDeclaration: ImportDeclaration | JSDocImportTag, specifierName?: Identifier): void;
|
|
30
|
+
/**
|
|
31
|
+
* Serializes an entity name as an expression for decorator type metadata.
|
|
32
|
+
*
|
|
33
|
+
* @param node The entity name to serialize.
|
|
34
|
+
*/
|
|
35
|
+
export declare function serializeEntityNameAsExpression(f: NodeFactory, node: EntityName): SerializedEntityNameAsExpression;
|
|
36
|
+
type SerializedEntityNameAsExpression = Identifier | BinaryExpression | PropertyAccessExpression;
|
|
37
|
+
export type MetaNode = Node & {
|
|
38
|
+
jsDoc?: JSDoc[];
|
|
39
|
+
_original?: MetaNode;
|
|
40
|
+
original?: MetaNode;
|
|
41
|
+
_symbol?: Symbol;
|
|
42
|
+
symbol?: Symbol;
|
|
43
|
+
_parent?: MetaNode;
|
|
44
|
+
localSymbol?: Symbol;
|
|
45
|
+
};
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Runtyped Framework
|
|
4
|
+
* Copyright (c) Deepkit UG, Marc J. Schmidt
|
|
5
|
+
* Copyright (c) Jacopo Scazzosi
|
|
6
|
+
*
|
|
7
|
+
* This program is free software: you can redistribute it and/or modify
|
|
8
|
+
* it under the terms of the MIT License.
|
|
9
|
+
*
|
|
10
|
+
* You should have received a copy of the MIT License along with this program.
|
|
11
|
+
*/
|
|
12
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
15
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
16
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
17
|
+
}
|
|
18
|
+
Object.defineProperty(o, k2, desc);
|
|
19
|
+
}) : (function(o, m, k, k2) {
|
|
20
|
+
if (k2 === undefined) k2 = k;
|
|
21
|
+
o[k2] = m[k];
|
|
22
|
+
}));
|
|
23
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
24
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
25
|
+
}) : function(o, v) {
|
|
26
|
+
o["default"] = v;
|
|
27
|
+
});
|
|
28
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
29
|
+
var ownKeys = function(o) {
|
|
30
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
31
|
+
var ar = [];
|
|
32
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
33
|
+
return ar;
|
|
34
|
+
};
|
|
35
|
+
return ownKeys(o);
|
|
36
|
+
};
|
|
37
|
+
return function (mod) {
|
|
38
|
+
if (mod && mod.__esModule) return mod;
|
|
39
|
+
var result = {};
|
|
40
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
41
|
+
__setModuleDefault(result, mod);
|
|
42
|
+
return result;
|
|
43
|
+
};
|
|
44
|
+
})();
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.NodeConverter = void 0;
|
|
47
|
+
exports.getIdentifierName = getIdentifierName;
|
|
48
|
+
exports.getEscapedText = getEscapedText;
|
|
49
|
+
exports.findSourceFile = findSourceFile;
|
|
50
|
+
exports.joinQualifiedName = joinQualifiedName;
|
|
51
|
+
exports.getCommentOfNode = getCommentOfNode;
|
|
52
|
+
exports.parseJSDocAttributeFromText = parseJSDocAttributeFromText;
|
|
53
|
+
exports.extractJSDocAttribute = extractJSDocAttribute;
|
|
54
|
+
exports.getPropertyName = getPropertyName;
|
|
55
|
+
exports.getNameAsString = getNameAsString;
|
|
56
|
+
exports.hasModifier = hasModifier;
|
|
57
|
+
exports.isNodeWithLocals = isNodeWithLocals;
|
|
58
|
+
exports.getGlobalsOfSourceFile = getGlobalsOfSourceFile;
|
|
59
|
+
exports.ensureImportIsEmitted = ensureImportIsEmitted;
|
|
60
|
+
exports.serializeEntityNameAsExpression = serializeEntityNameAsExpression;
|
|
61
|
+
const typescript_1 = __importStar(require("typescript"));
|
|
62
|
+
const ts_clone_node_1 = require("@marcj/ts-clone-node");
|
|
63
|
+
const { isArrowFunction, isComputedPropertyName, isIdentifier, isNamedImports, isNumericLiteral, isPrivateIdentifier, isStringLiteral, isStringLiteralLike, setOriginalNode, getLeadingCommentRanges, isNoSubstitutionTemplateLiteral, NodeFlags, SyntaxKind, } = typescript_1.default;
|
|
64
|
+
function is__String(value) {
|
|
65
|
+
return typeof value === 'string';
|
|
66
|
+
}
|
|
67
|
+
function getIdentifierName(node) {
|
|
68
|
+
if (is__String(node))
|
|
69
|
+
return node;
|
|
70
|
+
if (isIdentifier(node) || isPrivateIdentifier(node)) {
|
|
71
|
+
return typescript_1.default.unescapeLeadingUnderscores(node.escapedText);
|
|
72
|
+
}
|
|
73
|
+
if (isStringLiteral(node))
|
|
74
|
+
return node.text;
|
|
75
|
+
return '';
|
|
76
|
+
}
|
|
77
|
+
function getEscapedText(node) {
|
|
78
|
+
if (is__String(node))
|
|
79
|
+
return node;
|
|
80
|
+
if (isIdentifier(node) || isPrivateIdentifier(node))
|
|
81
|
+
return node.escapedText;
|
|
82
|
+
return getIdentifierName(node);
|
|
83
|
+
}
|
|
84
|
+
function findSourceFile(node) {
|
|
85
|
+
if (node.kind === SyntaxKind.SourceFile)
|
|
86
|
+
return node;
|
|
87
|
+
let current = node.parent;
|
|
88
|
+
while (current && current.kind !== SyntaxKind.SourceFile) {
|
|
89
|
+
current = current.parent;
|
|
90
|
+
}
|
|
91
|
+
return current;
|
|
92
|
+
}
|
|
93
|
+
function joinQualifiedName(name) {
|
|
94
|
+
if (isIdentifier(name))
|
|
95
|
+
return getIdentifierName(name);
|
|
96
|
+
return joinQualifiedName(name.left) + '_' + getIdentifierName(name.right);
|
|
97
|
+
}
|
|
98
|
+
function getCommentOfNode(sourceFile, node) {
|
|
99
|
+
const comment = getLeadingCommentRanges(sourceFile.text, node.pos);
|
|
100
|
+
if (!comment)
|
|
101
|
+
return;
|
|
102
|
+
return comment.map(v => sourceFile.text.substring(v.pos, v.end)).join('\n');
|
|
103
|
+
}
|
|
104
|
+
function parseJSDocAttributeFromText(comment, attribute) {
|
|
105
|
+
// no regex
|
|
106
|
+
const index = comment.indexOf('@' + attribute + ' ');
|
|
107
|
+
if (index === -1) {
|
|
108
|
+
let start = 0;
|
|
109
|
+
while (true) {
|
|
110
|
+
const withoutContent = comment.indexOf('@' + attribute, start);
|
|
111
|
+
if (withoutContent === -1)
|
|
112
|
+
return undefined;
|
|
113
|
+
//make sure next character is space or end of comment
|
|
114
|
+
const nextCharacter = comment[withoutContent + attribute.length + 1];
|
|
115
|
+
if (!nextCharacter || nextCharacter === ' ' || nextCharacter === '\n' || nextCharacter === '\r' || nextCharacter === '\t') {
|
|
116
|
+
return '';
|
|
117
|
+
}
|
|
118
|
+
start = withoutContent + attribute.length + 1;
|
|
119
|
+
}
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
const start = index + attribute.length + 2;
|
|
123
|
+
// end is either next attribute @ or end of comment.
|
|
124
|
+
const nextAttribute = comment.indexOf('@', start);
|
|
125
|
+
const endOfComment = comment.indexOf('*/', start);
|
|
126
|
+
const end = nextAttribute === -1 ? endOfComment : Math.min(nextAttribute, endOfComment);
|
|
127
|
+
const content = comment.substring(start, end).trim();
|
|
128
|
+
// make sure multiline comments are supported, and each line is trimmed and `\s\s\s\*` removed
|
|
129
|
+
return content.split('\n').map(v => {
|
|
130
|
+
const indexOfStar = v.indexOf('*');
|
|
131
|
+
if (indexOfStar === -1)
|
|
132
|
+
return v.trim();
|
|
133
|
+
return v.substring(indexOfStar + 1).trim();
|
|
134
|
+
}).join('\n');
|
|
135
|
+
}
|
|
136
|
+
function extractJSDocAttribute(sourceFile, node, attribute) {
|
|
137
|
+
// in TypeScript 5.3 they made JSDoc parsing optional and disabled by default.
|
|
138
|
+
// we need to read the comments manually and then parse @{attribute} {value} manually.
|
|
139
|
+
// we need reference to SourceFile, since Node.getSourceFile() although available in types,
|
|
140
|
+
// is not available at runtime sometimes (works in tests, but fails with tsc).
|
|
141
|
+
if (!node)
|
|
142
|
+
return undefined;
|
|
143
|
+
const comment = getCommentOfNode(sourceFile, node);
|
|
144
|
+
if (!comment)
|
|
145
|
+
return undefined;
|
|
146
|
+
return parseJSDocAttributeFromText(comment, attribute);
|
|
147
|
+
}
|
|
148
|
+
function getPropertyName(f, node) {
|
|
149
|
+
if (!node)
|
|
150
|
+
return '';
|
|
151
|
+
if (isIdentifier(node))
|
|
152
|
+
return getIdentifierName(node);
|
|
153
|
+
if (isStringLiteral(node))
|
|
154
|
+
return node.text;
|
|
155
|
+
if (isNumericLiteral(node))
|
|
156
|
+
return +node.text;
|
|
157
|
+
if (isNoSubstitutionTemplateLiteral(node))
|
|
158
|
+
return node.text;
|
|
159
|
+
if (isComputedPropertyName(node)) {
|
|
160
|
+
return f.createArrowFunction(undefined, undefined, [], undefined, undefined, node.expression);
|
|
161
|
+
}
|
|
162
|
+
if (isPrivateIdentifier(node))
|
|
163
|
+
return getIdentifierName(node);
|
|
164
|
+
return '';
|
|
165
|
+
}
|
|
166
|
+
function getNameAsString(node) {
|
|
167
|
+
if (!node)
|
|
168
|
+
return '';
|
|
169
|
+
if (isIdentifier(node))
|
|
170
|
+
return getIdentifierName(node);
|
|
171
|
+
if (isStringLiteral(node))
|
|
172
|
+
return node.text;
|
|
173
|
+
if (isNumericLiteral(node))
|
|
174
|
+
return node.text;
|
|
175
|
+
if ((0, typescript_1.isBigIntLiteral)(node))
|
|
176
|
+
return node.text;
|
|
177
|
+
if (isNoSubstitutionTemplateLiteral(node))
|
|
178
|
+
return node.text;
|
|
179
|
+
if (isComputedPropertyName(node)) {
|
|
180
|
+
if (isStringLiteralLike(node) || isNumericLiteral(node))
|
|
181
|
+
return node.text;
|
|
182
|
+
return '';
|
|
183
|
+
}
|
|
184
|
+
if (isPrivateIdentifier(node))
|
|
185
|
+
return getIdentifierName(node);
|
|
186
|
+
return joinQualifiedName(node);
|
|
187
|
+
}
|
|
188
|
+
function hasModifier(node, modifier) {
|
|
189
|
+
if (!node.modifiers)
|
|
190
|
+
return false;
|
|
191
|
+
return node.modifiers.some(v => v.kind === modifier);
|
|
192
|
+
}
|
|
193
|
+
const cloneHook = (node, payload) => {
|
|
194
|
+
if (isIdentifier(node)) {
|
|
195
|
+
//ts-clone-node wants to read `node.text` which does not exist. we hook into it and provide the correct value.
|
|
196
|
+
return {
|
|
197
|
+
text: () => {
|
|
198
|
+
return getIdentifierName(node);
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
return;
|
|
203
|
+
};
|
|
204
|
+
class NodeConverter {
|
|
205
|
+
constructor(f) {
|
|
206
|
+
this.f = f;
|
|
207
|
+
}
|
|
208
|
+
toExpression(node) {
|
|
209
|
+
if (node === undefined)
|
|
210
|
+
return this.f.createIdentifier('undefined');
|
|
211
|
+
if (Array.isArray(node)) {
|
|
212
|
+
return this.f.createArrayLiteralExpression(this.f.createNodeArray(node.map(v => this.toExpression(v))));
|
|
213
|
+
}
|
|
214
|
+
if ('string' === typeof node)
|
|
215
|
+
return this.f.createStringLiteral(node, true);
|
|
216
|
+
if ('number' === typeof node)
|
|
217
|
+
return this.f.createNumericLiteral(node);
|
|
218
|
+
if ('bigint' === typeof node)
|
|
219
|
+
return this.f.createBigIntLiteral(String(node));
|
|
220
|
+
if ('boolean' === typeof node)
|
|
221
|
+
return node ? this.f.createTrue() : this.f.createFalse();
|
|
222
|
+
if (node.pos === -1 && node.end === -1 && node.parent === undefined) {
|
|
223
|
+
if (isArrowFunction(node)) {
|
|
224
|
+
if (node.body.pos === -1 && node.body.end === -1 && node.body.parent === undefined)
|
|
225
|
+
return node;
|
|
226
|
+
return this.f.createArrowFunction(node.modifiers, node.typeParameters, node.parameters, node.type, node.equalsGreaterThanToken, this.toExpression(node.body));
|
|
227
|
+
}
|
|
228
|
+
return node;
|
|
229
|
+
}
|
|
230
|
+
switch (node.kind) {
|
|
231
|
+
case SyntaxKind.Identifier:
|
|
232
|
+
return finish(node, this.f.createIdentifier(getIdentifierName(node)));
|
|
233
|
+
case SyntaxKind.StringLiteral:
|
|
234
|
+
return finish(node, this.f.createStringLiteral(node.text));
|
|
235
|
+
case SyntaxKind.NumericLiteral:
|
|
236
|
+
return finish(node, this.f.createNumericLiteral(node.text));
|
|
237
|
+
case SyntaxKind.BigIntLiteral:
|
|
238
|
+
return finish(node, this.f.createBigIntLiteral(node.text));
|
|
239
|
+
case SyntaxKind.TrueKeyword:
|
|
240
|
+
return finish(node, this.f.createTrue());
|
|
241
|
+
case SyntaxKind.FalseKeyword:
|
|
242
|
+
return finish(node, this.f.createFalse());
|
|
243
|
+
}
|
|
244
|
+
//todo: ts-node-clone broke with ts 4.8,
|
|
245
|
+
// => TypeError: Cannot read properties of undefined (reading 'emitNode')
|
|
246
|
+
// which is probably due a broken node clone. We need to figure out which node it is
|
|
247
|
+
// and see what the issue is. since ts-node-clone is not really maintained anymore,
|
|
248
|
+
// we need to fork it
|
|
249
|
+
try {
|
|
250
|
+
return (0, ts_clone_node_1.cloneNode)(node, {
|
|
251
|
+
preserveComments: false,
|
|
252
|
+
factory: this.f,
|
|
253
|
+
setOriginalNodes: true,
|
|
254
|
+
preserveSymbols: true,
|
|
255
|
+
setParents: true,
|
|
256
|
+
hook: cloneHook,
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
catch (error) {
|
|
260
|
+
console.error('could not clone node', node);
|
|
261
|
+
throw error;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
exports.NodeConverter = NodeConverter;
|
|
266
|
+
function isExternalOrCommonJsModule(file) {
|
|
267
|
+
//both attributes are internal and not yet public
|
|
268
|
+
return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined;
|
|
269
|
+
}
|
|
270
|
+
function isNodeWithLocals(node) {
|
|
271
|
+
return 'locals' in node;
|
|
272
|
+
}
|
|
273
|
+
//logic copied from typescript
|
|
274
|
+
function getGlobalsOfSourceFile(file) {
|
|
275
|
+
if (file.redirectInfo)
|
|
276
|
+
return;
|
|
277
|
+
if (!isNodeWithLocals(file))
|
|
278
|
+
return;
|
|
279
|
+
if (!isExternalOrCommonJsModule(file))
|
|
280
|
+
return file.locals;
|
|
281
|
+
if (file.jsGlobalAugmentations)
|
|
282
|
+
return file.jsGlobalAugmentations;
|
|
283
|
+
if (file.symbol && file.symbol.globalExports)
|
|
284
|
+
return file.symbol.globalExports;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* For imports that can removed (like a class import only used as type only, like `p: Model[]`) we have
|
|
288
|
+
* to modify the import so TS does not remove it.
|
|
289
|
+
*/
|
|
290
|
+
function ensureImportIsEmitted(importDeclaration, specifierName) {
|
|
291
|
+
if (specifierName && importDeclaration.importClause && importDeclaration.importClause.namedBindings) {
|
|
292
|
+
// const binding = importDeclaration.importClause.namedBindings;
|
|
293
|
+
if (isNamedImports(importDeclaration.importClause.namedBindings)) {
|
|
294
|
+
for (const element of importDeclaration.importClause.namedBindings.elements) {
|
|
295
|
+
if (element.name.escapedText === specifierName.escapedText) {
|
|
296
|
+
element.flags |= NodeFlags.Synthesized;
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
importDeclaration.flags |= NodeFlags.Synthesized;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Serializes an entity name as an expression for decorator type metadata.
|
|
306
|
+
*
|
|
307
|
+
* @param node The entity name to serialize.
|
|
308
|
+
*/
|
|
309
|
+
function serializeEntityNameAsExpression(f, node) {
|
|
310
|
+
switch (node.kind) {
|
|
311
|
+
case SyntaxKind.Identifier:
|
|
312
|
+
return finish(node, f.createIdentifier(getIdentifierName(node)));
|
|
313
|
+
case SyntaxKind.QualifiedName:
|
|
314
|
+
return finish(node, serializeQualifiedNameAsExpression(f, node));
|
|
315
|
+
}
|
|
316
|
+
return node;
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Serializes an qualified name as an expression for decorator type metadata.
|
|
320
|
+
*
|
|
321
|
+
* @param node The qualified name to serialize.
|
|
322
|
+
* @param useFallback A value indicating whether to use logical operators to test for the
|
|
323
|
+
* qualified name at runtime.
|
|
324
|
+
*/
|
|
325
|
+
function serializeQualifiedNameAsExpression(f, node) {
|
|
326
|
+
return f.createPropertyAccessExpression(serializeEntityNameAsExpression(f, node.left), node.right);
|
|
327
|
+
}
|
|
328
|
+
function finish(oldNode, newNode) {
|
|
329
|
+
setOriginalNode(newNode, oldNode);
|
|
330
|
+
newNode._original = newNode.original;
|
|
331
|
+
newNode._symbol = oldNode._symbol ?? oldNode.symbol;
|
|
332
|
+
newNode.symbol = newNode._symbol;
|
|
333
|
+
return newNode;
|
|
334
|
+
}
|
|
335
|
+
//# sourceMappingURL=reflection-ast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reflection-ast.js","sourceRoot":"","sources":["../../../src/reflection-ast.ts"],"names":[],"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qB,OAAiB,EAAE,OAAU;IAC7D,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAClC,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC;IAErC,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;IACpD,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IACjC,OAAO,OAAO,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CompilerHost, CompilerOptions, ExportDeclaration, ImportDeclaration, JSDocImportTag, ResolvedModule, SourceFile, StringLiteral } from 'typescript';
|
|
2
|
+
export declare function patternMatch(path: string, patterns: string[], base?: string): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* A utility to resolve a module path and its declaration.
|
|
5
|
+
*
|
|
6
|
+
* It automatically reads a SourceFile, binds and caches it.
|
|
7
|
+
*/
|
|
8
|
+
export declare class Resolver {
|
|
9
|
+
compilerOptions: CompilerOptions;
|
|
10
|
+
host: CompilerHost;
|
|
11
|
+
protected sourceFiles: {
|
|
12
|
+
[fileName: string]: SourceFile;
|
|
13
|
+
};
|
|
14
|
+
constructor(compilerOptions: CompilerOptions, host: CompilerHost, sourceFiles: {
|
|
15
|
+
[fileName: string]: SourceFile;
|
|
16
|
+
});
|
|
17
|
+
resolve(from: SourceFile, importOrExportNode: ExportDeclaration | ImportDeclaration | JSDocImportTag): SourceFile | undefined;
|
|
18
|
+
protected resolveImpl(modulePath: StringLiteral, sourceFile: SourceFile): ResolvedModule | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Tries to resolve the .ts/d.ts file path for a given module path.
|
|
21
|
+
* Scans relative paths. Looks into package.json "types" and "exports" (with new 4.7 support)
|
|
22
|
+
*
|
|
23
|
+
* @param sourceFile the SourceFile of the file that contains the import. modulePath is relative to that.
|
|
24
|
+
* @param modulePath the x in 'from x'.
|
|
25
|
+
*/
|
|
26
|
+
resolveSourceFile(sourceFile: SourceFile, modulePath: StringLiteral): SourceFile | undefined;
|
|
27
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Resolver = void 0;
|
|
7
|
+
exports.patternMatch = patternMatch;
|
|
8
|
+
const micromatch_1 = __importDefault(require("micromatch"));
|
|
9
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
10
|
+
const { createSourceFile, resolveModuleName, isStringLiteral, JSDocParsingMode, ScriptTarget } = typescript_1.default;
|
|
11
|
+
function patternMatch(path, patterns, base) {
|
|
12
|
+
const include = patterns.filter(pattern => pattern[0] !== '!');
|
|
13
|
+
const exclude = patterns.filter(pattern => pattern[0] === '!').map(pattern => pattern.substring(1));
|
|
14
|
+
return micromatch_1.default.isMatch(path, include, {
|
|
15
|
+
ignore: exclude,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A utility to resolve a module path and its declaration.
|
|
20
|
+
*
|
|
21
|
+
* It automatically reads a SourceFile, binds and caches it.
|
|
22
|
+
*/
|
|
23
|
+
class Resolver {
|
|
24
|
+
constructor(compilerOptions, host, sourceFiles) {
|
|
25
|
+
this.compilerOptions = compilerOptions;
|
|
26
|
+
this.host = host;
|
|
27
|
+
this.sourceFiles = sourceFiles;
|
|
28
|
+
}
|
|
29
|
+
resolve(from, importOrExportNode) {
|
|
30
|
+
const moduleSpecifier = importOrExportNode.moduleSpecifier;
|
|
31
|
+
if (!moduleSpecifier)
|
|
32
|
+
return;
|
|
33
|
+
if (!isStringLiteral(moduleSpecifier))
|
|
34
|
+
return;
|
|
35
|
+
return this.resolveSourceFile(from, moduleSpecifier);
|
|
36
|
+
}
|
|
37
|
+
resolveImpl(modulePath, sourceFile) {
|
|
38
|
+
if (this.host.resolveModuleNameLiterals !== undefined) {
|
|
39
|
+
const results = this.host.resolveModuleNameLiterals([modulePath], sourceFile.fileName,
|
|
40
|
+
/*reusedNames*/ undefined, this.compilerOptions, sourceFile, undefined);
|
|
41
|
+
if (results[0])
|
|
42
|
+
return results[0].resolvedModule;
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (this.host.resolveModuleNames !== undefined) {
|
|
46
|
+
return this.host.resolveModuleNames([modulePath.text], sourceFile.fileName,
|
|
47
|
+
/*reusedNames*/ undefined,
|
|
48
|
+
/*redirectedReference*/ undefined, this.compilerOptions)[0];
|
|
49
|
+
}
|
|
50
|
+
const result = resolveModuleName(modulePath.text, sourceFile.fileName, this.compilerOptions, this.host);
|
|
51
|
+
return result.resolvedModule;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Tries to resolve the .ts/d.ts file path for a given module path.
|
|
55
|
+
* Scans relative paths. Looks into package.json "types" and "exports" (with new 4.7 support)
|
|
56
|
+
*
|
|
57
|
+
* @param sourceFile the SourceFile of the file that contains the import. modulePath is relative to that.
|
|
58
|
+
* @param modulePath the x in 'from x'.
|
|
59
|
+
*/
|
|
60
|
+
resolveSourceFile(sourceFile, modulePath) {
|
|
61
|
+
const result = this.resolveImpl(modulePath, sourceFile);
|
|
62
|
+
if (!result)
|
|
63
|
+
return;
|
|
64
|
+
// only .ts, .tsx and .d.ts files are supported
|
|
65
|
+
if (!result.resolvedFileName.endsWith('.ts')
|
|
66
|
+
&& !result.resolvedFileName.endsWith('.tsx')
|
|
67
|
+
&& !result.resolvedFileName.endsWith('.d.ts')) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const fileName = result.resolvedFileName;
|
|
71
|
+
if (this.sourceFiles[fileName])
|
|
72
|
+
return this.sourceFiles[fileName];
|
|
73
|
+
const source = this.host.readFile(result.resolvedFileName);
|
|
74
|
+
if (!source)
|
|
75
|
+
return;
|
|
76
|
+
const moduleSourceFile = (this.sourceFiles[fileName] = createSourceFile(fileName, source, {
|
|
77
|
+
languageVersion: this.compilerOptions.target || ScriptTarget.ES2018,
|
|
78
|
+
// JSDocParsingMode is not available in TS < 5.3
|
|
79
|
+
jsDocParsingMode: JSDocParsingMode ? JSDocParsingMode.ParseNone : undefined,
|
|
80
|
+
}, true));
|
|
81
|
+
this.sourceFiles[fileName] = moduleSourceFile;
|
|
82
|
+
//@ts-ignore
|
|
83
|
+
typescript_1.default.bindSourceFile(moduleSourceFile, this.compilerOptions);
|
|
84
|
+
return moduleSourceFile;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.Resolver = Resolver;
|
|
88
|
+
//# sourceMappingURL=resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolver.js","sourceRoot":"","sources":["../../../src/resolver.ts"],"names":[],"mappings":";;;;;;AAeA,oCAQC;AAvBD,4DAAoC;AAWpC,4DAA4B;AAE5B,MAAM,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,eAAe,EAAE,gBAAgB,EAAE,YAAY,EAAE,GAAG,oBAAE,CAAC;AAEpG,SAAgB,YAAY,CAAC,IAAY,EAAE,QAAkB,EAAE,IAAa;IACxE,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;IAE/D,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IAEpG,OAAO,oBAAU,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE;QACrC,MAAM,EAAE,OAAO;KAClB,CAAC,CAAC;AACP,CAAC;AAED;;;;GAIG;AACH,MAA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