js-code-detector 0.0.51 → 0.0.53

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.
Files changed (79) hide show
  1. package/dist/cjs/services/DetectService.js +7 -1
  2. package/dist/cjs/services/projectServiceClass/UmiProjectService.js +5 -0
  3. package/dist/cjs/services/projectServiceClass/ViteProjectService.d.ts +23 -0
  4. package/dist/cjs/services/projectServiceClass/ViteProjectService.js +142 -0
  5. package/dist/cjs/services/projectServiceClass/VueProjectService.d.ts +3 -0
  6. package/dist/cjs/services/projectServiceClass/VueProjectService.js +32 -6
  7. package/dist/cjs/util/ast_util/AstKit.d.ts +5 -21
  8. package/dist/cjs/util/ast_util/AstKit.js +33 -524
  9. package/dist/cjs/util/ast_util/AstUtil.d.ts +2 -1
  10. package/dist/cjs/util/ast_util/AstUtil.js +14 -9
  11. package/dist/cjs/util/ast_util/getAstKitByFilePath.d.ts +1 -1
  12. package/dist/cjs/util/ast_util/getAstKitByFilePath.js +1 -1
  13. package/dist/cjs/util/ast_util/helper/collectDeclarationIdentifiers.d.ts +2 -0
  14. package/dist/cjs/util/ast_util/helper/collectDeclarationIdentifiers.js +31 -0
  15. package/dist/cjs/util/ast_util/helper/collectDependenceIds.d.ts +2 -0
  16. package/dist/cjs/util/ast_util/helper/collectDependenceIds.js +90 -0
  17. package/dist/cjs/util/ast_util/helper/collectDependenceIdsOfExportMembers.d.ts +2 -0
  18. package/dist/cjs/util/ast_util/helper/collectDependenceIdsOfExportMembers.js +44 -0
  19. package/dist/cjs/util/ast_util/helper/collectEffectId.d.ts +2 -0
  20. package/dist/cjs/util/ast_util/helper/collectEffectId.js +26 -0
  21. package/dist/cjs/util/ast_util/helper/collectExpressionIdentifiersShallow.d.ts +2 -0
  22. package/dist/cjs/util/ast_util/helper/collectExpressionIdentifiersShallow.js +39 -0
  23. package/dist/cjs/util/ast_util/helper/collectHoldingIds.d.ts +4 -0
  24. package/dist/cjs/util/ast_util/helper/collectHoldingIds.js +110 -0
  25. package/dist/cjs/util/ast_util/helper/collectImportDeclarationIdentifiers.d.ts +2 -0
  26. package/dist/cjs/util/ast_util/helper/collectImportDeclarationIdentifiers.js +38 -0
  27. package/dist/cjs/util/ast_util/helper/collectVariableDeclarationIdentifiers.d.ts +2 -0
  28. package/dist/cjs/util/ast_util/helper/collectVariableDeclarationIdentifiers.js +43 -0
  29. package/dist/cjs/util/ast_util/helper/createAstNodeExt.d.ts +40 -0
  30. package/dist/cjs/util/ast_util/helper/createAstNodeExt.js +54 -0
  31. package/dist/cjs/util/ast_util/helper/deepFirstTravel.d.ts +9 -0
  32. package/dist/cjs/util/ast_util/helper/deepFirstTravel.js +142 -0
  33. package/dist/cjs/util/ast_util/helper/deepSearchParamsIdentifier.d.ts +2 -0
  34. package/dist/cjs/util/ast_util/helper/deepSearchParamsIdentifier.js +55 -0
  35. package/dist/cjs/util/ast_util/helper/findOrCreateExportedMember.d.ts +9 -0
  36. package/dist/cjs/util/ast_util/helper/findOrCreateExportedMember.js +32 -0
  37. package/dist/cjs/util/ast_util/helper/findOrCreateImportedMember.d.ts +8 -0
  38. package/dist/cjs/util/ast_util/helper/findOrCreateImportedMember.js +32 -0
  39. package/dist/cjs/util/ast_util/helper/getExportedNameOfAncestor.d.ts +2 -0
  40. package/dist/cjs/util/ast_util/helper/getExportedNameOfAncestor.js +113 -0
  41. package/dist/cjs/util/ast_util/helper/getExportedNameOfDeclarationIdentifier.d.ts +2 -0
  42. package/dist/cjs/util/ast_util/helper/getExportedNameOfDeclarationIdentifier.js +40 -0
  43. package/dist/cjs/util/ast_util/helper/getImpactedNode.d.ts +2 -0
  44. package/dist/cjs/util/ast_util/helper/getImpactedNode.js +50 -0
  45. package/dist/cjs/util/ast_util/helper/getNearestImpactedNode.d.ts +2 -0
  46. package/dist/cjs/util/ast_util/helper/getNearestImpactedNode.js +43 -0
  47. package/dist/cjs/util/ast_util/helper/getNodePath.d.ts +2 -0
  48. package/dist/cjs/util/ast_util/helper/getNodePath.js +27 -0
  49. package/dist/cjs/util/ast_util/helper/getShortNodeMsg.d.ts +2 -0
  50. package/dist/cjs/util/ast_util/helper/getShortNodeMsg.js +38 -0
  51. package/dist/cjs/util/ast_util/helper/getTopScopeNodesByLineNumberRange.d.ts +2 -0
  52. package/dist/cjs/util/ast_util/helper/getTopScopeNodesByLineNumberRange.js +51 -0
  53. package/dist/cjs/util/ast_util/helper/isIdentifierUntracked.d.ts +2 -0
  54. package/dist/cjs/util/ast_util/helper/isIdentifierUntracked.js +39 -0
  55. package/dist/cjs/util/ast_util/helper/isValidArrayNodeCollect.d.ts +2 -0
  56. package/dist/cjs/util/ast_util/helper/isValidArrayNodeCollect.js +27 -0
  57. package/dist/cjs/util/ast_util/helper/isValidNodeCollect.d.ts +2 -0
  58. package/dist/cjs/util/ast_util/helper/isValidNodeCollect.js +27 -0
  59. package/dist/cjs/util/ast_util/helper/syncTravel.d.ts +11 -0
  60. package/dist/cjs/util/ast_util/helper/syncTravel.js +325 -0
  61. package/dist/cjs/util/ast_util/helper/updateImportedAndExportedMember.d.ts +2 -0
  62. package/dist/cjs/util/ast_util/helper/updateImportedAndExportedMember.js +135 -0
  63. package/dist/cjs/util/ast_util/helper/updateLoc.d.ts +6 -0
  64. package/dist/cjs/util/ast_util/helper/updateLoc.js +74 -0
  65. package/dist/cjs/util/project_umi_util/isVueEntryFile.d.ts +1 -0
  66. package/dist/cjs/util/project_umi_util/isVueEntryFile.js +57 -0
  67. package/dist/cjs/util/project_umi_util/tsConfigPathsToWebpackAlias.d.ts +10 -0
  68. package/dist/cjs/util/project_umi_util/tsConfigPathsToWebpackAlias.js +80 -0
  69. package/dist/cjs/util/report_util/filterEffectedCode.d.ts +1 -1
  70. package/dist/cjs/util/report_util/filterEffectedExportMember.d.ts +2 -0
  71. package/dist/cjs/util/report_util/filterEffectedExportMember.js +10 -2
  72. package/dist/cjs/util/report_util/generateGitDiffReport.d.ts +1 -1
  73. package/dist/cjs/util/report_util/resolveImportPath.js +1 -1
  74. package/dist/cjs/util/report_util.d.ts +1 -1
  75. package/dist/cjs/util/shared/getMajorVersion.d.ts +1 -0
  76. package/dist/cjs/util/shared/getMajorVersion.js +37 -0
  77. package/dist/cjs/util/shared/getRepoSupportFlag.d.ts +1 -1
  78. package/dist/cjs/util/shared/getRepoSupportFlag.js +8 -3
  79. package/package.json +1 -1
