@kubb/ast 5.24.1 → 5.25.1
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/{file-3gsgXreK.js → combineFileMembers-DJHNAZBN.js} +204 -161
- package/dist/combineFileMembers-DJHNAZBN.js.map +1 -0
- package/dist/{file-D73XubVb.cjs → combineFileMembers-DmmuOmY8.cjs} +216 -160
- package/dist/combineFileMembers-DmmuOmY8.cjs.map +1 -0
- package/dist/factory.cjs +6 -6
- package/dist/factory.d.cts +2 -2
- package/dist/factory.d.ts +2 -2
- package/dist/factory.js +2 -2
- package/dist/{file-CMHRNuMX.d.cts → file-DJqd2j3y.d.cts} +3 -1
- package/dist/{file-D67ITWja.d.ts → file-Dg70hXm3.d.ts} +3 -1
- package/dist/{file-1YtTOZeL.js → file-HwCmj--S.js} +5 -3
- package/dist/file-HwCmj--S.js.map +1 -0
- package/dist/{file-azmmZwDb.cjs → file-z3xToonr.cjs} +11 -9
- package/dist/file-z3xToonr.cjs.map +1 -0
- package/dist/file.cjs +7 -5
- package/dist/file.d.cts +2 -2
- package/dist/file.d.ts +2 -2
- package/dist/file.js +3 -3
- package/dist/{index-DNZgWmNq.d.cts → index-BjmAaymt.d.cts} +1 -1
- package/dist/{index-CIUD99Ft.d.ts → index-Br4bwEnS.d.ts} +2 -2
- package/dist/{index-CGmrJThc.d.ts → index-Bz33tfQo.d.ts} +1 -1
- package/dist/{index-Bcxj7FqZ.d.cts → index-C5SXJAtZ.d.cts} +2 -2
- package/dist/{index-bkTCYnZj.d.cts → index-CCUB1hoV.d.cts} +1 -1
- package/dist/{index-C-nsgwuD.d.ts → index-D3yqgtiN.d.ts} +2 -2
- package/dist/{index-84453BaS.d.cts → index-DBKL6vyC.d.cts} +16 -3
- package/dist/{index-BvdIGsVr.d.cts → index-DNDNDzyJ.d.cts} +2 -2
- package/dist/{index-C7U9EiIP.d.ts → index-DXdwkq7X.d.ts} +2 -2
- package/dist/{index-B3o1AkNE.d.ts → index-MzcNxet1.d.ts} +1 -1
- package/dist/{index-DR9ahJ-x.d.cts → index-OfWkiJ5O.d.cts} +2 -2
- package/dist/{index-BFwAhPp8.d.ts → index-VPq6RwTm.d.ts} +16 -3
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/macro-3uGSg-ic.js.map +1 -1
- package/dist/macro-Ywn4-0s5.cjs.map +1 -1
- package/dist/macro.d.cts +1 -1
- package/dist/macro.d.ts +1 -1
- package/dist/mediaType-BbIfudh0.cjs.map +1 -1
- package/dist/mediaType-DXQCNYdM.js.map +1 -1
- package/dist/mediaType.d.cts +2 -2
- package/dist/mediaType.d.ts +2 -2
- package/dist/node.d.cts +2 -2
- package/dist/node.d.ts +2 -2
- package/dist/{nodes-BdZfapPI.cjs → nodes-TtDfZ9qf.cjs} +12 -12
- package/dist/{nodes-BdZfapPI.cjs.map → nodes-TtDfZ9qf.cjs.map} +1 -1
- package/dist/{nodes-D9nwroV5.js → nodes-u9i-tqFp.js} +2 -2
- package/dist/{nodes-D9nwroV5.js.map → nodes-u9i-tqFp.js.map} +1 -1
- package/dist/promise-B3YkZ4C8.js.map +1 -1
- package/dist/promise-DScaykew.cjs.map +1 -1
- package/dist/schema-0YJZqRXb.cjs.map +1 -1
- package/dist/schema-BvUrXIoX.js.map +1 -1
- package/dist/schema-CC008xgK.js.map +1 -1
- package/dist/schema-DfLGJ-oh.cjs.map +1 -1
- package/dist/schema.d.cts +2 -2
- package/dist/schema.d.ts +2 -2
- package/dist/{visitor-VYLe7Q4m.d.cts → visitor-BN5QJX7-.d.cts} +1 -1
- package/dist/{visitor-CqI8T9Qa.d.ts → visitor-BNGMMmpe.d.ts} +1 -1
- package/dist/visitor-DA5yfOJz.js.map +1 -1
- package/dist/visitor-DhuKS-7x.cjs.map +1 -1
- package/package.json +1 -1
- package/dist/file-1YtTOZeL.js.map +0 -1
- package/dist/file-3gsgXreK.js.map +0 -1
- package/dist/file-D73XubVb.cjs.map +0 -1
- package/dist/file-azmmZwDb.cjs.map +0 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import "./rolldown-runtime-BYyVTPww.js";
|
|
2
|
-
import { hash } from "node:crypto";
|
|
3
2
|
import path from "node:path";
|
|
4
|
-
import
|
|
3
|
+
import process from "node:process";
|
|
5
4
|
import { t as memo } from "./promise-B3YkZ4C8.js";
|
|
5
|
+
import { hash } from "node:crypto";
|
|
6
|
+
import { t as nodeKinds } from "./constants-UorsTFsa.js";
|
|
6
7
|
import { n as getNodeText } from "./nodeText-DFak5VpX.js";
|
|
7
8
|
// src/utils/moduleNames.ts
|
|
8
9
|
/**
|
|
@@ -13,6 +14,12 @@ function getNames(node) {
|
|
|
13
14
|
if (node.names) return node.names;
|
|
14
15
|
return node.kind === "Import" ? fromDeprecatedImport(node) : fromDeprecatedExport(node);
|
|
15
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Returns `true` when a source is an exported declaration. Reads the deprecated `isIndexable` and `isExportable`, in that order, when `export` is unset.
|
|
19
|
+
*/
|
|
20
|
+
function isExported(source) {
|
|
21
|
+
return !!(source.export ?? source.isIndexable ?? source.isExportable);
|
|
22
|
+
}
|
|
16
23
|
function getSpace(source) {
|
|
17
24
|
if (source.space) return source.space;
|
|
18
25
|
if (source.isTypeOnly != null) return source.isTypeOnly ? "type" : "value";
|
|
@@ -99,151 +106,6 @@ function toDeprecatedExport(names) {
|
|
|
99
106
|
asAlias: false
|
|
100
107
|
};
|
|
101
108
|
}
|
|
102
|
-
// src/utils/combineFileMembers.ts
|
|
103
|
-
/**
|
|
104
|
-
* File-member merging. `combineImports` and `combineExports` deduplicate and sort the import and
|
|
105
|
-
* export entries of one file, while `combineSources` deduplicates source entries in original order.
|
|
106
|
-
* `combineImports` also drops imports nothing references. This works on a file's members, not on
|
|
107
|
-
* schema content.
|
|
108
|
-
*/
|
|
109
|
-
const IDENTIFIER_RUN = /[\w$]+/g;
|
|
110
|
-
/**
|
|
111
|
-
* How many imports a file needs before indexing the source beats scanning it once per name.
|
|
112
|
-
*/
|
|
113
|
-
const INDEX_ABOVE_IMPORTS = 128;
|
|
114
|
-
const importForm = (item) => item.alias && (item.name === "*" || item.name === "default") ? item.name : "named";
|
|
115
|
-
const exportForm = (item) => item.name === "*" ? "*" : "named";
|
|
116
|
-
const label = (item) => item.alias ? `${item.name} as ${item.alias}` : item.name;
|
|
117
|
-
function statementKey({ path, form, space, names }) {
|
|
118
|
-
return form === "named" ? `${path}\0named\0${space}` : `${path}\0${form}\0${names[0]?.alias ?? ""}\0${space}`;
|
|
119
|
-
}
|
|
120
|
-
function toStatements(nodes, formOf) {
|
|
121
|
-
return nodes.flatMap((node) => {
|
|
122
|
-
const statements = /* @__PURE__ */ new Map();
|
|
123
|
-
for (const item of getNames(node)) {
|
|
124
|
-
const statement = {
|
|
125
|
-
path: node.path,
|
|
126
|
-
root: node.kind === "Import" ? node.root : void 0,
|
|
127
|
-
form: formOf(item),
|
|
128
|
-
space: item.space ?? "value",
|
|
129
|
-
names: []
|
|
130
|
-
};
|
|
131
|
-
const key = statementKey({
|
|
132
|
-
...statement,
|
|
133
|
-
names: [item]
|
|
134
|
-
});
|
|
135
|
-
const existing = statements.get(key) ?? statement;
|
|
136
|
-
statements.set(key, existing);
|
|
137
|
-
existing.names.push(item);
|
|
138
|
-
}
|
|
139
|
-
return [...statements.values()];
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Relative specifiers by `root`, then `path`. `createFile` sorts a file's imports again on every
|
|
144
|
-
* merge, and the path math dominated that sort on large specs. Two levels keep the existing strings
|
|
145
|
-
* as keys, so lookups reuse their hashes instead of hashing a new joined key each time.
|
|
146
|
-
*/
|
|
147
|
-
const specifierCache = memo.create({ max: 1e4 });
|
|
148
|
-
/**
|
|
149
|
-
* Returns the specifier a member is written with: POSIX and relative to the importing file when it
|
|
150
|
-
* has a `root`, like `getRelativePath` in parser-ts. Sorting on it keeps the order the same on every OS.
|
|
151
|
-
*/
|
|
152
|
-
function specifier(node) {
|
|
153
|
-
const { root, path: target } = node;
|
|
154
|
-
if (!root) return target;
|
|
155
|
-
const byPath = memo(specifierCache, root, () => /* @__PURE__ */ new Map());
|
|
156
|
-
return memo(byPath, target, () => {
|
|
157
|
-
const relative = path.relative(path.dirname(root), target).replaceAll("\\", "/");
|
|
158
|
-
return relative.startsWith("../") ? relative : `./${relative}`;
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
function sortKey(statement) {
|
|
162
|
-
return `${statement.form === "named" ? "1" : "0"}:${statement.space === "type" ? "0" : "1"}:${specifier(statement)}:${statement.names.map(label).toSorted().join("\0")}`;
|
|
163
|
-
}
|
|
164
|
-
function mergeStatements(statements, keep = () => true) {
|
|
165
|
-
const merged = /* @__PURE__ */ new Map();
|
|
166
|
-
const sorted = statements.map((statement) => ({
|
|
167
|
-
statement,
|
|
168
|
-
key: sortKey(statement)
|
|
169
|
-
})).sort((a, b) => a.key < b.key ? -1 : a.key > b.key ? 1 : 0);
|
|
170
|
-
for (const { statement } of sorted) {
|
|
171
|
-
const key = statementKey(statement);
|
|
172
|
-
const entry = merged.get(key) ?? {
|
|
173
|
-
statement: {
|
|
174
|
-
...statement,
|
|
175
|
-
names: []
|
|
176
|
-
},
|
|
177
|
-
seen: /* @__PURE__ */ new Set()
|
|
178
|
-
};
|
|
179
|
-
merged.set(key, entry);
|
|
180
|
-
for (const item of statement.names) {
|
|
181
|
-
const id = item.alias ?? item.name;
|
|
182
|
-
if (entry.seen.has(id) || !keep(item, statement)) continue;
|
|
183
|
-
entry.seen.add(id);
|
|
184
|
-
entry.statement.names.push(item);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
const result = [...merged.values()].map(({ statement }) => statement);
|
|
188
|
-
const bound = ({ path, item }) => `${path}\0${item.alias ?? item.name}`;
|
|
189
|
-
const values = new Set(result.filter(({ space }) => space === "value").flatMap(({ path, names }) => names.map((item) => bound({
|
|
190
|
-
path,
|
|
191
|
-
item
|
|
192
|
-
}))));
|
|
193
|
-
return result.map((statement) => statement.space === "type" ? {
|
|
194
|
-
...statement,
|
|
195
|
-
names: statement.names.filter((item) => !values.has(bound({
|
|
196
|
-
path: statement.path,
|
|
197
|
-
item
|
|
198
|
-
})))
|
|
199
|
-
} : statement).filter((statement) => statement.names.length > 0);
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Deduplicates `SourceNode` objects by `name + export + space`, keeping the first of each
|
|
203
|
-
* key. An unnamed source only drops when the same node appears twice, so markdown can repeat a
|
|
204
|
-
* paragraph or a table. Returns the deduplicated array in original order.
|
|
205
|
-
*/
|
|
206
|
-
function combineSources(sources) {
|
|
207
|
-
const seen = /* @__PURE__ */ new Set();
|
|
208
|
-
return sources.filter((source) => {
|
|
209
|
-
const key = source.name != null ? `${source.name}:${source.export ?? source.isExportable ?? false}:${getSpace(source)}` : source;
|
|
210
|
-
if (seen.has(key)) return false;
|
|
211
|
-
seen.add(key);
|
|
212
|
-
return true;
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Deduplicates and merges `ExportNode` objects: one export per path, form and space. Returns a sorted array.
|
|
217
|
-
*/
|
|
218
|
-
function combineExports(exports) {
|
|
219
|
-
return mergeStatements(toStatements(exports, exportForm)).map(({ path, names }) => ({
|
|
220
|
-
kind: "Export",
|
|
221
|
-
path,
|
|
222
|
-
...toDeprecatedExport(names),
|
|
223
|
-
names
|
|
224
|
-
}));
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Deduplicates and merges `ImportNode` objects, filtering out unused imports.
|
|
228
|
-
*
|
|
229
|
-
* Retains imports that are referenced in `source` or re-exported. One import per path, form and space. Returns
|
|
230
|
-
* a sorted, deduplicated, filtered array.
|
|
231
|
-
*/
|
|
232
|
-
function combineImports(imports, exports, source) {
|
|
233
|
-
const exportedNames = new Set(exports.flatMap((node) => getNames(node).map((item) => item.alias ?? item.name)));
|
|
234
|
-
const identifiers = source && imports.length > INDEX_ABOVE_IMPORTS ? new Set(source.match(IDENTIFIER_RUN)) : null;
|
|
235
|
-
const isUsed = (importName) => !source || identifiers?.has(importName) || source.includes(importName) || exportedNames.has(importName);
|
|
236
|
-
const statements = toStatements(imports.filter((node) => node.path !== node.root), importForm);
|
|
237
|
-
const pathsWithUsedNamedImport = new Set(statements.filter(({ form, names }) => form === "named" && names.some((item) => isUsed(item.alias ?? item.name))).map(({ path }) => path));
|
|
238
|
-
const keep = (item, { form, path }) => isUsed(item.alias ?? item.name) || form !== "named" && pathsWithUsedNamedImport.has(path);
|
|
239
|
-
return mergeStatements(statements, keep).map(({ path, root, names }) => ({
|
|
240
|
-
kind: "Import",
|
|
241
|
-
path,
|
|
242
|
-
...root != null ? { root } : {},
|
|
243
|
-
...toDeprecatedImport(names),
|
|
244
|
-
names
|
|
245
|
-
}));
|
|
246
|
-
}
|
|
247
109
|
// src/nodes/base.ts
|
|
248
110
|
/** Builds a `createX` factory for a node whose only computed field is `kind`. */
|
|
249
111
|
function nodeFactory(kind) {
|
|
@@ -264,9 +126,27 @@ function overrideSpace(names, { value, derived }) {
|
|
|
264
126
|
}));
|
|
265
127
|
}
|
|
266
128
|
const isOverride = ({ value, derived }) => value !== void 0 && JSON.stringify(value) !== JSON.stringify(derived);
|
|
129
|
+
const DERIVED = Symbol.for("kubb.ast.derived");
|
|
130
|
+
/** The deprecated fields the caller set: a value equal to the one the spread node derived is dropped, so `names` decides it. */
|
|
131
|
+
function ownFields(input) {
|
|
132
|
+
const snapshot = input[DERIVED];
|
|
133
|
+
if (!snapshot) return {
|
|
134
|
+
name: input.name,
|
|
135
|
+
isTypeOnly: input.isTypeOnly
|
|
136
|
+
};
|
|
137
|
+
return {
|
|
138
|
+
name: JSON.stringify(input.name) === snapshot.name ? void 0 : input.name,
|
|
139
|
+
isTypeOnly: input.isTypeOnly === snapshot.isTypeOnly ? void 0 : input.isTypeOnly
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function withoutDerived(input) {
|
|
143
|
+
const { [DERIVED]: _, ...rest } = input;
|
|
144
|
+
return rest;
|
|
145
|
+
}
|
|
267
146
|
/**
|
|
268
147
|
* Creates an `ImportNode`. A node built from `names` also gets the deprecated fields. A deprecated `name` or
|
|
269
148
|
* `isTypeOnly` that differs from the one `names` gives overrides it, so `{ ...imp, isTypeOnly: true }` still works.
|
|
149
|
+
* Fields a spread copies over unchanged are not overrides, so `{ ...imp, names }` uses the new `names`.
|
|
270
150
|
*
|
|
271
151
|
* @example Named import
|
|
272
152
|
* ```ts
|
|
@@ -276,34 +156,41 @@ const isOverride = ({ value, derived }) => value !== void 0 && JSON.stringify(va
|
|
|
276
156
|
*/
|
|
277
157
|
function createImport(input) {
|
|
278
158
|
if (!input.names) return {
|
|
279
|
-
...input,
|
|
159
|
+
...withoutDerived(input),
|
|
280
160
|
name: input.name ?? [],
|
|
281
161
|
kind: nodeKinds.import
|
|
282
162
|
};
|
|
163
|
+
const own = ownFields(input);
|
|
283
164
|
const derived = toDeprecatedImport(input.names);
|
|
284
165
|
if (isOverride({
|
|
285
|
-
value:
|
|
166
|
+
value: own.name,
|
|
286
167
|
derived: derived.name
|
|
287
168
|
})) return {
|
|
288
|
-
...input,
|
|
169
|
+
...withoutDerived(input),
|
|
289
170
|
names: null,
|
|
290
|
-
name:
|
|
171
|
+
name: own.name ?? [],
|
|
291
172
|
kind: nodeKinds.import
|
|
292
173
|
};
|
|
293
174
|
const names = overrideSpace(input.names, {
|
|
294
|
-
value:
|
|
175
|
+
value: own.isTypeOnly,
|
|
295
176
|
derived: derived.isTypeOnly
|
|
296
177
|
});
|
|
178
|
+
const fields = toDeprecatedImport(names);
|
|
297
179
|
return {
|
|
298
180
|
...input,
|
|
299
|
-
...
|
|
181
|
+
...fields,
|
|
300
182
|
names,
|
|
183
|
+
[DERIVED]: {
|
|
184
|
+
name: JSON.stringify(fields.name),
|
|
185
|
+
isTypeOnly: fields.isTypeOnly
|
|
186
|
+
},
|
|
301
187
|
kind: nodeKinds.import
|
|
302
188
|
};
|
|
303
189
|
}
|
|
304
190
|
/**
|
|
305
191
|
* Creates an `ExportNode`. A node built from `names` also gets the deprecated fields. A deprecated `name` or
|
|
306
|
-
* `isTypeOnly` that differs from the one `names` gives overrides it.
|
|
192
|
+
* `isTypeOnly` that differs from the one `names` gives overrides it. Fields a spread copies over unchanged are not
|
|
193
|
+
* overrides, so `{ ...exp, names }` uses the new `names`.
|
|
307
194
|
*
|
|
308
195
|
* @example Named export
|
|
309
196
|
* ```ts
|
|
@@ -313,26 +200,34 @@ function createImport(input) {
|
|
|
313
200
|
*/
|
|
314
201
|
function createExport(input) {
|
|
315
202
|
if (!input.names) return {
|
|
316
|
-
...input,
|
|
203
|
+
...withoutDerived(input),
|
|
317
204
|
kind: nodeKinds.export
|
|
318
205
|
};
|
|
206
|
+
const own = ownFields(input);
|
|
319
207
|
const derived = toDeprecatedExport(input.names);
|
|
320
208
|
if (isOverride({
|
|
321
|
-
value:
|
|
209
|
+
value: own.name,
|
|
322
210
|
derived: derived.name
|
|
323
211
|
})) return {
|
|
324
|
-
...input,
|
|
212
|
+
...withoutDerived(input),
|
|
213
|
+
name: own.name,
|
|
325
214
|
names: null,
|
|
326
215
|
kind: nodeKinds.export
|
|
327
216
|
};
|
|
328
217
|
const names = overrideSpace(input.names, {
|
|
329
|
-
value:
|
|
218
|
+
value: own.isTypeOnly,
|
|
330
219
|
derived: derived.isTypeOnly
|
|
331
220
|
});
|
|
221
|
+
const fields = toDeprecatedExport(names);
|
|
332
222
|
return {
|
|
333
223
|
...input,
|
|
334
|
-
...
|
|
224
|
+
...fields,
|
|
225
|
+
name: fields.name,
|
|
335
226
|
names,
|
|
227
|
+
[DERIVED]: {
|
|
228
|
+
name: JSON.stringify(fields.name),
|
|
229
|
+
isTypeOnly: fields.isTypeOnly
|
|
230
|
+
},
|
|
336
231
|
kind: nodeKinds.export
|
|
337
232
|
};
|
|
338
233
|
}
|
|
@@ -422,6 +317,154 @@ function createFile(input) {
|
|
|
422
317
|
meta: input.meta ?? {}
|
|
423
318
|
};
|
|
424
319
|
}
|
|
425
|
-
|
|
320
|
+
// src/utils/combineFileMembers.ts
|
|
321
|
+
/**
|
|
322
|
+
* File-member merging. `combineImports` and `combineExports` deduplicate and sort the import and
|
|
323
|
+
* export entries of one file, while `combineSources` deduplicates source entries in original order.
|
|
324
|
+
* `combineImports` also drops imports nothing references. This works on a file's members, not on
|
|
325
|
+
* schema content.
|
|
326
|
+
*/
|
|
327
|
+
const IDENTIFIER_RUN = /[\w$]+/g;
|
|
328
|
+
/**
|
|
329
|
+
* How many imports a file needs before indexing the source beats scanning it once per name.
|
|
330
|
+
*/
|
|
331
|
+
const INDEX_ABOVE_IMPORTS = 128;
|
|
332
|
+
const importForm = (item) => item.alias && (item.name === "*" || item.name === "default") ? item.name : "named";
|
|
333
|
+
const exportForm = (item) => item.name === "*" ? "*" : "named";
|
|
334
|
+
const label = (item) => item.alias ? `${item.name} as ${item.alias}` : item.name;
|
|
335
|
+
function statementKey({ path, form, space, names }) {
|
|
336
|
+
return form === "named" ? `${path}\0named\0${space}` : `${path}\0${form}\0${names[0]?.alias ?? ""}\0${space}`;
|
|
337
|
+
}
|
|
338
|
+
function toStatements(nodes, formOf) {
|
|
339
|
+
return nodes.flatMap((node) => {
|
|
340
|
+
const statements = /* @__PURE__ */ new Map();
|
|
341
|
+
for (const item of getNames(node)) {
|
|
342
|
+
const statement = {
|
|
343
|
+
path: node.path,
|
|
344
|
+
root: node.kind === "Import" ? node.root : void 0,
|
|
345
|
+
form: formOf(item),
|
|
346
|
+
space: item.space ?? "value",
|
|
347
|
+
names: []
|
|
348
|
+
};
|
|
349
|
+
const key = statementKey({
|
|
350
|
+
...statement,
|
|
351
|
+
names: [item]
|
|
352
|
+
});
|
|
353
|
+
const existing = statements.get(key) ?? statement;
|
|
354
|
+
statements.set(key, existing);
|
|
355
|
+
existing.names.push(item);
|
|
356
|
+
}
|
|
357
|
+
return [...statements.values()];
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Relative specifiers by `root`, then `path`. `createFile` sorts a file's imports again on every
|
|
362
|
+
* merge, and the path math dominated that sort on large specs. Two levels keep the existing strings
|
|
363
|
+
* as keys, so lookups reuse their hashes instead of hashing a new joined key each time.
|
|
364
|
+
*/
|
|
365
|
+
const specifierCache = memo.create({ max: 1e4 });
|
|
366
|
+
/**
|
|
367
|
+
* Module specifier that imports `filePath` from the file at `root`: POSIX, relative to that file's directory, `./`-prefixed unless it climbs with `../`.
|
|
368
|
+
*
|
|
369
|
+
* @example
|
|
370
|
+
* ```ts
|
|
371
|
+
* getRelativePath('/root/src/models/pet.ts', '/root/lib/client.ts') // '../../lib/client.ts'
|
|
372
|
+
* ```
|
|
373
|
+
*/
|
|
374
|
+
function getRelativePath(root, filePath) {
|
|
375
|
+
const rootKey = path.isAbsolute(root) && path.isAbsolute(filePath) ? root : `${process.cwd()}\u0000${root}`;
|
|
376
|
+
const byPath = memo(specifierCache, rootKey, () => /* @__PURE__ */ new Map());
|
|
377
|
+
return memo(byPath, filePath, () => {
|
|
378
|
+
const relative = path.relative(path.dirname(root), filePath).replaceAll("\\", "/");
|
|
379
|
+
return relative.startsWith("../") ? relative : `./${relative}`;
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
/** The specifier a member is written with, so sorting on it gives the same order on every OS. */
|
|
383
|
+
function specifier(node) {
|
|
384
|
+
return node.root ? getRelativePath(node.root, node.path) : node.path;
|
|
385
|
+
}
|
|
386
|
+
function sortKey(statement) {
|
|
387
|
+
return `${statement.form === "named" ? "1" : "0"}:${statement.space === "type" ? "0" : "1"}:${specifier(statement)}:${statement.names.map(label).toSorted().join("\0")}`;
|
|
388
|
+
}
|
|
389
|
+
function mergeStatements(statements, keep = () => true) {
|
|
390
|
+
const merged = /* @__PURE__ */ new Map();
|
|
391
|
+
const sorted = statements.map((statement) => ({
|
|
392
|
+
statement,
|
|
393
|
+
key: sortKey(statement)
|
|
394
|
+
})).sort((a, b) => a.key < b.key ? -1 : a.key > b.key ? 1 : 0);
|
|
395
|
+
for (const { statement } of sorted) {
|
|
396
|
+
const key = statementKey(statement);
|
|
397
|
+
const entry = merged.get(key) ?? {
|
|
398
|
+
statement: {
|
|
399
|
+
...statement,
|
|
400
|
+
names: []
|
|
401
|
+
},
|
|
402
|
+
seen: /* @__PURE__ */ new Set()
|
|
403
|
+
};
|
|
404
|
+
merged.set(key, entry);
|
|
405
|
+
for (const item of statement.names) {
|
|
406
|
+
const id = item.alias ?? item.name;
|
|
407
|
+
if (entry.seen.has(id) || !keep(item, statement)) continue;
|
|
408
|
+
entry.seen.add(id);
|
|
409
|
+
entry.statement.names.push(item);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
const result = [...merged.values()].map(({ statement }) => statement);
|
|
413
|
+
const bound = ({ path, item }) => `${path}\0${item.alias ?? item.name}`;
|
|
414
|
+
const values = new Set(result.filter(({ space }) => space === "value").flatMap(({ path, names }) => names.map((item) => bound({
|
|
415
|
+
path,
|
|
416
|
+
item
|
|
417
|
+
}))));
|
|
418
|
+
return result.map((statement) => statement.space === "type" ? {
|
|
419
|
+
...statement,
|
|
420
|
+
names: statement.names.filter((item) => !values.has(bound({
|
|
421
|
+
path: statement.path,
|
|
422
|
+
item
|
|
423
|
+
})))
|
|
424
|
+
} : statement).filter((statement) => statement.names.length > 0);
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Deduplicates `SourceNode` objects by `name + export + space`, keeping the first of each
|
|
428
|
+
* key. An unnamed source only drops when the same node appears twice, so markdown can repeat a
|
|
429
|
+
* paragraph or a table. Returns the deduplicated array in original order.
|
|
430
|
+
*/
|
|
431
|
+
function combineSources(sources) {
|
|
432
|
+
const seen = /* @__PURE__ */ new Set();
|
|
433
|
+
return sources.filter((source) => {
|
|
434
|
+
const key = source.name != null ? `${source.name}:${isExported(source)}:${getSpace(source)}` : source;
|
|
435
|
+
if (seen.has(key)) return false;
|
|
436
|
+
seen.add(key);
|
|
437
|
+
return true;
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Deduplicates and merges `ExportNode` objects: one export per path, form and space. Returns a sorted array.
|
|
442
|
+
*/
|
|
443
|
+
function combineExports(exports) {
|
|
444
|
+
return mergeStatements(toStatements(exports, exportForm)).map(({ path, names }) => createExport({
|
|
445
|
+
path,
|
|
446
|
+
names
|
|
447
|
+
}));
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Deduplicates and merges `ImportNode` objects, filtering out unused imports.
|
|
451
|
+
*
|
|
452
|
+
* Retains imports that are referenced in `source` or re-exported. One import per path, form and space. Returns
|
|
453
|
+
* a sorted, deduplicated, filtered array.
|
|
454
|
+
*/
|
|
455
|
+
function combineImports(imports, exports, source) {
|
|
456
|
+
const exportedNames = new Set(exports.flatMap((node) => getNames(node).map((item) => item.alias ?? item.name)));
|
|
457
|
+
const identifiers = source && imports.length > INDEX_ABOVE_IMPORTS ? new Set(source.match(IDENTIFIER_RUN)) : null;
|
|
458
|
+
const isUsed = (importName) => !source || identifiers?.has(importName) || source.includes(importName) || exportedNames.has(importName);
|
|
459
|
+
const statements = toStatements(imports.filter((node) => node.path !== node.root), importForm);
|
|
460
|
+
const pathsWithUsedNamedImport = new Set(statements.filter(({ form, names }) => form === "named" && names.some((item) => isUsed(item.alias ?? item.name))).map(({ path }) => path));
|
|
461
|
+
const keep = (item, { form, path }) => isUsed(item.alias ?? item.name) || form !== "named" && pathsWithUsedNamedImport.has(path);
|
|
462
|
+
return mergeStatements(statements, keep).map(({ path, root, names }) => createImport({
|
|
463
|
+
path,
|
|
464
|
+
...root != null ? { root } : {},
|
|
465
|
+
names
|
|
466
|
+
}));
|
|
467
|
+
}
|
|
468
|
+
export { createSource as a, getSpace as c, createImport as i, isExported as l, createExport as n, nodeFactory as o, createFile as r, getNames as s, getRelativePath as t };
|
|
426
469
|
|
|
427
|
-
//# sourceMappingURL=
|
|
470
|
+
//# sourceMappingURL=combineFileMembers-DJHNAZBN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combineFileMembers-DJHNAZBN.js","names":[],"sources":["../src/utils/moduleNames.ts","../src/nodes/base.ts","../src/nodes/file.ts","../src/utils/combineFileMembers.ts"],"sourcesContent":["import type { ExportNode, ImportNode, ModuleName, SourceNode, Space } from '../nodes/file.ts'\n\n/**\n * Returns the names an import or export brings across. A node built with the deprecated fields gets them from\n * those, each with an explicit `space`, so it prints exactly as before.\n */\nexport function getNames(node: ImportNode | ExportNode): Array<ModuleName> {\n if (node.names) return node.names\n return node.kind === 'Import' ? fromDeprecatedImport(node) : fromDeprecatedExport(node)\n}\n\n/**\n * Returns `true` when a source is an exported declaration. Reads the deprecated `isIndexable` and `isExportable`, in that order, when `export` is unset.\n */\nexport function isExported(source: Pick<SourceNode, 'export' | 'isIndexable' | 'isExportable'>): boolean {\n return !!(source.export ?? source.isIndexable ?? source.isExportable)\n}\n\nexport function getSpace(source: SourceNode): Space {\n if (source.space) return source.space\n if (source.isTypeOnly != null) return source.isTypeOnly ? 'type' : 'value'\n return source.nodes?.[0]?.kind === 'Type' ? 'type' : 'value'\n}\n\nexport type DeprecatedImport = Pick<ImportNode, 'name' | 'isTypeOnly' | 'isNameSpace'>\nexport type DeprecatedExport = Pick<ExportNode, 'name' | 'isTypeOnly' | 'asAlias'>\n\n/**\n * @deprecated Converts a node built with `name`, `isTypeOnly` and `isNameSpace` to `names`. Removed in Kubb v6.\n */\nfunction fromDeprecatedImport({ name, isTypeOnly, isNameSpace }: DeprecatedImport): Array<ModuleName> {\n const space: Space = isTypeOnly ? 'type' : 'value'\n if (!Array.isArray(name)) return [{ name: isNameSpace ? '*' : 'default', alias: name, space }]\n return name.map((item) => (typeof item === 'string' ? { name: item, space } : { name: item.propertyName, ...(item.name ? { alias: item.name } : {}), space }))\n}\n\n/**\n * @deprecated Converts a node built with `name`, `isTypeOnly` and `asAlias` to `names`. Removed in Kubb v6.\n */\nfunction fromDeprecatedExport({ name, isTypeOnly, asAlias }: DeprecatedExport): Array<ModuleName> {\n const space: Space = isTypeOnly ? 'type' : 'value'\n if (name == null) return [{ name: '*', space }]\n if (!Array.isArray(name)) return [asAlias ? { name: '*', alias: name, space } : { name, space }]\n return name.map((item) => ({ name: item, space }))\n}\n\n/**\n * @deprecated The old import fields for `names`, for code that still reads them. Removed in Kubb v6.\n */\nexport function toDeprecatedImport(names: ReadonlyArray<ModuleName>): DeprecatedImport {\n const isTypeOnly = names.length > 0 && names.every((item) => item.space === 'type')\n const [first] = names\n if (names.length === 1 && first?.alias && (first.name === '*' || first.name === 'default')) {\n return { name: first.alias, isTypeOnly, isNameSpace: first.name === '*' }\n }\n return { name: names.map((item) => (item.alias ? { propertyName: item.name, name: item.alias } : item.name)), isTypeOnly, isNameSpace: false }\n}\n\n/**\n * @deprecated The old export fields for `names`; an alias stands in for its name. Removed in Kubb v6.\n */\nexport function toDeprecatedExport(names: ReadonlyArray<ModuleName>): DeprecatedExport {\n const isTypeOnly = names.length > 0 && names.every((item) => item.space === 'type')\n const [first] = names\n if (names.length === 1 && first?.name === '*') {\n return first.alias ? { name: first.alias, isTypeOnly, asAlias: true } : { isTypeOnly, asAlias: false }\n }\n return { name: names.map((item) => item.alias ?? item.name), isTypeOnly, asAlias: false }\n}\n","import type { ValueOf } from '@internals/utils'\nimport type { nodeKinds } from '../constants.ts'\n\n/**\n * `kind` values used by AST nodes.\n *\n * @example\n * ```ts\n * const kind: NodeKind = 'Schema'\n * ```\n */\nexport type NodeKind = ValueOf<typeof nodeKinds>\n\n/**\n * Base shape shared by all AST nodes.\n *\n * @example\n * ```ts\n * const base: BaseNode = { kind: 'Input' }\n * ```\n */\nexport type BaseNode = {\n /**\n * Node discriminator.\n */\n kind: NodeKind\n /**\n * Where the node comes from in the input, in the form the adapter's `locate` reads. Document\n * adapters such as OpenAPI and AsyncAPI use an RFC 6901 JSON pointer, for example\n * `#/components/schemas/Pet`. Plugins can copy it to the code nodes they emit.\n */\n pointer?: string\n}\n\n/** `Omit` applied to each member of a union, so the union survives. */\nexport type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never\n\n/** Builds a `createX` factory for a node whose only computed field is `kind`. */\nexport function nodeFactory<T extends BaseNode>(kind: T['kind']): (input: Omit<T, 'kind'>) => T {\n return (input) => {\n const node = { ...input, kind }\n return node as T\n }\n}\n","import { hash } from 'node:crypto'\nimport path from 'node:path'\nimport { nodeKinds } from '../constants.ts'\nimport { combineExports, combineImports, combineSources } from '../utils/combineFileMembers.ts'\nimport { getNames, toDeprecatedExport, toDeprecatedImport } from '../utils/moduleNames.ts'\nimport { getNodeText } from '../utils/nodeText.ts'\nimport { type BaseNode, nodeFactory } from './base.ts'\nimport type { CodeNode } from './code.ts'\n\n/**\n * Supported file extensions.\n */\nexport type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`\n\nexport type ImportName = string | Array<string | { propertyName: string; name?: string }>\n\n/**\n * Whether a declaration exists only at compile time (`'type'`) or also at runtime (`'value'`).\n */\nexport type Space = 'type' | 'value'\n\n/**\n * One name an import or export brings across, as in the ECMAScript `ImportEntry` record.\n */\nexport type ModuleName = {\n /**\n * Name in the other module: `'default'` for its default export, `'*'` for the whole module.\n */\n name: string\n /**\n * Local name for an import, or the exported name for an export.\n */\n alias?: string | null\n /**\n * Type or value.\n * @default 'value'\n */\n space?: Space | null\n}\n\n/**\n * Represents a language-agnostic import/dependency declaration.\n *\n * @example Named import (TypeScript: `import { useState } from 'react'`)\n * ```ts\n * createImport({ names: [{ name: 'useState' }], path: 'react' })\n * ```\n *\n * @example Default import (TypeScript: `import React from 'react'`)\n * ```ts\n * createImport({ names: [{ name: 'default', alias: 'React' }], path: 'react' })\n * ```\n *\n * @example Type-only import (TypeScript: `import type { FC } from 'react'`)\n * ```ts\n * createImport({ names: [{ name: 'FC', space: 'type' }], path: 'react' })\n * ```\n *\n * @example Namespace import (TypeScript: `import * as React from 'react'`)\n * ```ts\n * createImport({ names: [{ name: '*', alias: 'React' }], path: 'react' })\n * ```\n */\nexport type ImportNode = BaseNode & {\n kind: 'Import'\n /**\n * The names the import brings in. `ast.file.getNames` also reads the deprecated fields.\n */\n names?: Array<ModuleName> | null\n /**\n * Import name(s) to be used.\n *\n * @deprecated Use `names`. Removed in Kubb v6.\n */\n name: ImportName\n /**\n * Path for the import.\n *\n * @example\n * `'@kubb/core'`\n */\n path: string\n /**\n * Add a type-only import prefix.\n *\n * @deprecated Set `space: 'type'` on each name. Removed in Kubb v6.\n */\n isTypeOnly?: boolean | null\n /**\n * Import the entire module as a namespace.\n *\n * @deprecated Use `{ name: '*', alias }` in `names`. Removed in Kubb v6.\n */\n isNameSpace?: boolean | null\n /**\n * When set, the import path is resolved relative to this root.\n */\n root?: string | null\n}\n\n/**\n * Represents a language-agnostic export/public API declaration.\n *\n * @example Named export (TypeScript: `export { Pets } from './Pets'`)\n * ```ts\n * createExport({ names: [{ name: 'Pets' }], path: './Pets' })\n * ```\n *\n * @example Type-only export (TypeScript: `export type { Pet } from './Pet'`)\n * ```ts\n * createExport({ names: [{ name: 'Pet', space: 'type' }], path: './Pet' })\n * ```\n *\n * @example Wildcard export (TypeScript: `export * from './utils'`)\n * ```ts\n * createExport({ names: [{ name: '*' }], path: './utils' })\n * ```\n *\n * @example Namespace alias (TypeScript: `export * as utils from './utils'`)\n * ```ts\n * createExport({ names: [{ name: '*', alias: 'utils' }], path: './utils' })\n * ```\n */\nexport type ExportNode = BaseNode & {\n kind: 'Export'\n /**\n * The names the export passes on. `ast.file.getNames` also reads the deprecated fields.\n */\n names?: Array<ModuleName> | null\n /**\n * Export name(s) to be used. When omitted, generates a wildcard export.\n *\n * @deprecated Use `names`. Removed in Kubb v6.\n */\n name?: string | Array<string> | null\n /**\n * Path for the export.\n *\n * @example\n * `'@kubb/core'`\n */\n path: string\n /**\n * Add a type-only export prefix.\n *\n * @deprecated Set `space: 'type'` on each name. Removed in Kubb v6.\n */\n isTypeOnly?: boolean | null\n /**\n * Export as an aliased namespace.\n *\n * @deprecated Use `{ name: '*', alias }` in `names`. Removed in Kubb v6.\n */\n asAlias?: boolean | null\n}\n\n/**\n * Represents a fragment of source code within a file.\n *\n * @example Named exportable source\n * ```ts\n * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], export: true })\n * ```\n *\n * @example Inline unnamed code block\n * ```ts\n * createSource({ nodes: [createText('const x = 1')] })\n * ```\n */\nexport type SourceNode = BaseNode & {\n kind: 'Source'\n /**\n * Optional name identifying this source (used for deduplication and barrel generation).\n */\n name?: string | null\n /**\n * Type or value. When unset, a source whose first node is a `Type` is a type.\n */\n space?: Space | null\n /**\n * Mark this source as a type-only export.\n *\n * @deprecated Use `space: 'type'`. Removed in Kubb v6.\n */\n isTypeOnly?: boolean | null\n /**\n * Mark this source as an exported declaration, which barrels list. The source text carries its own `export` keyword.\n */\n export?: boolean | null\n /**\n * Mark this exported source as the module's default export. Barrels skip it, since they can't re-export it by name.\n */\n default?: boolean | null\n /**\n * @deprecated Use `export`. Removed in Kubb v6.\n */\n isExportable?: boolean | null\n /**\n * @deprecated Use `export`. Removed in Kubb v6.\n */\n isIndexable?: boolean | null\n /**\n * Marks the source as a definition that importing files absorb instead of import. `expression` is\n * the declaration's right-hand side, such as `{ body: Pet }`.\n *\n * @deprecated Set `inline` on the file. Removed in Kubb v6.\n */\n inline?: { expression: string } | null\n /**\n * Child nodes that make up this source fragment, in DOM order.\n * Use a {@link TextNode} for raw string content.\n */\n nodes?: Array<CodeNode>\n}\n\n/**\n * Represents a fully resolved file in the AST.\n *\n * Created via `createFile()`, which computes the `id`, `name`, and `extname` from the input\n * and deduplicates `imports`, `exports`, and `sources`.\n *\n * @example\n * ```ts\n * const file = createFile({\n * baseName: 'petStore.ts',\n * path: 'src/models/petStore.ts',\n * sources: [createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], export: true })],\n * imports: [createImport({ name: ['z'], path: 'zod' })],\n * exports: [createExport({ name: ['Pet'], path: './petStore' })],\n * })\n * // file.id = SHA256 hash of the path\n * // file.name = 'petStore'\n * // file.extname = '.ts'\n * ```\n */\nexport type FileNode<TMeta extends object = object> = BaseNode & {\n kind: 'File'\n /**\n * Unique identifier derived from a SHA256 hash of the file path. `createFile`\n * computes it, so callers do not need to provide it.\n */\n id: string\n /**\n * File name without extension, derived from `baseName`.\n *\n * @see https://nodejs.org/api/path.html#pathformatpathobject\n */\n name: string\n /**\n * File base name, including extension, shaped like `${name}${extname}`.\n *\n * @see https://nodejs.org/api/path.html#pathbasenamepath-suffix\n */\n baseName: `${string}.${string}`\n /**\n * Full qualified path to the file.\n */\n path: string\n /**\n * File extension extracted from `baseName`.\n */\n extname: Extname\n /**\n * Deduplicated list of source code fragments.\n */\n sources: Array<SourceNode>\n /**\n * Deduplicated list of import declarations.\n */\n imports: Array<ImportNode>\n /**\n * Deduplicated list of export declarations.\n */\n exports: Array<ExportNode>\n /**\n * Optional metadata attached to this file, read by plugins during barrel generation.\n */\n meta?: TMeta\n /**\n * Optional banner prepended to the generated file content.\n * Accepts `null` so `resolver.default.banner()` results can be passed directly.\n */\n banner?: string | null\n /**\n * Optional footer appended to the generated file content.\n * Accepts `null` so `resolver.default.footer()` results can be passed directly.\n */\n footer?: string | null\n /**\n * Absolute on-disk path to copy into the output, through the parser's `copy` hook when it has one.\n *\n * Use to emit a real source file shipped inside a package (a template) into the generated\n * folder. When set, `copy` provides the file content and any `sources` nodes are ignored for\n * output; `sources` may still carry `name`/`export` so barrel generation\n * treats the file the same as a rendered one.\n */\n copy?: string | null\n /**\n * Marks a file that is never written. Each file that imports from it gets the body of each imported declaration, such as `{ body: Pet }`, in place of its name.\n */\n inline?: boolean | null\n}\n\nexport type ImportInput = Omit<ImportNode, 'kind' | 'name'> & { name?: ImportName }\n\nexport type ExportInput = Omit<ExportNode, 'kind'>\n\n// A spread node carries the deprecated fields derived from its `names`, so only a value that differs is an override.\ntype Override<TValue> = { value: TValue | null | undefined; derived: TValue | null | undefined }\n\nfunction overrideSpace(names: Array<ModuleName>, { value, derived }: Override<boolean>): Array<ModuleName> {\n if (value == null || value === derived) return names\n const space = value ? 'type' : 'value'\n return names.map((item) => ({ ...item, space }))\n}\n\nconst isOverride = ({ value, derived }: Override<unknown>): boolean => value !== undefined && JSON.stringify(value) !== JSON.stringify(derived)\n\n// Object spread copies symbol keys, so `{ ...imp, names }` carries the fields `imp` derived and they can be told apart from an override.\nconst DERIVED = Symbol.for('kubb.ast.derived')\n// `name` is stored as JSON, so changing the node's `name` array in place still counts as an override.\ntype Derived = { name: string | undefined; isTypeOnly?: boolean | null }\ntype WithDerived = { [DERIVED]?: Derived }\n\n/** The deprecated fields the caller set: a value equal to the one the spread node derived is dropped, so `names` decides it. */\nfunction ownFields<TName>(input: { name?: TName; isTypeOnly?: boolean | null } & WithDerived): { name?: TName; isTypeOnly?: boolean | null } {\n const snapshot = input[DERIVED]\n if (!snapshot) return { name: input.name, isTypeOnly: input.isTypeOnly }\n return {\n name: JSON.stringify(input.name) === snapshot.name ? undefined : input.name,\n isTypeOnly: input.isTypeOnly === snapshot.isTypeOnly ? undefined : input.isTypeOnly,\n }\n}\n\nfunction withoutDerived<T extends object>(input: T): T {\n const { [DERIVED]: _, ...rest } = input as T & WithDerived\n return rest as T\n}\n\n/**\n * Creates an `ImportNode`. A node built from `names` also gets the deprecated fields. A deprecated `name` or\n * `isTypeOnly` that differs from the one `names` gives overrides it, so `{ ...imp, isTypeOnly: true }` still works.\n * Fields a spread copies over unchanged are not overrides, so `{ ...imp, names }` uses the new `names`.\n *\n * @example Named import\n * ```ts\n * createImport({ names: [{ name: 'useState' }], path: 'react' })\n * // import { useState } from 'react'\n * ```\n */\nexport function createImport(input: ImportInput): ImportNode {\n if (!input.names) return { ...withoutDerived(input), name: input.name ?? [], kind: nodeKinds.import }\n const own = ownFields(input)\n const derived = toDeprecatedImport(input.names)\n if (isOverride({ value: own.name, derived: derived.name })) return { ...withoutDerived(input), names: null, name: own.name ?? [], kind: nodeKinds.import }\n const names = overrideSpace(input.names, { value: own.isTypeOnly, derived: derived.isTypeOnly })\n const fields = toDeprecatedImport(names)\n const node: ImportNode & WithDerived = {\n ...input,\n ...fields,\n names,\n [DERIVED]: { name: JSON.stringify(fields.name), isTypeOnly: fields.isTypeOnly },\n kind: nodeKinds.import,\n }\n return node\n}\n\n/**\n * Creates an `ExportNode`. A node built from `names` also gets the deprecated fields. A deprecated `name` or\n * `isTypeOnly` that differs from the one `names` gives overrides it. Fields a spread copies over unchanged are not\n * overrides, so `{ ...exp, names }` uses the new `names`.\n *\n * @example Named export\n * ```ts\n * createExport({ names: [{ name: 'Pet' }], path: './Pet' })\n * // export { Pet } from './Pet'\n * ```\n */\nexport function createExport(input: ExportInput): ExportNode {\n if (!input.names) return { ...withoutDerived(input), kind: nodeKinds.export }\n const own = ownFields(input)\n const derived = toDeprecatedExport(input.names)\n if (isOverride({ value: own.name, derived: derived.name })) return { ...withoutDerived(input), name: own.name, names: null, kind: nodeKinds.export }\n const names = overrideSpace(input.names, { value: own.isTypeOnly, derived: derived.isTypeOnly })\n const fields = toDeprecatedExport(names)\n const node: ExportNode & WithDerived = {\n ...input,\n ...fields,\n name: fields.name,\n names,\n [DERIVED]: { name: JSON.stringify(fields.name), isTypeOnly: fields.isTypeOnly },\n kind: nodeKinds.export,\n }\n return node\n}\n\n/**\n * Creates a `SourceNode` representing a fragment of source code within a file.\n *\n * @example\n * ```ts\n * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], export: true })\n * ```\n */\nexport const createSource = nodeFactory<SourceNode>(nodeKinds.source)\n\n/**\n * Input descriptor for {@link createFile}, before `id`, `name`, and `extname` are computed\n * and `imports`/`exports`/`sources` are deduplicated.\n */\nexport type UserFileNode<TMeta extends object = object> = Omit<FileNode<TMeta>, 'kind' | 'id' | 'name' | 'extname' | 'imports' | 'exports' | 'sources'> &\n Pick<Partial<FileNode<TMeta>>, 'imports' | 'exports' | 'sources'>\n\n/**\n * Creates a fully resolved `FileNode` from a file input descriptor.\n *\n * Computes:\n * - `id` SHA256 hash of the file path\n * - `name` `baseName` without extension\n * - `extname` extension extracted from `baseName`\n *\n * Deduplicates:\n * - `sources` via `combineSources`\n * - `exports` via `combineExports`\n * - `imports` via `combineImports` (also filters unused imports)\n *\n * @throws {Error} when `baseName` has no extension.\n *\n * @example\n * ```ts\n * const file = createFile({\n * baseName: 'petStore.ts',\n * path: 'src/models/petStore.ts',\n * sources: [createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')] })],\n * imports: [createImport({ name: ['z'], path: 'zod' })],\n * exports: [createExport({ name: ['Pet'], path: './petStore' })],\n * })\n * // file.id = SHA256 hash of 'src/models/petStore.ts'\n * // file.name = 'petStore'\n * // file.extname = '.ts'\n * ```\n *\n * @example Copy a real file into the output\n * ```ts\n * const file = createFile({\n * baseName: 'client.ts',\n * path: 'src/gen/client.ts',\n * copy: '/abs/path/to/templates/client.ts',\n * })\n * ```\n */\nexport function createFile<TMeta extends object = object>(input: UserFileNode<TMeta>): FileNode<TMeta> {\n const extname = path.extname(input.baseName) as `.${string}`\n if (!extname) {\n throw new Error(`No extname found for ${input.baseName}`)\n }\n\n const resolvedExports = input.exports?.length ? combineExports(input.exports) : []\n const resolvedSources = input.sources?.length ? combineSources(input.sources) : []\n\n // Skip building the source text and local-name set when there are no imports to resolve against them.\n const resolvedImports: Array<ImportNode> = (() => {\n if (!input.imports?.length) return []\n\n const sourceParts: Array<string> = []\n const localNames = new Set<string>()\n // Only the sources the file keeps count: an import used just by a dropped duplicate is unused.\n for (const item of resolvedSources) {\n const extracted = item.nodes && getNodeText(item.nodes)\n if (extracted) sourceParts.push(extracted)\n if (item.name) localNames.add(item.name)\n }\n const source = sourceParts.join('\\n') || undefined\n const combinedImports = combineImports(input.imports, resolvedExports, source)\n // Consolidating output (`mode: 'file'`) can put a symbol's definition and an import of it in the\n // same file: by path when the import still targets this file, by name when consolidation moved it.\n return combinedImports.flatMap((imp) => {\n if (imp.path === input.path) return []\n const names = getNames(imp)\n const kept = names.filter((item) => !localNames.has(item.alias ?? item.name))\n if (!kept.length) return []\n return [kept.length === names.length ? imp : createImport({ path: imp.path, ...(imp.root != null ? { root: imp.root } : {}), names: kept })]\n })\n })()\n\n return {\n ...input,\n kind: nodeKinds.file,\n id: hash('sha256', input.path, 'hex'),\n name: path.basename(input.baseName, extname),\n extname,\n imports: resolvedImports,\n exports: resolvedExports,\n sources: resolvedSources,\n meta: (input.meta ?? {}) as TMeta,\n }\n}\n","/**\n * File-member merging. `combineImports` and `combineExports` deduplicate and sort the import and\n * export entries of one file, while `combineSources` deduplicates source entries in original order.\n * `combineImports` also drops imports nothing references. This works on a file's members, not on\n * schema content.\n */\nimport path from 'node:path'\nimport process from 'node:process'\nimport { memo } from '@internals/utils'\nimport { createExport, createImport, type ExportNode, type ImportNode, type ModuleName, type SourceNode, type Space } from '../nodes/file.ts'\nimport { getNames, getSpace, isExported } from './moduleNames.ts'\n\nconst IDENTIFIER_RUN = /[\\w$]+/g\n\n/**\n * How many imports a file needs before indexing the source beats scanning it once per name.\n */\nconst INDEX_ABOVE_IMPORTS = 128\n\ntype Form = 'named' | 'default' | '*'\n\ntype Statement = { path: string; root?: string | null; form: Form; space: Space; names: Array<ModuleName> }\n\nconst importForm = (item: ModuleName): Form => (item.alias && (item.name === '*' || item.name === 'default') ? item.name : 'named')\nconst exportForm = (item: ModuleName): Form => (item.name === '*' ? '*' : 'named')\nconst label = (item: ModuleName): string => (item.alias ? `${item.name} as ${item.alias}` : item.name)\n\nfunction statementKey({ path, form, space, names }: Statement): string {\n return form === 'named' ? `${path}\\0named\\0${space}` : `${path}\\0${form}\\0${names[0]?.alias ?? ''}\\0${space}`\n}\n\nfunction toStatements(nodes: ReadonlyArray<ImportNode | ExportNode>, formOf: (item: ModuleName) => Form): Array<Statement> {\n return nodes.flatMap((node) => {\n const statements = new Map<string, Statement>()\n for (const item of getNames(node)) {\n const statement: Statement = {\n path: node.path,\n root: node.kind === 'Import' ? node.root : undefined,\n form: formOf(item),\n space: item.space ?? 'value',\n names: [],\n }\n const key = statementKey({ ...statement, names: [item] })\n const existing = statements.get(key) ?? statement\n statements.set(key, existing)\n existing.names.push(item)\n }\n return [...statements.values()]\n })\n}\n\n/**\n * Relative specifiers by `root`, then `path`. `createFile` sorts a file's imports again on every\n * merge, and the path math dominated that sort on large specs. Two levels keep the existing strings\n * as keys, so lookups reuse their hashes instead of hashing a new joined key each time.\n */\nconst specifierCache = memo.create<string, Map<string, string>>({ max: 10_000 })\n\n/**\n * Module specifier that imports `filePath` from the file at `root`: POSIX, relative to that file's directory, `./`-prefixed unless it climbs with `../`.\n *\n * @example\n * ```ts\n * getRelativePath('/root/src/models/pet.ts', '/root/lib/client.ts') // '../../lib/client.ts'\n * ```\n */\nexport function getRelativePath(root: string, filePath: string): string {\n // A relative input resolves against the working directory, so that directory is part of its key.\n const rootKey = path.isAbsolute(root) && path.isAbsolute(filePath) ? root : `${process.cwd()}\\u0000${root}`\n const byPath = memo(specifierCache, rootKey, () => new Map<string, string>())\n return memo(byPath, filePath, () => {\n const relative = path.relative(path.dirname(root), filePath).replaceAll('\\\\', '/')\n return relative.startsWith('../') ? relative : `./${relative}`\n })\n}\n\n/** The specifier a member is written with, so sorting on it gives the same order on every OS. */\nfunction specifier(node: { path: string; root?: string | null }): string {\n return node.root ? getRelativePath(node.root, node.path) : node.path\n}\n\nfunction sortKey(statement: Statement): string {\n const form = statement.form === 'named' ? '1' : '0'\n const space = statement.space === 'type' ? '0' : '1'\n return `${form}:${space}:${specifier(statement)}:${statement.names.map(label).toSorted().join('\\0')}`\n}\n\nfunction mergeStatements(statements: Array<Statement>, keep: (item: ModuleName, statement: Statement) => boolean = () => true): Array<Statement> {\n const merged = new Map<string, { statement: Statement; seen: Set<string> }>()\n const sorted = statements.map((statement) => ({ statement, key: sortKey(statement) })).sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0))\n\n for (const { statement } of sorted) {\n const key = statementKey(statement)\n const entry = merged.get(key) ?? { statement: { ...statement, names: [] }, seen: new Set<string>() }\n merged.set(key, entry)\n for (const item of statement.names) {\n const id = item.alias ?? item.name\n if (entry.seen.has(id) || !keep(item, statement)) continue\n entry.seen.add(id)\n entry.statement.names.push(item)\n }\n }\n\n const result = [...merged.values()].map(({ statement }) => statement)\n // A name kept as a value also serves its type uses, so a type statement from the same path must not bind it again.\n const bound = ({ path, item }: { path: string; item: ModuleName }) => `${path}\\0${item.alias ?? item.name}`\n const values = new Set(result.filter(({ space }) => space === 'value').flatMap(({ path, names }) => names.map((item) => bound({ path, item }))))\n return result\n .map((statement) =>\n statement.space === 'type' ? { ...statement, names: statement.names.filter((item) => !values.has(bound({ path: statement.path, item }))) } : statement,\n )\n .filter((statement) => statement.names.length > 0)\n}\n\n/**\n * Deduplicates `SourceNode` objects by `name + export + space`, keeping the first of each\n * key. An unnamed source only drops when the same node appears twice, so markdown can repeat a\n * paragraph or a table. Returns the deduplicated array in original order.\n */\nexport function combineSources(sources: Array<SourceNode>): Array<SourceNode> {\n const seen = new Set<SourceNode | string>()\n return sources.filter((source) => {\n const key = source.name != null ? `${source.name}:${isExported(source)}:${getSpace(source)}` : source\n if (seen.has(key)) return false\n seen.add(key)\n return true\n })\n}\n\n/**\n * Deduplicates and merges `ExportNode` objects: one export per path, form and space. Returns a sorted array.\n */\nexport function combineExports(exports: Array<ExportNode>): Array<ExportNode> {\n // Built through `createExport`, so a later `{ ...exp, names }` keeps the new names.\n return mergeStatements(toStatements(exports, exportForm)).map(({ path, names }) => createExport({ path, names }))\n}\n\n/**\n * Deduplicates and merges `ImportNode` objects, filtering out unused imports.\n *\n * Retains imports that are referenced in `source` or re-exported. One import per path, form and space. Returns\n * a sorted, deduplicated, filtered array.\n */\nexport function combineImports(imports: Array<ImportNode>, exports: Array<ExportNode>, source?: string): Array<ImportNode> {\n // Build a lookup of all exported names to retain imports that are re-exported\n const exportedNames = new Set(exports.flatMap((node) => getNames(node).map((item) => item.alias ?? item.name)))\n // `createFile` re-runs on every merge into a file, so scanning the source once per import name\n // costs a heavily merged file that scan again for every fragment it already holds. Indexing pays\n // for itself there, and costs more than it saves on the small files the default output produces.\n const identifiers = source && imports.length > INDEX_ABOVE_IMPORTS ? new Set(source.match(IDENTIFIER_RUN)) : null\n\n // A name in the index is used. One that is not still might be, inside a longer identifier, so the\n // substring test stays behind it.\n const isUsed = (importName: string): boolean => !source || identifiers?.has(importName) || source.includes(importName) || exportedNames.has(importName)\n\n const statements = toStatements(\n imports.filter((node) => node.path !== node.root),\n importForm,\n )\n\n // Paths that keep at least one used named import. A default import from such a path is retained\n // even when its binding can't be found in `source` e.g. a generated `client` default import\n // alongside `import type { Client } from <same path>`, where merged grouped output omits the body.\n const pathsWithUsedNamedImport = new Set(\n statements.filter(({ form, names }) => form === 'named' && names.some((item) => isUsed(item.alias ?? item.name))).map(({ path }) => path),\n )\n const keep = (item: ModuleName, { form, path }: Statement) => isUsed(item.alias ?? item.name) || (form !== 'named' && pathsWithUsedNamedImport.has(path))\n\n return mergeStatements(statements, keep).map(({ path, root, names }) => createImport({ path, ...(root != null ? { root } : {}), names }))\n}\n"],"mappings":";;;;;;;;;;;;AAMA,SAAgB,SAAS,MAAkD;CACzE,IAAI,KAAK,OAAO,OAAO,KAAK;CAC5B,OAAO,KAAK,SAAS,WAAW,qBAAqB,IAAI,IAAI,qBAAqB,IAAI;AACxF;;;;AAKA,SAAgB,WAAW,QAA8E;CACvG,OAAO,CAAC,EAAE,OAAO,UAAU,OAAO,eAAe,OAAO;AAC1D;AAEA,SAAgB,SAAS,QAA2B;CAClD,IAAI,OAAO,OAAO,OAAO,OAAO;CAChC,IAAI,OAAO,cAAc,MAAM,OAAO,OAAO,aAAa,SAAS;CACnE,OAAO,OAAO,QAAQ,EAAE,EAAE,SAAS,SAAS,SAAS;AACvD;;;;AAQA,SAAS,qBAAqB,EAAE,MAAM,YAAY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