@lowgular/code-graph 0.0.1 → 0.1.2

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 (155) hide show
  1. package/bin/cli.js +2463 -0
  2. package/lib.js +2430 -0
  3. package/package.json +26 -7
  4. package/apps/code-graph/src/main.js +0 -50
  5. package/libs/cli/code-graph/src/index.js +0 -39
  6. package/libs/cli/code-graph/src/lib/class-declarations/abstractions/service.js +0 -72
  7. package/libs/cli/code-graph/src/lib/class-declarations/abstractions/service.stateful.js +0 -68
  8. package/libs/cli/code-graph/src/lib/class-declarations/class-declarations.doc.js +0 -147
  9. package/libs/cli/code-graph/src/lib/class-declarations/class-declarations.graph.js +0 -55
  10. package/libs/cli/code-graph/src/lib/class-declarations/index.js +0 -27
  11. package/libs/cli/code-graph/src/lib/code.graph.factory.js +0 -63
  12. package/libs/cli/code-graph/src/lib/code.graph.js +0 -62
  13. package/libs/cli/code-graph/src/lib/core/core.js +0 -58
  14. package/libs/cli/code-graph/src/lib/core.js +0 -85
  15. package/libs/cli/code-graph/src/lib/decorators/index.js +0 -36
  16. package/libs/cli/code-graph/src/lib/docs/index.js +0 -21
  17. package/libs/cli/code-graph/src/lib/docs/specs.js +0 -36
  18. package/libs/cli/code-graph/src/lib/expressions/call-expressions.graph.js +0 -28
  19. package/libs/cli/code-graph/src/lib/fixtures/reactive-event-bus/src/app/examples.event-bus.js +0 -53
  20. package/libs/cli/code-graph/src/lib/method-declarations/index.js +0 -23
  21. package/libs/cli/code-graph/src/lib/method-declarations/method-declarations.doc.js +0 -106
  22. package/libs/cli/code-graph/src/lib/method-declarations/method-declarations.graph.js +0 -56
  23. package/libs/cli/code-graph/src/lib/parameters/index.js +0 -42
  24. package/libs/cli/code-graph/src/lib/property-declarations/abstractions/reactive-state.evals.js +0 -139
  25. package/libs/cli/code-graph/src/lib/property-declarations/abstractions/reactive-state.js +0 -104
  26. package/libs/cli/code-graph/src/lib/property-declarations/index.js +0 -25
  27. package/libs/cli/code-graph/src/lib/property-declarations/property-declarations.doc.js +0 -74
  28. package/libs/cli/code-graph/src/lib/property-declarations/property-declarations.graph.js +0 -43
  29. package/libs/cli/code-graph/src/lib/tools/index.js +0 -34
  30. package/libs/cli/code-graph/src/lib/tools/match-code-graph.tool.js +0 -64
  31. package/libs/cli/code-graph/src/lib/types/index.js +0 -99
  32. package/libs/cli/code-graph/src/lib/v2/extractors/extractor.doc.js +0 -345
  33. package/libs/cli/code-graph/src/lib/v2/extractors/extractor.js +0 -52
  34. package/libs/cli/code-graph/src/lib/v2/extractors/index.js +0 -23
  35. package/libs/cli/code-graph/src/lib/v2/graph-builder/code-graph.builder.js +0 -76
  36. package/libs/cli/code-graph/src/lib/v2/graph-builder/index.js +0 -21
  37. package/libs/cli/code-graph/src/lib/v2/graph-builder/node.processor.js +0 -48
  38. package/libs/cli/code-graph/src/lib/v2/graph-builder/relationship.processor.js +0 -79
  39. package/libs/cli/code-graph/src/lib/v2/graph-builder/type.processor.js +0 -45
  40. package/libs/cli/code-graph/src/lib/v2/index.js +0 -37
  41. package/libs/cli/code-graph/src/lib/v2/tools/build-code-graph.doc.js +0 -220
  42. package/libs/cli/code-graph/src/lib/v2/tools/build-code-graph.tool.js +0 -42
  43. package/libs/cli/cypher/src/index.js +0 -25
  44. package/libs/cli/cypher/src/lib/docs/features/advanced-optional-match.feature.js +0 -277
  45. package/libs/cli/cypher/src/lib/docs/features/anonymous-relationship.feature.js +0 -69
  46. package/libs/cli/cypher/src/lib/docs/features/anonymous-variable-length.feature.js +0 -105
  47. package/libs/cli/cypher/src/lib/docs/features/basic-filtering.feature.js +0 -70
  48. package/libs/cli/cypher/src/lib/docs/features/basic-optional-match.feature.js +0 -99
  49. package/libs/cli/cypher/src/lib/docs/features/basic-relationship.feature.js +0 -125
  50. package/libs/cli/cypher/src/lib/docs/features/index.js +0 -51
  51. package/libs/cli/cypher/src/lib/docs/features/limit.feature.js +0 -50
  52. package/libs/cli/cypher/src/lib/docs/features/match-nodes.feature.js +0 -106
  53. package/libs/cli/cypher/src/lib/docs/features/multiple-relationship-types.feature.js +0 -105
  54. package/libs/cli/cypher/src/lib/docs/features/order-by.feature.js +0 -143
  55. package/libs/cli/cypher/src/lib/docs/features/property-matching.feature.js +0 -152
  56. package/libs/cli/cypher/src/lib/docs/features/relationship-without-variable.feature.js +0 -48
  57. package/libs/cli/cypher/src/lib/docs/features/return-statement.feature.js +0 -65
  58. package/libs/cli/cypher/src/lib/docs/features/unidirected-relationship.feature.js +0 -82
  59. package/libs/cli/cypher/src/lib/docs/features/variable-length-path.feature.js +0 -136
  60. package/libs/cli/cypher/src/lib/docs/features/where-conditional.feature.js +0 -187
  61. package/libs/cli/cypher/src/lib/docs/features/where-operators.feature.js +0 -302
  62. package/libs/cli/cypher/src/lib/docs/prompts.js +0 -36
  63. package/libs/cli/cypher/src/lib/docs/specs.js +0 -181
  64. package/libs/cli/cypher/src/lib/executor/condition-evaluator.js +0 -158
  65. package/libs/cli/cypher/src/lib/executor/executor.js +0 -83
  66. package/libs/cli/cypher/src/lib/executor/graph.js +0 -15
  67. package/libs/cli/cypher/src/lib/executor/match-engine.js +0 -153
  68. package/libs/cli/cypher/src/lib/executor/pattern-matcher.js +0 -109
  69. package/libs/cli/cypher/src/lib/executor/relationship-navigator.js +0 -64
  70. package/libs/cli/cypher/src/lib/executor/result-formatter.js +0 -143
  71. package/libs/cli/cypher/src/lib/executor/traverse-engine.js +0 -164
  72. package/libs/cli/cypher/src/lib/executor/utils.js +0 -37
  73. package/libs/cli/cypher/src/lib/graph.stub.js +0 -63
  74. package/libs/cli/cypher/src/lib/index.js +0 -74
  75. package/libs/cli/cypher/src/lib/lexer.js +0 -398
  76. package/libs/cli/cypher/src/lib/parser.js +0 -602
  77. package/libs/cli/cypher/src/lib/validator/query-validator.js +0 -95
  78. package/libs/cli/cypher/src/lib/validator/supported-features.config.js +0 -111
  79. package/libs/cli/cypher/src/lib/validator/unsupported-features.config.js +0 -150
  80. package/libs/cli/shared/src/index.js +0 -53
  81. package/libs/cli/shared/src/lib/admin-token.js +0 -121
  82. package/libs/cli/shared/src/lib/config.js +0 -49
  83. package/libs/cli/shared/src/lib/consts.js +0 -57
  84. package/libs/cli/shared/src/lib/core.js +0 -46
  85. package/libs/cli/shared/src/lib/infrastructure/cli.js +0 -47
  86. package/libs/cli/shared/src/lib/infrastructure/config.js +0 -47
  87. package/libs/cli/shared/src/lib/infrastructure/config.reporitory.js +0 -51
  88. package/libs/cli/shared/src/lib/infrastructure/formatters/console-formatter.js +0 -96
  89. package/libs/cli/shared/src/lib/infrastructure/formatters/index.js +0 -41
  90. package/libs/cli/shared/src/lib/infrastructure/formatters/json-formatter.js +0 -64
  91. package/libs/cli/shared/src/lib/infrastructure/formatters/markdown-formatter.js +0 -120
  92. package/libs/cli/shared/src/lib/infrastructure/formatters/types.js +0 -15
  93. package/libs/cli/shared/src/lib/infrastructure/formatters/utils.js +0 -72
  94. package/libs/cli/shared/src/lib/infrastructure/git.js +0 -147
  95. package/libs/cli/shared/src/lib/infrastructure/http.js +0 -257
  96. package/libs/cli/shared/src/lib/infrastructure/markdown.js +0 -95
  97. package/libs/cli/shared/src/lib/infrastructure/transformers/embeddings.js +0 -88
  98. package/libs/cli/shared/src/lib/infrastructure/transformers/index.js +0 -25
  99. package/libs/cli/shared/src/lib/infrastructure/transformers/rag-eval.js +0 -154
  100. package/libs/cli/shared/src/lib/infrastructure/transformers/similarity.js +0 -210
  101. package/libs/cli/shared/src/lib/infrastructure/workspace.js +0 -297
  102. package/libs/cli/shared/src/lib/infrastructure/yaml.js +0 -237
  103. package/libs/cli/shared/src/lib/lowgular.config.js +0 -120
  104. package/libs/cli/shared/src/lib/token.js +0 -135
  105. package/libs/cli/shared/src/lib/utils/solution.util.js +0 -35
  106. package/libs/cli/shared/src/lib/utils/utils.js +0 -89
  107. package/libs/cli/typescript/src/index.js +0 -21
  108. package/libs/cli/typescript/src/lib/base/index.js +0 -23
  109. package/libs/cli/typescript/src/lib/base/nameable.js +0 -34
  110. package/libs/cli/typescript/src/lib/base/nodeable.js +0 -36
  111. package/libs/cli/typescript/src/lib/class.implementation.js +0 -52
  112. package/libs/cli/typescript/src/lib/core/declaration.registry.js +0 -107
  113. package/libs/cli/typescript/src/lib/core/design-pattern.js +0 -55
  114. package/libs/cli/typescript/src/lib/core/index.js +0 -35
  115. package/libs/cli/typescript/src/lib/core/navigable-declaration.js +0 -69
  116. package/libs/cli/typescript/src/lib/core/program-context.js +0 -71
  117. package/libs/cli/typescript/src/lib/core/syntax-kind.utils.js +0 -40
  118. package/libs/cli/typescript/src/lib/core/type.js +0 -374
  119. package/libs/cli/typescript/src/lib/declaration.abstraction.js +0 -90
  120. package/libs/cli/typescript/src/lib/decorator.implementation.js +0 -35
  121. package/libs/cli/typescript/src/lib/enum.implementation.js +0 -35
  122. package/libs/cli/typescript/src/lib/function-declaration.implementation.js +0 -35
  123. package/libs/cli/typescript/src/lib/index.js +0 -57
  124. package/libs/cli/typescript/src/lib/interface.implementation.js +0 -51
  125. package/libs/cli/typescript/src/lib/members/method-abstraction.resolver.js +0 -90
  126. package/libs/cli/typescript/src/lib/members/method-declaration.implementation.js +0 -44
  127. package/libs/cli/typescript/src/lib/members/method-signature.implementation.js +0 -46
  128. package/libs/cli/typescript/src/lib/members/method.util.js +0 -32
  129. package/libs/cli/typescript/src/lib/members/parameter.implementation.js +0 -38
  130. package/libs/cli/typescript/src/lib/members/property-declaration.implementation.js +0 -64
  131. package/libs/cli/typescript/src/lib/members/property-signature.implementation.js +0 -34
  132. package/libs/cli/typescript/src/lib/members/property.util.js +0 -61
  133. package/libs/cli/typescript/src/lib/members/statements/expressions/binary-expression.implementation.js +0 -42
  134. package/libs/cli/typescript/src/lib/members/statements/expressions/call-expression.implementation.js +0 -114
  135. package/libs/cli/typescript/src/lib/members/statements/expressions/expression.abstraction.js +0 -188
  136. package/libs/cli/typescript/src/lib/members/statements/expressions/property-access-expression.implementation.js +0 -35
  137. package/libs/cli/typescript/src/lib/members/statements/expressions/unary-expression.implementation.js +0 -51
  138. package/libs/cli/typescript/src/lib/members/statements/statement.implementation.js +0 -49
  139. package/libs/cli/typescript/src/lib/members/statements/utils.js +0 -51
  140. package/libs/cli/typescript/src/lib/plugins/built-in.plugin.js +0 -258
  141. package/libs/cli/typescript/src/lib/plugins/plugin.interface.js +0 -15
  142. package/libs/cli/typescript/src/lib/plugins/rxjs.plugin.js +0 -228
  143. package/libs/cli/typescript/src/lib/plugins/signal.plugin.js +0 -126
  144. package/libs/cli/typescript/src/lib/plugins/stubs.js +0 -66
  145. package/libs/cli/typescript/src/lib/type-alias.implementation.js +0 -72
  146. package/libs/cli/typescript/src/lib/utils.js +0 -39
  147. package/libs/cli/typescript/src/lib/variable-declaration.implementation.js +0 -35
  148. package/libs/core/codegular/src/index.js +0 -21
  149. package/libs/core/codegular/src/lib/index.js +0 -29
  150. package/libs/core/codegular/src/lib/node.js +0 -112
  151. package/libs/core/codegular/src/lib/program.js +0 -92
  152. package/libs/core/codegular/src/lib/string.js +0 -168
  153. package/libs/core/codegular/src/lib/type-checker.js +0 -170
  154. package/libs/core/codegular/src/lib/utils.js +0 -347
  155. package/main.js +0 -43
