@ai-dev-tools/test-copilot-core 1.0.19
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 +6 -0
- package/azure-pipelines.yml +51 -0
- package/out/cli/commands/appInsightTelemetry.d.ts +7 -0
- package/out/cli/commands/appInsightTelemetry.d.ts.map +1 -0
- package/out/cli/commands/appInsightTelemetry.js +76 -0
- package/out/cli/commands/appInsightTelemetry.js.map +1 -0
- package/out/cli/commands/cliConfig.d.ts +4 -0
- package/out/cli/commands/cliConfig.d.ts.map +1 -0
- package/out/cli/commands/cliConfig.js +68 -0
- package/out/cli/commands/cliConfig.js.map +1 -0
- package/out/cli/commands/prompt.d.ts +6 -0
- package/out/cli/commands/prompt.d.ts.map +1 -0
- package/out/cli/commands/prompt.js +29 -0
- package/out/cli/commands/prompt.js.map +1 -0
- package/out/cli/commands/ut.d.ts +14 -0
- package/out/cli/commands/ut.d.ts.map +1 -0
- package/out/cli/commands/ut.js +72 -0
- package/out/cli/commands/ut.js.map +1 -0
- package/out/cli/commands/utPipeCmdWrapper.d.ts +18 -0
- package/out/cli/commands/utPipeCmdWrapper.d.ts.map +1 -0
- package/out/cli/commands/utPipeCmdWrapper.js +37 -0
- package/out/cli/commands/utPipeCmdWrapper.js.map +1 -0
- package/out/cli/config/index.d.ts +15 -0
- package/out/cli/config/index.d.ts.map +1 -0
- package/out/cli/config/index.js +10 -0
- package/out/cli/config/index.js.map +1 -0
- package/out/cli/index.d.ts +3 -0
- package/out/cli/index.d.ts.map +1 -0
- package/out/cli/index.js +169 -0
- package/out/cli/index.js.map +1 -0
- package/out/cli/type.d.ts +11 -0
- package/out/cli/type.d.ts.map +1 -0
- package/out/cli/type.js +3 -0
- package/out/cli/type.js.map +1 -0
- package/out/cli/utils/ds.d.ts +3 -0
- package/out/cli/utils/ds.d.ts.map +1 -0
- package/out/cli/utils/ds.js +50 -0
- package/out/cli/utils/ds.js.map +1 -0
- package/out/cli/utils/gpt.d.ts +3 -0
- package/out/cli/utils/gpt.d.ts.map +1 -0
- package/out/cli/utils/gpt.js +63 -0
- package/out/cli/utils/gpt.js.map +1 -0
- package/out/core/analyze/cjs.d.ts +61 -0
- package/out/core/analyze/cjs.d.ts.map +1 -0
- package/out/core/analyze/cjs.js +358 -0
- package/out/core/analyze/cjs.js.map +1 -0
- package/out/core/analyze/class.d.ts +4 -0
- package/out/core/analyze/class.d.ts.map +1 -0
- package/out/core/analyze/class.js +32 -0
- package/out/core/analyze/class.js.map +1 -0
- package/out/core/analyze/declares.d.ts +7 -0
- package/out/core/analyze/declares.d.ts.map +1 -0
- package/out/core/analyze/declares.js +316 -0
- package/out/core/analyze/declares.js.map +1 -0
- package/out/core/analyze/deps.d.ts +8 -0
- package/out/core/analyze/deps.d.ts.map +1 -0
- package/out/core/analyze/deps.js +210 -0
- package/out/core/analyze/deps.js.map +1 -0
- package/out/core/analyze/functionComponent.d.ts +4 -0
- package/out/core/analyze/functionComponent.d.ts.map +1 -0
- package/out/core/analyze/functionComponent.js +77 -0
- package/out/core/analyze/functionComponent.js.map +1 -0
- package/out/core/analyze/functions.d.ts +4 -0
- package/out/core/analyze/functions.d.ts.map +1 -0
- package/out/core/analyze/functions.js +46 -0
- package/out/core/analyze/functions.js.map +1 -0
- package/out/core/analyze/index.d.ts +16 -0
- package/out/core/analyze/index.d.ts.map +1 -0
- package/out/core/analyze/index.js +149 -0
- package/out/core/analyze/index.js.map +1 -0
- package/out/core/analyze/index.type.d.ts +69 -0
- package/out/core/analyze/index.type.d.ts.map +1 -0
- package/out/core/analyze/index.type.js +14 -0
- package/out/core/analyze/index.type.js.map +1 -0
- package/out/core/analyze/utils/global.d.ts +2 -0
- package/out/core/analyze/utils/global.d.ts.map +1 -0
- package/out/core/analyze/utils/global.js +84 -0
- package/out/core/analyze/utils/global.js.map +1 -0
- package/out/core/analyzev2/declare/class.d.ts +4 -0
- package/out/core/analyzev2/declare/class.d.ts.map +1 -0
- package/out/core/analyzev2/declare/class.js +24 -0
- package/out/core/analyzev2/declare/class.js.map +1 -0
- package/out/core/analyzev2/declare/funcLike.d.ts +8 -0
- package/out/core/analyzev2/declare/funcLike.d.ts.map +1 -0
- package/out/core/analyzev2/declare/funcLike.js +71 -0
- package/out/core/analyzev2/declare/funcLike.js.map +1 -0
- package/out/core/analyzev2/declare/variable.d.ts +3 -0
- package/out/core/analyzev2/declare/variable.d.ts.map +1 -0
- package/out/core/analyzev2/declare/variable.js +15 -0
- package/out/core/analyzev2/declare/variable.js.map +1 -0
- package/out/core/analyzev2/file.d.ts +19 -0
- package/out/core/analyzev2/file.d.ts.map +1 -0
- package/out/core/analyzev2/file.js +449 -0
- package/out/core/analyzev2/file.js.map +1 -0
- package/out/core/analyzev2/index.d.ts +5 -0
- package/out/core/analyzev2/index.d.ts.map +1 -0
- package/out/core/analyzev2/index.js +30 -0
- package/out/core/analyzev2/index.js.map +1 -0
- package/out/core/analyzev2/type.d.ts +35 -0
- package/out/core/analyzev2/type.d.ts.map +1 -0
- package/out/core/analyzev2/type.js +3 -0
- package/out/core/analyzev2/type.js.map +1 -0
- package/out/core/config/index.d.ts +25 -0
- package/out/core/config/index.d.ts.map +1 -0
- package/out/core/config/index.js +14 -0
- package/out/core/config/index.js.map +1 -0
- package/out/core/constants.d.ts +9 -0
- package/out/core/constants.d.ts.map +1 -0
- package/out/core/constants.js +12 -0
- package/out/core/constants.js.map +1 -0
- package/out/core/features/common/base.d.ts +20 -0
- package/out/core/features/common/base.d.ts.map +1 -0
- package/out/core/features/common/base.js +77 -0
- package/out/core/features/common/base.js.map +1 -0
- package/out/core/features/common/types.d.ts +16 -0
- package/out/core/features/common/types.d.ts.map +1 -0
- package/out/core/features/common/types.js +12 -0
- package/out/core/features/common/types.js.map +1 -0
- package/out/core/features/generateFile.d.ts +31 -0
- package/out/core/features/generateFile.d.ts.map +1 -0
- package/out/core/features/generateFile.js +148 -0
- package/out/core/features/generateFile.js.map +1 -0
- package/out/core/features/generateSingle.d.ts +28 -0
- package/out/core/features/generateSingle.d.ts.map +1 -0
- package/out/core/features/generateSingle.js +149 -0
- package/out/core/features/generateSingle.js.map +1 -0
- package/out/core/features/index.d.ts +9 -0
- package/out/core/features/index.d.ts.map +1 -0
- package/out/core/features/index.js +16 -0
- package/out/core/features/index.js.map +1 -0
- package/out/core/features/lintFix.d.ts +2 -0
- package/out/core/features/lintFix.d.ts.map +1 -0
- package/out/core/features/lintFix.js +33 -0
- package/out/core/features/lintFix.js.map +1 -0
- package/out/core/features/mergeUTFile.d.ts +19 -0
- package/out/core/features/mergeUTFile.d.ts.map +1 -0
- package/out/core/features/mergeUTFile.js +63 -0
- package/out/core/features/mergeUTFile.js.map +1 -0
- package/out/core/features/removeFailedCases.d.ts +23 -0
- package/out/core/features/removeFailedCases.d.ts.map +1 -0
- package/out/core/features/removeFailedCases.js +81 -0
- package/out/core/features/removeFailedCases.js.map +1 -0
- package/out/core/features/updateSpec.d.ts +20 -0
- package/out/core/features/updateSpec.d.ts.map +1 -0
- package/out/core/features/updateSpec.js +98 -0
- package/out/core/features/updateSpec.js.map +1 -0
- package/out/core/features/validFix.d.ts +29 -0
- package/out/core/features/validFix.d.ts.map +1 -0
- package/out/core/features/validFix.js +219 -0
- package/out/core/features/validFix.js.map +1 -0
- package/out/core/generate/UTGen.d.ts +79 -0
- package/out/core/generate/UTGen.d.ts.map +1 -0
- package/out/core/generate/UTGen.js +795 -0
- package/out/core/generate/UTGen.js.map +1 -0
- package/out/core/llm/index.d.ts +9 -0
- package/out/core/llm/index.d.ts.map +1 -0
- package/out/core/llm/index.js +39 -0
- package/out/core/llm/index.js.map +1 -0
- package/out/core/llm/prompts/config.d.ts +6 -0
- package/out/core/llm/prompts/config.d.ts.map +1 -0
- package/out/core/llm/prompts/config.js +239 -0
- package/out/core/llm/prompts/config.js.map +1 -0
- package/out/core/llm/prompts/templates/common.d.ts +3 -0
- package/out/core/llm/prompts/templates/common.d.ts.map +1 -0
- package/out/core/llm/prompts/templates/common.js +27 -0
- package/out/core/llm/prompts/templates/common.js.map +1 -0
- package/out/core/llm/prompts/templates/fixCase.d.ts +4 -0
- package/out/core/llm/prompts/templates/fixCase.d.ts.map +1 -0
- package/out/core/llm/prompts/templates/fixCase.js +46 -0
- package/out/core/llm/prompts/templates/fixCase.js.map +1 -0
- package/out/core/llm/prompts/templates/fixLint.d.ts +3 -0
- package/out/core/llm/prompts/templates/fixLint.d.ts.map +1 -0
- package/out/core/llm/prompts/templates/fixLint.js +22 -0
- package/out/core/llm/prompts/templates/fixLint.js.map +1 -0
- package/out/core/llm/prompts/templates/genClassMemberUT.d.ts +5 -0
- package/out/core/llm/prompts/templates/genClassMemberUT.d.ts.map +1 -0
- package/out/core/llm/prompts/templates/genClassMemberUT.js +115 -0
- package/out/core/llm/prompts/templates/genClassMemberUT.js.map +1 -0
- package/out/core/llm/prompts/templates/genFuncUT.d.ts +4 -0
- package/out/core/llm/prompts/templates/genFuncUT.d.ts.map +1 -0
- package/out/core/llm/prompts/templates/genFuncUT.js +64 -0
- package/out/core/llm/prompts/templates/genFuncUT.js.map +1 -0
- package/out/core/llm/prompts/templates/mergeUT.d.ts +4 -0
- package/out/core/llm/prompts/templates/mergeUT.d.ts.map +1 -0
- package/out/core/llm/prompts/templates/mergeUT.js +106 -0
- package/out/core/llm/prompts/templates/mergeUT.js.map +1 -0
- package/out/core/llm/prompts/templates/msnStudio.d.ts +3 -0
- package/out/core/llm/prompts/templates/msnStudio.d.ts.map +1 -0
- package/out/core/llm/prompts/templates/msnStudio.js +36 -0
- package/out/core/llm/prompts/templates/msnStudio.js.map +1 -0
- package/out/core/llm/prompts/templates/snapshotUT.d.ts +4 -0
- package/out/core/llm/prompts/templates/snapshotUT.d.ts.map +1 -0
- package/out/core/llm/prompts/templates/snapshotUT.js +68 -0
- package/out/core/llm/prompts/templates/snapshotUT.js.map +1 -0
- package/out/core/llm/prompts/templates/updateSpecBlock.d.ts +3 -0
- package/out/core/llm/prompts/templates/updateSpecBlock.d.ts.map +1 -0
- package/out/core/llm/prompts/templates/updateSpecBlock.js +38 -0
- package/out/core/llm/prompts/templates/updateSpecBlock.js.map +1 -0
- package/out/core/llm/prompts/templates/updateSpecFile.d.ts +3 -0
- package/out/core/llm/prompts/templates/updateSpecFile.d.ts.map +1 -0
- package/out/core/llm/prompts/templates/updateSpecFile.js +30 -0
- package/out/core/llm/prompts/templates/updateSpecFile.js.map +1 -0
- package/out/core/llm/types.d.ts +80 -0
- package/out/core/llm/types.d.ts.map +1 -0
- package/out/core/llm/types.js +5 -0
- package/out/core/llm/types.js.map +1 -0
- package/out/core/quality/validateMockedTest.d.ts +3 -0
- package/out/core/quality/validateMockedTest.d.ts.map +1 -0
- package/out/core/quality/validateMockedTest.js +211 -0
- package/out/core/quality/validateMockedTest.js.map +1 -0
- package/out/core/utils/checkTestIgnore.d.ts +4 -0
- package/out/core/utils/checkTestIgnore.d.ts.map +1 -0
- package/out/core/utils/checkTestIgnore.js +52 -0
- package/out/core/utils/checkTestIgnore.js.map +1 -0
- package/out/core/utils/common.d.ts +4 -0
- package/out/core/utils/common.d.ts.map +1 -0
- package/out/core/utils/common.js +34 -0
- package/out/core/utils/common.js.map +1 -0
- package/out/core/utils/console.d.ts +8 -0
- package/out/core/utils/console.d.ts.map +1 -0
- package/out/core/utils/console.js +24 -0
- package/out/core/utils/console.js.map +1 -0
- package/out/core/utils/deps.d.ts +3 -0
- package/out/core/utils/deps.d.ts.map +1 -0
- package/out/core/utils/deps.js +58 -0
- package/out/core/utils/deps.js.map +1 -0
- package/out/core/utils/eslintRuleHandler.d.ts +3 -0
- package/out/core/utils/eslintRuleHandler.d.ts.map +1 -0
- package/out/core/utils/eslintRuleHandler.js +98 -0
- package/out/core/utils/eslintRuleHandler.js.map +1 -0
- package/out/core/utils/file.d.ts +18 -0
- package/out/core/utils/file.d.ts.map +1 -0
- package/out/core/utils/file.js +142 -0
- package/out/core/utils/file.js.map +1 -0
- package/out/core/utils/lint.d.ts +9 -0
- package/out/core/utils/lint.d.ts.map +1 -0
- package/out/core/utils/lint.js +95 -0
- package/out/core/utils/lint.js.map +1 -0
- package/out/core/utils/lru.d.ts +12 -0
- package/out/core/utils/lru.d.ts.map +1 -0
- package/out/core/utils/lru.js +47 -0
- package/out/core/utils/lru.js.map +1 -0
- package/out/core/utils/move.d.ts +12 -0
- package/out/core/utils/move.d.ts.map +1 -0
- package/out/core/utils/move.js +93 -0
- package/out/core/utils/move.js.map +1 -0
- package/out/core/utils/msnStudio.d.ts +13 -0
- package/out/core/utils/msnStudio.d.ts.map +1 -0
- package/out/core/utils/msnStudio.js +150 -0
- package/out/core/utils/msnStudio.js.map +1 -0
- package/out/core/utils/parseCustomizedCmd.d.ts +2 -0
- package/out/core/utils/parseCustomizedCmd.d.ts.map +1 -0
- package/out/core/utils/parseCustomizedCmd.js +32 -0
- package/out/core/utils/parseCustomizedCmd.js.map +1 -0
- package/out/core/utils/specBlock.d.ts +20 -0
- package/out/core/utils/specBlock.d.ts.map +1 -0
- package/out/core/utils/specBlock.js +231 -0
- package/out/core/utils/specBlock.js.map +1 -0
- package/out/core/utils/system.d.ts +13 -0
- package/out/core/utils/system.d.ts.map +1 -0
- package/out/core/utils/system.js +86 -0
- package/out/core/utils/system.js.map +1 -0
- package/out/core/utils/telemetry.d.ts +9 -0
- package/out/core/utils/telemetry.d.ts.map +1 -0
- package/out/core/utils/telemetry.js +32 -0
- package/out/core/utils/telemetry.js.map +1 -0
- package/out/core/utils/tsMorph.d.ts +13 -0
- package/out/core/utils/tsMorph.d.ts.map +1 -0
- package/out/core/utils/tsMorph.js +76 -0
- package/out/core/utils/tsMorph.js.map +1 -0
- package/out/core/valid/customizedLint.d.ts +2 -0
- package/out/core/valid/customizedLint.d.ts.map +1 -0
- package/out/core/valid/customizedLint.js +64 -0
- package/out/core/valid/customizedLint.js.map +1 -0
- package/out/core/valid/customizedTest.d.ts +3 -0
- package/out/core/valid/customizedTest.d.ts.map +1 -0
- package/out/core/valid/customizedTest.js +58 -0
- package/out/core/valid/customizedTest.js.map +1 -0
- package/out/core/valid/extractVitestConfig.d.ts +5 -0
- package/out/core/valid/extractVitestConfig.d.ts.map +1 -0
- package/out/core/valid/extractVitestConfig.js +97 -0
- package/out/core/valid/extractVitestConfig.js.map +1 -0
- package/out/core/valid/getViteConfig.d.ts +2 -0
- package/out/core/valid/getViteConfig.d.ts.map +1 -0
- package/out/core/valid/getViteConfig.js +65 -0
- package/out/core/valid/getViteConfig.js.map +1 -0
- package/out/core/valid/index.d.ts +15 -0
- package/out/core/valid/index.d.ts.map +1 -0
- package/out/core/valid/index.js +99 -0
- package/out/core/valid/index.js.map +1 -0
- package/out/core/valid/jest.d.ts +4 -0
- package/out/core/valid/jest.d.ts.map +1 -0
- package/out/core/valid/jest.js +121 -0
- package/out/core/valid/jest.js.map +1 -0
- package/out/core/valid/mock.d.ts +2 -0
- package/out/core/valid/mock.d.ts.map +1 -0
- package/out/core/valid/mock.js +149 -0
- package/out/core/valid/mock.js.map +1 -0
- package/out/core/valid/remove.d.ts +5 -0
- package/out/core/valid/remove.d.ts.map +1 -0
- package/out/core/valid/remove.js +109 -0
- package/out/core/valid/remove.js.map +1 -0
- package/out/core/valid/tag.d.ts +3 -0
- package/out/core/valid/tag.d.ts.map +1 -0
- package/out/core/valid/tag.js +91 -0
- package/out/core/valid/tag.js.map +1 -0
- package/out/core/valid/type.d.ts +83 -0
- package/out/core/valid/type.d.ts.map +1 -0
- package/out/core/valid/type.js +3 -0
- package/out/core/valid/type.js.map +1 -0
- package/out/core/valid/vitest.d.ts +3 -0
- package/out/core/valid/vitest.d.ts.map +1 -0
- package/out/core/valid/vitest.js +82 -0
- package/out/core/valid/vitest.js.map +1 -0
- package/out/index.d.ts +20 -0
- package/out/index.d.ts.map +1 -0
- package/out/index.js +60 -0
- package/out/index.js.map +1 -0
- package/out/setup.d.ts +11 -0
- package/out/setup.d.ts.map +1 -0
- package/out/setup.js +14 -0
- package/out/setup.js.map +1 -0
- package/out/types.d.ts +23 -0
- package/out/types.d.ts.map +1 -0
- package/out/types.js +3 -0
- package/out/types.js.map +1 -0
- package/package.json +39 -0
- package/package_devops.json +42 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractFC = extractFC;
|
|
4
|
+
const index_type_1 = require("./index.type");
|
|
5
|
+
const ts_morph_1 = require("ts-morph");
|
|
6
|
+
const deps_1 = require("./deps");
|
|
7
|
+
function extractFC(name, declaration, options) {
|
|
8
|
+
// only handle valuable declaration: const A: React.FC<Props> = () => {}
|
|
9
|
+
if (declaration.getKind() !== ts_morph_1.SyntaxKind.VariableDeclaration) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const varDecl = declaration.asKind(ts_morph_1.SyntaxKind.VariableDeclaration);
|
|
13
|
+
if (!varDecl) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
// 1. check whether type is: React.FC / FC / React.FunctionComponent
|
|
17
|
+
const typeNode = varDecl.getTypeNode();
|
|
18
|
+
if (!typeNode || typeNode.getKind() !== ts_morph_1.SyntaxKind.TypeReference) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const typeText = typeNode?.getText();
|
|
22
|
+
if (!typeText) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const isFC = typeText.startsWith("React.FC") ||
|
|
26
|
+
typeText.startsWith("React.FunctionComponent") ||
|
|
27
|
+
typeText.startsWith("FC");
|
|
28
|
+
if (!isFC) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
// 2. check whether initializer is ArrowFunction
|
|
32
|
+
const initializer = getFCInitializerArrowFn(varDecl);
|
|
33
|
+
if (!initializer) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
let body = declaration.getFullText().trim();
|
|
37
|
+
const parent = varDecl.getParent();
|
|
38
|
+
if (parent?.getKind() === ts_morph_1.SyntaxKind.VariableDeclarationList) {
|
|
39
|
+
const declarationList = parent;
|
|
40
|
+
const declarationKind = declarationList.getDeclarationKind();
|
|
41
|
+
if (!body.startsWith(declarationKind)) {
|
|
42
|
+
body = `${declarationKind} ${body}`;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// 3. get external identifiers
|
|
46
|
+
const externalIdentifiers = options?.skipDependencies ? undefined : (0, deps_1.searchExternalIdentifiers)(initializer, options);
|
|
47
|
+
// 4. return CodeMeta
|
|
48
|
+
return {
|
|
49
|
+
type: index_type_1.CodeType.Function,
|
|
50
|
+
name,
|
|
51
|
+
body: body.replaceAll(";;", ";"),
|
|
52
|
+
externalIdentifiers,
|
|
53
|
+
linesRange: [
|
|
54
|
+
declaration.getStartLineNumber(),
|
|
55
|
+
declaration.getEndLineNumber()
|
|
56
|
+
]
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function getFCInitializerArrowFn(varDecl) {
|
|
60
|
+
// 1. arrow function : const X = () => {}
|
|
61
|
+
const direct = varDecl.getInitializerIfKind(ts_morph_1.SyntaxKind.ArrowFunction);
|
|
62
|
+
if (direct) {
|
|
63
|
+
return direct;
|
|
64
|
+
}
|
|
65
|
+
// 2. handle call expression: const X = React.memo(() => {})
|
|
66
|
+
const init = varDecl.getInitializer();
|
|
67
|
+
if (init?.getKind() === ts_morph_1.SyntaxKind.CallExpression) {
|
|
68
|
+
const callExpr = init.asKind(ts_morph_1.SyntaxKind.CallExpression);
|
|
69
|
+
const args = callExpr?.getArguments();
|
|
70
|
+
// React.memo(() => {})
|
|
71
|
+
if (args?.length > 0 && args[0].getKind() === ts_morph_1.SyntaxKind.ArrowFunction) {
|
|
72
|
+
return args[0];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=functionComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functionComponent.js","sourceRoot":"","sources":["../../../src/core/analyze/functionComponent.ts"],"names":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AO,EAAE,KAAK,qBAAU,CAAC,aAAa,EAAE,CAAC;YACrE,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC;QACnB,CAAC;IACL,CAAC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { CodeMeta, ExtractOptions } from "./index.type";
|
|
2
|
+
import { Node, SourceFile } from "ts-morph";
|
|
3
|
+
export declare function extractFunction(name: string, declaration: Node, sourceFile: SourceFile, options?: ExtractOptions): CodeMeta | undefined;
|
|
4
|
+
//# sourceMappingURL=functions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../../src/core/analyze/functions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAY,cAAc,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAuB,IAAI,EAAE,UAAU,EAAuC,MAAM,UAAU,CAAC;AAItG,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,QAAQ,GAAG,SAAS,CAwCvI"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractFunction = extractFunction;
|
|
4
|
+
const index_type_1 = require("./index.type");
|
|
5
|
+
const ts_morph_1 = require("ts-morph");
|
|
6
|
+
const deps_1 = require("./deps");
|
|
7
|
+
function extractFunction(name, declaration, sourceFile, options) {
|
|
8
|
+
const kind = declaration.getKind();
|
|
9
|
+
if (kind === ts_morph_1.SyntaxKind.VariableDeclaration) {
|
|
10
|
+
const variableDeclaration = declaration.asKind(ts_morph_1.SyntaxKind.VariableDeclaration);
|
|
11
|
+
const initializer = variableDeclaration?.getInitializerIfKind(ts_morph_1.SyntaxKind.ArrowFunction);
|
|
12
|
+
if (!initializer) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
let body = declaration.getFullText().trim();
|
|
16
|
+
const parent = variableDeclaration?.getParent();
|
|
17
|
+
if (parent?.getKind() === ts_morph_1.SyntaxKind.VariableDeclarationList) {
|
|
18
|
+
const variableDeclarationList = parent;
|
|
19
|
+
const declarationKind = variableDeclarationList.getDeclarationKind();
|
|
20
|
+
if (!body.startsWith(declarationKind)) {
|
|
21
|
+
body = `${declarationKind} ${body}`;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
type: index_type_1.CodeType.Function,
|
|
26
|
+
name,
|
|
27
|
+
body: body.replaceAll(';;', ';'),
|
|
28
|
+
externalIdentifiers: options?.skipDependencies ? undefined : (0, deps_1.searchExternalIdentifiers)(initializer, options),
|
|
29
|
+
linesRange: [declaration.getStartLineNumber(), declaration.getEndLineNumber()]
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
if (kind === ts_morph_1.SyntaxKind.FunctionDeclaration || kind === ts_morph_1.SyntaxKind.ArrowFunction) {
|
|
33
|
+
const externalIdentifiers = options?.skipDependencies ? undefined : (0, deps_1.searchExternalIdentifiers)(declaration, options);
|
|
34
|
+
// Todo: actually don't need all file code, next optimization can just extract all dependent functions from file
|
|
35
|
+
// get all file code
|
|
36
|
+
const body = sourceFile.getFullText();
|
|
37
|
+
return {
|
|
38
|
+
type: index_type_1.CodeType.Function,
|
|
39
|
+
name,
|
|
40
|
+
body,
|
|
41
|
+
externalIdentifiers,
|
|
42
|
+
linesRange: [declaration.getStartLineNumber(), declaration.getEndLineNumber()]
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=functions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../../../src/core/analyze/functions.ts"],"names":[],"mappings":";;AAKA,0CAwCC;AA7CD,6CAAkE;AAClE,u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ACjF,CAAC;IACN,CAAC;IACD,IAAI,IAAI,KAAK,qBAAU,CAAC,mBAAmB,IAAI,IAAI,KAAK,qBAAU,CAAC,aAAa,EAAE,CAAC;QAC/E,MAAM,mBAAmB,GAAG,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAA,gCAAyB,EAAC,WAAkC,EAAE,OAAO,CAAC,CAAC;QAE3I,gHAAgH;QAChH,oBAAoB;QACpB,MAAM,IAAI,GAAG,UAAU,CAAC,WAAW,EAAE,CAAC;QAEtC,OAAO;YACH,IAAI,EAAE,qBAAQ,CAAC,QAAQ;YACvB,IAAI;YACJ,IAAI;YACJ,mBAAmB;YACnB,UAAU,EAAE,CAAC,WAAW,CAAC,kBAAkB,EAAE,EAAE,WAAW,CAAC,gBAAgB,EAAE,CAAC;SACjF,CAAC;IACN,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CodeDetailData, ExtractOptions } from "./index.type";
|
|
2
|
+
export * from './index.type';
|
|
3
|
+
export declare function read(fileName: string, extractOptions?: ExtractOptions): Promise<CodeDetailData[]>;
|
|
4
|
+
interface MergeCodeOptions {
|
|
5
|
+
disableImport?: boolean;
|
|
6
|
+
beforeImports?: string;
|
|
7
|
+
afterImports?: string;
|
|
8
|
+
disableLocal?: boolean;
|
|
9
|
+
beforeLocal?: string;
|
|
10
|
+
afterLocal?: string;
|
|
11
|
+
beforeCode?: string;
|
|
12
|
+
afterCode?: string;
|
|
13
|
+
maxLength?: number;
|
|
14
|
+
}
|
|
15
|
+
export declare function getCode(data: CodeDetailData, options?: MergeCodeOptions): string;
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/analyze/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAiC,cAAc,EAAE,MAAM,cAAc,CAAC;AAW7F,cAAc,cAAc,CAAC;AAE7B,wBAAsB,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAgDvG;AAED,UAAU,gBAAgB;IACtB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,GAAE,gBAAqB,GAAG,MAAM,CAqCpF"}
|
|
@@ -0,0 +1,149 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.read = read;
|
|
18
|
+
exports.getCode = getCode;
|
|
19
|
+
const cjs_1 = require("./cjs");
|
|
20
|
+
const declares_1 = require("./declares");
|
|
21
|
+
const checkTestIgnore_1 = require("../utils/checkTestIgnore");
|
|
22
|
+
const class_1 = require("./class");
|
|
23
|
+
const functionComponent_1 = require("./functionComponent");
|
|
24
|
+
const functions_1 = require("./functions");
|
|
25
|
+
const tsMorph_1 = require("../utils/tsMorph");
|
|
26
|
+
__exportStar(require("./index.type"), exports);
|
|
27
|
+
async function read(fileName, extractOptions) {
|
|
28
|
+
const formatFileName = formatPath(fileName);
|
|
29
|
+
// Todo: before analysis, check file size first, if larger than threshold, remind user to refine code and stop
|
|
30
|
+
const { sourceFile } = (0, tsMorph_1.getProject)(fileName);
|
|
31
|
+
// Check if the entire file should be ignored for coverage
|
|
32
|
+
if ((0, checkTestIgnore_1.hasIstanbulIgnoreFile)(sourceFile)) {
|
|
33
|
+
console.log(`Skipping file ${fileName} due to istanbul ignore file comment`);
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
const res = [];
|
|
37
|
+
const exportedDeclarations = sourceFile.getExportedDeclarations();
|
|
38
|
+
if (exportedDeclarations.size === 0 && (0, cjs_1.maybeCjs)(fileName, sourceFile.getFullText())) {
|
|
39
|
+
return (0, cjs_1.analyzeCommonJSFile)(fileName);
|
|
40
|
+
}
|
|
41
|
+
const exportData = {};
|
|
42
|
+
exportedDeclarations.forEach((declarations, name) => {
|
|
43
|
+
declarations.forEach((declaration) => {
|
|
44
|
+
const sourcePath = formatPath(declaration.getSourceFile().getFilePath());
|
|
45
|
+
if (sourcePath.toLocaleLowerCase() !== formatFileName.toLocaleLowerCase()) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
// Skip if the declaration has istanbul ignore next comment
|
|
49
|
+
if ((0, checkTestIgnore_1.hasIstanbulIgnoreNext)(declaration)) {
|
|
50
|
+
console.log(`Skipping [${name}] due to istanbul ignore next comment`);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const data = (0, functions_1.extractFunction)(name, declaration, sourceFile, extractOptions)
|
|
54
|
+
|| (0, class_1.extractClass)(name, declaration, extractOptions)
|
|
55
|
+
|| (0, functionComponent_1.extractFC)(name, declaration, extractOptions);
|
|
56
|
+
if (data) {
|
|
57
|
+
exportData[name] = data;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
const { importDeclarations, localDeclarations } = getFileDeclarations(sourceFile);
|
|
62
|
+
for (const dataKey in exportData) {
|
|
63
|
+
res.push(getCodeDetails(exportData[dataKey], importDeclarations, localDeclarations));
|
|
64
|
+
}
|
|
65
|
+
return res;
|
|
66
|
+
}
|
|
67
|
+
function getCode(data, options = {}) {
|
|
68
|
+
const { importDeclares, localDeclares = '', code } = data;
|
|
69
|
+
const { disableImport = false, beforeImports = '', afterImports = '', disableLocal = false, beforeLocal = '', afterLocal = '', beforeCode = '', afterCode = '', maxLength } = options;
|
|
70
|
+
const importDeclare = importDeclares ? Object.entries(importDeclares).map(([module, declares]) => {
|
|
71
|
+
return `declare module '${module}' {\n${declares.map(el => el.declare).join('\n')}\n}\n`;
|
|
72
|
+
}).join('') : '';
|
|
73
|
+
const importStatements = (importDeclare && !disableImport) ? `${beforeImports}${importDeclare}${afterImports}` : '';
|
|
74
|
+
const codeStatements = `${beforeCode}${code}${afterCode}`;
|
|
75
|
+
if (!maxLength) {
|
|
76
|
+
return `${importStatements}${codeStatements}`;
|
|
77
|
+
}
|
|
78
|
+
let attachStr = '';
|
|
79
|
+
const attachments = [];
|
|
80
|
+
!disableImport && attachments.push(importDeclare);
|
|
81
|
+
!disableLocal && attachments.push(localDeclares);
|
|
82
|
+
const attachLimit = Math.max(0, maxLength - codeStatements.length);
|
|
83
|
+
for (const attach of attachments) {
|
|
84
|
+
if (attach.length + attachStr.length > attachLimit) {
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
attachStr += attach;
|
|
88
|
+
}
|
|
89
|
+
return `${attachStr}${codeStatements}`;
|
|
90
|
+
}
|
|
91
|
+
function formatPath(path) {
|
|
92
|
+
return path.replace(/\\/g, '/');
|
|
93
|
+
}
|
|
94
|
+
function getFileDeclarations(sourceFile) {
|
|
95
|
+
const imports = sourceFile.getImportDeclarations();
|
|
96
|
+
const importDeclarations = (0, declares_1.getImportDeclarations)(imports);
|
|
97
|
+
const localDeclarations = (0, declares_1.getLocalDeclarations)(sourceFile);
|
|
98
|
+
return {
|
|
99
|
+
importDeclarations,
|
|
100
|
+
localDeclarations
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function getCodeDetails(codeData, importDeclarations, localDeclarations) {
|
|
104
|
+
const { type, name, body, externalIdentifiers, classFunctions, linesRange } = codeData;
|
|
105
|
+
let localDeclares = '';
|
|
106
|
+
const importDeclares = {};
|
|
107
|
+
for (const [externalIdentifier, declStr] of externalIdentifiers || new Map()) {
|
|
108
|
+
const dep = importDeclarations[externalIdentifier] || localDeclarations[externalIdentifier];
|
|
109
|
+
if (!dep || !dep.text) {
|
|
110
|
+
if (declStr) {
|
|
111
|
+
localDeclares += declStr + '\n';
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
console.warn(`Cannot find declaration for '${externalIdentifier}' in '${name}'`);
|
|
115
|
+
// localDeclares += `declare const ${externalIdentifier}: any;\n`;
|
|
116
|
+
}
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
if (dep.module) {
|
|
120
|
+
importDeclares[dep.module] = importDeclares[dep.module] || [];
|
|
121
|
+
importDeclares[dep.module].push({
|
|
122
|
+
name: externalIdentifier,
|
|
123
|
+
declare: dep.text
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
const text = dep.text;
|
|
128
|
+
if (text.startsWith('export ') || text.startsWith('declare ')) {
|
|
129
|
+
localDeclares += text + '\n';
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
localDeclares += `declare ${text}\n`;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
type,
|
|
138
|
+
name,
|
|
139
|
+
importDeclares,
|
|
140
|
+
localDeclares,
|
|
141
|
+
code: body.trim(),
|
|
142
|
+
classFunctions,
|
|
143
|
+
linesRange
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
// read("D:\\code\\AdsAppsCampaignUI\\private\\ads-studio\\packages\\ads-studio-panel\\src\\use-message-info.jsx").then(res => {
|
|
147
|
+
// console.log(JSON.stringify(res, null, 2));
|
|
148
|
+
// });
|
|
149
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/analyze/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAaA,oBAgDC;AAcD,0BAqCC;AA9GD,+BAAsD;AACtD,yCAAyE;AACzE,8DAAwF;AAExF,mCAAuC;AACvC,2DAAgD;AAChD,2CAA8C;AAC9C,8CAA8C;AAE9C,+CAA6B;AAEtB,KAAK,UAAU,IAAI,CAAC,QAAgB,EAAE,cAA+B;IACxE,MAAM,cAAc,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IAE5C,8GAA8G;IAE9G,MAAM,EAAE,UAAU,EAAE,GAAG,IAAA,oBAAU,EAAC,QAAQ,CAAC,CAAC;IAE5C,0DAA0D;IAC1D,IAAI,IAAA,uCAAqB,EAAC,UAAU,CAAC,EAAE,CAAC;QACpC,OAAO,CAAC,GAAG,CAAC,iBAAiB,QAAQ,sCAAsC,CAAC,CAAC;QAC7E,OAAO,EAAE,CAAC;IACd,CAAC;IAED,MAAM,GAAG,GAAqB,EAAE,CAAC;IACjC,MAAM,oBAAoB,GAAG,UAAU,CAAC,uBAAuB,EAAE,CAAC;IAClE,IAAI,oBAAoB,CAAC,IAAI,KAAK,CAAC,IAAI,IAAA,cAAQ,EAAC,QAAQ,EAAE,UAAU,CAAC,WAAW,EAAE,CAAC,EA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|
|
6
|
+
export interface ExtractOptions {
|
|
7
|
+
skipDependencies?: boolean;
|
|
8
|
+
deepTypesCheck?: boolean;
|
|
9
|
+
scanFunc?: boolean;
|
|
10
|
+
cachedProject?: Project;
|
|
11
|
+
}
|
|
12
|
+
export declare enum CodeType {
|
|
13
|
+
Function = 0,
|
|
14
|
+
Class = 1,
|
|
15
|
+
ClassMember = 2,
|
|
16
|
+
TypeDefine = 3,
|
|
17
|
+
Enum = 4,
|
|
18
|
+
Variable = 5
|
|
19
|
+
}
|
|
20
|
+
export interface CodeBaseInfo {
|
|
21
|
+
type: CodeType;
|
|
22
|
+
name: string;
|
|
23
|
+
linesRange: [number, number];
|
|
24
|
+
functions?: {
|
|
25
|
+
name: string;
|
|
26
|
+
linesRange: [number, number];
|
|
27
|
+
}[];
|
|
28
|
+
}
|
|
29
|
+
export interface CodeMeta {
|
|
30
|
+
type: CodeType;
|
|
31
|
+
name: string;
|
|
32
|
+
body: string;
|
|
33
|
+
externalIdentifiers?: Map<string, string>;
|
|
34
|
+
classFunctions?: ClassFunction[];
|
|
35
|
+
linesRange: [number, number];
|
|
36
|
+
}
|
|
37
|
+
export interface CodeDetailData {
|
|
38
|
+
type: CodeType;
|
|
39
|
+
name: string;
|
|
40
|
+
code: string;
|
|
41
|
+
classFunctions?: ClassFunction[];
|
|
42
|
+
importDeclares?: Record<string, Declare[]>;
|
|
43
|
+
localDeclares?: string;
|
|
44
|
+
linesRange: [number, number];
|
|
45
|
+
isCommonJS?: boolean;
|
|
46
|
+
isDefaultExport?: boolean;
|
|
47
|
+
}
|
|
48
|
+
export interface Declare {
|
|
49
|
+
name: string;
|
|
50
|
+
declare: string;
|
|
51
|
+
}
|
|
52
|
+
export interface ClassStructure {
|
|
53
|
+
name: string;
|
|
54
|
+
type: string;
|
|
55
|
+
ext: string;
|
|
56
|
+
impl: string;
|
|
57
|
+
body: [name: string, declareStr: string][];
|
|
58
|
+
functions: ClassFunction[];
|
|
59
|
+
}
|
|
60
|
+
export interface ClassFunction {
|
|
61
|
+
name: string;
|
|
62
|
+
body: string;
|
|
63
|
+
isProp: boolean;
|
|
64
|
+
isStatic: boolean;
|
|
65
|
+
scope: string;
|
|
66
|
+
externalIdentifiers?: Map<string, string>;
|
|
67
|
+
linesRange: [number, number];
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=index.type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.type.d.ts","sourceRoot":"","sources":["../../../src/core/analyze/index.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC,MAAM,WAAW,UAAU;IAEvB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC3B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,oBAAY,QAAQ;IAChB,QAAQ,IAAA;IACR,KAAK,IAAA;IACL,WAAW,IAAA;IACX,UAAU,IAAA;IACV,IAAI,IAAA;IACJ,QAAQ,IAAA;CACX;AAED,MAAM,WAAW,YAAY;IACzB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,SAAS,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,EAAE,CAAC;CAChE;AAED,MAAM,WAAW,QAAQ;IACrB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,mBAAmB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAA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.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CodeType = void 0;
|
|
4
|
+
var CodeType;
|
|
5
|
+
(function (CodeType) {
|
|
6
|
+
CodeType[CodeType["Function"] = 0] = "Function";
|
|
7
|
+
CodeType[CodeType["Class"] = 1] = "Class";
|
|
8
|
+
CodeType[CodeType["ClassMember"] = 2] = "ClassMember";
|
|
9
|
+
CodeType[CodeType["TypeDefine"] = 3] = "TypeDefine";
|
|
10
|
+
CodeType[CodeType["Enum"] = 4] = "Enum";
|
|
11
|
+
CodeType[CodeType["Variable"] = 5] = "Variable";
|
|
12
|
+
})(CodeType || (exports.CodeType = CodeType = {}));
|
|
13
|
+
;
|
|
14
|
+
//# sourceMappingURL=index.type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.type.js","sourceRoot":"","sources":["../../../src/core/analyze/index.type.ts"],"names":[],"mappings":";;;AAeA,IAAY,QAOX;AAPD,WAAY,QAAQ;IAChB,+CAAQ,CAAA;IACR,yCAAK,CAAA;IACL,qDAAW,CAAA;IACX,mDAAU,CAAA;IACV,uCAAI,CAAA;IACJ,+CAAQ,CAAA;AACZ,CAAC,EAPW,QAAQ,wBAAR,QAAQ,QAOnB;AAqDA,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global.d.ts","sourceRoot":"","sources":["../../../../src/core/analyze/utils/global.ts"],"names":[],"mappings":"AA8EA,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAElD"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isTsSymbol = isTsSymbol;
|
|
4
|
+
let tsSymbols = new Set([
|
|
5
|
+
"Array",
|
|
6
|
+
"ArrayBuffer",
|
|
7
|
+
"Boolean",
|
|
8
|
+
"DataView",
|
|
9
|
+
"Date",
|
|
10
|
+
"Error",
|
|
11
|
+
"EvalError",
|
|
12
|
+
"Float32Array",
|
|
13
|
+
"Float64Array",
|
|
14
|
+
"Function",
|
|
15
|
+
"Infinity",
|
|
16
|
+
"Int8Array",
|
|
17
|
+
"Int16Array",
|
|
18
|
+
"Int32Array",
|
|
19
|
+
"Map",
|
|
20
|
+
"Number",
|
|
21
|
+
"Object",
|
|
22
|
+
"Promise",
|
|
23
|
+
"RangeError",
|
|
24
|
+
"ReferenceError",
|
|
25
|
+
"RegExp",
|
|
26
|
+
"Set",
|
|
27
|
+
"String",
|
|
28
|
+
"Symbol",
|
|
29
|
+
"SyntaxError",
|
|
30
|
+
"TypeError",
|
|
31
|
+
"Uint8Array",
|
|
32
|
+
"Uint8ClampedArray",
|
|
33
|
+
"Uint16Array",
|
|
34
|
+
"Uint32Array",
|
|
35
|
+
"URIError",
|
|
36
|
+
"URL",
|
|
37
|
+
"URLSearchParams",
|
|
38
|
+
"WeakMap",
|
|
39
|
+
"WeakSet",
|
|
40
|
+
"document",
|
|
41
|
+
"eval",
|
|
42
|
+
"isFinite",
|
|
43
|
+
"isNaN",
|
|
44
|
+
"parseFloat",
|
|
45
|
+
"parseInt",
|
|
46
|
+
"console",
|
|
47
|
+
"decodeURI",
|
|
48
|
+
"decodeURIComponent",
|
|
49
|
+
"encodeURI",
|
|
50
|
+
"encodeURIComponent",
|
|
51
|
+
"escape",
|
|
52
|
+
"unescape",
|
|
53
|
+
"window",
|
|
54
|
+
"Math",
|
|
55
|
+
"JSON",
|
|
56
|
+
"Reflect",
|
|
57
|
+
"Proxy",
|
|
58
|
+
"Intl",
|
|
59
|
+
"WebAssembly",
|
|
60
|
+
"super",
|
|
61
|
+
"this",
|
|
62
|
+
"global",
|
|
63
|
+
"globalThis",
|
|
64
|
+
"Record",
|
|
65
|
+
"Pick",
|
|
66
|
+
"Omit",
|
|
67
|
+
"Exclude",
|
|
68
|
+
"Extract",
|
|
69
|
+
"NonNullable",
|
|
70
|
+
"Parameters",
|
|
71
|
+
"ConstructorParameters",
|
|
72
|
+
"ReturnType",
|
|
73
|
+
"InstanceType",
|
|
74
|
+
"Required",
|
|
75
|
+
"ThisType",
|
|
76
|
+
"OmitThisParameter",
|
|
77
|
+
"ThisParameterType",
|
|
78
|
+
"null",
|
|
79
|
+
"undefined"
|
|
80
|
+
]);
|
|
81
|
+
function isTsSymbol(symbol) {
|
|
82
|
+
return !!tsSymbols?.has(symbol);
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=global.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global.js","sourceRoot":"","sources":["../../../../src/core/analyze/utils/global.ts"],"names":[],"mappings":";;AA8EA,gCAEC;AAhFD,IAAI,SAAS,GAAG,IAAI,GAAG,CAAC;IACpB,OAAO;IACP,aAAa;IACb,SAAS;IACT,UAAU;IACV,MAAM;IACN,OAAO;IACP,WAAW;IACX,cAAc;IACd,cAAc;IACd,UAAU;IACV,UAAU;IACV,WAAW;IACX,YAAY;IACZ,YAAY;IACZ,KAAK;IACL,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,YAAY;IACZ,gBAAgB;IAChB,QAAQ;IACR,KAAK;IACL,QAAQ;IACR,QAAQ;IACR,aAAa;IACb,WAAW;IACX,YAAY;IACZ,mBAAmB;IACnB,aAAa;IACb,aAAa;IACb,UAAU;IACV,KAAK;IACL,iBAAiB;IACjB,SAAS;IACT,SAAS;IACT,UAAU;IACV,MAAM;IACN,UAAU;IACV,OAAO;IACP,YAAY;IACZ,UAAU;IACV,SAAS;IACT,WAAW;IACX,oBAAoB;IACpB,WAAW;IACX,oBAAoB;IACpB,QAAQ;IACR,UAAU;IACV,QAAQ;IACR,MAAM;IACN,MAAM;IACN,SAAS;IACT,OAAO;IACP,MAAM;IACN,aAAa;IACb,OAAO;IACP,MAAM;IACN,QAAQ;IACR,YAAY;IACZ,QAAQ;IACR,MAAM;IACN,MAAM;IACN,SAAS;IACT,SAAS;IACT,aAAa;IACb,YAAY;IACZ,uBAAuB;IACvB,YAAY;IACZ,cAAc;IACd,UAAU;IACV,UAAU;IACV,mBAAmB;IACnB,mBAAmB;IACnB,MAAM;IACN,WAAW;CACd,CAAC,CAAC;AAEH,SAAgB,UAAU,CAAC,MAAc;IACrC,OAAO,CAAC,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ClassDeclaration, ConstructorDeclaration } from "ts-morph";
|
|
2
|
+
export declare function getClassDeclaration(node: ClassDeclaration): string;
|
|
3
|
+
export declare function getConstructorDeclaration(node: ConstructorDeclaration): string;
|
|
4
|
+
//# sourceMappingURL=class.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"class.d.ts","sourceRoot":"","sources":["../../../../src/core/analyzev2/declare/class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAEpE,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,gBAAgB,GAAG,MAAM,CAYlE;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,sBAAsB,GAAG,MAAM,CAK9E"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getClassDeclaration = getClassDeclaration;
|
|
4
|
+
exports.getConstructorDeclaration = getConstructorDeclaration;
|
|
5
|
+
function getClassDeclaration(node) {
|
|
6
|
+
const name = node.getName();
|
|
7
|
+
const constructor = node.getConstructors()[0];
|
|
8
|
+
if (!name) {
|
|
9
|
+
return '';
|
|
10
|
+
}
|
|
11
|
+
const templateParams = node.getTypeParameters().map((param) => param.getText()).join(', ');
|
|
12
|
+
const exts = node.getExtends()?.getText() || '';
|
|
13
|
+
const impls = node.getImplements().map((impl) => impl.getText()).join(', ');
|
|
14
|
+
const modifiers = node.getModifiers().map((m) => m.getText()).join(' ');
|
|
15
|
+
const modifierStr = modifiers ? `${modifiers} ` : '';
|
|
16
|
+
return `${modifierStr}class ${name}${templateParams ? `<${templateParams}>` : ''}${exts ? ` extends ${exts}` : ''}${impls ? ` implements ${impls}` : ''}`;
|
|
17
|
+
}
|
|
18
|
+
function getConstructorDeclaration(node) {
|
|
19
|
+
const params = node.getParameters().map((param) => param.getText()).join(', ');
|
|
20
|
+
const modifiers = node.getModifiers().map((m) => m.getText()).join(' ');
|
|
21
|
+
const modifierStr = modifiers ? `${modifiers} ` : '';
|
|
22
|
+
return `${modifierStr}constructor(${params})`;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=class.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"class.js","sourceRoot":"","sources":["../../../../src/core/analyzev2/declare/class.ts"],"names":[],"mappings":";;AAEA,kDAYC;AAED,8DAKC;AAnBD,SAAgB,mBAAmB,CAAC,IAAsB;IACtD,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;IAC5B,MAAM,WAAW,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,CAAC;IAC9C,IAAI,CAAC,IAAI,EAAE,CAAC;QACR,OAAO,EAAE,CAAC;IACd,CAAC;IACD,MAAM,cAAc,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3F,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAChD,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5E,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACxE,MAAM,WAAW,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACrD,OAAO,GAAG,WAAW,SAAS,IAAI,GAAG,cAAc,CAAC,CAAC,CAAC,IAAI,cAAc,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,eAAe,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AAC9J,CAAC;AAED,SAAgB,yBAAyB,CAAC,IAA4B;IAClE,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/E,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACxE,MAAM,WAAW,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACrD,OAAO,GAAG,WAAW,eAAe,MAAM,GAAG,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FunctionDeclaration, GetAccessorDeclaration, MethodDeclaration, ParameterDeclaration, PropertyDeclaration, SetAccessorDeclaration, TypeParameterDeclaration, VariableDeclaration } from 'ts-morph';
|
|
2
|
+
export declare function getFuncLikeSignature(typeParams: TypeParameterDeclaration[], params: ParameterDeclaration[], returnType: string, useArrow?: boolean): string;
|
|
3
|
+
export declare function getFunctionSignature(fn: FunctionDeclaration): string;
|
|
4
|
+
export declare function getVariableFunctionSignature(fn: VariableDeclaration): string;
|
|
5
|
+
export declare function getMethodSignature(fn: MethodDeclaration): string;
|
|
6
|
+
export declare function getPropertyFunctionSignature(fn: PropertyDeclaration): string;
|
|
7
|
+
export declare function getAccessorsSignature(fn: GetAccessorDeclaration | SetAccessorDeclaration): string;
|
|
8
|
+
//# sourceMappingURL=funcLike.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"funcLike.d.ts","sourceRoot":"","sources":["../../../../src/core/analyzev2/declare/funcLike.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,mBAAmB,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,sBAAsB,EAAc,wBAAwB,EAAE,mBAAmB,EAA2B,MAAM,UAAU,CAAC;AAEhQ,wBAAgB,oBAAoB,CAChC,UAAU,EAAE,wBAAwB,EAAE,EACtC,MAAM,EAAE,oBAAoB,EAAE,EAC9B,UAAU,EAAE,MAAM,EAClB,QAAQ,GAAE,OAAe,GAC1B,MAAM,CAQR;AAED,wBAAgB,oBAAoB,CAChC,EAAE,EAAE,mBAAmB,GACxB,MAAM,CAWR;AAED,wBAAgB,4BAA4B,CAAC,EAAE,EAAE,mBAAmB,GAAG,MAAM,CAqB5E;AAED,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,iBAAiB,GAAG,MAAM,CAUhE;AAED,wBAAgB,4BAA4B,CAAC,EAAE,EAAE,mBAAmB,GAAG,MAAM,CAiB5E;AAED,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,sBAAsB,GAAG,sBAAsB,GAAG,MAAM,CAOjG"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFuncLikeSignature = getFuncLikeSignature;
|
|
4
|
+
exports.getFunctionSignature = getFunctionSignature;
|
|
5
|
+
exports.getVariableFunctionSignature = getVariableFunctionSignature;
|
|
6
|
+
exports.getMethodSignature = getMethodSignature;
|
|
7
|
+
exports.getPropertyFunctionSignature = getPropertyFunctionSignature;
|
|
8
|
+
exports.getAccessorsSignature = getAccessorsSignature;
|
|
9
|
+
const ts_morph_1 = require("ts-morph");
|
|
10
|
+
function getFuncLikeSignature(typeParams, params, returnType, useArrow = false) {
|
|
11
|
+
let typeParamsStr = typeParams.map((param) => param.getText()).join(', ');
|
|
12
|
+
if (typeParamsStr) {
|
|
13
|
+
typeParamsStr = `<${typeParamsStr}>`;
|
|
14
|
+
}
|
|
15
|
+
const paramsStr = params.map((param) => param.getText()).join(', ');
|
|
16
|
+
const arrow = useArrow ? '=>' : ':';
|
|
17
|
+
return `${typeParamsStr}(${paramsStr})${arrow}${returnType}`;
|
|
18
|
+
}
|
|
19
|
+
function getFunctionSignature(fn) {
|
|
20
|
+
const sig = getFuncLikeSignature(fn.getTypeParameters(), fn.getParameters(), fn.getReturnType().getText());
|
|
21
|
+
const name = fn.getName() || '';
|
|
22
|
+
const modifiers = fn.getModifiers().map((m) => m.getText()).join(' ');
|
|
23
|
+
const modifierStr = modifiers ? `${modifiers} ` : '';
|
|
24
|
+
const isGenerator = fn.isGenerator() ? 'function* ' : 'function ';
|
|
25
|
+
return `${modifierStr}${isGenerator}${name}${sig}`;
|
|
26
|
+
}
|
|
27
|
+
function getVariableFunctionSignature(fn) {
|
|
28
|
+
const name = fn.getName();
|
|
29
|
+
if (!name) {
|
|
30
|
+
return '';
|
|
31
|
+
}
|
|
32
|
+
const initializer = fn.getInitializer();
|
|
33
|
+
const kind = initializer?.getKind();
|
|
34
|
+
if (kind !== ts_morph_1.SyntaxKind.ArrowFunction && kind !== ts_morph_1.SyntaxKind.FunctionExpression) {
|
|
35
|
+
return '';
|
|
36
|
+
}
|
|
37
|
+
const arrowFn = initializer;
|
|
38
|
+
const sig = getFuncLikeSignature(arrowFn.getTypeParameters(), arrowFn.getParameters(), arrowFn.getReturnType().getText(), kind === ts_morph_1.SyntaxKind.ArrowFunction);
|
|
39
|
+
const isConst = fn.getVariableStatement()?.getDeclarationKind() === ts_morph_1.VariableDeclarationKind.Const ? 'const ' : 'let ';
|
|
40
|
+
const isExported = fn.isExported() ? 'export ' : '';
|
|
41
|
+
return `${isExported}${isConst}${name}${sig}`;
|
|
42
|
+
}
|
|
43
|
+
function getMethodSignature(fn) {
|
|
44
|
+
const sig = getFuncLikeSignature(fn.getTypeParameters(), fn.getParameters(), fn.getReturnType().getText());
|
|
45
|
+
const name = fn.getName() || '';
|
|
46
|
+
const modifiers = fn.getModifiers().map((m) => m.getText()).join(' ');
|
|
47
|
+
const modifierStr = modifiers ? `${modifiers} ` : '';
|
|
48
|
+
return `${modifierStr}${name}${sig}`;
|
|
49
|
+
}
|
|
50
|
+
function getPropertyFunctionSignature(fn) {
|
|
51
|
+
const initializer = fn.getInitializer();
|
|
52
|
+
const kind = initializer?.getKind();
|
|
53
|
+
if (kind !== ts_morph_1.SyntaxKind.ArrowFunction && kind !== ts_morph_1.SyntaxKind.FunctionExpression) {
|
|
54
|
+
return '';
|
|
55
|
+
}
|
|
56
|
+
const fnInitializer = initializer;
|
|
57
|
+
const sig = getFuncLikeSignature(fnInitializer.getTypeParameters(), fnInitializer.getParameters(), fnInitializer.getReturnType().getText(), kind === ts_morph_1.SyntaxKind.ArrowFunction);
|
|
58
|
+
const name = fn.getName() || '';
|
|
59
|
+
const modifiers = fn.getModifiers().map((m) => m.getText()).join(' ');
|
|
60
|
+
const modifierStr = modifiers ? `${modifiers} ` : '';
|
|
61
|
+
return `${modifierStr}${name}${sig}`;
|
|
62
|
+
}
|
|
63
|
+
function getAccessorsSignature(fn) {
|
|
64
|
+
const name = fn.getName() || '';
|
|
65
|
+
const modifiers = fn.getModifiers().map((m) => m.getText()).join(' ');
|
|
66
|
+
const modifierStr = modifiers ? `${modifiers} ` : '';
|
|
67
|
+
const isGet = fn.getKind() === ts_morph_1.SyntaxKind.GetAccessor ? 'get ' : 'set ';
|
|
68
|
+
const returnType = fn.getReturnType().getText();
|
|
69
|
+
return `${modifierStr}${isGet}${name}(): ${returnType}`;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=funcLike.js.map
|