@soda-gql/common 0.11.9 → 0.11.11
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/{canonical-id-BJahCcrS.mjs → canonical-id-9alor9gv.mjs} +66 -7
- package/dist/canonical-id-9alor9gv.mjs.map +1 -0
- package/dist/{canonical-id-CgMNOZyn.cjs → canonical-id-DHdeYIsT.cjs} +76 -5
- package/dist/canonical-id-DHdeYIsT.cjs.map +1 -0
- package/dist/canonical-id.cjs +5 -3
- package/dist/canonical-id.d.cts +2 -2
- package/dist/canonical-id.d.mts +2 -2
- package/dist/canonical-id.mjs +3 -3
- package/dist/{index-Cm2Zwk9m.d.cts → index-AqkJhrm3.d.mts} +53 -3
- package/dist/index-AqkJhrm3.d.mts.map +1 -0
- package/dist/index-BCu9PNbZ.d.mts +139 -0
- package/dist/index-BCu9PNbZ.d.mts.map +1 -0
- package/dist/{index-D1tzB3W5.d.cts → index-BMa2_rDb.d.mts} +6 -35
- package/dist/index-BMa2_rDb.d.mts.map +1 -0
- package/dist/index-BMl8pzFY.d.cts +139 -0
- package/dist/index-BMl8pzFY.d.cts.map +1 -0
- package/dist/{index-B424kKYS.d.mts → index-CbQyueYV.d.cts} +6 -35
- package/dist/index-CbQyueYV.d.cts.map +1 -0
- package/dist/{index-CPpVc8Id.d.mts → index-DZSebwar.d.cts} +53 -3
- package/dist/index-DZSebwar.d.cts.map +1 -0
- package/dist/index.cjs +9 -7
- package/dist/index.d.cts +4 -4
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +4 -4
- package/dist/portable-B3K3IE7E.cjs +239 -0
- package/dist/portable-B3K3IE7E.cjs.map +1 -0
- package/dist/portable-BFrcBOaX.mjs +196 -0
- package/dist/portable-BFrcBOaX.mjs.map +1 -0
- package/dist/portable.cjs +2 -5
- package/dist/portable.d.cts +2 -2
- package/dist/portable.d.mts +2 -2
- package/dist/portable.mjs +2 -2
- package/dist/utils-Rs7YbafF.cjs +431 -0
- package/dist/utils-Rs7YbafF.cjs.map +1 -0
- package/dist/utils-ZCE_eqCf.mjs +371 -0
- package/dist/utils-ZCE_eqCf.mjs.map +1 -0
- package/dist/utils.cjs +4 -1
- package/dist/utils.d.cts +2 -2
- package/dist/utils.d.mts +2 -2
- package/dist/utils.mjs +2 -2
- package/dist/{zod-C_6JfuYV.cjs → zod-DjI3IUH3.cjs} +2 -2
- package/dist/{zod-C_6JfuYV.cjs.map → zod-DjI3IUH3.cjs.map} +1 -1
- package/dist/zod.cjs +1 -1
- package/package.json +1 -1
- package/dist/canonical-id-BJahCcrS.mjs.map +0 -1
- package/dist/canonical-id-CgMNOZyn.cjs.map +0 -1
- package/dist/index-B424kKYS.d.mts.map +0 -1
- package/dist/index-CPpVc8Id.d.mts.map +0 -1
- package/dist/index-Cm2Zwk9m.d.cts.map +0 -1
- package/dist/index-D1tzB3W5.d.cts.map +0 -1
- package/dist/index-Dv8spPt0.d.mts +0 -61
- package/dist/index-Dv8spPt0.d.mts.map +0 -1
- package/dist/index-LaXfl_e_.d.cts +0 -61
- package/dist/index-LaXfl_e_.d.cts.map +0 -1
- package/dist/portable-BT3ahkQN.mjs +0 -391
- package/dist/portable-BT3ahkQN.mjs.map +0 -1
- package/dist/portable-cJqkfeHw.cjs +0 -451
- package/dist/portable-cJqkfeHw.cjs.map +0 -1
- package/dist/utils-CsTwS1dw.cjs +0 -148
- package/dist/utils-CsTwS1dw.cjs.map +0 -1
- package/dist/utils-DLEgAn7q.mjs +0 -106
- package/dist/utils-DLEgAn7q.mjs.map +0 -1
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
import { dirname, join, normalize, resolve } from "node:path";
|
|
2
|
+
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
3
|
+
import { err, ok } from "neverthrow";
|
|
4
|
+
|
|
5
|
+
//#region packages/common/src/utils/path.ts
|
|
6
|
+
/**
|
|
7
|
+
* File extensions to try when resolving module specifiers.
|
|
8
|
+
* Ordered to match TypeScript's module resolution order.
|
|
9
|
+
* @see https://www.typescriptlang.org/docs/handbook/module-resolution.html
|
|
10
|
+
*/
|
|
11
|
+
const MODULE_EXTENSION_CANDIDATES = [
|
|
12
|
+
".ts",
|
|
13
|
+
".tsx",
|
|
14
|
+
".mts",
|
|
15
|
+
".cts",
|
|
16
|
+
".js",
|
|
17
|
+
".mjs",
|
|
18
|
+
".cjs",
|
|
19
|
+
".jsx"
|
|
20
|
+
];
|
|
21
|
+
/**
|
|
22
|
+
* Mapping from JS extensions to their corresponding TS extensions.
|
|
23
|
+
* Used for ESM-style imports where .js is written but .ts is the actual source.
|
|
24
|
+
*/
|
|
25
|
+
const JS_TO_TS_EXTENSION_MAP = {
|
|
26
|
+
".js": [".ts", ".tsx"],
|
|
27
|
+
".mjs": [".mts"],
|
|
28
|
+
".cjs": [".cts"],
|
|
29
|
+
".jsx": [".tsx"]
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Parse a JS extension from a specifier for ESM-style import resolution.
|
|
33
|
+
* Returns the base path (without extension), the JS extension, and corresponding TS extensions.
|
|
34
|
+
*
|
|
35
|
+
* @param specifier - The import specifier to parse
|
|
36
|
+
* @returns Object with base, jsExtension, and tsExtensions, or null if no JS extension found
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* parseJsExtension("./foo.js") // { base: "./foo", jsExtension: ".js", tsExtensions: [".ts", ".tsx"] }
|
|
40
|
+
* parseJsExtension("./foo.mjs") // { base: "./foo", jsExtension: ".mjs", tsExtensions: [".mts"] }
|
|
41
|
+
* parseJsExtension("./foo") // null
|
|
42
|
+
* parseJsExtension("./foo.ts") // null
|
|
43
|
+
*/
|
|
44
|
+
const parseJsExtension = (specifier) => {
|
|
45
|
+
for (const [ext, tsExts] of Object.entries(JS_TO_TS_EXTENSION_MAP)) {
|
|
46
|
+
if (specifier.endsWith(ext)) {
|
|
47
|
+
return {
|
|
48
|
+
base: specifier.slice(0, -ext.length),
|
|
49
|
+
jsExtension: ext,
|
|
50
|
+
tsExtensions: tsExts
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Normalize path to use forward slashes (cross-platform).
|
|
58
|
+
* Ensures consistent path handling across platforms.
|
|
59
|
+
*/
|
|
60
|
+
const normalizePath = (value) => normalize(value).replace(/\\/g, "/");
|
|
61
|
+
/**
|
|
62
|
+
* Resolve a relative import specifier to an absolute file path.
|
|
63
|
+
* Tries the specifier as-is, with extensions, and as a directory with index files.
|
|
64
|
+
*
|
|
65
|
+
* @param from - Absolute path to the importing file
|
|
66
|
+
* @param specifier - Relative module specifier (must start with '.')
|
|
67
|
+
* @returns Absolute POSIX path to the resolved file, or null if not found
|
|
68
|
+
*/
|
|
69
|
+
const resolveRelativeImportWithExistenceCheck = ({ filePath, specifier }) => {
|
|
70
|
+
const jsExtInfo = parseJsExtension(specifier);
|
|
71
|
+
if (jsExtInfo) {
|
|
72
|
+
const baseWithoutExt = resolve(dirname(filePath), jsExtInfo.base);
|
|
73
|
+
for (const ext of jsExtInfo.tsExtensions) {
|
|
74
|
+
const candidate = `${baseWithoutExt}${ext}`;
|
|
75
|
+
if (existsSync(candidate)) {
|
|
76
|
+
return normalizePath(candidate);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const jsCandidate = `${baseWithoutExt}${jsExtInfo.jsExtension}`;
|
|
80
|
+
if (existsSync(jsCandidate)) {
|
|
81
|
+
try {
|
|
82
|
+
const stat = statSync(jsCandidate);
|
|
83
|
+
if (stat.isFile()) {
|
|
84
|
+
return normalizePath(jsCandidate);
|
|
85
|
+
}
|
|
86
|
+
} catch {}
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
const base = resolve(dirname(filePath), specifier);
|
|
91
|
+
for (const ext of MODULE_EXTENSION_CANDIDATES) {
|
|
92
|
+
const candidate = `${base}${ext}`;
|
|
93
|
+
if (existsSync(candidate)) {
|
|
94
|
+
return normalizePath(candidate);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
for (const ext of MODULE_EXTENSION_CANDIDATES) {
|
|
98
|
+
const candidate = join(base, `index${ext}`);
|
|
99
|
+
if (existsSync(candidate)) {
|
|
100
|
+
return normalizePath(candidate);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (existsSync(base)) {
|
|
104
|
+
try {
|
|
105
|
+
const stat = statSync(base);
|
|
106
|
+
if (stat.isFile()) {
|
|
107
|
+
return normalizePath(base);
|
|
108
|
+
}
|
|
109
|
+
} catch {}
|
|
110
|
+
}
|
|
111
|
+
return null;
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Resolve a relative import specifier to an absolute file path.
|
|
115
|
+
* Tries the specifier as-is, with extensions, and as a directory with index files.
|
|
116
|
+
*
|
|
117
|
+
* @param from - Absolute path to the importing file
|
|
118
|
+
* @param specifier - Relative module specifier (must start with '.')
|
|
119
|
+
* @returns Absolute POSIX path to the resolved file, or null if not found
|
|
120
|
+
*/
|
|
121
|
+
const resolveRelativeImportWithReferences = ({ filePath, specifier, references }) => {
|
|
122
|
+
const jsExtInfo = parseJsExtension(specifier);
|
|
123
|
+
if (jsExtInfo) {
|
|
124
|
+
const baseWithoutExt = resolve(dirname(filePath), jsExtInfo.base);
|
|
125
|
+
for (const ext of jsExtInfo.tsExtensions) {
|
|
126
|
+
const candidate = `${baseWithoutExt}${ext}`;
|
|
127
|
+
if (references.has(candidate)) {
|
|
128
|
+
return normalizePath(candidate);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const jsCandidate = `${baseWithoutExt}${jsExtInfo.jsExtension}`;
|
|
132
|
+
if (references.has(jsCandidate)) {
|
|
133
|
+
return normalizePath(jsCandidate);
|
|
134
|
+
}
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
const base = resolve(dirname(filePath), specifier);
|
|
138
|
+
if (references.has(base)) {
|
|
139
|
+
return normalizePath(base);
|
|
140
|
+
}
|
|
141
|
+
for (const ext of MODULE_EXTENSION_CANDIDATES) {
|
|
142
|
+
const candidate = `${base}${ext}`;
|
|
143
|
+
if (references.has(candidate)) {
|
|
144
|
+
return normalizePath(candidate);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
for (const ext of MODULE_EXTENSION_CANDIDATES) {
|
|
148
|
+
const candidate = join(base, `index${ext}`);
|
|
149
|
+
if (references.has(candidate)) {
|
|
150
|
+
return normalizePath(candidate);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return null;
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Check if a module specifier is relative (starts with '.' or '..')
|
|
157
|
+
*/
|
|
158
|
+
const isRelativeSpecifier = (specifier) => specifier.startsWith("./") || specifier.startsWith("../");
|
|
159
|
+
/**
|
|
160
|
+
* Check if a module specifier is external (package name, not relative)
|
|
161
|
+
*/
|
|
162
|
+
const isExternalSpecifier = (specifier) => !isRelativeSpecifier(specifier);
|
|
163
|
+
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region packages/common/src/utils/alias-resolver.ts
|
|
166
|
+
/**
|
|
167
|
+
* Match a specifier against a tsconfig path pattern.
|
|
168
|
+
* Returns the captured wildcard portion or null if no match.
|
|
169
|
+
*
|
|
170
|
+
* Pattern rules:
|
|
171
|
+
* - Exact match: "@/utils" matches "@/utils" exactly, captures ""
|
|
172
|
+
* - Wildcard: "@/*" matches "@/foo", captures "foo"
|
|
173
|
+
* - Wildcard with suffix: "*.js" matches "foo.js", captures "foo"
|
|
174
|
+
*/
|
|
175
|
+
const matchPattern = (specifier, pattern) => {
|
|
176
|
+
const starIndex = pattern.indexOf("*");
|
|
177
|
+
if (starIndex === -1) {
|
|
178
|
+
return specifier === pattern ? "" : null;
|
|
179
|
+
}
|
|
180
|
+
const prefix = pattern.slice(0, starIndex);
|
|
181
|
+
const suffix = pattern.slice(starIndex + 1);
|
|
182
|
+
if (!specifier.startsWith(prefix)) {
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
if (suffix && !specifier.endsWith(suffix)) {
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
const captured = specifier.slice(prefix.length, suffix ? specifier.length - suffix.length : undefined);
|
|
189
|
+
return captured;
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* Apply a captured wildcard to a target path.
|
|
193
|
+
*/
|
|
194
|
+
const applyCapture = (target, captured) => {
|
|
195
|
+
const starIndex = target.indexOf("*");
|
|
196
|
+
if (starIndex === -1) {
|
|
197
|
+
return target;
|
|
198
|
+
}
|
|
199
|
+
return target.slice(0, starIndex) + captured + target.slice(starIndex + 1);
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* Try to resolve a path to an actual file, applying extension resolution.
|
|
203
|
+
* Handles ESM-style imports with JS extensions.
|
|
204
|
+
*/
|
|
205
|
+
const resolveToFile = (basePath) => {
|
|
206
|
+
const jsExtInfo = parseJsExtension(basePath);
|
|
207
|
+
if (jsExtInfo) {
|
|
208
|
+
const baseWithoutExt = basePath.slice(0, -jsExtInfo.jsExtension.length);
|
|
209
|
+
for (const ext of jsExtInfo.tsExtensions) {
|
|
210
|
+
const candidate = `${baseWithoutExt}${ext}`;
|
|
211
|
+
if (existsSync(candidate)) {
|
|
212
|
+
try {
|
|
213
|
+
const stat = statSync(candidate);
|
|
214
|
+
if (stat.isFile()) {
|
|
215
|
+
return normalizePath(candidate);
|
|
216
|
+
}
|
|
217
|
+
} catch {}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if (existsSync(basePath)) {
|
|
221
|
+
try {
|
|
222
|
+
const stat = statSync(basePath);
|
|
223
|
+
if (stat.isFile()) {
|
|
224
|
+
return normalizePath(basePath);
|
|
225
|
+
}
|
|
226
|
+
} catch {}
|
|
227
|
+
}
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
if (existsSync(basePath)) {
|
|
231
|
+
try {
|
|
232
|
+
const stat = statSync(basePath);
|
|
233
|
+
if (stat.isFile()) {
|
|
234
|
+
return normalizePath(basePath);
|
|
235
|
+
}
|
|
236
|
+
} catch {}
|
|
237
|
+
}
|
|
238
|
+
for (const ext of MODULE_EXTENSION_CANDIDATES) {
|
|
239
|
+
const candidate = `${basePath}${ext}`;
|
|
240
|
+
if (existsSync(candidate)) {
|
|
241
|
+
try {
|
|
242
|
+
const stat = statSync(candidate);
|
|
243
|
+
if (stat.isFile()) {
|
|
244
|
+
return normalizePath(candidate);
|
|
245
|
+
}
|
|
246
|
+
} catch {}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
for (const ext of MODULE_EXTENSION_CANDIDATES) {
|
|
250
|
+
const candidate = join(basePath, `index${ext}`);
|
|
251
|
+
if (existsSync(candidate)) {
|
|
252
|
+
try {
|
|
253
|
+
const stat = statSync(candidate);
|
|
254
|
+
if (stat.isFile()) {
|
|
255
|
+
return normalizePath(candidate);
|
|
256
|
+
}
|
|
257
|
+
} catch {}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return null;
|
|
261
|
+
};
|
|
262
|
+
/**
|
|
263
|
+
* Create an alias resolver from tsconfig paths configuration.
|
|
264
|
+
*
|
|
265
|
+
* Resolution behavior:
|
|
266
|
+
* 1. Try each pattern in order (first match wins per TS spec)
|
|
267
|
+
* 2. For each matched pattern, try all target paths in order
|
|
268
|
+
* 3. For each target, apply extension resolution
|
|
269
|
+
* 4. Return first found file, or null if none found
|
|
270
|
+
*/
|
|
271
|
+
const createAliasResolver = (config) => {
|
|
272
|
+
const { paths } = config;
|
|
273
|
+
const patterns = Object.keys(paths);
|
|
274
|
+
return { resolve: (specifier) => {
|
|
275
|
+
for (const pattern of patterns) {
|
|
276
|
+
const captured = matchPattern(specifier, pattern);
|
|
277
|
+
if (captured === null) {
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
const targets = paths[pattern];
|
|
281
|
+
if (!targets) {
|
|
282
|
+
continue;
|
|
283
|
+
}
|
|
284
|
+
for (const target of targets) {
|
|
285
|
+
const resolvedTarget = applyCapture(target, captured);
|
|
286
|
+
const result = resolveToFile(resolvedTarget);
|
|
287
|
+
if (result) {
|
|
288
|
+
return result;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
return null;
|
|
293
|
+
} };
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
//#endregion
|
|
297
|
+
//#region packages/common/src/utils/cached-fn.ts
|
|
298
|
+
const cachedFn = (fn) => {
|
|
299
|
+
let cached = null;
|
|
300
|
+
const ensure = () => (cached ??= { value: fn() }).value;
|
|
301
|
+
ensure.clear = () => {
|
|
302
|
+
cached = null;
|
|
303
|
+
};
|
|
304
|
+
return ensure;
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
//#endregion
|
|
308
|
+
//#region packages/common/src/utils/tsconfig.ts
|
|
309
|
+
/**
|
|
310
|
+
* Strip JSON comments and trailing commas for parsing.
|
|
311
|
+
* Handles both line comments (//) and block comments.
|
|
312
|
+
*/
|
|
313
|
+
const stripJsonComments = (json) => {
|
|
314
|
+
return json.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/.*/g, "").replace(/,(\s*[}\]])/g, "$1");
|
|
315
|
+
};
|
|
316
|
+
/**
|
|
317
|
+
* Read and parse tsconfig.json to extract paths configuration.
|
|
318
|
+
* Currently does not support `extends` - reads only the specified file.
|
|
319
|
+
*
|
|
320
|
+
* @param tsconfigPath - Absolute path to tsconfig.json
|
|
321
|
+
* @returns Parsed paths configuration or null if no paths defined
|
|
322
|
+
*/
|
|
323
|
+
const readTsconfigPaths = (tsconfigPath) => {
|
|
324
|
+
let content;
|
|
325
|
+
try {
|
|
326
|
+
content = readFileSync(tsconfigPath, "utf-8");
|
|
327
|
+
} catch (error) {
|
|
328
|
+
return err({
|
|
329
|
+
code: "TSCONFIG_READ_FAILED",
|
|
330
|
+
message: `Failed to read tsconfig.json: ${error instanceof Error ? error.message : String(error)}`
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
let parsed;
|
|
334
|
+
try {
|
|
335
|
+
const cleaned = stripJsonComments(content);
|
|
336
|
+
parsed = JSON.parse(cleaned);
|
|
337
|
+
} catch (error) {
|
|
338
|
+
return err({
|
|
339
|
+
code: "TSCONFIG_PARSE_FAILED",
|
|
340
|
+
message: `Failed to parse tsconfig.json: ${error instanceof Error ? error.message : String(error)}`
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
if (typeof parsed !== "object" || parsed === null) {
|
|
344
|
+
return err({
|
|
345
|
+
code: "TSCONFIG_INVALID",
|
|
346
|
+
message: "tsconfig.json must be an object"
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
const config = parsed;
|
|
350
|
+
const compilerOptions = config.compilerOptions;
|
|
351
|
+
if (!compilerOptions?.paths) {
|
|
352
|
+
return ok(null);
|
|
353
|
+
}
|
|
354
|
+
const tsconfigDir = dirname(tsconfigPath);
|
|
355
|
+
const baseUrl = typeof compilerOptions.baseUrl === "string" ? resolve(tsconfigDir, compilerOptions.baseUrl) : tsconfigDir;
|
|
356
|
+
const rawPaths = compilerOptions.paths;
|
|
357
|
+
const resolvedPaths = {};
|
|
358
|
+
for (const [pattern, targets] of Object.entries(rawPaths)) {
|
|
359
|
+
if (Array.isArray(targets)) {
|
|
360
|
+
resolvedPaths[pattern] = targets.map((target) => resolve(baseUrl, target));
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
return ok({
|
|
364
|
+
baseUrl,
|
|
365
|
+
paths: resolvedPaths
|
|
366
|
+
});
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
//#endregion
|
|
370
|
+
export { isExternalSpecifier as a, parseJsExtension as c, MODULE_EXTENSION_CANDIDATES as i, resolveRelativeImportWithExistenceCheck as l, cachedFn as n, isRelativeSpecifier as o, createAliasResolver as r, normalizePath as s, readTsconfigPaths as t, resolveRelativeImportWithReferences as u };
|
|
371
|
+
//# sourceMappingURL=utils-ZCE_eqCf.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils-ZCE_eqCf.mjs","names":["JS_TO_TS_EXTENSION_MAP: Readonly<Record<string, readonly string[]>>","cached: { value: T } | null","content: string","parsed: unknown","resolvedPaths: Record<string, readonly string[]>"],"sources":["../src/utils/path.ts","../src/utils/alias-resolver.ts","../src/utils/cached-fn.ts","../src/utils/tsconfig.ts"],"sourcesContent":["import { existsSync, statSync } from \"node:fs\";\nimport { dirname, join, normalize, resolve } from \"node:path\";\n\n/**\n * File extensions to try when resolving module specifiers.\n * Ordered to match TypeScript's module resolution order.\n * @see https://www.typescriptlang.org/docs/handbook/module-resolution.html\n */\nexport const MODULE_EXTENSION_CANDIDATES = [\".ts\", \".tsx\", \".mts\", \".cts\", \".js\", \".mjs\", \".cjs\", \".jsx\"] as const;\n\n/**\n * Mapping from JS extensions to their corresponding TS extensions.\n * Used for ESM-style imports where .js is written but .ts is the actual source.\n */\nconst JS_TO_TS_EXTENSION_MAP: Readonly<Record<string, readonly string[]>> = {\n \".js\": [\".ts\", \".tsx\"],\n \".mjs\": [\".mts\"],\n \".cjs\": [\".cts\"],\n \".jsx\": [\".tsx\"],\n};\n\n/**\n * Result of parsing a JS extension from a specifier.\n */\nexport type JsExtensionInfo = {\n /** The specifier without the JS extension */\n readonly base: string;\n /** The JS extension found (e.g., \".js\", \".mjs\") */\n readonly jsExtension: string;\n /** The corresponding TS extensions to try (e.g., [\".ts\", \".tsx\"] for \".js\") */\n readonly tsExtensions: readonly string[];\n};\n\n/**\n * Parse a JS extension from a specifier for ESM-style import resolution.\n * Returns the base path (without extension), the JS extension, and corresponding TS extensions.\n *\n * @param specifier - The import specifier to parse\n * @returns Object with base, jsExtension, and tsExtensions, or null if no JS extension found\n *\n * @example\n * parseJsExtension(\"./foo.js\") // { base: \"./foo\", jsExtension: \".js\", tsExtensions: [\".ts\", \".tsx\"] }\n * parseJsExtension(\"./foo.mjs\") // { base: \"./foo\", jsExtension: \".mjs\", tsExtensions: [\".mts\"] }\n * parseJsExtension(\"./foo\") // null\n * parseJsExtension(\"./foo.ts\") // null\n */\nexport const parseJsExtension = (specifier: string): JsExtensionInfo | null => {\n for (const [ext, tsExts] of Object.entries(JS_TO_TS_EXTENSION_MAP)) {\n if (specifier.endsWith(ext)) {\n return {\n base: specifier.slice(0, -ext.length),\n jsExtension: ext,\n tsExtensions: tsExts,\n };\n }\n }\n return null;\n};\n\n/**\n * Normalize path to use forward slashes (cross-platform).\n * Ensures consistent path handling across platforms.\n */\nexport const normalizePath = (value: string): string => normalize(value).replace(/\\\\/g, \"/\");\n\n/**\n * Resolve a relative import specifier to an absolute file path.\n * Tries the specifier as-is, with extensions, and as a directory with index files.\n *\n * @param from - Absolute path to the importing file\n * @param specifier - Relative module specifier (must start with '.')\n * @returns Absolute POSIX path to the resolved file, or null if not found\n */\nexport const resolveRelativeImportWithExistenceCheck = ({\n filePath,\n specifier,\n}: {\n filePath: string;\n specifier: string;\n}): string | null => {\n // Handle ESM-style imports with JS extensions (e.g., \"./foo.js\" -> \"./foo.ts\")\n const jsExtInfo = parseJsExtension(specifier);\n if (jsExtInfo) {\n const baseWithoutExt = resolve(dirname(filePath), jsExtInfo.base);\n\n // Try corresponding TS extensions first\n for (const ext of jsExtInfo.tsExtensions) {\n const candidate = `${baseWithoutExt}${ext}`;\n if (existsSync(candidate)) {\n return normalizePath(candidate);\n }\n }\n\n // Fall back to actual JS file if it exists\n const jsCandidate = `${baseWithoutExt}${jsExtInfo.jsExtension}`;\n if (existsSync(jsCandidate)) {\n try {\n const stat = statSync(jsCandidate);\n if (stat.isFile()) {\n return normalizePath(jsCandidate);\n }\n } catch {\n // Ignore stat errors\n }\n }\n\n return null;\n }\n\n const base = resolve(dirname(filePath), specifier);\n\n // Try with extensions first (most common case)\n // This handles cases like \"./constants\" resolving to \"./constants.ts\"\n // even when a \"./constants\" directory exists\n for (const ext of MODULE_EXTENSION_CANDIDATES) {\n const candidate = `${base}${ext}`;\n if (existsSync(candidate)) {\n return normalizePath(candidate);\n }\n }\n\n // Try as directory with index files\n for (const ext of MODULE_EXTENSION_CANDIDATES) {\n const candidate = join(base, `index${ext}`);\n if (existsSync(candidate)) {\n return normalizePath(candidate);\n }\n }\n\n // Try exact path last (only if it's a file, not directory)\n if (existsSync(base)) {\n try {\n const stat = statSync(base);\n if (stat.isFile()) {\n return normalizePath(base);\n }\n } catch {\n // Ignore stat errors\n }\n }\n\n return null;\n};\n\n/**\n * Resolve a relative import specifier to an absolute file path.\n * Tries the specifier as-is, with extensions, and as a directory with index files.\n *\n * @param from - Absolute path to the importing file\n * @param specifier - Relative module specifier (must start with '.')\n * @returns Absolute POSIX path to the resolved file, or null if not found\n */\nexport const resolveRelativeImportWithReferences = <_>({\n filePath,\n specifier,\n references,\n}: {\n filePath: string;\n specifier: string;\n references: Map<string, _> | Set<string>;\n}): string | null => {\n // Handle ESM-style imports with JS extensions (e.g., \"./foo.js\" -> \"./foo.ts\")\n const jsExtInfo = parseJsExtension(specifier);\n if (jsExtInfo) {\n const baseWithoutExt = resolve(dirname(filePath), jsExtInfo.base);\n\n // Try corresponding TS extensions first\n for (const ext of jsExtInfo.tsExtensions) {\n const candidate = `${baseWithoutExt}${ext}`;\n if (references.has(candidate)) {\n return normalizePath(candidate);\n }\n }\n\n // Fall back to actual JS file if it exists in references\n const jsCandidate = `${baseWithoutExt}${jsExtInfo.jsExtension}`;\n if (references.has(jsCandidate)) {\n return normalizePath(jsCandidate);\n }\n\n return null;\n }\n\n const base = resolve(dirname(filePath), specifier);\n\n // Try exact path first\n if (references.has(base)) {\n return normalizePath(base);\n }\n\n // Try with extensions\n for (const ext of MODULE_EXTENSION_CANDIDATES) {\n const candidate = `${base}${ext}`;\n if (references.has(candidate)) {\n return normalizePath(candidate);\n }\n }\n\n // Try as directory with index files\n for (const ext of MODULE_EXTENSION_CANDIDATES) {\n const candidate = join(base, `index${ext}`);\n if (references.has(candidate)) {\n return normalizePath(candidate);\n }\n }\n\n return null;\n};\n\n/**\n * Check if a module specifier is relative (starts with '.' or '..')\n */\nexport const isRelativeSpecifier = (specifier: string): boolean => specifier.startsWith(\"./\") || specifier.startsWith(\"../\");\n\n/**\n * Check if a module specifier is external (package name, not relative)\n */\nexport const isExternalSpecifier = (specifier: string): boolean => !isRelativeSpecifier(specifier);\n","import { existsSync, statSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { MODULE_EXTENSION_CANDIDATES, normalizePath, parseJsExtension } from \"./path\";\nimport type { TsconfigPathsConfig } from \"./tsconfig\";\n\n/**\n * Alias resolver interface for resolving path aliases to file paths.\n */\nexport type AliasResolver = {\n /**\n * Resolve an alias specifier to an absolute file path.\n * Returns null if the specifier doesn't match any alias pattern\n * or if the resolved file doesn't exist.\n */\n readonly resolve: (specifier: string) => string | null;\n};\n\n/**\n * Match a specifier against a tsconfig path pattern.\n * Returns the captured wildcard portion or null if no match.\n *\n * Pattern rules:\n * - Exact match: \"@/utils\" matches \"@/utils\" exactly, captures \"\"\n * - Wildcard: \"@/*\" matches \"@/foo\", captures \"foo\"\n * - Wildcard with suffix: \"*.js\" matches \"foo.js\", captures \"foo\"\n */\nconst matchPattern = (specifier: string, pattern: string): string | null => {\n const starIndex = pattern.indexOf(\"*\");\n\n if (starIndex === -1) {\n // Exact match - no wildcard\n return specifier === pattern ? \"\" : null;\n }\n\n const prefix = pattern.slice(0, starIndex);\n const suffix = pattern.slice(starIndex + 1);\n\n if (!specifier.startsWith(prefix)) {\n return null;\n }\n\n if (suffix && !specifier.endsWith(suffix)) {\n return null;\n }\n\n // Extract the wildcard capture\n const captured = specifier.slice(prefix.length, suffix ? specifier.length - suffix.length : undefined);\n\n return captured;\n};\n\n/**\n * Apply a captured wildcard to a target path.\n */\nconst applyCapture = (target: string, captured: string): string => {\n const starIndex = target.indexOf(\"*\");\n if (starIndex === -1) {\n return target;\n }\n return target.slice(0, starIndex) + captured + target.slice(starIndex + 1);\n};\n\n/**\n * Try to resolve a path to an actual file, applying extension resolution.\n * Handles ESM-style imports with JS extensions.\n */\nconst resolveToFile = (basePath: string): string | null => {\n // Handle ESM-style JS extension imports\n const jsExtInfo = parseJsExtension(basePath);\n if (jsExtInfo) {\n const baseWithoutExt = basePath.slice(0, -jsExtInfo.jsExtension.length);\n\n // Try corresponding TS extensions first\n for (const ext of jsExtInfo.tsExtensions) {\n const candidate = `${baseWithoutExt}${ext}`;\n if (existsSync(candidate)) {\n try {\n const stat = statSync(candidate);\n if (stat.isFile()) {\n return normalizePath(candidate);\n }\n } catch {\n // Ignore stat errors\n }\n }\n }\n\n // Fall back to actual JS file\n if (existsSync(basePath)) {\n try {\n const stat = statSync(basePath);\n if (stat.isFile()) {\n return normalizePath(basePath);\n }\n } catch {\n // Ignore stat errors\n }\n }\n\n return null;\n }\n\n // Try exact path first (for paths with explicit extension)\n if (existsSync(basePath)) {\n try {\n const stat = statSync(basePath);\n if (stat.isFile()) {\n return normalizePath(basePath);\n }\n } catch {\n // Ignore stat errors\n }\n }\n\n // Try with extensions\n for (const ext of MODULE_EXTENSION_CANDIDATES) {\n const candidate = `${basePath}${ext}`;\n if (existsSync(candidate)) {\n try {\n const stat = statSync(candidate);\n if (stat.isFile()) {\n return normalizePath(candidate);\n }\n } catch {\n // Ignore stat errors\n }\n }\n }\n\n // Try as directory with index files\n for (const ext of MODULE_EXTENSION_CANDIDATES) {\n const candidate = join(basePath, `index${ext}`);\n if (existsSync(candidate)) {\n try {\n const stat = statSync(candidate);\n if (stat.isFile()) {\n return normalizePath(candidate);\n }\n } catch {\n // Ignore stat errors\n }\n }\n }\n\n return null;\n};\n\n/**\n * Create an alias resolver from tsconfig paths configuration.\n *\n * Resolution behavior:\n * 1. Try each pattern in order (first match wins per TS spec)\n * 2. For each matched pattern, try all target paths in order\n * 3. For each target, apply extension resolution\n * 4. Return first found file, or null if none found\n */\nexport const createAliasResolver = (config: TsconfigPathsConfig): AliasResolver => {\n const { paths } = config;\n const patterns = Object.keys(paths);\n\n return {\n resolve: (specifier: string): string | null => {\n // Try each pattern in order (first match wins per TS spec)\n for (const pattern of patterns) {\n const captured = matchPattern(specifier, pattern);\n if (captured === null) {\n continue;\n }\n\n const targets = paths[pattern];\n if (!targets) {\n continue;\n }\n\n // Try each target path in order\n for (const target of targets) {\n const resolvedTarget = applyCapture(target, captured);\n const result = resolveToFile(resolvedTarget);\n if (result) {\n return result;\n }\n }\n }\n\n return null;\n },\n };\n};\n","export const cachedFn = <T>(fn: () => T) => {\n let cached: { value: T } | null = null;\n\n const ensure = () => (cached ??= { value: fn() }).value;\n ensure.clear = () => {\n cached = null;\n };\n\n return ensure;\n};\n","import { readFileSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { err, ok, type Result } from \"neverthrow\";\n\n/**\n * Parsed tsconfig.json paths configuration.\n * All paths are resolved to absolute paths.\n */\nexport type TsconfigPathsConfig = {\n /** Absolute base URL for path resolution */\n readonly baseUrl: string;\n /** Path mappings with absolute paths */\n readonly paths: Readonly<Record<string, readonly string[]>>;\n};\n\n/**\n * Error types for tsconfig reading.\n */\nexport type TsconfigReadError = {\n readonly code: \"TSCONFIG_READ_FAILED\" | \"TSCONFIG_PARSE_FAILED\" | \"TSCONFIG_INVALID\";\n readonly message: string;\n};\n\n/**\n * Strip JSON comments and trailing commas for parsing.\n * Handles both line comments (//) and block comments.\n */\nconst stripJsonComments = (json: string): string => {\n return (\n json\n // Remove block comments\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, \"\")\n // Remove line comments\n .replace(/\\/\\/.*/g, \"\")\n // Remove trailing commas before } or ]\n .replace(/,(\\s*[}\\]])/g, \"$1\")\n );\n};\n\n/**\n * Read and parse tsconfig.json to extract paths configuration.\n * Currently does not support `extends` - reads only the specified file.\n *\n * @param tsconfigPath - Absolute path to tsconfig.json\n * @returns Parsed paths configuration or null if no paths defined\n */\nexport const readTsconfigPaths = (tsconfigPath: string): Result<TsconfigPathsConfig | null, TsconfigReadError> => {\n // Read file\n let content: string;\n try {\n content = readFileSync(tsconfigPath, \"utf-8\");\n } catch (error) {\n return err({\n code: \"TSCONFIG_READ_FAILED\",\n message: `Failed to read tsconfig.json: ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n\n // Parse JSON (with comment stripping)\n let parsed: unknown;\n try {\n const cleaned = stripJsonComments(content);\n parsed = JSON.parse(cleaned);\n } catch (error) {\n return err({\n code: \"TSCONFIG_PARSE_FAILED\",\n message: `Failed to parse tsconfig.json: ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n\n // Validate structure\n if (typeof parsed !== \"object\" || parsed === null) {\n return err({\n code: \"TSCONFIG_INVALID\",\n message: \"tsconfig.json must be an object\",\n });\n }\n\n const config = parsed as Record<string, unknown>;\n const compilerOptions = config.compilerOptions as Record<string, unknown> | undefined;\n\n // Return null if no paths defined\n if (!compilerOptions?.paths) {\n return ok(null);\n }\n\n // Resolve baseUrl\n const tsconfigDir = dirname(tsconfigPath);\n const baseUrl = typeof compilerOptions.baseUrl === \"string\" ? resolve(tsconfigDir, compilerOptions.baseUrl) : tsconfigDir;\n\n // Resolve paths to absolute paths\n const rawPaths = compilerOptions.paths as Record<string, string[]>;\n const resolvedPaths: Record<string, readonly string[]> = {};\n\n for (const [pattern, targets] of Object.entries(rawPaths)) {\n if (Array.isArray(targets)) {\n resolvedPaths[pattern] = targets.map((target) => resolve(baseUrl, target));\n }\n }\n\n return ok({\n baseUrl,\n paths: resolvedPaths,\n });\n};\n"],"mappings":";;;;;;;;;;AAQA,MAAa,8BAA8B;CAAC;CAAO;CAAQ;CAAQ;CAAQ;CAAO;CAAQ;CAAQ;CAAO;;;;;AAMzG,MAAMA,yBAAsE;CAC1E,OAAO,CAAC,OAAO,OAAO;CACtB,QAAQ,CAAC,OAAO;CAChB,QAAQ,CAAC,OAAO;CAChB,QAAQ,CAAC,OAAO;CACjB;;;;;;;;;;;;;;AA2BD,MAAa,oBAAoB,cAA8C;AAC7E,MAAK,MAAM,CAAC,KAAK,WAAW,OAAO,QAAQ,uBAA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AU,OAAO,MAAM;GAClG,CAAC;;AAIJ,KAAI,OAAO,WAAW,YAAY,WAAW,MAAM;AACjD,SAAO,IAAI;GACT,MAAM;GACN,SAAS;GACV,CAAC;;CAGJ,MAAM,SAAS;CACf,MAAM,kBAAkB,OAAO;AAG/B,KAAI,CAAC,iBAAiB,OAAO;AAC3B,SAAO,GAAG,KAAK;;CAIjB,MAAM,cAAc,QAAQ,aAAa;CACzC,MAAM,UAAU,OAAO,gBAAgB,YAAY,WAAW,QAAQ,aAAa,gBAAgB,QAAQ,GAAG;CAG9G,MAAM,WAAW,gBAAgB;CACjC,MAAMC,gBAAmD,EAAE;AAE3D,MAAK,MAAM,CAAC,SAAS,YAAY,OAAO,QAAQ,SAAS,EAAE;AACzD,MAAI,MAAM,QAAQ,QAAQ,EAAE;AAC1B,iBAAc,WAAW,QAAQ,KAAK,WAAW,QAAQ,SAAS,OAAO,CAAC;;;AAI9E,QAAO,GAAG;EACR;EACA,OAAO;EACR,CAAC"}
|
package/dist/utils.cjs
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
const require_utils = require('./utils-
|
|
1
|
+
const require_utils = require('./utils-Rs7YbafF.cjs');
|
|
2
2
|
|
|
3
3
|
exports.MODULE_EXTENSION_CANDIDATES = require_utils.MODULE_EXTENSION_CANDIDATES;
|
|
4
4
|
exports.cachedFn = require_utils.cachedFn;
|
|
5
|
+
exports.createAliasResolver = require_utils.createAliasResolver;
|
|
5
6
|
exports.isExternalSpecifier = require_utils.isExternalSpecifier;
|
|
6
7
|
exports.isRelativeSpecifier = require_utils.isRelativeSpecifier;
|
|
7
8
|
exports.normalizePath = require_utils.normalizePath;
|
|
9
|
+
exports.parseJsExtension = require_utils.parseJsExtension;
|
|
10
|
+
exports.readTsconfigPaths = require_utils.readTsconfigPaths;
|
|
8
11
|
exports.resolveRelativeImportWithExistenceCheck = require_utils.resolveRelativeImportWithExistenceCheck;
|
|
9
12
|
exports.resolveRelativeImportWithReferences = require_utils.resolveRelativeImportWithReferences;
|
package/dist/utils.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { MODULE_EXTENSION_CANDIDATES, cachedFn, isExternalSpecifier, isRelativeSpecifier, normalizePath, resolveRelativeImportWithExistenceCheck, resolveRelativeImportWithReferences };
|
|
1
|
+
import { a as normalizePath, c as resolveRelativeImportWithReferences, d as createAliasResolver, f as TsconfigPathsConfig, i as isRelativeSpecifier, l as cachedFn, m as readTsconfigPaths, n as MODULE_EXTENSION_CANDIDATES, o as parseJsExtension, p as TsconfigReadError, r as isExternalSpecifier, s as resolveRelativeImportWithExistenceCheck, t as JsExtensionInfo, u as AliasResolver } from "./index-BMl8pzFY.cjs";
|
|
2
|
+
export { AliasResolver, JsExtensionInfo, MODULE_EXTENSION_CANDIDATES, TsconfigPathsConfig, TsconfigReadError, cachedFn, createAliasResolver, isExternalSpecifier, isRelativeSpecifier, normalizePath, parseJsExtension, readTsconfigPaths, resolveRelativeImportWithExistenceCheck, resolveRelativeImportWithReferences };
|
package/dist/utils.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { MODULE_EXTENSION_CANDIDATES, cachedFn, isExternalSpecifier, isRelativeSpecifier, normalizePath, resolveRelativeImportWithExistenceCheck, resolveRelativeImportWithReferences };
|
|
1
|
+
import { a as normalizePath, c as resolveRelativeImportWithReferences, d as createAliasResolver, f as TsconfigPathsConfig, i as isRelativeSpecifier, l as cachedFn, m as readTsconfigPaths, n as MODULE_EXTENSION_CANDIDATES, o as parseJsExtension, p as TsconfigReadError, r as isExternalSpecifier, s as resolveRelativeImportWithExistenceCheck, t as JsExtensionInfo, u as AliasResolver } from "./index-BCu9PNbZ.mjs";
|
|
2
|
+
export { AliasResolver, JsExtensionInfo, MODULE_EXTENSION_CANDIDATES, TsconfigPathsConfig, TsconfigReadError, cachedFn, createAliasResolver, isExternalSpecifier, isRelativeSpecifier, normalizePath, parseJsExtension, readTsconfigPaths, resolveRelativeImportWithExistenceCheck, resolveRelativeImportWithReferences };
|
package/dist/utils.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as isExternalSpecifier, c as parseJsExtension, i as MODULE_EXTENSION_CANDIDATES, l as resolveRelativeImportWithExistenceCheck, n as cachedFn, o as isRelativeSpecifier, r as createAliasResolver, s as normalizePath, t as readTsconfigPaths, u as resolveRelativeImportWithReferences } from "./utils-ZCE_eqCf.mjs";
|
|
2
2
|
|
|
3
|
-
export { MODULE_EXTENSION_CANDIDATES, cachedFn, isExternalSpecifier, isRelativeSpecifier, normalizePath, resolveRelativeImportWithExistenceCheck, resolveRelativeImportWithReferences };
|
|
3
|
+
export { MODULE_EXTENSION_CANDIDATES, cachedFn, createAliasResolver, isExternalSpecifier, isRelativeSpecifier, normalizePath, parseJsExtension, readTsconfigPaths, resolveRelativeImportWithExistenceCheck, resolveRelativeImportWithReferences };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_canonical_id = require('./canonical-id-
|
|
1
|
+
const require_canonical_id = require('./canonical-id-DHdeYIsT.cjs');
|
|
2
2
|
let zod = require("zod");
|
|
3
3
|
|
|
4
4
|
//#region packages/common/src/zod/schema-helper.ts
|
|
@@ -13,4 +13,4 @@ Object.defineProperty(exports, 'defineSchemaFor', {
|
|
|
13
13
|
return defineSchemaFor;
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
|
-
//# sourceMappingURL=zod-
|
|
16
|
+
//# sourceMappingURL=zod-DjI3IUH3.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod-
|
|
1
|
+
{"version":3,"file":"zod-DjI3IUH3.cjs","names":["z"],"sources":["../src/zod/schema-helper.ts"],"sourcesContent":["import { z } from \"zod\";\n\n// biome-ignore lint/suspicious/noExplicitAny: abstract type\nexport type SchemaFor<TOutput> = z.ZodType<TOutput, any, any>;\n\nexport type ShapeFor<TOutput extends object> = { [K in keyof TOutput]-?: SchemaFor<TOutput[K]> };\n\nexport function defineSchemaFor<TOutput extends object>() {\n return <TShape extends ShapeFor<NoInfer<TOutput>>>(shape: TShape & { [K in Exclude<keyof TShape, keyof TOutput>]: never }) =>\n z.object(shape).strict();\n}\n"],"mappings":";;;;AAOA,SAAgB,kBAA0C;AACxD,SAAmD,UACjDA,MAAE,OAAO,MAAM,CAAC,QAAQ"}
|
package/dist/zod.cjs
CHANGED
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"canonical-id-BJahCcrS.mjs","names":["CanonicalIdSchema: z.ZodType<CanonicalId>","z","scopeStack: ScopeFrame[]","frame: ScopeFrame","exportBinding: string | undefined"],"sources":["../src/canonical-id/canonical-id.ts","../src/canonical-id/path-tracker.ts"],"sourcesContent":["import { isAbsolute, resolve } from \"node:path\";\nimport z from \"zod\";\nimport { normalizePath } from \"../utils\";\n\nexport type CanonicalId = string & { readonly __brand: \"CanonicalId\" };\n\nconst canonicalIdSeparator = \"::\" as const;\n\nexport const CanonicalIdSchema: z.ZodType<CanonicalId> = z.string() as unknown as z.ZodType<CanonicalId>;\n\n// Type-safe schema for CanonicalId - validates as string but types as branded\nexport const createCanonicalId = (filePath: string, astPath: string): CanonicalId => {\n if (!isAbsolute(filePath)) {\n throw new Error(\"[INTERNAL] CANONICAL_ID_REQUIRES_ABSOLUTE_PATH\");\n }\n\n const resolved = resolve(filePath);\n const normalized = normalizePath(resolved);\n\n // Create a 2-part ID: {absPath}::{astPath}\n // astPath uniquely identifies the definition's location in the AST (e.g., \"MyComponent.useQuery.def\")\n const idParts = [normalized, astPath];\n\n return idParts.join(canonicalIdSeparator) as CanonicalId;\n};\n\n/**\n * Parse a canonical ID into its components.\n * @param canonicalId - The canonical ID to parse (e.g., \"/app/src/user.ts::userFragment\")\n * @returns An object with filePath and astPath\n */\nexport const parseCanonicalId = (\n canonicalId: CanonicalId | string,\n): {\n filePath: string;\n astPath: string;\n} => {\n const idx = canonicalId.indexOf(canonicalIdSeparator);\n if (idx === -1) {\n return { filePath: canonicalId, astPath: \"\" };\n }\n return {\n filePath: canonicalId.slice(0, idx),\n astPath: canonicalId.slice(idx + canonicalIdSeparator.length),\n };\n};\n","/**\n * Canonical path tracker for AST traversal.\n *\n * This module provides a stateful helper that tracks scope information during\n * AST traversal to generate canonical IDs. It's designed to integrate with\n * existing plugin visitor patterns (Babel, SWC, TypeScript) without requiring\n * a separate AST traversal.\n *\n * Usage pattern:\n * 1. Plugin creates tracker at file/program entry\n * 2. Plugin calls enterScope/exitScope during its traversal\n * 3. Plugin calls registerDefinition when discovering GQL definitions\n * 4. Tracker provides canonical ID information\n */\n\nimport type { CanonicalId } from \"./canonical-id\";\nimport { createCanonicalId } from \"./canonical-id\";\n\n/**\n * Scope frame for tracking AST path segments\n */\nexport type ScopeFrame = {\n /** Name segment (e.g., \"MyComponent\", \"useQuery\", \"arrow#1\") */\n readonly nameSegment: string;\n /** Kind of scope */\n readonly kind: \"function\" | \"class\" | \"variable\" | \"property\" | \"method\" | \"expression\";\n /** Occurrence index for disambiguation */\n readonly occurrence: number;\n};\n\n/**\n * Opaque handle for scope tracking\n */\nexport type ScopeHandle = {\n readonly __brand: \"ScopeHandle\";\n readonly depth: number;\n};\n\n/**\n * Canonical path tracker interface\n */\nexport interface CanonicalPathTracker {\n /**\n * Enter a new scope during traversal\n * @param options Scope information\n * @returns Handle to use when exiting the scope\n */\n enterScope(options: { segment: string; kind: ScopeFrame[\"kind\"]; stableKey?: string }): ScopeHandle;\n\n /**\n * Exit a scope during traversal\n * @param handle Handle returned from enterScope\n */\n exitScope(handle: ScopeHandle): void;\n\n /**\n * Register a definition discovered during traversal\n * @returns Definition metadata including astPath and canonical ID information\n */\n registerDefinition(): {\n astPath: string;\n isTopLevel: boolean;\n exportBinding?: string;\n };\n\n /**\n * Resolve a canonical ID from an astPath\n * @param astPath AST path string\n * @returns Canonical ID\n */\n resolveCanonicalId(astPath: string): CanonicalId;\n\n /**\n * Register an export binding\n * @param local Local variable name\n * @param exported Exported name\n */\n registerExportBinding(local: string, exported: string): void;\n\n /**\n * Get current scope depth\n * @returns Current depth (0 = top level)\n */\n currentDepth(): number;\n}\n\n/**\n * Build AST path from scope stack (internal helper)\n */\nconst _buildAstPath = (stack: readonly ScopeFrame[]): string => {\n return stack.map((frame) => frame.nameSegment).join(\".\");\n};\n\n/**\n * Create a canonical path tracker\n *\n * @param options Configuration options\n * @returns Tracker instance\n *\n * @example\n * ```typescript\n * // In a Babel plugin\n * const tracker = createCanonicalTracker({ filePath: state.filename });\n *\n * const visitor = {\n * FunctionDeclaration: {\n * enter(path) {\n * const handle = tracker.enterScope({\n * segment: path.node.id.name,\n * kind: 'function'\n * });\n * },\n * exit(path) {\n * tracker.exitScope(handle);\n * }\n * }\n * };\n * ```\n */\nexport const createCanonicalTracker = (options: {\n filePath: string;\n getExportName?: (localName: string) => string | undefined;\n}): CanonicalPathTracker => {\n const { filePath, getExportName } = options;\n\n // Scope stack\n const scopeStack: ScopeFrame[] = [];\n\n // Occurrence counters for disambiguating duplicate names\n const occurrenceCounters = new Map<string, number>();\n\n // Used paths for ensuring uniqueness\n const usedPaths = new Set<string>();\n\n // Export bindings map\n const exportBindings = new Map<string, string>();\n\n const getNextOccurrence = (key: string): number => {\n const current = occurrenceCounters.get(key) ?? 0;\n occurrenceCounters.set(key, current + 1);\n return current;\n };\n\n const ensureUniquePath = (basePath: string): string => {\n let path = basePath;\n let suffix = 0;\n while (usedPaths.has(path)) {\n suffix++;\n path = `${basePath}$${suffix}`;\n }\n usedPaths.add(path);\n return path;\n };\n\n return {\n enterScope({ segment, kind, stableKey }): ScopeHandle {\n const key = stableKey ?? `${kind}:${segment}`;\n const occurrence = getNextOccurrence(key);\n\n const frame: ScopeFrame = {\n nameSegment: segment,\n kind,\n occurrence,\n };\n\n scopeStack.push(frame);\n\n return {\n __brand: \"ScopeHandle\",\n depth: scopeStack.length - 1,\n } as ScopeHandle;\n },\n\n exitScope(handle: ScopeHandle): void {\n // Validate handle depth matches current stack\n if (handle.depth !== scopeStack.length - 1) {\n throw new Error(`[INTERNAL] Invalid scope exit: expected depth ${scopeStack.length - 1}, got ${handle.depth}`);\n }\n scopeStack.pop();\n },\n\n registerDefinition(): {\n astPath: string;\n isTopLevel: boolean;\n exportBinding?: string;\n } {\n const basePath = _buildAstPath(scopeStack);\n const astPath = ensureUniquePath(basePath);\n const isTopLevel = scopeStack.length === 0;\n\n // Check export binding if provided\n let exportBinding: string | undefined;\n if (getExportName && isTopLevel) {\n // For top-level definitions, try to get export name\n // This is a simplified version - real logic depends on how the definition is bound\n exportBinding = undefined;\n }\n\n return {\n astPath,\n isTopLevel,\n exportBinding,\n };\n },\n\n resolveCanonicalId(astPath: string): CanonicalId {\n return createCanonicalId(filePath, astPath);\n },\n\n registerExportBinding(local: string, exported: string): void {\n exportBindings.set(local, exported);\n },\n\n currentDepth(): number {\n return scopeStack.length;\n },\n };\n};\n\n/**\n * Helper to create occurrence tracker (for backward compatibility)\n */\nexport const createOccurrenceTracker = (): {\n getNextOccurrence: (key: string) => number;\n} => {\n const occurrenceCounters = new Map<string, number>();\n\n return {\n getNextOccurrence(key: string): number {\n const current = occurrenceCounters.get(key) ?? 0;\n occurrenceCounters.set(key, current + 1);\n return current;\n },\n };\n};\n\n/**\n * Helper to create path tracker (for backward compatibility)\n */\nexport const createPathTracker = (): {\n ensureUniquePath: (basePath: string) => string;\n} => {\n const usedPaths = new Set<string>();\n\n return {\n ensureUniquePath(basePath: string): string {\n let path = basePath;\n let suffix = 0;\n while (usedPaths.has(path)) {\n suffix++;\n path = `${basePath}$${suffix}`;\n }\n usedPaths.add(path);\n return path;\n },\n };\n};\n\n/**\n * Build AST path from scope stack (for backward compatibility)\n */\nexport const buildAstPath = (stack: readonly ScopeFrame[]): string => {\n return stack.map((frame) => frame.nameSegment).join(\".\");\n};\n"],"mappings":";;;;;AAMA,MAAM,uBAAuB;AAE7B,MAAaA,oBAA4CC,IAAE,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yn.cjs","names":["CanonicalIdSchema: z.ZodType<CanonicalId>","z","normalizePath","scopeStack: ScopeFrame[]","frame: ScopeFrame","exportBinding: string | undefined"],"sources":["../src/canonical-id/canonical-id.ts","../src/canonical-id/path-tracker.ts"],"sourcesContent":["import { isAbsolute, resolve } from \"node:path\";\nimport z from \"zod\";\nimport { normalizePath } from \"../utils\";\n\nexport type CanonicalId = string & { readonly __brand: \"CanonicalId\" };\n\nconst canonicalIdSeparator = \"::\" as const;\n\nexport const CanonicalIdSchema: z.ZodType<CanonicalId> = z.string() as unknown as z.ZodType<CanonicalId>;\n\n// Type-safe schema for CanonicalId - validates as string but types as branded\nexport const createCanonicalId = (filePath: string, astPath: string): CanonicalId => {\n if (!isAbsolute(filePath)) {\n throw new Error(\"[INTERNAL] CANONICAL_ID_REQUIRES_ABSOLUTE_PATH\");\n }\n\n const resolved = resolve(filePath);\n const normalized = normalizePath(resolved);\n\n // Create a 2-part ID: {absPath}::{astPath}\n // astPath uniquely identifies the definition's location in the AST (e.g., \"MyComponent.useQuery.def\")\n const idParts = [normalized, astPath];\n\n return idParts.join(canonicalIdSeparator) as CanonicalId;\n};\n\n/**\n * Parse a canonical ID into its components.\n * @param canonicalId - The canonical ID to parse (e.g., \"/app/src/user.ts::userFragment\")\n * @returns An object with filePath and astPath\n */\nexport const parseCanonicalId = (\n canonicalId: CanonicalId | string,\n): {\n filePath: string;\n astPath: string;\n} => {\n const idx = canonicalId.indexOf(canonicalIdSeparator);\n if (idx === -1) {\n return { filePath: canonicalId, astPath: \"\" };\n }\n return {\n filePath: canonicalId.slice(0, idx),\n astPath: canonicalId.slice(idx + canonicalIdSeparator.length),\n };\n};\n","/**\n * Canonical path tracker for AST traversal.\n *\n * This module provides a stateful helper that tracks scope information during\n * AST traversal to generate canonical IDs. It's designed to integrate with\n * existing plugin visitor patterns (Babel, SWC, TypeScript) without requiring\n * a separate AST traversal.\n *\n * Usage pattern:\n * 1. Plugin creates tracker at file/program entry\n * 2. Plugin calls enterScope/exitScope during its traversal\n * 3. Plugin calls registerDefinition when discovering GQL definitions\n * 4. Tracker provides canonical ID information\n */\n\nimport type { CanonicalId } from \"./canonical-id\";\nimport { createCanonicalId } from \"./canonical-id\";\n\n/**\n * Scope frame for tracking AST path segments\n */\nexport type ScopeFrame = {\n /** Name segment (e.g., \"MyComponent\", \"useQuery\", \"arrow#1\") */\n readonly nameSegment: string;\n /** Kind of scope */\n readonly kind: \"function\" | \"class\" | \"variable\" | \"property\" | \"method\" | \"expression\";\n /** Occurrence index for disambiguation */\n readonly occurrence: number;\n};\n\n/**\n * Opaque handle for scope tracking\n */\nexport type ScopeHandle = {\n readonly __brand: \"ScopeHandle\";\n readonly depth: number;\n};\n\n/**\n * Canonical path tracker interface\n */\nexport interface CanonicalPathTracker {\n /**\n * Enter a new scope during traversal\n * @param options Scope information\n * @returns Handle to use when exiting the scope\n */\n enterScope(options: { segment: string; kind: ScopeFrame[\"kind\"]; stableKey?: string }): ScopeHandle;\n\n /**\n * Exit a scope during traversal\n * @param handle Handle returned from enterScope\n */\n exitScope(handle: ScopeHandle): void;\n\n /**\n * Register a definition discovered during traversal\n * @returns Definition metadata including astPath and canonical ID information\n */\n registerDefinition(): {\n astPath: string;\n isTopLevel: boolean;\n exportBinding?: string;\n };\n\n /**\n * Resolve a canonical ID from an astPath\n * @param astPath AST path string\n * @returns Canonical ID\n */\n resolveCanonicalId(astPath: string): CanonicalId;\n\n /**\n * Register an export binding\n * @param local Local variable name\n * @param exported Exported name\n */\n registerExportBinding(local: string, exported: string): void;\n\n /**\n * Get current scope depth\n * @returns Current depth (0 = top level)\n */\n currentDepth(): number;\n}\n\n/**\n * Build AST path from scope stack (internal helper)\n */\nconst _buildAstPath = (stack: readonly ScopeFrame[]): string => {\n return stack.map((frame) => frame.nameSegment).join(\".\");\n};\n\n/**\n * Create a canonical path tracker\n *\n * @param options Configuration options\n * @returns Tracker instance\n *\n * @example\n * ```typescript\n * // In a Babel plugin\n * const tracker = createCanonicalTracker({ filePath: state.filename });\n *\n * const visitor = {\n * FunctionDeclaration: {\n * enter(path) {\n * const handle = tracker.enterScope({\n * segment: path.node.id.name,\n * kind: 'function'\n * });\n * },\n * exit(path) {\n * tracker.exitScope(handle);\n * }\n * }\n * };\n * ```\n */\nexport const createCanonicalTracker = (options: {\n filePath: string;\n getExportName?: (localName: string) => string | undefined;\n}): CanonicalPathTracker => {\n const { filePath, getExportName } = options;\n\n // Scope stack\n const scopeStack: ScopeFrame[] = [];\n\n // Occurrence counters for disambiguating duplicate names\n const occurrenceCounters = new Map<string, number>();\n\n // Used paths for ensuring uniqueness\n const usedPaths = new Set<string>();\n\n // Export bindings map\n const exportBindings = new Map<string, string>();\n\n const getNextOccurrence = (key: string): number => {\n const current = occurrenceCounters.get(key) ?? 0;\n occurrenceCounters.set(key, current + 1);\n return current;\n };\n\n const ensureUniquePath = (basePath: string): string => {\n let path = basePath;\n let suffix = 0;\n while (usedPaths.has(path)) {\n suffix++;\n path = `${basePath}$${suffix}`;\n }\n usedPaths.add(path);\n return path;\n };\n\n return {\n enterScope({ segment, kind, stableKey }): ScopeHandle {\n const key = stableKey ?? `${kind}:${segment}`;\n const occurrence = getNextOccurrence(key);\n\n const frame: ScopeFrame = {\n nameSegment: segment,\n kind,\n occurrence,\n };\n\n scopeStack.push(frame);\n\n return {\n __brand: \"ScopeHandle\",\n depth: scopeStack.length - 1,\n } as ScopeHandle;\n },\n\n exitScope(handle: ScopeHandle): void {\n // Validate handle depth matches current stack\n if (handle.depth !== scopeStack.length - 1) {\n throw new Error(`[INTERNAL] Invalid scope exit: expected depth ${scopeStack.length - 1}, got ${handle.depth}`);\n }\n scopeStack.pop();\n },\n\n registerDefinition(): {\n astPath: string;\n isTopLevel: boolean;\n exportBinding?: string;\n } {\n const basePath = _buildAstPath(scopeStack);\n const astPath = ensureUniquePath(basePath);\n const isTopLevel = scopeStack.length === 0;\n\n // Check export binding if provided\n let exportBinding: string | undefined;\n if (getExportName && isTopLevel) {\n // For top-level definitions, try to get export name\n // This is a simplified version - real logic depends on how the definition is bound\n exportBinding = undefined;\n }\n\n return {\n astPath,\n isTopLevel,\n exportBinding,\n };\n },\n\n resolveCanonicalId(astPath: string): CanonicalId {\n return createCanonicalId(filePath, astPath);\n },\n\n registerExportBinding(local: string, exported: string): void {\n exportBindings.set(local, exported);\n },\n\n currentDepth(): number {\n return scopeStack.length;\n },\n };\n};\n\n/**\n * Helper to create occurrence tracker (for backward compatibility)\n */\nexport const createOccurrenceTracker = (): {\n getNextOccurrence: (key: string) => number;\n} => {\n const occurrenceCounters = new Map<string, number>();\n\n return {\n getNextOccurrence(key: string): number {\n const current = occurrenceCounters.get(key) ?? 0;\n occurrenceCounters.set(key, current + 1);\n return current;\n },\n };\n};\n\n/**\n * Helper to create path tracker (for backward compatibility)\n */\nexport const createPathTracker = (): {\n ensureUniquePath: (basePath: string) => string;\n} => {\n const usedPaths = new Set<string>();\n\n return {\n ensureUniquePath(basePath: string): string {\n let path = basePath;\n let suffix = 0;\n while (usedPaths.has(path)) {\n suffix++;\n path = `${basePath}$${suffix}`;\n }\n usedPaths.add(path);\n return path;\n },\n };\n};\n\n/**\n * Build AST path from scope stack (for backward compatibility)\n */\nexport const buildAstPath = (stack: readonly ScopeFrame[]): string => {\n return stack.map((frame) => frame.nameSegment).join(\".\");\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM,uBAAuB;AAE7B,MAAaA,oBAA4CC,YAAE,QAAQ;AAGnE,MAAa,qBAAqB,UAAkB,YAAiC;AACnF,KAAI,2BAAY,SAAS,EAAE;AACzB,QAAM,IAAI,MAAM,iDAAiD;;CAGnE,MAAM,kCAAmB,SAAS;CAClC,MAAM,aAAaC,4BAAc,SAAS;CAI1C,MAAM,UAAU,CAAC,YAAY,QAAQ;AAErC,QAAO,QAAQ,KAAK,qBAAqB;;;;;;;AAQ3C,MAAa,oBACX,gBAIG;CACH,MAAM,MAAM,YAAY,QAAQ,qBAAqB;AACrD,KA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W;GAC1C,MAAM,UAAU,iBAAiB,SAAS;GAC1C,MAAM,aAAa,WAAW,WAAW;GAGzC,IAAIC;AACJ,OAAI,iBAAiB,YAAY;AAG/B,oBAAgB;;AAGlB,UAAO;IACL;IACA;IACA;IACD;;EAGH,mBAAmB,SAA8B;AAC/C,UAAO,kBAAkB,UAAU,QAAQ;;EAG7C,sBAAsB,OAAe,UAAwB;AAC3D,kBAAe,IAAI,OAAO,SAAS;;EAGrC,eAAuB;AACrB,UAAO,WAAW;;EAErB;;;;;AAMH,MAAa,gCAER;CACH,MAAM,qBAAqB,IAAI,KAAqB;AAEpD,QAAO,EACL,kBAAkB,KAAqB;EACrC,MAAM,UAAU,mBAAmB,IAAI,IAAI,IAAI;AAC/C,qBAAmB,IAAI,KAAK,UAAU,EAAE;AACxC,SAAO;IAEV;;;;;AAMH,MAAa,0BAER;CACH,MAAM,YAAY,IAAI,KAAa;AAEnC,QAAO,EACL,iBAAiB,UAA0B;EACzC,IAAI,OAAO;EACX,IAAI,SAAS;AACb,SAAO,UAAU,IAAI,KAAK,EAAE;AAC1B;AACA,UAAO,GAAG,SAAS,GAAG;;AAExB,YAAU,IAAI,KAAK;AACnB,SAAO;IAEV;;;;;AAMH,MAAa,gBAAgB,UAAyC;AACpE,QAAO,MAAM,KAAK,UAAU,MAAM,YAAY,CAAC,KAAK,IAAI"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-B424kKYS.d.mts","names":[],"sources":["../src/portable/fs.ts","../src/portable/hash.ts","../src/portable/id.ts","../src/portable/runtime.ts","../src/portable/spawn.ts"],"sourcesContent":[],"mappings":";;AAMA;;AAE4C,UAF3B,UAAA,CAE2B;EAKM,QAAA,CAAA,IAAA,EAAA,MAAA,CAAA,EANxB,OAMwB,CAAA,MAAA,CAAA;EAC1B,SAAA,CAAA,IAAA,EAAA,MAAA,EAAA,OAAA,EAAA,MAAA,CAAA,EANoB,OAMpB,CAAA,IAAA,CAAA;EACe;;;;EAWf,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;;cAoGS;;;;;;cAiBA;;;;;;cAsBA,+BAAgC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-Cm2Zwk9m.d.cts","names":[],"sources":["../src/canonical-id/canonical-id.ts","../src/canonical-id/path-tracker.ts"],"sourcesContent":[],"mappings":";;;KAIY,WAAA;;AAAZ,CAAA;AAIa,cAAA,iBAA6B,EAAV,GAAA,CAAE,OAAF,CAAU,WAAD,CAAA;AAG5B,cAAA,iBAAyD,EAAA,CAAA,QAarE,EAAA,MAAA,EAAA,OAAA,EAAA,MAAA,EAAA,GAbqE,WAarE;AAOD;;;;ACVA;AAYY,cDFC,gBCEU,EAAA,CAAA,WAAA,EDDR,WCCQ,GAAA,MAAA,EAAA,GAAA;EAQN,QAAA,EAAA,MAAA;EAM8B,OAAA,EAAA,MAAA;CAA2C;;;;;;;AAwE7E,KAlGD,UAAA,GAkGC;EAuGA;EAiBA,SAAA,WAiBZ,EAAA,MAAA;EAKY;;;;;;;;KApOD,WAAA;;;;;;;UAQK,oBAAA;;;;;;;;UAM8B;;MAA2C;;;;;oBAMtE;;;;;;;;;;;;;;;uCAiBmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAiD1B;;;MAGT;;;;cAoGS;;;;;;cAiBA;;;;;;cAsBA,+BAAgC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-D1tzB3W5.d.cts","names":[],"sources":["../src/portable/fs.ts","../src/portable/hash.ts","../src/portable/id.ts","../src/portable/runtime.ts","../src/portable/spawn.ts"],"sourcesContent":[],"mappings":";;AAMA;;AAE4C,UAF3B,UAAA,CAE2B;EAKM,QAAA,CAAA,IAAA,EAAA,MAAA,CAAA,EANxB,OAMwB,CAAA,MAAA,CAAA;EAC1B,SAAA,CAAA,IAAA,EAAA,MAAA,EAAA,OAAA,EAAA,MAAA,CAAA,EANoB,OAMpB,CAAA,IAAA,CAAA;EACe;;;;EAWf,eAAA,CAAA,IA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,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,GAAA,GGbG,CHaH,CAAA,EAAA,GAAA,GGba,CHab;AAmE/B;AA2OA;AAWA;;iBGrTgB,qBAAA,CAAA;;;;AHxBhB;;AAE4C,UIF3B,YAAA,CJE2B;EAKM,GAAA,EAAA,MAAA,EAAA;EAC1B,GAAA,CAAA,EAAA,MAAA;EACe,GAAA,CAAA,EIN/B,MJM+B,CAAA,MAAA,EAAA,MAAA,CAAA;;AACK,UIJ3B,WAAA,CJI2B;EACc,MAAA,EAAA,MAAA;EASlC,MAAA,EAAA,MAAA;EAAO,QAAA,EAAA,MAAA;AAmE/B;AA2OgB,iBItTM,KAAA,CJsTO,OAAI,EItTI,YJsTM,CAAA,EItTS,OJsTT,CItTiB,WJsTjB,CAAA"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
//#region packages/common/src/utils/cached-fn.d.ts
|
|
2
|
-
declare const cachedFn: <T>(fn: () => T) => {
|
|
3
|
-
(): T;
|
|
4
|
-
clear(): void;
|
|
5
|
-
};
|
|
6
|
-
//#endregion
|
|
7
|
-
//#region packages/common/src/utils/path.d.ts
|
|
8
|
-
/**
|
|
9
|
-
* File extensions to try when resolving module specifiers.
|
|
10
|
-
* Ordered to match TypeScript's module resolution order.
|
|
11
|
-
* @see https://www.typescriptlang.org/docs/handbook/module-resolution.html
|
|
12
|
-
*/
|
|
13
|
-
declare const MODULE_EXTENSION_CANDIDATES: readonly [".ts", ".tsx", ".mts", ".cts", ".js", ".mjs", ".cjs", ".jsx"];
|
|
14
|
-
/**
|
|
15
|
-
* Normalize path to use forward slashes (cross-platform).
|
|
16
|
-
* Ensures consistent path handling across platforms.
|
|
17
|
-
*/
|
|
18
|
-
declare const normalizePath: (value: string) => string;
|
|
19
|
-
/**
|
|
20
|
-
* Resolve a relative import specifier to an absolute file path.
|
|
21
|
-
* Tries the specifier as-is, with extensions, and as a directory with index files.
|
|
22
|
-
*
|
|
23
|
-
* @param from - Absolute path to the importing file
|
|
24
|
-
* @param specifier - Relative module specifier (must start with '.')
|
|
25
|
-
* @returns Absolute POSIX path to the resolved file, or null if not found
|
|
26
|
-
*/
|
|
27
|
-
declare const resolveRelativeImportWithExistenceCheck: ({
|
|
28
|
-
filePath,
|
|
29
|
-
specifier
|
|
30
|
-
}: {
|
|
31
|
-
filePath: string;
|
|
32
|
-
specifier: string;
|
|
33
|
-
}) => string | null;
|
|
34
|
-
/**
|
|
35
|
-
* Resolve a relative import specifier to an absolute file path.
|
|
36
|
-
* Tries the specifier as-is, with extensions, and as a directory with index files.
|
|
37
|
-
*
|
|
38
|
-
* @param from - Absolute path to the importing file
|
|
39
|
-
* @param specifier - Relative module specifier (must start with '.')
|
|
40
|
-
* @returns Absolute POSIX path to the resolved file, or null if not found
|
|
41
|
-
*/
|
|
42
|
-
declare const resolveRelativeImportWithReferences: <_>({
|
|
43
|
-
filePath,
|
|
44
|
-
specifier,
|
|
45
|
-
references
|
|
46
|
-
}: {
|
|
47
|
-
filePath: string;
|
|
48
|
-
specifier: string;
|
|
49
|
-
references: Map<string, _> | Set<string>;
|
|
50
|
-
}) => string | null;
|
|
51
|
-
/**
|
|
52
|
-
* Check if a module specifier is relative (starts with '.' or '..')
|
|
53
|
-
*/
|
|
54
|
-
declare const isRelativeSpecifier: (specifier: string) => boolean;
|
|
55
|
-
/**
|
|
56
|
-
* Check if a module specifier is external (package name, not relative)
|
|
57
|
-
*/
|
|
58
|
-
declare const isExternalSpecifier: (specifier: string) => boolean;
|
|
59
|
-
//#endregion
|
|
60
|
-
export { resolveRelativeImportWithExistenceCheck as a, normalizePath as i, isExternalSpecifier as n, resolveRelativeImportWithReferences as o, isRelativeSpecifier as r, cachedFn as s, MODULE_EXTENSION_CANDIDATES as t };
|
|
61
|
-
//# sourceMappingURL=index-Dv8spPt0.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-Dv8spPt0.d.mts","names":[],"sources":["../src/utils/cached-fn.ts","../src/utils/path.ts"],"sourcesContent":[],"mappings":";cAAa,wBAAyB;EAAzB,EAAA,EAAyB,CAAzB;;;;;;AAAb;;;;ACQa,cAAA,2BAAqG,EAAA,SAAA,CAAA,KAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,KAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,CAAA;AAMlH;AAUA;AAkDA;;AAAuD,cA5D1C,aA4D0C,EAAA,CAAA,KAAA,EAAA,MAAA,EAAA,GAAA,MAAA;;;;;;AAsCvD;AAKA;;cA7Fa;;;;;;;;;;;;;;;cAkDA;;;;;;;cAOC,YAAY,KAAK;;;;;cA+BlB;;;;cAKA"}
|