tidewave 0.1.0 → 0.3.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,5 @@
1
+ import ts from 'typescript';
2
+ import type { SymbolInfo } from '../core';
3
+ export declare function getSignature(checker: ts.TypeChecker, symbol: ts.Symbol, type: ts.Type): string;
4
+ export declare function getTypeString(checker: ts.TypeChecker, symbol: ts.Symbol, type: ts.Type): string;
5
+ export declare function formatOutput(info: SymbolInfo): string;
@@ -1,3 +1,4 @@
1
+ import { createRequire } from "node:module";
1
2
  var __create = Object.create;
2
3
  var __getProtoOf = Object.getPrototypeOf;
3
4
  var __defProp = Object.defineProperty;
@@ -24,6 +25,7 @@ var __export = (target, all) => {
24
25
  set: (newValue) => all[name] = () => newValue
25
26
  });
26
27
  };
28
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
27
29
 
28
30
  // src/resolution/formatters.ts
29
31
  import ts from "typescript";
@@ -0,0 +1,6 @@
1
+ import type { ExtractionRequest, ExtractResult, ExtractorOptions, ResolveResult } from '../core';
2
+ import { formatOutput } from './formatters';
3
+ export declare function extractDocs(modulePath: string): Promise<ExtractResult>;
4
+ export declare function getSourceLocation(reference: string): Promise<ResolveResult>;
5
+ export declare function extractSymbol(request: ExtractionRequest, options?: ExtractorOptions): Promise<ExtractResult>;
6
+ export { formatOutput };
@@ -1,3 +1,4 @@
1
+ import { createRequire } from "node:module";
1
2
  var __create = Object.create;
2
3
  var __getProtoOf = Object.getPrototypeOf;
3
4
  var __defProp = Object.defineProperty;
@@ -24,218 +25,12 @@ var __export = (target, all) => {
24
25
  set: (newValue) => all[name] = () => newValue
25
26
  });
26
27
  };
27
-
28
- // src/resolution/module-resolver.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;
28
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
237
29
 
238
30
  // src/core.ts
31
+ function isError(result) {
32
+ return result != null && "success" in result && result.success === false;
33
+ }
239
34
  function isResolveError(result) {
240
35
  return result != null && "success" in result && result.success === false;
241
36
  }
@@ -262,6 +57,8 @@ function createExtractError(code, message, details) {
262
57
  }
263
58
 
264
59
  // src/resolution/module-resolver.ts
