tidewave 0.1.0

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.
@@ -0,0 +1,634 @@
1
+ var __create = Object.create;
2
+ var __getProtoOf = Object.getPrototypeOf;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __toESM = (mod, isNodeMode, target) => {
7
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
8
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
9
+ for (let key of __getOwnPropNames(mod))
10
+ if (!__hasOwnProp.call(to, key))
11
+ __defProp(to, key, {
12
+ get: () => mod[key],
13
+ enumerable: true
14
+ });
15
+ return to;
16
+ };
17
+ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
18
+ var __export = (target, all) => {
19
+ for (var name in all)
20
+ __defProp(target, name, {
21
+ get: all[name],
22
+ enumerable: true,
23
+ configurable: true,
24
+ set: (newValue) => all[name] = () => newValue
25
+ });
26
+ };
27
+
28
+ // src/resolution/utils.ts
29
+ import ts from "typescript";
30
+
31
+ // node:path
32
+ var L = Object.create;
33
+ var h = Object.defineProperty;
34
+ var D = Object.getOwnPropertyDescriptor;
35
+ var T = Object.getOwnPropertyNames;
36
+ var _ = Object.getPrototypeOf;
37
+ var E = Object.prototype.hasOwnProperty;
38
+ var R = (s, e) => () => (e || s((e = { exports: {} }).exports, e), e.exports);
39
+ var N = (s, e, r, t) => {
40
+ if (e && typeof e == "object" || typeof e == "function")
41
+ for (let i of T(e))
42
+ !E.call(s, i) && i !== r && h(s, i, { get: () => e[i], enumerable: !(t = D(e, i)) || t.enumerable });
43
+ return s;
44
+ };
45
+ var j = (s, e, r) => (r = s != null ? L(_(s)) : {}, N(e || !s || !s.__esModule ? h(r, "default", { value: s, enumerable: true }) : r, s));
46
+ var k = R((W, w) => {
47
+ function v(s) {
48
+ if (typeof s != "string")
49
+ throw new TypeError("Path must be a string. Received " + JSON.stringify(s));
50
+ }
51
+ function C(s, e) {
52
+ for (var r = "", t = 0, i = -1, a = 0, n, l = 0;l <= s.length; ++l) {
53
+ if (l < s.length)
54
+ n = s.charCodeAt(l);
55
+ else {
56
+ if (n === 47)
57
+ break;
58
+ n = 47;
59
+ }
60
+ if (n === 47) {
61
+ if (!(i === l - 1 || a === 1))
62
+ if (i !== l - 1 && a === 2) {
63
+ if (r.length < 2 || t !== 2 || r.charCodeAt(r.length - 1) !== 46 || r.charCodeAt(r.length - 2) !== 46) {
64
+ if (r.length > 2) {
65
+ var f = r.lastIndexOf("/");
66
+ if (f !== r.length - 1) {
67
+ f === -1 ? (r = "", t = 0) : (r = r.slice(0, f), t = r.length - 1 - r.lastIndexOf("/")), i = l, a = 0;
68
+ continue;
69
+ }
70
+ } else if (r.length === 2 || r.length === 1) {
71
+ r = "", t = 0, i = l, a = 0;
72
+ continue;
73
+ }
74
+ }
75
+ e && (r.length > 0 ? r += "/.." : r = "..", t = 2);
76
+ } else
77
+ r.length > 0 ? r += "/" + s.slice(i + 1, l) : r = s.slice(i + 1, l), t = l - i - 1;
78
+ i = l, a = 0;
79
+ } else
80
+ n === 46 && a !== -1 ? ++a : a = -1;
81
+ }
82
+ return r;
83
+ }
84
+ function F(s, e) {
85
+ var r = e.dir || e.root, t = e.base || (e.name || "") + (e.ext || "");
86
+ return r ? r === e.root ? r + t : r + s + t : t;
87
+ }
88
+ var m = { resolve: function() {
89
+ for (var e = "", r = false, t, i = arguments.length - 1;i >= -1 && !r; i--) {
90
+ var a;
91
+ i >= 0 ? a = arguments[i] : (t === undefined && (t = process.cwd()), a = t), v(a), a.length !== 0 && (e = a + "/" + e, r = a.charCodeAt(0) === 47);
92
+ }
93
+ return e = C(e, !r), r ? e.length > 0 ? "/" + e : "/" : e.length > 0 ? e : ".";
94
+ }, normalize: function(e) {
95
+ if (v(e), e.length === 0)
96
+ return ".";
97
+ var r = e.charCodeAt(0) === 47, t = e.charCodeAt(e.length - 1) === 47;
98
+ return e = C(e, !r), e.length === 0 && !r && (e = "."), e.length > 0 && t && (e += "/"), r ? "/" + e : e;
99
+ }, isAbsolute: function(e) {
100
+ return v(e), e.length > 0 && e.charCodeAt(0) === 47;
101
+ }, join: function() {
102
+ if (arguments.length === 0)
103
+ return ".";
104
+ for (var e, r = 0;r < arguments.length; ++r) {
105
+ var t = arguments[r];
106
+ v(t), t.length > 0 && (e === undefined ? e = t : e += "/" + t);
107
+ }
108
+ return e === undefined ? "." : m.normalize(e);
109
+ }, relative: function(e, r) {
110
+ if (v(e), v(r), e === r || (e = m.resolve(e), r = m.resolve(r), e === r))
111
+ return "";
112
+ for (var t = 1;t < e.length && e.charCodeAt(t) === 47; ++t)
113
+ ;
114
+ for (var i = e.length, a = i - t, n = 1;n < r.length && r.charCodeAt(n) === 47; ++n)
115
+ ;
116
+ for (var l = r.length, f = l - n, c = a < f ? a : f, d = -1, o = 0;o <= c; ++o) {
117
+ if (o === c) {
118
+ if (f > c) {
119
+ if (r.charCodeAt(n + o) === 47)
120
+ return r.slice(n + o + 1);
121
+ if (o === 0)
122
+ return r.slice(n + o);
123
+ } else
124
+ a > c && (e.charCodeAt(t + o) === 47 ? d = o : o === 0 && (d = 0));
125
+ break;
126
+ }
127
+ var A = e.charCodeAt(t + o), z = r.charCodeAt(n + o);
128
+ if (A !== z)
129
+ break;
130
+ A === 47 && (d = o);
131
+ }
132
+ var b = "";
133
+ for (o = t + d + 1;o <= i; ++o)
134
+ (o === i || e.charCodeAt(o) === 47) && (b.length === 0 ? b += ".." : b += "/..");
135
+ return b.length > 0 ? b + r.slice(n + d) : (n += d, r.charCodeAt(n) === 47 && ++n, r.slice(n));
136
+ }, _makeLong: function(e) {
137
+ return e;
138
+ }, dirname: function(e) {
139
+ if (v(e), e.length === 0)
140
+ return ".";
141
+ for (var r = e.charCodeAt(0), t = r === 47, i = -1, a = true, n = e.length - 1;n >= 1; --n)
142
+ if (r = e.charCodeAt(n), r === 47) {
143
+ if (!a) {
144
+ i = n;
145
+ break;
146
+ }
147
+ } else
148
+ a = false;
149
+ return i === -1 ? t ? "/" : "." : t && i === 1 ? "//" : e.slice(0, i);
150
+ }, basename: function(e, r) {
151
+ if (r !== undefined && typeof r != "string")
152
+ throw new TypeError('"ext" argument must be a string');
153
+ v(e);
154
+ var t = 0, i = -1, a = true, n;
155
+ if (r !== undefined && r.length > 0 && r.length <= e.length) {
156
+ if (r.length === e.length && r === e)
157
+ return "";
158
+ var l = r.length - 1, f = -1;
159
+ for (n = e.length - 1;n >= 0; --n) {
160
+ var c = e.charCodeAt(n);
161
+ if (c === 47) {
162
+ if (!a) {
163
+ t = n + 1;
164
+ break;
165
+ }
166
+ } else
167
+ f === -1 && (a = false, f = n + 1), l >= 0 && (c === r.charCodeAt(l) ? --l === -1 && (i = n) : (l = -1, i = f));
168
+ }
169
+ return t === i ? i = f : i === -1 && (i = e.length), e.slice(t, i);
170
+ } else {
171
+ for (n = e.length - 1;n >= 0; --n)
172
+ if (e.charCodeAt(n) === 47) {
173
+ if (!a) {
174
+ t = n + 1;
175
+ break;
176
+ }
177
+ } else
178
+ i === -1 && (a = false, i = n + 1);
179
+ return i === -1 ? "" : e.slice(t, i);
180
+ }
181
+ }, extname: function(e) {
182
+ v(e);
183
+ for (var r = -1, t = 0, i = -1, a = true, n = 0, l = e.length - 1;l >= 0; --l) {
184
+ var f = e.charCodeAt(l);
185
+ if (f === 47) {
186
+ if (!a) {
187
+ t = l + 1;
188
+ break;
189
+ }
190
+ continue;
191
+ }
192
+ i === -1 && (a = false, i = l + 1), f === 46 ? r === -1 ? r = l : n !== 1 && (n = 1) : r !== -1 && (n = -1);
193
+ }
194
+ return r === -1 || i === -1 || n === 0 || n === 1 && r === i - 1 && r === t + 1 ? "" : e.slice(r, i);
195
+ }, format: function(e) {
196
+ if (e === null || typeof e != "object")
197
+ throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof e);
198
+ return F("/", e);
199
+ }, parse: function(e) {
200
+ v(e);
201
+ var r = { root: "", dir: "", base: "", ext: "", name: "" };
202
+ if (e.length === 0)
203
+ return r;
204
+ var t = e.charCodeAt(0), i = t === 47, a;
205
+ i ? (r.root = "/", a = 1) : a = 0;
206
+ for (var n = -1, l = 0, f = -1, c = true, d = e.length - 1, o = 0;d >= a; --d) {
207
+ if (t = e.charCodeAt(d), t === 47) {
208
+ if (!c) {
209
+ l = d + 1;
210
+ break;
211
+ }
212
+ continue;
213
+ }
214
+ f === -1 && (c = false, f = d + 1), t === 46 ? n === -1 ? n = d : o !== 1 && (o = 1) : n !== -1 && (o = -1);
215
+ }
216
+ return n === -1 || f === -1 || o === 0 || o === 1 && n === f - 1 && n === l + 1 ? f !== -1 && (l === 0 && i ? r.base = r.name = e.slice(1, f) : r.base = r.name = e.slice(l, f)) : (l === 0 && i ? (r.name = e.slice(1, n), r.base = e.slice(1, f)) : (r.name = e.slice(l, n), r.base = e.slice(l, f)), r.ext = e.slice(n, f)), l > 0 ? r.dir = e.slice(0, l - 1) : i && (r.dir = "/"), r;
217
+ }, sep: "/", delimiter: ":", win32: null, posix: null };
218
+ m.posix = m;
219
+ w.exports = m;
220
+ });
221
+ var x = j(k());
222
+ var u = x;
223
+ var J = x;
224
+ var P = function(s) {
225
+ return s;
226
+ };
227
+ var S = function() {
228
+ throw new Error("Not implemented");
229
+ };
230
+ u.parse ??= S;
231
+ J.parse ??= S;
232
+ var g = { resolve: u.resolve.bind(u), normalize: u.normalize.bind(u), isAbsolute: u.isAbsolute.bind(u), join: u.join.bind(u), relative: u.relative.bind(u), toNamespacedPath: P, dirname: u.dirname.bind(u), basename: u.basename.bind(u), extname: u.extname.bind(u), format: u.format.bind(u), parse: u.parse.bind(u), sep: "/", delimiter: ":", win32: undefined, posix: undefined, _makeLong: P };
233
+ var y = { sep: "\\", delimiter: ";", win32: undefined, ...g, posix: g };
234
+ g.win32 = y.win32 = y;
235
+ g.posix = g;
236
+ var q = g;
237
+
238
+ // src/resolution/utils.ts
239
+ function getLocation(symbol) {
240
+ if (symbol.valueDeclaration) {
241
+ const sourceFile = symbol.valueDeclaration.getSourceFile();
242
+ const { line, character } = sourceFile.getLineAndCharacterOfPosition(symbol.valueDeclaration.getStart());
243
+ let { fileName } = sourceFile;
244
+ const cwd = process.cwd();
245
+ if (fileName.startsWith(cwd)) {
246
+ fileName = q.relative(cwd, fileName);
247
+ }
248
+ return `${fileName}:${line + 1}:${character + 1}`;
249
+ }
250
+ if (symbol.declarations && symbol.declarations.length > 0) {
251
+ const [firstDeclaration] = symbol.declarations;
252
+ const sourceFile = firstDeclaration?.getSourceFile();
253
+ if (sourceFile === undefined || firstDeclaration === undefined)
254
+ return "unknown";
255
+ const { line, character } = sourceFile.getLineAndCharacterOfPosition(firstDeclaration.getStart());
256
+ let fileName = sourceFile?.fileName;
257
+ const cwd = process.cwd();
258
+ if (fileName?.startsWith(cwd)) {
259
+ fileName = q.relative(cwd, fileName);
260
+ }
261
+ return `${fileName}:${line + 1}:${character + 1}`;
262
+ }
263
+ return "unknown";
264
+ }
265
+ function getDocumentation(checker, symbol) {
266
+ return ts.displayPartsToString(symbol.getDocumentationComment(checker));
267
+ }
268
+ function getJSDoc(checker, symbol) {
269
+ const jsDocTags = symbol.getJsDocTags(checker);
270
+ return jsDocTags.map((tag) => {
271
+ const tagName = tag.name;
272
+ const tagText = tag.text ? ts.displayPartsToString(tag.text) : "";
273
+ return `@${tagName}${tagText ? " " + tagText : ""}`;
274
+ }).join(`
275
+ `);
276
+ }
277
+ function getSymbolKind(symbol) {
278
+ const flags = symbol.getFlags();
279
+ if (flags & ts.SymbolFlags.Function)
280
+ return "function";
281
+ if (flags & ts.SymbolFlags.Class)
282
+ return "class";
283
+ if (flags & ts.SymbolFlags.Interface)
284
+ return "interface";
285
+ if (flags & ts.SymbolFlags.TypeAlias)
286
+ return "type";
287
+ if (flags & ts.SymbolFlags.Variable)
288
+ return "variable";
289
+ if (flags & ts.SymbolFlags.Property)
290
+ return "property";
291
+ if (flags & ts.SymbolFlags.Method)
292
+ return "method";
293
+ if (flags & ts.SymbolFlags.Enum)
294
+ return "enum";
295
+ if (flags & ts.SymbolFlags.Module)
296
+ return "module";
297
+ if (symbol.valueDeclaration) {
298
+ if (ts.isFunctionDeclaration(symbol.valueDeclaration)) {
299
+ return "function";
300
+ }
301
+ if (ts.isClassDeclaration(symbol.valueDeclaration)) {
302
+ return "class";
303
+ }
304
+ if (ts.isVariableDeclaration(symbol.valueDeclaration)) {
305
+ return "variable";
306
+ }
307
+ if (ts.isMethodDeclaration(symbol.valueDeclaration)) {
308
+ return "method";
309
+ }
310
+ }
311
+ return "unknown";
312
+ }
313
+
314
+ // src/resolution/formatters.ts
315
+ import ts2 from "typescript";
316
+ function getSignature(checker, symbol, type) {
317
+ const signatures = checker.getSignaturesOfType(type, ts2.SignatureKind.Call);
318
+ if (signatures.length > 0) {
319
+ return signatures.map((sig) => {
320
+ const sigString = checker.signatureToString(sig);
321
+ return `${symbol.getName()}${sigString}`;
322
+ }).join(`
323
+ `);
324
+ }
325
+ const constructSignatures = checker.getSignaturesOfType(type, ts2.SignatureKind.Construct);
326
+ if (constructSignatures.length > 0) {
327
+ return constructSignatures.map((sig) => "new " + checker.signatureToString(sig)).join(`
328
+ `);
329
+ }
330
+ if (symbol.valueDeclaration || symbol.declarations && symbol.declarations.length > 0) {
331
+ const declaration = symbol.valueDeclaration || symbol.declarations[0];
332
+ if (!declaration)
333
+ return checker.typeToString(type);
334
+ const sourceFile = declaration.getSourceFile();
335
+ if (ts2.isFunctionDeclaration(declaration) && declaration.name) {
336
+ const functionType = checker.getTypeOfSymbolAtLocation(symbol, declaration);
337
+ const functionSignatures = checker.getSignaturesOfType(functionType, ts2.SignatureKind.Call);
338
+ if (functionSignatures.length > 0) {
339
+ return functionSignatures.map((sig) => checker.signatureToString(sig)).join(`
340
+ `);
341
+ }
342
+ }
343
+ if (ts2.isInterfaceDeclaration(declaration) || ts2.isTypeAliasDeclaration(declaration)) {
344
+ const start2 = declaration.getStart();
345
+ const end2 = declaration.getEnd();
346
+ const text2 = sourceFile.text.substring(start2, end2);
347
+ const lines = text2.split(`
348
+ `).map((line) => line.trim()).filter((line) => line.length > 0);
349
+ if (ts2.isInterfaceDeclaration(declaration)) {
350
+ const bodyStart = text2.indexOf("{");
351
+ const bodyEnd = text2.lastIndexOf("}");
352
+ if (bodyStart !== -1 && bodyEnd !== -1) {
353
+ const body = text2.substring(bodyStart, bodyEnd + 1);
354
+ const interfaceName = `interface ${declaration.name.text}`;
355
+ const compactBody = body.replace(/\s*\n\s*/g, " ").replace(/\s+/g, " ");
356
+ return `${interfaceName} ${compactBody}`;
357
+ }
358
+ }
359
+ return lines.join(" ").replace(/\s+/g, " ");
360
+ }
361
+ if (ts2.isClassDeclaration(declaration)) {
362
+ const classType = checker.getTypeOfSymbolAtLocation(symbol, declaration);
363
+ const classConstructSignatures = checker.getSignaturesOfType(classType, ts2.SignatureKind.Construct);
364
+ if (classConstructSignatures.length > 0) {
365
+ return classConstructSignatures.map((sig) => "new " + checker.signatureToString(sig)).join(`
366
+ `);
367
+ } else {
368
+ const start2 = declaration.getStart();
369
+ const end2 = Math.min(declaration.getStart() + 100, declaration.getEnd());
370
+ const text2 = sourceFile.text.substring(start2, end2);
371
+ return text2.split(`
372
+ `)[0]?.trim() + (text2.includes(`
373
+ `) ? "..." : "") || "";
374
+ }
375
+ }
376
+ const start = declaration.getStart();
377
+ const end = Math.min(declaration.getStart() + 100, declaration.getEnd());
378
+ const text = sourceFile.text.substring(start, end);
379
+ return text.split(`
380
+ `)[0]?.trim() + (text.includes(`
381
+ `) ? "..." : "") || "";
382
+ }
383
+ return checker.typeToString(type);
384
+ }
385
+ function getTypeString(checker, symbol, type) {
386
+ if (symbol.flags & (ts2.SymbolFlags.Interface | ts2.SymbolFlags.TypeAlias)) {
387
+ const declaration = symbol.valueDeclaration || symbol.declarations && symbol.declarations[0];
388
+ if (declaration && ts2.isInterfaceDeclaration(declaration)) {
389
+ const properties = type.getProperties();
390
+ if (properties.length > 0) {
391
+ const propertyStrings = properties.map((prop) => {
392
+ const propDeclaration = prop.valueDeclaration || prop.declarations && prop.declarations[0];
393
+ const propType = propDeclaration ? checker.getTypeOfSymbolAtLocation(prop, propDeclaration) : checker.getTypeAtLocation(prop.declarations[0]);
394
+ const propTypeString = checker.typeToString(propType);
395
+ const isOptional = prop.flags & ts2.SymbolFlags.Optional;
396
+ return `${prop.getName()}${isOptional ? "?" : ""}: ${propTypeString}`;
397
+ });
398
+ return `{ ${propertyStrings.join("; ")} }`;
399
+ }
400
+ }
401
+ }
402
+ const defaultTypeString = checker.typeToString(type);
403
+ if (defaultTypeString === "any" && symbol.flags & ts2.SymbolFlags.Interface) {
404
+ return `interface ${symbol.getName()}`;
405
+ }
406
+ return defaultTypeString;
407
+ }
408
+ function formatOutput(info) {
409
+ const output = [];
410
+ output.push(`
411
+ ${info.name}`);
412
+ output.push(`Kind: ${info.kind}`);
413
+ output.push(`Location: ${info.location}`);
414
+ output.push("");
415
+ if (info.signature) {
416
+ output.push("Signature:");
417
+ output.push(info.signature);
418
+ output.push("");
419
+ }
420
+ if (info.documentation) {
421
+ output.push("Documentation:");
422
+ output.push(info.documentation);
423
+ output.push("");
424
+ }
425
+ if (info.jsDoc) {
426
+ output.push("JSDoc Tags:");
427
+ output.push(info.jsDoc);
428
+ output.push("");
429
+ }
430
+ output.push("Type:");
431
+ output.push(info.type);
432
+ return output.join(`
433
+ `);
434
+ }
435
+
436
+ // src/resolution/symbol-finder.ts
437
+ import ts3 from "typescript";
438
+
439
+ // src/core.ts
440
+ function isResolveError(result) {
441
+ return result != null && "success" in result && result.success === false;
442
+ }
443
+ function isExtractError(result) {
444
+ return result != null && "error" in result;
445
+ }
446
+ function resolveError(specifier, source) {
447
+ return {
448
+ success: false,
449
+ error: {
450
+ code: "MODULE_NOT_FOUND",
451
+ message: `Cannot resolve module '${specifier}' from '${source}'`
452
+ }
453
+ };
454
+ }
455
+ function createExtractError(code, message, details) {
456
+ return {
457
+ error: {
458
+ code,
459
+ message,
460
+ details
461
+ }
462
+ };
463
+ }
464
+
465
+ // src/resolution/symbol-finder.ts
466
+ function findSymbolInJavaScriptFile(sourceFile, checker, symbolName) {
467
+ for (const statement of sourceFile.statements) {
468
+ if (ts3.isFunctionDeclaration(statement) && statement.name?.text === symbolName) {
469
+ return checker.getSymbolAtLocation(statement.name);
470
+ }
471
+ if (ts3.isClassDeclaration(statement) && statement.name?.text === symbolName) {
472
+ return checker.getSymbolAtLocation(statement.name);
473
+ }
474
+ if (ts3.isVariableStatement(statement)) {
475
+ for (const declaration of statement.declarationList.declarations) {
476
+ if (ts3.isIdentifier(declaration.name) && declaration.name.text === symbolName) {
477
+ return checker.getSymbolAtLocation(declaration.name);
478
+ }
479
+ }
480
+ }
481
+ if (ts3.isExpressionStatement(statement)) {
482
+ const { expression } = statement;
483
+ if (ts3.isBinaryExpression(expression) && expression.operatorToken.kind === ts3.SyntaxKind.EqualsToken) {
484
+ const { left, right } = expression;
485
+ if (ts3.isPropertyAccessExpression(left) && ts3.isIdentifier(left.expression) && left.expression.text === "module" && ts3.isIdentifier(left.name) && left.name.text === "exports" && ts3.isObjectLiteralExpression(right)) {
486
+ for (const prop of right.properties) {
487
+ if (ts3.isPropertyAssignment(prop) || ts3.isShorthandPropertyAssignment(prop)) {
488
+ const propName = ts3.isIdentifier(prop.name) ? prop.name.text : undefined;
489
+ if (propName === symbolName) {
490
+ let targetIdentifier;
491
+ if (ts3.isShorthandPropertyAssignment(prop)) {
492
+ targetIdentifier = prop.name;
493
+ } else if (ts3.isPropertyAssignment(prop) && ts3.isIdentifier(prop.initializer)) {
494
+ targetIdentifier = prop.initializer;
495
+ }
496
+ if (targetIdentifier) {
497
+ for (const statement2 of sourceFile.statements) {
498
+ if (ts3.isFunctionDeclaration(statement2) && statement2.name?.text === targetIdentifier.text) {
499
+ const originalSymbol = checker.getSymbolAtLocation(statement2.name);
500
+ if (originalSymbol) {
501
+ return originalSymbol;
502
+ }
503
+ }
504
+ if (ts3.isClassDeclaration(statement2) && statement2.name?.text === targetIdentifier.text) {
505
+ const originalSymbol = checker.getSymbolAtLocation(statement2.name);
506
+ if (originalSymbol) {
507
+ return originalSymbol;
508
+ }
509
+ }
510
+ if (ts3.isVariableStatement(statement2)) {
511
+ for (const declaration of statement2.declarationList.declarations) {
512
+ if (ts3.isIdentifier(declaration.name) && declaration.name.text === targetIdentifier.text) {
513
+ const originalSymbol = checker.getSymbolAtLocation(declaration.name);
514
+ if (originalSymbol) {
515
+ return originalSymbol;
516
+ }
517
+ }
518
+ }
519
+ }
520
+ }
521
+ const exportSymbol = checker.getSymbolAtLocation(targetIdentifier);
522
+ return exportSymbol;
523
+ }
524
+ }
525
+ }
526
+ }
527
+ }
528
+ }
529
+ }
530
+ }
531
+ return;
532
+ }
533
+ function getSymbolInfo(checker, symbol, member, isStatic) {
534
+ const declaration = symbol.valueDeclaration || symbol.declarations && symbol.declarations[0];
535
+ if (!declaration && (!symbol.declarations || symbol.declarations.length === 0)) {
536
+ return createExtractError("TYPE_ERROR", `Symbol '${symbol.getName()}' has no declarations`);
537
+ }
538
+ const targetDeclaration = declaration || symbol.declarations[0];
539
+ const type = checker.getTypeOfSymbolAtLocation(symbol, targetDeclaration);
540
+ const symbolName = symbol.getName();
541
+ let targetSymbol = symbol;
542
+ let targetType = type;
543
+ let name = symbolName;
544
+ if (member) {
545
+ if (isStatic) {
546
+ const staticMembers = checker.getPropertiesOfType(type);
547
+ const staticMember = staticMembers.find((s) => s.getName() === member);
548
+ if (staticMember) {
549
+ targetSymbol = staticMember;
550
+ targetType = checker.getTypeOfSymbolAtLocation(staticMember, staticMember.valueDeclaration);
551
+ name = `${symbolName}.${member}`;
552
+ } else {
553
+ return createExtractError("MEMBER_NOT_FOUND", `Static member '${member}' not found on '${symbolName}'`);
554
+ }
555
+ } else {
556
+ let instanceType;
557
+ if (symbol.flags & ts3.SymbolFlags.Class) {
558
+ instanceType = checker.getTypeOfSymbolAtLocation(symbol, symbol.valueDeclaration);
559
+ const constructSignatures = instanceType.getConstructSignatures();
560
+ if (constructSignatures.length > 0) {
561
+ const [constructSignature] = constructSignatures;
562
+ if (constructSignature) {
563
+ const instanceTypeFromConstruct = checker.getReturnTypeOfSignature(constructSignature);
564
+ const instanceMembers = checker.getPropertiesOfType(instanceTypeFromConstruct);
565
+ const instanceMember = instanceMembers.find((s) => s.getName() === member);
566
+ if (instanceMember) {
567
+ targetSymbol = instanceMember;
568
+ targetType = checker.getTypeOfSymbolAtLocation(instanceMember, instanceMember.valueDeclaration);
569
+ name = `${symbolName}#${member}`;
570
+ } else {
571
+ return createExtractError("MEMBER_NOT_FOUND", `Instance member '${member}' not found on '${symbolName}'. Available: ${instanceMembers.map((m) => m.getName()).join(", ")}`);
572
+ }
573
+ }
574
+ } else {
575
+ const instanceMembers = checker.getPropertiesOfType(instanceType);
576
+ const instanceMember = instanceMembers.find((s) => s.getName() === member);
577
+ if (instanceMember) {
578
+ targetSymbol = instanceMember;
579
+ targetType = checker.getTypeOfSymbolAtLocation(instanceMember, instanceMember.valueDeclaration);
580
+ name = `${symbolName}#${member}`;
581
+ } else {
582
+ return createExtractError("MEMBER_NOT_FOUND", `Instance member '${member}' not found on '${symbolName}'. Available: ${instanceMembers.map((m) => m.getName()).join(", ")}`);
583
+ }
584
+ }
585
+ } else {
586
+ const callSignatures = type.getCallSignatures();
587
+ const constructSignatures = type.getConstructSignatures();
588
+ if (constructSignatures.length > 0) {
589
+ const [constructSignature] = constructSignatures;
590
+ if (constructSignature) {
591
+ instanceType = checker.getReturnTypeOfSignature(constructSignature);
592
+ }
593
+ } else if (callSignatures.length > 0) {
594
+ const [callSignature] = callSignatures;
595
+ if (callSignature) {
596
+ instanceType = checker.getReturnTypeOfSignature(callSignature);
597
+ }
598
+ }
599
+ if (instanceType) {
600
+ const instanceMembers = checker.getPropertiesOfType(instanceType);
601
+ const instanceMember = instanceMembers.find((s) => s.getName() === member);
602
+ if (instanceMember) {
603
+ targetSymbol = instanceMember;
604
+ targetType = checker.getTypeOfSymbolAtLocation(instanceMember, instanceMember.valueDeclaration);
605
+ name = `${symbolName}#${member}`;
606
+ } else {
607
+ return createExtractError("MEMBER_NOT_FOUND", `Instance member '${member}' not found on '${symbolName}'`);
608
+ }
609
+ } else {
610
+ return createExtractError("TYPE_ERROR", `'${symbolName}' is not a constructor or class`);
611
+ }
612
+ }
613
+ }
614
+ }
615
+ const typeString = getTypeString(checker, targetSymbol, targetType);
616
+ const signature = getSignature(checker, targetSymbol, targetType);
617
+ const documentation = getDocumentation(checker, targetSymbol);
618
+ const jsDoc = getJSDoc(checker, targetSymbol);
619
+ const kind = getSymbolKind(targetSymbol);
620
+ const location = getLocation(targetSymbol);
621
+ return {
622
+ name,
623
+ kind,
624
+ type: typeString,
625
+ documentation,
626
+ jsDoc,
627
+ signature,
628
+ location
629
+ };
630
+ }
631
+ export {
632
+ getSymbolInfo,
633
+ findSymbolInJavaScriptFile
634
+ };