@@ -0,0 +1,142 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/util/ast_util/helper/deepFirstTravel.ts
30
+ var deepFirstTravel_exports = {};
31
+ __export(deepFirstTravel_exports, {
32
+ default: () => deepFirstTravel
33
+ });
34
+ module.exports = __toCommonJS(deepFirstTravel_exports);
35
+ var import_SHARED_CONSTANTS = require("../SHARED_CONSTANTS");
36
+ var import_isValidNodeCollect = __toESM(require("./isValidNodeCollect"));
37
+ var import_isValidArrayNodeCollect = __toESM(require("./isValidArrayNodeCollect"));
38
+ var import_updateLoc = __toESM(require("./updateLoc"));
39
+ var import_collectDependenceIds = __toESM(require("./collectDependenceIds"));
40
+ var import_collectEffectId = __toESM(require("./collectEffectId"));
41
+ var import_collectHoldingIds = __toESM(require("./collectHoldingIds"));
42
+ var import_updateImportedAndExportedMember = __toESM(require("./updateImportedAndExportedMember"));
43
+ function deepFirstTravel(node, visitedNodeSet, extra) {
44
+ visitedNodeSet.add(node);
45
+ const { filePath, depth, mapUuidToNode, mapFileLineToNodeSet, mapPathToNodeSet, stopTravelCallback } = extra;
46
+ const _util = {
47
+ startLine: NaN,
48
+ endLine: NaN,
49
+ startColumn: NaN,
50
+ endColumn: NaN,
51
+ filePath,
52
+ parent: null,
53
+ parentProperty: "",
54
+ indexOfProperty: null,
55
+ ancestors: [],
56
+ nodeCollection: [],
57
+ children: [],
58
+ uuid: "",
59
+ variableScope: [],
60
+ dependenceIds: /* @__PURE__ */ new Set(),
61
+ dependenceIdsNoScope: /* @__PURE__ */ new Set(),
62
+ holdingIdType: null,
63
+ holdingIds: /* @__PURE__ */ new Set(),
64
+ holdingIdNameMap: /* @__PURE__ */ new Map(),
65
+ inject: /* @__PURE__ */ new Set(),
66
+ provide: /* @__PURE__ */ new Set(),
67
+ effectIds: /* @__PURE__ */ new Set(),
68
+ occupation: /* @__PURE__ */ new Set(),
69
+ importedMember: [],
70
+ exportedMember: []
71
+ };
72
+ node._util = _util;
73
+ const { nodeCollection, children } = _util;
74
+ const stopTravel = stopTravelCallback == null ? void 0 : stopTravelCallback(node);
75
+ if (stopTravel) {
76
+ return node;
77
+ }
78
+ Object.keys(node).forEach((nodeKey) => {
79
+ if (import_SHARED_CONSTANTS.INVALID_NODE_KEY.includes(nodeKey)) {
80
+ return;
81
+ }
82
+ const nodeValue = node[nodeKey];
83
+ if (visitedNodeSet.has(nodeValue) || !nodeValue) {
84
+ return;
85
+ }
86
+ if ((0, import_isValidNodeCollect.default)(nodeValue)) {
87
+ const childNode = deepFirstTravel(nodeValue, visitedNodeSet, { filePath, depth: depth + 1, mapUuidToNode, mapFileLineToNodeSet, mapPathToNodeSet, stopTravelCallback });
88
+ nodeCollection.push(childNode, ...childNode._util.nodeCollection);
89
+ children.push(childNode);
90
+ childNode._util.parentProperty = nodeKey;
91
+ } else if ((0, import_isValidArrayNodeCollect.default)(nodeValue)) {
92
+ const validNodeArray = nodeValue.filter((nodeItem) => (0, import_isValidNodeCollect.default)(nodeItem)).map((v) => {
93
+ return deepFirstTravel(v, visitedNodeSet, { filePath, depth: depth + 1, mapUuidToNode, mapFileLineToNodeSet, mapPathToNodeSet, stopTravelCallback });
94
+ });
95
+ nodeCollection.push(...validNodeArray.map((n) => [n, ...n._util.nodeCollection]).flat());
96
+ children.push(...validNodeArray);
97
+ validNodeArray.forEach((v, index) => {
98
+ v._util.parentProperty = nodeKey;
99
+ v._util.indexOfProperty = index;
100
+ });
101
+ }
102
+ });
103
+ try {
104
+ children.forEach((child) => child._util.parent = node);
105
+ nodeCollection.forEach((nodeItem) => {
106
+ !nodeItem._util.ancestors.includes(node) && nodeItem._util.ancestors.unshift(node);
107
+ });
108
+ } catch (e) {
109
+ console.error("parent ancestors update", e.message);
110
+ }
111
+ try {
112
+ const skip = nodeCollection.some((nodeItem) => stopTravelCallback == null ? void 0 : stopTravelCallback(nodeItem));
113
+ if (!skip) {
114
+ (0, import_collectHoldingIds.default)(node);
115
+ }
116
+ } catch (e) {
117
+ console.error("收集持有的 identifier 出错", e.message);
118
+ }
119
+ try {
120
+ (0, import_collectDependenceIds.default)(node);
121
+ } catch (e) {
122
+ console.error("收集使用的标识符号", e.message);
123
+ }
124
+ if (node.type === "Program") {
125
+ try {
126
+ nodeCollection.forEach((child) => (0, import_collectEffectId.default)(child));
127
+ } catch (e) {
128
+ console.error("collectEffectId", e.message);
129
+ }
130
+ try {
131
+ node.body.forEach((child) => (0, import_updateImportedAndExportedMember.default)(child, node));
132
+ } catch (e) {
133
+ console.error("收集导入、导出成员信息报错", e.message);
134
+ }
135
+ }
136
+ try {
137
+ (0, import_updateLoc.default)(node, { mapUuidToNode, mapFileLineToNodeSet, mapPathToNodeSet });
138
+ } catch (e) {
139
+ console.error("updateLoc", e.message);
140
+ }
141
+ return node;
142
+ }
@@ -0,0 +1,2 @@
1
+ import { AstNode } from "../AstUtil";
2
+ export default function deepSearchParamsIdentifier(id: AstNode | null, callback: (identifier: AstNode) => void): void;
@@ -0,0 +1,55 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/util/ast_util/helper/deepSearchParamsIdentifier.ts
20
+ var deepSearchParamsIdentifier_exports = {};
21
+ __export(deepSearchParamsIdentifier_exports, {
22
+ default: () => deepSearchParamsIdentifier
23
+ });
24
+ module.exports = __toCommonJS(deepSearchParamsIdentifier_exports);
25
+ function deepSearchParamsIdentifier(id, callback) {
26
+ if (!id) {
27
+ return;
28
+ }
29
+ if (id.type === "Identifier") {
30
+ callback(id);
31
+ }
32
+ if (id.type === "AssignmentPattern") {
33
+ const left = id.left;
34
+ deepSearchParamsIdentifier(left, callback);
35
+ }
36
+ if (id.type === "RestElement") {
37
+ deepSearchParamsIdentifier(id.argument, callback);
38
+ }
39
+ if (id.type === "ObjectProperty") {
40
+ const value = id.value;
41
+ deepSearchParamsIdentifier(value, callback);
42
+ }
43
+ if (id.type === "ObjectPattern") {
44
+ const properties = id.properties;
45
+ for (const property of properties) {
46
+ deepSearchParamsIdentifier(property, callback);
47
+ }
48
+ }
49
+ if (id.type === "ArrayPattern") {
50
+ const elements = id.elements;
51
+ for (const element of elements) {
52
+ deepSearchParamsIdentifier(element, callback);
53
+ }
54
+ }
55
+ }
@@ -0,0 +1,9 @@
1
+ import { AstNode } from "../AstUtil";
2
+ export default function findOrCreateExportedMember(exportedMember: AstNode['_util']['exportedMember'], sourceValue: string): {
3
+ sourcePath: string;
4
+ members: {
5
+ exportedName: string;
6
+ localName: string;
7
+ }[];
8
+ ExportAllDeclaration: boolean;
9
+ };
@@ -0,0 +1,32 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/util/ast_util/helper/findOrCreateExportedMember.ts
20
+ var findOrCreateExportedMember_exports = {};
21
+ __export(findOrCreateExportedMember_exports, {
22
+ default: () => findOrCreateExportedMember
23
+ });
24
+ module.exports = __toCommonJS(findOrCreateExportedMember_exports);
25
+ function findOrCreateExportedMember(exportedMember, sourceValue) {
26
+ let target = exportedMember.find((v) => v.sourcePath === sourceValue);
27
+ if (!target) {
28
+ target = { sourcePath: sourceValue, members: [], ExportAllDeclaration: false };
29
+ exportedMember.push(target);
30
+ }
31
+ return target;
32
+ }
@@ -0,0 +1,8 @@
1
+ import { AstNode } from "../AstUtil";
2
+ export default function findOrCreateImportedMember(importedMember: AstNode['_util']['importedMember'], sourceValue: string): {
3
+ sourcePath: string;
4
+ members: {
5
+ importedName: string;
6
+ localName: string;
7
+ }[];
8
+ };
@@ -0,0 +1,32 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/util/ast_util/helper/findOrCreateImportedMember.ts
20
+ var findOrCreateImportedMember_exports = {};
21
+ __export(findOrCreateImportedMember_exports, {
22
+ default: () => findOrCreateImportedMember
23
+ });
24
+ module.exports = __toCommonJS(findOrCreateImportedMember_exports);
25
+ function findOrCreateImportedMember(importedMember, sourceValue) {
26
+ let target = importedMember.find((v) => v.sourcePath === sourceValue);
27
+ if (!target) {
28
+ target = { sourcePath: sourceValue, members: [] };
29
+ importedMember.push(target);
30
+ }
31
+ return target;
32
+ }
@@ -0,0 +1,2 @@
1
+ import { AstNode } from "../AstUtil";
2
+ export default function getExportedNameOfAncestor(node: AstNode | undefined | null): string[];
@@ -0,0 +1,113 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/util/ast_util/helper/getExportedNameOfAncestor.ts
30
+ var getExportedNameOfAncestor_exports = {};
31
+ __export(getExportedNameOfAncestor_exports, {
32
+ default: () => getExportedNameOfAncestor
33
+ });
34
+ module.exports = __toCommonJS(getExportedNameOfAncestor_exports);
35
+ var import_SHARED_CONSTANTS = require("../SHARED_CONSTANTS");
36
+ var import_getExportedNameOfDeclarationIdentifier = __toESM(require("./getExportedNameOfDeclarationIdentifier"));
37
+ var import_collectVariableDeclarationIdentifiers = __toESM(require("./collectVariableDeclarationIdentifiers"));
38
+ var import_deepSearchParamsIdentifier = __toESM(require("./deepSearchParamsIdentifier"));
39
+ function getExportedNameOfAncestor(node) {
40
+ var _a, _b;
41
+ if (!node) {
42
+ console.warn("获取 上级导出成员名字报错: node is null");
43
+ return [];
44
+ }
45
+ const ancestors = node._util.ancestors;
46
+ const nodeArray = [...ancestors, node];
47
+ const nameList = /* @__PURE__ */ new Set();
48
+ outer:
49
+ for (const ancestor of nodeArray) {
50
+ if (ancestor.type === "VElement") {
51
+ nameList.add("default");
52
+ break outer;
53
+ }
54
+ if (ancestor.type === "ExportDefaultDeclaration") {
55
+ const { declaration } = ancestor;
56
+ if (declaration) {
57
+ nameList.add("default");
58
+ break outer;
59
+ }
60
+ }
61
+ if (ancestor.type === "ExportNamedDeclaration") {
62
+ const declarationType = (_a = ancestor.declaration) == null ? void 0 : _a.type;
63
+ if (import_SHARED_CONSTANTS.EXPORT_DECLARATION_TYPES.includes(declarationType)) {
64
+ const nameToAdd = ancestor.declaration.id.name;
65
+ if (nameToAdd) {
66
+ nameList.add(nameToAdd);
67
+ }
68
+ break outer;
69
+ } else if (["VariableDeclaration"].includes(declarationType)) {
70
+ (0, import_collectVariableDeclarationIdentifiers.default)(ancestor.declaration, (identifier) => {
71
+ nameList.add(identifier.name);
72
+ });
73
+ break outer;
74
+ } else if (declarationType) {
75
+ console.log("未处理的 declarationType :", declarationType);
76
+ }
77
+ const specifiers = ancestor.specifiers;
78
+ if (Array.isArray(specifiers)) {
79
+ for (const specifier of specifiers) {
80
+ if (specifier.type === "ExportSpecifier" || specifier.type === "ExportNamespaceSpecifier") {
81
+ nameList.add(specifier.exported.name);
82
+ }
83
+ }
84
+ }
85
+ break outer;
86
+ }
87
+ if (["FunctionDeclaration", "ClassDeclaration"].includes(ancestor.type) && "Program" === ((_b = ancestor._util.parent) == null ? void 0 : _b.type)) {
88
+ const ancestorId = ancestor.id;
89
+ if (ancestorId) {
90
+ const nameToAdd = (0, import_getExportedNameOfDeclarationIdentifier.default)(ancestorId);
91
+ if (nameToAdd) {
92
+ nameList.add(nameToAdd);
93
+ }
94
+ }
95
+ break outer;
96
+ }
97
+ if (["VariableDeclarator"].includes(ancestor.type)) {
98
+ const id = ancestor.id;
99
+ const varIdentifierSet = /* @__PURE__ */ new Set();
100
+ (0, import_deepSearchParamsIdentifier.default)(id, (identifier) => {
101
+ varIdentifierSet.add(identifier);
102
+ });
103
+ for (const identifier of varIdentifierSet) {
104
+ const nameToAdd = (0, import_getExportedNameOfDeclarationIdentifier.default)(identifier);
105
+ if (nameToAdd) {
106
+ nameList.add(nameToAdd);
107
+ }
108
+ }
109
+ break outer;
110
+ }
111
+ }
112
+ return Array.from(nameList);
113
+ }
@@ -0,0 +1,2 @@
1
+ import { AstNode } from "../AstUtil";
2
+ export default function getExportedNameOfDeclarationIdentifier(id: AstNode): any;
@@ -0,0 +1,40 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/util/ast_util/helper/getExportedNameOfDeclarationIdentifier.ts
20
+ var getExportedNameOfDeclarationIdentifier_exports = {};
21
+ __export(getExportedNameOfDeclarationIdentifier_exports, {
22
+ default: () => getExportedNameOfDeclarationIdentifier
23
+ });
24
+ module.exports = __toCommonJS(getExportedNameOfDeclarationIdentifier_exports);
25
+ function getExportedNameOfDeclarationIdentifier(id) {
26
+ var _a;
27
+ const occupationInExport = [...id._util.occupation].filter((op) => {
28
+ var _a2;
29
+ return ["ExportSpecifier", "ExportDefaultDeclaration"].includes((_a2 = op._util.parent) == null ? void 0 : _a2.type);
30
+ });
31
+ for (const op of occupationInExport) {
32
+ const occupationParentType = (_a = op._util.parent) == null ? void 0 : _a.type;
33
+ if (occupationParentType === "ExportSpecifier") {
34
+ return op._util.parent.exported.name;
35
+ }
36
+ if (occupationParentType === "ExportDefaultDeclaration") {
37
+ return "default";
38
+ }
39
+ }
40
+ }
@@ -0,0 +1,2 @@
1
+ import { AstNode } from "../AstUtil";
2
+ export default function getImpactedNode(ancestor: AstNode): AstNode | null;
@@ -0,0 +1,50 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/util/ast_util/helper/getImpactedNode.ts
20
+ var getImpactedNode_exports = {};
21
+ __export(getImpactedNode_exports, {
22
+ default: () => getImpactedNode
23
+ });
24
+ module.exports = __toCommonJS(getImpactedNode_exports);
25
+ function getImpactedNode(ancestor) {
26
+ const { type } = ancestor;
27
+ if (type === "JSXOpeningElement") {
28
+ const { name } = ancestor.name;
29
+ if (name && typeof name === "object") {
30
+ return name;
31
+ }
32
+ }
33
+ if (type === "JSXElement") {
34
+ const { openingElement } = ancestor;
35
+ const { name } = openingElement;
36
+ if (name && typeof name === "object") {
37
+ return name;
38
+ }
39
+ }
40
+ if (type === "VariableDeclarator") {
41
+ return ancestor.id;
42
+ }
43
+ if (type === "AssignmentExpression") {
44
+ return ancestor.left;
45
+ }
46
+ if (type === "FunctionDeclaration") {
47
+ return ancestor.id || ancestor;
48
+ }
49
+ return null;
50
+ }
@@ -0,0 +1,2 @@
1
+ import { AstNode } from "../AstUtil";
2
+ export default function getNearestImpactedNode(ancestors: AstNode[]): AstNode | undefined;
@@ -0,0 +1,43 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/util/ast_util/helper/getNearestImpactedNode.ts
30
+ var getNearestImpactedNode_exports = {};
31
+ __export(getNearestImpactedNode_exports, {
32
+ default: () => getNearestImpactedNode
33
+ });
34
+ module.exports = __toCommonJS(getNearestImpactedNode_exports);
35
+ var import_getImpactedNode = __toESM(require("./getImpactedNode"));
36
+ function getNearestImpactedNode(ancestors) {
37
+ for (const ancestor of ancestors) {
38
+ const impactedNode = (0, import_getImpactedNode.default)(ancestor);
39
+ if (impactedNode) {
40
+ return impactedNode;
41
+ }
42
+ }
43
+ }
@@ -0,0 +1,2 @@
1
+ import { AstNode } from "../AstUtil";
2
+ export default function getNodePath(node: AstNode): string;
@@ -0,0 +1,27 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/util/ast_util/helper/getNodePath.ts
20
+ var getNodePath_exports = {};
21
+ __export(getNodePath_exports, {
22
+ default: () => getNodePath
23
+ });
24
+ module.exports = __toCommonJS(getNodePath_exports);
25
+ function getNodePath(node) {
26
+ return [...node._util.ancestors, node].map((n) => n.type).join(":") + ":" + node.name;
27
+ }
@@ -0,0 +1,2 @@
1
+ import { AstNode } from "../AstUtil";
2
+ export default function getShortNodeMsg(node: AstNode, hideParentProperty?: boolean): string;
@@ -0,0 +1,38 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/util/ast_util/helper/getShortNodeMsg.ts
20
+ var getShortNodeMsg_exports = {};
21
+ __export(getShortNodeMsg_exports, {
22
+ default: () => getShortNodeMsg
23
+ });
24
+ module.exports = __toCommonJS(getShortNodeMsg_exports);
25
+ function getShortNodeMsg(node, hideParentProperty = false) {
26
+ const { _util: { startLine, startColumn, endLine, endColumn, parentProperty, indexOfProperty } } = node;
27
+ let type = node.type;
28
+ let name = node.name;
29
+ if (name && typeof name === "object") {
30
+ type = name.type;
31
+ name = name.name;
32
+ }
33
+ const msg = [
34
+ hideParentProperty ? [] : [parentProperty, indexOfProperty !== null ? String(indexOfProperty) : null],
35
+ [type, name]
36
+ ].map((e) => e.filter(Boolean).join(":")).filter(Boolean).join(" ");
37
+ return `${msg}「${startLine}:${startColumn}, ${endLine}:${endColumn}」`;
38
+ }
@@ -0,0 +1,2 @@
1
+ import { AstNode } from "../AstUtil";
2
+ export default function getTopScopeNodesByLineNumberRange(mapFileLineToNodeSet: Map<number, Set<AstNode>>, lineNumberStart: number, lineNumberEnd: number, loose?: boolean): AstNode[];