@aiready/core 0.24.19 → 0.24.21
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/dist/chunk-3NEZ5M7Y.mjs +385 -340
- package/dist/chunk-5IVDH26E.mjs +142 -88
- package/dist/chunk-BE52N7T2.mjs +892 -0
- package/dist/chunk-GQMKSUA4.mjs +381 -336
- package/dist/chunk-LRM26BOB.mjs +381 -336
- package/dist/chunk-MOM3IXCA.mjs +146 -91
- package/dist/chunk-OT6FOHL4.mjs +144 -88
- package/dist/chunk-OVWWYI75.mjs +307 -0
- package/dist/chunk-U3IY2CFC.mjs +18 -22
- package/dist/chunk-WPFXQH5F.mjs +307 -0
- package/dist/chunk-WUDUSXUE.mjs +366 -0
- package/dist/chunk-YQATXOKD.mjs +36 -0
- package/dist/chunk-YVPVNRFQ.mjs +937 -0
- package/dist/client/index.mjs +2 -2
- package/dist/csharp-parser-JE5MWHQS.mjs +9 -0
- package/dist/csharp-parser-XW7WHE77.mjs +5 -9
- package/dist/go-parser-KTG4CGF5.mjs +5 -9
- package/dist/go-parser-T7PR6WJI.mjs +9 -0
- package/dist/index-CcP12wb-.d.mts +996 -693
- package/dist/index-CcP12wb-.d.ts +996 -693
- package/dist/index-DGbarGnr.d.mts +996 -693
- package/dist/index-DGbarGnr.d.ts +996 -693
- package/dist/index-slasaNzr.d.mts +998 -695
- package/dist/index-slasaNzr.d.ts +998 -695
- package/dist/index.d.mts +32 -1
- package/dist/index.d.ts +32 -1
- package/dist/index.js +35 -2
- package/dist/index.mjs +41 -9
- package/dist/java-parser-EOKMGQ6B.mjs +5 -9
- package/dist/java-parser-WGOXKULP.mjs +9 -0
- package/dist/python-parser-7NCR7VCQ.mjs +8 -0
- package/dist/python-parser-BCI7JVLF.mjs +4 -8
- package/dist/typescript-parser-3KYGSSY5.mjs +3 -0
- package/dist/typescript-parser-4BA4VYAF.mjs +3 -7
- package/dist/typescript-parser-FOUPHVFI.mjs +3 -7
- package/dist/typescript-parser-G3TSNR7O.mjs +7 -0
- package/dist/typescript-parser-RMNCTHRD.mjs +3 -7
- package/dist/typescript-parser-WALISXF4.mjs +7 -0
- package/package.json +11 -10
package/dist/chunk-5IVDH26E.mjs
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ParseError
|
|
3
|
-
} from "./chunk-U3IY2CFC.mjs";
|
|
1
|
+
import { ParseError } from './chunk-U3IY2CFC.mjs';
|
|
4
2
|
|
|
5
3
|
// src/parsers/typescript-parser.ts
|
|
6
|
-
import { parse } from
|
|
4
|
+
import { parse } from '@typescript-eslint/typescript-estree';
|
|
7
5
|
var TypeScriptParser = class {
|
|
8
6
|
constructor() {
|
|
9
|
-
this.language =
|
|
10
|
-
this.extensions = [
|
|
11
|
-
}
|
|
12
|
-
async initialize() {
|
|
7
|
+
this.language = 'typescript' /* TypeScript */;
|
|
8
|
+
this.extensions = ['.ts', '.tsx', '.js', '.jsx'];
|
|
13
9
|
}
|
|
10
|
+
async initialize() {}
|
|
14
11
|
canHandle(filePath) {
|
|
15
12
|
return this.extensions.some((ext) => filePath.endsWith(ext));
|
|
16
13
|
}
|
|
@@ -22,13 +19,13 @@ var TypeScriptParser = class {
|
|
|
22
19
|
range: true,
|
|
23
20
|
tokens: true,
|
|
24
21
|
comment: true,
|
|
25
|
-
jsx: filePath.endsWith(
|
|
22
|
+
jsx: filePath.endsWith('x'),
|
|
26
23
|
});
|
|
27
24
|
} catch (error) {
|
|
28
25
|
const err = error;
|
|
29
|
-
throw new ParseError(err.message ||
|
|
26
|
+
throw new ParseError(err.message || 'Unknown error', filePath, {
|
|
30
27
|
line: err.lineNumber || 1,
|
|
31
|
-
column: err.column || 0
|
|
28
|
+
column: err.column || 0,
|
|
32
29
|
});
|
|
33
30
|
}
|
|
34
31
|
}
|
|
@@ -40,19 +37,19 @@ var TypeScriptParser = class {
|
|
|
40
37
|
range: true,
|
|
41
38
|
tokens: true,
|
|
42
39
|
comment: true,
|
|
43
|
-
jsx: filePath.endsWith(
|
|
40
|
+
jsx: filePath.endsWith('x'),
|
|
44
41
|
});
|
|
45
42
|
const imports = this.extractImports(ast);
|
|
46
43
|
const exports = this.extractExports(ast, code, filePath);
|
|
47
44
|
return {
|
|
48
45
|
exports,
|
|
49
46
|
imports,
|
|
50
|
-
language: this.language
|
|
47
|
+
language: this.language,
|
|
51
48
|
};
|
|
52
49
|
} catch (error) {
|
|
53
50
|
throw new ParseError(error.message, filePath, {
|
|
54
51
|
line: error.lineNumber || 1,
|
|
55
|
-
column: error.column || 0
|
|
52
|
+
column: error.column || 0,
|
|
56
53
|
});
|
|
57
54
|
}
|
|
58
55
|
}
|
|
@@ -63,47 +60,50 @@ var TypeScriptParser = class {
|
|
|
63
60
|
classPattern: /^[A-Z][a-zA-Z0-9]*$/,
|
|
64
61
|
constantPattern: /^[A-Z][A-Z0-9_]*$/,
|
|
65
62
|
typePattern: /^[A-Z][a-zA-Z0-9]*$/,
|
|
66
|
-
interfacePattern: /^I?[A-Z][a-zA-Z0-9]
|
|
63
|
+
interfacePattern: /^I?[A-Z][a-zA-Z0-9]*$/,
|
|
67
64
|
};
|
|
68
65
|
}
|
|
69
66
|
analyzeMetadata(node, code) {
|
|
70
67
|
if (!code) return {};
|
|
71
68
|
return {
|
|
72
69
|
isPure: this.isLikelyPure(node),
|
|
73
|
-
hasSideEffects: !this.isLikelyPure(node)
|
|
70
|
+
hasSideEffects: !this.isLikelyPure(node),
|
|
74
71
|
};
|
|
75
72
|
}
|
|
76
73
|
extractImports(ast) {
|
|
77
74
|
const imports = [];
|
|
78
75
|
for (const node of ast.body) {
|
|
79
|
-
if (node.type ===
|
|
76
|
+
if (node.type === 'ImportDeclaration') {
|
|
80
77
|
const specifiers = [];
|
|
81
78
|
let isTypeOnly = false;
|
|
82
|
-
if (node.importKind ===
|
|
79
|
+
if (node.importKind === 'type') {
|
|
83
80
|
isTypeOnly = true;
|
|
84
81
|
}
|
|
85
82
|
for (const spec of node.specifiers) {
|
|
86
|
-
if (spec.type ===
|
|
83
|
+
if (spec.type === 'ImportSpecifier') {
|
|
87
84
|
const imported = spec.imported;
|
|
88
|
-
const name =
|
|
85
|
+
const name =
|
|
86
|
+
imported.type === 'Identifier' ? imported.name : imported.value;
|
|
89
87
|
specifiers.push(name);
|
|
90
|
-
} else if (spec.type ===
|
|
91
|
-
specifiers.push(
|
|
92
|
-
} else if (spec.type ===
|
|
93
|
-
specifiers.push(
|
|
88
|
+
} else if (spec.type === 'ImportDefaultSpecifier') {
|
|
89
|
+
specifiers.push('default');
|
|
90
|
+
} else if (spec.type === 'ImportNamespaceSpecifier') {
|
|
91
|
+
specifiers.push('*');
|
|
94
92
|
}
|
|
95
93
|
}
|
|
96
94
|
imports.push({
|
|
97
95
|
source: node.source.value,
|
|
98
96
|
specifiers,
|
|
99
97
|
isTypeOnly,
|
|
100
|
-
loc: node.loc
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
98
|
+
loc: node.loc
|
|
99
|
+
? {
|
|
100
|
+
start: {
|
|
101
|
+
line: node.loc.start.line,
|
|
102
|
+
column: node.loc.start.column,
|
|
103
|
+
},
|
|
104
|
+
end: { line: node.loc.end.line, column: node.loc.end.column },
|
|
105
|
+
}
|
|
106
|
+
: void 0,
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
109
|
}
|
|
@@ -112,60 +112,67 @@ var TypeScriptParser = class {
|
|
|
112
112
|
extractExports(ast, code, filePath) {
|
|
113
113
|
const exports = [];
|
|
114
114
|
for (const node of ast.body) {
|
|
115
|
-
if (node.type ===
|
|
115
|
+
if (node.type === 'ExportNamedDeclaration') {
|
|
116
116
|
if (node.declaration) {
|
|
117
117
|
const declaration = node.declaration;
|
|
118
|
-
if (
|
|
118
|
+
if (
|
|
119
|
+
(declaration.type === 'FunctionDeclaration' ||
|
|
120
|
+
declaration.type === 'TSDeclareFunction') &&
|
|
121
|
+
declaration.id
|
|
122
|
+
) {
|
|
119
123
|
exports.push(
|
|
120
124
|
this.createExport(
|
|
121
125
|
declaration.id.name,
|
|
122
|
-
|
|
126
|
+
'function',
|
|
123
127
|
node,
|
|
124
128
|
// Pass the outer ExportNamedDeclaration
|
|
125
129
|
code,
|
|
126
130
|
filePath
|
|
127
131
|
)
|
|
128
132
|
);
|
|
129
|
-
} else if (
|
|
133
|
+
} else if (
|
|
134
|
+
declaration.type === 'ClassDeclaration' &&
|
|
135
|
+
declaration.id
|
|
136
|
+
) {
|
|
130
137
|
exports.push(
|
|
131
138
|
this.createExport(
|
|
132
139
|
declaration.id.name,
|
|
133
|
-
|
|
140
|
+
'class',
|
|
134
141
|
node,
|
|
135
142
|
// Pass the outer ExportNamedDeclaration
|
|
136
143
|
code,
|
|
137
144
|
filePath
|
|
138
145
|
)
|
|
139
146
|
);
|
|
140
|
-
} else if (declaration.type ===
|
|
147
|
+
} else if (declaration.type === 'TSTypeAliasDeclaration') {
|
|
141
148
|
exports.push(
|
|
142
149
|
this.createExport(
|
|
143
150
|
declaration.id.name,
|
|
144
|
-
|
|
151
|
+
'type',
|
|
145
152
|
node,
|
|
146
153
|
// Pass the outer ExportNamedDeclaration
|
|
147
154
|
code,
|
|
148
155
|
filePath
|
|
149
156
|
)
|
|
150
157
|
);
|
|
151
|
-
} else if (declaration.type ===
|
|
158
|
+
} else if (declaration.type === 'TSInterfaceDeclaration') {
|
|
152
159
|
exports.push(
|
|
153
160
|
this.createExport(
|
|
154
161
|
declaration.id.name,
|
|
155
|
-
|
|
162
|
+
'interface',
|
|
156
163
|
node,
|
|
157
164
|
// Pass the outer ExportNamedDeclaration
|
|
158
165
|
code,
|
|
159
166
|
filePath
|
|
160
167
|
)
|
|
161
168
|
);
|
|
162
|
-
} else if (declaration.type ===
|
|
169
|
+
} else if (declaration.type === 'VariableDeclaration') {
|
|
163
170
|
for (const decl of declaration.declarations) {
|
|
164
|
-
if (decl.id.type ===
|
|
171
|
+
if (decl.id.type === 'Identifier') {
|
|
165
172
|
exports.push(
|
|
166
173
|
this.createExport(
|
|
167
174
|
decl.id.name,
|
|
168
|
-
|
|
175
|
+
'const',
|
|
169
176
|
node,
|
|
170
177
|
code,
|
|
171
178
|
filePath,
|
|
@@ -176,9 +183,9 @@ var TypeScriptParser = class {
|
|
|
176
183
|
}
|
|
177
184
|
}
|
|
178
185
|
}
|
|
179
|
-
} else if (node.type ===
|
|
186
|
+
} else if (node.type === 'ExportDefaultDeclaration') {
|
|
180
187
|
exports.push(
|
|
181
|
-
this.createExport(
|
|
188
|
+
this.createExport('default', 'default', node, code, filePath)
|
|
182
189
|
);
|
|
183
190
|
}
|
|
184
191
|
}
|
|
@@ -192,78 +199,118 @@ var TypeScriptParser = class {
|
|
|
192
199
|
let isPrimitive = false;
|
|
193
200
|
let isTyped = false;
|
|
194
201
|
if (initializer) {
|
|
195
|
-
if (
|
|
202
|
+
if (
|
|
203
|
+
initializer.type === 'Literal' ||
|
|
204
|
+
(initializer.type === 'TemplateLiteral' &&
|
|
205
|
+
initializer.expressions.length === 0)
|
|
206
|
+
) {
|
|
196
207
|
isPrimitive = true;
|
|
197
208
|
}
|
|
198
209
|
}
|
|
199
|
-
let structNode =
|
|
210
|
+
let structNode =
|
|
211
|
+
node.type === 'ExportNamedDeclaration' && node.declaration
|
|
212
|
+
? node.declaration
|
|
213
|
+
: node.type === 'ExportDefaultDeclaration'
|
|
214
|
+
? node.declaration
|
|
215
|
+
: node;
|
|
200
216
|
if (!structNode) structNode = node;
|
|
201
|
-
if (filePath.endsWith(
|
|
202
|
-
if (
|
|
217
|
+
if (filePath.endsWith('.ts') || filePath.endsWith('.tsx')) {
|
|
218
|
+
if (
|
|
219
|
+
structNode.type === 'TSTypeAliasDeclaration' ||
|
|
220
|
+
structNode.type === 'TSInterfaceDeclaration' ||
|
|
221
|
+
structNode.type === 'TSEnumDeclaration'
|
|
222
|
+
) {
|
|
203
223
|
isTyped = true;
|
|
204
|
-
} else if (
|
|
224
|
+
} else if (
|
|
225
|
+
structNode.type === 'FunctionDeclaration' ||
|
|
226
|
+
structNode.type === 'TSDeclareFunction'
|
|
227
|
+
) {
|
|
205
228
|
const func = structNode;
|
|
206
229
|
const hasReturnType = !!func.returnType;
|
|
207
|
-
const allParamsTyped =
|
|
230
|
+
const allParamsTyped =
|
|
231
|
+
func.params.length === 0 ||
|
|
232
|
+
func.params.every((p) => !!p.typeAnnotation);
|
|
208
233
|
isTyped = hasReturnType && allParamsTyped;
|
|
209
|
-
} else if (structNode.type ===
|
|
234
|
+
} else if (structNode.type === 'VariableDeclaration') {
|
|
210
235
|
const variable = structNode;
|
|
211
236
|
isTyped = variable.declarations.every(
|
|
212
237
|
(d) => !!d.id.typeAnnotation || !!d.init
|
|
213
238
|
);
|
|
214
|
-
} else if (structNode.type ===
|
|
239
|
+
} else if (structNode.type === 'ClassDeclaration') {
|
|
215
240
|
isTyped = true;
|
|
216
241
|
}
|
|
217
|
-
} else if (filePath.endsWith(
|
|
242
|
+
} else if (filePath.endsWith('.js') || filePath.endsWith('.jsx')) {
|
|
218
243
|
isTyped = false;
|
|
219
244
|
}
|
|
220
|
-
if (
|
|
221
|
-
|
|
245
|
+
if (
|
|
246
|
+
structNode.type === 'ClassDeclaration' ||
|
|
247
|
+
structNode.type === 'TSInterfaceDeclaration'
|
|
248
|
+
) {
|
|
249
|
+
const body =
|
|
250
|
+
structNode.type === 'ClassDeclaration'
|
|
251
|
+
? structNode.body.body
|
|
252
|
+
: structNode.body.body;
|
|
222
253
|
methodCount = body.filter(
|
|
223
|
-
(m) => m.type ===
|
|
254
|
+
(m) => m.type === 'MethodDefinition' || m.type === 'TSMethodSignature'
|
|
224
255
|
).length;
|
|
225
256
|
propertyCount = body.filter(
|
|
226
|
-
(m) =>
|
|
257
|
+
(m) =>
|
|
258
|
+
m.type === 'PropertyDefinition' || m.type === 'TSPropertySignature'
|
|
227
259
|
).length;
|
|
228
|
-
if (structNode.type ===
|
|
260
|
+
if (structNode.type === 'ClassDeclaration') {
|
|
229
261
|
const constructor = body.find(
|
|
230
|
-
(m) => m.type ===
|
|
262
|
+
(m) => m.type === 'MethodDefinition' && m.kind === 'constructor'
|
|
231
263
|
);
|
|
232
264
|
if (constructor && constructor.value && constructor.value.params) {
|
|
233
|
-
parameters = constructor.value.params
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
265
|
+
parameters = constructor.value.params
|
|
266
|
+
.map((p) => {
|
|
267
|
+
if (p.type === 'Identifier') return p.name;
|
|
268
|
+
if (
|
|
269
|
+
p.type === 'TSParameterProperty' &&
|
|
270
|
+
p.parameter.type === 'Identifier'
|
|
271
|
+
) {
|
|
272
|
+
return p.parameter.name;
|
|
273
|
+
}
|
|
274
|
+
return void 0;
|
|
275
|
+
})
|
|
276
|
+
.filter((p) => !!p);
|
|
240
277
|
}
|
|
241
278
|
}
|
|
242
279
|
}
|
|
243
|
-
if (
|
|
244
|
-
|
|
280
|
+
if (
|
|
281
|
+
!parameters &&
|
|
282
|
+
(structNode.type === 'FunctionDeclaration' ||
|
|
283
|
+
structNode.type === 'TSDeclareFunction' ||
|
|
284
|
+
structNode.type === 'MethodDefinition')
|
|
285
|
+
) {
|
|
286
|
+
const funcNode =
|
|
287
|
+
structNode.type === 'MethodDefinition' ? structNode.value : structNode;
|
|
245
288
|
if (funcNode && funcNode.params) {
|
|
246
|
-
parameters = funcNode.params
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
289
|
+
parameters = funcNode.params
|
|
290
|
+
.map((p) => {
|
|
291
|
+
if (p.type === 'Identifier') return p.name;
|
|
292
|
+
return void 0;
|
|
293
|
+
})
|
|
294
|
+
.filter((p) => !!p);
|
|
250
295
|
}
|
|
251
296
|
}
|
|
252
297
|
return {
|
|
253
298
|
name,
|
|
254
299
|
type,
|
|
255
300
|
isPrimitive,
|
|
256
|
-
loc: node.loc
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
301
|
+
loc: node.loc
|
|
302
|
+
? {
|
|
303
|
+
start: { line: node.loc.start.line, column: node.loc.start.column },
|
|
304
|
+
end: { line: node.loc.end.line, column: node.loc.end.column },
|
|
305
|
+
}
|
|
306
|
+
: void 0,
|
|
260
307
|
documentation,
|
|
261
308
|
methodCount,
|
|
262
309
|
propertyCount,
|
|
263
310
|
parameters,
|
|
264
311
|
isPure: this.isLikelyPure(node),
|
|
265
312
|
hasSideEffects: !this.isLikelyPure(node),
|
|
266
|
-
isTyped
|
|
313
|
+
isTyped,
|
|
267
314
|
};
|
|
268
315
|
}
|
|
269
316
|
extractDocumentation(node, code) {
|
|
@@ -274,21 +321,30 @@ var TypeScriptParser = class {
|
|
|
274
321
|
if (jsdocMatch) {
|
|
275
322
|
return {
|
|
276
323
|
content: jsdocMatch[1].trim(),
|
|
277
|
-
type:
|
|
324
|
+
type: 'jsdoc',
|
|
278
325
|
};
|
|
279
326
|
}
|
|
280
327
|
}
|
|
281
328
|
return void 0;
|
|
282
329
|
}
|
|
283
330
|
isLikelyPure(node) {
|
|
284
|
-
const sn =
|
|
331
|
+
const sn =
|
|
332
|
+
node.type === 'ExportNamedDeclaration' && node.declaration
|
|
333
|
+
? node.declaration
|
|
334
|
+
: node.type === 'ExportDefaultDeclaration'
|
|
335
|
+
? node.declaration
|
|
336
|
+
: node;
|
|
285
337
|
if (!sn) return false;
|
|
286
|
-
if (sn.type ===
|
|
287
|
-
if (sn.type ===
|
|
288
|
-
const body = sn.type ===
|
|
289
|
-
if (body && body.type ===
|
|
338
|
+
if (sn.type === 'VariableDeclaration' && sn.kind === 'const') return true;
|
|
339
|
+
if (sn.type === 'FunctionDeclaration' || sn.type === 'MethodDefinition') {
|
|
340
|
+
const body = sn.type === 'MethodDefinition' ? sn.value.body : sn.body;
|
|
341
|
+
if (body && body.type === 'BlockStatement') {
|
|
290
342
|
const bodyContent = JSON.stringify(body);
|
|
291
|
-
if (
|
|
343
|
+
if (
|
|
344
|
+
bodyContent.includes('"name":"console"') ||
|
|
345
|
+
bodyContent.includes('"name":"process"') ||
|
|
346
|
+
bodyContent.includes('"type":"AssignmentExpression"')
|
|
347
|
+
) {
|
|
292
348
|
return false;
|
|
293
349
|
}
|
|
294
350
|
return true;
|
|
@@ -299,6 +355,4 @@ var TypeScriptParser = class {
|
|
|
299
355
|
}
|
|
300
356
|
};
|
|
301
357
|
|
|
302
|
-
export {
|
|
303
|
-
TypeScriptParser
|
|
304
|
-
};
|
|
358
|
+
export { TypeScriptParser };
|