@@ -1,112 +0,0 @@
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
- var node_exports = {};
29
- __export(node_exports, {
30
- every: () => every,
31
- findByDecorator: () => findByDecorator,
32
- findChildOrThrow: () => findChildOrThrow,
33
- getChildrenBy: () => getChildrenBy,
34
- getDecoratorName: () => getDecoratorName,
35
- hasAnyDecoratorName: () => hasAnyDecoratorName,
36
- hasDecorator: () => hasDecorator,
37
- hasKind: () => hasKind,
38
- hasName: () => hasName
39
- });
40
- module.exports = __toCommonJS(node_exports);
41
- var ts = __toESM(require("typescript"));
42
- var import_string = require("./string.js");
43
- const { forEachChild, SyntaxKind } = ts;
44
- const hasKind = (kinds) => (child) => kinds.includes(child.kind);
45
- const hasName = (names) => (child) => names.includes((0, import_string.getNameByIdentifier)(child));
46
- const hasDecorator = (decoratorName) => (child) => findByDecorator(child, decoratorName) !== void 0;
47
- const hasAnyDecoratorName = (node, decoratorNames) => {
48
- const decorators = getChildrenBy(node, hasKind([SyntaxKind.Decorator]));
49
- return decorators.find((d) => {
50
- return getChildrenBy(d, hasKind([SyntaxKind.CallExpression])).find(
51
- (callExpr) => {
52
- return decoratorNames.includes((0, import_string.getNameByIdentifier)(callExpr));
53
- }
54
- ) !== void 0;
55
- }) !== void 0;
56
- };
57
- const every = () => true;
58
- function getChildrenBy(node, findFunc = every) {
59
- const elements = [];
60
- forEachChild(node, (child) => {
61
- if (!findFunc(child)) {
62
- return;
63
- }
64
- elements.push(child);
65
- });
66
- return elements;
67
- }
68
- function findChildOrThrow(node, findFunc) {
69
- let element;
70
- forEachChild(node, (child) => {
71
- if (element)
72
- return;
73
- if (findFunc(child)) {
74
- element = child;
75
- return;
76
- }
77
- });
78
- if (element === void 0) {
79
- throw new Error("Could not find child");
80
- }
81
- return element;
82
- }
83
- const getDecoratorName = (d) => {
84
- return (0, import_string.getNameByIdentifier)(
85
- getChildrenBy(d, hasKind([SyntaxKind.CallExpression]))[0]
86
- );
87
- };
88
- const findByDecorator = (node, decoratorName) => {
89
- const decorators = getChildrenBy(node, hasKind([SyntaxKind.Decorator]));
90
- if (decorators.length === 0) {
91
- return void 0;
92
- }
93
- return decorators.find((d) => {
94
- return getChildrenBy(d, hasKind([SyntaxKind.CallExpression])).find(
95
- (callExpr) => {
96
- return (0, import_string.getNameByIdentifier)(callExpr) === decoratorName;
97
- }
98
- ) !== void 0;
99
- });
100
- };
101
- // Annotate the CommonJS export names for ESM import in node:
102
- 0 && (module.exports = {
103
- every,
104
- findByDecorator,
105
- findChildOrThrow,
106
- getChildrenBy,
107
- getDecoratorName,
108
- hasAnyDecoratorName,
109
- hasDecorator,
110
- hasKind,
111
- hasName
112
- });
@@ -1,92 +0,0 @@
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
- var program_exports = {};
29
- __export(program_exports, {
30
- createProgramFromFileSystem: () => createProgramFromFileSystem,
31
- createProgramFromTsConfig: () => createProgramFromTsConfig,
32
- createSourceFileFromContent: () => createSourceFileFromContent
33
- });
34
- module.exports = __toCommonJS(program_exports);
35
- var path = __toESM(require("path"));
36
- var ts = __toESM(require("typescript"));
37
- const createSourceFileFromContent = (fileName, content) => {
38
- return ts.createSourceFile(fileName, content, ts.ScriptTarget.Latest, true);
39
- };
40
- const createProgramFromFileSystem = (fileSystem) => {
41
- const compilerOptions = {
42
- target: ts.ScriptTarget.ES2020,
43
- module: ts.ModuleKind.CommonJS,
44
- moduleResolution: ts.ModuleResolutionKind.NodeJs,
45
- allowSyntheticDefaultImports: true,
46
- esModuleInterop: true,
47
- skipLibCheck: true,
48
- lib: ["ES2020", "DOM"]
49
- };
50
- const compilerHost = ts.createCompilerHost(compilerOptions);
51
- const originalGetSourceFile = compilerHost.getSourceFile;
52
- compilerHost.getSourceFile = (fileName, languageVersion) => {
53
- if (fileSystem[fileName]) {
54
- return ts.createSourceFile(
55
- fileName,
56
- fileSystem[fileName],
57
- languageVersion,
58
- true
59
- );
60
- }
61
- return originalGetSourceFile(fileName, languageVersion);
62
- };
63
- const fileNames = Object.keys(fileSystem);
64
- return ts.createProgram(fileNames, compilerOptions, compilerHost);
65
- };
66
- const createProgramFromTsConfig = (configPath) => {
67
- const configFile = ts.readConfigFile(configPath, ts.sys.readFile);
68
- if (configFile.error) {
69
- const errorMessage = ts.formatDiagnostic(configFile.error, {
70
- getCurrentDirectory: () => process.cwd(),
71
- getNewLine: () => "\n",
72
- getCanonicalFileName: (fileName) => fileName
73
- });
74
- throw new Error(`Error reading tsconfig at ${configPath}: ${errorMessage}`);
75
- }
76
- const parsedConfig = ts.parseJsonConfigFileContent(
77
- configFile.config,
78
- ts.sys,
79
- path.dirname(configPath)
80
- );
81
- return ts.createProgram(
82
- parsedConfig.fileNames,
83
- parsedConfig.options,
84
- ts.createCompilerHost(parsedConfig.options)
85
- );
86
- };
87
- // Annotate the CommonJS export names for ESM import in node:
88
- 0 && (module.exports = {
89
- createProgramFromFileSystem,
90
- createProgramFromTsConfig,
91
- createSourceFileFromContent
92
- });
@@ -1,168 +0,0 @@
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
- var string_exports = {};
29
- __export(string_exports, {
30
- getEndCharacter: () => getEndCharacter,
31
- getEndLine: () => getEndLine,
32
- getFilePath: () => getFilePath,
33
- getInitializerText: () => getInitializerText,
34
- getNameAndRange: () => getNameAndRange,
35
- getNameByIdentifier: () => getNameByIdentifier,
36
- getNameOrThrow: () => getNameOrThrow,
37
- getPropertyType: () => getPropertyType,
38
- getRange: () => getRange,
39
- getStartCharacter: () => getStartCharacter,
40
- getStartLine: () => getStartLine,
41
- getText: () => getText,
42
- getTextOrThrow: () => getTextOrThrow,
43
- rangeDistance: () => rangeDistance,
44
- throwUndefined: () => throwUndefined
45
- });
46
- module.exports = __toCommonJS(string_exports);
47
- var ts = __toESM(require("typescript"));
48
- var import_utils = require("./utils.js");
49
- const { SyntaxKind } = ts;
50
- const throwUndefined = (val, message) => {
51
- if (val === void 0) {
52
- throw new Error(message);
53
- }
54
- return val;
55
- };
56
- const getText = (n) => n.getText(n.getSourceFile());
57
- const getTextOrThrow = (n) => throwUndefined(getText(n), `Could not get text`);
58
- const getNameByIdentifier = (n) => {
59
- if (n.kind === SyntaxKind.Identifier) {
60
- return getText(n);
61
- }
62
- const [nameNode] = (0, import_utils.findChildrenByKind)(n, SyntaxKind.Identifier);
63
- return nameNode ? getText(nameNode) : void 0;
64
- };
65
- const getInitializerText = (node) => {
66
- return getText(node.initializer);
67
- };
68
- const getPropertyType = (node) => {
69
- const typeNode = node.type;
70
- if (typeNode) {
71
- return typeNode.getText(node.getSourceFile());
72
- }
73
- return void 0;
74
- };
75
- function getTypeFromInitializer(initializer) {
76
- if (ts.isStringLiteral(initializer)) {
77
- return "string";
78
- }
79
- if (ts.isNumericLiteral(initializer)) {
80
- return "number";
81
- }
82
- if (initializer.kind === ts.SyntaxKind.TrueKeyword || initializer.kind === ts.SyntaxKind.FalseKeyword) {
83
- return "boolean";
84
- }
85
- if (ts.isArrayLiteralExpression(initializer)) {
86
- return "any[]";
87
- }
88
- if (ts.isObjectLiteralExpression(initializer)) {
89
- return "object";
90
- }
91
- if (ts.isIdentifier(initializer)) {
92
- return initializer.text;
93
- }
94
- if (ts.isCallExpression(initializer)) {
95
- return "any";
96
- }
97
- if ("members" in initializer && initializer.members) {
98
- return "object";
99
- }
100
- return "any";
101
- }
102
- const getRange = (n) => {
103
- const s = n.getSourceFile();
104
- return {
105
- start: s.getLineAndCharacterOfPosition(n.getStart()),
106
- end: s.getLineAndCharacterOfPosition(n.getEnd())
107
- };
108
- };
109
- const getFilePath = (n) => {
110
- return n.getSourceFile().fileName;
111
- };
112
- const getStartLine = (n) => {
113
- const s = n.getSourceFile();
114
- return s.getLineAndCharacterOfPosition(n.getStart()).line;
115
- };
116
- const getEndLine = (n) => {
117
- const s = n.getSourceFile();
118
- return s.getLineAndCharacterOfPosition(n.getEnd()).line;
119
- };
120
- const getEndCharacter = (n) => {
121
- const s = n.getSourceFile();
122
- return s.getLineAndCharacterOfPosition(n.getEnd()).character;
123
- };
124
- const getStartCharacter = (n) => {
125
- const s = n.getSourceFile();
126
- return s.getLineAndCharacterOfPosition(n.getStart()).character;
127
- };
128
- function rangeDistance(outer, inner) {
129
- function toFlat(x) {
130
- return x.line * 1e6 + x.character;
131
- }
132
- const startDistance = toFlat(inner.start) - toFlat(outer.start);
133
- const endDistance = toFlat(outer.end) - toFlat(inner.end);
134
- if (startDistance < 0 || endDistance < 0) {
135
- console.log("rangeDistance: ", startDistance, endDistance);
136
- return void 0;
137
- }
138
- return startDistance + endDistance;
139
- }
140
- const getNameAndRange = (n) => {
141
- const [nameNode] = (0, import_utils.findChildrenByKind)(n, SyntaxKind.Identifier);
142
- if (!nameNode) {
143
- return void 0;
144
- }
145
- return {
146
- text: getText(nameNode),
147
- range: getRange(nameNode)
148
- };
149
- };
150
- const getNameOrThrow = (n) => throwUndefined(getNameByIdentifier(n), `Could not get name`);
151
- // Annotate the CommonJS export names for ESM import in node:
152
- 0 && (module.exports = {
153
- getEndCharacter,
154
- getEndLine,
155
- getFilePath,
156
- getInitializerText,
157
- getNameAndRange,
158
- getNameByIdentifier,
159
- getNameOrThrow,
160
- getPropertyType,
161
- getRange,
162
- getStartCharacter,
163
- getStartLine,
164
- getText,
165
- getTextOrThrow,
166
- rangeDistance,
167
- throwUndefined
168
- });
@@ -1,170 +0,0 @@
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
- var type_checker_exports = {};
29
- __export(type_checker_exports, {
30
- getDeclarationFromType: () => getDeclarationFromType,
31
- getDeclarationFromTypeLocation: () => getDeclarationFromTypeLocation,
32
- getDeclarationFromTypeReference: () => getDeclarationFromTypeReference,
33
- getDeclarationFromValueSymbol: () => getDeclarationFromValueSymbol,
34
- getDeclarations: () => getDeclarations
35
- });
36
- module.exports = __toCommonJS(type_checker_exports);
37
- var ts = __toESM(require("typescript"));
38
- const getDeclarationFromSymbol = (symbol, context) => {
39
- let aliasedSymbol = symbol;
40
- try {
41
- if (symbol.flags & ts.SymbolFlags.Alias) {
42
- aliasedSymbol = context.typeChecker.getAliasedSymbol(symbol) || symbol;
43
- }
44
- } catch (error) {
45
- aliasedSymbol = symbol;
46
- }
47
- const declarations = aliasedSymbol.getDeclarations();
48
- if (declarations && declarations.length > 0) {
49
- return declarations[declarations.length - 1];
50
- }
51
- return aliasedSymbol.valueDeclaration;
52
- };
53
- const getDeclarationFromType = (type, context) => {
54
- if (type.aliasSymbol) {
55
- const aliasDeclarations = type.aliasSymbol.getDeclarations();
56
- if (aliasDeclarations && aliasDeclarations.length > 0) {
57
- return aliasDeclarations[aliasDeclarations.length - 1];
58
- }
59
- if (type.aliasSymbol.valueDeclaration) {
60
- return type.aliasSymbol.valueDeclaration;
61
- }
62
- }
63
- const baseType = type.target || type;
64
- const typeSymbol = baseType.symbol;
65
- if (typeSymbol) {
66
- const declarations = typeSymbol.getDeclarations();
67
- if (declarations && declarations.length > 0) {
68
- return declarations[declarations.length - 1];
69
- }
70
- if (typeSymbol.valueDeclaration) {
71
- return typeSymbol.valueDeclaration;
72
- }
73
- }
74
- return void 0;
75
- };
76
- const getDeclarationFromTypeReference = (node, context) => {
77
- const symbol = context.typeChecker.getSymbolAtLocation(node.typeName);
78
- if (!symbol) {
79
- return void 0;
80
- }
81
- return getDeclarationFromSymbol(symbol, context);
82
- };
83
- const getDeclarationFromValueSymbol = (node, context) => {
84
- const symbol = context.typeChecker.getSymbolAtLocation(node);
85
- if (!symbol) {
86
- return void 0;
87
- }
88
- return getDeclarationFromSymbol(symbol, context);
89
- };
90
- const getDeclarationFromTypeLocation = (node, context) => {
91
- try {
92
- const type = context.typeChecker.getTypeAtLocation(node);
93
- if (!type) {
94
- return void 0;
95
- }
96
- return getDeclarationFromType(type, context);
97
- } catch (error) {
98
- return void 0;
99
- }
100
- };
101
- const getDeclarationsFromSymbol = (symbol, context) => {
102
- let aliasedSymbol = symbol;
103
- try {
104
- if (symbol.flags & ts.SymbolFlags.Alias) {
105
- aliasedSymbol = context.typeChecker.getAliasedSymbol(symbol) || symbol;
106
- }
107
- } catch (error) {
108
- aliasedSymbol = symbol;
109
- }
110
- const declarations = aliasedSymbol.getDeclarations();
111
- if (declarations && declarations.length > 0) {
112
- return declarations;
113
- }
114
- if (aliasedSymbol.valueDeclaration) {
115
- return [aliasedSymbol.valueDeclaration];
116
- }
117
- return [];
118
- };
119
- const getDeclarations = (node, typeChecker) => {
120
- if ("kind" in node) {
121
- const currentNode = node;
122
- if (ts.isTypeReferenceNode(node)) {
123
- const symbol = typeChecker.getSymbolAtLocation(node.typeName);
124
- if (symbol) {
125
- return getDeclarationsFromSymbol(symbol, { typeChecker });
126
- }
127
- return [];
128
- }
129
- try {
130
- const symbol = typeChecker.getSymbolAtLocation(currentNode);
131
- if (symbol) {
132
- return getDeclarationsFromSymbol(symbol, { typeChecker });
133
- }
134
- } catch (error) {
135
- }
136
- try {
137
- const type2 = typeChecker.getTypeAtLocation(currentNode);
138
- if (type2) {
139
- return getDeclarations(type2, typeChecker);
140
- }
141
- } catch (error) {
142
- }
143
- return [];
144
- }
145
- const type = node;
146
- const declarations = [];
147
- if (type.aliasSymbol) {
148
- const aliasDeclarations = type.aliasSymbol.getDeclarations();
149
- if (aliasDeclarations && aliasDeclarations.length > 0) {
150
- declarations.push(...aliasDeclarations);
151
- } else if (type.aliasSymbol.valueDeclaration) {
152
- declarations.push(type.aliasSymbol.valueDeclaration);
153
- }
154
- }
155
- const baseType = type.target || type;
156
- const typeSymbol = baseType.symbol;
157
- if (typeSymbol) {
158
- const typeDecls = getDeclarationsFromSymbol(typeSymbol, { typeChecker });
159
- declarations.push(...typeDecls);
160
- }
161
- return declarations;
162
- };
163
- // Annotate the CommonJS export names for ESM import in node:
164
- 0 && (module.exports = {
165
- getDeclarationFromType,
166
- getDeclarationFromTypeLocation,
167
- getDeclarationFromTypeReference,
168
- getDeclarationFromValueSymbol,
169
- getDeclarations
170
- });