@alloy-js/core 0.20.0-dev.3 → 0.20.0-dev.6

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.
Files changed (137) hide show
  1. package/dist/src/binder.d.ts +62 -38
  2. package/dist/src/binder.d.ts.map +1 -1
  3. package/dist/src/binder.js +214 -173
  4. package/dist/src/components/Declaration.d.ts +2 -2
  5. package/dist/src/components/Declaration.d.ts.map +1 -1
  6. package/dist/src/components/Declaration.js +8 -2
  7. package/dist/src/components/MemberDeclaration.d.ts +2 -2
  8. package/dist/src/components/MemberDeclaration.d.ts.map +1 -1
  9. package/dist/src/components/MemberDeclaration.js +9 -5
  10. package/dist/src/components/MemberScope.d.ts +30 -13
  11. package/dist/src/components/MemberScope.d.ts.map +1 -1
  12. package/dist/src/components/MemberScope.js +37 -15
  13. package/dist/src/components/Output.d.ts.map +1 -1
  14. package/dist/src/components/Output.js +2 -5
  15. package/dist/src/components/ReferenceOrContent.d.ts +1 -1
  16. package/dist/src/components/ReferenceOrContent.d.ts.map +1 -1
  17. package/dist/src/components/Scope.d.ts +5 -5
  18. package/dist/src/components/Scope.d.ts.map +1 -1
  19. package/dist/src/components/Scope.js +9 -5
  20. package/dist/src/context/member-scope.d.ts +7 -8
  21. package/dist/src/context/member-scope.d.ts.map +1 -1
  22. package/dist/src/context/member-scope.js +5 -5
  23. package/dist/src/context/name-policy.d.ts.map +1 -1
  24. package/dist/src/context/name-policy.js +3 -0
  25. package/dist/src/context/scope.d.ts +1 -0
  26. package/dist/src/context/scope.d.ts.map +1 -1
  27. package/dist/src/context/scope.js +7 -0
  28. package/dist/src/inspect.browser.d.ts +5 -0
  29. package/dist/src/inspect.browser.d.ts.map +1 -0
  30. package/dist/src/inspect.browser.js +5 -0
  31. package/dist/src/inspect.d.ts +2 -0
  32. package/dist/src/inspect.d.ts.map +1 -0
  33. package/dist/src/inspect.js +1 -0
  34. package/dist/src/name-policy.d.ts +11 -0
  35. package/dist/src/name-policy.d.ts.map +1 -1
  36. package/dist/src/name-policy.js +3 -0
  37. package/dist/src/reactive-union-set.d.ts.map +1 -1
  38. package/dist/src/reactive-union-set.js +12 -8
  39. package/dist/src/refkey.d.ts +39 -3
  40. package/dist/src/refkey.d.ts.map +1 -1
  41. package/dist/src/refkey.js +52 -8
  42. package/dist/src/symbols/basic-scope.d.ts +14 -0
  43. package/dist/src/symbols/basic-scope.d.ts.map +1 -0
  44. package/dist/src/symbols/basic-scope.js +20 -0
  45. package/dist/src/symbols/basic-symbol.d.ts +19 -0
  46. package/dist/src/symbols/basic-symbol.d.ts.map +1 -0
  47. package/dist/src/symbols/basic-symbol.js +28 -0
  48. package/dist/src/symbols/index.d.ts +3 -1
  49. package/dist/src/symbols/index.d.ts.map +1 -1
  50. package/dist/src/symbols/index.js +3 -1
  51. package/dist/src/symbols/output-scope.d.ts +70 -41
  52. package/dist/src/symbols/output-scope.d.ts.map +1 -1
  53. package/dist/src/symbols/output-scope.js +98 -130
  54. package/dist/src/symbols/output-space.d.ts +25 -0
  55. package/dist/src/symbols/output-space.d.ts.map +1 -0
  56. package/dist/src/symbols/output-space.js +35 -0
  57. package/dist/src/symbols/output-symbol.d.ts +213 -37
  58. package/dist/src/symbols/output-symbol.d.ts.map +1 -1
  59. package/dist/src/symbols/output-symbol.js +323 -203
  60. package/dist/src/symbols/symbol-flow.d.ts +1 -1
  61. package/dist/src/symbols/symbol-flow.d.ts.map +1 -1
  62. package/dist/src/symbols/symbol-flow.js +22 -7
  63. package/dist/src/symbols/symbol-slot.d.ts +27 -9
  64. package/dist/src/symbols/symbol-slot.d.ts.map +1 -1
  65. package/dist/src/symbols/symbol-slot.js +20 -4
  66. package/dist/src/symbols/symbol-table.d.ts +19 -8
  67. package/dist/src/symbols/symbol-table.d.ts.map +1 -1
  68. package/dist/src/symbols/symbol-table.js +65 -16
  69. package/dist/src/tracer.d.ts +15 -3
  70. package/dist/src/tracer.d.ts.map +1 -1
  71. package/dist/src/tracer.js +39 -63
  72. package/dist/src/utils.d.ts +1 -1
  73. package/dist/src/utils.d.ts.map +1 -1
  74. package/dist/src/utils.js +4 -4
  75. package/dist/src/write-output.d.ts +1 -1
  76. package/dist/src/write-output.d.ts.map +1 -1
  77. package/dist/src/write-output.js +31 -37
  78. package/dist/test/components/declaration.test.js +9 -14
  79. package/dist/test/components/reference-or-content.test.js +2 -2
  80. package/dist/test/symbols/output-scope.test.js +33 -198
  81. package/dist/test/symbols/output-symbol.test.js +139 -385
  82. package/dist/test/symbols/resolution.test.js +431 -114
  83. package/dist/test/symbols/symbol-table.test.d.ts +2 -0
  84. package/dist/test/symbols/symbol-table.test.d.ts.map +1 -0
  85. package/dist/test/symbols/symbol-table.test.js +14 -0
  86. package/dist/test/symbols/utils.d.ts +10 -24
  87. package/dist/test/symbols/utils.d.ts.map +1 -1
  88. package/dist/test/symbols/utils.js +23 -45
  89. package/dist/tsconfig.tsbuildinfo +1 -1
  90. package/package.json +4 -2
  91. package/src/binder.ts +348 -273
  92. package/src/components/Declaration.tsx +13 -3
  93. package/src/components/MemberDeclaration.tsx +15 -8
  94. package/src/components/MemberScope.tsx +61 -20
  95. package/src/components/Output.tsx +0 -4
  96. package/src/components/Scope.tsx +16 -9
  97. package/src/context/member-scope.ts +10 -10
  98. package/src/context/name-policy.ts +3 -0
  99. package/src/context/scope.ts +9 -0
  100. package/src/inspect.browser.ts +6 -0
  101. package/src/inspect.ts +1 -0
  102. package/src/name-policy.ts +14 -0
  103. package/src/reactive-union-set.ts +14 -8
  104. package/src/refkey.ts +88 -14
  105. package/src/symbols/basic-scope.ts +23 -0
  106. package/src/symbols/basic-symbol.ts +32 -0
  107. package/src/symbols/index.ts +3 -1
  108. package/src/symbols/output-scope.ts +131 -170
  109. package/src/symbols/output-space.ts +49 -0
  110. package/src/symbols/output-symbol.ts +434 -258
  111. package/src/symbols/symbol-flow.ts +38 -9
  112. package/src/symbols/symbol-slot.tsx +46 -8
  113. package/src/symbols/symbol-table.ts +95 -21
  114. package/src/tracer.ts +53 -83
  115. package/src/utils.tsx +4 -4
  116. package/src/write-output.ts +33 -45
  117. package/temp/api.json +5551 -3066
  118. package/test/components/declaration.test.tsx +6 -19
  119. package/test/components/reference-or-content.test.tsx +2 -2
  120. package/test/symbols/output-scope.test.ts +33 -125
  121. package/test/symbols/output-symbol.test.ts +128 -348
  122. package/test/symbols/resolution.test.ts +530 -117
  123. package/test/symbols/symbol-table.test.ts +15 -0
  124. package/test/symbols/utils.ts +38 -74
  125. package/tsdoc.json +4 -0
  126. package/dist/src/slot.d.ts +0 -15
  127. package/dist/src/slot.d.ts.map +0 -1
  128. package/dist/src/slot.js +0 -50
  129. package/dist/src/symbols/flags.d.ts +0 -70
  130. package/dist/src/symbols/flags.d.ts.map +0 -1
  131. package/dist/src/symbols/flags.js +0 -72
  132. package/dist/test/components/slot.test.d.ts +0 -2
  133. package/dist/test/components/slot.test.d.ts.map +0 -1
  134. package/dist/test/components/slot.test.js +0 -134
  135. package/src/slot.ts +0 -89
  136. package/src/symbols/flags.ts +0 -82
  137. package/test/components/slot.test.tsx +0 -174
