@alloy-js/core 0.20.0-dev.4 → 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.
- package/dist/src/binder.d.ts +62 -38
- package/dist/src/binder.d.ts.map +1 -1
- package/dist/src/binder.js +214 -173
- package/dist/src/components/Declaration.d.ts +2 -2
- package/dist/src/components/Declaration.d.ts.map +1 -1
- package/dist/src/components/Declaration.js +8 -2
- package/dist/src/components/MemberDeclaration.d.ts +2 -2
- package/dist/src/components/MemberDeclaration.d.ts.map +1 -1
- package/dist/src/components/MemberDeclaration.js +9 -5
- package/dist/src/components/MemberScope.d.ts +30 -13
- package/dist/src/components/MemberScope.d.ts.map +1 -1
- package/dist/src/components/MemberScope.js +37 -15
- package/dist/src/components/Output.d.ts.map +1 -1
- package/dist/src/components/Output.js +2 -5
- package/dist/src/components/ReferenceOrContent.d.ts +1 -1
- package/dist/src/components/ReferenceOrContent.d.ts.map +1 -1
- package/dist/src/components/Scope.d.ts +5 -5
- package/dist/src/components/Scope.d.ts.map +1 -1
- package/dist/src/components/Scope.js +9 -5
- package/dist/src/context/member-scope.d.ts +7 -8
- package/dist/src/context/member-scope.d.ts.map +1 -1
- package/dist/src/context/member-scope.js +5 -5
- package/dist/src/context/name-policy.d.ts.map +1 -1
- package/dist/src/context/name-policy.js +3 -0
- package/dist/src/context/scope.d.ts +1 -0
- package/dist/src/context/scope.d.ts.map +1 -1
- package/dist/src/context/scope.js +7 -0
- package/dist/src/inspect.browser.d.ts +5 -0
- package/dist/src/inspect.browser.d.ts.map +1 -0
- package/dist/src/inspect.browser.js +5 -0
- package/dist/src/inspect.d.ts +2 -0
- package/dist/src/inspect.d.ts.map +1 -0
- package/dist/src/inspect.js +1 -0
- package/dist/src/name-policy.d.ts +11 -0
- package/dist/src/name-policy.d.ts.map +1 -1
- package/dist/src/name-policy.js +3 -0
- package/dist/src/reactive-union-set.d.ts.map +1 -1
- package/dist/src/reactive-union-set.js +12 -8
- package/dist/src/refkey.d.ts +39 -3
- package/dist/src/refkey.d.ts.map +1 -1
- package/dist/src/refkey.js +52 -8
- package/dist/src/symbols/basic-scope.d.ts +14 -0
- package/dist/src/symbols/basic-scope.d.ts.map +1 -0
- package/dist/src/symbols/basic-scope.js +20 -0
- package/dist/src/symbols/basic-symbol.d.ts +19 -0
- package/dist/src/symbols/basic-symbol.d.ts.map +1 -0
- package/dist/src/symbols/basic-symbol.js +28 -0
- package/dist/src/symbols/index.d.ts +3 -1
- package/dist/src/symbols/index.d.ts.map +1 -1
- package/dist/src/symbols/index.js +3 -1
- package/dist/src/symbols/output-scope.d.ts +70 -41
- package/dist/src/symbols/output-scope.d.ts.map +1 -1
- package/dist/src/symbols/output-scope.js +98 -130
- package/dist/src/symbols/output-space.d.ts +25 -0
- package/dist/src/symbols/output-space.d.ts.map +1 -0
- package/dist/src/symbols/output-space.js +35 -0
- package/dist/src/symbols/output-symbol.d.ts +213 -37
- package/dist/src/symbols/output-symbol.d.ts.map +1 -1
- package/dist/src/symbols/output-symbol.js +323 -203
- package/dist/src/symbols/symbol-flow.d.ts +1 -1
- package/dist/src/symbols/symbol-flow.d.ts.map +1 -1
- package/dist/src/symbols/symbol-flow.js +22 -7
- package/dist/src/symbols/symbol-slot.d.ts +27 -9
- package/dist/src/symbols/symbol-slot.d.ts.map +1 -1
- package/dist/src/symbols/symbol-slot.js +20 -4
- package/dist/src/symbols/symbol-table.d.ts +19 -8
- package/dist/src/symbols/symbol-table.d.ts.map +1 -1
- package/dist/src/symbols/symbol-table.js +65 -16
- package/dist/src/tracer.d.ts +15 -3
- package/dist/src/tracer.d.ts.map +1 -1
- package/dist/src/tracer.js +39 -63
- package/dist/test/components/declaration.test.js +9 -14
- package/dist/test/components/reference-or-content.test.js +2 -2
- package/dist/test/symbols/output-scope.test.js +33 -198
- package/dist/test/symbols/output-symbol.test.js +139 -385
- package/dist/test/symbols/resolution.test.js +431 -114
- package/dist/test/symbols/symbol-table.test.d.ts +2 -0
- package/dist/test/symbols/symbol-table.test.d.ts.map +1 -0
- package/dist/test/symbols/symbol-table.test.js +14 -0
- package/dist/test/symbols/utils.d.ts +10 -24
- package/dist/test/symbols/utils.d.ts.map +1 -1
- package/dist/test/symbols/utils.js +23 -45
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -2
- package/src/binder.ts +348 -273
- package/src/components/Declaration.tsx +13 -3
- package/src/components/MemberDeclaration.tsx +15 -8
- package/src/components/MemberScope.tsx +61 -20
- package/src/components/Output.tsx +0 -4
- package/src/components/Scope.tsx +16 -9
- package/src/context/member-scope.ts +10 -10
- package/src/context/name-policy.ts +3 -0
- package/src/context/scope.ts +9 -0
- package/src/inspect.browser.ts +6 -0
- package/src/inspect.ts +1 -0
- package/src/name-policy.ts +14 -0
- package/src/reactive-union-set.ts +14 -8
- package/src/refkey.ts +88 -14
- package/src/symbols/basic-scope.ts +23 -0
- package/src/symbols/basic-symbol.ts +32 -0
- package/src/symbols/index.ts +3 -1
- package/src/symbols/output-scope.ts +131 -170
- package/src/symbols/output-space.ts +49 -0
- package/src/symbols/output-symbol.ts +434 -258
- package/src/symbols/symbol-flow.ts +38 -9
- package/src/symbols/symbol-slot.tsx +46 -8
- package/src/symbols/symbol-table.ts +95 -21
- package/src/tracer.ts +53 -83
- package/temp/api.json +5559 -3079
- package/test/components/declaration.test.tsx +6 -19
- package/test/components/reference-or-content.test.tsx +2 -2
- package/test/symbols/output-scope.test.ts +33 -125
- package/test/symbols/output-symbol.test.ts +128 -348
- package/test/symbols/resolution.test.ts +530 -117
- package/test/symbols/symbol-table.test.ts +15 -0
- package/test/symbols/utils.ts +38 -74
- package/tsdoc.json +4 -0
- package/dist/src/slot.d.ts +0 -15
- package/dist/src/slot.d.ts.map +0 -1
- package/dist/src/slot.js +0 -50
- package/dist/src/symbols/flags.d.ts +0 -70
- package/dist/src/symbols/flags.d.ts.map +0 -1
- package/dist/src/symbols/flags.js +0 -72
- package/dist/test/components/slot.test.d.ts +0 -2
- package/dist/test/components/slot.test.d.ts.map +0 -1
- package/dist/test/components/slot.test.js +0 -134
- package/src/slot.ts +0 -89
- package/src/symbols/flags.ts +0 -82
- package/test/components/slot.test.tsx +0 -174
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { reactive, ReactiveFlags, shallowReactive, track, TrackOpTypes, trigger, TriggerOpTypes, watch } from "@vue/reactivity";
|
|
1
|
+
import { isRef, reactive, ReactiveFlags, shallowReactive, track, TrackOpTypes, trigger, TriggerOpTypes, watch } from "@vue/reactivity";
|
|
2
2
|
import { useBinder } from "../context/binder.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { OutputScopeFlags, OutputSymbolFlags } from "./flags.js";
|
|
8
|
-
import { OutputScope } from "./output-scope.js";
|
|
3
|
+
import { inspect } from "../inspect.js";
|
|
4
|
+
import { untrack } from "../reactivity.js";
|
|
5
|
+
import { formatSymbol, formatSymbolName, trace, traceEffect, TracePhase } from "../tracer.js";
|
|
6
|
+
import { OutputMemberSpace } from "./output-space.js";
|
|
9
7
|
let symbolCount = 0;
|
|
10
8
|
|
|
11
9
|
/**
|
|
@@ -19,11 +17,25 @@ let symbolCount = 0;
|
|
|
19
17
|
* you can observe changes to their properties in a reactive context.
|
|
20
18
|
*/
|
|
21
19
|
export class OutputSymbol {
|
|
20
|
+
static memberSpaces = [];
|
|
22
21
|
#originalName;
|
|
22
|
+
/**
|
|
23
|
+
* Read only. The requested name of this symbol. The symbol's actual name may
|
|
24
|
+
* be different depending on naming policy or conflicts with other symbols.
|
|
25
|
+
*
|
|
26
|
+
* @readonly
|
|
27
|
+
*/
|
|
23
28
|
get originalName() {
|
|
24
29
|
return this.#originalName;
|
|
25
30
|
}
|
|
31
|
+
|
|
32
|
+
// this field is set by calling the name accessor.
|
|
26
33
|
#name;
|
|
34
|
+
/**
|
|
35
|
+
* The name of this symbol.
|
|
36
|
+
*
|
|
37
|
+
* @reactive
|
|
38
|
+
*/
|
|
27
39
|
get name() {
|
|
28
40
|
track(this, TrackOpTypes.GET, "name");
|
|
29
41
|
return this.#name;
|
|
@@ -33,63 +45,117 @@ export class OutputSymbol {
|
|
|
33
45
|
if (old === name) {
|
|
34
46
|
return;
|
|
35
47
|
}
|
|
36
|
-
this.#name = name;
|
|
48
|
+
this.#name = this.#namePolicy && !this.#ignoreNamePolicy ? this.#namePolicy(name) : name;
|
|
37
49
|
trigger(this, TriggerOpTypes.SET, "name", name, old);
|
|
38
50
|
}
|
|
39
51
|
#id;
|
|
52
|
+
/**
|
|
53
|
+
* The unique id of this symbol.
|
|
54
|
+
*
|
|
55
|
+
* @readonly
|
|
56
|
+
*/
|
|
40
57
|
get id() {
|
|
41
58
|
return this.#id;
|
|
42
59
|
}
|
|
43
|
-
#
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
60
|
+
#ignoreNamePolicy = false;
|
|
61
|
+
/**
|
|
62
|
+
* Whether the name of this symbol bypasses the active name policy. When true,
|
|
63
|
+
* the name of this symbol will be fixed, though it may conflict with other
|
|
64
|
+
* symbols which are also ignoring the name policy.
|
|
65
|
+
*
|
|
66
|
+
* @readonly
|
|
67
|
+
*/
|
|
68
|
+
get ignoreNamePolicy() {
|
|
69
|
+
return this.#ignoreNamePolicy;
|
|
47
70
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
71
|
+
#ignoreNameConflict = false;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Whether the name of this symbol bypasses the active name conflict
|
|
75
|
+
* resolution. When true, the name of this symbol will be fixed, though it may
|
|
76
|
+
* conflict with other symbols which are also ignoring name conflict
|
|
77
|
+
* resolution.
|
|
78
|
+
*/
|
|
79
|
+
get ignoreNameConflict() {
|
|
80
|
+
return this.#ignoreNameConflict;
|
|
57
81
|
}
|
|
58
|
-
#
|
|
82
|
+
#memberSpaces = shallowReactive({});
|
|
83
|
+
/**
|
|
84
|
+
* The member spaces of this symbol.
|
|
85
|
+
*
|
|
86
|
+
* @readonly
|
|
87
|
+
*/
|
|
88
|
+
get memberSpaces() {
|
|
89
|
+
return Object.values(this.#memberSpaces);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Get the member space for the given key.
|
|
94
|
+
*/
|
|
95
|
+
memberSpaceFor(spaceKey) {
|
|
96
|
+
return this.#memberSpaces[spaceKey];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* The scope this symbol is in. When this symbol is a member symbol, this will
|
|
101
|
+
* return undefined.
|
|
102
|
+
*
|
|
103
|
+
* @readonly
|
|
104
|
+
*/
|
|
59
105
|
get scope() {
|
|
60
|
-
|
|
61
|
-
|
|
106
|
+
if (this.isMemberSymbol) {
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
if (this.spaces.length === 0) {
|
|
110
|
+
return undefined;
|
|
111
|
+
}
|
|
112
|
+
return this.spaces[0].scope;
|
|
62
113
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
114
|
+
#spaces;
|
|
115
|
+
/**
|
|
116
|
+
* The declaration or member spaces this symbol belongs to.
|
|
117
|
+
*
|
|
118
|
+
* @reactive
|
|
119
|
+
*/
|
|
120
|
+
get spaces() {
|
|
121
|
+
track(this, TrackOpTypes.GET, "spaces");
|
|
122
|
+
return this.#spaces;
|
|
123
|
+
}
|
|
124
|
+
set spaces(spaces) {
|
|
125
|
+
const old = this.#spaces;
|
|
126
|
+
if (old === spaces) {
|
|
66
127
|
return;
|
|
67
128
|
}
|
|
68
|
-
|
|
69
|
-
this.#
|
|
70
|
-
|
|
129
|
+
const spacesArray = spaces === undefined ? [] : Array.isArray(spaces) ? spaces : [spaces];
|
|
130
|
+
this.#handleNewSpaces(spacesArray, old);
|
|
131
|
+
this.#spaces = spacesArray;
|
|
132
|
+
trigger(this, TriggerOpTypes.SET, "spaces", spaces, old);
|
|
71
133
|
}
|
|
72
|
-
#
|
|
73
|
-
if (
|
|
134
|
+
#handleNewSpaces(newSpaces, oldSpaces) {
|
|
135
|
+
if (oldSpaces) {
|
|
74
136
|
// ensure when changing scope that this symbol only belongs to one of them
|
|
75
|
-
|
|
137
|
+
oldSpaces.forEach(oldSpace => oldSpace.delete(this));
|
|
76
138
|
}
|
|
77
|
-
if (
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
newScope.symbols.add(this);
|
|
81
|
-
if (newScope.flags & OutputScopeFlags.InstanceMemberScope) {
|
|
82
|
-
this.flags |= OutputSymbolFlags.InstanceMember;
|
|
83
|
-
}
|
|
84
|
-
if (newScope.flags & OutputScopeFlags.StaticMemberScope) {
|
|
85
|
-
this.flags |= OutputSymbolFlags.StaticMember;
|
|
139
|
+
if (newSpaces) {
|
|
140
|
+
newSpaces.forEach(newSpace => newSpace.add(this));
|
|
86
141
|
}
|
|
87
142
|
}
|
|
88
143
|
#binder;
|
|
144
|
+
/**
|
|
145
|
+
* The binder that is tracking this symbol.
|
|
146
|
+
*
|
|
147
|
+
* @readonly
|
|
148
|
+
*/
|
|
89
149
|
get binder() {
|
|
90
150
|
return this.#binder;
|
|
91
151
|
}
|
|
92
152
|
#refkeys;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* The refkeys for this symbol.
|
|
156
|
+
*
|
|
157
|
+
* @reactive
|
|
158
|
+
*/
|
|
93
159
|
get refkeys() {
|
|
94
160
|
track(this, TrackOpTypes.GET, "refkeys");
|
|
95
161
|
return this.#refkeys;
|
|
@@ -102,169 +168,250 @@ export class OutputSymbol {
|
|
|
102
168
|
this.#refkeys = shallowReactive(Array.isArray(refkeys) ? refkeys : [refkeys]);
|
|
103
169
|
trigger(this, TriggerOpTypes.SET, "refkeys", this.#refkeys, old);
|
|
104
170
|
}
|
|
105
|
-
#instanceMemberScope;
|
|
106
|
-
get instanceMemberScope() {
|
|
107
|
-
track(this, TrackOpTypes.GET, "instanceMemberScope");
|
|
108
|
-
return this.#instanceMemberScope;
|
|
109
|
-
}
|
|
110
171
|
#aliasTarget;
|
|
172
|
+
/**
|
|
173
|
+
* The symbol that this symbol is an alias for.
|
|
174
|
+
*
|
|
175
|
+
* @readonly
|
|
176
|
+
*/
|
|
111
177
|
get aliasTarget() {
|
|
112
178
|
return this.#aliasTarget;
|
|
113
179
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* If this symbol is an alias for another symbol, return the the aliased symbol. Otherwise, return this symbol.
|
|
183
|
+
*/
|
|
184
|
+
dealias() {
|
|
185
|
+
if (this.#aliasTarget) {
|
|
186
|
+
return this.#aliasTarget.dealias();
|
|
117
187
|
}
|
|
118
|
-
|
|
119
|
-
binder: this.#binder,
|
|
120
|
-
owner: this,
|
|
121
|
-
flags: OutputScopeFlags.InstanceMemberScope
|
|
122
|
-
});
|
|
123
|
-
trigger(this, TriggerOpTypes.SET, "instanceMemberScope", this.#instanceMemberScope, undefined);
|
|
188
|
+
return this;
|
|
124
189
|
}
|
|
125
190
|
|
|
126
191
|
/**
|
|
127
|
-
*
|
|
128
|
-
*
|
|
192
|
+
* Whether this symbol is an alias for another symbol.
|
|
193
|
+
*
|
|
194
|
+
* @readonly
|
|
129
195
|
*/
|
|
130
|
-
|
|
131
|
-
return
|
|
132
|
-
binder: this.#binder,
|
|
133
|
-
owner: options.owner,
|
|
134
|
-
flags: options.flags
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
#staticMemberScope;
|
|
138
|
-
get staticMemberScope() {
|
|
139
|
-
track(this, TrackOpTypes.GET, "staticMemberScope");
|
|
140
|
-
return this.#staticMemberScope;
|
|
141
|
-
}
|
|
142
|
-
#createStaticMemberScope() {
|
|
143
|
-
if (this.#staticMemberScope || !(this.#flags & OutputSymbolFlags.StaticMemberContainer)) {
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
this.#staticMemberScope = new OutputScope(`${this.name} static members`, {
|
|
147
|
-
binder: this.#binder,
|
|
148
|
-
owner: this,
|
|
149
|
-
flags: OutputScopeFlags.StaticMemberScope
|
|
150
|
-
});
|
|
151
|
-
trigger(this, TriggerOpTypes.SET, "staticMemberScope", this.#staticMemberScope, undefined);
|
|
196
|
+
get isAlias() {
|
|
197
|
+
return !!this.#aliasTarget;
|
|
152
198
|
}
|
|
153
199
|
#metadata;
|
|
200
|
+
/**
|
|
201
|
+
* An arbitrary bag of metadata for this symbol. This property is read only,
|
|
202
|
+
* but the metadata is a reactive object.
|
|
203
|
+
*
|
|
204
|
+
* @readonly
|
|
205
|
+
*/
|
|
154
206
|
get metadata() {
|
|
155
207
|
return this.#metadata;
|
|
156
208
|
}
|
|
209
|
+
copyToSpace(space) {
|
|
210
|
+
const copy = this.copy();
|
|
211
|
+
copy.spaces = space;
|
|
212
|
+
return copy;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Whether this symbol is a member of another symbol.
|
|
217
|
+
*
|
|
218
|
+
* @readonly
|
|
219
|
+
*/
|
|
220
|
+
get isMemberSymbol() {
|
|
221
|
+
return this.spaces[0] instanceof OutputMemberSpace;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* When this is a member symbol, this returns the symbol that this is symbol
|
|
226
|
+
* is a member of.
|
|
227
|
+
*/
|
|
228
|
+
get ownerSymbol() {
|
|
229
|
+
if (!this.isMemberSymbol) {
|
|
230
|
+
return undefined;
|
|
231
|
+
}
|
|
232
|
+
return this.spaces[0].symbol;
|
|
233
|
+
}
|
|
234
|
+
#isTransient;
|
|
157
235
|
|
|
158
236
|
/**
|
|
159
|
-
*
|
|
160
|
-
*
|
|
237
|
+
* Whether this symbol is a transient symbol. Transient symbols cannot be
|
|
238
|
+
* referenced and are meant to be combined with other symbols.
|
|
239
|
+
*
|
|
240
|
+
* @readonly
|
|
161
241
|
*/
|
|
242
|
+
get isTransient() {
|
|
243
|
+
if (this.#isTransient) {
|
|
244
|
+
return true;
|
|
245
|
+
}
|
|
246
|
+
if (this.ownerSymbol) {
|
|
247
|
+
return this.ownerSymbol.isTransient;
|
|
248
|
+
}
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
#movedTo;
|
|
252
|
+
/**
|
|
253
|
+
* The symbol that this symbol's members have been moved to.
|
|
254
|
+
*
|
|
255
|
+
* @readonly
|
|
256
|
+
* @reactive
|
|
257
|
+
*/
|
|
258
|
+
get movedTo() {
|
|
259
|
+
track(this, TrackOpTypes.GET, "movedTo");
|
|
260
|
+
return this.#movedTo;
|
|
261
|
+
}
|
|
262
|
+
#setMovedTo(value) {
|
|
263
|
+
this.#movedTo = value;
|
|
264
|
+
trigger(this, TriggerOpTypes.SET, "movedTo");
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Whether this symbol's members have been moved to another symbol.
|
|
269
|
+
*
|
|
270
|
+
* @reactive
|
|
271
|
+
*/
|
|
272
|
+
get isMoved() {
|
|
273
|
+
return this.movedTo !== undefined;
|
|
274
|
+
}
|
|
275
|
+
#type;
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* The symbol which defines the type of this symbol. The type symbol provides
|
|
279
|
+
* information about the value this symbol contains, such as what members it
|
|
280
|
+
* has.
|
|
281
|
+
*
|
|
282
|
+
* @reactive
|
|
283
|
+
*/
|
|
284
|
+
get type() {
|
|
285
|
+
track(this, TrackOpTypes.GET, "type");
|
|
286
|
+
return this.#type;
|
|
287
|
+
}
|
|
288
|
+
set type(value) {
|
|
289
|
+
if (isRef(value)) {
|
|
290
|
+
watch(value, newValue => {
|
|
291
|
+
const old = this.#type;
|
|
292
|
+
this.#type = newValue && newValue.dealias();
|
|
293
|
+
trigger(this, TriggerOpTypes.SET, "type", newValue, old);
|
|
294
|
+
});
|
|
295
|
+
} else {
|
|
296
|
+
const old = this.#type;
|
|
297
|
+
this.#type = value && value.dealias();
|
|
298
|
+
trigger(this, TriggerOpTypes.SET, "type", value, old);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Whether this symbol has its symbol representing its type available.
|
|
304
|
+
*
|
|
305
|
+
* @readonly
|
|
306
|
+
* @reactive
|
|
307
|
+
*/
|
|
308
|
+
get hasTypeSymbol() {
|
|
309
|
+
return this.type !== undefined;
|
|
310
|
+
}
|
|
311
|
+
#isTyped = false;
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Whether this symbol's members are provided by a type symbol. The
|
|
315
|
+
* `typeSymbol` property is this symbol. It may not be available yet, so check
|
|
316
|
+
* `hasTypeSymbol`.
|
|
317
|
+
*/
|
|
318
|
+
get isTyped() {
|
|
319
|
+
return this.#isTyped;
|
|
320
|
+
}
|
|
321
|
+
#namePolicy;
|
|
322
|
+
get namePolicy() {
|
|
323
|
+
return this.#namePolicy;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// Tell \@vue/reactivity that this symbol should never be wrapped in a reactive
|
|
327
|
+
// proxy.
|
|
162
328
|
[ReactiveFlags.SKIP] = true;
|
|
163
|
-
constructor(name, options = {}) {
|
|
329
|
+
constructor(name, spaces, options = {}) {
|
|
164
330
|
this.#binder = options.binder ?? useBinder();
|
|
165
|
-
this.#
|
|
166
|
-
|
|
331
|
+
this.#namePolicy = options.namePolicy;
|
|
332
|
+
if (typeof name === "string") {
|
|
333
|
+
this.#ignoreNameConflict = !!options.ignoreNameConflict;
|
|
334
|
+
this.#ignoreNamePolicy = !!options.ignoreNamePolicy;
|
|
335
|
+
this.name = name;
|
|
336
|
+
this.#originalName = name;
|
|
337
|
+
this.#refkeys = shallowReactive(this.#normalizeRefkeyOption(options.refkeys));
|
|
338
|
+
} else {
|
|
339
|
+
this.#ignoreNameConflict = name.options.ignoreNameConflict ?? !!options.ignoreNameConflict;
|
|
340
|
+
this.#ignoreNamePolicy = name.options.ignoreNamePolicy ?? !!options.ignoreNamePolicy;
|
|
341
|
+
this.name = name.name;
|
|
342
|
+
this.#originalName = name.name;
|
|
343
|
+
this.#refkeys = shallowReactive([name, ...this.#normalizeRefkeyOption(options.refkeys)]);
|
|
344
|
+
}
|
|
167
345
|
this.#id = symbolCount++;
|
|
168
|
-
this.#
|
|
169
|
-
this.#scope = options.scope ?? this.#defaultScope();
|
|
346
|
+
this.#spaces = Array.isArray(spaces) ? spaces : spaces === undefined ? [] : [spaces];
|
|
170
347
|
this.#aliasTarget = options.aliasTarget;
|
|
171
|
-
if (this.#aliasTarget) {
|
|
172
|
-
this.#flags |= OutputSymbolFlags.Alias;
|
|
173
|
-
this.#flags &= ~(OutputSymbolFlags.MemberContainer | OutputSymbolFlags.Member);
|
|
174
|
-
}
|
|
175
|
-
this.#refkeys = shallowReactive(Array.isArray(options.refkeys) ? options.refkeys : isRefkey(options.refkeys) ? [options.refkeys] : []);
|
|
176
348
|
this.#metadata = reactive(options.metadata ?? {});
|
|
177
|
-
this.#
|
|
178
|
-
this.#
|
|
179
|
-
this
|
|
349
|
+
this.#isTransient = !!options.transient;
|
|
350
|
+
this.#isTyped = !!options.type;
|
|
351
|
+
this.type = options.type;
|
|
352
|
+
this.#handleNewSpaces(this.#spaces);
|
|
353
|
+
const constructor = this.constructor;
|
|
354
|
+
this.#memberSpaces = Object.fromEntries(constructor.memberSpaces.map(spaceKey => [spaceKey, new OutputMemberSpace(this, spaceKey, this.#binder)]));
|
|
180
355
|
trace(TracePhase.symbol.create, () => `${formatSymbol(this)}`);
|
|
181
356
|
traceEffect(TracePhase.symbol.update, () => {
|
|
182
357
|
return `${formatSymbol(this)}`;
|
|
183
358
|
});
|
|
184
359
|
this.#binder?.notifySymbolCreated(this);
|
|
185
360
|
}
|
|
361
|
+
#normalizeRefkeyOption(refkeys) {
|
|
362
|
+
if (refkeys === undefined) {
|
|
363
|
+
return [];
|
|
364
|
+
} else if (Array.isArray(refkeys)) {
|
|
365
|
+
return refkeys;
|
|
366
|
+
} else {
|
|
367
|
+
return [refkeys];
|
|
368
|
+
}
|
|
369
|
+
}
|
|
186
370
|
delete() {
|
|
187
371
|
trace(TracePhase.symbol.delete, () => `${formatSymbolName(this)}`);
|
|
188
|
-
if (this.#
|
|
189
|
-
this.#
|
|
372
|
+
if (this.#spaces) {
|
|
373
|
+
this.#spaces.forEach(space => space.delete(this));
|
|
190
374
|
}
|
|
191
375
|
this.#binder?.notifySymbolDeleted(this);
|
|
192
376
|
}
|
|
193
377
|
|
|
194
378
|
/**
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
* symbols are set to a composite refkey of the target symbol's refkey and the
|
|
199
|
-
* instantiated symbol's refkey.
|
|
379
|
+
* Move member symbols from this transient symbol to the target symbol. This is reactive -
|
|
380
|
+
* whenever a member is added to this symbol, it will be moved to the target
|
|
381
|
+
* symbol.
|
|
200
382
|
*/
|
|
201
|
-
|
|
383
|
+
moveMembersTo(targetSymbol) {
|
|
202
384
|
if (this.#aliasTarget) {
|
|
203
|
-
return this.#aliasTarget.
|
|
385
|
+
return this.#aliasTarget.moveMembersTo(targetSymbol);
|
|
204
386
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
});
|
|
208
|
-
const from = this.#instanceMemberScope ?? this.#staticMemberScope;
|
|
209
|
-
if (from) {
|
|
210
|
-
targetSymbol.flags |= OutputSymbolFlags.StaticMemberContainer;
|
|
211
|
-
targetSymbol.#createStaticMemberScope();
|
|
212
|
-
targetSymbol.#staticMemberScope.copySymbolsFrom(from, {
|
|
213
|
-
onAdd: symbol => {
|
|
214
|
-
const clone = symbol.copyToScope(targetSymbol.#staticMemberScope, targetSymbol);
|
|
215
|
-
clone.#flags &= ~OutputSymbolFlags.InstanceMember;
|
|
216
|
-
clone.#flags |= OutputSymbolFlags.StaticMember;
|
|
217
|
-
return clone;
|
|
218
|
-
}
|
|
219
|
-
});
|
|
387
|
+
if (!this.isTransient) {
|
|
388
|
+
throw new Error("Can only move members from transient symbols");
|
|
220
389
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
for (const targetRk of member.refkeys) {
|
|
226
|
-
instantiationRks.push(refkey(baseRk, targetRk));
|
|
390
|
+
for (const sourceSpace of this.memberSpaces) {
|
|
391
|
+
const targetSpace = targetSymbol.memberSpaceFor(sourceSpace.key);
|
|
392
|
+
if (!targetSpace) {
|
|
393
|
+
throw new Error("Target symbol doesn't have member space " + sourceSpace.key);
|
|
227
394
|
}
|
|
395
|
+
sourceSpace.moveTo(targetSpace);
|
|
228
396
|
}
|
|
229
|
-
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* Copy member symbols from the target symbol into the target symbol. The
|
|
234
|
-
* copied symbols have their refkey set to
|
|
235
|
-
* `refkey(targetSymbol.refkey, this.refkey)`.
|
|
236
|
-
*/
|
|
237
|
-
copyTo(targetSymbol) {
|
|
238
|
-
if (this.#aliasTarget) {
|
|
239
|
-
return this.#aliasTarget.copyTo(targetSymbol);
|
|
240
|
-
}
|
|
241
|
-
if (this.staticMemberScope) {
|
|
242
|
-
targetSymbol.flags |= OutputSymbolFlags.StaticMemberContainer;
|
|
243
|
-
targetSymbol.staticMemberScope.copySymbolsFrom(this.staticMemberScope);
|
|
244
|
-
}
|
|
245
|
-
if (this.instanceMemberScope) {
|
|
246
|
-
targetSymbol.flags |= OutputSymbolFlags.InstanceMemberContainer;
|
|
247
|
-
targetSymbol.instanceMemberScope.copySymbolsFrom(this.instanceMemberScope);
|
|
248
|
-
}
|
|
397
|
+
this.#setMovedTo(targetSymbol);
|
|
249
398
|
}
|
|
250
399
|
|
|
251
400
|
/**
|
|
252
|
-
*
|
|
401
|
+
* Copy the members of this symbol to the target symbol. This is reactive -
|
|
402
|
+
* whenever a member is added to this symbol, it will be copied to the target
|
|
403
|
+
* symbol.
|
|
253
404
|
*/
|
|
254
|
-
|
|
405
|
+
copyMembersTo(targetSymbol) {
|
|
255
406
|
if (this.#aliasTarget) {
|
|
256
|
-
return this.#aliasTarget.
|
|
257
|
-
}
|
|
258
|
-
if (!(this.flags & OutputSymbolFlags.Transient)) {
|
|
259
|
-
throw new Error("Can only move members from transient symbols");
|
|
260
|
-
}
|
|
261
|
-
if (this.staticMemberScope) {
|
|
262
|
-
targetSymbol.flags |= OutputSymbolFlags.StaticMemberContainer;
|
|
263
|
-
targetSymbol.staticMemberScope.moveSymbolsFrom(this.staticMemberScope);
|
|
407
|
+
return this.#aliasTarget.copyMembersTo(targetSymbol);
|
|
264
408
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
409
|
+
for (const sourceSpace of this.memberSpaces) {
|
|
410
|
+
const targetSpace = targetSymbol.memberSpaceFor(sourceSpace.key);
|
|
411
|
+
if (!targetSpace) {
|
|
412
|
+
throw new Error("Target symbol doesn't have member space " + sourceSpace.key);
|
|
413
|
+
}
|
|
414
|
+
sourceSpace.copyTo(targetSpace);
|
|
268
415
|
}
|
|
269
416
|
}
|
|
270
417
|
|
|
@@ -281,53 +428,26 @@ export class OutputSymbol {
|
|
|
281
428
|
*
|
|
282
429
|
* @param newScope - The scope to use for the copy.
|
|
283
430
|
*/
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
binder: this.#binder,
|
|
293
|
-
scope: newScope,
|
|
294
|
-
flags: this.#flags,
|
|
295
|
-
refkeys: baseSymbol ? this.#instantiationRk(baseSymbol, this) : [],
|
|
296
|
-
metadata: this.#metadata
|
|
297
|
-
});
|
|
298
|
-
if (this.instanceMemberScope) {
|
|
299
|
-
clone.#instanceMemberScope = this.instanceMemberScope.clone({
|
|
300
|
-
owner: clone
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
if (this.staticMemberScope) {
|
|
304
|
-
clone.#staticMemberScope = this.staticMemberScope.clone({
|
|
305
|
-
owner: clone
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
watch(() => this.name, newName => clone.name = newName);
|
|
309
|
-
watch(() => this.flags, newFlags => clone.flags = newFlags);
|
|
310
|
-
return clone;
|
|
431
|
+
|
|
432
|
+
getCopyOptions() {
|
|
433
|
+
return {
|
|
434
|
+
binder: this.binder,
|
|
435
|
+
aliasTarget: this.aliasTarget,
|
|
436
|
+
metadata: this.metadata,
|
|
437
|
+
transient: this.isTransient
|
|
438
|
+
};
|
|
311
439
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
if (!memberScope) {
|
|
318
|
-
throw new Error("Cannot declare member symbols without a member scope");
|
|
319
|
-
}
|
|
320
|
-
if (this.#flags & OutputSymbolFlags.InstanceMember) {
|
|
321
|
-
if (!memberScope.instanceMembers) {
|
|
322
|
-
throw new Error("Cannot declare instance member symbols without an instance member scope");
|
|
323
|
-
}
|
|
324
|
-
return memberScope.instanceMembers;
|
|
325
|
-
} else {
|
|
326
|
-
if (!memberScope.staticMembers) {
|
|
327
|
-
throw new Error("Cannot declare static member symbols without a static member scope");
|
|
328
|
-
}
|
|
329
|
-
return memberScope.staticMembers;
|
|
440
|
+
initializeCopy(copy) {
|
|
441
|
+
for (const sourceSpace of this.memberSpaces) {
|
|
442
|
+
const targetSpace = copy.memberSpaceFor(sourceSpace.key);
|
|
443
|
+
if (!targetSpace) {
|
|
444
|
+
throw new Error("Target doesn't have space " + sourceSpace.key);
|
|
330
445
|
}
|
|
446
|
+
sourceSpace.copyTo(targetSpace);
|
|
331
447
|
}
|
|
448
|
+
watch(() => this.name, newName => copy.name = newName);
|
|
449
|
+
}
|
|
450
|
+
[inspect.custom]() {
|
|
451
|
+
return untrack(() => `${this.constructor.name} "${this.name}"[${this.id}]`);
|
|
332
452
|
}
|
|
333
453
|
}
|
|
@@ -9,5 +9,5 @@ export interface TakeSymbolsCallback {
|
|
|
9
9
|
export declare function takeSymbols(cb?: (symbol: OutputSymbol) => void): import("@vue/reactivity").ShallowReactive<Set<OutputSymbol>>;
|
|
10
10
|
export declare function emitSymbol(symbol: OutputSymbol | Ref<OutputSymbol | undefined>): void;
|
|
11
11
|
export declare function moveTakenMembersTo(baseSymbol: OutputSymbol): void;
|
|
12
|
-
export declare function instantiateTakenMembersTo(baseSymbol: OutputSymbol): void;
|
|
12
|
+
export declare function instantiateTakenMembersTo(baseSymbol: OutputSymbol, toSpaceKey: string, fromSpaceKey: string): void;
|
|
13
13
|
//# sourceMappingURL=symbol-flow.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"symbol-flow.d.ts","sourceRoot":"","sources":["../../../src/symbols/symbol-flow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,GAAG,EAAmB,MAAM,iBAAiB,CAAC;AAM9D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,WAAW,kBAAkB;IACjC,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;CAC9B;AAED,MAAM,WAAW,mBAAmB;IAClC,CAAC,OAAO,EAAE,GAAG,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;CACpC;AAED,wBAAgB,WAAW,CAAC,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,gEAiB9D;AAED,wBAAgB,UAAU,CACxB,MAAM,EAAE,YAAY,GAAG,GAAG,CAAC,YAAY,GAAG,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"symbol-flow.d.ts","sourceRoot":"","sources":["../../../src/symbols/symbol-flow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,GAAG,EAAmB,MAAM,iBAAiB,CAAC;AAM9D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,WAAW,kBAAkB;IACjC,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;CAC9B;AAED,MAAM,WAAW,mBAAmB;IAClC,CAAC,OAAO,EAAE,GAAG,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;CACpC;AAED,wBAAgB,WAAW,CAAC,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,gEAiB9D;AAED,wBAAgB,UAAU,CACxB,MAAM,EAAE,YAAY,GAAG,GAAG,CAAC,YAAY,GAAG,SAAS,CAAC,QAiErD;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,YAAY,QAe1D;AAED,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,YAAY,EACxB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,QAKrB"}
|