@hey-api/codegen-core 0.5.4 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +50 -25
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +48 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -13
- package/dist/index.cjs +0 -1759
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -1154
- package/dist/index.d.cts.map +0 -1
package/dist/index.d.cts
DELETED
|
@@ -1,1154 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { MaybeArray, MaybeFunc } from "@hey-api/types";
|
|
3
|
-
import colors from "ansi-colors";
|
|
4
|
-
|
|
5
|
-
//#region src/refs/types.d.ts
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Ref wrapper which ensures a stable reference for a value.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* type NumRef = Ref<number>; // { '~ref': number }
|
|
13
|
-
* const num: NumRef = { '~ref': 42 };
|
|
14
|
-
* console.log(num['~ref']); // 42
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
type Ref<T> = T extends {
|
|
18
|
-
['~ref']: unknown;
|
|
19
|
-
} ? T : {
|
|
20
|
-
'~ref': T;
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Maps every property of `T` to a `Ref` of that property.
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* ```ts
|
|
27
|
-
* type Foo = { a: number; b: string };
|
|
28
|
-
* type Refs = Refs<Foo>; // { a: Ref<number>; b: Ref<string> }
|
|
29
|
-
* const refs: Refs = { a: { '~ref': 1 }, b: { '~ref': 'x' } };
|
|
30
|
-
* console.log(refs.a['~ref'], refs.b['~ref']); // 1 'x'
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
type Refs<T> = { [K in keyof T]: Ref<T[K]> };
|
|
34
|
-
/**
|
|
35
|
-
* Unwraps a Ref to its value type.
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```ts
|
|
39
|
-
* type N = FromRef<{ '~ref': number }>; // number
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
type FromRef<T> = T extends {
|
|
43
|
-
'~ref': infer U;
|
|
44
|
-
} ? U : T;
|
|
45
|
-
/**
|
|
46
|
-
* Maps every property of a Ref-wrapped object back to its plain value.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```ts
|
|
50
|
-
* type Foo = { a: number; b: string };
|
|
51
|
-
* type Refs = Refs<Foo>; // { a: Ref<number>; b: Ref<string> }
|
|
52
|
-
* type Foo2 = FromRefs<Refs>; // { a: number; b: string }
|
|
53
|
-
* ```
|
|
54
|
-
*/
|
|
55
|
-
type FromRefs<T> = { [K in keyof T]: T[K] extends Ref<infer U> ? U : T[K] };
|
|
56
|
-
//#endregion
|
|
57
|
-
//#region src/extensions.d.ts
|
|
58
|
-
/**
|
|
59
|
-
* Arbitrary metadata passed to the project's render function.
|
|
60
|
-
*
|
|
61
|
-
* Implementers should extend this interface for their own needs.
|
|
62
|
-
*/
|
|
63
|
-
interface IProjectRenderMeta {
|
|
64
|
-
[key: string]: unknown;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Additional metadata about the symbol.
|
|
68
|
-
*
|
|
69
|
-
* Implementers should extend this interface for their own needs.
|
|
70
|
-
*/
|
|
71
|
-
interface ISymbolMeta {
|
|
72
|
-
[key: string]: unknown;
|
|
73
|
-
}
|
|
74
|
-
//#endregion
|
|
75
|
-
//#region src/nodes/node.d.ts
|
|
76
|
-
type MaybeRef<T> = T | Ref<T>;
|
|
77
|
-
type NodeName = MaybeRef<Symbol | string | number>;
|
|
78
|
-
type NodeNameSanitizer = (name: string) => string;
|
|
79
|
-
type NodeRelationship = 'container' | 'reference';
|
|
80
|
-
type NodeScope = 'type' | 'value';
|
|
81
|
-
interface INode<T = unknown> {
|
|
82
|
-
/** Perform semantic analysis. */
|
|
83
|
-
analyze(ctx: IAnalysisContext): void;
|
|
84
|
-
/** Create a shallow copy of this node. */
|
|
85
|
-
clone(): this;
|
|
86
|
-
/** Whether this node is exported from its file. */
|
|
87
|
-
exported?: boolean;
|
|
88
|
-
/** The file this node belongs to. */
|
|
89
|
-
file?: File;
|
|
90
|
-
/** The programming language associated with this node */
|
|
91
|
-
language: Language;
|
|
92
|
-
/** The display name of this node. */
|
|
93
|
-
readonly name: Ref<NodeName> & {
|
|
94
|
-
set(value: NodeName): void;
|
|
95
|
-
toString(): string;
|
|
96
|
-
};
|
|
97
|
-
/** Optional function to sanitize the node name. */
|
|
98
|
-
readonly nameSanitizer?: NodeNameSanitizer;
|
|
99
|
-
/** Whether this node is a root node in the file. */
|
|
100
|
-
root?: boolean;
|
|
101
|
-
/** The scope of this node. */
|
|
102
|
-
scope?: NodeScope;
|
|
103
|
-
/** Semantic children in the structure hierarchy. */
|
|
104
|
-
structuralChildren?: Map<INode, NodeRelationship>;
|
|
105
|
-
/** Semantic parents in the structure hierarchy. */
|
|
106
|
-
structuralParents?: Map<INode, NodeRelationship>;
|
|
107
|
-
/** The symbol associated with this node. */
|
|
108
|
-
symbol?: Symbol;
|
|
109
|
-
/** Convert this node into AST representation. */
|
|
110
|
-
toAst(): T;
|
|
111
|
-
/** Brand used for renderer dispatch. */
|
|
112
|
-
readonly '~brand': string;
|
|
113
|
-
}
|
|
114
|
-
//#endregion
|
|
115
|
-
//#region src/symbols/types.d.ts
|
|
116
|
-
type BindingKind = 'default' | 'named' | 'namespace';
|
|
117
|
-
type ISymbolIdentifier = number | ISymbolMeta;
|
|
118
|
-
type SymbolKind = 'class' | 'enum' | 'function' | 'interface' | 'namespace' | 'type' | 'var';
|
|
119
|
-
type ISymbolIn = {
|
|
120
|
-
/**
|
|
121
|
-
* Array of file names (without extensions) from which this symbol is re-exported.
|
|
122
|
-
*
|
|
123
|
-
* @default undefined
|
|
124
|
-
*/
|
|
125
|
-
exportFrom?: ReadonlyArray<string>;
|
|
126
|
-
/**
|
|
127
|
-
* Whether this symbol is exported from its own file.
|
|
128
|
-
*
|
|
129
|
-
* @default false
|
|
130
|
-
*/
|
|
131
|
-
exported?: boolean;
|
|
132
|
-
/**
|
|
133
|
-
* External module name if this symbol is imported from a module not managed
|
|
134
|
-
* by the project (e.g. "zod", "lodash").
|
|
135
|
-
*
|
|
136
|
-
* @default undefined
|
|
137
|
-
*/
|
|
138
|
-
external?: string;
|
|
139
|
-
/**
|
|
140
|
-
* Optional output strategy to override default behavior.
|
|
141
|
-
*
|
|
142
|
-
* @returns The file path to output the symbol to, or undefined to fallback to default behavior.
|
|
143
|
-
*/
|
|
144
|
-
getFilePath?: Symbol['getFilePath'];
|
|
145
|
-
/**
|
|
146
|
-
* Kind of import if this symbol represents an import.
|
|
147
|
-
*
|
|
148
|
-
* @default 'named'
|
|
149
|
-
*/
|
|
150
|
-
importKind?: BindingKind;
|
|
151
|
-
/**
|
|
152
|
-
* Kind of symbol.
|
|
153
|
-
*
|
|
154
|
-
* @default 'var'
|
|
155
|
-
*/
|
|
156
|
-
kind?: SymbolKind;
|
|
157
|
-
/**
|
|
158
|
-
* Arbitrary metadata about the symbol.
|
|
159
|
-
*
|
|
160
|
-
* @default undefined
|
|
161
|
-
*/
|
|
162
|
-
meta?: ISymbolMeta;
|
|
163
|
-
/**
|
|
164
|
-
* The intended, user-facing name of the symbol before any conflict resolution.
|
|
165
|
-
* It is **not** guaranteed to be the final emitted name — aliasing may occur if the
|
|
166
|
-
* file contains conflicting local identifiers or other symbols with the same intended name.
|
|
167
|
-
*
|
|
168
|
-
* @example "UserModel"
|
|
169
|
-
*/
|
|
170
|
-
name: string;
|
|
171
|
-
};
|
|
172
|
-
interface ISymbolRegistry {
|
|
173
|
-
/**
|
|
174
|
-
* Get a symbol.
|
|
175
|
-
*
|
|
176
|
-
* @param identifier Symbol identifier to reference.
|
|
177
|
-
* @returns The symbol, or undefined if not found.
|
|
178
|
-
*/
|
|
179
|
-
get(identifier: ISymbolIdentifier): Symbol | undefined;
|
|
180
|
-
/**
|
|
181
|
-
* Returns whether a symbol is registered in the registry.
|
|
182
|
-
*
|
|
183
|
-
* @param identifier Symbol identifier to check.
|
|
184
|
-
* @returns True if the symbol is registered, false otherwise.
|
|
185
|
-
*/
|
|
186
|
-
isRegistered(identifier: ISymbolIdentifier): boolean;
|
|
187
|
-
/**
|
|
188
|
-
* Returns the current symbol ID and increments it.
|
|
189
|
-
*
|
|
190
|
-
* @returns Symbol ID before being incremented.
|
|
191
|
-
*/
|
|
192
|
-
readonly nextId: number;
|
|
193
|
-
/**
|
|
194
|
-
* Queries symbols by metadata filter.
|
|
195
|
-
*
|
|
196
|
-
* @param filter Metadata filter to query symbols by.
|
|
197
|
-
* @returns Array of symbols matching the filter.
|
|
198
|
-
*/
|
|
199
|
-
query(filter: ISymbolMeta): ReadonlyArray<Symbol>;
|
|
200
|
-
/**
|
|
201
|
-
* References a symbol.
|
|
202
|
-
*
|
|
203
|
-
* @param meta Metadata filter to reference symbol by.
|
|
204
|
-
* @returns The referenced symbol.
|
|
205
|
-
*/
|
|
206
|
-
reference(meta: ISymbolMeta): Symbol;
|
|
207
|
-
/**
|
|
208
|
-
* Register a symbol globally.
|
|
209
|
-
*
|
|
210
|
-
* Deduplicates identical symbols by ID.
|
|
211
|
-
*
|
|
212
|
-
* @param symbol Symbol to register.
|
|
213
|
-
* @returns The registered symbol.
|
|
214
|
-
*/
|
|
215
|
-
register(symbol: ISymbolIn): Symbol;
|
|
216
|
-
/**
|
|
217
|
-
* Get all symbols in the order they were registered.
|
|
218
|
-
*
|
|
219
|
-
* @returns Array of all registered symbols, in insert order.
|
|
220
|
-
*/
|
|
221
|
-
registered(): IterableIterator<Symbol>;
|
|
222
|
-
}
|
|
223
|
-
//#endregion
|
|
224
|
-
//#region src/symbols/symbol.d.ts
|
|
225
|
-
declare class Symbol<Node extends INode = INode> {
|
|
226
|
-
/**
|
|
227
|
-
* Canonical symbol this stub resolves to, if any.
|
|
228
|
-
*
|
|
229
|
-
* Stubs created during DSL construction may later be associated
|
|
230
|
-
* with a fully registered symbol. Once set, all property lookups
|
|
231
|
-
* should defer to the canonical symbol.
|
|
232
|
-
*/
|
|
233
|
-
private _canonical?;
|
|
234
|
-
/**
|
|
235
|
-
* True if this symbol is exported from its defining file.
|
|
236
|
-
*
|
|
237
|
-
* @default false
|
|
238
|
-
*/
|
|
239
|
-
private _exported;
|
|
240
|
-
/**
|
|
241
|
-
* Names of files (without extension) from which this symbol is re-exported.
|
|
242
|
-
*
|
|
243
|
-
* @default []
|
|
244
|
-
*/
|
|
245
|
-
private _exportFrom;
|
|
246
|
-
/**
|
|
247
|
-
* External module name if this symbol is imported from a module not managed
|
|
248
|
-
* by the project (e.g. "zod", "lodash").
|
|
249
|
-
*
|
|
250
|
-
* @default undefined
|
|
251
|
-
*/
|
|
252
|
-
private _external?;
|
|
253
|
-
/**
|
|
254
|
-
* The file this symbol is ultimately emitted into.
|
|
255
|
-
*
|
|
256
|
-
* Only top-level symbols have an assigned file.
|
|
257
|
-
*/
|
|
258
|
-
private _file?;
|
|
259
|
-
/**
|
|
260
|
-
* The alias-resolved, conflict-free emitted name.
|
|
261
|
-
*/
|
|
262
|
-
private _finalName?;
|
|
263
|
-
/**
|
|
264
|
-
* Custom strategy to determine file output path.
|
|
265
|
-
*
|
|
266
|
-
* @returns The file path to output the symbol to, or undefined to fallback to default behavior.
|
|
267
|
-
*/
|
|
268
|
-
private _getFilePath?;
|
|
269
|
-
/**
|
|
270
|
-
* How this symbol should be imported (namespace/default/named).
|
|
271
|
-
*
|
|
272
|
-
* @default 'named'
|
|
273
|
-
*/
|
|
274
|
-
private _importKind;
|
|
275
|
-
/**
|
|
276
|
-
* Kind of symbol (class, type, alias, etc.).
|
|
277
|
-
*
|
|
278
|
-
* @default 'var'
|
|
279
|
-
*/
|
|
280
|
-
private _kind;
|
|
281
|
-
/**
|
|
282
|
-
* Arbitrary user metadata.
|
|
283
|
-
*
|
|
284
|
-
* @default undefined
|
|
285
|
-
*/
|
|
286
|
-
private _meta?;
|
|
287
|
-
/**
|
|
288
|
-
* Intended user-facing name before conflict resolution.
|
|
289
|
-
*
|
|
290
|
-
* @example "UserModel"
|
|
291
|
-
*/
|
|
292
|
-
private _name;
|
|
293
|
-
/**
|
|
294
|
-
* Node that defines this symbol.
|
|
295
|
-
*/
|
|
296
|
-
private _node?;
|
|
297
|
-
/** Brand used for identifying symbols. */
|
|
298
|
-
readonly '~brand' = "heyapi.symbol";
|
|
299
|
-
/** Globally unique, stable symbol ID. */
|
|
300
|
-
readonly id: number;
|
|
301
|
-
constructor(input: ISymbolIn, id: number);
|
|
302
|
-
/**
|
|
303
|
-
* Returns the canonical symbol for this instance.
|
|
304
|
-
*
|
|
305
|
-
* If this symbol was created as a stub, this getter returns
|
|
306
|
-
* the fully registered canonical symbol. Otherwise, it returns
|
|
307
|
-
* the symbol itself.
|
|
308
|
-
*/
|
|
309
|
-
get canonical(): Symbol;
|
|
310
|
-
/**
|
|
311
|
-
* Indicates whether this symbol is exported from its defining file.
|
|
312
|
-
*/
|
|
313
|
-
get exported(): boolean;
|
|
314
|
-
/**
|
|
315
|
-
* Names of files (without extension) that re-export this symbol.
|
|
316
|
-
*/
|
|
317
|
-
get exportFrom(): ReadonlyArray<string>;
|
|
318
|
-
/**
|
|
319
|
-
* External module from which this symbol originates, if any.
|
|
320
|
-
*/
|
|
321
|
-
get external(): string | undefined;
|
|
322
|
-
/**
|
|
323
|
-
* Read‑only accessor for the assigned output file.
|
|
324
|
-
*
|
|
325
|
-
* Only top-level symbols have an assigned file.
|
|
326
|
-
*/
|
|
327
|
-
get file(): File | undefined;
|
|
328
|
-
/**
|
|
329
|
-
* Read‑only accessor for the resolved final emitted name.
|
|
330
|
-
*/
|
|
331
|
-
get finalName(): string;
|
|
332
|
-
/**
|
|
333
|
-
* Custom file path resolver, if provided.
|
|
334
|
-
*/
|
|
335
|
-
get getFilePath(): ((symbol: Symbol) => string | undefined) | undefined;
|
|
336
|
-
/**
|
|
337
|
-
* How this symbol should be imported (named/default/namespace).
|
|
338
|
-
*/
|
|
339
|
-
get importKind(): BindingKind;
|
|
340
|
-
/**
|
|
341
|
-
* Indicates whether this is a canonical symbol (not a stub).
|
|
342
|
-
*/
|
|
343
|
-
get isCanonical(): boolean;
|
|
344
|
-
/**
|
|
345
|
-
* The symbol's kind (class, type, alias, variable, etc.).
|
|
346
|
-
*/
|
|
347
|
-
get kind(): SymbolKind;
|
|
348
|
-
/**
|
|
349
|
-
* Arbitrary user‑provided metadata associated with this symbol.
|
|
350
|
-
*/
|
|
351
|
-
get meta(): ISymbolMeta | undefined;
|
|
352
|
-
/**
|
|
353
|
-
* User-intended name before aliasing or conflict resolution.
|
|
354
|
-
*/
|
|
355
|
-
get name(): string;
|
|
356
|
-
/**
|
|
357
|
-
* Read‑only accessor for the defining node.
|
|
358
|
-
*/
|
|
359
|
-
get node(): Node | undefined;
|
|
360
|
-
/**
|
|
361
|
-
* Marks this symbol as a stub and assigns its canonical symbol.
|
|
362
|
-
*
|
|
363
|
-
* After calling this, all semantic queries (name, kind, file,
|
|
364
|
-
* meta, etc.) should reflect the canonical symbol's values.
|
|
365
|
-
*
|
|
366
|
-
* @param symbol — The canonical symbol this stub should resolve to.
|
|
367
|
-
*/
|
|
368
|
-
setCanonical(symbol: Symbol): void;
|
|
369
|
-
/**
|
|
370
|
-
* Marks the symbol as exported from its file.
|
|
371
|
-
*
|
|
372
|
-
* @param exported — Whether the symbol is exported.
|
|
373
|
-
*/
|
|
374
|
-
setExported(exported: boolean): void;
|
|
375
|
-
/**
|
|
376
|
-
* Records file names that re‑export this symbol.
|
|
377
|
-
*
|
|
378
|
-
* @param list — Source files re‑exporting this symbol.
|
|
379
|
-
*/
|
|
380
|
-
setExportFrom(list: ReadonlyArray<string>): void;
|
|
381
|
-
/**
|
|
382
|
-
* Assigns the output file this symbol will be emitted into.
|
|
383
|
-
*
|
|
384
|
-
* This may only be set once.
|
|
385
|
-
*/
|
|
386
|
-
setFile(file: File): void;
|
|
387
|
-
/**
|
|
388
|
-
* Assigns the conflict‑resolved final local name for this symbol.
|
|
389
|
-
*
|
|
390
|
-
* This may only be set once.
|
|
391
|
-
*/
|
|
392
|
-
setFinalName(name: string): void;
|
|
393
|
-
/**
|
|
394
|
-
* Sets how this symbol should be imported.
|
|
395
|
-
*
|
|
396
|
-
* @param kind — The import strategy (named/default/namespace).
|
|
397
|
-
*/
|
|
398
|
-
setImportKind(kind: BindingKind): void;
|
|
399
|
-
/**
|
|
400
|
-
* Sets the symbol's kind (class, type, alias, variable, etc.).
|
|
401
|
-
*
|
|
402
|
-
* @param kind — The new symbol kind.
|
|
403
|
-
*/
|
|
404
|
-
setKind(kind: SymbolKind): void;
|
|
405
|
-
/**
|
|
406
|
-
* Updates the intended user‑facing name for this symbol.
|
|
407
|
-
*
|
|
408
|
-
* @param name — The new name.
|
|
409
|
-
*/
|
|
410
|
-
setName(name: string): void;
|
|
411
|
-
/**
|
|
412
|
-
* Binds the node that defines this symbol.
|
|
413
|
-
*
|
|
414
|
-
* This may only be set once.
|
|
415
|
-
*/
|
|
416
|
-
setNode(node: Node): void;
|
|
417
|
-
/**
|
|
418
|
-
* Returns a debug‑friendly string representation identifying the symbol.
|
|
419
|
-
*/
|
|
420
|
-
toString(): string;
|
|
421
|
-
/**
|
|
422
|
-
* Ensures this symbol is canonical before allowing mutation.
|
|
423
|
-
*
|
|
424
|
-
* A symbol that has been marked as a stub (i.e., its `_canonical` points
|
|
425
|
-
* to a different symbol) may not be mutated. This guard throws an error
|
|
426
|
-
* if any setter attempts to modify a stub, preventing accidental writes
|
|
427
|
-
* to non‑canonical instances.
|
|
428
|
-
*
|
|
429
|
-
* @throws {Error} If the symbol is a stub and is being mutated.
|
|
430
|
-
*/
|
|
431
|
-
private assertCanonical;
|
|
432
|
-
}
|
|
433
|
-
//#endregion
|
|
434
|
-
//#region src/planner/scope.d.ts
|
|
435
|
-
type NameScopes = Map<string, Set<SymbolKind>>;
|
|
436
|
-
type Scope = {
|
|
437
|
-
/** Child scopes. */
|
|
438
|
-
children: Array<Scope>;
|
|
439
|
-
/** Resolved names in this scope. */
|
|
440
|
-
localNames: NameScopes;
|
|
441
|
-
/** Parent scope, if any. */
|
|
442
|
-
parent?: Scope;
|
|
443
|
-
/** Symbols registered in this scope. */
|
|
444
|
-
symbols: Array<Ref<Symbol>>;
|
|
445
|
-
};
|
|
446
|
-
//#endregion
|
|
447
|
-
//#region src/planner/types.d.ts
|
|
448
|
-
type Input = Ref<object> | object | string | number | undefined;
|
|
449
|
-
type NameConflictResolver = (args: {
|
|
450
|
-
attempt: number;
|
|
451
|
-
baseName: string;
|
|
452
|
-
}) => string | null;
|
|
453
|
-
interface IAnalysisContext {
|
|
454
|
-
/** Register a dependency on another symbol. */
|
|
455
|
-
addDependency(symbol: Ref<Symbol>): void;
|
|
456
|
-
/** Register a dependency on another symbol or analyze further. */
|
|
457
|
-
analyze(input: Input): void;
|
|
458
|
-
/** Get local names in the current scope. */
|
|
459
|
-
localNames(scope: Scope): NameScopes;
|
|
460
|
-
/** Pop the current local scope. */
|
|
461
|
-
popScope(): void;
|
|
462
|
-
/** Push a new local scope. */
|
|
463
|
-
pushScope(): void;
|
|
464
|
-
/** Current local scope. */
|
|
465
|
-
scope: Scope;
|
|
466
|
-
/** Stack of local name scopes. */
|
|
467
|
-
scopes: Scope;
|
|
468
|
-
/** Top-level symbol for the current analysis pass. */
|
|
469
|
-
symbol?: Symbol;
|
|
470
|
-
/** Walks all symbols in the scope tree in depth-first order. */
|
|
471
|
-
walkScopes(callback: (symbol: Ref<Symbol>, scope: Scope) => void, scope?: Scope): void;
|
|
472
|
-
}
|
|
473
|
-
//#endregion
|
|
474
|
-
//#region src/languages/types.d.ts
|
|
475
|
-
type Extensions = Partial<Record<Language, ReadonlyArray<string>>>;
|
|
476
|
-
type Language = 'c' | 'c#' | 'c++' | 'css' | 'dart' | 'go' | 'haskell' | 'html' | 'java' | 'javascript' | 'json' | 'kotlin' | 'lua' | 'markdown' | 'matlab' | 'perl' | 'php' | 'python' | 'r' | 'ruby' | 'rust' | 'scala' | 'shell' | 'sql' | 'swift' | 'typescript' | 'yaml' | (string & {});
|
|
477
|
-
// other/custom language
|
|
478
|
-
|
|
479
|
-
type NameConflictResolvers = Partial<Record<Language, NameConflictResolver>>;
|
|
480
|
-
//#endregion
|
|
481
|
-
//#region src/files/types.d.ts
|
|
482
|
-
type FileKeyArgs = Pick<Required<File>, 'logicalFilePath'> & Pick<Partial<File>, 'external' | 'language'>;
|
|
483
|
-
type IFileIn = {
|
|
484
|
-
/**
|
|
485
|
-
* Indicates whether the file is external, meaning it is not generated
|
|
486
|
-
* as part of the project but is referenced (e.g., a module from
|
|
487
|
-
* node_modules).
|
|
488
|
-
*
|
|
489
|
-
* @example true
|
|
490
|
-
*/
|
|
491
|
-
external?: boolean;
|
|
492
|
-
/**
|
|
493
|
-
* Language of the file.
|
|
494
|
-
*
|
|
495
|
-
* @example "typescript"
|
|
496
|
-
*/
|
|
497
|
-
language?: Language;
|
|
498
|
-
/**
|
|
499
|
-
* Logical, extension-free path used for planning and routing.
|
|
500
|
-
*
|
|
501
|
-
* @example "src/models/user"
|
|
502
|
-
*/
|
|
503
|
-
logicalFilePath: string;
|
|
504
|
-
/**
|
|
505
|
-
* The desired name for the file within the project. If there are multiple files
|
|
506
|
-
* with the same desired name, this might not end up being the actual name.
|
|
507
|
-
*
|
|
508
|
-
* @example "UserModel"
|
|
509
|
-
*/
|
|
510
|
-
name?: string;
|
|
511
|
-
};
|
|
512
|
-
interface IFileRegistry {
|
|
513
|
-
/**
|
|
514
|
-
* Get a file.
|
|
515
|
-
*
|
|
516
|
-
* @returns The file, or undefined if not found.
|
|
517
|
-
*/
|
|
518
|
-
get(args: FileKeyArgs): File | undefined;
|
|
519
|
-
/**
|
|
520
|
-
* Returns whether a file is registered in the registry.
|
|
521
|
-
*
|
|
522
|
-
* @returns True if the file is registered, false otherwise.
|
|
523
|
-
*/
|
|
524
|
-
isRegistered(args: FileKeyArgs): boolean;
|
|
525
|
-
/**
|
|
526
|
-
* Returns the current file ID and increments it.
|
|
527
|
-
*
|
|
528
|
-
* @returns File ID before being incremented
|
|
529
|
-
*/
|
|
530
|
-
readonly nextId: number;
|
|
531
|
-
/**
|
|
532
|
-
* Register a file globally.
|
|
533
|
-
*
|
|
534
|
-
* @param file File to register.
|
|
535
|
-
* @returns Newly registered file if created, merged file otherwise.
|
|
536
|
-
*/
|
|
537
|
-
register(file: IFileIn): File;
|
|
538
|
-
/**
|
|
539
|
-
* Get all files in the order they were registered.
|
|
540
|
-
*
|
|
541
|
-
* @returns Array of all registered files, in insert order.
|
|
542
|
-
*/
|
|
543
|
-
registered(): IterableIterator<File>;
|
|
544
|
-
}
|
|
545
|
-
//#endregion
|
|
546
|
-
//#region src/nodes/types.d.ts
|
|
547
|
-
interface INodeRegistry {
|
|
548
|
-
/**
|
|
549
|
-
* Register a syntax node.
|
|
550
|
-
*
|
|
551
|
-
* @returns The index of the registered node.
|
|
552
|
-
*/
|
|
553
|
-
add(node: INode | null): number;
|
|
554
|
-
/**
|
|
555
|
-
* All nodes in insertion order.
|
|
556
|
-
*/
|
|
557
|
-
all(): Iterable<INode>;
|
|
558
|
-
/**
|
|
559
|
-
* Remove a node by its index.
|
|
560
|
-
*
|
|
561
|
-
* @param index Index of the node to remove.
|
|
562
|
-
*/
|
|
563
|
-
remove(index: number): void;
|
|
564
|
-
/**
|
|
565
|
-
* Update a node at the given index.
|
|
566
|
-
*
|
|
567
|
-
* @param index Index of the node to update.
|
|
568
|
-
* @param node New node to set.
|
|
569
|
-
*/
|
|
570
|
-
update(index: number, node: INode | null): void;
|
|
571
|
-
}
|
|
572
|
-
//#endregion
|
|
573
|
-
//#region src/output.d.ts
|
|
574
|
-
interface IOutput {
|
|
575
|
-
/**
|
|
576
|
-
* The main content of the file to output.
|
|
577
|
-
*
|
|
578
|
-
* A raw string representing source code.
|
|
579
|
-
*
|
|
580
|
-
* @example "function foo(): void {\n // implementation\n}\n"
|
|
581
|
-
*/
|
|
582
|
-
content: string;
|
|
583
|
-
/**
|
|
584
|
-
* Logical output path (used for writing the file).
|
|
585
|
-
*
|
|
586
|
-
* @example "models/user.ts"
|
|
587
|
-
*/
|
|
588
|
-
path: string;
|
|
589
|
-
}
|
|
590
|
-
//#endregion
|
|
591
|
-
//#region src/renderer.d.ts
|
|
592
|
-
interface RenderContext<Node extends INode = INode> {
|
|
593
|
-
/**
|
|
594
|
-
* The current file.
|
|
595
|
-
*/
|
|
596
|
-
file: File<Node>;
|
|
597
|
-
/**
|
|
598
|
-
* Arbitrary metadata.
|
|
599
|
-
*/
|
|
600
|
-
meta?: IProjectRenderMeta;
|
|
601
|
-
/**
|
|
602
|
-
* The project the file belongs to.
|
|
603
|
-
*/
|
|
604
|
-
project: IProject;
|
|
605
|
-
}
|
|
606
|
-
interface Renderer {
|
|
607
|
-
/** Renders the given file. */
|
|
608
|
-
render(ctx: RenderContext): string;
|
|
609
|
-
/** Returns whether this renderer can render the given file. */
|
|
610
|
-
supports(ctx: RenderContext): boolean;
|
|
611
|
-
}
|
|
612
|
-
//#endregion
|
|
613
|
-
//#region src/project/types.d.ts
|
|
614
|
-
/**
|
|
615
|
-
* Represents a code generation project consisting of codegen files.
|
|
616
|
-
*
|
|
617
|
-
* Manages imports, symbols, and output generation across the project.
|
|
618
|
-
*/
|
|
619
|
-
interface IProject {
|
|
620
|
-
/**
|
|
621
|
-
* The default file to assign symbols without a specific file selector.
|
|
622
|
-
*
|
|
623
|
-
* @default 'main'
|
|
624
|
-
*/
|
|
625
|
-
readonly defaultFileName: string;
|
|
626
|
-
/** Default name conflict resolver used when a file has no specific resolver. */
|
|
627
|
-
readonly defaultNameConflictResolver: NameConflictResolver;
|
|
628
|
-
/** Maps language to array of extensions. First element is used by default. */
|
|
629
|
-
readonly extensions: Extensions;
|
|
630
|
-
/**
|
|
631
|
-
* Function to transform file names before they are used.
|
|
632
|
-
*
|
|
633
|
-
* @param name The original file name.
|
|
634
|
-
* @returns The transformed file name.
|
|
635
|
-
*/
|
|
636
|
-
readonly fileName?: (name: string) => string;
|
|
637
|
-
/** Centralized file registry for the project. */
|
|
638
|
-
readonly files: IFileRegistry;
|
|
639
|
-
/** Map of language-specific name conflict resolvers for files in the project. */
|
|
640
|
-
readonly nameConflictResolvers: NameConflictResolvers;
|
|
641
|
-
/** Centralized node registry for the project. */
|
|
642
|
-
readonly nodes: INodeRegistry;
|
|
643
|
-
/**
|
|
644
|
-
* Finalizes the project structure, resolving nodes, symbols, and dependencies.
|
|
645
|
-
*
|
|
646
|
-
* @param meta Arbitrary metadata.
|
|
647
|
-
* @returns void
|
|
648
|
-
*/
|
|
649
|
-
plan(meta?: IProjectRenderMeta): void;
|
|
650
|
-
/**
|
|
651
|
-
* Produces output representations for all files in the project.
|
|
652
|
-
*
|
|
653
|
-
* @param meta Arbitrary metadata.
|
|
654
|
-
* @returns Array of outputs ready for writing or further processing.
|
|
655
|
-
* @example
|
|
656
|
-
* project.render().forEach(output => writeFile(output));
|
|
657
|
-
*/
|
|
658
|
-
render(meta?: IProjectRenderMeta): ReadonlyArray<IOutput>;
|
|
659
|
-
/**
|
|
660
|
-
* List of available renderers.
|
|
661
|
-
*
|
|
662
|
-
* @example
|
|
663
|
-
* [new TypeScriptRenderer()]
|
|
664
|
-
*/
|
|
665
|
-
readonly renderers: ReadonlyArray<Renderer>;
|
|
666
|
-
/** The absolute path to the root folder of the project. */
|
|
667
|
-
readonly root: string;
|
|
668
|
-
/** Centralized symbol registry for the project. */
|
|
669
|
-
readonly symbols: ISymbolRegistry;
|
|
670
|
-
}
|
|
671
|
-
//#endregion
|
|
672
|
-
//#region src/files/file.d.ts
|
|
673
|
-
declare class File<Node extends INode = INode> {
|
|
674
|
-
/**
|
|
675
|
-
* Exports from this file.
|
|
676
|
-
*/
|
|
677
|
-
private _exports;
|
|
678
|
-
/**
|
|
679
|
-
* File extension (e.g. `.ts`).
|
|
680
|
-
*/
|
|
681
|
-
private _extension?;
|
|
682
|
-
/**
|
|
683
|
-
* Actual emitted file path, including extension and directories.
|
|
684
|
-
*/
|
|
685
|
-
private _finalPath?;
|
|
686
|
-
/**
|
|
687
|
-
* Imports to this file.
|
|
688
|
-
*/
|
|
689
|
-
private _imports;
|
|
690
|
-
/**
|
|
691
|
-
* Language of the file.
|
|
692
|
-
*/
|
|
693
|
-
private _language?;
|
|
694
|
-
/**
|
|
695
|
-
* Logical, extension-free path used for planning and routing.
|
|
696
|
-
*/
|
|
697
|
-
private _logicalFilePath;
|
|
698
|
-
/**
|
|
699
|
-
* Base name of the file (without extension).
|
|
700
|
-
*/
|
|
701
|
-
private _name?;
|
|
702
|
-
/**
|
|
703
|
-
* Syntax nodes contained in this file.
|
|
704
|
-
*/
|
|
705
|
-
private _nodes;
|
|
706
|
-
/**
|
|
707
|
-
* Renderer assigned to this file.
|
|
708
|
-
*/
|
|
709
|
-
private _renderer?;
|
|
710
|
-
/** Brand used for identifying files. */
|
|
711
|
-
readonly '~brand' = "heyapi.file";
|
|
712
|
-
/** All names defined in this file, including local scopes. */
|
|
713
|
-
allNames: NameScopes;
|
|
714
|
-
/** Whether this file is external to the project. */
|
|
715
|
-
external: boolean;
|
|
716
|
-
/** Unique identifier for the file. */
|
|
717
|
-
readonly id: number;
|
|
718
|
-
/** The project this file belongs to. */
|
|
719
|
-
readonly project: IProject;
|
|
720
|
-
/** Names declared at the top level of the file. */
|
|
721
|
-
topLevelNames: NameScopes;
|
|
722
|
-
constructor(input: IFileIn, id: number, project: IProject);
|
|
723
|
-
/**
|
|
724
|
-
* Exports from this file.
|
|
725
|
-
*/
|
|
726
|
-
get exports(): ReadonlyArray<ExportModule>;
|
|
727
|
-
/**
|
|
728
|
-
* Read-only accessor for the file extension.
|
|
729
|
-
*/
|
|
730
|
-
get extension(): string | undefined;
|
|
731
|
-
/**
|
|
732
|
-
* Read-only accessor for the final emitted path.
|
|
733
|
-
*
|
|
734
|
-
* If undefined, the file has not yet been assigned a final path
|
|
735
|
-
* or is external to the project and should not be emitted.
|
|
736
|
-
*/
|
|
737
|
-
get finalPath(): string | undefined;
|
|
738
|
-
/**
|
|
739
|
-
* Imports to this file.
|
|
740
|
-
*/
|
|
741
|
-
get imports(): ReadonlyArray<ImportModule>;
|
|
742
|
-
/**
|
|
743
|
-
* Language of the file; inferred from nodes or fallback if not set explicitly.
|
|
744
|
-
*/
|
|
745
|
-
get language(): Language | undefined;
|
|
746
|
-
/**
|
|
747
|
-
* Logical, extension-free path used for planning and routing.
|
|
748
|
-
*/
|
|
749
|
-
get logicalFilePath(): string;
|
|
750
|
-
/**
|
|
751
|
-
* Base name of the file (without extension).
|
|
752
|
-
*
|
|
753
|
-
* If no name was set explicitly, it is inferred from the logical file path.
|
|
754
|
-
*/
|
|
755
|
-
get name(): string;
|
|
756
|
-
/**
|
|
757
|
-
* Syntax nodes contained in this file.
|
|
758
|
-
*/
|
|
759
|
-
get nodes(): ReadonlyArray<Node>;
|
|
760
|
-
/**
|
|
761
|
-
* Renderer assigned to this file.
|
|
762
|
-
*/
|
|
763
|
-
get renderer(): Renderer | undefined;
|
|
764
|
-
/**
|
|
765
|
-
* Add an export group to the file.
|
|
766
|
-
*/
|
|
767
|
-
addExport(group: ExportModule): void;
|
|
768
|
-
/**
|
|
769
|
-
* Add an import group to the file.
|
|
770
|
-
*/
|
|
771
|
-
addImport(group: ImportModule): void;
|
|
772
|
-
/**
|
|
773
|
-
* Add a syntax node to the file.
|
|
774
|
-
*/
|
|
775
|
-
addNode(node: Node): void;
|
|
776
|
-
/**
|
|
777
|
-
* Sets the file extension.
|
|
778
|
-
*/
|
|
779
|
-
setExtension(extension: string): void;
|
|
780
|
-
/**
|
|
781
|
-
* Sets the final emitted path of the file.
|
|
782
|
-
*/
|
|
783
|
-
setFinalPath(path: string): void;
|
|
784
|
-
/**
|
|
785
|
-
* Sets the language of the file.
|
|
786
|
-
*/
|
|
787
|
-
setLanguage(lang: Language): void;
|
|
788
|
-
/**
|
|
789
|
-
* Sets the name of the file.
|
|
790
|
-
*/
|
|
791
|
-
setName(name: string): void;
|
|
792
|
-
/**
|
|
793
|
-
* Sets the renderer assigned to this file.
|
|
794
|
-
*/
|
|
795
|
-
setRenderer(renderer: Renderer): void;
|
|
796
|
-
/**
|
|
797
|
-
* Returns a debug‑friendly string representation identifying the file.
|
|
798
|
-
*/
|
|
799
|
-
toString(): string;
|
|
800
|
-
}
|
|
801
|
-
//#endregion
|
|
802
|
-
//#region src/bindings.d.ts
|
|
803
|
-
interface ExportMember {
|
|
804
|
-
/**
|
|
805
|
-
* Name under which the symbol is exported in this file.
|
|
806
|
-
*
|
|
807
|
-
* export { Foo as Bar } from "./models"
|
|
808
|
-
*
|
|
809
|
-
* exportedName === "Bar"
|
|
810
|
-
*/
|
|
811
|
-
exportedName: string;
|
|
812
|
-
/** Whether this export is type-only. */
|
|
813
|
-
isTypeOnly: boolean;
|
|
814
|
-
/** Export flavor. */
|
|
815
|
-
kind: BindingKind;
|
|
816
|
-
/** The exported name of the symbol in its source file. */
|
|
817
|
-
sourceName: string;
|
|
818
|
-
}
|
|
819
|
-
type ExportModule = Pick<ExportMember, 'isTypeOnly'> & {
|
|
820
|
-
/** Whether this module can export all symbols: `export * from 'module'`. */
|
|
821
|
-
canExportAll: boolean;
|
|
822
|
-
/** Members exported from this module. */
|
|
823
|
-
exports: Array<ExportMember>;
|
|
824
|
-
/** Source file. */
|
|
825
|
-
from: File;
|
|
826
|
-
/** Namespace export: `export * as ns from 'module'`. Mutually exclusive with `exports`. */
|
|
827
|
-
namespaceExport?: string;
|
|
828
|
-
};
|
|
829
|
-
interface ImportMember {
|
|
830
|
-
/** Whether this import is type-only. */
|
|
831
|
-
isTypeOnly: boolean;
|
|
832
|
-
/**
|
|
833
|
-
* The name this symbol will have locally in this file.
|
|
834
|
-
* This is where aliasing is applied:
|
|
835
|
-
*
|
|
836
|
-
* import { Foo as Foo$2 } from "./x"
|
|
837
|
-
*
|
|
838
|
-
* localName === "Foo$2"
|
|
839
|
-
*/
|
|
840
|
-
localName: string;
|
|
841
|
-
/** The exported name of the symbol in its source file. */
|
|
842
|
-
sourceName: string;
|
|
843
|
-
}
|
|
844
|
-
type ImportModule = Pick<ImportMember, 'isTypeOnly'> & Pick<Partial<ImportMember>, 'localName'> & {
|
|
845
|
-
/** Source file. */
|
|
846
|
-
from: File;
|
|
847
|
-
/** List of symbols imported from this module. */
|
|
848
|
-
imports: Array<ImportMember>;
|
|
849
|
-
/** Import flavor. */
|
|
850
|
-
kind: BindingKind;
|
|
851
|
-
};
|
|
852
|
-
//#endregion
|
|
853
|
-
//#region src/brands.d.ts
|
|
854
|
-
declare const nodeBrand = "heyapi.node";
|
|
855
|
-
declare const symbolBrand = "heyapi.symbol";
|
|
856
|
-
//#endregion
|
|
857
|
-
//#region src/guards.d.ts
|
|
858
|
-
declare function isNode(value: unknown): value is INode;
|
|
859
|
-
declare function isNodeRef(value: Ref<unknown>): value is Ref<INode>;
|
|
860
|
-
declare function isSymbol(value: unknown): value is Symbol;
|
|
861
|
-
declare function isSymbolRef(value: Ref<unknown>): value is Ref<Symbol>;
|
|
862
|
-
//#endregion
|
|
863
|
-
//#region src/languages/extensions.d.ts
|
|
864
|
-
declare const defaultExtensions: Extensions;
|
|
865
|
-
//#endregion
|
|
866
|
-
//#region src/languages/resolvers.d.ts
|
|
867
|
-
declare const defaultNameConflictResolvers: NameConflictResolvers;
|
|
868
|
-
//#endregion
|
|
869
|
-
//#region src/log.d.ts
|
|
870
|
-
declare const DebugGroups: {
|
|
871
|
-
readonly analyzer: colors.StyleFunction;
|
|
872
|
-
readonly dsl: colors.StyleFunction;
|
|
873
|
-
readonly file: colors.StyleFunction;
|
|
874
|
-
readonly registry: colors.StyleFunction;
|
|
875
|
-
readonly symbol: colors.StyleFunction;
|
|
876
|
-
};
|
|
877
|
-
declare const WarnGroups: {
|
|
878
|
-
readonly deprecated: colors.StyleFunction;
|
|
879
|
-
};
|
|
880
|
-
declare function debug(message: string, group: keyof typeof DebugGroups): void;
|
|
881
|
-
declare function warn(message: string, group: keyof typeof WarnGroups): void;
|
|
882
|
-
declare function warnDeprecated({
|
|
883
|
-
context,
|
|
884
|
-
field,
|
|
885
|
-
replacement
|
|
886
|
-
}: {
|
|
887
|
-
context?: string;
|
|
888
|
-
field: string;
|
|
889
|
-
replacement?: MaybeFunc<(field: string) => MaybeArray<string>>;
|
|
890
|
-
}): void;
|
|
891
|
-
declare const log: {
|
|
892
|
-
debug: typeof debug;
|
|
893
|
-
warn: typeof warn;
|
|
894
|
-
warnDeprecated: typeof warnDeprecated;
|
|
895
|
-
};
|
|
896
|
-
//#endregion
|
|
897
|
-
//#region src/logger.d.ts
|
|
898
|
-
declare class Logger {
|
|
899
|
-
private events;
|
|
900
|
-
private end;
|
|
901
|
-
/**
|
|
902
|
-
* Recursively end all unended events in the event tree.
|
|
903
|
-
* This ensures all events have end marks before measuring.
|
|
904
|
-
*/
|
|
905
|
-
private endAllEvents;
|
|
906
|
-
report(print?: boolean): PerformanceMeasure | undefined;
|
|
907
|
-
private reportEvent;
|
|
908
|
-
private start;
|
|
909
|
-
private storeEvent;
|
|
910
|
-
timeEvent(name: string): {
|
|
911
|
-
mark: PerformanceMark;
|
|
912
|
-
timeEnd: () => void;
|
|
913
|
-
};
|
|
914
|
-
}
|
|
915
|
-
//#endregion
|
|
916
|
-
//#region src/planner/resolvers.d.ts
|
|
917
|
-
declare const simpleNameConflictResolver: NameConflictResolver;
|
|
918
|
-
declare const underscoreNameConflictResolver: NameConflictResolver;
|
|
919
|
-
//#endregion
|
|
920
|
-
//#region src/files/registry.d.ts
|
|
921
|
-
type FileId = number;
|
|
922
|
-
declare class FileRegistry implements IFileRegistry {
|
|
923
|
-
private _id;
|
|
924
|
-
private _values;
|
|
925
|
-
private readonly project;
|
|
926
|
-
constructor(project: IProject);
|
|
927
|
-
get(args: FileKeyArgs): File | undefined;
|
|
928
|
-
isRegistered(args: FileKeyArgs): boolean;
|
|
929
|
-
get nextId(): FileId;
|
|
930
|
-
register(file: IFileIn): File;
|
|
931
|
-
registered(): IterableIterator<File>;
|
|
932
|
-
private createFileKey;
|
|
933
|
-
}
|
|
934
|
-
//#endregion
|
|
935
|
-
//#region src/nodes/registry.d.ts
|
|
936
|
-
declare class NodeRegistry implements INodeRegistry {
|
|
937
|
-
private list;
|
|
938
|
-
add(node: INode | null): number;
|
|
939
|
-
all(): Iterable<INode>;
|
|
940
|
-
remove(index: number): void;
|
|
941
|
-
update(index: number, node: INode | null): void;
|
|
942
|
-
}
|
|
943
|
-
//#endregion
|
|
944
|
-
//#region src/symbols/registry.d.ts
|
|
945
|
-
type SymbolId = number;
|
|
946
|
-
declare class SymbolRegistry implements ISymbolRegistry {
|
|
947
|
-
private _id;
|
|
948
|
-
private _indices;
|
|
949
|
-
private _queryCache;
|
|
950
|
-
private _queryCacheDependencies;
|
|
951
|
-
private _registered;
|
|
952
|
-
private _stubs;
|
|
953
|
-
private _stubCache;
|
|
954
|
-
private _values;
|
|
955
|
-
get(identifier: ISymbolIdentifier): Symbol | undefined;
|
|
956
|
-
isRegistered(identifier: ISymbolIdentifier): boolean;
|
|
957
|
-
get nextId(): SymbolId;
|
|
958
|
-
query(filter: ISymbolMeta): ReadonlyArray<Symbol>;
|
|
959
|
-
reference(meta: ISymbolMeta): Symbol;
|
|
960
|
-
register(symbol: ISymbolIn): Symbol;
|
|
961
|
-
registered(): IterableIterator<Symbol>;
|
|
962
|
-
private buildCacheKey;
|
|
963
|
-
private buildIndexKeySpace;
|
|
964
|
-
private indexSymbol;
|
|
965
|
-
private invalidateCache;
|
|
966
|
-
private isSubset;
|
|
967
|
-
private replaceStubs;
|
|
968
|
-
private serializeIndexEntry;
|
|
969
|
-
}
|
|
970
|
-
//#endregion
|
|
971
|
-
//#region src/project/project.d.ts
|
|
972
|
-
declare class Project implements IProject {
|
|
973
|
-
private _isPlanned;
|
|
974
|
-
readonly files: FileRegistry;
|
|
975
|
-
readonly nodes: NodeRegistry;
|
|
976
|
-
readonly symbols: SymbolRegistry;
|
|
977
|
-
readonly defaultFileName: string;
|
|
978
|
-
readonly defaultNameConflictResolver: NameConflictResolver;
|
|
979
|
-
readonly extensions: Extensions;
|
|
980
|
-
readonly fileName?: (name: string) => string;
|
|
981
|
-
readonly nameConflictResolvers: NameConflictResolvers;
|
|
982
|
-
readonly renderers: ReadonlyArray<Renderer>;
|
|
983
|
-
readonly root: string;
|
|
984
|
-
constructor(args: Pick<Partial<IProject>, 'defaultFileName' | 'defaultNameConflictResolver' | 'extensions' | 'fileName' | 'nameConflictResolvers' | 'renderers'> & Pick<IProject, 'root'>);
|
|
985
|
-
plan(meta?: IProjectRenderMeta): void;
|
|
986
|
-
render(meta?: IProjectRenderMeta): ReadonlyArray<IOutput>;
|
|
987
|
-
}
|
|
988
|
-
//#endregion
|
|
989
|
-
//#region src/refs/refs.d.ts
|
|
990
|
-
/**
|
|
991
|
-
* Wraps a single value in a Ref object.
|
|
992
|
-
*
|
|
993
|
-
* If the value is already a Ref, returns it as-is (idempotent).
|
|
994
|
-
*
|
|
995
|
-
* @example
|
|
996
|
-
* ```ts
|
|
997
|
-
* const r = ref(123); // { '~ref': 123 }
|
|
998
|
-
* console.log(r['~ref']); // 123
|
|
999
|
-
*
|
|
1000
|
-
* const r2 = ref(r); // { '~ref': 123 } (not double-wrapped)
|
|
1001
|
-
* ```
|
|
1002
|
-
*/
|
|
1003
|
-
declare const ref: <T>(value: T) => Ref<T>;
|
|
1004
|
-
/**
|
|
1005
|
-
* Converts a plain object to an object of Refs (deep, per property).
|
|
1006
|
-
*
|
|
1007
|
-
* @example
|
|
1008
|
-
* ```ts
|
|
1009
|
-
* const obj = { a: 1, b: "x" };
|
|
1010
|
-
* const refs = refs(obj); // { a: { '~ref': 1 }, b: { '~ref': "x" } }
|
|
1011
|
-
* ```
|
|
1012
|
-
*/
|
|
1013
|
-
declare const refs: <T extends Record<string, unknown>>(obj: T) => Refs<T>;
|
|
1014
|
-
/**
|
|
1015
|
-
* Unwraps a single Ref object to its value.
|
|
1016
|
-
*
|
|
1017
|
-
* @example
|
|
1018
|
-
* ```ts
|
|
1019
|
-
* const r = { '~ref': 42 };
|
|
1020
|
-
* const n = fromRef(r); // 42
|
|
1021
|
-
* console.log(n); // 42
|
|
1022
|
-
* ```
|
|
1023
|
-
*/
|
|
1024
|
-
declare const fromRef: <T extends Ref<unknown> | undefined>(ref: T) => FromRef<T>;
|
|
1025
|
-
/**
|
|
1026
|
-
* Converts an object of Refs back to a plain object (unwraps all refs).
|
|
1027
|
-
*
|
|
1028
|
-
* @example
|
|
1029
|
-
* ```ts
|
|
1030
|
-
* const refs = { a: { '~ref': 1 }, b: { '~ref': "x" } };
|
|
1031
|
-
* const plain = fromRefs(refs); // { a: 1, b: "x" }
|
|
1032
|
-
* ```
|
|
1033
|
-
*/
|
|
1034
|
-
declare const fromRefs: <T extends Refs<Record<string, unknown>>>(obj: T) => FromRefs<T>;
|
|
1035
|
-
/**
|
|
1036
|
-
* Checks whether a value is a Ref object.
|
|
1037
|
-
*
|
|
1038
|
-
* @param value Value to check
|
|
1039
|
-
* @returns True if the value is a Ref object.
|
|
1040
|
-
*/
|
|
1041
|
-
declare const isRef: <T>(value: unknown) => value is Ref<T>;
|
|
1042
|
-
//#endregion
|
|
1043
|
-
//#region src/structure/types.d.ts
|
|
1044
|
-
interface StructureInsert {
|
|
1045
|
-
/** Inserted data. */
|
|
1046
|
-
data: unknown;
|
|
1047
|
-
/** Locations where the data should be inserted. */
|
|
1048
|
-
locations: ReadonlyArray<StructureLocation>;
|
|
1049
|
-
/** Source of the inserted data. */
|
|
1050
|
-
source: symbol;
|
|
1051
|
-
}
|
|
1052
|
-
interface StructureItem extends Pick<StructureInsert, 'data' | 'source'> {
|
|
1053
|
-
/** Location of this item within the structure. */
|
|
1054
|
-
location: ReadonlyArray<string>;
|
|
1055
|
-
}
|
|
1056
|
-
interface StructureLocation {
|
|
1057
|
-
/** Path within the structure where the data should be inserted. */
|
|
1058
|
-
path: ReadonlyArray<string>;
|
|
1059
|
-
/** Shell to apply at this location. */
|
|
1060
|
-
shell?: StructureShell;
|
|
1061
|
-
}
|
|
1062
|
-
interface StructureShell {
|
|
1063
|
-
define: (node: StructureNode) => StructureShellResult;
|
|
1064
|
-
}
|
|
1065
|
-
interface StructureShellResult {
|
|
1066
|
-
dependencies?: Array<INode>;
|
|
1067
|
-
node: INode;
|
|
1068
|
-
}
|
|
1069
|
-
//#endregion
|
|
1070
|
-
//#region src/structure/node.d.ts
|
|
1071
|
-
declare class StructureNode {
|
|
1072
|
-
/** Nested nodes within this node. */
|
|
1073
|
-
children: Map<string, StructureNode>;
|
|
1074
|
-
/** Items contained in this node. */
|
|
1075
|
-
items: Array<StructureItem>;
|
|
1076
|
-
/** The name of this node (e.g., "Users", "Accounts"). */
|
|
1077
|
-
name: string;
|
|
1078
|
-
/** Parent node in the hierarchy. Undefined if this is the root node. */
|
|
1079
|
-
parent?: StructureNode;
|
|
1080
|
-
/** Shell claimed for this node. */
|
|
1081
|
-
shell?: StructureShell;
|
|
1082
|
-
/** Source of the claimed shell. */
|
|
1083
|
-
shellSource?: symbol;
|
|
1084
|
-
/** True if this is a virtual root. */
|
|
1085
|
-
virtual: boolean;
|
|
1086
|
-
constructor(name: string, parent?: StructureNode, options?: {
|
|
1087
|
-
virtual?: boolean;
|
|
1088
|
-
});
|
|
1089
|
-
get isRoot(): boolean;
|
|
1090
|
-
/**
|
|
1091
|
-
* Gets or creates a child node.
|
|
1092
|
-
*
|
|
1093
|
-
* If the child doesn't exist, it's created automatically.
|
|
1094
|
-
*
|
|
1095
|
-
* @param name - The name of the child node
|
|
1096
|
-
* @returns The child node instance
|
|
1097
|
-
*/
|
|
1098
|
-
child(name: string): StructureNode;
|
|
1099
|
-
/**
|
|
1100
|
-
* Gets the full path of this node in the hierarchy.
|
|
1101
|
-
*
|
|
1102
|
-
* @returns An array of node names from the root to this node
|
|
1103
|
-
*/
|
|
1104
|
-
getPath(): ReadonlyArray<string>;
|
|
1105
|
-
/**
|
|
1106
|
-
* Yields items from a specific source with typed data.
|
|
1107
|
-
*
|
|
1108
|
-
* @param source - The source symbol to filter by
|
|
1109
|
-
* @returns Generator of items from that source
|
|
1110
|
-
*/
|
|
1111
|
-
itemsFrom<T = unknown>(source: symbol): Generator<StructureItem & {
|
|
1112
|
-
data: T;
|
|
1113
|
-
}>;
|
|
1114
|
-
/**
|
|
1115
|
-
* Walk all nodes in the structure (depth-first, post-order).
|
|
1116
|
-
*
|
|
1117
|
-
* @returns Generator of all structure nodes
|
|
1118
|
-
*/
|
|
1119
|
-
walk(): Generator<StructureNode>;
|
|
1120
|
-
}
|
|
1121
|
-
//#endregion
|
|
1122
|
-
//#region src/structure/model.d.ts
|
|
1123
|
-
declare class StructureModel {
|
|
1124
|
-
/** Root nodes mapped by their names. */
|
|
1125
|
-
private _roots;
|
|
1126
|
-
/** Node for data without a specific root. */
|
|
1127
|
-
private _virtualRoot?;
|
|
1128
|
-
/**
|
|
1129
|
-
* Get all root nodes.
|
|
1130
|
-
*/
|
|
1131
|
-
get roots(): ReadonlyArray<StructureNode>;
|
|
1132
|
-
/**
|
|
1133
|
-
* Insert data into the structure.
|
|
1134
|
-
*/
|
|
1135
|
-
insert(args: StructureInsert): void;
|
|
1136
|
-
/**
|
|
1137
|
-
* Gets or creates a root by name.
|
|
1138
|
-
*
|
|
1139
|
-
* If the root doesn't exist, it's created automatically.
|
|
1140
|
-
*
|
|
1141
|
-
* @param name - The name of the root
|
|
1142
|
-
* @returns The root instance
|
|
1143
|
-
*/
|
|
1144
|
-
root(name: string | null): StructureNode;
|
|
1145
|
-
/**
|
|
1146
|
-
* Walk all nodes in the structure (depth-first, post-order).
|
|
1147
|
-
*
|
|
1148
|
-
* @returns Generator of all structure nodes
|
|
1149
|
-
*/
|
|
1150
|
-
walk(): Generator<StructureNode>;
|
|
1151
|
-
}
|
|
1152
|
-
//#endregion
|
|
1153
|
-
export { type IAnalysisContext as AnalysisContext, type BindingKind, type ExportMember, type ExportModule, type Extensions, File, type IFileIn as FileIn, type FromRef, type FromRefs, type IProject, type ImportMember, type ImportModule, type Language, Logger, type NameConflictResolver, type NameConflictResolvers, type INode as Node, type NodeName, type NodeNameSanitizer, type NodeRelationship, type NodeScope, type IOutput as Output, Project, type IProjectRenderMeta as ProjectRenderMeta, type Ref, type Refs, type RenderContext, type Renderer, type StructureInsert, type StructureItem, type StructureLocation, StructureModel, StructureNode, type StructureShell, type StructureShellResult, Symbol, type ISymbolIdentifier as SymbolIdentifier, type ISymbolIn as SymbolIn, type ISymbolMeta as SymbolMeta, defaultExtensions, defaultNameConflictResolvers, fromRef, fromRefs, isNode, isNodeRef, isRef, isSymbol, isSymbolRef, log, nodeBrand, ref, refs, simpleNameConflictResolver, symbolBrand, underscoreNameConflictResolver };
|
|
1154
|
-
//# sourceMappingURL=index.d.cts.map
|