@@ -1,9 +1,9 @@
1
- import { reactive, ReactiveFlags, shallowReactive, track, TrackOpTypes, trigger, TriggerOpTypes, watch } from "@vue/reactivity";
1
+ import { effect, reactive, ReactiveFlags, shallowReactive, track, TrackOpTypes, trigger, TriggerOpTypes } from "@vue/reactivity";
2
2
  import { useBinder } from "../context/binder.js";
3
- import { useScope } from "../context/scope.js";
4
- import { formatScope, formatScopeName, trace, traceEffect, TracePhase } from "../tracer.js";
5
- import { OutputScopeFlags } from "./flags.js";
6
- import { SymbolTable } from "./symbol-table.js";
3
+ import { inspect } from "../inspect.js";
4
+ import { untrack } from "../reactivity.js";
5
+ import { formatScope, trace, traceEffect, TracePhase } from "../tracer.js";
6
+ import { OutputDeclarationSpace } from "./output-space.js";
7
7
  let scopeCount = 0;
8
8
  /**
9
9
  * A container of symbols accessible within some scope in your output code.
@@ -24,10 +24,12 @@ let scopeCount = 0;
24
24
  * within a reactive context.
25
25
  */
26
26
  export class OutputScope {
27
- // my kingdom for decorators
27
+ static declarationSpaces = [];
28
28
  #name;
29
29
  /**
30
30
  * The name of the scope.
31
+ *
32
+ * @reactive
31
33
  */
32
34
  get name() {
33
35
  track(this, TrackOpTypes.GET, "name");
@@ -41,77 +43,59 @@ export class OutputScope {
41
43
  #id;
42
44
  /**
43
45
  * The unique id of this scope.
46
+ *
47
+ * @readonly
44
48
  */
45
49
  get id() {
46
50
  return this.#id;
47
51
  }
48
- #kind;
49
-
50
- /**
51
- * The kind of scope. Subtypes will likely provide a set of known scope kinds.
52
- * The kind is not used by the binder itself.
53
- */
54
- get kind() {
55
- return this.#kind;
56
- }
57
- #flags;
58
- /**
59
- * The flags that describe this scope.
60
- */
61
- get flags() {
62
- track(this, TrackOpTypes.GET, "flags");
63
- return this.#flags;
64
- }
65
- set flags(flags) {
66
- const old = this.#flags;
67
- this.#flags = flags;
68
- trigger(this, TriggerOpTypes.SET, "flags", flags, old);
69
- }
70
52
 
71
53
  // read only
72
54
  #metadata;
55
+ /**
56
+ * Arbitrary metadata associated with this scope. This property is not
57
+ * reactive but the metadata object is a reactive object.
58
+ *
59
+ * @readonly
60
+ */
73
61
  get metadata() {
74
62
  return this.#metadata;
75
63
  }
76
64
  #parent;
65
+
77
66
  /**
78
- * The container of this scope. This is only defined for scopes which don't
79
- * have the {@link OutputScopeFlags.StaticMemberScope} or
80
- * {@link OutputScopeFlags.InstanceMemberScope} flag.
67
+ * The parent scope of this scope. Undefined if this is a root scope.
68
+ *
69
+ * @reactive
81
70
  */
82
71
  get parent() {
72
+ track(this, TrackOpTypes.GET, "parent");
83
73
  return this.#parent;
84
74
  }
85
- #owner;
86
- /**
87
- * The symbol that owns this scope. This is only defined for scopes that have
88
- * the {@link OutputScopeFlags.StaticMemberScope} or
89
- * {@link OutputScopeFlags.InstanceMemberScope} flag.
90
- */
91
- get owner() {
92
- return this.#owner;
93
- }
94
- #symbols;
95
- /**
96
- * The symbols defined within this scope.
97
- */
98
- get symbols() {
99
- return this.#symbols;
75
+ set parent(scope) {
76
+ const old = this.#parent;
77
+ if (old) {
78
+ old.children.delete(this);
79
+ }
80
+ if (scope) {
81
+ scope.children.add(this);
82
+ }
83
+ trigger(this, TriggerOpTypes.SET, "parent", scope, old);
84
+ this.#parent = scope;
100
85
  }
101
- #symbolsByRefkey;
86
+ #spaces;
87
+
102
88
  /**
103
- * The symbols defined within this scope, indexed by refkey.
89
+ * Get the declaration space for the given key.
104
90
  */
105
- get symbolsByRefkey() {
106
- return this.#symbolsByRefkey;
107
- }
108
- #symbolNames;
109
- get symbolNames() {
110
- return this.#symbolNames;
91
+ spaceFor(key) {
92
+ return this.#spaces[key];
111
93
  }
112
94
  #children;
113
95
  /**
114
96
  * The scopes nested within this scope.
97
+ *
98
+ * @readonly
115
99
  */
116
100
  get children() {
117
101
  return this.#children;
@@ -119,104 +103,88 @@ export class OutputScope {
119
103
  #binder;
120
104
  /**
121
105
  * The binder that created this scope.
106
+ *
107
+ * @readonly
122
108
  */
123
109
  get binder() {
124
110
  return this.#binder;
125
111
  }
126
112
  [ReactiveFlags.SKIP] = this;
127
- constructor(name, options = {}) {
113
+ constructor(name, parentScope, options = {}) {
128
114
  this.#name = name;
129
115
  this.#id = scopeCount++;
130
- this.#flags = options.flags ?? OutputScopeFlags.None;
131
- this.#kind = options.kind ?? "scope";
132
116
  this.#metadata = reactive(options.metadata ?? {});
133
117
  this.#binder = options.binder ?? useBinder();
134
- this.#owner = options.owner;
135
118
  this.#children = shallowReactive(new Set());
136
- if (this.#flags & OutputScopeFlags.MemberScope) {
137
- if (!this.#owner) {
138
- throw new Error("Member scopes must have an owner");
139
- }
140
- } else {
141
- if (!this.#parent) {
142
- this.#parent = options.parent ?? useScope() ?? this.#binder?.globalScope;
143
- }
144
- if (this.#parent) {
145
- // not global scope
146
- this.#parent.children.add(this);
147
- }
148
- }
149
- this.#symbols = new SymbolTable(this, {
150
- nameConflictResolver: this.#binder?.nameConflictResolver
151
- });
152
- this.#symbolsByRefkey = this.#symbols.createIndex(s => s.refkeys);
153
- this.#symbolNames = this.#symbols.createDerivedSet(s => {
154
- return s.name;
119
+ this.#parent = parentScope;
120
+ effect(() => {
121
+ this.#setOwnerSymbol(options.ownerSymbol?.movedTo ?? options.ownerSymbol);
155
122
  });
156
123
  if (this.#parent) {
157
124
  this.#parent.children.add(this);
158
125
  }
126
+ const constructor = this.constructor;
127
+ this.#spaces = Object.fromEntries(constructor.declarationSpaces.map(spaceKey => [spaceKey, new OutputDeclarationSpace(this, spaceKey, this.#binder)]));
159
128
  this.#binder?.notifyScopeCreated(this);
160
129
  trace(TracePhase.scope.create, () => `${formatScope(this)}`);
161
130
  traceEffect(TracePhase.scope.update, () => {
162
131
  return `${formatScope(this)}`;
163
132
  });
164
133
  }
165
- moveSymbolsFrom(source, options) {
166
- trace(TracePhase.scope.copySymbols, () => `Moving symbols from ${formatScopeName(source)} to ${formatScopeName(this)}`);
167
- this.#symbols.addSubset(source.#symbols, {
168
- onAdd: symbol => {
169
- if (options?.onAdd) {
170
- return options.onAdd(symbol);
171
- }
172
- symbol.scope = this;
173
- return symbol;
174
- },
175
- onDelete: symbol => {
176
- if (options?.onDelete) {
177
- options.onDelete(symbol);
178
- }
179
- }
180
- });
134
+
135
+ /**
136
+ * Get all the declaration spaces in this scope.
137
+ *
138
+ * @readonly
139
+ */
140
+ get spaces() {
141
+ return Object.values(this.#spaces);
181
142
  }
182
- copySymbolsFrom(source, options) {
183
- trace(TracePhase.scope.copySymbols, () => `Copying symbols from ${formatScopeName(source)} to ${formatScopeName(this)}`);
184
- this.#symbols.addSubset(source.#symbols, {
185
- onAdd: symbol => {
186
- if (options?.onAdd) {
187
- return options.onAdd(symbol);
188
- }
189
- return symbol.copyToScope(this);
190
- },
191
- onDelete: symbol => {
192
- if (options?.onDelete) {
193
- options.onDelete(symbol);
194
- }
195
- }
196
- });
143
+ #ownerSymbol;
144
+ /**
145
+ * The symbol whose members are in scope. When an owner symbol is present,
146
+ * this scope is considered a member scope, and does not provide its own
147
+ * declaration spaces.
148
+ *
149
+ * @readonly
150
+ * @reactive
151
+ */
152
+ get ownerSymbol() {
153
+ track(this, TrackOpTypes.GET, "ownerSymbol");
154
+ return this.#ownerSymbol;
197
155
  }
198
- clone(options = {}) {
199
- if (this.#flags & OutputScopeFlags.MemberScope && !options.owner) {
200
- throw new Error("Member scope clones must specify an owner symbol");
201
- } else if (this.#flags & ~OutputScopeFlags.MemberScope && !options.parent) {
202
- throw new Error("Non-member scope clones must specify a parent scope");
203
- }
204
- const clone = new OutputScope(this.#name, {
205
- binder: this.#binder,
206
- flags: this.#flags,
207
- kind: this.#kind,
208
- metadata: this.#metadata,
209
- parent: options.parent,
210
- owner: options.owner
211
- });
212
- watch(() => this.name, newName => clone.name = newName);
213
- watch(() => this.flags, newFlags => clone.flags = newFlags);
214
- // todo: this should be reactive, but cloning non-member scopes
215
- // seems like a very rare thing.
216
- for (const child of this.#children) {
217
- clone.children.add(child.clone());
156
+ #setOwnerSymbol(value) {
157
+ const old = this.#ownerSymbol;
158
+ this.#ownerSymbol = value;
159
+ trigger(this, TriggerOpTypes.SET, "ownerSymbol", value, old);
160
+ }
161
+
162
+ /**
163
+ * Whether this scope is a transient scope. Transient scopes are used for
164
+ * temporary values that are to be combined with other non-transient symbols.
165
+ * Scopes are transient when their owner symbol is transient.
166
+ *
167
+ * @readonly
168
+ */
169
+ get isTransient() {
170
+ if (!this.ownerSymbol) {
171
+ return false;
218
172
  }
219
- clone.copySymbolsFrom(this);
220
- return clone;
173
+ return this.ownerSymbol.isTransient;
174
+ }
175
+ /**
176
+ * Check if this is scope is a member scope. Member scopes have no member
177
+ * spaces of their own, but instead put members of their owner symbol in
178
+ * scope.
179
+ *
180
+ * @readonly
181
+ * @reactive
182
+ */
183
+ get isMemberScope() {
184
+ return !!this.ownerSymbol;
185
+ }
186
+ [inspect.custom]() {
187
+ const ownerSymbol = this.ownerSymbol ? ` for ${inspect(this.ownerSymbol)}` : "";
188
+ return untrack(() => `${this.constructor.name} ${this.name}[${this.id}]${ownerSymbol}`);
221
189
  }
222
190
  }
@@ -0,0 +1,25 @@
1
+ import { Binder } from "../binder.js";
2
+ import { inspect } from "../inspect.js";
3
+ import { OutputScope } from "./output-scope.js";
4
+ import { OutputSymbol } from "./output-symbol.js";
5
+ import { SymbolTable } from "./symbol-table.js";
6
+ export type OutputSpace = OutputDeclarationSpace | OutputMemberSpace;
7
+ export declare class OutputDeclarationSpace extends SymbolTable {
8
+ #private;
9
+ constructor(scope: OutputScope, key: string, binder?: Binder);
10
+ /**
11
+ * The scope this declaration space belongs to.
12
+ */
13
+ get scope(): OutputScope;
14
+ [inspect.custom](): string;
15
+ }
16
+ export declare class OutputMemberSpace extends SymbolTable {
17
+ #private;
18
+ constructor(symbol: OutputSymbol, key: string, binder?: Binder);
19
+ /**
20
+ * The symbol this member space belongs to.
21
+ */
22
+ get symbol(): OutputSymbol;
23
+ [inspect.custom](): string;
24
+ }
25
+ //# sourceMappingURL=output-space.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output-space.d.ts","sourceRoot":"","sources":["../../../src/symbols/output-space.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,MAAM,WAAW,GAAG,sBAAsB,GAAG,iBAAiB,CAAC;AACrE,qBAAa,sBAAuB,SAAQ,WAAW;;gBACzC,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;IAM5D;;OAEG;IACH,IAAI,KAAK,gBAER;IAED,CAAC,OAAO,CAAC,MAAM,CAAC;CAKjB;AAED,qBAAa,iBAAkB,SAAQ,WAAW;;gBACpC,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;IAM9D;;OAEG;IACH,IAAI,MAAM,iBAET;IAED,CAAC,OAAO,CAAC,MAAM,CAAC;CAKjB"}
@@ -0,0 +1,35 @@
1
+ import { inspect } from "../inspect.js";
2
+ import { untrack } from "../reactivity.js";
3
+ import { SymbolTable } from "./symbol-table.js";
4
+ export class OutputDeclarationSpace extends SymbolTable {
5
+ constructor(scope, key, binder) {
6
+ super(key, binder);
7
+ this.#scope = scope;
8
+ }
9
+ #scope;
10
+ /**
11
+ * The scope this declaration space belongs to.
12
+ */
13
+ get scope() {
14
+ return this.#scope;
15
+ }
16
+ [inspect.custom]() {
17
+ return untrack(() => `OutputDeclarationSpace for scope ${inspect(this.#scope)}`);
18
+ }
19
+ }
20
+ export class OutputMemberSpace extends SymbolTable {
21
+ constructor(symbol, key, binder) {
22
+ super(key, binder);
23
+ this.#symbol = symbol;
24
+ }
25
+ #symbol;
26
+ /**
27
+ * The symbol this member space belongs to.
28
+ */
29
+ get symbol() {
30
+ return this.#symbol;
31
+ }
32
+ [inspect.custom]() {
33
+ return untrack(() => `OutputMemberSpace for symbol ${inspect(this.#symbol)}`);
34
+ }
35
+ }
@@ -1,15 +1,65 @@
1
- import { ReactiveFlags } from "@vue/reactivity";
1
+ import { ReactiveFlags, Ref } from "@vue/reactivity";
2
2
  import type { Binder } from "../binder.js";
3
- import { type Refkey } from "../refkey.js";
4
- import { OutputScopeFlags, OutputSymbolFlags } from "./flags.js";
5
- import { OutputScope } from "./output-scope.js";
3
+ import { inspect } from "../inspect.js";
4
+ import { NamePolicyGetter } from "../name-policy.js";
5
+ import { Namekey, type Refkey } from "../refkey.js";
6
+ import { OutputMemberSpace, OutputSpace } from "./output-space.js";
6
7
  export interface OutputSymbolOptions {
8
+ /**
9
+ * The binder instance associated with this symbol. Symbol updates and changes
10
+ * will be reported to this binder. This binder will be able to find this
11
+ * symbol via its refkey and other means. Without a binder, this symbol will
12
+ * be unbound, which means it cannot be referenced by refkey.
13
+ */
7
14
  binder?: Binder;
8
- scope?: OutputScope;
9
- flags?: OutputSymbolFlags;
15
+ /**
16
+ * The refkey or refkeys associated with this symbol.
17
+ */
10
18
  refkeys?: Refkey | Refkey[];
19
+ /**
20
+ * Arbitrary metadata about this symbol.
21
+ */
11
22
  metadata?: Record<string, unknown>;
23
+ /**
24
+ * The symbol this symbol is an alias for.
25
+ */
12
26
  aliasTarget?: OutputSymbol;
27
+ /**
28
+ * Whether this symbol is transient.
29
+ */
30
+ transient?: boolean;
31
+ /**
32
+ * The symbol that provides type information for this symbol. When present,
33
+ * this symbol will not contain its own members, and instead members will be
34
+ * provided by the type. This can be provided a Ref, in which case the type
35
+ * will be the value of that ref.
36
+ */
37
+ type?: OutputSymbol | Ref<OutputSymbol | undefined>;
38
+ /**
39
+ * When provided, this symbol will be named according to the provided name
40
+ * policy.
41
+ *
42
+ * @example
43
+ *
44
+ * ```ts
45
+ * const classNamer = useNamePolicy().for("class");
46
+ * const symbol = new BasicSymbol("my-class", { namePolicy: classNamer });
47
+ * console.log(symbol.name); // "MyClass" (assuming a PascalCase class naming policy)
48
+ * ```
49
+ */
50
+ namePolicy?: NamePolicyGetter;
51
+ /**
52
+ * Whether the name of this symbol should bypass the active name policy. When true,
53
+ * the name of this symbol will be fixed, though it may conflict with other symbols which are
54
+ * also ignoring the name policy.
55
+ */
56
+ ignoreNamePolicy?: boolean;
57
+ /**
58
+ * Whether the name of this symbol should bypass the active name conflict resolution.
59
+ * When true, the name of this symbol will be fixed, though it may conflict with other symbols which are
60
+ * also ignoring name conflict resolution.
61
+ */
62
+ ignoreNameConflict?: boolean;
13
63
  }
14
64
  /**
15
65
  * An output symbol is a named entity that can be referenced in your output
@@ -21,56 +71,174 @@ export interface OutputSymbolOptions {
21
71
  * subtypes that provide additional metadata. Symbols are reactive values, so
22
72
  * you can observe changes to their properties in a reactive context.
23
73
  */
24
- export declare class OutputSymbol {
74
+ export declare abstract class OutputSymbol {
25
75
  #private;
76
+ static readonly memberSpaces: Readonly<string[]>;
77
+ /**
78
+ * Read only. The requested name of this symbol. The symbol's actual name may
79
+ * be different depending on naming policy or conflicts with other symbols.
80
+ *
81
+ * @readonly
82
+ */
26
83
  get originalName(): string;
84
+ /**
85
+ * The name of this symbol.
86
+ *
87
+ * @reactive
88
+ */
27
89
  get name(): string;
28
90
  set name(name: string);
91
+ /**
92
+ * The unique id of this symbol.
93
+ *
94
+ * @readonly
95
+ */
29
96
  get id(): number;
30
- get flags(): OutputSymbolFlags;
31
- set flags(flags: OutputSymbolFlags);
32
- get scope(): OutputScope;
33
- set scope(scope: OutputScope);
97
+ /**
98
+ * Whether the name of this symbol bypasses the active name policy. When true,
99
+ * the name of this symbol will be fixed, though it may conflict with other
100
+ * symbols which are also ignoring the name policy.
101
+ *
102
+ * @readonly
103
+ */
104
+ get ignoreNamePolicy(): boolean;
105
+ /**
106
+ * Whether the name of this symbol bypasses the active name conflict
107
+ * resolution. When true, the name of this symbol will be fixed, though it may
108
+ * conflict with other symbols which are also ignoring name conflict
109
+ * resolution.
110
+ */
111
+ get ignoreNameConflict(): boolean;
112
+ /**
113
+ * The member spaces of this symbol.
114
+ *
115
+ * @readonly
116
+ */
117
+ get memberSpaces(): OutputMemberSpace[];
118
+ /**
119
+ * Get the member space for the given key.
120
+ */
121
+ memberSpaceFor(spaceKey: string): OutputMemberSpace | undefined;
122
+ /**
123
+ * The scope this symbol is in. When this symbol is a member symbol, this will
124
+ * return undefined.
125
+ *
126
+ * @readonly
127
+ */
128
+ get scope(): import("./output-scope.js").OutputScope | undefined;
129
+ /**
130
+ * The declaration or member spaces this symbol belongs to.
131
+ *
132
+ * @reactive
133
+ */
134
+ get spaces(): OutputSpace[];
135
+ set spaces(spaces: OutputSpace[] | OutputSpace | undefined);
136
+ /**
137
+ * The binder that is tracking this symbol.
138
+ *
139
+ * @readonly
140
+ */
34
141
  get binder(): Binder | undefined;
142
+ /**
143
+ * The refkeys for this symbol.
144
+ *
145
+ * @reactive
146
+ */
35
147
  get refkeys(): Refkey[];
36
148
  set refkeys(refkeys: Refkey[]);
37
- get instanceMemberScope(): OutputScope | undefined;
149
+ /**
150
+ * The symbol that this symbol is an alias for.
151
+ *
152
+ * @readonly
153
+ */
38
154
  get aliasTarget(): OutputSymbol | undefined;
39
155
  /**
40
- * Create an output scope to hold member symbols. By default this just creates
41
- * an OutputScope, but can be subclassed to build scope subtypes when needed.
156
+ * If this symbol is an alias for another symbol, return the the aliased symbol. Otherwise, return this symbol.
157
+ */
158
+ dealias(): OutputSymbol;
159
+ /**
160
+ * Whether this symbol is an alias for another symbol.
161
+ *
162
+ * @readonly
163
+ */
164
+ get isAlias(): boolean;
165
+ /**
166
+ * An arbitrary bag of metadata for this symbol. This property is read only,
167
+ * but the metadata is a reactive object.
168
+ *
169
+ * @readonly
42
170
  */
43
- protected createMemberScope(name: string, options: {
44
- owner?: OutputSymbol;
45
- flags?: OutputScopeFlags;
46
- }): OutputScope;
47
- get staticMemberScope(): OutputScope | undefined;
48
171
  get metadata(): Record<string, unknown>;
172
+ copyToSpace(space: OutputSpace): OutputSymbol;
49
173
  /**
50
- * Tell \@vue/reactivity that this symbol should never be wrapped in a reactive
51
- * proxy.
174
+ * Whether this symbol is a member of another symbol.
175
+ *
176
+ * @readonly
52
177
  */
53
- [ReactiveFlags.SKIP]: boolean;
54
- constructor(name: string, options?: OutputSymbolOptions);
55
- delete(): void;
178
+ get isMemberSymbol(): boolean;
179
+ /**
180
+ * When this is a member symbol, this returns the symbol that this is symbol
181
+ * is a member of.
182
+ */
183
+ get ownerSymbol(): OutputSymbol | undefined;
184
+ /**
185
+ * Whether this symbol is a transient symbol. Transient symbols cannot be
186
+ * referenced and are meant to be combined with other symbols.
187
+ *
188
+ * @readonly
189
+ */
190
+ get isTransient(): boolean;
191
+ /**
192
+ * The symbol that this symbol's members have been moved to.
193
+ *
194
+ * @readonly
195
+ * @reactive
196
+ */
197
+ get movedTo(): OutputSymbol | undefined;
198
+ /**
199
+ * Whether this symbol's members have been moved to another symbol.
200
+ *
201
+ * @reactive
202
+ */
203
+ get isMoved(): boolean;
204
+ /**
205
+ * The symbol which defines the type of this symbol. The type symbol provides
206
+ * information about the value this symbol contains, such as what members it
207
+ * has.
208
+ *
209
+ * @reactive
210
+ */
211
+ get type(): OutputSymbol | Ref<OutputSymbol | undefined> | undefined;
212
+ set type(value: OutputSymbol | Ref<OutputSymbol | undefined> | undefined);
56
213
  /**
57
- * Takes the instance members or static members on this symbol and creates
58
- * corresponding static members on the target symbol. Instance or static
59
- * members of instantiated symbols are copied. The refkey of any instantiated
60
- * symbols are set to a composite refkey of the target symbol's refkey and the
61
- * instantiated symbol's refkey.
214
+ * Whether this symbol has its symbol representing its type available.
215
+ *
216
+ * @readonly
217
+ * @reactive
218
+ */
219
+ get hasTypeSymbol(): boolean;
220
+ /**
221
+ * Whether this symbol's members are provided by a type symbol. The
222
+ * `typeSymbol` property is this symbol. It may not be available yet, so check
223
+ * `hasTypeSymbol`.
62
224
  */
63
- instantiateTo(targetSymbol: OutputSymbol): void;
225
+ get isTyped(): boolean;
226
+ get namePolicy(): NamePolicyGetter | undefined;
227
+ [ReactiveFlags.SKIP]: boolean;
228
+ constructor(name: string | Namekey, spaces: OutputSpace[] | OutputSpace | undefined, options?: OutputSymbolOptions);
229
+ delete(): void;
64
230
  /**
65
- * Copy member symbols from the target symbol into the target symbol. The
66
- * copied symbols have their refkey set to
67
- * `refkey(targetSymbol.refkey, this.refkey)`.
231
+ * Move member symbols from this transient symbol to the target symbol. This is reactive -
232
+ * whenever a member is added to this symbol, it will be moved to the target
233
+ * symbol.
68
234
  */
69
- copyTo(targetSymbol: OutputSymbol): void;
235
+ moveMembersTo(targetSymbol: OutputSymbol): void;
70
236
  /**
71
- * Move member symbols from this transient symbol to the target symbol.
237
+ * Copy the members of this symbol to the target symbol. This is reactive -
238
+ * whenever a member is added to this symbol, it will be copied to the target
239
+ * symbol.
72
240
  */
73
- moveTo(targetSymbol: OutputSymbol): void;
241
+ copyMembersTo(targetSymbol: OutputSymbol): void;
74
242
  /**
75
243
  * Makes a copy of this symbol which will update the name and flags
76
244
  * of the clone when the original symbol is updated.
@@ -84,6 +252,14 @@ export declare class OutputSymbol {
84
252
  *
85
253
  * @param newScope - The scope to use for the copy.
86
254
  */
87
- copyToScope(newScope: OutputScope, baseSymbol?: OutputSymbol): OutputSymbol;
255
+ abstract copy(): OutputSymbol;
256
+ protected getCopyOptions(): {
257
+ binder: Binder | undefined;
258
+ aliasTarget: OutputSymbol | undefined;
259
+ metadata: Record<string, unknown>;
260
+ transient: boolean;
261
+ };
262
+ protected initializeCopy(copy: OutputSymbol): void;
263
+ [inspect.custom](): string;
88
264
  }
89
265
  //# sourceMappingURL=output-symbol.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"output-symbol.d.ts","sourceRoot":"","sources":["../../../src/symbols/output-symbol.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EAOd,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAI3C,OAAO,EAAoB,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAS7D,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,WAAW,CAAC,EAAE,YAAY,CAAC;CAC5B;AAID;;;;;;;;;GASG;AACH,qBAAa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