60
+ import ts from "typescript";
61
+ import path from "node:path";
265
62
  function loadTsConfig(prefix) {
266
63
  const projectPath = prefix || process.cwd();
267
64
  const configPath = ts.findConfigFile(projectPath, ts.sys.fileExists, "tsconfig.json");
@@ -281,7 +78,7 @@ function loadTsConfig(prefix) {
281
78
  if (configPath) {
282
79
  const configFile = ts.readConfigFile(configPath, ts.sys.readFile);
283
80
  if (configFile.config) {
284
- const parsedConfig = ts.parseJsonConfigFileContent(configFile.config, ts.sys, q.dirname(configPath));
81
+ const parsedConfig = ts.parseJsonConfigFileContent(configFile.config, ts.sys, path.dirname(configPath));
285
82
  compilerOptions = { ...compilerOptions, ...parsedConfig.options };
286
83
  rootNames = parsedConfig.fileNames;
287
84
  }
@@ -293,7 +90,7 @@ function loadTsConfig(prefix) {
293
90
  }
294
91
  function resolveModule(moduleName, compilerOptions) {
295
92
  if (moduleName.startsWith("./") || moduleName.startsWith("../") || moduleName.includes(".") && !moduleName.includes("/")) {
296
- const absolutePath = q.resolve(moduleName);
93
+ const absolutePath = path.resolve(moduleName);
297
94
  if (ts.sys.fileExists(absolutePath)) {
298
95
  const dedicatedProgram = ts.createProgram([absolutePath], compilerOptions);
299
96
  const sourceFile = dedicatedProgram.getSourceFile(absolutePath);
@@ -302,7 +99,7 @@ function resolveModule(moduleName, compilerOptions) {
302
99
  }
303
100
  }
304
101
  }
305
- const moduleResolver = ts.resolveModuleName(moduleName, q.resolve("./index.ts"), compilerOptions, ts.sys);
102
+ const moduleResolver = ts.resolveModuleName(moduleName, path.resolve("./index.ts"), compilerOptions, ts.sys);
306
103
  if (moduleResolver.resolvedModule) {
307
104
  const { resolvedFileName } = moduleResolver.resolvedModule;
308
105
  const dedicatedProgram = ts.createProgram([resolvedFileName], compilerOptions);
@@ -365,6 +162,7 @@ function resolveNodeBuiltin(moduleName, compilerOptions) {
365
162
 
366
163
  // src/resolution/utils.ts
367
164
  import ts2 from "typescript";
165
+ import path2 from "node:path";
368
166
  function getLocation(symbol) {
369
167
  if (symbol.valueDeclaration) {
370
168
  const sourceFile = symbol.valueDeclaration.getSourceFile();
@@ -372,7 +170,7 @@ function getLocation(symbol) {
372
170
  let { fileName } = sourceFile;
373
171
  const cwd = process.cwd();
374
172
  if (fileName.startsWith(cwd)) {
375
- fileName = q.relative(cwd, fileName);
173
+ fileName = path2.relative(cwd, fileName);
376
174
  }
377
175
  return `${fileName}:${line + 1}:${character + 1}`;
378
176
  }
@@ -385,7 +183,7 @@ function getLocation(symbol) {
385
183
  let fileName = sourceFile?.fileName;
386
184
  const cwd = process.cwd();
387
185
  if (fileName?.startsWith(cwd)) {
388
- fileName = q.relative(cwd, fileName);
186
+ fileName = path2.relative(cwd, fileName);
389
187
  }
390
188
  return `${fileName}:${line + 1}:${character + 1}`;
391
189
  }
@@ -732,6 +530,7 @@ function getSymbolInfo(checker, symbol, member, isStatic) {
732
530
 
733
531
  // src/resolution/index.ts
734
532
  import ts5 from "typescript";
533
+ import path3 from "node:path";
735
534
  function parseModulePath(modulePath) {
736
535
  let module;
737
536
  let symbolPath;
@@ -936,12 +735,12 @@ async function getSourceLocation(reference) {
936
735
  }
937
736
  const moduleName = reference;
938
737
  if (moduleName.startsWith("./") || moduleName.startsWith("../")) {
939
- const absolutePath = q.resolve(moduleName);
738
+ const absolutePath = path3.resolve(moduleName);
940
739
  if (ts5.sys.fileExists(absolutePath)) {
941
740
  const cwd = process.cwd();
942
741
  let finalPath;
943
742
  if (absolutePath.startsWith(cwd)) {
944
- const relativePath = q.relative(cwd, absolutePath);
743
+ const relativePath = path3.relative(cwd, absolutePath);
945
744
  finalPath = relativePath.startsWith("..") ? absolutePath : relativePath;
946
745
  } else {
947
746
  finalPath = absolutePath;
@@ -950,13 +749,13 @@ async function getSourceLocation(reference) {
950
749
  }
951
750
  }
952
751
  const config = loadTsConfig(options.prefix);
953
- const moduleResolver = ts5.resolveModuleName(moduleName, q.resolve("./index.ts"), config.options, ts5.sys);
752
+ const moduleResolver = ts5.resolveModuleName(moduleName, path3.resolve("./index.ts"), config.options, ts5.sys);
954
753
  if (moduleResolver.resolvedModule) {
955
754
  const { resolvedFileName } = moduleResolver.resolvedModule;
956
755
  const cwd = process.cwd();
957
756
  let finalPath;
958
757
  if (resolvedFileName.startsWith(cwd)) {
959
- const relativePath = q.relative(cwd, resolvedFileName);
758
+ const relativePath = path3.relative(cwd, resolvedFileName);
960
759
  finalPath = relativePath.startsWith("..") ? resolvedFileName : relativePath;
961
760
  } else {
962
761
  finalPath = resolvedFileName;
@@ -0,0 +1,8 @@
1
+ import ts from 'typescript';
2
+ import type { InternalResolveResult } from '../core';
3
+ export declare function loadTsConfig(prefix?: string): {
4
+ fileNames: string[];
5
+ options: ts.CompilerOptions;
6
+ };
7
+ export declare function resolveModule(moduleName: string, compilerOptions: ts.CompilerOptions): InternalResolveResult;
8
+ export declare function resolveNodeBuiltin(moduleName: string, compilerOptions: ts.CompilerOptions): InternalResolveResult;
@@ -1,3 +1,4 @@
1
+ import { createRequire } from "node:module";
1
2
  var __create = Object.create;
2
3
  var __getProtoOf = Object.getPrototypeOf;
3
4
  var __defProp = Object.defineProperty;
@@ -24,218 +25,12 @@ var __export = (target, all) => {
24
25
  set: (newValue) => all[name] = () => newValue
25
26
  });
26
27
  };
27
-
28
- // src/resolution/module-resolver.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;
28
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
237
29
 
238
30
  // src/core.ts
31
+ function isError(result) {
32
+ return result != null && "success" in result && result.success === false;
33
+ }
239
34
  function isResolveError(result) {
240
35
  return result != null && "success" in result && result.success === false;
241
36
  }
@@ -262,6 +57,8 @@ function createExtractError(code, message, details) {
262
57
  }
263
58
 
264
59
  // src/resolution/module-resolver.ts
60
+ import ts from "typescript";
61
+ import path from "node:path";
265
62
  function loadTsConfig(prefix) {
266
63
  const projectPath = prefix || process.cwd();
267
64
  const configPath = ts.findConfigFile(projectPath, ts.sys.fileExists, "tsconfig.json");
@@ -281,7 +78,7 @@ function loadTsConfig(prefix) {
281
78
  if (configPath) {
282
79
  const configFile = ts.readConfigFile(configPath, ts.sys.readFile);
283
80
  if (configFile.config) {
284
- const parsedConfig = ts.parseJsonConfigFileContent(configFile.config, ts.sys, q.dirname(configPath));
81
+ const parsedConfig = ts.parseJsonConfigFileContent(configFile.config, ts.sys, path.dirname(configPath));
285
82
  compilerOptions = { ...compilerOptions, ...parsedConfig.options };
286
83
  rootNames = parsedConfig.fileNames;
287
84
  }
@@ -293,7 +90,7 @@ function loadTsConfig(prefix) {
293
90
  }
294
91
  function resolveModule(moduleName, compilerOptions) {
295
92
  if (moduleName.startsWith("./") || moduleName.startsWith("../") || moduleName.includes(".") && !moduleName.includes("/")) {
296
- const absolutePath = q.resolve(moduleName);
93
+ const absolutePath = path.resolve(moduleName);
297
94
  if (ts.sys.fileExists(absolutePath)) {
298
95
  const dedicatedProgram = ts.createProgram([absolutePath], compilerOptions);
299
96
  const sourceFile = dedicatedProgram.getSourceFile(absolutePath);
@@ -302,7 +99,7 @@ function resolveModule(moduleName, compilerOptions) {
302
99
  }
303
100
  }
304
101
  }
305
- const moduleResolver = ts.resolveModuleName(moduleName, q.resolve("./index.ts"), compilerOptions, ts.sys);
102
+ const moduleResolver = ts.resolveModuleName(moduleName, path.resolve("./index.ts"), compilerOptions, ts.sys);
306
103
  if (moduleResolver.resolvedModule) {
307
104
  const { resolvedFileName } = moduleResolver.resolvedModule;
308
105
  const dedicatedProgram = ts.createProgram([resolvedFileName], compilerOptions);
@@ -0,0 +1,4 @@
1
+ import ts from 'typescript';
2
+ import type { ExtractResult } from '../core';
3
+ export declare function findSymbolInJavaScriptFile(sourceFile: ts.SourceFile, checker: ts.TypeChecker, symbolName: string): ts.Symbol | undefined;
4
+ export declare function getSymbolInfo(checker: ts.TypeChecker, symbol: ts.Symbol, member?: string, isStatic?: boolean): ExtractResult;