@hey-api/codegen-core 0.4.0 → 0.5.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/README.md +3 -123
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +214 -55
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +214 -55
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
import colors from "ansi-colors";
|
|
2
3
|
|
|
3
4
|
//#region src/refs/types.d.ts
|
|
@@ -12,7 +13,9 @@ import colors from "ansi-colors";
|
|
|
12
13
|
* console.log(num['~ref']); // 42
|
|
13
14
|
* ```
|
|
14
15
|
*/
|
|
15
|
-
type Ref<T> = {
|
|
16
|
+
type Ref<T> = T extends {
|
|
17
|
+
['~ref']: unknown;
|
|
18
|
+
} ? T : {
|
|
16
19
|
'~ref': T;
|
|
17
20
|
};
|
|
18
21
|
/**
|
|
@@ -35,7 +38,9 @@ type Refs<T> = { [K in keyof T]: Ref<T[K]> };
|
|
|
35
38
|
* type N = FromRef<{ '~ref': number }>; // number
|
|
36
39
|
* ```
|
|
37
40
|
*/
|
|
38
|
-
type FromRef<T> = T extends
|
|
41
|
+
type FromRef<T> = T extends {
|
|
42
|
+
'~ref': infer U;
|
|
43
|
+
} ? U : T;
|
|
39
44
|
/**
|
|
40
45
|
* Maps every property of a Ref-wrapped object back to its plain value.
|
|
41
46
|
*
|
|
@@ -46,7 +51,7 @@ type FromRef<T> = T extends Ref<infer V> ? V : T;
|
|
|
46
51
|
* type Foo2 = FromRefs<Refs>; // { a: number; b: string }
|
|
47
52
|
* ```
|
|
48
53
|
*/
|
|
49
|
-
type FromRefs<T> = { [K in keyof T]: T[K] extends Ref<infer
|
|
54
|
+
type FromRefs<T> = { [K in keyof T]: T[K] extends Ref<infer U> ? U : T[K] };
|
|
50
55
|
//#endregion
|
|
51
56
|
//#region src/extensions.d.ts
|
|
52
57
|
/**
|
|
@@ -67,19 +72,37 @@ interface ISymbolMeta {
|
|
|
67
72
|
}
|
|
68
73
|
//#endregion
|
|
69
74
|
//#region src/nodes/node.d.ts
|
|
75
|
+
type MaybeRef<T> = T | Ref<T>;
|
|
76
|
+
type NodeName = MaybeRef<Symbol | string | number>;
|
|
77
|
+
type NodeNameSanitizer = (name: string) => string;
|
|
78
|
+
type NodeRelationship = 'container' | 'reference';
|
|
79
|
+
type NodeScope = 'type' | 'value';
|
|
70
80
|
interface INode<T = unknown> {
|
|
71
81
|
/** Perform semantic analysis. */
|
|
72
82
|
analyze(ctx: IAnalysisContext): void;
|
|
83
|
+
/** Create a shallow copy of this node. */
|
|
84
|
+
clone(): this;
|
|
73
85
|
/** Whether this node is exported from its file. */
|
|
74
86
|
exported?: boolean;
|
|
75
87
|
/** The file this node belongs to. */
|
|
76
88
|
file?: File;
|
|
77
89
|
/** The programming language associated with this node */
|
|
78
90
|
language: Language;
|
|
79
|
-
/**
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
91
|
+
/** The display name of this node. */
|
|
92
|
+
readonly name: Ref<NodeName> & {
|
|
93
|
+
set(value: NodeName): void;
|
|
94
|
+
toString(): string;
|
|
95
|
+
};
|
|
96
|
+
/** Optional function to sanitize the node name. */
|
|
97
|
+
readonly nameSanitizer?: NodeNameSanitizer;
|
|
98
|
+
/** Whether this node is a root node in the file. */
|
|
99
|
+
root?: boolean;
|
|
100
|
+
/** The scope of this node. */
|
|
101
|
+
scope?: NodeScope;
|
|
102
|
+
/** Semantic children in the structure hierarchy. */
|
|
103
|
+
structuralChildren?: Map<INode, NodeRelationship>;
|
|
104
|
+
/** Semantic parents in the structure hierarchy. */
|
|
105
|
+
structuralParents?: Map<INode, NodeRelationship>;
|
|
83
106
|
/** The symbol associated with this node. */
|
|
84
107
|
symbol?: Symbol;
|
|
85
108
|
/** Convert this node into AST representation. */
|
|
@@ -92,7 +115,6 @@ interface INode<T = unknown> {
|
|
|
92
115
|
type BindingKind = 'default' | 'named' | 'namespace';
|
|
93
116
|
type ISymbolIdentifier = number | ISymbolMeta;
|
|
94
117
|
type SymbolKind = 'class' | 'enum' | 'function' | 'interface' | 'namespace' | 'type' | 'var';
|
|
95
|
-
type SymbolNameSanitizer = (name: string) => string;
|
|
96
118
|
type ISymbolIn = {
|
|
97
119
|
/**
|
|
98
120
|
* Array of file names (without extensions) from which this symbol is re-exported.
|
|
@@ -121,10 +143,14 @@ type ISymbolIn = {
|
|
|
121
143
|
getFilePath?: Symbol['getFilePath'];
|
|
122
144
|
/**
|
|
123
145
|
* Kind of import if this symbol represents an import.
|
|
146
|
+
*
|
|
147
|
+
* @default 'named'
|
|
124
148
|
*/
|
|
125
149
|
importKind?: BindingKind;
|
|
126
150
|
/**
|
|
127
151
|
* Kind of symbol.
|
|
152
|
+
*
|
|
153
|
+
* @default 'var'
|
|
128
154
|
*/
|
|
129
155
|
kind?: SymbolKind;
|
|
130
156
|
/**
|
|
@@ -195,7 +221,7 @@ interface ISymbolRegistry {
|
|
|
195
221
|
}
|
|
196
222
|
//#endregion
|
|
197
223
|
//#region src/symbols/symbol.d.ts
|
|
198
|
-
declare class Symbol {
|
|
224
|
+
declare class Symbol<Node extends INode = INode> {
|
|
199
225
|
/**
|
|
200
226
|
* Canonical symbol this stub resolves to, if any.
|
|
201
227
|
*
|
|
@@ -263,12 +289,6 @@ declare class Symbol {
|
|
|
263
289
|
* @example "UserModel"
|
|
264
290
|
*/
|
|
265
291
|
private _name;
|
|
266
|
-
/**
|
|
267
|
-
* Optional function to sanitize the symbol name.
|
|
268
|
-
*
|
|
269
|
-
* @default undefined
|
|
270
|
-
*/
|
|
271
|
-
private _nameSanitizer?;
|
|
272
292
|
/**
|
|
273
293
|
* Node that defines this symbol.
|
|
274
294
|
*/
|
|
@@ -332,14 +352,10 @@ declare class Symbol {
|
|
|
332
352
|
* User-intended name before aliasing or conflict resolution.
|
|
333
353
|
*/
|
|
334
354
|
get name(): string;
|
|
335
|
-
/**
|
|
336
|
-
* Optional function to sanitize the symbol name.
|
|
337
|
-
*/
|
|
338
|
-
get nameSanitizer(): SymbolNameSanitizer | undefined;
|
|
339
355
|
/**
|
|
340
356
|
* Read‑only accessor for the defining node.
|
|
341
357
|
*/
|
|
342
|
-
get node():
|
|
358
|
+
get node(): Node | undefined;
|
|
343
359
|
/**
|
|
344
360
|
* Marks this symbol as a stub and assigns its canonical symbol.
|
|
345
361
|
*
|
|
@@ -391,18 +407,12 @@ declare class Symbol {
|
|
|
391
407
|
* @param name — The new name.
|
|
392
408
|
*/
|
|
393
409
|
setName(name: string): void;
|
|
394
|
-
/**
|
|
395
|
-
* Sets a custom function to sanitize the symbol's name.
|
|
396
|
-
*
|
|
397
|
-
* @param fn — The name sanitizer function to apply.
|
|
398
|
-
*/
|
|
399
|
-
setNameSanitizer(fn: SymbolNameSanitizer): void;
|
|
400
410
|
/**
|
|
401
411
|
* Binds the node that defines this symbol.
|
|
402
412
|
*
|
|
403
413
|
* This may only be set once.
|
|
404
414
|
*/
|
|
405
|
-
setNode(node:
|
|
415
|
+
setNode(node: Node): void;
|
|
406
416
|
/**
|
|
407
417
|
* Returns a debug‑friendly string representation identifying the symbol.
|
|
408
418
|
*/
|
|
@@ -420,13 +430,8 @@ declare class Symbol {
|
|
|
420
430
|
private assertCanonical;
|
|
421
431
|
}
|
|
422
432
|
//#endregion
|
|
423
|
-
//#region src/planner/
|
|
424
|
-
type Input = Ref<object> | object | string | number | undefined;
|
|
433
|
+
//#region src/planner/scope.d.ts
|
|
425
434
|
type NameScopes = Map<string, Set<SymbolKind>>;
|
|
426
|
-
type NameConflictResolver = (args: {
|
|
427
|
-
attempt: number;
|
|
428
|
-
baseName: string;
|
|
429
|
-
}) => string | null;
|
|
430
435
|
type Scope = {
|
|
431
436
|
/** Child scopes. */
|
|
432
437
|
children: Array<Scope>;
|
|
@@ -437,6 +442,13 @@ type Scope = {
|
|
|
437
442
|
/** Symbols registered in this scope. */
|
|
438
443
|
symbols: Array<Ref<Symbol>>;
|
|
439
444
|
};
|
|
445
|
+
//#endregion
|
|
446
|
+
//#region src/planner/types.d.ts
|
|
447
|
+
type Input = Ref<object> | object | string | number | undefined;
|
|
448
|
+
type NameConflictResolver = (args: {
|
|
449
|
+
attempt: number;
|
|
450
|
+
baseName: string;
|
|
451
|
+
}) => string | null;
|
|
440
452
|
interface IAnalysisContext {
|
|
441
453
|
/** Register a dependency on another symbol. */
|
|
442
454
|
addDependency(symbol: Ref<Symbol>): void;
|
|
@@ -576,11 +588,11 @@ interface IOutput {
|
|
|
576
588
|
}
|
|
577
589
|
//#endregion
|
|
578
590
|
//#region src/renderer.d.ts
|
|
579
|
-
interface RenderContext {
|
|
591
|
+
interface RenderContext<Node extends INode = INode> {
|
|
580
592
|
/**
|
|
581
593
|
* The current file.
|
|
582
594
|
*/
|
|
583
|
-
file: File
|
|
595
|
+
file: File<Node>;
|
|
584
596
|
/**
|
|
585
597
|
* Arbitrary metadata.
|
|
586
598
|
*/
|
|
@@ -627,6 +639,13 @@ interface IProject {
|
|
|
627
639
|
readonly nameConflictResolvers: NameConflictResolvers;
|
|
628
640
|
/** Centralized node registry for the project. */
|
|
629
641
|
readonly nodes: INodeRegistry;
|
|
642
|
+
/**
|
|
643
|
+
* Finalizes the project structure, resolving nodes, symbols, and dependencies.
|
|
644
|
+
*
|
|
645
|
+
* @param meta Arbitrary metadata.
|
|
646
|
+
* @returns void
|
|
647
|
+
*/
|
|
648
|
+
plan(meta?: IProjectRenderMeta): void;
|
|
630
649
|
/**
|
|
631
650
|
* Produces output representations for all files in the project.
|
|
632
651
|
*
|
|
@@ -650,7 +669,7 @@ interface IProject {
|
|
|
650
669
|
}
|
|
651
670
|
//#endregion
|
|
652
671
|
//#region src/files/file.d.ts
|
|
653
|
-
declare class File {
|
|
672
|
+
declare class File<Node extends INode = INode> {
|
|
654
673
|
/**
|
|
655
674
|
* Exports from this file.
|
|
656
675
|
*/
|
|
@@ -736,7 +755,7 @@ declare class File {
|
|
|
736
755
|
/**
|
|
737
756
|
* Syntax nodes contained in this file.
|
|
738
757
|
*/
|
|
739
|
-
get nodes(): ReadonlyArray<
|
|
758
|
+
get nodes(): ReadonlyArray<Node>;
|
|
740
759
|
/**
|
|
741
760
|
* Renderer assigned to this file.
|
|
742
761
|
*/
|
|
@@ -752,7 +771,7 @@ declare class File {
|
|
|
752
771
|
/**
|
|
753
772
|
* Add a syntax node to the file.
|
|
754
773
|
*/
|
|
755
|
-
addNode(node:
|
|
774
|
+
addNode(node: Node): void;
|
|
756
775
|
/**
|
|
757
776
|
* Sets the file extension.
|
|
758
777
|
*/
|
|
@@ -809,8 +828,6 @@ type ExportModule = Pick<ExportMember, 'isTypeOnly'> & {
|
|
|
809
828
|
interface ImportMember {
|
|
810
829
|
/** Whether this import is type-only. */
|
|
811
830
|
isTypeOnly: boolean;
|
|
812
|
-
/** Import flavor. */
|
|
813
|
-
kind: BindingKind;
|
|
814
831
|
/**
|
|
815
832
|
* The name this symbol will have locally in this file.
|
|
816
833
|
* This is where aliasing is applied:
|
|
@@ -823,29 +840,19 @@ interface ImportMember {
|
|
|
823
840
|
/** The exported name of the symbol in its source file. */
|
|
824
841
|
sourceName: string;
|
|
825
842
|
}
|
|
826
|
-
type ImportModule = Pick<ImportMember, 'isTypeOnly'> & {
|
|
843
|
+
type ImportModule = Pick<ImportMember, 'isTypeOnly'> & Pick<Partial<ImportMember>, 'localName'> & {
|
|
827
844
|
/** Source file. */
|
|
828
845
|
from: File;
|
|
829
846
|
/** List of symbols imported from this module. */
|
|
830
847
|
imports: Array<ImportMember>;
|
|
831
|
-
/**
|
|
832
|
-
|
|
848
|
+
/** Import flavor. */
|
|
849
|
+
kind: BindingKind;
|
|
833
850
|
};
|
|
834
851
|
//#endregion
|
|
835
852
|
//#region src/brands.d.ts
|
|
836
853
|
declare const nodeBrand = "heyapi.node";
|
|
837
854
|
declare const symbolBrand = "heyapi.symbol";
|
|
838
855
|
//#endregion
|
|
839
|
-
//#region src/debug.d.ts
|
|
840
|
-
declare const DEBUG_GROUPS: {
|
|
841
|
-
readonly analyzer: colors.StyleFunction;
|
|
842
|
-
readonly dsl: colors.StyleFunction;
|
|
843
|
-
readonly file: colors.StyleFunction;
|
|
844
|
-
readonly registry: colors.StyleFunction;
|
|
845
|
-
readonly symbol: colors.StyleFunction;
|
|
846
|
-
};
|
|
847
|
-
declare function debug(message: string, group: keyof typeof DEBUG_GROUPS): void;
|
|
848
|
-
//#endregion
|
|
849
856
|
//#region src/guards.d.ts
|
|
850
857
|
declare function isNode(value: unknown): value is INode;
|
|
851
858
|
declare function isNodeRef(value: Ref<unknown>): value is Ref<INode>;
|
|
@@ -858,6 +865,42 @@ declare const defaultExtensions: Extensions;
|
|
|
858
865
|
//#region src/languages/resolvers.d.ts
|
|
859
866
|
declare const defaultNameConflictResolvers: NameConflictResolvers;
|
|
860
867
|
//#endregion
|
|
868
|
+
//#region src/log.d.ts
|
|
869
|
+
/**
|
|
870
|
+
* Accepts a value or a readonly array of values of type T.
|
|
871
|
+
*/
|
|
872
|
+
type MaybeArray<T> = T | ReadonlyArray<T>;
|
|
873
|
+
/**
|
|
874
|
+
* Accepts a value or a function returning a value.
|
|
875
|
+
*/
|
|
876
|
+
type MaybeFunc<T extends (...args: Array<any>) => any> = T | ReturnType<T>;
|
|
877
|
+
declare const DebugGroups: {
|
|
878
|
+
readonly analyzer: colors.StyleFunction;
|
|
879
|
+
readonly dsl: colors.StyleFunction;
|
|
880
|
+
readonly file: colors.StyleFunction;
|
|
881
|
+
readonly registry: colors.StyleFunction;
|
|
882
|
+
readonly symbol: colors.StyleFunction;
|
|
883
|
+
};
|
|
884
|
+
declare const WarnGroups: {
|
|
885
|
+
readonly deprecated: colors.StyleFunction;
|
|
886
|
+
};
|
|
887
|
+
declare function debug(message: string, group: keyof typeof DebugGroups): void;
|
|
888
|
+
declare function warn(message: string, group: keyof typeof WarnGroups): void;
|
|
889
|
+
declare function warnDeprecated({
|
|
890
|
+
context,
|
|
891
|
+
field,
|
|
892
|
+
replacement
|
|
893
|
+
}: {
|
|
894
|
+
context?: string;
|
|
895
|
+
field: string;
|
|
896
|
+
replacement?: MaybeFunc<(field: string) => MaybeArray<string>>;
|
|
897
|
+
}): void;
|
|
898
|
+
declare const log: {
|
|
899
|
+
debug: typeof debug;
|
|
900
|
+
warn: typeof warn;
|
|
901
|
+
warnDeprecated: typeof warnDeprecated;
|
|
902
|
+
};
|
|
903
|
+
//#endregion
|
|
861
904
|
//#region src/planner/resolvers.d.ts
|
|
862
905
|
declare const simpleNameConflictResolver: NameConflictResolver;
|
|
863
906
|
declare const underscoreNameConflictResolver: NameConflictResolver;
|
|
@@ -915,6 +958,7 @@ declare class SymbolRegistry implements ISymbolRegistry {
|
|
|
915
958
|
//#endregion
|
|
916
959
|
//#region src/project/project.d.ts
|
|
917
960
|
declare class Project implements IProject {
|
|
961
|
+
private _isPlanned;
|
|
918
962
|
readonly files: FileRegistry;
|
|
919
963
|
readonly nodes: NodeRegistry;
|
|
920
964
|
readonly symbols: SymbolRegistry;
|
|
@@ -926,6 +970,7 @@ declare class Project implements IProject {
|
|
|
926
970
|
readonly renderers: ReadonlyArray<Renderer>;
|
|
927
971
|
readonly root: string;
|
|
928
972
|
constructor(args: Pick<Partial<IProject>, 'defaultFileName' | 'defaultNameConflictResolver' | 'extensions' | 'fileName' | 'nameConflictResolvers' | 'renderers'> & Pick<IProject, 'root'>);
|
|
973
|
+
plan(meta?: IProjectRenderMeta): void;
|
|
929
974
|
render(meta?: IProjectRenderMeta): ReadonlyArray<IOutput>;
|
|
930
975
|
}
|
|
931
976
|
//#endregion
|
|
@@ -933,10 +978,14 @@ declare class Project implements IProject {
|
|
|
933
978
|
/**
|
|
934
979
|
* Wraps a single value in a Ref object.
|
|
935
980
|
*
|
|
981
|
+
* If the value is already a Ref, returns it as-is (idempotent).
|
|
982
|
+
*
|
|
936
983
|
* @example
|
|
937
984
|
* ```ts
|
|
938
985
|
* const r = ref(123); // { '~ref': 123 }
|
|
939
986
|
* console.log(r['~ref']); // 123
|
|
987
|
+
*
|
|
988
|
+
* const r2 = ref(r); // { '~ref': 123 } (not double-wrapped)
|
|
940
989
|
* ```
|
|
941
990
|
*/
|
|
942
991
|
declare const ref: <T>(value: T) => Ref<T>;
|
|
@@ -960,7 +1009,7 @@ declare const refs: <T extends Record<string, unknown>>(obj: T) => Refs<T>;
|
|
|
960
1009
|
* console.log(n); // 42
|
|
961
1010
|
* ```
|
|
962
1011
|
*/
|
|
963
|
-
declare const fromRef: <T extends Ref<unknown> | undefined>(ref: T) => T
|
|
1012
|
+
declare const fromRef: <T extends Ref<unknown> | undefined>(ref: T) => FromRef<T>;
|
|
964
1013
|
/**
|
|
965
1014
|
* Converts an object of Refs back to a plain object (unwraps all refs).
|
|
966
1015
|
*
|
|
@@ -979,5 +1028,115 @@ declare const fromRefs: <T extends Refs<Record<string, unknown>>>(obj: T) => Fro
|
|
|
979
1028
|
*/
|
|
980
1029
|
declare const isRef: <T>(value: unknown) => value is Ref<T>;
|
|
981
1030
|
//#endregion
|
|
982
|
-
|
|
1031
|
+
//#region src/structure/types.d.ts
|
|
1032
|
+
interface StructureInsert {
|
|
1033
|
+
/** Inserted data. */
|
|
1034
|
+
data: unknown;
|
|
1035
|
+
/** Locations where the data should be inserted. */
|
|
1036
|
+
locations: ReadonlyArray<StructureLocation>;
|
|
1037
|
+
/** Source of the inserted data. */
|
|
1038
|
+
source: symbol;
|
|
1039
|
+
}
|
|
1040
|
+
interface StructureItem extends Pick<StructureInsert, 'data' | 'source'> {
|
|
1041
|
+
/** Location of this item within the structure. */
|
|
1042
|
+
location: ReadonlyArray<string>;
|
|
1043
|
+
}
|
|
1044
|
+
interface StructureLocation {
|
|
1045
|
+
/** Path within the structure where the data should be inserted. */
|
|
1046
|
+
path: ReadonlyArray<string>;
|
|
1047
|
+
/** Shell to apply at this location. */
|
|
1048
|
+
shell?: StructureShell;
|
|
1049
|
+
}
|
|
1050
|
+
interface StructureShell {
|
|
1051
|
+
define: (node: StructureNode) => StructureShellResult;
|
|
1052
|
+
}
|
|
1053
|
+
interface StructureShellResult {
|
|
1054
|
+
dependencies?: Array<INode>;
|
|
1055
|
+
node: INode;
|
|
1056
|
+
}
|
|
1057
|
+
//#endregion
|
|
1058
|
+
//#region src/structure/node.d.ts
|
|
1059
|
+
declare class StructureNode {
|
|
1060
|
+
/** Nested nodes within this node. */
|
|
1061
|
+
children: Map<string, StructureNode>;
|
|
1062
|
+
/** Items contained in this node. */
|
|
1063
|
+
items: Array<StructureItem>;
|
|
1064
|
+
/** The name of this node (e.g., "Users", "Accounts"). */
|
|
1065
|
+
name: string;
|
|
1066
|
+
/** Parent node in the hierarchy. Undefined if this is the root node. */
|
|
1067
|
+
parent?: StructureNode;
|
|
1068
|
+
/** Shell claimed for this node. */
|
|
1069
|
+
shell?: StructureShell;
|
|
1070
|
+
/** Source of the claimed shell. */
|
|
1071
|
+
shellSource?: symbol;
|
|
1072
|
+
/** True if this is a virtual root. */
|
|
1073
|
+
virtual: boolean;
|
|
1074
|
+
constructor(name: string, parent?: StructureNode, options?: {
|
|
1075
|
+
virtual?: boolean;
|
|
1076
|
+
});
|
|
1077
|
+
get isRoot(): boolean;
|
|
1078
|
+
/**
|
|
1079
|
+
* Gets or creates a child node.
|
|
1080
|
+
*
|
|
1081
|
+
* If the child doesn't exist, it's created automatically.
|
|
1082
|
+
*
|
|
1083
|
+
* @param name - The name of the child node
|
|
1084
|
+
* @returns The child node instance
|
|
1085
|
+
*/
|
|
1086
|
+
child(name: string): StructureNode;
|
|
1087
|
+
/**
|
|
1088
|
+
* Gets the full path of this node in the hierarchy.
|
|
1089
|
+
*
|
|
1090
|
+
* @returns An array of node names from the root to this node
|
|
1091
|
+
*/
|
|
1092
|
+
getPath(): ReadonlyArray<string>;
|
|
1093
|
+
/**
|
|
1094
|
+
* Yields items from a specific source with typed data.
|
|
1095
|
+
*
|
|
1096
|
+
* @param source - The source symbol to filter by
|
|
1097
|
+
* @returns Generator of items from that source
|
|
1098
|
+
*/
|
|
1099
|
+
itemsFrom<T = unknown>(source: symbol): Generator<StructureItem & {
|
|
1100
|
+
data: T;
|
|
1101
|
+
}>;
|
|
1102
|
+
/**
|
|
1103
|
+
* Walk all nodes in the structure (depth-first, post-order).
|
|
1104
|
+
*
|
|
1105
|
+
* @returns Generator of all structure nodes
|
|
1106
|
+
*/
|
|
1107
|
+
walk(): Generator<StructureNode>;
|
|
1108
|
+
}
|
|
1109
|
+
//#endregion
|
|
1110
|
+
//#region src/structure/model.d.ts
|
|
1111
|
+
declare class StructureModel {
|
|
1112
|
+
/** Root nodes mapped by their names. */
|
|
1113
|
+
private _roots;
|
|
1114
|
+
/** Node for data without a specific root. */
|
|
1115
|
+
private _virtualRoot?;
|
|
1116
|
+
/**
|
|
1117
|
+
* Get all root nodes.
|
|
1118
|
+
*/
|
|
1119
|
+
get roots(): ReadonlyArray<StructureNode>;
|
|
1120
|
+
/**
|
|
1121
|
+
* Insert data into the structure.
|
|
1122
|
+
*/
|
|
1123
|
+
insert(args: StructureInsert): void;
|
|
1124
|
+
/**
|
|
1125
|
+
* Gets or creates a root by name.
|
|
1126
|
+
*
|
|
1127
|
+
* If the root doesn't exist, it's created automatically.
|
|
1128
|
+
*
|
|
1129
|
+
* @param name - The name of the root
|
|
1130
|
+
* @returns The root instance
|
|
1131
|
+
*/
|
|
1132
|
+
root(name: string | null): StructureNode;
|
|
1133
|
+
/**
|
|
1134
|
+
* Walk all nodes in the structure (depth-first, post-order).
|
|
1135
|
+
*
|
|
1136
|
+
* @returns Generator of all structure nodes
|
|
1137
|
+
*/
|
|
1138
|
+
walk(): Generator<StructureNode>;
|
|
1139
|
+
}
|
|
1140
|
+
//#endregion
|
|
1141
|
+
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, 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 };
|
|
983
1142
|
//# sourceMappingURL=index.d.mts.map
|